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

Commit b5d1ea3f authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

bta_dm: Remove canceling service discovery on BTA_DmSearchCancel()

This patch removes canceling of ongoing service discovery.
It was done on BTA_DmSearchCancel() which should cancel BTA_DmSearch()
operations.
Service discovery is started with BTA_DmDiscover() and seems that
it should not be canceled unless link is disconnected.

Main problem which is fixed by this patch is following scenario

1. Device A is bonded and service discovery is started
2. Device B create bond has started and user accepted it
3. After 2), BTA_DmSearchCancel() is called to stop Inquiry and LE scan,
   however this function also stops Service Discovery started by
BTA_DmDiscover()
4. Because of 3), Device A is bonded but without any known services and
   there is no way to trigger service discovery again unless unbond and
   bonding again.

Issue can be easily reproduced with 2 Hearing Aids if bonding
has been called not from AOSP Settings but from external application which
can do it fast.
This issue might also create problems with future LeAudio devices.

test: atest -b -i -t -c BluetoothInstrumentationTests
sponsor: jpawlowski@

Reviewed-on: https://gerrit.codecoup.pl/c/aosp/platform/system/bt/+/3616


Reviewed-by: default avatarJakub Tyszkowski <jakub.tyszkowski@codecoup.pl>
Change-Id: Ie944b705d908d4b9283b99da0e36854b0b72d09e
parent 4786b942
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -117,7 +117,6 @@ static void bta_dm_ble_id_key_cback(uint8_t key_type,
                                    tBTM_BLE_LOCAL_KEYS* p_key);
static void bta_dm_gattc_register(void);
static void btm_dm_start_gatt_discovery(const RawAddress& bd_addr);
static void bta_dm_cancel_gatt_discovery(const RawAddress& bd_addr);
static void bta_dm_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC* p_data);
extern tBTM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void);
#if (BLE_VND_INCLUDED == TRUE)
@@ -880,10 +879,6 @@ void bta_dm_search_cancel() {
  } else {
    bta_dm_inq_cmpl(0);
  }

  if (bta_dm_search_cb.gatt_disc_active) {
    bta_dm_cancel_gatt_discovery(bta_dm_search_cb.peer_bdaddr);
  }
}

/*******************************************************************************
@@ -1532,9 +1527,6 @@ void bta_dm_search_cancel_notify() {
       bta_dm_search_cb.state == BTA_DM_SEARCH_CANCELLING)) {
    BTM_CancelRemoteDeviceName();
  }
  if (bta_dm_search_cb.gatt_disc_active) {
    bta_dm_cancel_gatt_discovery(bta_dm_search_cb.peer_bdaddr);
  }
}

/*******************************************************************************
@@ -3961,23 +3953,6 @@ void btm_dm_start_gatt_discovery(const RawAddress& bd_addr) {
  }
}

/*******************************************************************************
 *
 * Function         bta_dm_cancel_gatt_discovery
 *
 * Description      This is GATT cancel the GATT service search.
 *
 * Parameters:
 *
 ******************************************************************************/
static void bta_dm_cancel_gatt_discovery(const RawAddress& bd_addr) {
  if (bta_dm_search_cb.conn_id == GATT_INVALID_CONN_ID) {
    BTA_GATTC_CancelOpen(bta_dm_search_cb.client_if, bd_addr, true);
  }

  bta_dm_gatt_disc_complete(bta_dm_search_cb.conn_id, (tGATT_STATUS)GATT_ERROR);
}

/*******************************************************************************
 *
 * Function         bta_dm_proc_open_evt