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

Commit c82d3210 authored by Matthew Xie's avatar Matthew Xie Committed by Android Git Automerger
Browse files

am 24c02c41: am d67aff68: am a63ba428: Merge "Separate the protection of...

am 24c02c41: am d67aff68: am a63ba428: Merge "Separate the protection of mProxyServiceStateCallbacks from that of mService" into lmp-mr1-dev

* commit '24c02c418673a18a287ce0820f0024f7a18ff181':
  Separate the protection of mProxyServiceStateCallbacks from that of mService
parents ad8ea7fd b6600692
Loading
Loading
Loading
Loading
+23 −19
Original line number Diff line number Diff line
@@ -1429,6 +1429,7 @@ public final class BluetoothAdapter {
                if (VDBG) Log.d(TAG, "onBluetoothServiceUp: " + bluetoothService);
                synchronized (mManagerCallback) {
                    mService = bluetoothService;
                    synchronized (mProxyServiceStateCallbacks) {
                        for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){
                            try {
                                if (cb != null) {
@@ -1440,6 +1441,7 @@ public final class BluetoothAdapter {
                        }
                    }
                }
            }

            public void onBluetoothServiceDown() {
                if (VDBG) Log.d(TAG, "onBluetoothServiceDown: " + mService);
@@ -1448,6 +1450,7 @@ public final class BluetoothAdapter {
                    if (mLeScanClients != null) mLeScanClients.clear();
                    if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
                    if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
                    synchronized (mProxyServiceStateCallbacks) {
                        for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){
                            try {
                                if (cb != null) {
@@ -1459,6 +1462,7 @@ public final class BluetoothAdapter {
                        }
                    }
                }
            }
    };

    /**
@@ -1596,10 +1600,10 @@ public final class BluetoothAdapter {
            return mManagerService;
    }

    private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks = new ArrayList<IBluetoothManagerCallback>();
    final private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks = new ArrayList<IBluetoothManagerCallback>();

    /*package*/ IBluetooth getBluetoothService(IBluetoothManagerCallback cb) {
        synchronized (mManagerCallback) {
        synchronized (mProxyServiceStateCallbacks) {
            if (cb == null) {
                Log.w(TAG, "getBluetoothService() called with no BluetoothManagerCallback");
            } else if (!mProxyServiceStateCallbacks.contains(cb)) {
@@ -1610,7 +1614,7 @@ public final class BluetoothAdapter {
    }

    /*package*/ void removeServiceStateCallback(IBluetoothManagerCallback cb) {
        synchronized (mManagerCallback) {
        synchronized (mProxyServiceStateCallbacks) {
            mProxyServiceStateCallbacks.remove(cb);
        }
    }