From: Zhihai Xu Date: Wed, 27 Nov 2013 08:40:53 +0000 (+0530) Subject: Bluetooth: GAP: Remove bonded device info on Authentication fail X-Git-Tag: android-x86-7.1-r1~1801 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=fc07218666349142c0de3b461921b8cda792aa76;p=android-x86%2Fsystem-bt.git 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 a0ea0b0aa..e72a95e45 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -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: diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c index a12c5cc0e..a8499382f 100644 --- a/btif/src/btif_storage.c +++ b/btif/src/btif_storage.c @@ -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;