summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei Wang <weiwa@google.com>2014-03-20 16:38:04 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-20 16:38:04 +0000
commitb0d63d53592bfa9c064805be361b1432e7643aa9 (patch)
tree84a94a818e33720ec1a37fc41d684675f7df9bd0 /core
parent9b12bd90a51aa0fe25d25f34791bc8e7db0b3141 (diff)
parent13bd85772f6279d14303ec3a18615613c3722844 (diff)
downloadframeworks_base-b0d63d53592bfa9c064805be361b1432e7643aa9.zip
frameworks_base-b0d63d53592bfa9c064805be361b1432e7643aa9.tar.gz
frameworks_base-b0d63d53592bfa9c064805be361b1432e7643aa9.tar.bz2
am 13bd8577: am c0384b6b: DO NOT MERGE: Move advetise clean up to callback code. fixes b/13289050 Cherrypick from master to fix b/13289050
* commit '13bd85772f6279d14303ec3a18615613c3722844': DO NOT MERGE: Move advetise clean up to callback code. fixes b/13289050 Cherrypick from master to fix b/13289050
Diffstat (limited to 'core')
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index f973d84..75b007c 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -593,7 +593,6 @@ public final class BluetoothAdapter {
return false;
}
mAdvertisingGattCallback.stopAdvertising();
- mAdvertisingGattCallback = null;
return true;
} catch (RemoteException e) {
Log.e(TAG, "", e);
@@ -1797,15 +1796,12 @@ public final class BluetoothAdapter {
try {
IBluetoothGatt iGatt = adapter.getBluetoothManager().getBluetoothGatt();
iGatt.stopAdvertising();
- Log.d(TAG, "unregistering client " + mLeHandle);
- iGatt.unregisterClient(mLeHandle);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to stop advertising and unregister" + e);
+ Log.e(TAG, "Failed to stop advertising" + e);
}
} else {
Log.e(TAG, "stopAdvertising, BluetoothAdapter is null");
}
- mLeHandle = -1;
notifyAll();
}
}
@@ -1995,6 +1991,26 @@ public final class BluetoothAdapter {
if (advertiseState == STATE_ADVERTISE_STARTED) {
mAdvertiseCallback.onAdvertiseStart(status);
} else {
+ synchronized (this) {
+ if (status == ADVERTISE_CALLBACK_SUCCESS) {
+ BluetoothAdapter adapter = mBluetoothAdapter.get();
+ if (adapter != null) {
+ try {
+ IBluetoothGatt iGatt =
+ adapter.getBluetoothManager().getBluetoothGatt();
+ Log.d(TAG, "unregistering client " + mLeHandle);
+ iGatt.unregisterClient(mLeHandle);
+ // Reset advertise app handle.
+ mLeHandle = -1;
+ adapter.mAdvertisingGattCallback = null;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to unregister client" + e);
+ }
+ } else {
+ Log.e(TAG, "cannot unregister client, BluetoothAdapter is null");
+ }
+ }
+ }
mAdvertiseCallback.onAdvertiseStop(status);
}
}