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

Commit f1f07b05 authored by Myles Watson's avatar Myles Watson
Browse files

BTM: Do not start authentication twice

Originally, this code used an alarm to delay authentication requests.
When an incoming authentication request arrived, the alarm was
checked first. That check was removed with the alarm, so this CL
adds a check to see if the device is authenticating before starting
the process.

Bug: 270161453
Test: atest pts-bot
Change-Id: I0cd19a3070656c3882323d1fa87caed1ee330e1e
Merged-In: I0cd19a3070656c3882323d1fa87caed1ee330e1e
parent 51e1638c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4502,7 +4502,6 @@ static bool btm_sec_start_get_name(tBTM_SEC_DEV_REC* p_dev_rec) {
 *
 ******************************************************************************/
static void btm_sec_wait_and_start_authentication(tBTM_SEC_DEV_REC* p_dev_rec) {
  p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING;
  auto addr = new RawAddress(p_dev_rec->bd_addr);

  static const int32_t delay_auth =
@@ -4537,8 +4536,11 @@ static void btm_sec_auth_timer_timeout(void* data) {
    LOG_INFO("%s: invalid device or not found", __func__);
  } else if (btm_dev_authenticated(p_dev_rec)) {
    LOG_INFO("%s: device is already authenticated", __func__);
  } else if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) {
    LOG_INFO("%s: device is in the process of authenticating", __func__);
  } else {
    LOG_INFO("%s: starting authentication", __func__);
    p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING;
    btsnd_hcic_auth_request(p_dev_rec->hci_handle);
  }
}