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

Commit 21e70c4b authored by Zach Johnson's avatar Zach Johnson
Browse files

Simplfy BTA_SdpSearch

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I7b3459a08d98db2f2de3e4beaf94117e0fdb1a1c
parent 5029df2c
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -418,16 +418,11 @@ void bta_sdp_enable(tBTA_SDP_DM_CBACK* p_cback) {
 * Returns      void
 *
 ******************************************************************************/
void bta_sdp_search(tBTA_SDP_API_SEARCH* p_data) {
  if (p_data == NULL) {
    APPL_TRACE_DEBUG("SDP control block handle is null");
    return;
  }
void bta_sdp_search(const RawAddress bd_addr, const bluetooth::Uuid uuid) {
  tBTA_SDP_STATUS status = BTA_SDP_FAILURE;

  APPL_TRACE_DEBUG("%s in, sdp_active:%d", __func__, bta_sdp_cb.sdp_active);

  const Uuid& uuid = p_data->uuid;
  if (bta_sdp_cb.sdp_active != BTA_SDP_ACTIVE_NONE) {
    /* SDP is still in progress */
    status = BTA_SDP_BUSY;
@@ -435,18 +430,17 @@ void bta_sdp_search(tBTA_SDP_API_SEARCH* p_data) {
      tBTA_SDP_SEARCH_COMP result;
      memset(&result, 0, sizeof(result));
      result.uuid = uuid;
      result.remote_addr = p_data->bd_addr;
      result.remote_addr = bd_addr;
      result.status = status;
      tBTA_SDP bta_sdp;
      bta_sdp.sdp_search_comp = result;
      bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, &bta_sdp, NULL);
    }
    osi_free(p_data);
    return;
  }

  bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_YES;
  bta_sdp_cb.remote_addr = p_data->bd_addr;
  bta_sdp_cb.remote_addr = bd_addr;

  /* initialize the search for the uuid */
  APPL_TRACE_DEBUG("%s init discovery with UUID: %s", __func__,
@@ -456,8 +450,8 @@ void bta_sdp_search(tBTA_SDP_API_SEARCH* p_data) {

  Uuid* bta_sdp_search_uuid = (Uuid*)osi_malloc(sizeof(Uuid));
  *bta_sdp_search_uuid = uuid;
  if (!SDP_ServiceSearchAttributeRequest2(
          p_data->bd_addr, p_bta_sdp_cfg->p_sdp_db, bta_sdp_search_cback,
  if (!SDP_ServiceSearchAttributeRequest2(bd_addr, p_bta_sdp_cfg->p_sdp_db,
                                          bta_sdp_search_cback,
                                          (void*)bta_sdp_search_uuid)) {
    bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE;

@@ -466,7 +460,7 @@ void bta_sdp_search(tBTA_SDP_API_SEARCH* p_data) {
      tBTA_SDP_SEARCH_COMP result;
      memset(&result, 0, sizeof(result));
      result.uuid = uuid;
      result.remote_addr = p_data->bd_addr;
      result.remote_addr = bd_addr;
      result.status = status;
      tBTA_SDP bta_sdp;
      bta_sdp.sdp_search_comp = result;
@@ -476,7 +470,6 @@ void bta_sdp_search(tBTA_SDP_API_SEARCH* p_data) {
  /*
  else report the result when the cback is called
  */
  osi_free(p_data);
}

/*******************************************************************************
+1 −11
Original line number Diff line number Diff line
@@ -76,17 +76,7 @@ tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK* p_cback) {
 ******************************************************************************/
tBTA_SDP_STATUS BTA_SdpSearch(const RawAddress& bd_addr,
                              const bluetooth::Uuid& uuid) {
  tBTA_SDP_API_SEARCH* p_msg =
      (tBTA_SDP_API_SEARCH*)osi_malloc(sizeof(tBTA_SDP_API_SEARCH));

  APPL_TRACE_API("%s", __func__);

  p_msg->hdr.event = BTA_SDP_API_SEARCH_EVT;
  p_msg->bd_addr = bd_addr;
  p_msg->uuid = uuid;

  do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_search, p_msg));

  do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_search, bd_addr, uuid));
  return BTA_SDP_SUCCESS;
}

+2 −9
Original line number Diff line number Diff line
@@ -49,13 +49,6 @@ enum {
  BTA_SDP_ACTIVE_YES /* waiting for SDP result */
};

/* data type for BTA_SDP_API_SEARCH_EVT */
typedef struct {
  BT_HDR hdr;
  RawAddress bd_addr;
  bluetooth::Uuid uuid;
} tBTA_SDP_API_SEARCH;

/* data type for BTA_SDP_API_SEARCH_EVT */
typedef struct {
  BT_HDR hdr;
@@ -66,7 +59,6 @@ typedef struct {
typedef union {
  /* GKI event buffer header */
  BT_HDR hdr;
  tBTA_SDP_API_SEARCH get_search;
  tBTA_SDP_API_RECORD_USER record;
} tBTA_SDP_MSG;

@@ -86,7 +78,8 @@ extern tBTA_SDP_CFG* p_bta_sdp_cfg;
extern bool bta_sdp_sm_execute(BT_HDR* p_msg);

extern void bta_sdp_enable(tBTA_SDP_DM_CBACK* p_cback);
extern void bta_sdp_search(tBTA_SDP_API_SEARCH* p_data);
extern void bta_sdp_search(const RawAddress bd_addr,
                           const bluetooth::Uuid uuid);
extern void bta_sdp_create_record(tBTA_SDP_API_RECORD_USER* p_data);
extern void bta_sdp_remove_record(tBTA_SDP_API_RECORD_USER* p_data);