OSDN Git Service

Bluetooth: GAP: Remove bonded device info on Authentication fail
authorZhihai Xu <zhihaixu@google.com>
Wed, 27 Nov 2013 08:40:53 +0000 (14:10 +0530)
committerMatthew Xie <mattx@google.com>
Tue, 6 May 2014 08:14:24 +0000 (01:14 -0700)
Remove bonded device information from the BT-IF layer storage
on authentication failure if already bonded with just works
model.
from QCOM
Change-Id: Ia3c1635c446f39b1dbd4cdd0122c2f70cbbc8dd7

btif/src/btif_dm.c
btif/src/btif_storage.c

index a0ea0b0..e72a95e 100644 (file)
@@ -893,6 +893,7 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
 
             /* map the auth failure codes, so we can retry pairing if necessary */
             case HCI_ERR_AUTH_FAILURE:
+                btif_storage_remove_bonded_device(&bd_addr);
             case HCI_ERR_HOST_REJECT_SECURITY:
             case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE:
             case HCI_ERR_UNIT_KEY_USED:
index a12c5cc..a849938 100644 (file)
@@ -803,9 +803,13 @@ bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr)
     bdstr_t bdstr;
     bd2str(remote_bd_addr, &bdstr);
     BTIF_TRACE_DEBUG1("in bd addr:%s", bdstr);
-    int ret = btif_config_remove("Remote", bdstr, "LinkKeyType");
-    ret &= btif_config_remove("Remote", bdstr, "PinLength");
-    ret &= btif_config_remove("Remote", bdstr, "LinkKey");
+    int ret = 1;
+    if(btif_config_exist("Remote", bdstr, "LinkKeyType"))
+        ret &= btif_config_remove("Remote", bdstr, "LinkKeyType");
+    if(btif_config_exist("Remote", bdstr, "PinLength"))
+        ret &= btif_config_remove("Remote", bdstr, "PinLength");
+    if(btif_config_exist("Remote", bdstr, "LinkKey"))
+        ret &= btif_config_remove("Remote", bdstr, "LinkKey");
     /* write bonded info immediately */
     btif_config_flush();
     return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;