Merge "Add missing "try ... finally" safeguards" into nyc-dev

am: 0810732a2a

* commit '0810732a2affee7264d12b73fbcfa82d0db991b4':
  Add missing "try ... finally" safeguards

Change-Id: I227ab98f33c025543e4ac4adf16453acd6159713
This commit is contained in:
Pavlin Radoslavov
2016-05-25 00:18:53 +00:00
committed by android-build-merger
2 changed files with 29 additions and 20 deletions

View File

@@ -2045,12 +2045,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 ){

View File

@@ -1457,14 +1457,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);
@@ -1765,14 +1768,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;