Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c655ba87 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Remove redundant GATT_StartIf

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
parent 032498c1
Loading
Loading
Loading
Loading
+0 −14
Original line number Original line Diff line number Diff line
@@ -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 */
/** Register a GATT client application with BTA */
void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
void bta_gattc_register(const Uuid& app_uuid, tBTA_GATTC_CBACK* p_cback,
                        BtaAppRegisterCallback cb) {
                        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 */
        /* BTA use the same client interface as BTE GATT statck */
        client_if = bta_gattc_cb.cl_rcb[i].client_if;
        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;
        status = GATT_SUCCESS;
        break;
        break;
      }
      }
+0 −25
Original line number Original line Diff line number Diff line
@@ -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);
          GATT_Register(p_msg->api_reg.app_uuid, &bta_gatts_cback);
      if (!p_cb->rcb[first_unuse].gatt_if) {
      if (!p_cb->rcb[first_unuse].gatt_if) {
        status = GATT_NO_RESOURCES;
        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 {
    } else {
      status = GATT_NO_RESOURCES;
      status = GATT_NO_RESOURCES;
@@ -231,24 +224,6 @@ void bta_gatts_register(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg) {
    (*p_msg->api_reg.p_cback)(BTA_GATTS_REG_EVT, &cb_data);
    (*p_msg->api_reg.p_cback)(BTA_GATTS_REG_EVT, &cb_data);
}
}


/*******************************************************************************
 *
 * 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
 * Function         bta_gatts_deregister
+1 −7
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@
 ****************************************************************************/
 ****************************************************************************/
enum {
enum {
  BTA_GATTS_API_REG_EVT = BTA_SYS_EVT_START(BTA_ID_GATTS),
  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_DEREG_EVT,
  BTA_GATTS_API_INDICATION_EVT,
  BTA_GATTS_API_INDICATION_EVT,


@@ -67,9 +66,7 @@ typedef struct {
typedef struct {
typedef struct {
  BT_HDR hdr;
  BT_HDR hdr;
  tGATT_IF server_if;
  tGATT_IF server_if;
} tBTA_GATTS_INT_START_IF;
} tBTA_GATTS_API_DEREG;

typedef tBTA_GATTS_INT_START_IF tBTA_GATTS_API_DEREG;


typedef struct {
typedef struct {
  BT_HDR hdr;
  BT_HDR hdr;
@@ -118,8 +115,6 @@ typedef union {
  tBTA_GATTS_API_RSP api_rsp;
  tBTA_GATTS_API_RSP api_rsp;
  tBTA_GATTS_API_OPEN api_open;
  tBTA_GATTS_API_OPEN api_open;
  tBTA_GATTS_API_CANCEL_OPEN api_cancel_open;
  tBTA_GATTS_API_CANCEL_OPEN api_cancel_open;

  tBTA_GATTS_INT_START_IF int_start_if;
} tBTA_GATTS_DATA;
} tBTA_GATTS_DATA;


/* application registration control block */
/* 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_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_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_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_deregister(tBTA_GATTS_CB* p_cb, tBTA_GATTS_DATA* p_msg);
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB* p_srvc_cb,
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB* p_srvc_cb,
                                     tBTA_GATTS_DATA* p_msg);
                                     tBTA_GATTS_DATA* p_msg);
+0 −4
Original line number Original line Diff line number Diff line
@@ -54,10 +54,6 @@ bool bta_gatts_hdl_event(BT_HDR* p_msg) {
      bta_gatts_register(p_cb, (tBTA_GATTS_DATA*)p_msg);
      bta_gatts_register(p_cb, (tBTA_GATTS_DATA*)p_msg);
      break;
      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:
    case BTA_GATTS_API_DEREG_EVT:
      bta_gatts_deregister(p_cb, (tBTA_GATTS_DATA*)p_msg);
      bta_gatts_deregister(p_cb, (tBTA_GATTS_DATA*)p_msg);
      break;
      break;
+0 −1
Original line number Original line Diff line number Diff line
@@ -184,7 +184,6 @@ bt_status_t btif_gattc_test_command_impl(int command,
        tmp.fill(0xAE);
        tmp.fill(0xAE);
        test_cb.gatt_if = GATT_Register(bluetooth::Uuid::From128BitBE(tmp),
        test_cb.gatt_if = GATT_Register(bluetooth::Uuid::From128BitBE(tmp),
                                        &btif_test_callbacks);
                                        &btif_test_callbacks);
        GATT_StartIf(test_cb.gatt_if);
      } else {
      } else {
        GATT_Deregister(test_cb.gatt_if);
        GATT_Deregister(test_cb.gatt_if);
        test_cb.gatt_if = 0;
        test_cb.gatt_if = 0;
Loading