diff options
author | Ravi Nagarajan <nravi@broadcom.com> | 2012-05-29 17:11:03 +0530 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:22 -0700 |
commit | cc10fec21ba2bdb9c908509b1667c8c34d0e8c02 (patch) | |
tree | 752a70c19571a58d044a7e8eb22d94d97107cfcb /btif | |
parent | 7b4048c6064ab21da67dc3450bdfd431f109e4fc (diff) | |
download | external_bluetooth_bluedroid-cc10fec21ba2bdb9c908509b1667c8c34d0e8c02.zip external_bluetooth_bluedroid-cc10fec21ba2bdb9c908509b1667c8c34d0e8c02.tar.gz external_bluetooth_bluedroid-cc10fec21ba2bdb9c908509b1667c8c34d0e8c02.tar.bz2 |
When Bluetooth disable is initiated, terminate pending bonding setup, and reset control blocks on startup/init
Change-Id: Iddc37e60ddb712de4af39a25f3c2e5bc7b11410d
Diffstat (limited to 'btif')
-rw-r--r-- | btif/include/btif_dm.h | 3 | ||||
-rwxr-xr-x | btif/src/btif_core.c | 2 | ||||
-rwxr-xr-x | btif/src/btif_dm.c | 19 | ||||
-rwxr-xr-x | btif/src/btif_hf.c | 4 |
4 files changed, 23 insertions, 5 deletions
diff --git a/btif/include/btif_dm.h b/btif/include/btif_dm.h index 9af0a04..71f2c5e 100644 --- a/btif/include/btif_dm.h +++ b/btif/include/btif_dm.h @@ -76,4 +76,7 @@ BOOLEAN btif_dm_proc_rmt_oob(BD_ADDR bd_addr, BT_OCTET16 p_c, BT_OCTET16 p_r); #endif /* BTIF_DM_OOB_TEST */ #endif /* BTM_OOB_INCLUDED */ +/* Notify BT disable being initiated. DM may chose to abort pending commands, like pairing*/ +void btif_dm_on_disable(void); + #endif diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c index 777c4ca..42caf95 100755 --- a/btif/src/btif_core.c +++ b/btif/src/btif_core.c @@ -575,7 +575,6 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd) ** Returns void ** *******************************************************************************/ - bt_status_t btif_disable_bluetooth(void) { tBTA_STATUS status; @@ -588,6 +587,7 @@ bt_status_t btif_disable_bluetooth(void) BTIF_TRACE_DEBUG0("BTIF DISABLE BLUETOOTH"); + btif_dm_on_disable(); btif_core_state = BTIF_CORE_STATE_DISABLING; /* cleanup rfcomm & l2cap api */ diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index 422927c..e2ab8c5 100755 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -1107,6 +1107,9 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) btif_in_execute_service_request(i, TRUE); } } + /* clear control blocks */ + memset(&pairing_cb, 0, sizeof(btif_dm_pairing_cb_t)); + /* This function will also trigger the adapter_properties_cb ** and bonded_devices_info_cb */ @@ -1501,9 +1504,9 @@ bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr) else { BTA_DmPinReply( (UINT8 *)bd_addr->address, FALSE, 0, NULL); - if (!BTM_IsAclConnectionUp((UINT8 *)bd_addr->address)) - BTA_DmBondCancel ((UINT8 *)bd_addr->address); } + /* Cancel bonding, in case it is in ACL connection setup state */ + BTA_DmBondCancel ((UINT8 *)bd_addr->address); } return BT_STATUS_SUCCESS; @@ -1831,3 +1834,15 @@ BOOLEAN btif_dm_proc_rmt_oob(BD_ADDR bd_addr, BT_OCTET16 p_c, BT_OCTET16 p_r) } #endif /* BTIF_DM_OOB_TEST */ +void btif_dm_on_disable() +{ + /* cancel any pending pairing requests */ + if (pairing_cb.state == BT_BOND_STATE_BONDING) + { + bt_bdaddr_t bd_addr; + + BTIF_TRACE_DEBUG1("%s: Cancel pending pairing request", __FUNCTION__); + bdcpy(bd_addr.address, pairing_cb.bd_addr); + btif_dm_cancel_bond(&bd_addr); + } +} diff --git a/btif/src/btif_hf.c b/btif/src/btif_hf.c index 5851efa..bcbf00a 100755 --- a/btif/src/btif_hf.c +++ b/btif/src/btif_hf.c @@ -484,8 +484,8 @@ static bt_status_t init( bthf_callbacks_t* callbacks ) * Internally, the HSP_SERVICE_ID shall also be enabled */ btif_enable_service(BTA_HFP_SERVICE_ID); - btif_hf_cb.call_end_timestamp.tv_sec = 0; - btif_hf_cb.call_end_timestamp.tv_nsec = 0; + memset(&btif_hf_cb, 0, sizeof(btif_hf_cb_t)); + clear_phone_state(); return BT_STATUS_SUCCESS; } |