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

Commit 4392c2c4 authored by Hui Peng's avatar Hui Peng
Browse files

[Invisalign2] refactor btm_sec_rmt_name_request_complete

move the failing case to the beginning and return early

Bug: 301661850
Test: mma packages/modules/Bluetooth
Change-Id: I4a18b5f1f66554b06efa217a14a7c62722e19814
parent 818f6121
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -2356,7 +2356,17 @@ void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr,

  if (!p_bd_name) p_bd_name = (const uint8_t*)"";

  if (p_dev_rec != nullptr) {
  if (p_dev_rec == nullptr) {
    LOG_DEBUG(
        "Remote read request complete for unknown device pairing_state:%s "
        "status:%s name:%s",
        btm_pair_state_descr(btm_sec_cb.pairing_state),
        hci_status_code_text(status).c_str(), p_bd_name);

    call_registered_rmt_name_callbacks(p_bd_addr, nullptr, nullptr, status);
    return;
  }

    old_sec_state = p_dev_rec->sec_state;
    if (status == HCI_SUCCESS) {
      LOG_DEBUG(
@@ -2389,19 +2399,9 @@ void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr,
    /* Notify all clients waiting for name to be resolved */
    call_registered_rmt_name_callbacks(p_bd_addr, p_dev_rec->dev_class,
                                       p_dev_rec->sec_bd_name, status);
  } else {
    LOG_DEBUG(
        "Remote read request complete for unknown device pairing_state:%s "
        "status:%s name:%s",
        btm_pair_state_descr(btm_sec_cb.pairing_state),
        hci_status_code_text(status).c_str(), p_bd_name);

    call_registered_rmt_name_callbacks(p_bd_addr, nullptr, nullptr, status);
    return;
  }

  /* If we were delaying asking UI for a PIN because name was not resolved, ask
   * now */
    /* If we were delaying asking UI for a PIN because name was not resolved,
     * ask now */
    if ((btm_sec_cb.pairing_state == BTM_PAIR_STATE_WAIT_LOCAL_PIN) &&
        p_bd_addr && (btm_sec_cb.pairing_bda == *p_bd_addr)) {
      LOG_VERBOSE(