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

Commit 17e681ce authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Guard mPendingGattOperations to prevent NPE" am: 4958b4bb am: 77f12dea am: 6f820ebe

parents 9f081afa 6f820ebe
Loading
Loading
Loading
Loading
+25 −20
Original line number Diff line number Diff line
@@ -337,6 +337,7 @@ public class MediaControlGattService implements MediaControlGattServiceInterface
            Log.d(TAG, "onUnauthorizedGattOperation device: " + device);
        }

        synchronized (mPendingGattOperations) {
            List<GattOpContext> operations = mPendingGattOperations.get(device);
            if (operations == null) {
                operations = new ArrayList<>();
@@ -349,6 +350,7 @@ public class MediaControlGattService implements MediaControlGattServiceInterface
                mMcpService.onDeviceUnauthorized(device);
            }
        }
    }

    private void onAuthorizedGattOperation(BluetoothDevice device, GattOpContext op) {
        int status = BluetoothGatt.GATT_SUCCESS;
@@ -494,14 +496,17 @@ public class MediaControlGattService implements MediaControlGattServiceInterface
            Log.d(TAG, "ClearUnauthorizedGattOperations device: " + device);
        }

        synchronized (mPendingGattOperations) {
            mPendingGattOperations.remove(device);
        }
    }

    private void ProcessPendingGattOperations(BluetoothDevice device) {
        if (VDBG) {
            Log.d(TAG, "ProcessPendingGattOperations device: " + device);
        }

        synchronized (mPendingGattOperations) {
            if (mPendingGattOperations.containsKey(device)) {
                if (getDeviceAuthorization(device) == BluetoothDevice.ACCESS_ALLOWED) {
                    for (GattOpContext op : mPendingGattOperations.get(device)) {
@@ -512,10 +517,10 @@ public class MediaControlGattService implements MediaControlGattServiceInterface
                        onRejectedAuthorizationGattOperation(device, op);
                    }
                }

                ClearUnauthorizedGattOperations(device);
            }
        }
    }

    @VisibleForTesting
    final BluetoothGattServerCallback mServerCallback = new BluetoothGattServerCallback() {