summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Eisenbach <eisenbach@google.com>2015-01-20 23:18:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-01-20 23:18:20 +0000
commit0e3af27dd1acd8034efb9b53bdb824fc342e7c7b (patch)
treec47343d723aea6d3844d4e09e01d3a26b094fabb
parent45f25f7ba5aca87e8709b4901ca7057dbb4a3ccf (diff)
parent3f8164cd8c4bcce5e79770ee7c02fe00ba9581d5 (diff)
downloadandroid_packages_apps_Bluetooth-0e3af27dd1acd8034efb9b53bdb824fc342e7c7b.tar.gz
android_packages_apps_Bluetooth-0e3af27dd1acd8034efb9b53bdb824fc342e7c7b.tar.bz2
android_packages_apps_Bluetooth-0e3af27dd1acd8034efb9b53bdb824fc342e7c7b.zip
Merge "Remove GATT context if client registration did not succeed" into lmp-mr1-dev
-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);
}
}