OSDN Git Service

GAP Setting remove device pending status as FALSE
authorBalraj Selvaraj <bselva@codeaurora.org>
Thu, 11 Feb 2016 08:16:02 +0000 (13:46 +0530)
committerAndre Eisenbach <eisenbach@google.com>
Fri, 4 Mar 2016 18:53:04 +0000 (10:53 -0800)
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

bta/dm/bta_dm_act.c

index 0dfec09..73d7afb 100644 (file)
@@ -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
     {
@@ -3454,6 +3461,29 @@ static void bta_dm_delay_role_switch_cback(UNUSED_ATTR void *data)
 
 /*******************************************************************************
 **
+** 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
 **
 ** Description      Removes device entry from Security device DB if ACL connection with