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

Commit f5a771b8 authored by cheng_cai's avatar cheng_cai Committed by Chris Manton
Browse files

Fix discover service process using wrong transport

Application may use createBond by transport API to bond with a dual mode
device. If the stack doesn’t get a name from the adv packet, the
stack will start to discover remote name before discovering remote
service. As stack will clear the bta_dm_search_cb.transport flag after
searching remote name, the sdp protocol will be used to discover remote
services, but actually it should use gatt protocol.

Bug: 154299225
Test: Create bond with a dual mode device using le transport
Tag: #compatibility
Sponsor: optedoblivion@
Change-Id: I05b9fa9cf9801cf681e195d490d77d61f77e43a3
parent 84b0bdc5
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1628,9 +1628,6 @@ static void bta_dm_discover_device(const RawAddress& remote_bd_addr) {
    transport = bta_dm_search_cb.transport;
  }

  /* Reset transport state for next discovery */
  bta_dm_search_cb.transport = BT_TRANSPORT_UNKNOWN;

  VLOG(1) << __func__ << " BDA: " << remote_bd_addr;

  bta_dm_search_cb.peer_bdaddr = remote_bd_addr;
@@ -1659,13 +1656,22 @@ static void bta_dm_discover_device(const RawAddress& remote_bd_addr) {
      ((bta_dm_search_cb.p_btm_inq_info == NULL) ||
       (bta_dm_search_cb.p_btm_inq_info &&
        (!bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name)))) {
    if (bta_dm_read_remote_device_name(bta_dm_search_cb.peer_bdaddr, transport))
    if (bta_dm_read_remote_device_name(bta_dm_search_cb.peer_bdaddr,
                                       transport)) {
      if (bta_dm_search_cb.state != BTA_DM_DISCOVER_ACTIVE) {
        /* Reset transport state for next discovery */
        bta_dm_search_cb.transport = BT_TRANSPORT_UNKNOWN;
      }
      return;
    }

    /* starting name discovery failed */
    bta_dm_search_cb.name_discover_done = true;
  }

  /* Reset transport state for next discovery */
  bta_dm_search_cb.transport = BT_TRANSPORT_UNKNOWN;

  /* if application wants to discover service */
  if (bta_dm_search_cb.services) {
    /* initialize variables */