OSDN Git Service

Remove redundant GATT_StartIf
authorJakub Pawlowski <jpawlowski@google.com>
Thu, 13 Dec 2018 16:53:15 +0000 (17:53 +0100)
committerJakub Pawlowski <jpawlowski@google.com>
Thu, 13 Dec 2018 21:55:33 +0000 (22:55 +0100)
GATT_StartIf is just sending connect callback about all currently
connected devices, even ones that this app is not interested in.

For btif/java apps, we will trigger connection attempt to just one
device right after registration, which would trigger connect callback
anyway.

For all bta layer apps, they do guard inside connect callback to make
sure code is triggered for already known device, but the devices are
considered as known only after they already connected, and some event
triggered app to create control block.

Thus, GATT_StartIf is surplus feature that should be removed.

Test: run all sl4a GATT tests
Change-Id: I8c45b92dbbf80894c32bb870eb392e766063c934

bta/gatt/bta_gattc_act.cc
bta/gatt/bta_gatts_act.cc
bta/gatt/bta_gatts_int.h
bta/gatt/bta_gatts_main.cc
btif/src/btif_gatt_test.cc
stack/gap/gap_ble.cc
stack/gatt/gatt_api.cc
stack/gatt/gatt_attr.cc
stack/include/gatt_api.h
stack/srvc/srvc_eng.cc

index 0a6ab6c..6db1ff6 100644 (file)
@@ -156,16 +156,6 @@ void bta_gattc_disable() {
   }
 }
 
-/** start an application interface */
-void bta_gattc_start_if(uint8_t client_if) {
-  if (!bta_gattc_cl_get_regcb(client_if)) {
-    LOG(ERROR) << "Unable to start app.: Unknown client_if=" << +client_if;
-    return;
-  }
-
-  GATT_StartIf(client_if);
-}
-
 /** Register a GATT client application with BTA */
 void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
                         BtaAppRegisterCallback cb) {
@@ -191,10 +181,6 @@ void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
 
         /* BTA use the same client interface as BTE GATT statck */
         client_if = bta_gattc_cb.cl_rcb[i].client_if;
-
-        do_in_main_thread(FROM_HERE,
-                          base::Bind(&bta_gattc_start_if, client_if));
-
         status = GATT_SUCCESS;
         break;
       }
index 8e3d589..284611d 100644 (file)
@@ -214,13 +214,6 @@ void bta_gatts_register(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) {
           GATT_Register(p_msg->api_reg.app_uuid, &bta_gatts_cback);
       if (!p_cb->rcb[first_unuse].gatt_if) {
         status = GATT_NO_RESOURCES;
-      } else {
-        tBTA_GATTS_INT_START_IF* p_buf = (tBTA_GATTS_INT_START_IF*)osi_malloc(
-            sizeof(tBTA_GATTS_INT_START_IF));
-        p_buf->hdr.event = BTA_GATTS_INT_START_IF_EVT;
-        p_buf->server_if = p_cb->rcb[first_unuse].gatt_if;
-
-        bta_sys_sendmsg(p_buf);
       }
     } else {
       status = GATT_NO_RESOURCES;
@@ -233,24 +226,6 @@ void bta_gatts_register(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) {
 
 /*******************************************************************************
  *
- * Function         bta_gatts_start_if
- *
- * Description      start an application interface.
- *
- * Returns          none.
- *
- ******************************************************************************/
-void bta_gatts_start_if(UNUSED_ATTR tBTA_GATTS_CB* p_cb,
-                        tBTA_GATTS_DATA* p_msg) {
-  if (bta_gatts_find_app_rcb_by_app_if(p_msg->int_start_if.server_if)) {
-    GATT_StartIf(p_msg->int_start_if.server_if);
-  } else {
-    LOG(ERROR) << "Unable to start app.: Unknown interface="
-               << +p_msg->int_start_if.server_if;
-  }
-}
-/*******************************************************************************
- *
  * Function         bta_gatts_deregister
  *
  * Description      deregister an application.
index adecf30..022a412 100644 (file)
@@ -37,7 +37,6 @@
  ****************************************************************************/
 enum {
   BTA_GATTS_API_REG_EVT = BTA_SYS_EVT_START(BTA_ID_GATTS),
-  BTA_GATTS_INT_START_IF_EVT,
   BTA_GATTS_API_DEREG_EVT,
   BTA_GATTS_API_INDICATION_EVT,
 
@@ -67,9 +66,7 @@ typedef struct {
 typedef struct {
   BT_HDR hdr;
   tGATT_IF server_if;
-} tBTA_GATTS_INT_START_IF;
-
-typedef tBTA_GATTS_INT_START_IF tBTA_GATTS_API_DEREG;
+} tBTA_GATTS_API_DEREG;
 
 typedef struct {
   BT_HDR hdr;
@@ -118,8 +115,6 @@ typedef union {
   tBTA_GATTS_API_RSP api_rsp;
   tBTA_GATTS_API_OPEN api_open;
   tBTA_GATTS_API_CANCEL_OPEN api_cancel_open;
-
-  tBTA_GATTS_INT_START_IF int_start_if;
 } tBTA_GATTS_DATA;
 
 /* application registration control block */
@@ -161,7 +156,6 @@ extern bool bta_gatts_hdl_event(BT_HDR* p_msg);
 extern void bta_gatts_api_disable(tBTA_GATTS_CB* p_cb);
 extern void bta_gatts_api_enable(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_data);
 extern void bta_gatts_register(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg);
-extern void bta_gatts_start_if(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg);
 extern void bta_gatts_deregister(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg);
 extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB* p_srvc_cb,
                                      tBTA_GATTS_DATA* p_msg);
index 1dc0aa2..28b4cc4 100644 (file)
@@ -54,10 +54,6 @@ bool bta_gatts_hdl_event(BT_HDR* p_msg) {
       bta_gatts_register(p_cb, (tBTA_GATTS_DATA*)p_msg);
       break;
 
-    case BTA_GATTS_INT_START_IF_EVT:
-      bta_gatts_start_if(p_cb, (tBTA_GATTS_DATA*)p_msg);
-      break;
-
     case BTA_GATTS_API_DEREG_EVT:
       bta_gatts_deregister(p_cb, (tBTA_GATTS_DATA*)p_msg);
       break;
index 1c0af35..ec5d0c2 100644 (file)
@@ -184,7 +184,6 @@ bt_status_t btif_gattc_test_command_impl(int command,
         tmp.fill(0xAE);
         test_cb.gatt_if = GATT_Register(bluetooth::Uuid::From128BitBE(tmp),
                                         &btif_test_callbacks);
-        GATT_StartIf(test_cb.gatt_if);
       } else {
         GATT_Deregister(test_cb.gatt_if);
         test_cb.gatt_if = 0;
index cce62d4..ce66df8 100644 (file)
@@ -403,8 +403,6 @@ void gap_attr_db_init(void) {
 
   gatt_if = GATT_Register(app_uuid, &gap_cback);
 
-  GATT_StartIf(gatt_if);
-
   Uuid svc_uuid = Uuid::From16Bit(UUID_SERVCLASS_GAP_SERVER);
   Uuid name_uuid = Uuid::From16Bit(GATT_UUID_GAP_DEVICE_NAME);
   Uuid icon_uuid = Uuid::From16Bit(GATT_UUID_GAP_ICON);
index ae7af8c..c8944d6 100644 (file)
@@ -1039,43 +1039,6 @@ void GATT_Deregister(tGATT_IF gatt_if) {
 
 /*******************************************************************************
  *
- * Function         GATT_StartIf
- *
- * Description      This function is called after registration to start
- *                  receiving callbacks for registered interface.  Function may
- *                  call back with connection status and queued notifications
- *
- * Parameter        gatt_if: applicaiton interface.
- *
- * Returns          None.
- *
- ******************************************************************************/
-void GATT_StartIf(tGATT_IF gatt_if) {
-  tGATT_REG* p_reg;
-  tGATT_TCB* p_tcb;
-  RawAddress bda;
-  uint8_t start_idx, found_idx;
-  uint16_t conn_id;
-  tGATT_TRANSPORT transport;
-
-  VLOG(1) << __func__ << " gatt_if=" << +gatt_if;
-  p_reg = gatt_get_regcb(gatt_if);
-  if (p_reg != NULL) {
-    start_idx = 0;
-    while (
-        gatt_find_the_connected_bda(start_idx, bda, &found_idx, &transport)) {
-      p_tcb = gatt_find_tcb_by_addr(bda, transport);
-      if (p_reg->app_cb.p_conn_cb && p_tcb) {
-        conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
-        (*p_reg->app_cb.p_conn_cb)(gatt_if, bda, conn_id, true, 0, transport);
-      }
-      start_idx = ++found_idx;
-    }
-  }
-}
-
-/*******************************************************************************
- *
  * Function         GATT_Connect
  *
  * Description      This function initiate a connecttion to a remote device on
index 8861a7a..be71283 100644 (file)
@@ -278,7 +278,6 @@ void gatt_profile_db_init(void) {
 
   /* Create a GATT profile service */
   gatt_cb.gatt_if = GATT_Register(Uuid::From128BitBE(tmp), &gatt_profile_cback);
-  GATT_StartIf(gatt_cb.gatt_if);
 
   Uuid service_uuid = Uuid::From16Bit(UUID_SERVCLASS_GATT_SERVER);
 
index 069a179..09f96db 100644 (file)
@@ -945,21 +945,6 @@ extern void GATT_Deregister(tGATT_IF gatt_if);
 
 /*******************************************************************************
  *
- * Function         GATT_StartIf
- *
- * Description      This function is called after registration to start
- *                  receiving callbacks for registered interface.  Function may
- *                  call back with connection status and queued notifications
- *
- * Parameter        gatt_if: applicaiton interface.
- *
- * Returns          None
- *
- ******************************************************************************/
-extern void GATT_StartIf(tGATT_IF gatt_if);
-
-/*******************************************************************************
- *
  * Function         GATT_Connect
  *
  * Description      This function initiate a connecttion to a remote device on
index af57ff1..01b5a82 100644 (file)
@@ -412,7 +412,6 @@ tGATT_STATUS srvc_eng_init(void) {
     bluetooth::Uuid app_uuid =
         bluetooth::Uuid::From16Bit(UUID_SERVCLASS_DEVICE_INFO);
     srvc_eng_cb.gatt_if = GATT_Register(app_uuid, &srvc_gatt_cback);
-    GATT_StartIf(srvc_eng_cb.gatt_if);
 
     VLOG(1) << "Srvc_Init:  gatt_if=" << +srvc_eng_cb.gatt_if;