diff options
author | Matthew Xie <mattx@google.com> | 2011-09-20 14:14:29 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-09-20 14:14:29 -0700 |
commit | e0515aad3a51aa2eadce5c448f771d2372916939 (patch) | |
tree | 4d580a85e9319c36aed0e30fd564fcc53402e98f /core/java/android/server/BluetoothService.java | |
parent | de5e4455c5a750e70e43674e1fe9f95bce09654b (diff) | |
parent | 778eccf4923571c77f158e92b2f5f0f7dfd21875 (diff) | |
download | frameworks_base-e0515aad3a51aa2eadce5c448f771d2372916939.zip frameworks_base-e0515aad3a51aa2eadce5c448f771d2372916939.tar.gz frameworks_base-e0515aad3a51aa2eadce5c448f771d2372916939.tar.bz2 |
am 778eccf4: Merge "Check null of pidPair to skip the case the service record has been removed" into ics-factoryrom
* commit '778eccf4923571c77f158e92b2f5f0f7dfd21875':
Check null of pidPair to skip the case the service record has been removed
Diffstat (limited to 'core/java/android/server/BluetoothService.java')
-rwxr-xr-x | core/java/android/server/BluetoothService.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java index f0fb4e0..63da926 100755 --- a/core/java/android/server/BluetoothService.java +++ b/core/java/android/server/BluetoothService.java @@ -390,8 +390,7 @@ public class BluetoothService extends IBluetooth.Stub { } /** - * The Bluetooth has been turned off, but hot. Do bonding, profile, - * and internal cleanup + * The Bluetooth has been turned off, but hot. Do bonding, profile cleanup */ synchronized void finishDisable() { // mark in progress bondings as cancelled @@ -409,8 +408,17 @@ public class BluetoothService extends IBluetooth.Stub { Intent intent = new Intent(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED); intent.putExtra(BluetoothAdapter.EXTRA_SCAN_MODE, BluetoothAdapter.SCAN_MODE_NONE); mContext.sendBroadcast(intent, BLUETOOTH_PERM); + } + /** + * Local clean up after broadcasting STATE_OFF intent + */ + synchronized void cleanupAfterFinishDisable() { mAdapterProperties.clear(); + + for (Integer srHandle : mServiceRecordToPid.keySet()) { + removeServiceRecordNative(srHandle); + } mServiceRecordToPid.clear(); mProfilesConnected = 0; @@ -1526,6 +1534,8 @@ public class BluetoothService extends IBluetooth.Stub { public void removeServiceRecord(int handle) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + // Since this is a binder call check if Bluetooth is off + if (getBluetoothStateInternal() == BluetoothAdapter.STATE_OFF) return; Message message = mHandler.obtainMessage(MESSAGE_REMOVE_SERVICE_RECORD); message.obj = new Pair<Integer, Integer>(handle, Binder.getCallingPid()); mHandler.sendMessage(message); @@ -1533,8 +1543,7 @@ public class BluetoothService extends IBluetooth.Stub { private synchronized void checkAndRemoveRecord(int handle, int pid) { Pair<Integer, IBinder> pidPair = mServiceRecordToPid.get(handle); - Integer owner = pidPair.first; - if (owner != null && pid == owner.intValue()) { + if (pidPair != null && pid == pidPair.first) { if (DBG) Log.d(TAG, "Removing service record " + Integer.toHexString(handle) + " for pid " + pid); mServiceRecordToPid.remove(handle); |