Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dfd8a97 authored by Nitin Arora's avatar Nitin Arora Committed by Andre Eisenbach
Browse files

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
parent 329469d2
Loading
Loading
Loading
Loading
+23 −23
Original line number Diff line number Diff line
@@ -2276,38 +2276,42 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
{
    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)
            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)
@@ -2324,15 +2328,11 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
            ||(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)
        {
            return;
        }
        else
        {

        /* starting name discovery failed */
        bta_dm_search_cb.name_discover_done = TRUE;
    }
    }

    /* if application wants to discover service */
    if ( bta_dm_search_cb.services )
@@ -2368,11 +2368,11 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
#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)
+11 −0
Original line number Diff line number Diff line
@@ -313,6 +313,17 @@ bt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr,
*******************************************************************************/
bt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr);

/*******************************************************************************
**
** 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
+26 −1
Original line number Diff line number Diff line
@@ -2572,6 +2572,31 @@ bt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr)
    return BT_STATUS_SUCCESS;
}

/*******************************************************************************
**
** 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
@@ -2879,7 +2904,7 @@ static void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
            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
    {