Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f924b023 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Add a missing null check inside A2dpService.resetAvrcpBlacklist()

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
parent fa088217
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
    }
+3 −1
Original line number Diff line number Diff line
@@ -214,8 +214,10 @@ public class A2dpService extends ProfileService {
    }

    public void resetAvrcpBlacklist(BluetoothDevice device) {
        if (mAvrcp != null) {
            mAvrcp.resetBlackList(device.getAddress());
        }
    }

    synchronized boolean isA2dpPlaying(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM,
+2 −31
Original line number Diff line number Diff line
@@ -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();