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

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

Merge "Guard mPendingGattOperations to prevent NPE"

parents 7997535a 5171c80a
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() {