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

am: 47ae606d2c

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

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

View File

@@ -2029,12 +2029,15 @@ public final class BluetoothAdapter {
public void onBluetoothServiceDown() { public void onBluetoothServiceDown() {
if (VDBG) Log.d(TAG, "onBluetoothServiceDown: " + mService); if (VDBG) Log.d(TAG, "onBluetoothServiceDown: " + mService);
mServiceLock.writeLock().lock(); try {
mService = null; mServiceLock.writeLock().lock();
if (mLeScanClients != null) mLeScanClients.clear(); mService = null;
if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup(); if (mLeScanClients != null) mLeScanClients.clear();
if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup(); if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
mServiceLock.writeLock().unlock(); if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
} finally {
mServiceLock.writeLock().unlock();
}
synchronized (mProxyServiceStateCallbacks) { synchronized (mProxyServiceStateCallbacks) {
for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){

View File

@@ -1539,14 +1539,17 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
BluetoothAdapter.STATE_OFF); BluetoothAdapter.STATE_OFF);
sendBluetoothServiceDownCallback(); sendBluetoothServiceDownCallback();
mBluetoothLock.writeLock().lock(); try {
if (mBluetooth != null) { mBluetoothLock.writeLock().lock();
mBluetooth = null; if (mBluetooth != null) {
// Unbind mBluetooth = null;
mContext.unbindService(mConnection); // Unbind
mContext.unbindService(mConnection);
}
mBluetoothGatt = null;
} finally {
mBluetoothLock.writeLock().unlock();
} }
mBluetoothGatt = null;
mBluetoothLock.writeLock().unlock();
SystemClock.sleep(100); SystemClock.sleep(100);
@@ -1851,14 +1854,17 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
sendBluetoothServiceDownCallback(); sendBluetoothServiceDownCallback();
mBluetoothLock.writeLock().lock(); try {
if (mBluetooth != null) { mBluetoothLock.writeLock().lock();
mBluetooth = null; if (mBluetooth != null) {
// Unbind mBluetooth = null;
mContext.unbindService(mConnection); // Unbind
mContext.unbindService(mConnection);
}
mBluetoothGatt = null;
} finally {
mBluetoothLock.writeLock().unlock();
} }
mBluetoothGatt = null;
mBluetoothLock.writeLock().unlock();
mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE); mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE);
mState = BluetoothAdapter.STATE_OFF; mState = BluetoothAdapter.STATE_OFF;