1 /*
2 * Copyright 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /*
18 * Generated mock file from original source file
19 */
20
21 #include "stack/include/btm_ble_api_types.h"
22 #include "stack/include/btm_ble_sec_api_types.h"
23 #include "stack/include/btm_client_interface.h"
24 #include "stack/include/btm_sec_api_types.h"
25 #include "stack/include/btm_status.h"
26 #include "types/bt_transport.h"
27 #include "types/raw_address.h"
28
29 // TODO(b/369381361) Enfore -Wmissing-prototypes
30 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
31
32 // Test accessible feature page
33 uint8_t hci_feature_bytes_per_page[HCI_FEATURE_BYTES_PER_PAGE] = {};
34
35 namespace {
36
37 struct btm_client_interface_t default_btm_client_interface = {
38 .lifecycle = {
39 .BTM_PmRegister = [](uint8_t /* mask */, uint8_t* /* p_pm_id */,
__anon46c2d7710202(uint8_t , uint8_t* , tBTM_PM_STATUS_CBACK* ) 40 tBTM_PM_STATUS_CBACK* /* p_cb */) -> tBTM_STATUS {
41 return tBTM_STATUS::BTM_SUCCESS;
42 },
__anon46c2d7710302(struct acl_client_callback_s* ) 43 .ACL_RegisterClient = [](struct acl_client_callback_s* /* callbacks */) {},
__anon46c2d7710402(struct acl_client_callback_s* ) 44 .ACL_UnregisterClient = [](struct acl_client_callback_s* /* callbacks */) {},
__anon46c2d7710502() 45 .btm_init = []() {},
__anon46c2d7710602() 46 .btm_free = []() {},
__anon46c2d7710702() 47 .btm_ble_init = []() {},
__anon46c2d7710802() 48 .btm_ble_free = []() {},
__anon46c2d7710902() 49 .BTM_reset_complete = []() {},
50 },
51 .peer = {
52 .BTM_IsAclConnectionUp = [](const RawAddress& /* remote_bda */,
__anon46c2d7710a02(const RawAddress& , tBT_TRANSPORT ) 53 tBT_TRANSPORT /* transport */) -> bool {
54 return false;
55 },
56 .BTM_ReadConnectedTransportAddress = [](RawAddress* /* remote_bda */,
__anon46c2d7710b02(RawAddress* , tBT_TRANSPORT ) 57 tBT_TRANSPORT /* transport */) -> bool {
58 return false;
59 },
__anon46c2d7710c02(const RawAddress& ) 60 .BTM_ReadRemoteFeatures = [](const RawAddress& /* addr */) -> uint8_t* {
61 return hci_feature_bytes_per_page;
62 },
63 .BTM_ReadDevInfo = [](const RawAddress& /* remote_bda */,
64 tBT_DEVICE_TYPE* /* p_dev_type */,
__anon46c2d7710d02(const RawAddress& , tBT_DEVICE_TYPE* , tBLE_ADDR_TYPE* ) 65 tBLE_ADDR_TYPE* /* p_addr_type */) {},
__anon46c2d7710e02(const RawAddress& ) 66 .BTM_GetMaxPacketSize = [](const RawAddress& /* bd_addr */) -> uint16_t {
67 return 0;
68 },
69 .BTM_ReadRemoteVersion =
70 [](const RawAddress& /* addr */, uint8_t* /* lmp_version */,
71 uint16_t* /* manufacturer */,
__anon46c2d7710f02(const RawAddress& , uint8_t* , uint16_t* , uint16_t* ) 72 uint16_t* /* lmp_sub_version */) -> bool { return false; },
73
74 .BTM_GetPeerDeviceTypeFromFeatures = [](const RawAddress& /* bd_addr */)
__anon46c2d7711002(const RawAddress& ) 75 -> tBT_DEVICE_TYPE { return BT_DEVICE_TYPE_DUMO; },
76
77 .BTM_RequestPeerSCA = [](const RawAddress& /* remote_bda */,
__anon46c2d7711102(const RawAddress& , tBT_TRANSPORT ) 78 tBT_TRANSPORT /* transport */) {},
79 .BTM_GetPeerSCA = [](const RawAddress& /* remote_bda */,
__anon46c2d7711202(const RawAddress& , tBT_TRANSPORT ) 80 tBT_TRANSPORT /* transport */) -> uint8_t { return 0; },
81 .BTM_IsPhy2mSupported = [](const RawAddress& /* remote_bda */,
__anon46c2d7711302(const RawAddress& , tBT_TRANSPORT ) 82 tBT_TRANSPORT /* transport */) -> bool { return true; },
83 .BTM_GetHCIConnHandle = [](const RawAddress& /* remote_bda */,
__anon46c2d7711402(const RawAddress& , tBT_TRANSPORT ) 84 tBT_TRANSPORT /* transport */) -> uint16_t { return 0; },
85 },
86 .link_policy = {
87 .BTM_GetRole = [](const RawAddress& /* remote_bd_addr */, tHCI_ROLE* /* p_role */)
__anon46c2d7711502(const RawAddress& , tHCI_ROLE* ) 88 -> tBTM_STATUS { return tBTM_STATUS::BTM_SUCCESS; },
89 .BTM_SetPowerMode = [](uint8_t /* pm_id */, const RawAddress& /* remote_bda */,
__anon46c2d7711602(uint8_t , const RawAddress& , const tBTM_PM_PWR_MD* ) 90 const tBTM_PM_PWR_MD* /* p_mode */) -> tBTM_STATUS {
91 return tBTM_STATUS::BTM_SUCCESS;
92 },
93 .BTM_SetSsrParams = [](RawAddress const& /* bd_addr */, uint16_t /* max_lat */,
94 uint16_t /* min_rmt_to */, uint16_t /* min_loc_to */)
__anon46c2d7711702(RawAddress const& , uint16_t , uint16_t , uint16_t ) 95 -> tBTM_STATUS { return tBTM_STATUS::BTM_SUCCESS; },
96 .BTM_SwitchRoleToCentral = [](const RawAddress& /* remote_bd_addr */)
__anon46c2d7711802(const RawAddress& ) 97 -> tBTM_STATUS { return tBTM_STATUS::BTM_SUCCESS; },
__anon46c2d7711902(const RawAddress& ) 98 .BTM_block_role_switch_for = [](const RawAddress& /* peer_addr */) {},
__anon46c2d7711a02(const RawAddress& ) 99 .BTM_block_sniff_mode_for = [](const RawAddress& /* peer_addr */) {},
__anon46c2d7711b02() 100 .BTM_default_unblock_role_switch = []() {},
__anon46c2d7711c02(const RawAddress& ) 101 .BTM_unblock_role_switch_for = [](const RawAddress& /* peer_addr */) {},
__anon46c2d7711d02(const RawAddress& ) 102 .BTM_unblock_sniff_mode_for = [](const RawAddress& /* peer_addr */) {},
__anon46c2d7711e02(uint16_t ) 103 .BTM_WritePageTimeout = [](uint16_t /* timeout */) {},
104 },
105 .link_controller = {
106 .BTM_GetLinkSuperTout = [](const RawAddress& /* remote_bda */,
__anon46c2d7711f02(const RawAddress& , uint16_t* ) 107 uint16_t* /* p_timeout */) -> tBTM_STATUS {
108 return tBTM_STATUS::BTM_SUCCESS;
109 },
110 .BTM_ReadRSSI = [](const RawAddress& /* remote_bda */, tBTM_CMPL_CB* /* p_cb */)
__anon46c2d7712002(const RawAddress& , tBTM_CMPL_CB* ) 111 -> tBTM_STATUS { return tBTM_STATUS::BTM_SUCCESS; },
112 },
113 .security = {
__anon46c2d7712102() 114 .BTM_Sec_Init = []() {},
__anon46c2d7712202() 115 .BTM_Sec_Free = []() {},
__anon46c2d7712302(const tBTM_APPL_INFO* ) 116 .BTM_SecRegister = [](const tBTM_APPL_INFO* /* p_cb_info */) -> bool {
117 return false;
118 },
119 .BTM_BleLoadLocalKeys = [](uint8_t /* key_type */,
__anon46c2d7712402(uint8_t , tBTM_BLE_LOCAL_KEYS* ) 120 tBTM_BLE_LOCAL_KEYS* /* p_key */) {},
121 .BTM_SecAddDevice = [](const RawAddress& /* bd_addr */, DEV_CLASS /* dev_class */,
122 LinkKey /* link_key */, uint8_t /* key_type */,
__anon46c2d7712502(const RawAddress& , DEV_CLASS , LinkKey , uint8_t , uint8_t ) 123 uint8_t /* pin_length */) {},
124 .BTM_SecAddBleDevice = [](const RawAddress& /* bd_addr */,
125 tBT_DEVICE_TYPE /* dev_type */,
__anon46c2d7712602(const RawAddress& , tBT_DEVICE_TYPE , tBLE_ADDR_TYPE ) 126 tBLE_ADDR_TYPE /* addr_type */) {},
__anon46c2d7712702(const RawAddress& ) 127 .BTM_SecDeleteDevice = [](const RawAddress& /* bd_addr */) -> bool { return true; },
128 .BTM_SecAddBleKey = [](const RawAddress& /* bd_addr */,
129 tBTM_LE_KEY_VALUE* /* p_le_key */,
__anon46c2d7712802(const RawAddress& , tBTM_LE_KEY_VALUE* , tBTM_LE_KEY_TYPE ) 130 tBTM_LE_KEY_TYPE /* key_type */) {},
__anon46c2d7712902(const RawAddress& ) 131 .BTM_SecClearSecurityFlags = [](const RawAddress& /* bd_addr */) {},
132 .BTM_SetEncryption = [](const RawAddress& /* bd_addr */,
133 tBT_TRANSPORT /* transport */,
134 tBTM_SEC_CALLBACK* /* p_callback */, void* /* p_ref_data */,
__anon46c2d7712a02(const RawAddress& , tBT_TRANSPORT , tBTM_SEC_CALLBACK* , void* , tBTM_BLE_SEC_ACT ) 135 tBTM_BLE_SEC_ACT /* sec_act */) -> tBTM_STATUS {
136 return tBTM_STATUS::BTM_SUCCESS;
137 },
138 .BTM_IsEncrypted = [](const RawAddress& /* bd_addr */,
__anon46c2d7712b02(const RawAddress& , tBT_TRANSPORT ) 139 tBT_TRANSPORT /* transport */) -> bool { return false; },
__anon46c2d7712c02(const RawAddress& ) 140 .BTM_SecIsSecurityPending = [](const RawAddress& /* bd_addr */) -> bool {
141 return false;
142 },
143 .BTM_IsLinkKeyKnown = [](const RawAddress& /* bd_addr */,
__anon46c2d7712d02(const RawAddress& , tBT_TRANSPORT ) 144 tBT_TRANSPORT /* transport */) -> bool { return false; },
145 .BTM_SetSecurityLevel = [](bool /* is_originator */, const char* /*p_name */,
146 uint8_t /* service_id */, uint16_t /* sec_level */,
147 uint16_t /* psm */, uint32_t /* mx_proto_id */,
__anon46c2d7712e02(bool , const char* , uint8_t , uint16_t , uint16_t , uint32_t , uint32_t ) 148 uint32_t /* mx_chan_id */) -> bool { return false; },
__anon46c2d7712f02(uint8_t ) 149 .BTM_SecClrService = [](uint8_t /* service_id */) -> uint8_t { return 0; },
__anon46c2d7713002(uint16_t ) 150 .BTM_SecClrServiceByPsm = [](uint16_t /* psm */) -> uint8_t { return 0; },
151 .BTM_SecBond = [](const RawAddress& /* bd_addr */, tBLE_ADDR_TYPE /* addr_type */,
152 tBT_TRANSPORT /* transport */, tBT_DEVICE_TYPE /* device_type */)
__anon46c2d7713102(const RawAddress& , tBLE_ADDR_TYPE , tBT_TRANSPORT , tBT_DEVICE_TYPE ) 153 -> tBTM_STATUS { return tBTM_STATUS::BTM_SUCCESS; },
__anon46c2d7713202(const RawAddress& ) 154 .BTM_SecBondCancel = [](const RawAddress& /* bd_addr */) -> tBTM_STATUS {
155 return tBTM_STATUS::BTM_SUCCESS;
156 },
157 .BTM_RemoteOobDataReply = [](tBTM_STATUS /* res */, const RawAddress& /* bd_addr */,
__anon46c2d7713302(tBTM_STATUS , const RawAddress& , const Octet16& , const Octet16& ) 158 const Octet16& /* c */, const Octet16& /* r */) {},
159 .BTM_PINCodeReply = [](const RawAddress& /* bd_addr */, tBTM_STATUS /* res */,
__anon46c2d7713402(const RawAddress& , tBTM_STATUS , uint8_t , uint8_t* ) 160 uint8_t /* pin_len */, uint8_t* /* p_pin */) {},
161 .BTM_SecConfirmReqReply = [](tBTM_STATUS /* res */, tBT_TRANSPORT /* transport */,
__anon46c2d7713502(tBTM_STATUS , tBT_TRANSPORT , const RawAddress ) 162 const RawAddress /* bd_addr */) {},
163 .BTM_BleSirkConfirmDeviceReply = [](const RawAddress& /* bd_addr */,
__anon46c2d7713602(const RawAddress& , tBTM_STATUS ) 164 tBTM_STATUS /* res */) {},
165 .BTM_BlePasskeyReply = [](const RawAddress& /* bd_addr */, tBTM_STATUS /* res */,
__anon46c2d7713702(const RawAddress& , tBTM_STATUS , uint32_t ) 166 uint32_t /* passkey */) {},
__anon46c2d7713802() 167 .BTM_GetSecurityMode = []() -> uint8_t { return 0; },
__anon46c2d7713902(const RawAddress& ) 168 .BTM_SecReadDevName = [](const RawAddress& /* bd_addr */) -> const char* {
169 return nullptr;
170 },
__anon46c2d7713a02(const RawAddress& ) 171 .BTM_SecReadDevClass = [](const RawAddress& /* bd_addr */) -> DEV_CLASS {
172 return kDevClassEmpty;
173 },
174 },
175 .ble = {
176 .BTM_BleGetEnergyInfo = [](tBTM_BLE_ENERGY_INFO_CBACK* /* p_ener_cback */)
__anon46c2d7713b02(tBTM_BLE_ENERGY_INFO_CBACK* ) 177 -> tBTM_STATUS { return tBTM_STATUS::BTM_SUCCESS; },
178 .BTM_BleObserve = [](bool /* start */, uint8_t /* duration */,
179 tBTM_INQ_RESULTS_CB* /* p_results_cb */,
__anon46c2d7713c02(bool , uint8_t , tBTM_INQ_RESULTS_CB* , tBTM_CMPL_CB* ) 180 tBTM_CMPL_CB* /* p_cmpl_cb */) -> tBTM_STATUS {
181 return tBTM_STATUS::BTM_SUCCESS;
182 },
183 .BTM_SetBleDataLength = [](const RawAddress& /* bd_addr */,
__anon46c2d7713d02(const RawAddress& , uint16_t ) 184 uint16_t /* tx_pdu_length */) -> tBTM_STATUS {
185 return tBTM_STATUS::BTM_SUCCESS;
186 },
187 .BTM_BleReadControllerFeatures =
__anon46c2d7713e02(tBTM_BLE_CTRL_FEATURES_CBACK* ) 188 [](tBTM_BLE_CTRL_FEATURES_CBACK* /* p_vsc_cback */) {},
189 .BTM_BleSetPhy = [](const RawAddress& /* bd_addr */, uint8_t /* tx_phys */,
__anon46c2d7713f02(const RawAddress& , uint8_t , uint8_t , uint16_t ) 190 uint8_t /* rx_phys */, uint16_t /* phy_options */) {},
191 .BTM_BleSetPrefConnParams =
192 [](const RawAddress& /* bd_addr */, uint16_t /* min_conn_int */,
193 uint16_t /* max_conn_int */, uint16_t /* peripheral_latency */,
__anon46c2d7714002(const RawAddress& , uint16_t , uint16_t , uint16_t , uint16_t ) 194 uint16_t /* supervision_tout */) {},
__anon46c2d7714102(const RawAddress& ) 195 .BTM_UseLeLink = [](const RawAddress& /* bd_addr */) -> bool { return false; },
__anon46c2d7714202(const RawAddress& ) 196 .BTM_IsRemoteVersionReceived = [](const RawAddress& /* remote_bda */) -> bool {
197 return true;
198 },
__anon46c2d7714302(BTM_CONSOLIDATION_CB* ) 199 .BTM_SetConsolidationCallback = [](BTM_CONSOLIDATION_CB* /* cb */) {},
200 },
201 .sco = {
202 .BTM_CreateSco = [](const RawAddress* /* remote_bda */, bool /* is_orig */,
203 uint16_t /* pkt_types */, uint16_t* /* p_sco_inx */,
204 tBTM_SCO_CB* /* p_conn_cb */, tBTM_SCO_CB* /* p_disc_cb */)
__anon46c2d7714402(const RawAddress* , bool , uint16_t , uint16_t* , tBTM_SCO_CB* , tBTM_SCO_CB* ) 205 -> tBTM_STATUS { return tBTM_STATUS::BTM_SUCCESS; },
206 .BTM_RegForEScoEvts = [](uint16_t /* sco_inx */,
__anon46c2d7714502(uint16_t , tBTM_ESCO_CBACK* ) 207 tBTM_ESCO_CBACK* /* p_esco_cback */) -> tBTM_STATUS {
208 return tBTM_STATUS::BTM_SUCCESS;
209 },
__anon46c2d7714602(uint16_t ) 210 .BTM_RemoveSco = [](uint16_t /* sco_inx */) -> tBTM_STATUS {
211 return tBTM_STATUS::BTM_SUCCESS;
212 },
__anon46c2d7714702(const RawAddress& ) 213 .BTM_RemoveScoByBdaddr = [](const RawAddress& /* bd_addr */) {},
__anon46c2d7714802(uint16_t ) 214 .BTM_WriteVoiceSettings = [](uint16_t /* settings */) {},
215 .BTM_EScoConnRsp = [](uint16_t /* sco_inx */, tHCI_STATUS /* hci_status */,
__anon46c2d7714902(uint16_t , tHCI_STATUS , enh_esco_params_t* ) 216 enh_esco_params_t* /* p_parms */) {},
__anon46c2d7714a02() 217 .BTM_GetNumScoLinks = []() -> uint8_t { return 0; },
__anon46c2d7714b02(enh_esco_params_t* ) 218 .BTM_SetEScoMode = [](enh_esco_params_t* /* p_parms */) -> tBTM_STATUS {
219 return tBTM_STATUS::BTM_SUCCESS;
220 },
__anon46c2d7714c02() 221 .BTM_GetScoDebugDump = []() -> tBTM_SCO_DEBUG_DUMP { return {}; },
__anon46c2d7714d02(const RawAddress& ) 222 .BTM_IsScoActiveByBdaddr = [](const RawAddress& /* remote_bda */) -> bool {
223 return false;
224 },
225 },
226 .local = {
__anon46c2d7714e02(const char** ) 227 .BTM_ReadLocalDeviceName = [](const char** /* p_name */) -> tBTM_STATUS {
228 return tBTM_STATUS::BTM_SUCCESS;
229 },
__anon46c2d7714f02(const char* ) 230 .BTM_SetLocalDeviceName = [](const char* /* p_name */) -> tBTM_STATUS {
231 return tBTM_STATUS::BTM_SUCCESS;
232 },
__anon46c2d7715002(DEV_CLASS ) 233 .BTM_SetDeviceClass = [](DEV_CLASS /* dev_class */) -> tBTM_STATUS {
234 return tBTM_STATUS::BTM_SUCCESS;
235 },
__anon46c2d7715102() 236 .BTM_IsDeviceUp = []() -> bool { return true; },
__anon46c2d7715202() 237 .BTM_ReadDeviceClass = []() -> DEV_CLASS { return kDevClassEmpty; },
238 },
239 .eir = {
__anon46c2d7715302(BT_HDR* ) 240 .BTM_WriteEIR = [](BT_HDR* /* p_buff */) -> tBTM_STATUS {
241 return tBTM_STATUS::BTM_SUCCESS;
242 },
243 .BTM_GetEirSupportedServices = [](uint32_t* /* p_eir_uuid */, uint8_t** /* p */,
244 uint8_t /* max_num_uuid16 */,
__anon46c2d7715402(uint32_t* , uint8_t** , uint8_t , uint8_t* ) 245 uint8_t* /* p_num_uuid16 */) -> uint8_t {
246 return 0;
247 },
248 .BTM_GetEirUuidList = [](const uint8_t* /* p_eir */, size_t /* eir_len */,
249 uint8_t /* uuid_size */, uint8_t* /* p_num_uuid */,
250 uint8_t* /* p_uuid_list */,
__anon46c2d7715502(const uint8_t* , size_t , uint8_t , uint8_t* , uint8_t* , uint8_t ) 251 uint8_t /* max_num_uuid */) -> uint8_t { return 0; },
__anon46c2d7715602(uint32_t* , uint16_t ) 252 .BTM_AddEirService = [](uint32_t* /* p_eir_uuid */, uint16_t /* uuid16 */) {},
__anon46c2d7715702(uint32_t* , uint16_t ) 253 .BTM_RemoveEirService = [](uint32_t* /* p_eir_uuid */, uint16_t /* uuid16 */) {},
254 },
255 .db = {
__anon46c2d7715802(const RawAddress& ) 256 .BTM_InqDbRead = [](const RawAddress& /* p_bda */) -> tBTM_INQ_INFO* {
257 return nullptr;
258 },
__anon46c2d7715902() 259 .BTM_InqDbFirst = []() -> tBTM_INQ_INFO* { return nullptr; },
__anon46c2d7715a02(tBTM_INQ_INFO* ) 260 .BTM_InqDbNext = [](tBTM_INQ_INFO* /* p_cur */) -> tBTM_INQ_INFO* {
261 return nullptr;
262 },
__anon46c2d7715b02(const RawAddress* ) 263 .BTM_ClearInqDb = [](const RawAddress* /* p_bda */) -> tBTM_STATUS {
264 return tBTM_STATUS::BTM_SUCCESS;
265 },
266 },
267 .vendor =
268 {
269 .BTM_VendorSpecificCommand =
270 [](uint16_t /* opcode */, uint8_t /* param_len */,
__anon46c2d7715c02(uint16_t , uint8_t , uint8_t* , tBTM_VSC_CMPL_CB* ) 271 uint8_t* /* p_param_buf */, tBTM_VSC_CMPL_CB* /* p_cb */) {},
272 },
273 };
274
275 } // namespace
276
BTM_BleReadControllerFeatures(void (*)(tHCI_ERROR_CODE))277 void BTM_BleReadControllerFeatures(void (*)(tHCI_ERROR_CODE)) {}
BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *)278 tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK* /* p_ener_cback */) {
279 return tBTM_STATUS::BTM_SUCCESS;
280 }
281
282 // Initialize the working btm client interface to the default
283 struct btm_client_interface_t mock_btm_client_interface = default_btm_client_interface;
284
285 // Reset the working btm client interface to the default
reset_mock_btm_client_interface()286 void reset_mock_btm_client_interface() { mock_btm_client_interface = default_btm_client_interface; }
287
288 // Serve the working btm client interface
get_btm_client_interface()289 struct btm_client_interface_t& get_btm_client_interface() { return mock_btm_client_interface; }
290