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

Commit 75081bf2 authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Don't abort pairing due to unrelated name discovery

Pairing may get aborted if an unreleated name discovery concludes before
name discovery for the pairing is concluded.

Test: mmm packages/modules/Bluetooth
Flag: com.android.bluetooth.flags.pairing_name_discovery_addresss_mismatch
Bug: 336606577
Bug: 349144497
Change-Id: I684b39a0614eb0ca61976c77c6ebbdb312d26bf4
parent 68247bbc
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -2259,7 +2259,20 @@ void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr, const uint8_

  /* Check if we were delaying bonding because name was not resolved */
  if (btm_sec_cb.pairing_state == BTM_PAIR_STATE_GET_REM_NAME) {
    if (btm_sec_cb.pairing_bda == bd_addr) {
    if (btm_sec_cb.pairing_bda != bd_addr) {
      log::warn("wrong BDA, retry with pairing BDA");
      tBTM_STATUS btm_status = get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(
              btm_sec_cb.pairing_bda, NULL, BT_TRANSPORT_BR_EDR);
      if (btm_status != BTM_CMD_STARTED) {
        log::warn("failed ({}) to restart remote name request for pairing, must be already queued",
                  btm_status_text(btm_status));
        if (!com::android::bluetooth::flags::pairing_name_discovery_addresss_mismatch()) {
          NotifyBondingChange(*p_dev_rec, HCI_ERR_MEMORY_FULL);
        }
      }
      return;
    }

    log::verbose("continue bonding sm4: 0x{:04x}, status:0x{:x}", p_dev_rec->sm4, status);
    if (btm_sec_cb.pairing_flags & BTM_PAIR_FLAGS_WE_CANCEL_DD) {
      btm_sec_bond_cancel_complete();
@@ -2320,15 +2333,6 @@ void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr, const uint8_
        log::debug("Wait for connection to begin pairing");
        return;
      }
    } else {
      log::warn("wrong BDA, retry with pairing BDA");
      if (get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(
                  btm_sec_cb.pairing_bda, NULL, BT_TRANSPORT_BR_EDR) != BTM_CMD_STARTED) {
        log::error("failed to start remote name request");
        NotifyBondingChange(*p_dev_rec, HCI_ERR_MEMORY_FULL);
      };
      return;
    }
  }

  /* check if we were delaying link_key_callback because name was not resolved