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

Commit 4a10ee98 authored by weichinweng's avatar weichinweng
Browse files

Support set active device to null.

Since some process will call removeActiveDevice for setting device to
null. But below current logic, if the device is null will skip the
action. The patch is that add check if the deivce is null, will directly
set the active to null.

Bug: 152581026
Test: Manual
Change-Id: Ib4c00d75e0de0581abf993469a029e02d36d608e
parent 538a1ade
Loading
Loading
Loading
Loading
+12 −9
Original line number Original line Diff line number Diff line
@@ -2345,21 +2345,24 @@ public class AdapterService extends Service {
                return false;
                return false;
        }
        }


        if (setA2dp && mA2dpService != null && mA2dpService.getConnectionPolicy(device)
        if (setA2dp && mA2dpService != null && (device == null
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
                || mA2dpService.getConnectionPolicy(device)
            Log.i(TAG, "setActiveDevice: Setting active A2dp device " + device.getAddress());
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED)) {
            Log.i(TAG, "setActiveDevice: Setting active A2dp device " + device);
            mA2dpService.setActiveDevice(device);
            mA2dpService.setActiveDevice(device);
        }
        }


        if (mHearingAidService != null && mHearingAidService.getConnectionPolicy(device)
        if (mHearingAidService != null && (device == null
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
                || mHearingAidService.getConnectionPolicy(device)
            Log.i(TAG, "setActiveDevice: Setting active Hearing Aid " + device.getAddress());
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED)) {
            Log.i(TAG, "setActiveDevice: Setting active Hearing Aid " + device);
            mHearingAidService.setActiveDevice(device);
            mHearingAidService.setActiveDevice(device);
        }
        }


        if (setHeadset && mHeadsetService != null && mHeadsetService.getConnectionPolicy(device)
        if (setHeadset && mHeadsetService != null && (device == null
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
                || mHeadsetService.getConnectionPolicy(device)
            Log.i(TAG, "setActiveDevice: Setting active Headset " + device.getAddress());
                == BluetoothProfile.CONNECTION_POLICY_ALLOWED)) {
            Log.i(TAG, "setActiveDevice: Setting active Headset " + device);
            mHeadsetService.setActiveDevice(device);
            mHeadsetService.setActiveDevice(device);
        }
        }