summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndre Eisenbach <eisenbach@google.com>2015-01-16 13:02:48 -0800
committerAndre Eisenbach <eisenbach@google.com>2015-01-16 13:02:48 -0800
commit3f8164cd8c4bcce5e79770ee7c02fe00ba9581d5 (patch)
tree425a17c10eb793d31f68f6ee68935b5925666f75 /src
parent8dae225b378f250f7a0348e923bade61895171d6 (diff)
downloadandroid_packages_apps_Bluetooth-3f8164cd8c4bcce5e79770ee7c02fe00ba9581d5.tar.gz
android_packages_apps_Bluetooth-3f8164cd8c4bcce5e79770ee7c02fe00ba9581d5.tar.bz2
android_packages_apps_Bluetooth-3f8164cd8c4bcce5e79770ee7c02fe00ba9581d5.zip
Remove GATT context if client registration did not succeed
Bug: 19028495 Change-Id: I25827e365621fa9b3ef6e85ef9c103cf03654b7c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/bluetooth/gatt/ContextMap.java17
-rw-r--r--src/com/android/bluetooth/gatt/GattService.java8
2 files changed, 23 insertions, 2 deletions
diff --git a/src/com/android/bluetooth/gatt/ContextMap.java b/src/com/android/bluetooth/gatt/ContextMap.java
index bdb82b5d8..1b40bc0d8 100644
--- a/src/com/android/bluetooth/gatt/ContextMap.java
+++ b/src/com/android/bluetooth/gatt/ContextMap.java
@@ -134,6 +134,23 @@ import java.util.UUID;
}
/**
+ * Remove the context for a given UUID
+ */
+ void remove(UUID uuid) {
+ synchronized (mApps) {
+ Iterator<App> i = mApps.iterator();
+ while(i.hasNext()) {
+ App entry = i.next();
+ if (entry.uuid.equals(uuid)) {
+ entry.unlinkToDeath();
+ i.remove();
+ break;
+ }
+ }
+ }
+ }
+
+ /**
* Remove the context for a given application ID.
*/
void remove(int id) {
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java
index ecda6226e..c428cf832 100644
--- a/src/com/android/bluetooth/gatt/GattService.java
+++ b/src/com/android/bluetooth/gatt/GattService.java
@@ -638,8 +638,12 @@ public class GattService extends ProfileService {
if (DBG) Log.d(TAG, "onClientRegistered() - UUID=" + uuid + ", clientIf=" + clientIf);
ClientMap.App app = mClientMap.getByUuid(uuid);
if (app != null) {
- app.id = clientIf;
- app.linkToDeath(new ClientDeathRecipient(clientIf));
+ if (status == 0) {
+ app.id = clientIf;
+ app.linkToDeath(new ClientDeathRecipient(clientIf));
+ } else {
+ mClientMap.remove(uuid);
+ }
app.callback.onClientRegistered(status, clientIf);
}
}