summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Eisenbach2015-01-20 23:18:19 +0000
committerAndroid (Google) Code Review2015-01-20 23:18:20 +0000
commit0e3af27dd1acd8034efb9b53bdb824fc342e7c7b (patch)
treec47343d723aea6d3844d4e09e01d3a26b094fabb
parent45f25f7ba5aca87e8709b4901ca7057dbb4a3ccf (diff)
parent3f8164cd8c4bcce5e79770ee7c02fe00ba9581d5 (diff)
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 bdb82b5..1b40bc0 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 ecda622..c428cf8 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);
}
}