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

Commit a6422356 authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Conclude the service search when the device is removed

When GATT service search is triggered on LTK derivation, bta_dm tries to connect over LE if LE ACL does not exists already. If the remote device is removed before LE ACL could be established, service search state is not reset. This blocks furthers requests for device or service discovery.

Change-Id: Ie080940179ba51edf3a223fbe3e896ef78c720cf
Test: Remove the bond within 30 seconds of pairing, try finding new devices
Bug: 281449565
parent 0d3404e3
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ void BTIF_dm_enable();
void btm_ble_adv_init(void);
void btm_ble_scanner_init(void);

static void bta_dm_gatt_disc_complete(uint16_t conn_id, tGATT_STATUS status);
static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, const uint8_t* p_eir,
                                  uint16_t eir_len);
static void bta_dm_inq_cmpl_cb(void* p_result);
@@ -603,6 +604,16 @@ static void bta_dm_process_remove_device_no_callback(
void bta_dm_process_remove_device(const RawAddress& bd_addr) {
  bta_dm_process_remove_device_no_callback(bd_addr);

  /* Conclude service search if it was pending */
  if (bta_dm_search_cb.state == BTA_DM_DISCOVER_ACTIVE &&
      bta_dm_search_cb.peer_bdaddr == bd_addr) {
    LOG_INFO(
        "Device removed while service discovery was pending, "
        "conclude the service disvovery");
    bta_dm_gatt_disc_complete((uint16_t)GATT_INVALID_CONN_ID,
                              (tGATT_STATUS)GATT_ERROR);
  }

  if (bta_dm_cb.p_sec_cback) {
    tBTA_DM_SEC sec_event;
    sec_event.link_down.bd_addr = bd_addr;