Adding transport type while initiating remote discovery
This change ensures that the completion of SMP pairing for LE
devices specifically requests remote device discovery based on
transport type set to LE to prevent initiation of BR/EDR
connection due to incorrect transport type info
Bug: 22515456
Change-Id: Id1e5603d3cc53ca3dff427b93059a00f8d9150a7
diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c
index 6c2bc55..eb49637 100644
--- a/bta/dm/bta_dm_act.c
+++ b/bta/dm/bta_dm_act.c
@@ -2276,38 +2276,42 @@
{
tBTA_DM_MSG * p_msg;
tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
+
#if BLE_INCLUDED == TRUE
+ if (bta_dm_search_cb.transport == BTA_TRANSPORT_UNKNOWN)
+ {
tBT_DEVICE_TYPE dev_type;
tBLE_ADDR_TYPE addr_type;
- if (bta_dm_search_cb.transport == BTA_TRANSPORT_UNKNOWN)
- {
BTM_ReadDevInfo(remote_bd_addr, &dev_type, &addr_type);
- if (dev_type == BT_DEVICE_TYPE_BLE || addr_type == BLE_ADDR_RANDOM )
+ if (dev_type == BT_DEVICE_TYPE_BLE || addr_type == BLE_ADDR_RANDOM)
transport = BT_TRANSPORT_LE;
- }
- else
+ } else {
transport = bta_dm_search_cb.transport;
+ }
#endif
+ /* Reset transport state for next discovery */
+ bta_dm_search_cb.transport = BTA_TRANSPORT_UNKNOWN;
- APPL_TRACE_DEBUG("bta_dm_discover_device, BDA:0x%02X%02X%02X%02X%02X%02X",
+ APPL_TRACE_DEBUG("%s BDA:0x%02X%02X%02X%02X%02X%02X", __func__,
remote_bd_addr[0],remote_bd_addr[1],
remote_bd_addr[2],remote_bd_addr[3],
remote_bd_addr[4],remote_bd_addr[5]);
bdcpy(bta_dm_search_cb.peer_bdaddr, remote_bd_addr);
- APPL_TRACE_DEBUG("bta_dm_discover_device name_discover_done = %d p_btm_inq_info 0x%x state = %d",
+ APPL_TRACE_DEBUG("%s name_discover_done = %d p_btm_inq_info 0x%x state = %d, transport=%d",
+ __func__,
bta_dm_search_cb.name_discover_done,
bta_dm_search_cb.p_btm_inq_info,
- bta_dm_search_cb.state
- );
+ bta_dm_search_cb.state,
+ transport);
+
if (bta_dm_search_cb.p_btm_inq_info)
{
- APPL_TRACE_DEBUG("bta_dm_discover_device appl_knows_rem_name %d",
- bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name
- );
+ APPL_TRACE_DEBUG("%s appl_knows_rem_name %d", __func__,
+ bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name);
}
if((bta_dm_search_cb.p_btm_inq_info)
@@ -2323,15 +2327,11 @@
&& (( bta_dm_search_cb.p_btm_inq_info == NULL )
||(bta_dm_search_cb.p_btm_inq_info && (!bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name))))
{
- if(bta_dm_read_remote_device_name(bta_dm_search_cb.peer_bdaddr, transport) == TRUE)
- {
+ if (bta_dm_read_remote_device_name(bta_dm_search_cb.peer_bdaddr, transport) == TRUE)
return;
- }
- else
- {
- /* starting name discovery failed */
- bta_dm_search_cb.name_discover_done = TRUE;
- }
+
+ /* starting name discovery failed */
+ bta_dm_search_cb.name_discover_done = TRUE;
}
/* if application wants to discover service */
@@ -2368,11 +2368,11 @@
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
if ( bta_dm_search_cb.p_btm_inq_info )
{
- APPL_TRACE_DEBUG("bta_dm_discover_device p_btm_inq_info 0x%x results.device_type 0x%x services_to_search 0x%x",
+ APPL_TRACE_DEBUG("%s p_btm_inq_info 0x%x results.device_type 0x%x services_to_search 0x%x",
+ __func__,
bta_dm_search_cb.p_btm_inq_info,
bta_dm_search_cb.p_btm_inq_info->results.device_type,
- bta_dm_search_cb.services_to_search
- );
+ bta_dm_search_cb.services_to_search);
}
if (transport == BT_TRANSPORT_LE)
diff --git a/btif/include/btif_api.h b/btif/include/btif_api.h
index 2e41d22..62687d3 100644
--- a/btif/include/btif_api.h
+++ b/btif/include/btif_api.h
@@ -315,6 +315,17 @@
/*******************************************************************************
**
+** Function btif_dm_get_remote_services_by_transport
+**
+** Description Start SDP to get remote services by transport
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_get_remote_services_by_transport(bt_bdaddr_t *remote_addr, int transport);
+
+/*******************************************************************************
+**
** Function btif_dut_mode_configure
**
** Description Configure Test Mode - 'enable' to 1 puts the device in test mode and 0 exits
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index 1f3893e..1131c98 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -2574,6 +2574,31 @@
/*******************************************************************************
**
+** Function btif_dm_get_remote_services_transport
+**
+** Description Start SDP to get remote services by transport
+**
+** Returns bt_status_t
+**
+*******************************************************************************/
+bt_status_t btif_dm_get_remote_services_by_transport(bt_bdaddr_t *remote_addr, const int transport)
+{
+ BTIF_TRACE_EVENT("%s", __func__);
+
+ /* Set the mask extension */
+ tBTA_SERVICE_MASK_EXT mask_ext;
+ mask_ext.num_uuid = 0;
+ mask_ext.p_uuid = NULL;
+ mask_ext.srvc_mask = BTA_ALL_SERVICE_MASK;
+
+ BTA_DmDiscoverByTransport(remote_addr->address, &mask_ext,
+ bte_dm_search_services_evt, TRUE, transport);
+
+ return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
** Function btif_dm_get_remote_service_record
**
** Description Start SDP to get remote service record
@@ -2879,7 +2904,7 @@
btif_dm_save_ble_bonding_keys();
}
BTA_GATTC_Refresh(bd_addr.address);
- btif_dm_get_remote_services(&bd_addr);
+ btif_dm_get_remote_services_by_transport(&bd_addr, BTA_GATT_TRANSPORT_LE);
}
else
{