am a63ba428: Merge "Separate the protection of mProxyServiceStateCallbacks from that of mService" into lmp-mr1-dev

* commit 'a63ba4287e5c87f41cd7d4b43111fd18f3ec499b':
  Separate the protection of mProxyServiceStateCallbacks from that of mService
This commit is contained in:
Matthew Xie
2015-02-09 21:59:13 +00:00
committed by Android Git Automerger

View File

@@ -1429,14 +1429,16 @@ public final class BluetoothAdapter {
if (VDBG) Log.d(TAG, "onBluetoothServiceUp: " + bluetoothService); if (VDBG) Log.d(TAG, "onBluetoothServiceUp: " + bluetoothService);
synchronized (mManagerCallback) { synchronized (mManagerCallback) {
mService = bluetoothService; mService = bluetoothService;
for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ synchronized (mProxyServiceStateCallbacks) {
try { for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){
if (cb != null) { try {
cb.onBluetoothServiceUp(bluetoothService); if (cb != null) {
} else { cb.onBluetoothServiceUp(bluetoothService);
Log.d(TAG, "onBluetoothServiceUp: cb is null!!!"); } else {
} Log.d(TAG, "onBluetoothServiceUp: cb is null!!!");
} catch (Exception e) { Log.e(TAG,"",e);} }
} catch (Exception e) { Log.e(TAG,"",e);}
}
} }
} }
} }
@@ -1448,14 +1450,16 @@ public final class BluetoothAdapter {
if (mLeScanClients != null) mLeScanClients.clear(); if (mLeScanClients != null) mLeScanClients.clear();
if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup(); if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup(); if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){ synchronized (mProxyServiceStateCallbacks) {
try { for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){
if (cb != null) { try {
cb.onBluetoothServiceDown(); if (cb != null) {
} else { cb.onBluetoothServiceDown();
Log.d(TAG, "onBluetoothServiceDown: cb is null!!!"); } else {
} Log.d(TAG, "onBluetoothServiceDown: cb is null!!!");
} catch (Exception e) { Log.e(TAG,"",e);} }
} catch (Exception e) { Log.e(TAG,"",e);}
}
} }
} }
} }
@@ -1596,10 +1600,10 @@ public final class BluetoothAdapter {
return mManagerService; return mManagerService;
} }
private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks = new ArrayList<IBluetoothManagerCallback>(); final private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks = new ArrayList<IBluetoothManagerCallback>();
/*package*/ IBluetooth getBluetoothService(IBluetoothManagerCallback cb) { /*package*/ IBluetooth getBluetoothService(IBluetoothManagerCallback cb) {
synchronized (mManagerCallback) { synchronized (mProxyServiceStateCallbacks) {
if (cb == null) { if (cb == null) {
Log.w(TAG, "getBluetoothService() called with no BluetoothManagerCallback"); Log.w(TAG, "getBluetoothService() called with no BluetoothManagerCallback");
} else if (!mProxyServiceStateCallbacks.contains(cb)) { } else if (!mProxyServiceStateCallbacks.contains(cb)) {
@@ -1610,7 +1614,7 @@ public final class BluetoothAdapter {
} }
/*package*/ void removeServiceStateCallback(IBluetoothManagerCallback cb) { /*package*/ void removeServiceStateCallback(IBluetoothManagerCallback cb) {
synchronized (mManagerCallback) { synchronized (mProxyServiceStateCallbacks) {
mProxyServiceStateCallbacks.remove(cb); mProxyServiceStateCallbacks.remove(cb);
} }
} }