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

Commit 01b1c64a authored by xutianguo's avatar xutianguo Committed by Myles Watson
Browse files

Fix potenial NPE in PhonePolicy



NPE might happen in PhonePolicy since HeadsetService could be null.

Bug: NA
Test: Connect Bluetooth devices and check A2DP/HeadSet profiles

Change-Id: Ib90147b407bc80675ba027f4c6cac94ae39a1d7b
Signed-off-by: default avatarxutianguo <xutianguo@xiaomi.com>
parent 5cae5fbd
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -387,9 +387,10 @@ class PhonePolicy {
        switch (profileId) {
            case BluetoothProfile.HEADSET:
                HeadsetService hsService = mFactory.getHeadsetService();
                List<BluetoothDevice> deviceList = hsService.getConnectedDevices();
                if ((hsService != null) && (BluetoothProfile.PRIORITY_AUTO_CONNECT
                if ((hsService != null)
                        && (BluetoothProfile.PRIORITY_AUTO_CONNECT
                                   != hsService.getPriority(device))) {
                    List<BluetoothDevice> deviceList = hsService.getConnectedDevices();
                    adjustOtherHeadsetPriorities(hsService, deviceList);
                    hsService.setPriority(device, BluetoothProfile.PRIORITY_AUTO_CONNECT);
                }