From 033edab9780481ca743d1f14cc893dc533c3c3f2 Mon Sep 17 00:00:00 2001 From: Satya Calloji Date: Thu, 7 May 2015 09:45:00 -0700 Subject: [PATCH] Fix GATT connection failure after BT reset Handles the address type incorrect value storage issue and removes usage of DMT supported flag which was based on legacy code Bug: 20912064 Change-Id: I5bd20dc9cd0997ac3dbd4b346cc0513f1809f241 --- btif/include/btif_storage.h | 29 -------------------- btif/src/btif_dm.c | 12 ++++----- btif/src/btif_gatt_client.c | 10 +------ btif/src/btif_gatt_server.c | 3 +-- btif/src/btif_storage.c | 64 --------------------------------------------- 5 files changed, 7 insertions(+), 111 deletions(-) diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h index bf6a5edcf..54dc5d6b0 100644 --- a/btif/include/btif_storage.h +++ b/btif/include/btif_storage.h @@ -349,33 +349,4 @@ bt_status_t btif_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr, bt_status_t btif_storage_get_remote_version(const bt_bdaddr_t *remote_bd_addr, bt_remote_version_t *p_ver); -/******************************************************************************* -** -** Function btif_storage_set_dmt_support_type -** -** Description Sets DMT support status for a remote device -** -** Returns BT_STATUS_SUCCESS if config update is successful -** BT_STATUS_FAIL otherwise -** -*******************************************************************************/ - -bt_status_t btif_storage_set_dmt_support_type(const bt_bdaddr_t *remote_bd_addr, - BOOLEAN dmt_supported); - - - -/******************************************************************************* -** -** Function btif_storage_is_dmt_supported_device -** -** Description checks if a device supports Dual mode topology -** -** Returns TRUE if remote supports DMT else FALSE -** -*******************************************************************************/ - -BOOLEAN btif_storage_is_dmt_supported_device(const bt_bdaddr_t *remote_bd_addr); - - #endif /* BTIF_STORAGE_H */ diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index 84ee166cd..c8835ae2e 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -1388,12 +1388,6 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param) ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device (inquiry)", status); #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) status = btif_storage_set_remote_addr_type(&bdaddr, addr_type); - if (( dev_type == BT_DEVICE_TYPE_DUMO)&& - (p_search_data->inq_res.flag & BTA_BLE_DMT_CONTROLLER_SPT) && - (p_search_data->inq_res.flag & BTA_BLE_DMT_HOST_SPT)) - { - btif_storage_set_dmt_support_type (&bdaddr, TRUE); - } ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote addr type (inquiry)", status); #endif /* Callback to notify upper layer of device */ @@ -2918,7 +2912,11 @@ static void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) { status = BT_STATUS_SUCCESS; state = BT_BOND_STATE_BONDED; - + int addr_type; + bt_bdaddr_t bdaddr; + bdcpy(bdaddr.address, p_auth_cmpl->bd_addr); + if (btif_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) + btif_storage_set_remote_addr_type(&bdaddr, p_auth_cmpl->addr_type); btif_dm_save_ble_bonding_keys(); BTA_GATTC_Refresh(bd_addr.address); btif_dm_get_remote_services(&bd_addr); diff --git a/btif/src/btif_gatt_client.c b/btif/src/btif_gatt_client.c index 171725c25..7c4e57d14 100644 --- a/btif/src/btif_gatt_client.c +++ b/btif/src/btif_gatt_client.c @@ -584,13 +584,6 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param) } - if (( p_btif_cb->device_type == BT_DEVICE_TYPE_DUMO)&& - (p_btif_cb->flag & BTA_BLE_DMT_CONTROLLER_SPT) && - (p_btif_cb->flag & BTA_BLE_DMT_HOST_SPT)) - { - btif_storage_set_dmt_support_type (&(p_btif_cb->bd_addr), TRUE); - } - dev_type = p_btif_cb->device_type; BTIF_STORAGE_FILL_PROPERTY(&properties, BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type), &dev_type); @@ -1163,8 +1156,7 @@ static void btgattc_handle_event(uint16_t event, char* p_param) break; case BT_DEVICE_TYPE_DUMO: - if ((p_cb->transport == GATT_TRANSPORT_LE) && - (btif_storage_is_dmt_supported_device(&(p_cb->bd_addr)) == TRUE)) + if (p_cb->transport == GATT_TRANSPORT_LE) transport = BTA_GATT_TRANSPORT_LE; else transport = BTA_GATT_TRANSPORT_BR_EDR; diff --git a/btif/src/btif_gatt_server.c b/btif/src/btif_gatt_server.c index 1632b0180..cd86f9399 100644 --- a/btif/src/btif_gatt_server.c +++ b/btif/src/btif_gatt_server.c @@ -413,8 +413,7 @@ static void btgatts_handle_event(uint16_t event, char* p_param) break; case BT_DEVICE_TYPE_DUMO: - if ((p_cb->transport == GATT_TRANSPORT_LE) && - (btif_storage_is_dmt_supported_device(&(p_cb->bd_addr)) == TRUE)) + if (p_cb->transport == GATT_TRANSPORT_LE) transport = BTA_GATT_TRANSPORT_LE; else transport = BTA_GATT_TRANSPORT_BR_EDR; diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c index d0aac7b4b..225c5938d 100644 --- a/btif/src/btif_storage.c +++ b/btif/src/btif_storage.c @@ -1651,67 +1651,3 @@ BOOLEAN btif_storage_is_fixed_pin_zeros_keyboard(bt_bdaddr_t *remote_bd_addr) } -/******************************************************************************* -** -** Function btif_storage_set_dmt_support_type -** -** Description Sets DMT support status for a remote device -** -** Returns BT_STATUS_SUCCESS if config update is successful -** BT_STATUS_FAIL otherwise -** -*******************************************************************************/ - -bt_status_t btif_storage_set_dmt_support_type(const bt_bdaddr_t *remote_bd_addr, - BOOLEAN dmt_supported) -{ - int ret; - bdstr_t bdstr = {0}; - if(remote_bd_addr) - { - bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); - } - else - { - BTIF_TRACE_ERROR("%s NULL BD Address", __FUNCTION__); - return BT_STATUS_FAIL; - } - - ret = btif_config_set_int(bdstr,"DMTSupported", (int)dmt_supported); - return ret ? BT_STATUS_SUCCESS:BT_STATUS_FAIL; - -} - -/******************************************************************************* -** -** Function btif_storage_is_dmt_supported_device -** -** Description checks if a device supports Dual mode topology -** -** Returns TRUE if remote address is valid and supports DMT else FALSE -** -*******************************************************************************/ - -BOOLEAN btif_storage_is_dmt_supported_device(const bt_bdaddr_t *remote_bd_addr) -{ - int dmt_supported = 0; - bdstr_t bdstr = {0}; - if(remote_bd_addr) - bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); - - if(remote_bd_addr) - { - bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); - } - else - { - BTIF_TRACE_ERROR("%s NULL BD Address", __FUNCTION__); - return FALSE; - } - - btif_config_get_int(bdstr,"DMTSupported", &dmt_supported); - - return dmt_supported == 1 ? TRUE:FALSE; -} - - -- 2.11.0