OSDN Git Service

Open connection if it doesn't exsist in bta_gattc_process_indicate
authorweichinweng <weichinweng@google.com>
Wed, 29 May 2019 06:27:15 +0000 (14:27 +0800)
committerWeichin Weng <weichinweng@google.com>
Wed, 29 May 2019 10:35:05 +0000 (10:35 +0000)
If Service Changed indication is received before the connection is open
, send the BTA_GATTC_INT_CONN_EVT to open it before processing the
indication.

Bug: 131814072
Test: CTS Bluetooth LE Secure Test. Unit test.

Change-Id: I1b3415ef6aafb52a6ac229409514a85f35de5842

bta/gatt/bta_gattc_act.cc

index 5e60049..90978f6 100644 (file)
@@ -1240,6 +1240,20 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op,
   }
 
   tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
+  /* connection not open yet */
+  if (p_clcb == NULL) {
+    p_clcb = bta_gattc_clcb_alloc(gatt_if, remote_bda, transport);
+
+    if (p_clcb == NULL) {
+      LOG(ERROR) << __func__ << ": No resources";
+      return;
+    }
+
+    p_clcb->bta_conn_id = conn_id;
+    p_clcb->transport = transport;
+
+    bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CONN_EVT, NULL);
+  }
 
   notify.handle = handle;
 
@@ -1250,21 +1264,6 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op,
 
   /* if app registered for the notification */
   if (bta_gattc_check_notif_registry(p_clrcb, p_srcb, &notify)) {
-    /* connection not open yet */
-    if (p_clcb == NULL) {
-      p_clcb = bta_gattc_clcb_alloc(gatt_if, remote_bda, transport);
-
-      if (p_clcb == NULL) {
-        LOG(ERROR) << "No resources";
-        return;
-      }
-
-      p_clcb->bta_conn_id = conn_id;
-      p_clcb->transport = transport;
-
-      bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CONN_EVT, NULL);
-    }
-
     if (p_clcb != NULL)
       bta_gattc_proc_other_indication(p_clcb, op, p_data, &notify);
   }