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

Commit 49b3c1be authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

BLE OOB Pairing - parse address type (1/5)

When address type is not parsed, creating bond to devices not using
random address is impossible.

Bug: 32780409
Test: try pairing with nRF52DK using random address
Change-Id: Idc0315e9e3f9e17c3cf56fa483c8e21eb3590f01
(cherry picked from commit ecc2ea9f)
parent 0cf9c2e7
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -717,7 +717,15 @@ static void btif_dm_cb_create_bond(bt_bdaddr_t *bd_addr, tBTA_TRANSPORT transpor
        }
        if (btif_storage_get_remote_addr_type(bd_addr, &addr_type) != BT_STATUS_SUCCESS)
        {
            btif_storage_set_remote_addr_type(bd_addr, BLE_ADDR_PUBLIC);

            // Try to read address type. OOB pairing might have set it earlier, but
            // didn't store it, it defaults to BLE_ADDR_PUBLIC
            uint8_t tmp_dev_type;
            uint8_t tmp_addr_type;
            BTM_ReadDevInfo(bd_addr->address, &tmp_dev_type, &tmp_addr_type);
            addr_type = tmp_addr_type;

            btif_storage_set_remote_addr_type(bd_addr, addr_type);
        }
    }
    if((btif_config_get_int((char const *)&bdstr,"DevType", &device_type) &&
@@ -2387,6 +2395,19 @@ bt_status_t btif_dm_create_bond_out_of_band(const bt_bdaddr_t *bd_addr, int tran
    bdcpy(oob_cb.bdaddr, bd_addr->address);
    memcpy(&oob_cb.oob_data, oob_data, sizeof(bt_out_of_band_data_t));

    uint8_t empty[] = {0, 0, 0, 0, 0, 0, 0};
    // If LE Bluetooth Device Address is provided, use provided address type
    // value.
    if (memcmp(oob_data->le_bt_dev_addr, empty, 7) != 0) {
        /* byte no 7 is address type in LE Bluetooth Address OOB data */
        uint8_t address_type = oob_data->le_bt_dev_addr[6];
        if (address_type == BLE_ADDR_PUBLIC || address_type == BLE_ADDR_RANDOM) {
            // bd_addr->address is already reversed, so use it instead of
            // oob_data->le_bt_dev_addr
            BTM_SecAddBleDevice(bd_addr->address, NULL, BT_DEVICE_TYPE_BLE, address_type);
        }
    }

    bdstr_t bdstr;
    BTIF_TRACE_EVENT("%s: bd_addr=%s, transport=%d", __FUNCTION__, bdaddr_to_string(bd_addr, bdstr, sizeof(bdstr)), transport);
    return btif_dm_create_bond(bd_addr, transport);
+1 −1
Original line number Diff line number Diff line
@@ -1402,7 +1402,7 @@ UINT16 btm_get_acl_disc_reason_code (void)
** Returns          the handle of the connection, or 0xFFFF if none.
**
*******************************************************************************/
UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport)
UINT16 BTM_GetHCIConnHandle (const BD_ADDR remote_bda, tBT_TRANSPORT transport)
{
    tACL_CONN   *p;
    BTM_TRACE_DEBUG ("BTM_GetHCIConnHandle");
+1 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr);
** Returns          TRUE if added OK, else FALSE
**
*******************************************************************************/
BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE dev_type,
BOOLEAN BTM_SecAddBleDevice (const BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE dev_type,
                             tBLE_ADDR_TYPE addr_type)
{
    BTM_TRACE_DEBUG ("%s: dev_type=0x%x", __func__, dev_type);
+1 −1
Original line number Diff line number Diff line
@@ -3723,7 +3723,7 @@ extern tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
** Returns          the handle of the connection, or 0xFFFF if none.
**
*******************************************************************************/
extern UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
extern UINT16 BTM_GetHCIConnHandle (const BD_ADDR remote_bda, tBT_TRANSPORT transport);

/*******************************************************************************
**
+1 −1
Original line number Diff line number Diff line
@@ -912,7 +912,7 @@ extern "C" {
** Returns          TRUE if added OK, else FALSE
**
*******************************************************************************/
extern BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name,
extern BOOLEAN BTM_SecAddBleDevice (const BD_ADDR bd_addr, BD_NAME bd_name,
                                           tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type);

/*******************************************************************************