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

Commit 22bd60c6 authored by Balraj Selvaraj's avatar Balraj Selvaraj Committed by Andre Eisenbach
Browse files

GAP Setting remove device pending status as FALSE

Use case: DUT deletes Link key and failed to initiate
  authentication request after remote headset turned Off and ON

steps:
- Pair the DUT and HS. (Link Keys get established.)
- Now Switch OFF BT on DUT. (DUT still has the Link key of HS)
- Reset the paired devices memory in HS and keep HS in
  pairing mode. (HS loses DUT's link key)
- Now switch ON BT on DUT. (DUT starts reconnection with HS,
  but as HS lost DUT's key, PIN or KEY missing event will
  come to host)
- DUT reconnects to HS (Using newly established link keys)
- Now power OFF and ON the HS.
- HS will try reconnection with DUT.
- While there is an incoming connection from HS to DUT,
  host is giving negative link key reply always for the
  multiple link key requests from HS.
- HS sends disconnection with "Authentication failure"

Failure: DUT should not delete Link key and DUT should
  initiate Authenticatin request.

Root cause: pending status was not FALSE from security device
  DB, which will causing Authentication Failure.

Fix: Setting the remove device pending status to FALSE from
  security device DB, when the link key notification event
  comes. Basically it will avoid deleting the device from
  security device DB, Which is solving the reconnection
  initated from remote when we remove the link key at
  remote side.

Change-Id: Ic164d8d5b5c2e0b9cc5f04f993047fb0a8e5d9a9
parent bc18a270
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result);
#define BTA_DM_SWITCH_DELAY_TIMER_MS 500
#endif

static void bta_dm_reset_sec_dev_pending(BD_ADDR remote_bd_addr);
static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
static void bta_dm_observe_cmpl_cb(void * p_result);
@@ -2764,6 +2765,12 @@ static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class,
#endif
        if(bta_dm_cb.p_sec_cback)
            bta_dm_cb.p_sec_cback(event, &sec_event);

        // Setting remove_dev_pending flag to FALSE, where it will avoid deleting the
        // security device record when the ACL connection link goes down in case of
        // reconnection.
        if (bta_dm_cb.device_list.count)
            bta_dm_reset_sec_dev_pending(p_auth_cmpl->bd_addr);
    }
    else
    {
@@ -3452,6 +3459,29 @@ static void bta_dm_delay_role_switch_cback(UNUSED_ATTR void *data)
    bta_dm_adjust_roles(FALSE);
}

/*******************************************************************************
**
** Function         bta_dm_reset_sec_dev_pending
**
** Description      Setting the remove device pending status to FALSE from
**                  security device DB, when the link key notification
**                  event comes.
**
** Returns          void
**
*******************************************************************************/
static void bta_dm_reset_sec_dev_pending(BD_ADDR remote_bd_addr)
{
    for (size_t i = 0; i < bta_dm_cb.device_list.count; i++)
    {
        if (bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, remote_bd_addr) == 0)
        {
            bta_dm_cb.device_list.peer_device[i].remove_dev_pending = FALSE;
            return;
        }
    }
}

/*******************************************************************************
**
** Function         bta_dm_remove_sec_dev_entry