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

Commit b66aa618 authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Gerrit Code Review
Browse files

Merge "Get rid of tBTA_DM_SDP_RESULT" into main

parents 71251ff5 783de1dc
Loading
Loading
Loading
Loading
+23 −44
Original line number Diff line number Diff line
@@ -372,16 +372,23 @@ static void bta_dm_store_audio_profiles_version() {
  }
}

/*******************************************************************************
 *
 * Function         bta_dm_sdp_result
 *
 * Description      Process the discovery result from sdp
 *
 * Returns          void
 *
 ******************************************************************************/
static void bta_dm_sdp_result(tBTA_DM_SDP_RESULT& sdp_event) {
static void bta_dm_sdp_result(tSDP_STATUS sdp_result);

/* Callback from sdp with discovery status */
static void bta_dm_sdp_callback(const RawAddress& /* bd_addr */,
                                tSDP_STATUS sdp_status) {
  log::info("{}", bta_dm_state_text(bta_dm_discovery_get_state()));

  if (bta_dm_discovery_get_state() == BTA_DM_DISCOVER_IDLE) {
    bta_dm_free_sdp_db();
    return;
  }

  do_in_main_thread(FROM_HERE, base::BindOnce(&bta_dm_sdp_result, sdp_status));
}

/* Process the discovery result from sdp */
static void bta_dm_sdp_result(tSDP_STATUS sdp_result) {
  tSDP_DISC_REC* p_sdp_rec = NULL;
  bool scn_found = false;
  uint16_t service = 0xFFFF;
@@ -389,12 +396,9 @@ static void bta_dm_sdp_result(tBTA_DM_SDP_RESULT& sdp_event) {

  std::vector<Uuid> uuid_list;

  const tSDP_RESULT sdp_result = sdp_event.sdp_result;

  if ((sdp_event.sdp_result == SDP_SUCCESS) ||
      (sdp_event.sdp_result == SDP_NO_RECS_MATCH) ||
      (sdp_event.sdp_result == SDP_DB_FULL)) {
    log::verbose("sdp_result::0x{:x}", sdp_event.sdp_result);
  if ((sdp_result == SDP_SUCCESS) || (sdp_result == SDP_NO_RECS_MATCH) ||
      (sdp_result == SDP_DB_FULL)) {
    log::verbose("sdp_result::0x{:x}", sdp_result);
    do {
      p_sdp_rec = NULL;
      if (bta_dm_discovery_cb.service_index == (BTA_USER_SERVICE_ID + 1)) {
@@ -551,7 +555,7 @@ static void bta_dm_sdp_result(tBTA_DM_SDP_RESULT& sdp_event) {
        kBtmLogTag, bta_dm_discovery_cb.peer_bdaddr, "Discovery failed",
        base::StringPrintf("Result:%s", sdp_result_text(sdp_result).c_str()));
    log::error("SDP connection failed {}", sdp_status_text(sdp_result));
    if (sdp_event.sdp_result == SDP_CONN_FAILED)
    if (sdp_result == SDP_CONN_FAILED)
      bta_dm_discovery_cb.wait_disc = false;

    /* not able to connect go to next device */
@@ -901,22 +905,6 @@ static void bta_dm_discover_services(tBTA_DM_API_DISCOVER& discover) {
  bta_dm_find_services(bd_addr);
}

/*******************************************************************************
 *
 * Function         bta_dm_sdp_callback
 *
 * Description      Callback from sdp with discovery status
 *
 * Returns          void
 *
 ******************************************************************************/
static void bta_dm_sdp_callback(const RawAddress& /* bd_addr */,
                                tSDP_STATUS sdp_status) {
  post_disc_evt(BTA_DM_SDP_RESULT_EVT,
                std::make_unique<tBTA_DM_MSG>(
                    tBTA_DM_SDP_RESULT{.sdp_result = sdp_status}));
}

#ifndef BTA_DM_GATT_CLOSE_DELAY_TOUT
#define BTA_DM_GATT_CLOSE_DELAY_TOUT 1000
#endif
@@ -1178,8 +1166,8 @@ tBT_TRANSPORT bta_dm_determine_discovery_transport(const RawAddress& bd_addr) {
  return ::bta_dm_determine_discovery_transport(bd_addr);
}

void bta_dm_sdp_result(tBTA_DM_SDP_RESULT& sdp_event) {
  ::bta_dm_sdp_result(sdp_event);
void bta_dm_sdp_result(tSDP_STATUS sdp_status) {
  ::bta_dm_sdp_result(sdp_status);
}

}  // namespace testing
@@ -1235,9 +1223,6 @@ static void bta_dm_disc_sm_execute(tBTA_DM_DISC_EVT event,

          bta_dm_discover_services(std::get<tBTA_DM_API_DISCOVER>(*msg));
          break;
        case BTA_DM_SDP_RESULT_EVT:
          bta_dm_free_sdp_db();
          break;
        case BTA_DM_DISC_CLOSE_TOUT_EVT:
          bta_dm_close_gatt_conn();
          break;
@@ -1250,12 +1235,6 @@ static void bta_dm_disc_sm_execute(tBTA_DM_DISC_EVT event,

    case BTA_DM_DISCOVER_ACTIVE:
      switch (event) {
        case BTA_DM_SDP_RESULT_EVT:
          log::assert_that(std::holds_alternative<tBTA_DM_SDP_RESULT>(*msg),
                           "bad message type: {}", msg->index());

          bta_dm_sdp_result(std::get<tBTA_DM_SDP_RESULT>(*msg));
          break;
        case BTA_DM_DISCOVERY_RESULT_EVT:
          log::assert_that(std::holds_alternative<tBTA_DM_SVC_RES>(*msg),
                           "bad message type: {}", msg->index());
+1 −7
Original line number Diff line number Diff line
@@ -56,11 +56,6 @@ typedef struct {
  tBT_TRANSPORT transport;
} tBTA_DM_API_DISCOVER;

/* data type for BTA_DM_SDP_RESULT_EVT */
typedef struct {
  tSDP_RESULT sdp_result;
} tBTA_DM_SDP_RESULT;

typedef struct {
  RawAddress bd_addr;          /* BD address peer device. */
  tBTA_SERVICE_MASK services;  /* Services found on peer device. */
@@ -70,8 +65,7 @@ typedef struct {
  tHCI_STATUS hci_status;
} tBTA_DM_SVC_RES;

using tBTA_DM_MSG =
    std::variant<tBTA_DM_API_DISCOVER, tBTA_DM_SDP_RESULT, tBTA_DM_SVC_RES>;
using tBTA_DM_MSG = std::variant<tBTA_DM_API_DISCOVER, tBTA_DM_SVC_RES>;

typedef enum {
  BTA_DM_DISCOVER_IDLE,
+2 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ namespace legacy {
namespace testing {

tBTA_DM_SERVICE_DISCOVERY_CB& bta_dm_discovery_cb();
void bta_dm_sdp_result(tBTA_DM_SDP_RESULT& sdp_event);
void bta_dm_sdp_result(tSDP_STATUS sdp_status);

}  // namespace testing
}  // namespace legacy
@@ -75,6 +75,5 @@ TEST_F(BtaSdpRegisteredTest, bta_dm_sdp_result_SDP_SUCCESS) {

  mock_btm_client_interface.security.BTM_SecReadDevName =
      [](const RawAddress& bd_addr) -> const char* { return kName; };
  tBTA_DM_SDP_RESULT result{.sdp_result = SDP_SUCCESS};
  bluetooth::legacy::testing::bta_dm_sdp_result(result);
  bluetooth::legacy::testing::bta_dm_sdp_result(SDP_SUCCESS);
}
+0 −5
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ struct bta_dm_process_remove_device bta_dm_process_remove_device;
struct bta_dm_remove_device bta_dm_remove_device;
struct bta_dm_remote_key_missing bta_dm_remote_key_missing;
struct bta_dm_rm_cback bta_dm_rm_cback;
struct bta_dm_sdp_result bta_dm_sdp_result;
struct bta_dm_set_dev_name bta_dm_set_dev_name;
struct bta_dm_set_encryption bta_dm_set_encryption;
struct handle_remote_features_complete handle_remote_features_complete;
@@ -250,10 +249,6 @@ void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id, uint8_t app_id,
  inc_func_call_count(__func__);
  test::mock::bta_dm_act::bta_dm_rm_cback(status, id, app_id, peer_addr);
}
void bta_dm_sdp_result(tBTA_DM_SDP_RESULT& sdp_event) {
  inc_func_call_count(__func__);
  test::mock::bta_dm_act::bta_dm_sdp_result(sdp_event);
}
void bta_dm_set_dev_name(const std::vector<uint8_t>& name) {
  inc_func_call_count(__func__);
  test::mock::bta_dm_act::bta_dm_set_dev_name(name);
+0 −10
Original line number Diff line number Diff line
@@ -504,16 +504,6 @@ struct bta_dm_rm_cback {
};
extern struct bta_dm_rm_cback bta_dm_rm_cback;

// Name: bta_dm_sdp_result
// Params: tBTA_DM_SDP_RESULT& sdp_event
// Return: void
struct bta_dm_sdp_result {
  std::function<void(tBTA_DM_SDP_RESULT& sdp_event)> body{
      [](tBTA_DM_SDP_RESULT& /* sdp_event */) {}};
  void operator()(tBTA_DM_SDP_RESULT& sdp_event) { body(sdp_event); };
};
extern struct bta_dm_sdp_result bta_dm_sdp_result;

// Name: bta_dm_search_cancel_cmpl
// Params:
// Return: void