From 17706aa42214addb95ee4aea5177a8784960dfc1 Mon Sep 17 00:00:00 2001 From: Harish Paryani Date: Wed, 7 Mar 2012 16:36:03 -0800 Subject: Disconnect before Unpair Change-Id: Ib28372748df21d36d371d308975758f60df7aa28 --- btif/include/btif_common.h | 1 - btif/src/btif_dm.c | 29 ++++++++++------------------- 2 files changed, 10 insertions(+), 20 deletions(-) mode change 100644 => 100755 btif/include/btif_common.h mode change 100644 => 100755 btif/src/btif_dm.c (limited to 'btif') diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h old mode 100644 new mode 100755 index f594ee4..a440802 --- a/btif/include/btif_common.h +++ b/btif/include/btif_common.h @@ -135,7 +135,6 @@ enum BTIF_DM_CB_START = BTIF_SIG_CB_START(BTIF_DM), BTIF_DM_CB_DISCOVERY_STARTED, /* Discovery has started */ BTIF_DM_CB_BONDING_STARTED, /* Bonding process has started */ - BTIF_DM_CB_REMOVED_BONDING /* Bonded device deleted */ }; /************************************************************************************ diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c old mode 100644 new mode 100755 index 8fbc31d..9626457 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -679,7 +679,8 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) tBTA_DM_SEC *p_data = (tBTA_DM_SEC*)p_param; tBTA_SERVICE_MASK service_mask; uint32_t i; - + bt_bdaddr_t bd_addr; + BTIF_TRACE_EVENT1("btif_dm_upstreams_cback ev: %d", event); switch (event) @@ -758,6 +759,13 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) case BTA_DM_SP_KEY_NOTIF_EVT: btif_dm_ssp_key_notif_evt(&p_data->key_notif); break; + + case BTA_DM_DEV_UNPAIRED_EVT: + bdcpy(bd_addr.address, p_data->link_down.bd_addr); + btif_storage_remove_bonded_device(&bd_addr); + CHECK_CALL_CBACK(bt_hal_cbacks, bond_state_changed_cb, BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_NONE); + break; + case BTA_DM_AUTHORIZE_EVT: case BTA_DM_LINK_DOWN_EVT: case BTA_DM_SIG_STRENGTH_EVT: @@ -801,19 +809,6 @@ static void btif_dm_generic_evt(UINT16 event, char* p_param) } break; - case BTIF_DM_CB_REMOVED_BONDING: - { - bt_bdaddr_t *bd_addr = (bt_bdaddr_t*)p_param; - bt_status_t status; - - status = btif_storage_remove_bonded_device(bd_addr); - ASSERTC(status == BT_STATUS_SUCCESS, "failed to delete bonded device", status); - - CHECK_CALL_CBACK(bt_hal_cbacks, bond_state_changed_cb, - BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_NONE); - } - break; - default: { BTIF_TRACE_WARNING2("%s : Unknown event 0x%x", __FUNCTION__, event); @@ -1051,14 +1046,10 @@ bt_status_t btif_dm_remove_bond(const bt_bdaddr_t *bd_addr) BTIF_TRACE_DEBUG1("Successfully removed bonding with device: %s", bd2str((bt_bdaddr_t *)bd_addr, &bdstr)); - /* Device shall be removed from the storage in the btif context */ - btif_transfer_context(btif_dm_generic_evt, BTIF_DM_CB_REMOVED_BONDING, - (char*)bd_addr, sizeof(bt_bdaddr_t), NULL); } else { - /* TODO: ACL is already up with this device, disconnect and then issue RemoveBond */ - BTIF_TRACE_WARNING0("ACL connection exists with device. Disconnect and issue remove bonding"); + return BT_STATUS_FAIL; } return BT_STATUS_SUCCESS; } -- cgit v1.1