From 47881c733f6cdd0de66e7ccc4e32d873f1842e5b Mon Sep 17 00:00:00 2001 From: "ilbeom.kim" <ilbeom.kim@lge.com> Date: Thu, 12 Apr 2018 08:26:10 +0900 Subject: [PATCH] Don't start the authentication when peer device already started it If host gets link_key_request event from the controller, it means peer device started the authentication. In this case, host should not start the authentication because it will be caused the authentication collision by controller side. This sequence can be referred at BT 4.2 core specification document, p.1388, Figure 4.2. Bug: 74241491 Test: Manual - Connect Android wear to Android phone - Turn off BT on Android wear - Turn on BT on Android wear - Observe the logcat whether connection time is within 30 seconds Android Wear Stability Test Change-Id: I138d45316ea75dd96444c36bde36ce15a64b669a --- system/stack/btm/btm_sec.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc index b0809010f50..87601a0c160 100644 --- a/system/stack/btm/btm_sec.cc +++ b/system/stack/btm/btm_sec.cc @@ -4046,6 +4046,8 @@ void btm_sec_encrypt_change(uint16_t handle, uint8_t status, __func__, p_dev_rec, p_dev_rec->p_callback); p_dev_rec->p_callback = NULL; l2cu_resubmit_pending_sec_req(&p_dev_rec->bd_addr); + } else if (p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) { + p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; } return; } @@ -4700,6 +4702,7 @@ void btm_sec_link_key_request(const RawAddress& bda) { tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(bda); VLOG(2) << __func__ << " bda: " << bda; + p_dev_rec->sec_state = BTM_SEC_STATE_AUTHENTICATING; if ((btm_cb.pairing_state == BTM_PAIR_STATE_WAIT_PIN_REQ) && (btm_cb.collision_start_time != 0) && -- GitLab