OSDN Git Service

Add a missing null check inside A2dpService.resetAvrcpBlacklist()
authorPavlin Radoslavov <pavlin@google.com>
Tue, 29 Mar 2016 23:41:08 +0000 (16:41 -0700)
committerPavlin Radoslavov <pavlin@google.com>
Wed, 30 Mar 2016 04:25:47 +0000 (21:25 -0700)
Add a missing null pointer check inside method
A2dpService.resetAvrcpBlacklist()

Also:
 - Removed BondStateMachine.setProfilePriority() because it is
   not used.
 - Fix a typo "priorty" -> "priority"
 - Fix a log message.

Bug: 27837879
Change-Id: Ieabf00d2ff1e49aa06598674f14e97eb9086d432

jni/com_android_bluetooth_sdp.cpp
src/com/android/bluetooth/a2dp/A2dpService.java
src/com/android/bluetooth/btservice/BondStateMachine.java

index dde5e54..889ab7b 100644 (file)
@@ -547,7 +547,7 @@ static void cleanupNative(JNIEnv *env, jobject object) {
     }
 
     if (sCallbacksObj != NULL) {
-        ALOGW("Cleaning up Bluetooth Health object");
+        ALOGW("Cleaning up Bluetooth SDP object");
         env->DeleteGlobalRef(sCallbacksObj);
         sCallbacksObj = NULL;
     }
index a278927..41c31d1 100755 (executable)
@@ -214,7 +214,9 @@ public class A2dpService extends ProfileService {
     }
 
     public void resetAvrcpBlacklist(BluetoothDevice device) {
-        mAvrcp.resetBlackList(device.getAddress());
+        if (mAvrcp != null) {
+            mAvrcp.resetBlackList(device.getAddress());
+        }
     }
 
     synchronized boolean isA2dpPlaying(BluetoothDevice device) {
index 790597f..353157e 100644 (file)
@@ -216,15 +216,7 @@ final class BondStateMachine extends StateMachine {
                             mAdapterService.setSimAccessPermission(dev,
                                     BluetoothDevice.ACCESS_UNKNOWN);
                             // Set the profile Priorities to undefined
-                            clearProfilePriorty(dev);
-                        }
-                        else if (newState == BluetoothDevice.BOND_BONDED)
-                        {
-                           // Do not set profile priority
-                           // Profile priority should be set after SDP completion
-
-                           // Restore the profile priorty settings
-                           //setProfilePriorty(dev);
+                            clearProfilePriority(dev);
                         }
                     }
                     else if(!mDevices.contains(dev))
@@ -450,28 +442,7 @@ final class BondStateMachine extends StateMachine {
         sendMessage(msg);
     }
 
-    private void setProfilePriorty (BluetoothDevice device){
-        HidService hidService = HidService.getHidService();
-        A2dpService a2dpService = A2dpService.getA2dpService();
-        HeadsetService headsetService = HeadsetService.getHeadsetService();
-
-        if ((hidService != null) &&
-            (hidService.getPriority(device) == BluetoothProfile.PRIORITY_UNDEFINED)){
-            hidService.setPriority(device,BluetoothProfile.PRIORITY_ON);
-        }
-
-        if ((a2dpService != null) &&
-            (a2dpService.getPriority(device) == BluetoothProfile.PRIORITY_UNDEFINED)){
-            a2dpService.setPriority(device,BluetoothProfile.PRIORITY_ON);
-        }
-
-        if ((headsetService != null) &&
-            (headsetService.getPriority(device) == BluetoothProfile.PRIORITY_UNDEFINED)){
-            headsetService.setPriority(device,BluetoothProfile.PRIORITY_ON);
-        }
-    }
-
-    private void clearProfilePriorty (BluetoothDevice device){
+    private void clearProfilePriority(BluetoothDevice device) {
         HidService hidService = HidService.getHidService();
         A2dpService a2dpService = A2dpService.getA2dpService();
         HeadsetService headsetService = HeadsetService.getHeadsetService();