Bluetooth: GAP: Remove bonded device info on Authentication fail
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
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index a0ea0b0..e72a95e 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -893,6 +893,7 @@
/* 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:
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index a12c5cc..a849938 100644
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -803,9 +803,13 @@
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;