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

Commit f811c706 authored by Tyler Gunn's avatar Tyler Gunn Committed by Automerger Merge Worker
Browse files

Merge "BluetoothDeviceManager.java: add null check before call...

Merge "BluetoothDeviceManager.java: add null check before call mBluetoothAdapter.getActiveDevices" am: a017a975

Original change: https://android-review.googlesource.com/c/platform/packages/services/Telecomm/+/1853961

Change-Id: Ib53d2169baae372a95d443e3693b659a91cd525e
parents b9fc508c a017a975
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ public class BluetoothDeviceManager {
        Set<Long> seenHiSyncIds = new LinkedHashSet<>();
        // Add the left-most active device to the seen list so that we match up with the list
        // generated in BluetoothRouteManager.
        if (mBluetoothAdapter != null) {
            for (BluetoothDevice device : mBluetoothAdapter.getActiveDevices(
                        BluetoothProfile.HEARING_AID)) {
                if (device != null) {
@@ -165,6 +166,7 @@ public class BluetoothDeviceManager {
                    break;
                }
            }
        }
        synchronized (mLock) {
            for (BluetoothDevice d : mHearingAidDevicesByAddress.values()) {
                long hiSyncId = mHearingAidDeviceSyncIds.getOrDefault(d, -1L);
@@ -244,12 +246,14 @@ public class BluetoothDeviceManager {
    }

    public void disconnectAudio() {
        if (mBluetoothAdapter != null) {
            for (BluetoothDevice device: mBluetoothAdapter.getActiveDevices(
                        BluetoothProfile.HEARING_AID)) {
                if (device != null) {
                    mBluetoothAdapter.setActiveDevice(null, BluetoothAdapter.ACTIVE_DEVICE_ALL);
                }
            }
        }
        disconnectSco();
    }

@@ -295,6 +299,7 @@ public class BluetoothDeviceManager {
    }

    public void cacheHearingAidDevice() {
        if (mBluetoothAdapter != null) {
            for (BluetoothDevice device : mBluetoothAdapter.getActiveDevices(
                        BluetoothProfile.HEARING_AID)) {
                if (device != null) {
@@ -302,6 +307,7 @@ public class BluetoothDeviceManager {
                }
            }
        }
    }

    public void restoreHearingAidDevice() {
        if (mBluetoothHearingAidActiveDeviceCache != null) {