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

Commit 38609374 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Avoid a NullPointerException in getDevicesMatchingConnectionStates"

parents 69f90a26 d18a54d4
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -220,7 +220,9 @@ public class HeadsetService extends ProfileService {
        mStateMachinesThread.quitSafely();
        mStateMachinesThread = null;
        // Step 1: Clear
        synchronized (mStateMachines) {
            mAdapterService = null;
        }
        return true;
    }

@@ -771,14 +773,14 @@ public class HeadsetService extends ProfileService {
    public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        ArrayList<BluetoothDevice> devices = new ArrayList<>();
        if (states == null) {
        synchronized (mStateMachines) {
            if (states == null || mAdapterService == null) {
                return devices;
            }
            final BluetoothDevice[] bondedDevices = mAdapterService.getBondedDevices();
            if (bondedDevices == null) {
                return devices;
            }
        synchronized (mStateMachines) {
            for (BluetoothDevice device : bondedDevices) {
                final ParcelUuid[] featureUuids = mAdapterService.getRemoteUuids(device);
                if (!BluetoothUuid.containsAnyUuid(featureUuids, HEADSET_UUIDS)) {