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

Commit 64a3c8c7 authored by Chris Manton's avatar Chris Manton
Browse files

Fix get_btm_client_interface mocks/fakes

Also fix unused extra method

Bug: 297427753
Test: m .

Change-Id: I3a9f045e4a722dfe156f68db4f98c67c9c18c761
parent 0b969b04
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -125,8 +125,6 @@ struct btm_client_interface_t {
                             uint8_t pin_length);
    bool (*BTM_SecAddRmtNameNotifyCallback)(tBTM_RMT_NAME_CALLBACK* p_callback);
    bool (*BTM_SecDeleteDevice)(const RawAddress& bd_addr);
    bool (*BTM_SecDeleteRmtNameNotifyCallbac)(
        tBTM_RMT_NAME_CALLBACK* p_callback);
    bool (*BTM_SecRegister)(const tBTM_APPL_INFO* p_cb_info);
    const char* (*BTM_SecReadDevName)(const RawAddress& bd_addr);
    tBTM_STATUS (*BTM_SecBond)(const RawAddress& bd_addr,
+85 −85
Original line number Diff line number Diff line
@@ -36,14 +36,14 @@ tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback) {

struct btm_client_interface_t btm_client_interface = {
    .lifecycle = {
        .BTM_GetHCIConnHandle = [](const RawAddress& remote_bda,
                                   tBT_TRANSPORT transport) -> uint16_t {
          return 0;
        },
        .BTM_PmRegister = [](uint8_t mask, uint8_t* p_pm_id,
                             tBTM_PM_STATUS_CBACK* p_cb) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_GetHCIConnHandle = [](const RawAddress& remote_bda,
                                   tBT_TRANSPORT transport) -> uint16_t {
          return 0;
        },
        .BTM_VendorSpecificCommand = BTM_VendorSpecificCommand,
        .ACL_RegisterClient = [](struct acl_client_callback_s* callbacks) {},
        .ACL_UnregisterClient = [](struct acl_client_callback_s* callbacks) {},
@@ -53,54 +53,19 @@ struct btm_client_interface_t btm_client_interface = {
        .btm_ble_free = []() {},
        .BTM_reset_complete = []() {},
    },
    .eir = {
        .BTM_GetEirSupportedServices =
            [](uint32_t* p_eir_uuid, uint8_t** p, uint8_t max_num_uuid16,
               uint8_t* p_num_uuid16) -> uint8_t { return 0; },
        .BTM_GetEirUuidList = [](const uint8_t* p_eir, size_t eir_len,
                                 uint8_t uuid_size, uint8_t* p_num_uuid,
                                 uint8_t* p_uuid_list,
                                 uint8_t max_num_uuid) -> uint8_t { return 0; },
        .BTM_AddEirService = [](uint32_t* p_eir_uuid, uint16_t uuid16) {},
        .BTM_RemoveEirService = [](uint32_t* p_eir_uuid, uint16_t uuid16) {},
        .BTM_WriteEIR = [](BT_HDR* p_buff) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
    },
    .link_policy = {
        .BTM_GetRole = [](const RawAddress& remote_bd_addr, tHCI_ROLE* p_role)
            -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_SetPowerMode = [](uint8_t pm_id, const RawAddress& remote_bda,
                               const tBTM_PM_PWR_MD* p_mode) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_SetSsrParams =
            [](RawAddress const& bd_addr, uint16_t max_lat, uint16_t min_rmt_to,
               uint16_t min_loc_to) -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_SwitchRoleToCentral = [](const RawAddress& remote_bd_addr)
            -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_WritePageTimeout = BTM_WritePageTimeout,
        .BTM_block_role_switch_for = [](const RawAddress& peer_addr) {},
        .BTM_unblock_role_switch_for = [](const RawAddress& peer_addr) {},
        .BTM_block_sniff_mode_for = [](const RawAddress& peer_addr) {},
        .BTM_unblock_sniff_mode_for = [](const RawAddress& peer_addr) {},
        .BTM_default_unblock_role_switch = []() {},
    },
    .link_controller = {
        .BTM_GetLinkSuperTout = [](const RawAddress& remote_bda,
                                   uint16_t* p_timeout) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_ReadRSSI = [](const RawAddress& remote_bda, tBTM_CMPL_CB* p_cb)
            -> tBTM_STATUS { return BTM_SUCCESS; },
    .scn =
        {
            .BTM_AllocateSCN = BTM_AllocateSCN,
            .BTM_TryAllocateSCN = BTM_TryAllocateSCN,
            .BTM_FreeSCN = BTM_FreeSCN,
        },
    .neighbor =
        {
            .BTM_CancelInquiry = BTM_CancelInquiry,
            .BTM_ClearInqDb = BTM_ClearInqDb,
            .BTM_InqDbNext = BTM_InqDbNext,
            .BTM_SetConnectability = BTM_SetConnectability,
            .BTM_ClearInqDb = BTM_ClearInqDb,
            .BTM_SetDiscoverability = BTM_SetDiscoverability,
            .BTM_SetConnectability = BTM_SetConnectability,
            .BTM_StartInquiry = BTM_StartInquiry,
            .BTM_IsInquiryActive = BTM_IsInquiryActive,
            .BTM_SetInquiryMode = BTM_SetInquiryMode,
@@ -113,7 +78,6 @@ struct btm_client_interface_t btm_client_interface = {
                .SupportTransparentSynchronousData =
                    [](const RawAddress& bd_addr) -> bool { return false; },
            },
        .BTM_CancelRemoteDeviceName = BTM_CancelRemoteDeviceName,
        .BTM_IsAclConnectionUp = [](const RawAddress& remote_bda,
                                    tBT_TRANSPORT transport) -> bool {
          return false;
@@ -122,13 +86,14 @@ struct btm_client_interface_t btm_client_interface = {
            [](RawAddress* remote_bda, tBT_TRANSPORT transport) -> bool {
          return false;
        },
        .BTM_ReadDevInfo = [](const RawAddress& remote_bda,
                              tBT_DEVICE_TYPE* p_dev_type,
                              tBLE_ADDR_TYPE* p_addr_type) {},
        .BTM_CancelRemoteDeviceName = BTM_CancelRemoteDeviceName,
        .BTM_ReadRemoteDeviceName = BTM_ReadRemoteDeviceName,
        .BTM_ReadRemoteFeatures = [](const RawAddress& addr) -> uint8_t* {
          return hci_feature_bytes_per_page;
        },
        .BTM_ReadDevInfo = [](const RawAddress& remote_bda,
                              tBT_DEVICE_TYPE* p_dev_type,
                              tBLE_ADDR_TYPE* p_addr_type) {},
        .BTM_GetMaxPacketSize = [](const RawAddress& bd_addr) -> uint16_t {
          return 0;
        },
@@ -137,28 +102,44 @@ struct btm_client_interface_t btm_client_interface = {
               uint16_t* manufacturer,
               uint16_t* lmp_sub_version) -> bool { return false; },
    },
    .scn =
        {
            .BTM_AllocateSCN = BTM_AllocateSCN,
            .BTM_TryAllocateSCN = BTM_TryAllocateSCN,
            .BTM_FreeSCN = BTM_FreeSCN,
    .link_policy = {
        .BTM_GetRole = [](const RawAddress& remote_bd_addr, tHCI_ROLE* p_role)
            -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_SetPowerMode = [](uint8_t pm_id, const RawAddress& remote_bda,
                               const tBTM_PM_PWR_MD* p_mode) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_SetSsrParams =
            [](RawAddress const& bd_addr, uint16_t max_lat, uint16_t min_rmt_to,
               uint16_t min_loc_to) -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_SwitchRoleToCentral = [](const RawAddress& remote_bd_addr)
            -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_block_role_switch_for = [](const RawAddress& peer_addr) {},
        .BTM_block_sniff_mode_for = [](const RawAddress& peer_addr) {},
        .BTM_default_unblock_role_switch = []() {},
        .BTM_unblock_role_switch_for = [](const RawAddress& peer_addr) {},
        .BTM_unblock_sniff_mode_for = [](const RawAddress& peer_addr) {},
        .BTM_WritePageTimeout = BTM_WritePageTimeout,
    },
    .link_controller = {
        .BTM_GetLinkSuperTout = [](const RawAddress& remote_bda,
                                   uint16_t* p_timeout) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_ReadRSSI = [](const RawAddress& remote_bda, tBTM_CMPL_CB* p_cb)
            -> tBTM_STATUS { return BTM_SUCCESS; },
    },
    .security = {
        .BTM_ConfirmReqReply = [](tBTM_STATUS res,
                                  const RawAddress& bd_addr) {},
        .BTM_PINCodeReply = [](const RawAddress& bd_addr, tBTM_STATUS res,
                               uint8_t pin_len, uint8_t* p_pin) {},
        .BTM_RemoteOobDataReply = [](tBTM_STATUS res, const RawAddress& bd_addr,
                                     const Octet16& c, const Octet16& r) {},
        .BTM_SecAddBleDevice = [](const RawAddress& bd_addr,
                                  tBT_DEVICE_TYPE dev_type,
                                  tBLE_ADDR_TYPE addr_type) {},
        .BTM_SecAddBleKey = [](const RawAddress& bd_addr,
                               tBTM_LE_KEY_VALUE* p_le_key,
                               tBTM_LE_KEY_TYPE key_type) {},
        .BTM_SecAddDevice = BTM_SecAddDevice,
        .BTM_SecAddRmtNameNotifyCallback =
            [](tBTM_RMT_NAME_CALLBACK* p_callback) -> bool { return false; },
        .BTM_SecDeleteDevice = BTM_SecDeleteDevice,
        .BTM_SecRegister = [](const tBTM_APPL_INFO* p_cb_info) -> bool {
          return false;
        },
        .BTM_SecReadDevName = [](const RawAddress& bd_addr) -> const char* {
          return nullptr;
        },
        .BTM_SecBond = [](const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
                          tBT_TRANSPORT transport, tBT_DEVICE_TYPE device_type,
                          uint8_t pin_len, uint8_t* p_pin) -> tBTM_STATUS {
@@ -167,18 +148,23 @@ struct btm_client_interface_t btm_client_interface = {
        .BTM_SecBondCancel = [](const RawAddress& bd_addr) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_SecAddBleKey = [](const RawAddress& bd_addr,
                               tBTM_LE_KEY_VALUE* p_le_key,
                               tBTM_LE_KEY_TYPE key_type) {},
        .BTM_SecAddBleDevice = [](const RawAddress& bd_addr,
                                  tBT_DEVICE_TYPE dev_type,
                                  tBLE_ADDR_TYPE addr_type) {},
        .BTM_SecClearSecurityFlags = BTM_SecClearSecurityFlags,
        .BTM_SecClrService = [](uint8_t service_id) -> uint8_t { return 0; },
        .BTM_SecClrServiceByPsm = [](uint16_t psm) -> uint8_t { return 0; },
        .BTM_SecDeleteDevice = BTM_SecDeleteDevice,
        .BTM_RemoteOobDataReply = [](tBTM_STATUS res, const RawAddress& bd_addr,
                                     const Octet16& c, const Octet16& r) {},
        .BTM_PINCodeReply = [](const RawAddress& bd_addr, tBTM_STATUS res,
                               uint8_t pin_len, uint8_t* p_pin) {},
        .BTM_ConfirmReqReply = [](tBTM_STATUS res,
                                  const RawAddress& bd_addr) {},
        .BTM_SecDeleteRmtNameNotifyCallback =
            [](tBTM_RMT_NAME_CALLBACK* p_callback) -> bool { return false; },
        .BTM_SecReadDevName = [](const RawAddress& bd_addr) -> const char* {
          return nullptr;
        },
        .BTM_SecRegister = [](const tBTM_APPL_INFO* p_cb_info) -> bool {
          return false;
        },
        .BTM_SetEncryption =
            [](const RawAddress& bd_addr, tBT_TRANSPORT transport,
               tBTM_SEC_CALLBACK* p_callback, void* p_ref_data,
@@ -196,15 +182,19 @@ struct btm_client_interface_t btm_client_interface = {
        },
    },
    .ble = {
        .BTM_BleConfirmReply = [](const RawAddress& bd_addr, uint8_t res) {},
        .BTM_BleGetEnergyInfo = [](tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback)
            -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_BleLoadLocalKeys = [](uint8_t key_type,
                                   tBTM_BLE_LOCAL_KEYS* p_key) {},
        .BTM_BleObserve =
            [](bool start, uint8_t duration, tBTM_INQ_RESULTS_CB* p_results_cb,
               tBTM_CMPL_CB* p_cmpl_cb,
               bool low_latency_scan) -> tBTM_STATUS { return BTM_SUCCESS; },
        .BTM_SetBleDataLength = [](const RawAddress& bd_addr,
                                   uint16_t tx_pdu_length) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_BleConfirmReply = [](const RawAddress& bd_addr, uint8_t res) {},
        .BTM_BleLoadLocalKeys = [](uint8_t key_type,
                                   tBTM_BLE_LOCAL_KEYS* p_key) {},
        .BTM_BlePasskeyReply = [](const RawAddress& bd_addr, uint8_t res,
                                  uint32_t passkey) {},
        .BTM_BleReadControllerFeatures =
@@ -215,32 +205,42 @@ struct btm_client_interface_t btm_client_interface = {
            [](const RawAddress& bd_addr, uint16_t min_conn_int,
               uint16_t max_conn_int, uint16_t peripheral_latency,
               uint16_t supervision_tout) {},
        .BTM_SetBleDataLength = [](const RawAddress& bd_addr,
                                   uint16_t tx_pdu_length) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_UseLeLink = [](const RawAddress& bd_addr) -> bool {
          return false;
        }},
    .sco =
        {
            .BTM_CreateSco = BTM_CreateSco,
            .BTM_EScoConnRsp = BTM_EScoConnRsp,
            .BTM_GetNumScoLinks = BTM_GetNumScoLinks,
            .BTM_RegForEScoEvts = BTM_RegForEScoEvts,
            .BTM_RemoveSco = BTM_RemoveSco,
            .BTM_SetEScoMode = BTM_SetEScoMode,
            .BTM_WriteVoiceSettings = BTM_WriteVoiceSettings,
            .BTM_EScoConnRsp = BTM_EScoConnRsp,
            .BTM_GetNumScoLinks = BTM_GetNumScoLinks,
            .BTM_SetEScoMode = BTM_SetEScoMode,
        },
    .local =
        {
            .BTM_ReadLocalDeviceNameFromController =
                BTM_ReadLocalDeviceNameFromController,
            .BTM_SetDeviceClass = BTM_SetDeviceClass,
            .BTM_SetLocalDeviceName = BTM_SetLocalDeviceName,
            .BTM_SetDeviceClass = BTM_SetDeviceClass,
            .BTM_IsDeviceUp = BTM_IsDeviceUp,
            .BTM_ReadDeviceClass = BTM_ReadDeviceClass,
        },
    .eir = {
        .BTM_WriteEIR = [](BT_HDR* p_buff) -> tBTM_STATUS {
          return BTM_SUCCESS;
        },
        .BTM_GetEirSupportedServices =
            [](uint32_t* p_eir_uuid, uint8_t** p, uint8_t max_num_uuid16,
               uint8_t* p_num_uuid16) -> uint8_t { return 0; },
        .BTM_GetEirUuidList = [](const uint8_t* p_eir, size_t eir_len,
                                 uint8_t uuid_size, uint8_t* p_num_uuid,
                                 uint8_t* p_uuid_list,
                                 uint8_t max_num_uuid) -> uint8_t { return 0; },
        .BTM_AddEirService = [](uint32_t* p_eir_uuid, uint16_t uuid16) {},
        .BTM_RemoveEirService = [](uint32_t* p_eir_uuid, uint16_t uuid16) {},
    },
    .db =
        {
            .BTM_InqDbRead = BTM_InqDbRead,