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 // Test accessible feature page
30 uint8_t hci_feature_bytes_per_page[HCI_FEATURE_BYTES_PER_PAGE] = {};
31
32 namespace {
33
34 struct btm_client_interface_t default_btm_client_interface = {
35 .lifecycle = {
36 .BTM_PmRegister = [](uint8_t /* mask */, uint8_t* /* p_pm_id */,
__anon9b56c4fb0202(uint8_t , uint8_t* , tBTM_PM_STATUS_CBACK* ) 37 tBTM_PM_STATUS_CBACK* /* p_cb */) -> tBTM_STATUS {
38 return BTM_SUCCESS;
39 },
40 .BTM_GetHCIConnHandle = [](const RawAddress& /* remote_bda */,
__anon9b56c4fb0302(const RawAddress& , tBT_TRANSPORT ) 41 tBT_TRANSPORT /* transport */) -> uint16_t {
42 return 0;
43 },
44 .BTM_VendorSpecificCommand =
45 [](uint16_t /* opcode */, uint8_t /* param_len */,
__anon9b56c4fb0402(uint16_t , uint8_t , uint8_t* , tBTM_VSC_CMPL_CB* ) 46 uint8_t* /* p_param_buf */, tBTM_VSC_CMPL_CB* /* p_cb */) {},
47 .ACL_RegisterClient =
__anon9b56c4fb0502(struct acl_client_callback_s* ) 48 [](struct acl_client_callback_s* /* callbacks */) {},
49 .ACL_UnregisterClient =
__anon9b56c4fb0602(struct acl_client_callback_s* ) 50 [](struct acl_client_callback_s* /* callbacks */) {},
__anon9b56c4fb0702() 51 .btm_init = []() {},
__anon9b56c4fb0802() 52 .btm_free = []() {},
__anon9b56c4fb0902() 53 .btm_ble_init = []() {},
__anon9b56c4fb0a02() 54 .btm_ble_free = []() {},
__anon9b56c4fb0b02() 55 .BTM_reset_complete = []() {},
56 },
57 .peer = {
58 .BTM_IsAclConnectionUp = [](const RawAddress& /* remote_bda */,
__anon9b56c4fb0c02(const RawAddress& , tBT_TRANSPORT ) 59 tBT_TRANSPORT /* transport */) -> bool {
60 return false;
61 },
62 .BTM_ReadConnectedTransportAddress =
63 [](RawAddress* /* remote_bda */,
__anon9b56c4fb0d02(RawAddress* , tBT_TRANSPORT ) 64 tBT_TRANSPORT /* transport */) -> bool { return false; },
__anon9b56c4fb0e02() 65 .BTM_CancelRemoteDeviceName = []() -> tBTM_STATUS {
66 return BTM_SUCCESS;
67 },
68 .BTM_ReadRemoteDeviceName = [](const RawAddress& /* remote_bda */,
69 tBTM_NAME_CMPL_CB* /* p_cb */,
70 tBT_TRANSPORT /* transport */)
__anon9b56c4fb0f02(const RawAddress& , tBTM_NAME_CMPL_CB* , tBT_TRANSPORT ) 71 -> tBTM_STATUS { return BTM_SUCCESS; },
__anon9b56c4fb1002(const RawAddress& ) 72 .BTM_ReadRemoteFeatures = [](const RawAddress& /* addr */) -> uint8_t* {
73 return hci_feature_bytes_per_page;
74 },
75 .BTM_ReadDevInfo = [](const RawAddress& /* remote_bda */,
76 tBT_DEVICE_TYPE* /* p_dev_type */,
__anon9b56c4fb1102(const RawAddress& , tBT_DEVICE_TYPE* , tBLE_ADDR_TYPE* ) 77 tBLE_ADDR_TYPE* /* p_addr_type */) {},
78 .BTM_GetMaxPacketSize =
__anon9b56c4fb1202(const RawAddress& ) 79 [](const RawAddress& /* bd_addr */) -> uint16_t { return 0; },
80 .BTM_ReadRemoteVersion =
81 [](const RawAddress& /* addr */, uint8_t* /* lmp_version */,
82 uint16_t* /* manufacturer */,
__anon9b56c4fb1302(const RawAddress& , uint8_t* , uint16_t* , uint16_t* ) 83 uint16_t* /* lmp_sub_version */) -> bool { return false; },
84 },
85 .link_policy = {
86 .BTM_GetRole = [](const RawAddress& /* remote_bd_addr */,
__anon9b56c4fb1402(const RawAddress& , tHCI_ROLE* ) 87 tHCI_ROLE* /* p_role */) -> tBTM_STATUS {
88 return BTM_SUCCESS;
89 },
90 .BTM_SetPowerMode =
91 [](uint8_t /* pm_id */, const RawAddress& /* remote_bda */,
__anon9b56c4fb1502(uint8_t , const RawAddress& , const tBTM_PM_PWR_MD* ) 92 const tBTM_PM_PWR_MD* /* p_mode */) -> tBTM_STATUS {
93 return BTM_SUCCESS;
94 },
95 .BTM_SetSsrParams = [](RawAddress const& /* bd_addr */,
96 uint16_t /* max_lat */,
97 uint16_t /* min_rmt_to */,
__anon9b56c4fb1602(RawAddress const& , uint16_t , uint16_t , uint16_t ) 98 uint16_t /* min_loc_to */) -> tBTM_STATUS {
99 return BTM_SUCCESS;
100 },
101 .BTM_SwitchRoleToCentral = [](const RawAddress& /* remote_bd_addr */)
__anon9b56c4fb1702(const RawAddress& ) 102 -> tBTM_STATUS { return BTM_SUCCESS; },
__anon9b56c4fb1802(const RawAddress& ) 103 .BTM_block_role_switch_for = [](const RawAddress& /* peer_addr */) {},
__anon9b56c4fb1902(const RawAddress& ) 104 .BTM_block_sniff_mode_for = [](const RawAddress& /* peer_addr */) {},
__anon9b56c4fb1a02() 105 .BTM_default_unblock_role_switch = []() {},
__anon9b56c4fb1b02(const RawAddress& ) 106 .BTM_unblock_role_switch_for = [](const RawAddress& /* peer_addr */) {},
__anon9b56c4fb1c02(const RawAddress& ) 107 .BTM_unblock_sniff_mode_for = [](const RawAddress& /* peer_addr */) {},
__anon9b56c4fb1d02(uint16_t ) 108 .BTM_WritePageTimeout = [](uint16_t /* timeout */) {},
109 },
110 .link_controller = {
111 .BTM_GetLinkSuperTout = [](const RawAddress& /* remote_bda */,
__anon9b56c4fb1e02(const RawAddress& , uint16_t* ) 112 uint16_t* /* p_timeout */) -> tBTM_STATUS {
113 return BTM_SUCCESS;
114 },
115 .BTM_ReadRSSI = [](const RawAddress& /* remote_bda */,
__anon9b56c4fb1f02(const RawAddress& , tBTM_CMPL_CB* ) 116 tBTM_CMPL_CB* /* p_cb */) -> tBTM_STATUS {
117 return BTM_SUCCESS;
118 },
119 },
120 .security = {
__anon9b56c4fb2002() 121 .BTM_Sec_Init = []() {},
__anon9b56c4fb2102() 122 .BTM_Sec_Free = []() {},
__anon9b56c4fb2202(const tBTM_APPL_INFO* ) 123 .BTM_SecRegister = [](const tBTM_APPL_INFO* /* p_cb_info */) -> bool {
124 return false;
125 },
126 .BTM_BleLoadLocalKeys = [](uint8_t /* key_type */,
__anon9b56c4fb2302(uint8_t , tBTM_BLE_LOCAL_KEYS* ) 127 tBTM_BLE_LOCAL_KEYS* /* p_key */) {},
128 .BTM_SecAddDevice = [](const RawAddress& /* bd_addr */,
129 DEV_CLASS /* dev_class */,
130 LinkKey /* link_key */, uint8_t /* key_type */,
__anon9b56c4fb2402(const RawAddress& , DEV_CLASS , LinkKey , uint8_t , uint8_t ) 131 uint8_t /* pin_length */) {},
132 .BTM_SecAddBleDevice = [](const RawAddress& /* bd_addr */,
133 tBT_DEVICE_TYPE /* dev_type */,
__anon9b56c4fb2502(const RawAddress& , tBT_DEVICE_TYPE , tBLE_ADDR_TYPE ) 134 tBLE_ADDR_TYPE /* addr_type */) {},
__anon9b56c4fb2602(const RawAddress& ) 135 .BTM_SecDeleteDevice = [](const RawAddress& /* bd_addr */) -> bool {
136 return true;
137 },
138 .BTM_SecAddBleKey = [](const RawAddress& /* bd_addr */,
139 tBTM_LE_KEY_VALUE* /* p_le_key */,
__anon9b56c4fb2702(const RawAddress& , tBTM_LE_KEY_VALUE* , tBTM_LE_KEY_TYPE ) 140 tBTM_LE_KEY_TYPE /* key_type */) {},
__anon9b56c4fb2802(const RawAddress& ) 141 .BTM_SecClearSecurityFlags = [](const RawAddress& /* bd_addr */) {},
142 .BTM_SetEncryption =
143 [](const RawAddress& /* bd_addr */, tBT_TRANSPORT /* transport */,
144 tBTM_SEC_CALLBACK* /* p_callback */, void* /* p_ref_data */,
__anon9b56c4fb2902(const RawAddress& , tBT_TRANSPORT , tBTM_SEC_CALLBACK* , void* , tBTM_BLE_SEC_ACT ) 145 tBTM_BLE_SEC_ACT /* sec_act */) -> tBTM_STATUS {
146 return BTM_SUCCESS;
147 },
148 .BTM_IsEncrypted = [](const RawAddress& /* bd_addr */,
__anon9b56c4fb2a02(const RawAddress& , tBT_TRANSPORT ) 149 tBT_TRANSPORT /* transport */) -> bool {
150 return false;
151 },
152 .BTM_SecIsSecurityPending =
__anon9b56c4fb2b02(const RawAddress& ) 153 [](const RawAddress& /* bd_addr */) -> bool { return false; },
154 .BTM_IsLinkKeyKnown = [](const RawAddress& /* bd_addr */,
__anon9b56c4fb2c02(const RawAddress& , tBT_TRANSPORT ) 155 tBT_TRANSPORT /* transport */) -> bool {
156 return false;
157 },
__anon9b56c4fb2d02(uint8_t ) 158 .BTM_SecClrService = [](uint8_t /* service_id */) -> uint8_t {
159 return 0;
160 },
__anon9b56c4fb2e02(uint16_t ) 161 .BTM_SecClrServiceByPsm = [](uint16_t /* psm */) -> uint8_t {
162 return 0;
163 },
164 .BTM_SecBond = [](const RawAddress& /* bd_addr */,
165 tBLE_ADDR_TYPE /* addr_type */,
166 tBT_TRANSPORT /* transport */,
__anon9b56c4fb2f02(const RawAddress& , tBLE_ADDR_TYPE , tBT_TRANSPORT , tBT_DEVICE_TYPE ) 167 tBT_DEVICE_TYPE /* device_type */) -> tBTM_STATUS {
168 return BTM_SUCCESS;
169 },
170 .BTM_SecBondCancel = [](const RawAddress& /* bd_addr */)
__anon9b56c4fb3002(const RawAddress& ) 171 -> tBTM_STATUS { return BTM_SUCCESS; },
172
173 .BTM_RemoteOobDataReply =
174 [](tBTM_STATUS /* res */, const RawAddress& /* bd_addr */,
__anon9b56c4fb3102(tBTM_STATUS , const RawAddress& , const Octet16& , const Octet16& ) 175 const Octet16& /* c */, const Octet16& /* r */) {},
176 .BTM_PINCodeReply = [](const RawAddress& /* bd_addr */,
177 tBTM_STATUS /* res */, uint8_t /* pin_len */,
__anon9b56c4fb3202(const RawAddress& , tBTM_STATUS , uint8_t , uint8_t* ) 178 uint8_t* /* p_pin */) {},
179 .BTM_SecConfirmReqReply = [](tBTM_STATUS /* res */,
180 tBT_TRANSPORT /* transport */,
__anon9b56c4fb3302(tBTM_STATUS , tBT_TRANSPORT , const RawAddress ) 181 const RawAddress /* bd_addr */) {},
182 .BTM_BleSirkConfirmDeviceReply = [](const RawAddress& /* bd_addr */,
__anon9b56c4fb3402(const RawAddress& , uint8_t ) 183 uint8_t /* res */) {},
184 .BTM_BlePasskeyReply = [](const RawAddress& /* bd_addr */,
__anon9b56c4fb3502(const RawAddress& , uint8_t , uint32_t ) 185 uint8_t /* res */, uint32_t /* passkey */) {},
__anon9b56c4fb3602() 186 .BTM_GetSecurityMode = []() -> uint8_t { return 0; },
187 .BTM_SecReadDevName = [](const RawAddress& /* bd_addr */)
__anon9b56c4fb3702(const RawAddress& ) 188 -> const char* { return nullptr; },
189 .BTM_SecAddRmtNameNotifyCallback =
__anon9b56c4fb3802(tBTM_RMT_NAME_CALLBACK* ) 190 [](tBTM_RMT_NAME_CALLBACK* /* p_callback */) -> bool {
191 return false;
192 },
193 .BTM_SecDeleteRmtNameNotifyCallback =
__anon9b56c4fb3902(tBTM_RMT_NAME_CALLBACK* ) 194 [](tBTM_RMT_NAME_CALLBACK* /* p_callback */) -> bool {
195 return false;
196 },
197 },
198 .ble = {
199 .BTM_BleGetEnergyInfo =
__anon9b56c4fb3a02(tBTM_BLE_ENERGY_INFO_CBACK* ) 200 [](tBTM_BLE_ENERGY_INFO_CBACK* /* p_ener_cback */) -> tBTM_STATUS {
201 return BTM_SUCCESS;
202 },
203 .BTM_BleObserve = [](bool /* start */, uint8_t /* duration */,
204 tBTM_INQ_RESULTS_CB* /* p_results_cb */,
205 tBTM_CMPL_CB* /* p_cmpl_cb */,
__anon9b56c4fb3b02(bool , uint8_t , tBTM_INQ_RESULTS_CB* , tBTM_CMPL_CB* , bool ) 206 bool /* low_latency_scan */) -> tBTM_STATUS {
207 return BTM_SUCCESS;
208 },
209 .BTM_SetBleDataLength = [](const RawAddress& /* bd_addr */,
210 uint16_t /* tx_pdu_length */)
__anon9b56c4fb3c02(const RawAddress& , uint16_t ) 211 -> tBTM_STATUS { return BTM_SUCCESS; },
212 .BTM_BleReadControllerFeatures =
__anon9b56c4fb3d02(tBTM_BLE_CTRL_FEATURES_CBACK* ) 213 [](tBTM_BLE_CTRL_FEATURES_CBACK* /* p_vsc_cback */) {},
214 .BTM_BleSetPhy = [](const RawAddress& /* bd_addr */,
215 uint8_t /* tx_phys */, uint8_t /* rx_phys */,
__anon9b56c4fb3e02(const RawAddress& , uint8_t , uint8_t , uint16_t ) 216 uint16_t /* phy_options */) {},
217 .BTM_BleSetPrefConnParams =
218 [](const RawAddress& /* bd_addr */, uint16_t /* min_conn_int */,
219 uint16_t /* max_conn_int */, uint16_t /* peripheral_latency */,
__anon9b56c4fb3f02(const RawAddress& , uint16_t , uint16_t , uint16_t , uint16_t ) 220 uint16_t /* supervision_tout */) {},
__anon9b56c4fb4002(const RawAddress& ) 221 .BTM_UseLeLink = [](const RawAddress& /* bd_addr */) -> bool {
222 return false;
223 },
224 },
225 .sco = {
226 .BTM_CreateSco = [](const RawAddress* /* remote_bda */,
227 bool /* is_orig */, uint16_t /* pkt_types */,
228 uint16_t* /* p_sco_inx */,
229 tBTM_SCO_CB* /* p_conn_cb */,
__anon9b56c4fb4102(const RawAddress* , bool , uint16_t , uint16_t* , tBTM_SCO_CB* , tBTM_SCO_CB* ) 230 tBTM_SCO_CB* /* p_disc_cb */) -> tBTM_STATUS {
231 return BTM_SUCCESS;
232 },
233 .BTM_RegForEScoEvts = [](uint16_t /* sco_inx */,
234 tBTM_ESCO_CBACK* /* p_esco_cback */)
__anon9b56c4fb4202(uint16_t , tBTM_ESCO_CBACK* ) 235 -> tBTM_STATUS { return BTM_SUCCESS; },
__anon9b56c4fb4302(uint16_t ) 236 .BTM_RemoveSco = [](uint16_t /* sco_inx */) -> tBTM_STATUS {
237 return BTM_SUCCESS;
238 },
__anon9b56c4fb4402(uint16_t ) 239 .BTM_WriteVoiceSettings = [](uint16_t /* settings */) {},
240 .BTM_EScoConnRsp = [](uint16_t /* sco_inx */,
241 tHCI_STATUS /* hci_status */,
__anon9b56c4fb4502(uint16_t , tHCI_STATUS , enh_esco_params_t* ) 242 enh_esco_params_t* /* p_parms */) {},
__anon9b56c4fb4602() 243 .BTM_GetNumScoLinks = []() -> uint8_t { return 0; },
__anon9b56c4fb4702(enh_esco_params_t* ) 244 .BTM_SetEScoMode = [](enh_esco_params_t* /* p_parms */) -> tBTM_STATUS {
245 return BTM_SUCCESS;
246 },
247 },
248 .local = {
249 .BTM_ReadLocalDeviceName = [](const char** /* p_name */)
__anon9b56c4fb4802(const char** ) 250 -> tBTM_STATUS { return BTM_SUCCESS; },
251 .BTM_ReadLocalDeviceNameFromController =
__anon9b56c4fb4902(tBTM_CMPL_CB* ) 252 [](tBTM_CMPL_CB* /* p_rln_cmpl_cback */) -> tBTM_STATUS {
253 return BTM_SUCCESS;
254 },
__anon9b56c4fb4a02(const char* ) 255 .BTM_SetLocalDeviceName = [](const char* /* p_name */) -> tBTM_STATUS {
256 return BTM_SUCCESS;
257 },
__anon9b56c4fb4b02(DEV_CLASS ) 258 .BTM_SetDeviceClass = [](DEV_CLASS /* dev_class */) -> tBTM_STATUS {
259 return BTM_SUCCESS;
260 },
__anon9b56c4fb4c02() 261 .BTM_IsDeviceUp = []() -> bool { return true; },
__anon9b56c4fb4d02() 262 .BTM_ReadDeviceClass = []() -> DEV_CLASS { return kDevClassEmpty; },
263 },
264 .eir = {
__anon9b56c4fb4e02(BT_HDR* ) 265 .BTM_WriteEIR = [](BT_HDR* /* p_buff */) -> tBTM_STATUS {
266 return BTM_SUCCESS;
267 },
268 .BTM_GetEirSupportedServices =
269 [](uint32_t* /* p_eir_uuid */, uint8_t** /* p */,
270 uint8_t /* max_num_uuid16 */,
__anon9b56c4fb4f02(uint32_t* , uint8_t** , uint8_t , uint8_t* ) 271 uint8_t* /* p_num_uuid16 */) -> uint8_t { return 0; },
272 .BTM_GetEirUuidList =
273 [](const uint8_t* /* p_eir */, size_t /* eir_len */,
274 uint8_t /* uuid_size */, uint8_t* /* p_num_uuid */,
275 uint8_t* /* p_uuid_list */,
__anon9b56c4fb5002(const uint8_t* , size_t , uint8_t , uint8_t* , uint8_t* , uint8_t ) 276 uint8_t /* max_num_uuid */) -> uint8_t { return 0; },
277 .BTM_AddEirService = [](uint32_t* /* p_eir_uuid */,
__anon9b56c4fb5102(uint32_t* , uint16_t ) 278 uint16_t /* uuid16 */) {},
279 .BTM_RemoveEirService = [](uint32_t* /* p_eir_uuid */,
__anon9b56c4fb5202(uint32_t* , uint16_t ) 280 uint16_t /* uuid16 */) {},
281 },
282 .db = {
__anon9b56c4fb5302(const RawAddress& ) 283 .BTM_InqDbRead = [](const RawAddress& /* p_bda */) -> tBTM_INQ_INFO* {
284 return nullptr;
285 },
__anon9b56c4fb5402() 286 .BTM_InqDbFirst = []() -> tBTM_INQ_INFO* { return nullptr; },
__anon9b56c4fb5502(tBTM_INQ_INFO* ) 287 .BTM_InqDbNext = [](tBTM_INQ_INFO* /* p_cur */) -> tBTM_INQ_INFO* {
288 return nullptr;
289 },
__anon9b56c4fb5602(const RawAddress* ) 290 .BTM_ClearInqDb = [](const RawAddress* /* p_bda */) -> tBTM_STATUS {
291 return BTM_SUCCESS;
292 },
293 },
294 };
295
296 } // namespace
297
BTM_BleReadControllerFeatures(void (*)(tHCI_ERROR_CODE))298 void BTM_BleReadControllerFeatures(void (*)(tHCI_ERROR_CODE)) {}
BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *)299 tBTM_STATUS BTM_BleGetEnergyInfo(
300 tBTM_BLE_ENERGY_INFO_CBACK* /* p_ener_cback */) {
301 return BTM_SUCCESS;
302 }
303
304 // Initialize the working btm client interface to the default
305 struct btm_client_interface_t mock_btm_client_interface =
306 default_btm_client_interface;
307
308 // Reset the working btm client interface to the default
reset_mock_btm_client_interface()309 void reset_mock_btm_client_interface() {
310 mock_btm_client_interface = default_btm_client_interface;
311 }
312
313 // Serve the working btm client interface
get_btm_client_interface()314 struct btm_client_interface_t& get_btm_client_interface() {
315 return mock_btm_client_interface;
316 }
317