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

Commit e52a6060 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

DO NOT MERGE Fix compilation on platforms with BLE_INCLUDED == FALSE

This is not a comprehensive fix. More work is necessary to ensure the
correct separation of BLE_INCLUDED TRUE/FALSE as well as removing many
of the hacked-up if() statements resulting from this patch.

Change-Id: I1812594feba0bf43369096e472a8b18cde305255
parent 9d4c1659
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2728,9 +2728,10 @@ static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class,
        memcpy(p_auth_cmpl->key, key, LINK_KEY_LEN);
        sec_event.auth_cmpl.fail_reason = HCI_SUCCESS;

#if BLE_INCLUDED == TRUE
        // Report the BR link key based on the BR/EDR address and type
        BTM_ReadDevInfo(bd_addr, &sec_event.auth_cmpl.dev_type, &sec_event.auth_cmpl.addr_type);

#endif
        if(bta_dm_cb.p_sec_cback)
            bta_dm_cb.p_sec_cback(event, &sec_event);
    }
@@ -2765,8 +2766,10 @@ static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev
        memcpy(sec_event.auth_cmpl.bd_name, bd_name, (BD_NAME_LEN-1));
        sec_event.auth_cmpl.bd_name[BD_NAME_LEN-1] = 0;

#if BLE_INCLUDED == TRUE
        // Report the BR link key based on the BR/EDR address and type
        BTM_ReadDevInfo(bd_addr, &sec_event.auth_cmpl.dev_type, &sec_event.auth_cmpl.addr_type);
#endif
        sec_event.auth_cmpl.fail_reason = (UINT8)result;

        if(bta_dm_cb.p_sec_cback)
@@ -4385,7 +4388,9 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D

        case BTM_LE_COMPLT_EVT:
            bdcpy(sec_event.auth_cmpl.bd_addr, bda);
#if BLE_INCLUDED == TRUE
            BTM_ReadDevInfo(bda, &sec_event.auth_cmpl.dev_type, &sec_event.auth_cmpl.addr_type);
#endif
            p_name = BTM_SecReadDevName(bda);
            if (p_name != NULL)
            {
+6 −1
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ BOOLEAN blacklistPairingRetries(BD_ADDR bd_addr)
typedef struct
{
    bt_bond_state_t state;
    bt_bdaddr_t static_bdaddr;
    BD_ADDR bd_addr;
    UINT8 bond_type;
    UINT8 pin_code_len;
@@ -143,7 +144,6 @@ typedef struct
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
    BOOLEAN is_le_only;
    BOOLEAN is_le_nc; /* LE Numeric comparison */
    bt_bdaddr_t static_bdaddr;
    btif_dm_ble_cb_t ble;
#endif
} btif_dm_pairing_cb_t;
@@ -1115,7 +1115,9 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
    // Skip SDP for certain  HID Devices
    if (p_auth_cmpl->success)
    {
#if BLE_INCLUDED == TRUE
        btif_storage_set_remote_addr_type(&bd_addr, p_auth_cmpl->addr_type);
#endif
        btif_update_remote_properties(p_auth_cmpl->bd_addr,
                                      p_auth_cmpl->bd_name, NULL, p_auth_cmpl->dev_type);
        pairing_cb.timeout_retries = 0;
@@ -1152,6 +1154,8 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
        {
            /* Trigger SDP on the device */
            pairing_cb.sdp_attempts = 1;;

#if BLE_INCLUDED == TRUE
            /* If bonded due to cross-key, save the static address too*/
            if(pairing_cb.state == BT_BOND_STATE_BONDING &&
              (bdcmp(p_auth_cmpl->bd_addr, pairing_cb.bd_addr) != 0))
@@ -1160,6 +1164,7 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
                                 __func__);
                bdcpy(pairing_cb.static_bdaddr.address, p_auth_cmpl->bd_addr);
            }
#endif

            if(btif_dm_inquiry_in_progress)
                btif_dm_cancel_discovery();
+5 −1
Original line number Diff line number Diff line
@@ -441,12 +441,14 @@ tBTM_SEC_DEV_REC *btm_find_dev(BD_ADDR bd_addr)
                if (!memcmp (p_dev_rec->bd_addr, bd_addr, BD_ADDR_LEN))
                    return(p_dev_rec);

#if BLE_INCLUDED == TRUE
                // If a LE random address is looking for device record
                if (!memcmp(p_dev_rec->ble.pseudo_addr, bd_addr, BD_ADDR_LEN))
                    return (p_dev_rec);

                if (btm_ble_addr_resolvable(bd_addr, p_dev_rec))
                    return(p_dev_rec);
#endif
            }
        }
    }
@@ -464,6 +466,7 @@ tBTM_SEC_DEV_REC *btm_find_dev(BD_ADDR bd_addr)
*******************************************************************************/
void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec)
{
#if BLE_INCLUDED == TRUE
    tBTM_SEC_DEV_REC *p_dev_rec = &btm_cb.sec_dev_rec[0];
    tBTM_SEC_DEV_REC temp_rec = *p_target_rec;
    BD_ADDR dummy_bda = {0};
@@ -478,8 +481,8 @@ void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec)
            {
                memcpy(p_target_rec, p_dev_rec, sizeof(tBTM_SEC_DEV_REC));
                p_target_rec->ble = temp_rec.ble;
                p_target_rec->enc_key_size = temp_rec.enc_key_size;
                p_target_rec->ble_hci_handle = temp_rec.ble_hci_handle;
                p_target_rec->enc_key_size = temp_rec.enc_key_size;
                p_target_rec->conn_params = temp_rec.conn_params;
                p_target_rec->device_type |= temp_rec.device_type;
                p_target_rec->sec_flags |= temp_rec.sec_flags;
@@ -504,6 +507,7 @@ void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec)
            }
        }
    }
#endif
}

/*******************************************************************************
+4 −3
Original line number Diff line number Diff line
@@ -573,12 +573,9 @@ typedef struct
                                        /* HCI_IO_CAPABILITY_REQUEST_EVT from the peer before */
                                        /* it knows peer's support for Secure Connections */

#if (BLE_INCLUDED == TRUE)
    UINT16              ble_hci_handle;         /* use in DUMO connection */
    UINT8               enc_key_size;           /* current link encryption key size */
    tBTM_SEC_BLE        ble;
    tBT_DEVICE_TYPE     device_type;
    tBTM_LE_CONN_PRAMS  conn_params;
    BOOLEAN             new_encryption_key_is_p256; /* Set to TRUE when the newly generated LK
                                                    ** is generated from P-256.
                                                    ** Link encrypted with such LK can be used
@@ -587,6 +584,10 @@ typedef struct
    BOOLEAN no_smp_on_br;       /* if set to TRUE then SMP on BR/EDR doesn't */
                                /* work, i.e. link keys crosspairing */
                                /* SC BR/EDR->SC LE doesn't happen */

#if BLE_INCLUDED == TRUE
    tBTM_SEC_BLE        ble;
    tBTM_LE_CONN_PRAMS  conn_params;
#endif

// btla-specific ++
+8 −6
Original line number Diff line number Diff line
@@ -5873,9 +5873,11 @@ void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEA
    {
        p_dev_rec->p_callback = NULL;

#if BLE_INCLUDED == TRUE
        if (is_le_transport)
           (*p_callback) (p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE, p_dev_rec->p_ref_data, res);
        else
#endif
           (*p_callback) (p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, p_dev_rec->p_ref_data, res);
    }

@@ -6131,7 +6133,6 @@ static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRA
    tBTM_SEC_QUEUE_ENTRY    *p_e;
    BUFFER_Q                *bq = &btm_cb.sec_pending_q;
    UINT8                   res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING;
    UINT8                   sec_act ;

    p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_getfirst(bq);

@@ -6143,7 +6144,9 @@ static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRA
#endif
            )
        {
            sec_act = *(UINT8 *)(p_e->p_ref_data);
#if BLE_INCLUDED == TRUE
            UINT8 sec_act = *(UINT8 *)(p_e->p_ref_data);
#endif

            if (encr_enable == 0 || transport == BT_TRANSPORT_BR_EDR
#if BLE_INCLUDED == TRUE
@@ -6178,7 +6181,6 @@ static UINT16 btm_sec_set_serv_level4_flags(UINT16 cur_security, BOOLEAN is_orig
    return cur_security | sec_level4_flags;
}

#if (BLE_INCLUDED == TRUE)
/*******************************************************************************
**
** Function         btm_sec_clear_ble_keys
@@ -6222,6 +6224,8 @@ BOOLEAN btm_sec_is_a_bonded_dev (BD_ADDR bda)
    if (p_dev_rec &&
#if (SMP_INCLUDED == TRUE)
        ((p_dev_rec->ble.key_type && (p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN))||
#else
        (
#endif
         (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)))
    {
@@ -6340,5 +6344,3 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec)
    return (p && (p->link_role == BTM_ROLE_MASTER));
}
#endif /* BLE_INCLUDED */
Loading