aboutsummaryrefslogtreecommitdiff
path: root/framework/java
diff options
context:
space:
mode:
authorPavlin Radoslavov <pavlin@google.com>2016-05-24 15:28:41 -0700
committerPavlin Radoslavov <pavlin@google.com>2016-05-24 17:14:51 -0700
commitf453e34eac30e6587d0764a57ddf98f9ced69c25 (patch)
treec1b9bea60053642d6331da99388875192e48b10a /framework/java
parent97340071f7e408d2e3d18179cef4a10a66940e1a (diff)
Add missing "try ... finally" safeguards
Safeguards for code protected by ReentrantReadWriteLock. Bug: 28734075 Bug: 28799467 Change-Id: Ib7f598a92e8df6bd855ca48cdd094c1c73a935f2 (cherry picked from commit e957a8a0b4100d001f79c866e7904d2426ac8da0)
Diffstat (limited to 'framework/java')
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index 15b16f7314..36e041ae0c 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -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 ){