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

Commit 2a280477 authored by Srinu Jella's avatar Srinu Jella Committed by Jack He
Browse files

Serialize the commands during Pairing process

Steps:
1. Pair and connect with HID mouse.
2. Once the settings UI shows paired and connected
3. Try to unpair the device, but UI still shows connected.

Failure: Unable to unpair HID mouse due to LMP
response timeout occurred for  remote version and remote
feature request.

Root Cause: Remote version, Remote features, Authentication
requested commands go simultaneously to the remote device
which can't handle the multiple commands at a time.

Fix: Serialize the Remote version, Remote features, Authentication
requested commands.

Test: Tested manually with apple magic mouse.
Bug: 35125883

Change-Id: I4448c291a60ee637dc5927806547e67f26571d86
(cherry picked from commit 485f6429)
parent d32815dc
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -283,8 +283,6 @@ void btm_acl_created(const RawAddress& bda, DEV_CLASS dc, BD_NAME bdn,
        } else {
          btm_establish_continue(p);
        }
      } else {
        btm_read_remote_features(p->hci_handle);
      }

      /* read page 1 - on rmt feature event for buffer reasons */
@@ -351,7 +349,7 @@ void btm_acl_removed(const RawAddress& bda, tBT_TRANSPORT transport) {
    if (p->link_up_issued) {
      p->link_up_issued = false;

      /* If anyone cares, tell him database changed */
      /* If anyone cares, indicate the database changed */
      if (btm_cb.p_bl_changed_cb) {
        tBTM_BL_EVENT_DATA evt_data;
        evt_data.event = BTM_BL_DISCN_EVT;
@@ -884,6 +882,10 @@ void btm_read_remote_version_complete(uint8_t* p) {
        STREAM_TO_UINT8(p_acl_cb->lmp_version, p);
        STREAM_TO_UINT16(p_acl_cb->manufacturer, p);
        STREAM_TO_UINT16(p_acl_cb->lmp_subversion, p);

        if (p_acl_cb->transport == BT_TRANSPORT_BR_EDR) {
          btm_read_remote_features(p_acl_cb->hci_handle);
        }
      }

      if (p_acl_cb->transport == BT_TRANSPORT_LE) {
@@ -933,6 +935,16 @@ void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
           HCI_FEATURE_BYTES_PER_PAGE);
  }

  if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) ||
      p_dev_rec->is_originator) {
    BTM_TRACE_DEBUG("%s: Calling Next Security Procedure", __func__);
    uint8_t status = btm_sec_execute_procedure(p_dev_rec);
    if (status != BTM_CMD_STARTED) {
      BTM_TRACE_ERROR("%s: Security procedure not started! status %d", __func__,
                      status);
      btm_sec_dev_rec_cback_event(p_dev_rec, status, false);
    }
  }
  const uint8_t req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);

  /* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
@@ -1177,6 +1189,10 @@ void btm_establish_continue(tACL_CONN* p_acl_cb) {
      BTM_SetLinkPolicy(p_acl_cb->remote_addr, &btm_cb.btm_def_link_policy);
  }
#endif
  if (p_acl_cb->link_up_issued) {
    BTM_TRACE_ERROR("%s: Already link is up ", __func__);
    return;
  }
  p_acl_cb->link_up_issued = true;

  /* If anyone cares, tell him database changed */
+1 −0
Original line number Diff line number Diff line
@@ -289,5 +289,6 @@ extern void btm_acl_reset_paging(void);
extern void btm_acl_paging(BT_HDR* p, const RawAddress& dest);
extern uint8_t btm_sec_clr_service_by_psm(uint16_t psm);
extern void btm_sec_clr_temp_auth_service(const RawAddress& bda);
extern tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec);

#endif
+1 −2
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ static tBTM_SEC_SERV_REC* btm_sec_find_mx_serv(uint8_t is_originator,
                                               uint32_t mx_proto_id,
                                               uint32_t mx_chan_id);

static tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec);
static bool btm_sec_start_get_name(tBTM_SEC_DEV_REC* p_dev_rec);
static void btm_sec_start_authentication(tBTM_SEC_DEV_REC* p_dev_rec);
static void btm_sec_start_encryption(tBTM_SEC_DEV_REC* p_dev_rec);
@@ -5014,7 +5013,7 @@ void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset) {
 *                  BTM_NO_RESOURCES  - permission declined
 *
 ******************************************************************************/
static tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec) {
tBTM_STATUS btm_sec_execute_procedure(tBTM_SEC_DEV_REC* p_dev_rec) {
  BTM_TRACE_EVENT(
      "btm_sec_execute_procedure: Required:0x%x Flags:0x%x State:%d",
      p_dev_rec->security_required, p_dev_rec->sec_flags, p_dev_rec->sec_state);