Merge "Add missing "try ... finally" safeguards"
This commit is contained in:
@@ -2029,12 +2029,15 @@ public final class BluetoothAdapter {
|
||||
public void onBluetoothServiceDown() {
|
||||
if (VDBG) Log.d(TAG, "onBluetoothServiceDown: " + mService);
|
||||
|
||||
mServiceLock.writeLock().lock();
|
||||
mService = null;
|
||||
if (mLeScanClients != null) mLeScanClients.clear();
|
||||
if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
|
||||
if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
|
||||
mServiceLock.writeLock().unlock();
|
||||
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 ){
|
||||
|
||||
@@ -1539,14 +1539,17 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||
BluetoothAdapter.STATE_OFF);
|
||||
sendBluetoothServiceDownCallback();
|
||||
|
||||
mBluetoothLock.writeLock().lock();
|
||||
if (mBluetooth != null) {
|
||||
mBluetooth = null;
|
||||
// Unbind
|
||||
mContext.unbindService(mConnection);
|
||||
try {
|
||||
mBluetoothLock.writeLock().lock();
|
||||
if (mBluetooth != null) {
|
||||
mBluetooth = null;
|
||||
// Unbind
|
||||
mContext.unbindService(mConnection);
|
||||
}
|
||||
mBluetoothGatt = null;
|
||||
} finally {
|
||||
mBluetoothLock.writeLock().unlock();
|
||||
}
|
||||
mBluetoothGatt = null;
|
||||
mBluetoothLock.writeLock().unlock();
|
||||
|
||||
SystemClock.sleep(100);
|
||||
|
||||
@@ -1851,14 +1854,17 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||
|
||||
sendBluetoothServiceDownCallback();
|
||||
|
||||
mBluetoothLock.writeLock().lock();
|
||||
if (mBluetooth != null) {
|
||||
mBluetooth = null;
|
||||
// Unbind
|
||||
mContext.unbindService(mConnection);
|
||||
try {
|
||||
mBluetoothLock.writeLock().lock();
|
||||
if (mBluetooth != null) {
|
||||
mBluetooth = null;
|
||||
// Unbind
|
||||
mContext.unbindService(mConnection);
|
||||
}
|
||||
mBluetoothGatt = null;
|
||||
} finally {
|
||||
mBluetoothLock.writeLock().unlock();
|
||||
}
|
||||
mBluetoothGatt = null;
|
||||
mBluetoothLock.writeLock().unlock();
|
||||
|
||||
mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE);
|
||||
mState = BluetoothAdapter.STATE_OFF;
|
||||
|
||||
Reference in New Issue
Block a user