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

Commit 3ef690cd authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by android-build-merger
Browse files

Merge "Add missing "try ... finally" safeguards"

am: 47ae606d

* commit '47ae606d':
  Add missing "try ... finally" safeguards

Change-Id: I4d15b25f3e72d26c6a8efae21b8952ab72203a1d
parents e1a60983 47ae606d
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -2029,12 +2029,15 @@ public final class BluetoothAdapter {
            public void onBluetoothServiceDown() {
                if (VDBG) Log.d(TAG, "onBluetoothServiceDown: " + mService);

                try {
                    mServiceLock.writeLock().lock();
                    mService = null;
                    if (mLeScanClients != null) mLeScanClients.clear();
                    if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
                    if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
                } finally {
                    mServiceLock.writeLock().unlock();
                }

                synchronized (mProxyServiceStateCallbacks) {
                    for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){
+20 −14
Original line number Diff line number Diff line
@@ -1539,6 +1539,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                                                    BluetoothAdapter.STATE_OFF);
                        sendBluetoothServiceDownCallback();

                        try {
                            mBluetoothLock.writeLock().lock();
                            if (mBluetooth != null) {
                                mBluetooth = null;
@@ -1546,7 +1547,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                                mContext.unbindService(mConnection);
                            }
                            mBluetoothGatt = null;
                        } finally {
                            mBluetoothLock.writeLock().unlock();
                        }

                        SystemClock.sleep(100);

@@ -1851,6 +1854,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {

        sendBluetoothServiceDownCallback();

        try {
            mBluetoothLock.writeLock().lock();
            if (mBluetooth != null) {
                mBluetooth = null;
@@ -1858,7 +1862,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
                mContext.unbindService(mConnection);
            }
            mBluetoothGatt = null;
        } finally {
            mBluetoothLock.writeLock().unlock();
        }

        mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE);
        mState = BluetoothAdapter.STATE_OFF;