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

Commit a8dedda0 authored by Chris Manton's avatar Chris Manton
Browse files

rnr: Condition upon hci status

Bug: 254358644
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines
Ignore-AOSP-First: Cherry-pick

Merged-In: I69c866b0177bbee5be1d0962e07912e265435cbe
Change-Id: I69c866b0177bbee5be1d0962e07912e265435cbe
parent 4ef3cfb3
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -1969,12 +1969,29 @@ static void bta_dm_remname_cback(void* p) {
      BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
    }
  } else {
    // if we got a different response, ignore it
    // if we got a different response, maybe ignore it
    // we will have made a request directly from BTM_ReadRemoteDeviceName so we
    // expect a dedicated response for us
    LOG_INFO("ignoring remote name response in DM callback since it's for the wrong bd_addr");
    if (p_remote_name->hci_status == HCI_ERR_CONNECTION_EXISTS) {
      if (bluetooth::shim::is_gd_security_enabled()) {
        bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback(
            &bta_dm_service_search_remname_cback);
      } else {
        BTM_SecDeleteRmtNameNotifyCallback(
            &bta_dm_service_search_remname_cback);
      }
      LOG_INFO(
          "Assume command failed due to disconnection hci_status:%s peer:%s",
          hci_error_code_text(p_remote_name->hci_status).c_str(),
          PRIVATE_ADDRESS(p_remote_name->bd_addr));
    } else {
      LOG_INFO(
          "Ignored remote name response for the wrong address exp:%s act:%s",
          PRIVATE_ADDRESS(bta_dm_search_cb.peer_bdaddr),
          PRIVATE_ADDRESS(p_remote_name->bd_addr));
      return;
    }
  }

  /* remote name discovery is done but it could be failed */
  bta_dm_search_cb.name_discover_done = true;