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

Commit b4c0e78a authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Make SDP and inquiry request dequeue and execute more comprehensive and

cancelDiscovery now removes all queued inquiry requests.

Ignore-AOSP-First: Submitting for QPR1 & fix needs to be reworked for AOSP
Tag: #feature
Bug: 198178836
Test: Manual
Merged-In: I7b9fc60f090e507c9905ed98c8d2c82d0a9a1fd2
Change-Id: I7b9fc60f090e507c9905ed98c8d2c82d0a9a1fd2
parent 1892a884
Loading
Loading
Loading
Loading
+3 −12
Original line number Original line Diff line number Diff line
@@ -979,7 +979,7 @@ static bool bta_dm_read_remote_device_name(const RawAddress& bd_addr,
void bta_dm_inq_cmpl(uint8_t num) {
void bta_dm_inq_cmpl(uint8_t num) {
  if (bta_dm_search_get_state() == BTA_DM_SEARCH_CANCELLING) {
  if (bta_dm_search_get_state() == BTA_DM_SEARCH_CANCELLING) {
    bta_dm_search_set_state(BTA_DM_SEARCH_IDLE);
    bta_dm_search_set_state(BTA_DM_SEARCH_IDLE);
    bta_dm_search_cancel_cmpl();
    bta_dm_execute_queued_request();
    return;
    return;
  }
  }


@@ -1278,6 +1278,7 @@ void bta_dm_search_cmpl() {
  /* no BLE connection, i.e. Classic service discovery end */
  /* no BLE connection, i.e. Classic service discovery end */
  if (conn_id == GATT_INVALID_CONN_ID) {
  if (conn_id == GATT_INVALID_CONN_ID) {
    bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);
    bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);
    bta_dm_execute_queued_request();
    return;
    return;
  }
  }


@@ -1288,6 +1289,7 @@ void bta_dm_search_cmpl() {
  if (count == 0) {
  if (count == 0) {
    LOG_INFO("Empty GATT database - no BLE services discovered");
    LOG_INFO("Empty GATT database - no BLE services discovered");
    bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);
    bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr);
    bta_dm_execute_queued_request();
    return;
    return;
  }
  }


@@ -1498,17 +1500,6 @@ void bta_dm_search_clear_queue() {
  fixed_queue_flush(bta_dm_search_cb.pending_discovery_queue, osi_free);
  fixed_queue_flush(bta_dm_search_cb.pending_discovery_queue, osi_free);
}
}


/*******************************************************************************
 *
 * Function         bta_dm_search_cancel_cmpl
 *
 * Description      Search cancel is complete
 *
 * Returns          void
 *
 ******************************************************************************/
void bta_dm_search_cancel_cmpl() { bta_dm_execute_queued_request(); }

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         bta_dm_search_cancel_notify
 * Function         bta_dm_search_cancel_notify
+2 −1
Original line number Original line Diff line number Diff line
@@ -103,6 +103,8 @@ void BTA_DmSearch(tBTA_DM_SEARCH_CBACK* p_cback, bool is_bonding_or_sdp) {
 *
 *
 ******************************************************************************/
 ******************************************************************************/
void BTA_DmSearchCancel(void) {
void BTA_DmSearchCancel(void) {
  bta_dm_search_clear_queue();

  switch (bta_dm_search_get_state()) {
  switch (bta_dm_search_get_state()) {
    case BTA_DM_SEARCH_IDLE:
    case BTA_DM_SEARCH_IDLE:
      bta_dm_search_cancel_notify();
      bta_dm_search_cancel_notify();
@@ -112,7 +114,6 @@ void BTA_DmSearchCancel(void) {
      bta_dm_search_cancel();
      bta_dm_search_cancel();
      break;
      break;
    case BTA_DM_SEARCH_CANCELLING:
    case BTA_DM_SEARCH_CANCELLING:
      bta_dm_search_clear_queue();
      bta_dm_search_cancel_notify();
      bta_dm_search_cancel_notify();
      break;
      break;
    case BTA_DM_DISCOVER_ACTIVE:
    case BTA_DM_DISCOVER_ACTIVE:
+0 −1
Original line number Original line Diff line number Diff line
@@ -541,7 +541,6 @@ extern void bta_dm_queue_disc(tBTA_DM_MSG* p_data);
extern void bta_dm_execute_queued_request();
extern void bta_dm_execute_queued_request();
extern bool bta_dm_is_search_request_queued();
extern bool bta_dm_is_search_request_queued();
extern void bta_dm_search_clear_queue();
extern void bta_dm_search_clear_queue();
extern void bta_dm_search_cancel_cmpl();
extern void bta_dm_search_cancel_notify();
extern void bta_dm_search_cancel_notify();
extern void bta_dm_disc_rmt_name(tBTA_DM_MSG* p_data);
extern void bta_dm_disc_rmt_name(tBTA_DM_MSG* p_data);
extern tBTA_DM_PEER_DEVICE* bta_dm_find_peer_device(
extern tBTA_DM_PEER_DEVICE* bta_dm_find_peer_device(
+1 −1
Original line number Original line Diff line number Diff line
@@ -129,7 +129,7 @@ bool bta_dm_search_sm_execute(BT_HDR_RIGID* p_msg) {
          bta_dm_search_set_state(BTA_DM_SEARCH_IDLE);
          bta_dm_search_set_state(BTA_DM_SEARCH_IDLE);
          bta_dm_free_sdp_db();
          bta_dm_free_sdp_db();
          bta_dm_search_cancel_notify();
          bta_dm_search_cancel_notify();
          bta_dm_search_cancel_cmpl();
          bta_dm_execute_queued_request();
          break;
          break;
      }
      }
      break;
      break;
+0 −2
Original line number Original line Diff line number Diff line
@@ -473,7 +473,6 @@ static void bond_state_changed(bt_status_t status, const RawAddress& bd_addr,
    pairing_cb.bd_addr = bd_addr;
    pairing_cb.bd_addr = bd_addr;
  } else {
  } else {
    pairing_cb = {};
    pairing_cb = {};
    bta_dm_execute_queued_request();
  }
  }
}
}


@@ -1330,7 +1329,6 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event,
        // Both SDP and bonding are done, clear pairing control block in case
        // Both SDP and bonding are done, clear pairing control block in case
        // it is not already cleared
        // it is not already cleared
        pairing_cb = {};
        pairing_cb = {};
        bta_dm_execute_queued_request();


        // Send one empty UUID to Java to unblock pairing intent when SDP failed
        // Send one empty UUID to Java to unblock pairing intent when SDP failed
        // or no UUID is discovered
        // or no UUID is discovered
Loading