diff options
author | Matthew Xie <mattx@google.com> | 2015-02-06 14:09:54 -0800 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2015-02-06 14:13:56 -0800 |
commit | 60675b227354ab158e11fc5df2bbe654608d43dc (patch) | |
tree | efb57d7c61c6775db6e891cfa02dcd6050865955 /core | |
parent | f789d45b24acc3745ccc97adb687502d488404f6 (diff) | |
download | frameworks_base-60675b227354ab158e11fc5df2bbe654608d43dc.zip frameworks_base-60675b227354ab158e11fc5df2bbe654608d43dc.tar.gz frameworks_base-60675b227354ab158e11fc5df2bbe654608d43dc.tar.bz2 |
Separate the protection of mProxyServiceStateCallbacks from that of mService
The overuse of mManagerCallback caused a deaklock.
Bug: 19264190
Change-Id: Iff20019ff0c99bb5f36435feb15e43e280a8e102
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/bluetooth/BluetoothAdapter.java | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java index c262bae..b8f4bf8 100644 --- a/core/java/android/bluetooth/BluetoothAdapter.java +++ b/core/java/android/bluetooth/BluetoothAdapter.java @@ -1429,14 +1429,16 @@ public final class BluetoothAdapter { if (VDBG) Log.d(TAG, "onBluetoothServiceUp: " + bluetoothService); synchronized (mManagerCallback) { mService = bluetoothService; - for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ - try { - if (cb != null) { - cb.onBluetoothServiceUp(bluetoothService); - } else { - Log.d(TAG, "onBluetoothServiceUp: cb is null!!!"); - } - } catch (Exception e) { Log.e(TAG,"",e);} + synchronized (mProxyServiceStateCallbacks) { + for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ + try { + if (cb != null) { + cb.onBluetoothServiceUp(bluetoothService); + } else { + Log.d(TAG, "onBluetoothServiceUp: cb is null!!!"); + } + } catch (Exception e) { Log.e(TAG,"",e);} + } } } } @@ -1448,14 +1450,16 @@ public final class BluetoothAdapter { if (mLeScanClients != null) mLeScanClients.clear(); if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup(); if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup(); - for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ - try { - if (cb != null) { - cb.onBluetoothServiceDown(); - } else { - Log.d(TAG, "onBluetoothServiceDown: cb is null!!!"); - } - } catch (Exception e) { Log.e(TAG,"",e);} + synchronized (mProxyServiceStateCallbacks) { + for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ + try { + if (cb != null) { + cb.onBluetoothServiceDown(); + } else { + Log.d(TAG, "onBluetoothServiceDown: cb is null!!!"); + } + } catch (Exception e) { Log.e(TAG,"",e);} + } } } } @@ -1596,10 +1600,10 @@ public final class BluetoothAdapter { return mManagerService; } - private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks = new ArrayList<IBluetoothManagerCallback>(); + final private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks = new ArrayList<IBluetoothManagerCallback>(); /*package*/ IBluetooth getBluetoothService(IBluetoothManagerCallback cb) { - synchronized (mManagerCallback) { + synchronized (mProxyServiceStateCallbacks) { if (cb == null) { Log.w(TAG, "getBluetoothService() called with no BluetoothManagerCallback"); } else if (!mProxyServiceStateCallbacks.contains(cb)) { @@ -1610,7 +1614,7 @@ public final class BluetoothAdapter { } /*package*/ void removeServiceStateCallback(IBluetoothManagerCallback cb) { - synchronized (mManagerCallback) { + synchronized (mProxyServiceStateCallbacks) { mProxyServiceStateCallbacks.remove(cb); } } |