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

Commit ec401373 authored by Michael Sun's avatar Michael Sun
Browse files

Handle “already authenticated” with authentication race

When the host initiates an authentication but is raced by a
device-initiated authentication and the device-initiated authentication
completes first, the "already authenticated" handling leaves the
host-initiated authentication request in a pending state. For RFCOMM
channels, this results in a pending socket port that does not close
until a timeout occurs, which later can compete with HFP opening.

Bug: 301563951
Tag: #floss
Test: emerge-brya floss
Test: m com.android.btservices

Change-Id: Ib682dbed7032580d83f9921310321ba677668fbf
parent ed649a3d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -4664,6 +4664,10 @@ 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__);
    if (p_dev_rec->p_callback) {
      (*p_dev_rec->p_callback)(&p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR,
                               p_dev_rec->p_ref_data, BTM_SUCCESS);
    }
  } else if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) {
    LOG_INFO("%s: device is in the process of authenticating", __func__);
  } else {