1 /*
2 * Copyright 2019 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 #define LOG_TAG "bt_shim_btm"
18
19 #include <base/callback.h>
20
21 #include <mutex>
22
23 #include "common/metric_id_allocator.h"
24 #include "common/time_util.h"
25 #include "device/include/controller.h"
26 #include "gd/common/callback.h"
27 #include "gd/neighbor/name.h"
28 #include "gd/os/log.h"
29 #include "gd/security/security_module.h"
30 #include "gd/security/ui.h"
31 #include "main/shim/btm.h"
32 #include "main/shim/btm_api.h"
33 #include "main/shim/controller.h"
34 #include "main/shim/helpers.h"
35 #include "main/shim/metric_id_api.h"
36 #include "main/shim/shim.h"
37 #include "main/shim/stack.h"
38 #include "stack/btm/btm_int_types.h"
39 #include "types/raw_address.h"
40
41 using bluetooth::common::MetricIdAllocator;
42
43 #define BTIF_DM_DEFAULT_INQ_MAX_RESULTS 0
44 #define BTIF_DM_DEFAULT_INQ_MAX_DURATION 10
45
46 /**
47 * Legacy bluetooth module global control block state
48 *
49 * Mutex is used to synchronize access from the shim
50 * layer into the global control block. This is used
51 * by the shim despite potentially arbitrary
52 * unsynchronized access by the legacy stack.
53 */
54 extern tBTM_CB btm_cb;
55 std::mutex btm_cb_mutex_;
56
57 extern bool btm_inq_find_bdaddr(const RawAddress& p_bda);
58 extern tINQ_DB_ENT* btm_inq_db_find(const RawAddress& raw_address);
59 extern tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda);
60
61 /**
62 * Legacy bluetooth btm stack entry points
63 */
64 extern void btm_acl_update_inquiry_status(uint8_t status);
65 extern void btm_clear_all_pending_le_entry(void);
66 extern void btm_clr_inq_result_flt(void);
67 extern void btm_set_eir_uuid(uint8_t* p_eir, tBTM_INQ_RESULTS* p_results);
68 extern void btm_sort_inq_result(void);
69 extern void btm_process_inq_complete(uint8_t status, uint8_t result_type);
70
is_classic_device(tBT_DEVICE_TYPE device_type)71 static bool is_classic_device(tBT_DEVICE_TYPE device_type) {
72 return device_type == BT_DEVICE_TYPE_BREDR;
73 }
74
has_classic_device(tBT_DEVICE_TYPE device_type)75 static bool has_classic_device(tBT_DEVICE_TYPE device_type) {
76 return device_type & BT_DEVICE_TYPE_BREDR;
77 }
78
btm_api_process_inquiry_result(const RawAddress & raw_address,uint8_t page_scan_rep_mode,DEV_CLASS device_class,uint16_t clock_offset)79 void btm_api_process_inquiry_result(const RawAddress& raw_address,
80 uint8_t page_scan_rep_mode,
81 DEV_CLASS device_class,
82 uint16_t clock_offset) {
83 tINQ_DB_ENT* p_i = btm_inq_db_find(raw_address);
84
85 if (p_i == nullptr) {
86 p_i = btm_inq_db_new(raw_address);
87 CHECK(p_i != nullptr);
88 } else if (p_i->inq_count == btm_cb.btm_inq_vars.inq_counter &&
89 is_classic_device(p_i->inq_info.results.device_type)) {
90 return;
91 }
92
93 p_i->inq_info.results.page_scan_rep_mode = page_scan_rep_mode;
94 p_i->inq_info.results.page_scan_per_mode = 0; // RESERVED
95 p_i->inq_info.results.page_scan_mode = 0; // RESERVED
96 p_i->inq_info.results.dev_class[0] = device_class[0];
97 p_i->inq_info.results.dev_class[1] = device_class[1];
98 p_i->inq_info.results.dev_class[2] = device_class[2];
99 p_i->inq_info.results.clock_offset = clock_offset | BTM_CLOCK_OFFSET_VALID;
100 p_i->inq_info.results.inq_result_type = BTM_INQ_RESULT_BR;
101 p_i->inq_info.results.rssi = BTM_INQ_RES_IGNORE_RSSI;
102
103 p_i->time_of_resp = bluetooth::common::time_get_os_boottime_ms();
104 p_i->inq_count = btm_cb.btm_inq_vars.inq_counter;
105 p_i->inq_info.appl_knows_rem_name = false;
106
107 if (p_i->inq_count != btm_cb.btm_inq_vars.inq_counter) {
108 p_i->inq_info.results.device_type = BT_DEVICE_TYPE_BREDR;
109 btm_cb.btm_inq_vars.inq_cmpl_info.num_resp++;
110 p_i->scan_rsp = false;
111 } else {
112 p_i->inq_info.results.device_type |= BT_DEVICE_TYPE_BREDR;
113 }
114
115 if (btm_cb.btm_inq_vars.p_inq_results_cb == nullptr) {
116 return;
117 }
118
119 (btm_cb.btm_inq_vars.p_inq_results_cb)(&p_i->inq_info.results, nullptr, 0);
120 }
121
btm_api_process_inquiry_result_with_rssi(RawAddress raw_address,uint8_t page_scan_rep_mode,DEV_CLASS device_class,uint16_t clock_offset,int8_t rssi)122 void btm_api_process_inquiry_result_with_rssi(RawAddress raw_address,
123 uint8_t page_scan_rep_mode,
124 DEV_CLASS device_class,
125 uint16_t clock_offset,
126 int8_t rssi) {
127 tINQ_DB_ENT* p_i = btm_inq_db_find(raw_address);
128
129 bool update = false;
130 if (btm_inq_find_bdaddr(raw_address)) {
131 if (p_i != nullptr &&
132 (rssi > p_i->inq_info.results.rssi || p_i->inq_info.results.rssi == 0 ||
133 has_classic_device(p_i->inq_info.results.device_type))) {
134 update = true;
135 }
136 }
137
138 bool is_new = true;
139 if (p_i == nullptr) {
140 p_i = btm_inq_db_new(raw_address);
141 CHECK(p_i != nullptr);
142 } else if (p_i->inq_count == btm_cb.btm_inq_vars.inq_counter &&
143 is_classic_device(p_i->inq_info.results.device_type)) {
144 is_new = false;
145 }
146
147 p_i->inq_info.results.rssi = rssi;
148
149 if (is_new) {
150 p_i->inq_info.results.page_scan_rep_mode = page_scan_rep_mode;
151 p_i->inq_info.results.page_scan_per_mode = 0; // RESERVED
152 p_i->inq_info.results.page_scan_mode = 0; // RESERVED
153 p_i->inq_info.results.dev_class[0] = device_class[0];
154 p_i->inq_info.results.dev_class[1] = device_class[1];
155 p_i->inq_info.results.dev_class[2] = device_class[2];
156 p_i->inq_info.results.clock_offset = clock_offset | BTM_CLOCK_OFFSET_VALID;
157 p_i->inq_info.results.inq_result_type = BTM_INQ_RESULT_BR;
158
159 p_i->time_of_resp = bluetooth::common::time_get_os_boottime_ms();
160 p_i->inq_count = btm_cb.btm_inq_vars.inq_counter;
161 p_i->inq_info.appl_knows_rem_name = false;
162
163 if (p_i->inq_count != btm_cb.btm_inq_vars.inq_counter) {
164 p_i->inq_info.results.device_type = BT_DEVICE_TYPE_BREDR;
165 btm_cb.btm_inq_vars.inq_cmpl_info.num_resp++;
166 p_i->scan_rsp = false;
167 } else {
168 p_i->inq_info.results.device_type |= BT_DEVICE_TYPE_BREDR;
169 }
170 }
171
172 if (btm_cb.btm_inq_vars.p_inq_results_cb == nullptr) {
173 return;
174 }
175
176 if (is_new || update) {
177 (btm_cb.btm_inq_vars.p_inq_results_cb)(&p_i->inq_info.results, nullptr, 0);
178 }
179 }
btm_api_process_extended_inquiry_result(RawAddress raw_address,uint8_t page_scan_rep_mode,DEV_CLASS device_class,uint16_t clock_offset,int8_t rssi,const uint8_t * eir_data,size_t eir_len)180 void btm_api_process_extended_inquiry_result(RawAddress raw_address,
181 uint8_t page_scan_rep_mode,
182 DEV_CLASS device_class,
183 uint16_t clock_offset, int8_t rssi,
184 const uint8_t* eir_data,
185 size_t eir_len) {
186 tINQ_DB_ENT* p_i = btm_inq_db_find(raw_address);
187
188 bool update = false;
189 if (btm_inq_find_bdaddr(raw_address) && p_i != nullptr) {
190 update = true;
191 }
192
193 bool is_new = true;
194 if (p_i == nullptr) {
195 p_i = btm_inq_db_new(raw_address);
196 } else if (p_i->inq_count == btm_cb.btm_inq_vars.inq_counter &&
197 (p_i->inq_info.results.device_type == BT_DEVICE_TYPE_BREDR)) {
198 is_new = false;
199 }
200
201 p_i->inq_info.results.rssi = rssi;
202
203 if (is_new) {
204 p_i->inq_info.results.page_scan_rep_mode = page_scan_rep_mode;
205 p_i->inq_info.results.page_scan_per_mode = 0; // RESERVED
206 p_i->inq_info.results.page_scan_mode = 0; // RESERVED
207 p_i->inq_info.results.dev_class[0] = device_class[0];
208 p_i->inq_info.results.dev_class[1] = device_class[1];
209 p_i->inq_info.results.dev_class[2] = device_class[2];
210 p_i->inq_info.results.clock_offset = clock_offset | BTM_CLOCK_OFFSET_VALID;
211 p_i->inq_info.results.inq_result_type = BTM_INQ_RESULT_BR;
212
213 p_i->time_of_resp = bluetooth::common::time_get_os_boottime_ms();
214 p_i->inq_count = btm_cb.btm_inq_vars.inq_counter;
215 p_i->inq_info.appl_knows_rem_name = false;
216
217 if (p_i->inq_count != btm_cb.btm_inq_vars.inq_counter) {
218 p_i->inq_info.results.device_type = BT_DEVICE_TYPE_BREDR;
219 btm_cb.btm_inq_vars.inq_cmpl_info.num_resp++;
220 p_i->scan_rsp = false;
221 } else {
222 p_i->inq_info.results.device_type |= BT_DEVICE_TYPE_BREDR;
223 }
224 }
225
226 if (btm_cb.btm_inq_vars.p_inq_results_cb == nullptr) {
227 return;
228 }
229
230 if (is_new || update) {
231 memset(p_i->inq_info.results.eir_uuid, 0,
232 BTM_EIR_SERVICE_ARRAY_SIZE * (BTM_EIR_ARRAY_BITS / 8));
233 btm_set_eir_uuid(const_cast<uint8_t*>(eir_data), &p_i->inq_info.results);
234 uint8_t* p_eir_data = const_cast<uint8_t*>(eir_data);
235 (btm_cb.btm_inq_vars.p_inq_results_cb)(&p_i->inq_info.results, p_eir_data,
236 eir_len);
237 }
238 }
239
240 namespace {
241 std::unordered_map<bluetooth::hci::AddressWithType, bt_bdname_t>
242 address_name_map_;
243
244 std::unordered_map<bluetooth::hci::IoCapability, int> gd_legacy_io_caps_map_ = {
245 {bluetooth::hci::IoCapability::DISPLAY_ONLY, BTM_IO_CAP_OUT},
246 {bluetooth::hci::IoCapability::DISPLAY_YES_NO, BTM_IO_CAP_IO},
247 {bluetooth::hci::IoCapability::KEYBOARD_ONLY, BTM_IO_CAP_IN},
248 {bluetooth::hci::IoCapability::NO_INPUT_NO_OUTPUT, BTM_IO_CAP_NONE},
249 };
250
251 std::unordered_map<bluetooth::hci::AuthenticationRequirements, int>
252 gd_legacy_auth_reqs_map_ = {
253 {bluetooth::hci::AuthenticationRequirements::NO_BONDING,
254 BTM_AUTH_SP_NO},
255 {bluetooth::hci::AuthenticationRequirements::NO_BONDING_MITM_PROTECTION,
256 BTM_AUTH_SP_YES},
257 {bluetooth::hci::AuthenticationRequirements::DEDICATED_BONDING,
258 BTM_AUTH_AP_NO},
259 {bluetooth::hci::AuthenticationRequirements::
260 DEDICATED_BONDING_MITM_PROTECTION,
261 BTM_AUTH_AP_YES},
262 {bluetooth::hci::AuthenticationRequirements::GENERAL_BONDING,
263 BTM_AUTH_SPGB_NO},
264 {bluetooth::hci::AuthenticationRequirements::
265 GENERAL_BONDING_MITM_PROTECTION,
266 BTM_AUTH_SPGB_YES},
267 };
268 }
269
270 class ShimUi : public bluetooth::security::UI {
271 public:
GetInstance()272 static ShimUi* GetInstance() {
273 static ShimUi instance;
274 return &instance;
275 }
276
277 ShimUi(const ShimUi&) = delete;
278 ShimUi& operator=(const ShimUi&) = delete;
279
SetBtaCallbacks(const tBTM_APPL_INFO * bta_callbacks)280 void SetBtaCallbacks(const tBTM_APPL_INFO* bta_callbacks) {
281 bta_callbacks_ = bta_callbacks;
282 if (bta_callbacks->p_pin_callback == nullptr) {
283 LOG_INFO("UNIMPLEMENTED %s pin_callback", __func__);
284 }
285
286 if (bta_callbacks->p_link_key_callback == nullptr) {
287 LOG_INFO("UNIMPLEMENTED %s link_key_callback", __func__);
288 }
289
290 if (bta_callbacks->p_auth_complete_callback == nullptr) {
291 LOG_INFO("UNIMPLEMENTED %s auth_complete_callback", __func__);
292 }
293
294 if (bta_callbacks->p_bond_cancel_cmpl_callback == nullptr) {
295 LOG_INFO("UNIMPLEMENTED %s bond_cancel_complete_callback", __func__);
296 }
297
298 if (bta_callbacks->p_le_callback == nullptr) {
299 LOG_INFO("UNIMPLEMENTED %s le_callback", __func__);
300 }
301
302 if (bta_callbacks->p_le_key_callback == nullptr) {
303 LOG_INFO("UNIMPLEMENTED %s le_key_callback", __func__);
304 }
305 }
306
DisplayPairingPrompt(const bluetooth::hci::AddressWithType & address,std::string name)307 void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& address,
308 std::string name) {
309 waiting_for_pairing_prompt_ = true;
310 bt_bdname_t legacy_name{0};
311 memcpy(legacy_name.name, name.data(), name.length());
312 // TODO(optedoblivion): Handle callback to BTA for BLE
313 }
314
Cancel(const bluetooth::hci::AddressWithType & address)315 void Cancel(const bluetooth::hci::AddressWithType& address) {
316 LOG(WARNING) << " ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ " << __func__;
317 }
318
HandleConfirm(bluetooth::security::ConfirmationData data)319 void HandleConfirm(bluetooth::security::ConfirmationData data) {
320 const bluetooth::hci::AddressWithType& address = data.GetAddressWithType();
321 uint32_t numeric_value = data.GetNumericValue();
322 bt_bdname_t legacy_name{0};
323 memcpy(legacy_name.name, data.GetName().data(), data.GetName().length());
324
325 if (bta_callbacks_->p_sp_callback) {
326 // Call sp_cback for IO_REQ
327 tBTM_SP_IO_REQ io_req_evt_data;
328 io_req_evt_data.bd_addr = bluetooth::ToRawAddress(address.GetAddress());
329 // Local IO Caps (Phone is always DisplayYesNo)
330 io_req_evt_data.io_cap = BTM_IO_CAP_IO;
331 // Local Auth Reqs (Phone is always DEDICATED_BONDING)
332 io_req_evt_data.auth_req = BTM_AUTH_AP_NO;
333 io_req_evt_data.oob_data = BTM_OOB_NONE;
334 (*bta_callbacks_->p_sp_callback)(BTM_SP_IO_REQ_EVT,
335 (tBTM_SP_EVT_DATA*)&io_req_evt_data);
336
337 // Call sp_cback for IO_RSP
338 tBTM_SP_IO_RSP io_rsp_evt_data;
339 io_rsp_evt_data.bd_addr = bluetooth::ToRawAddress(address.GetAddress());
340 io_rsp_evt_data.io_cap = gd_legacy_io_caps_map_[data.GetRemoteIoCaps()];
341 io_rsp_evt_data.auth_req =
342 gd_legacy_auth_reqs_map_[data.GetRemoteAuthReqs()];
343 io_rsp_evt_data.auth_req = BTM_AUTH_AP_YES;
344 io_rsp_evt_data.oob_data = BTM_OOB_NONE;
345 (*bta_callbacks_->p_sp_callback)(BTM_SP_IO_RSP_EVT,
346 (tBTM_SP_EVT_DATA*)&io_rsp_evt_data);
347
348 // Call sp_cback for USER_CONFIRMATION
349 tBTM_SP_EVT_DATA user_cfm_req_evt_data;
350 user_cfm_req_evt_data.cfm_req.bd_addr =
351 bluetooth::ToRawAddress(address.GetAddress());
352 user_cfm_req_evt_data.cfm_req.num_val = numeric_value;
353 // If we pop a dialog then it isn't just_works
354 user_cfm_req_evt_data.cfm_req.just_works = data.IsJustWorks();
355
356 address_name_map_.emplace(address, legacy_name);
357 memcpy((char*)user_cfm_req_evt_data.cfm_req.bd_name, legacy_name.name,
358 BD_NAME_LEN);
359
360 (*bta_callbacks_->p_sp_callback)(BTM_SP_CFM_REQ_EVT,
361 &user_cfm_req_evt_data);
362 }
363 }
364
DisplayConfirmValue(bluetooth::security::ConfirmationData data)365 void DisplayConfirmValue(bluetooth::security::ConfirmationData data) {
366 waiting_for_pairing_prompt_ = false;
367 data.SetJustWorks(false);
368 HandleConfirm(data);
369 }
370
DisplayYesNoDialog(bluetooth::security::ConfirmationData data)371 void DisplayYesNoDialog(bluetooth::security::ConfirmationData data) {
372 waiting_for_pairing_prompt_ = false;
373 data.SetJustWorks(true);
374 HandleConfirm(data);
375 }
376
DisplayEnterPasskeyDialog(bluetooth::security::ConfirmationData data)377 void DisplayEnterPasskeyDialog(bluetooth::security::ConfirmationData data) {
378 waiting_for_pairing_prompt_ = false;
379 LOG_WARN("UNIMPLEMENTED, Passkey not supported in GD");
380 }
381
DisplayPasskey(bluetooth::security::ConfirmationData data)382 void DisplayPasskey(bluetooth::security::ConfirmationData data) {
383 waiting_for_pairing_prompt_ = false;
384 LOG_WARN("UNIMPLEMENTED, Passkey not supported in GD");
385 }
386
DisplayEnterPinDialog(bluetooth::security::ConfirmationData data)387 void DisplayEnterPinDialog(bluetooth::security::ConfirmationData data) {
388 waiting_for_pairing_prompt_ = false;
389 LOG_WARN("UNIMPLEMENTED, PIN not supported in GD");
390 }
391
392 bool waiting_for_pairing_prompt_ = false;
393
394 private:
ShimUi()395 ShimUi() : bta_callbacks_(nullptr) {}
~ShimUi()396 ~ShimUi() {}
397 const tBTM_APPL_INFO* bta_callbacks_;
398 };
399
400 ShimUi* shim_ui_ = nullptr;
401
402 class ShimBondListener : public bluetooth::security::ISecurityManagerListener {
403 public:
GetInstance()404 static ShimBondListener* GetInstance() {
405 static ShimBondListener instance;
406 return &instance;
407 }
408
409 ShimBondListener(const ShimBondListener&) = delete;
410 ShimBondListener& operator=(const ShimBondListener&) = delete;
411
SetBtaCallbacks(const tBTM_APPL_INFO * bta_callbacks)412 void SetBtaCallbacks(const tBTM_APPL_INFO* bta_callbacks) {
413 bta_callbacks_ = bta_callbacks;
414 if (bta_callbacks->p_pin_callback == nullptr) {
415 LOG_INFO("UNIMPLEMENTED %s pin_callback", __func__);
416 }
417
418 if (bta_callbacks->p_link_key_callback == nullptr) {
419 LOG_INFO("UNIMPLEMENTED %s link_key_callback", __func__);
420 }
421
422 if (bta_callbacks->p_auth_complete_callback == nullptr) {
423 LOG_INFO("UNIMPLEMENTED %s auth_complete_callback", __func__);
424 }
425
426 if (bta_callbacks->p_bond_cancel_cmpl_callback == nullptr) {
427 LOG_INFO("UNIMPLEMENTED %s bond_cancel_complete_callback", __func__);
428 }
429
430 if (bta_callbacks->p_le_callback == nullptr) {
431 LOG_INFO("UNIMPLEMENTED %s le_callback", __func__);
432 }
433
434 if (bta_callbacks->p_le_key_callback == nullptr) {
435 LOG_INFO("UNIMPLEMENTED %s le_key_callback", __func__);
436 }
437 }
438
OnDeviceBonded(bluetooth::hci::AddressWithType device)439 void OnDeviceBonded(bluetooth::hci::AddressWithType device) override {
440 // Call sp_cback for LINK_KEY_NOTIFICATION
441 // Call AUTHENTICATION_COMPLETE callback
442 if (device.GetAddressType() ==
443 bluetooth::hci::AddressType::PUBLIC_DEVICE_ADDRESS) {
444 auto it = address_name_map_.find(device);
445 bt_bdname_t tmp_name;
446 if (it != address_name_map_.end()) {
447 tmp_name = it->second;
448 }
449 BD_NAME name;
450 memcpy((char*)name, tmp_name.name, BD_NAME_LEN);
451
452 if (*bta_callbacks_->p_link_key_callback) {
453 LinkKey key; // Never want to send the key to the stack
454 (*bta_callbacks_->p_link_key_callback)(
455 bluetooth::ToRawAddress(device.GetAddress()), 0, name, key,
456 BTM_LKEY_TYPE_COMBINATION);
457 }
458 if (*bta_callbacks_->p_auth_complete_callback) {
459 (*bta_callbacks_->p_auth_complete_callback)(
460 bluetooth::ToRawAddress(device.GetAddress()), 0, name, HCI_SUCCESS);
461 }
462 }
463 bool is_gd_enabled = bluetooth::shim::is_any_gd_enabled();
464 if (is_gd_enabled) {
465 bluetooth::shim::AllocateIdFromMetricIdAllocator(
466 bluetooth::ToRawAddress(device.GetAddress()));
467 } else {
468 MetricIdAllocator::GetInstance().AllocateId(
469 bluetooth::ToRawAddress(device.GetAddress()));
470 }
471 bool is_saving_successful =
472 is_gd_enabled ? bluetooth::shim::SaveDeviceOnMetricIdAllocator(
473 bluetooth::ToRawAddress(device.GetAddress()))
474 : MetricIdAllocator::GetInstance().SaveDevice(
475 bluetooth::ToRawAddress(device.GetAddress()));
476 if (!is_saving_successful) {
477 LOG(FATAL) << __func__ << ": Fail to save metric id for device "
478 << bluetooth::ToRawAddress(device.GetAddress());
479 }
480 }
481
OnDeviceUnbonded(bluetooth::hci::AddressWithType device)482 void OnDeviceUnbonded(bluetooth::hci::AddressWithType device) override {
483 if (bta_callbacks_->p_bond_cancel_cmpl_callback) {
484 (*bta_callbacks_->p_bond_cancel_cmpl_callback)(BTM_SUCCESS);
485 }
486 if (bluetooth::shim::is_any_gd_enabled()) {
487 bluetooth::shim::ForgetDeviceFromMetricIdAllocator(
488 bluetooth::ToRawAddress(device.GetAddress()));
489 } else {
490 MetricIdAllocator::GetInstance().ForgetDevice(
491 bluetooth::ToRawAddress(device.GetAddress()));
492 }
493 }
494
OnDeviceBondFailed(bluetooth::hci::AddressWithType device,bluetooth::security::PairingFailure status)495 void OnDeviceBondFailed(bluetooth::hci::AddressWithType device,
496 bluetooth::security::PairingFailure status) override {
497 auto it = address_name_map_.find(device);
498 bt_bdname_t tmp_name;
499 if (it != address_name_map_.end()) {
500 tmp_name = it->second;
501 }
502 BD_NAME name;
503 memcpy((char*)name, tmp_name.name, BD_NAME_LEN);
504
505 if (bta_callbacks_->p_auth_complete_callback) {
506 (*bta_callbacks_->p_auth_complete_callback)(
507 bluetooth::ToRawAddress(device.GetAddress()), 0, name,
508 HCI_ERR_AUTH_FAILURE);
509 }
510 }
511
OnEncryptionStateChanged(bluetooth::hci::EncryptionChangeView encryption_change_view)512 void OnEncryptionStateChanged(
513 bluetooth::hci::EncryptionChangeView encryption_change_view) override {
514 // TODO(optedoblivion): Find BTA callback for this to call
515 }
516
517 private:
ShimBondListener()518 ShimBondListener() : bta_callbacks_(nullptr) {}
~ShimBondListener()519 ~ShimBondListener() {}
520 const tBTM_APPL_INFO* bta_callbacks_;
521 };
522
BTM_StartInquiry(tBTM_INQ_RESULTS_CB * p_results_cb,tBTM_CMPL_CB * p_cmpl_cb)523 tBTM_STATUS bluetooth::shim::BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb,
524 tBTM_CMPL_CB* p_cmpl_cb) {
525 CHECK(p_results_cb != nullptr);
526 CHECK(p_cmpl_cb != nullptr);
527
528 tBTM_INQ_PARMS inqparms = {};
529 inqparms.mode = BTM_GENERAL_INQUIRY | BTM_BLE_GENERAL_INQUIRY;
530 inqparms.duration = BTIF_DM_DEFAULT_INQ_MAX_DURATION;
531
532 std::lock_guard<std::mutex> lock(btm_cb_mutex_);
533
534 btm_cb.btm_inq_vars.inq_cmpl_info.num_resp = 0;
535
536 Stack::GetInstance()->GetBtm()->StartActiveScanning();
537 if (inqparms.duration != 0) {
538 Stack::GetInstance()->GetBtm()->SetScanningTimer(
539 inqparms.duration * 1000, common::BindOnce([]() {
540 LOG_INFO("%s scanning timeout popped", __func__);
541 std::lock_guard<std::mutex> lock(btm_cb_mutex_);
542 Stack::GetInstance()->GetBtm()->StopActiveScanning();
543 }));
544 }
545
546 Stack::GetInstance()->GetBtm()->StartActiveScanning();
547
548 uint8_t classic_mode = inqparms.mode & 0x0f;
549 if (!Stack::GetInstance()->GetBtm()->StartInquiry(
550 classic_mode, inqparms.duration, 0,
551 [](tBTM_STATUS status, uint8_t inquiry_mode) {
552 LOG_INFO("%s Inquiry is complete status:%hd inquiry_mode:%hhd",
553 __func__, status, inquiry_mode);
554 btm_cb.btm_inq_vars.inqparms.mode &= ~(inquiry_mode);
555
556 btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);
557 if (btm_cb.btm_inq_vars.inq_active) {
558 btm_cb.btm_inq_vars.inq_cmpl_info.status = status;
559 btm_clear_all_pending_le_entry();
560 btm_cb.btm_inq_vars.state = BTM_INQ_INACTIVE_STATE;
561
562 /* Increment so the start of a next inquiry has a new count */
563 btm_cb.btm_inq_vars.inq_counter++;
564
565 btm_clr_inq_result_flt();
566
567 if ((status == BTM_SUCCESS) &&
568 controller_get_interface()
569 ->supports_rssi_with_inquiry_results()) {
570 btm_sort_inq_result();
571 }
572
573 btm_cb.btm_inq_vars.inq_active = BTM_INQUIRY_INACTIVE;
574 btm_cb.btm_inq_vars.p_inq_results_cb = nullptr;
575 btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
576
577 if (btm_cb.btm_inq_vars.p_inq_cmpl_cb != nullptr) {
578 LOG_INFO("%s Sending inquiry completion to upper layer",
579 __func__);
580 (btm_cb.btm_inq_vars.p_inq_cmpl_cb)(
581 (tBTM_INQUIRY_CMPL*)&btm_cb.btm_inq_vars.inq_cmpl_info);
582 btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
583 }
584 }
585 })) {
586 LOG_WARN("%s Unable to start inquiry", __func__);
587 return BTM_ERR_PROCESSING;
588 }
589
590 btm_cb.btm_inq_vars.state = BTM_INQ_ACTIVE_STATE;
591 btm_cb.btm_inq_vars.p_inq_cmpl_cb = p_cmpl_cb;
592 btm_cb.btm_inq_vars.p_inq_results_cb = p_results_cb;
593 btm_cb.btm_inq_vars.inq_active = inqparms.mode;
594
595 btm_acl_update_inquiry_status(BTM_INQUIRY_STARTED);
596
597 return BTM_CMD_STARTED;
598 }
599
BTM_SetDiscoverability(uint16_t discoverable_mode,uint16_t window,uint16_t interval)600 tBTM_STATUS bluetooth::shim::BTM_SetDiscoverability(uint16_t discoverable_mode,
601 uint16_t window,
602 uint16_t interval) {
603 uint16_t classic_discoverable_mode = discoverable_mode & 0xff;
604 uint16_t le_discoverable_mode = discoverable_mode >> 8;
605
606 if (window == 0) window = BTM_DEFAULT_DISC_WINDOW;
607 if (interval == 0) interval = BTM_DEFAULT_DISC_INTERVAL;
608
609 switch (le_discoverable_mode) {
610 case kDiscoverableModeOff:
611 Stack::GetInstance()->GetBtm()->StopAdvertising();
612 break;
613 case kLimitedDiscoverableMode:
614 case kGeneralDiscoverableMode:
615 Stack::GetInstance()->GetBtm()->StartAdvertising();
616 break;
617 default:
618 LOG_WARN("%s Unexpected le discoverability mode:%d", __func__,
619 le_discoverable_mode);
620 }
621
622 switch (classic_discoverable_mode) {
623 case kDiscoverableModeOff:
624 Stack::GetInstance()->GetBtm()->SetClassicDiscoverabilityOff();
625 break;
626 case kLimitedDiscoverableMode:
627 Stack::GetInstance()->GetBtm()->SetClassicLimitedDiscoverability(
628 window, interval);
629 break;
630 case kGeneralDiscoverableMode:
631 Stack::GetInstance()->GetBtm()->SetClassicGeneralDiscoverability(
632 window, interval);
633 break;
634 default:
635 LOG_WARN("%s Unexpected classic discoverability mode:%d", __func__,
636 classic_discoverable_mode);
637 }
638 return BTM_SUCCESS;
639 }
640
BTM_EnableInterlacedInquiryScan()641 void bluetooth::shim::BTM_EnableInterlacedInquiryScan() {
642 Stack::GetInstance()->GetBtm()->SetInterlacedInquiryScan();
643 }
644
BTM_BleObserve(bool start,uint8_t duration_sec,tBTM_INQ_RESULTS_CB * p_results_cb,tBTM_CMPL_CB * p_cmpl_cb)645 tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec,
646 tBTM_INQ_RESULTS_CB* p_results_cb,
647 tBTM_CMPL_CB* p_cmpl_cb) {
648 if (start) {
649 CHECK(p_results_cb != nullptr);
650 CHECK(p_cmpl_cb != nullptr);
651
652 std::lock_guard<std::mutex> lock(btm_cb_mutex_);
653
654 if (btm_cb.ble_ctr_cb.is_ble_observe_active()) {
655 LOG_WARN("%s Observing already active", __func__);
656 return BTM_WRONG_MODE;
657 }
658
659 btm_cb.ble_ctr_cb.p_obs_results_cb = p_results_cb;
660 btm_cb.ble_ctr_cb.p_obs_cmpl_cb = p_cmpl_cb;
661 Stack::GetInstance()->GetBtm()->StartObserving();
662 btm_cb.ble_ctr_cb.set_ble_observe_active();
663
664 if (duration_sec != 0) {
665 Stack::GetInstance()->GetBtm()->SetObservingTimer(
666 duration_sec * 1000, common::BindOnce([]() {
667 LOG_INFO("%s observing timeout popped", __func__);
668
669 Stack::GetInstance()->GetBtm()->CancelObservingTimer();
670 Stack::GetInstance()->GetBtm()->StopObserving();
671
672 std::lock_guard<std::mutex> lock(btm_cb_mutex_);
673 btm_cb.ble_ctr_cb.reset_ble_observe();
674
675 if (btm_cb.ble_ctr_cb.p_obs_cmpl_cb) {
676 (btm_cb.ble_ctr_cb.p_obs_cmpl_cb)(
677 &btm_cb.btm_inq_vars.inq_cmpl_info);
678 }
679 btm_cb.ble_ctr_cb.p_obs_results_cb = nullptr;
680 btm_cb.ble_ctr_cb.p_obs_cmpl_cb = nullptr;
681
682 btm_cb.btm_inq_vars.inqparms.mode &= ~(BTM_BLE_INQUIRY_MASK);
683
684 btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);
685
686 btm_clear_all_pending_le_entry();
687 btm_cb.btm_inq_vars.state = BTM_INQ_INACTIVE_STATE;
688
689 btm_cb.btm_inq_vars.inq_counter++;
690 btm_clr_inq_result_flt();
691 btm_sort_inq_result();
692
693 btm_cb.btm_inq_vars.inq_active = BTM_INQUIRY_INACTIVE;
694 btm_cb.btm_inq_vars.p_inq_results_cb = NULL;
695 btm_cb.btm_inq_vars.p_inq_cmpl_cb = NULL;
696
697 if (btm_cb.btm_inq_vars.p_inq_cmpl_cb) {
698 (btm_cb.btm_inq_vars.p_inq_cmpl_cb)(
699 (tBTM_INQUIRY_CMPL*)&btm_cb.btm_inq_vars.inq_cmpl_info);
700 btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
701 }
702 }));
703 }
704 } else {
705 std::lock_guard<std::mutex> lock(btm_cb_mutex_);
706
707 if (!btm_cb.ble_ctr_cb.is_ble_observe_active()) {
708 LOG_WARN("%s Observing already inactive", __func__);
709 }
710 Stack::GetInstance()->GetBtm()->CancelObservingTimer();
711 Stack::GetInstance()->GetBtm()->StopObserving();
712 btm_cb.ble_ctr_cb.reset_ble_observe();
713 Stack::GetInstance()->GetBtm()->StopObserving();
714 if (btm_cb.ble_ctr_cb.p_obs_cmpl_cb) {
715 (btm_cb.ble_ctr_cb.p_obs_cmpl_cb)(&btm_cb.btm_inq_vars.inq_cmpl_info);
716 }
717 btm_cb.ble_ctr_cb.p_obs_results_cb = nullptr;
718 btm_cb.ble_ctr_cb.p_obs_cmpl_cb = nullptr;
719 }
720 return BTM_CMD_STARTED;
721 }
722
BTM_EnableInterlacedPageScan()723 void bluetooth::shim::BTM_EnableInterlacedPageScan() {
724 Stack::GetInstance()->GetBtm()->SetInterlacedPageScan();
725 }
726
BTM_SetInquiryMode(uint8_t inquiry_mode)727 tBTM_STATUS bluetooth::shim::BTM_SetInquiryMode(uint8_t inquiry_mode) {
728 switch (inquiry_mode) {
729 case kStandardInquiryResult:
730 Stack::GetInstance()->GetBtm()->SetStandardInquiryResultMode();
731 break;
732 case kInquiryResultWithRssi:
733 Stack::GetInstance()->GetBtm()->SetInquiryWithRssiResultMode();
734 break;
735 case kExtendedInquiryResult:
736 Stack::GetInstance()->GetBtm()->SetExtendedInquiryResultMode();
737 break;
738 default:
739 return BTM_ILLEGAL_VALUE;
740 }
741 return BTM_SUCCESS;
742 }
743
BTM_SetConnectability(uint16_t page_mode,uint16_t window,uint16_t interval)744 tBTM_STATUS bluetooth::shim::BTM_SetConnectability(uint16_t page_mode,
745 uint16_t window,
746 uint16_t interval) {
747 uint16_t classic_connectible_mode = page_mode & 0xff;
748 uint16_t le_connectible_mode = page_mode >> 8;
749
750 if (!window) window = BTM_DEFAULT_CONN_WINDOW;
751 if (!interval) interval = BTM_DEFAULT_CONN_INTERVAL;
752
753 switch (le_connectible_mode) {
754 case kConnectibleModeOff:
755 Stack::GetInstance()->GetBtm()->StopConnectability();
756 break;
757 case kConnectibleModeOn:
758 Stack::GetInstance()->GetBtm()->StartConnectability();
759 break;
760 default:
761 return BTM_ILLEGAL_VALUE;
762 break;
763 }
764
765 switch (classic_connectible_mode) {
766 case kConnectibleModeOff:
767 Stack::GetInstance()->GetBtm()->SetClassicConnectibleOff();
768 break;
769 case kConnectibleModeOn:
770 Stack::GetInstance()->GetBtm()->SetClassicConnectibleOn();
771 break;
772 default:
773 return BTM_ILLEGAL_VALUE;
774 break;
775 }
776 return BTM_SUCCESS;
777 }
778
BTM_IsInquiryActive(void)779 uint16_t bluetooth::shim::BTM_IsInquiryActive(void) {
780 if (Stack::GetInstance()->GetBtm()->IsGeneralInquiryActive()) {
781 return BTM_GENERAL_INQUIRY_ACTIVE;
782 }
783 return BTM_INQUIRY_INACTIVE;
784 }
785
BTM_CancelInquiry(void)786 void bluetooth::shim::BTM_CancelInquiry(void) {
787 LOG_INFO("%s Cancel inquiry", __func__);
788 Stack::GetInstance()->GetBtm()->CancelInquiry();
789
790 btm_cb.btm_inq_vars.state = BTM_INQ_INACTIVE_STATE;
791 btm_clr_inq_result_flt();
792
793 Stack::GetInstance()->GetBtm()->CancelScanningTimer();
794 Stack::GetInstance()->GetBtm()->StopActiveScanning();
795
796 btm_cb.ble_ctr_cb.reset_ble_inquiry();
797
798 btm_cb.btm_inq_vars.inqparms.mode &=
799 ~(btm_cb.btm_inq_vars.inqparms.mode & BTM_BLE_INQUIRY_MASK);
800
801 btm_acl_update_inquiry_status(BTM_INQUIRY_COMPLETE);
802 /* Ignore any stray or late complete messages if the inquiry is not active */
803 if (btm_cb.btm_inq_vars.inq_active) {
804 btm_cb.btm_inq_vars.inq_cmpl_info.status = BTM_SUCCESS;
805 btm_clear_all_pending_le_entry();
806
807 if (controller_get_interface()->supports_rssi_with_inquiry_results()) {
808 btm_sort_inq_result();
809 }
810
811 btm_cb.btm_inq_vars.inq_active = BTM_INQUIRY_INACTIVE;
812 btm_cb.btm_inq_vars.p_inq_results_cb = nullptr;
813 btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
814 btm_cb.btm_inq_vars.inq_counter++;
815
816 if (btm_cb.btm_inq_vars.p_inq_cmpl_cb != nullptr) {
817 LOG_INFO("%s Sending cancel inquiry completion to upper layer", __func__);
818 (btm_cb.btm_inq_vars.p_inq_cmpl_cb)(
819 (tBTM_INQUIRY_CMPL*)&btm_cb.btm_inq_vars.inq_cmpl_info);
820 btm_cb.btm_inq_vars.p_inq_cmpl_cb = nullptr;
821 }
822 }
823 }
824
BTM_ReadRemoteDeviceName(const RawAddress & raw_address,tBTM_CMPL_CB * callback,tBT_TRANSPORT transport)825 tBTM_STATUS bluetooth::shim::BTM_ReadRemoteDeviceName(
826 const RawAddress& raw_address, tBTM_CMPL_CB* callback,
827 tBT_TRANSPORT transport) {
828 CHECK(callback != nullptr);
829 tBTM_STATUS status = BTM_NO_RESOURCES;
830
831 switch (transport) {
832 case BT_TRANSPORT_LE:
833 status = Stack::GetInstance()->GetBtm()->ReadLeRemoteDeviceName(
834 raw_address, callback);
835 break;
836 case BT_TRANSPORT_BR_EDR:
837 status = Stack::GetInstance()->GetBtm()->ReadClassicRemoteDeviceName(
838 raw_address, callback);
839 break;
840 default:
841 LOG_WARN("%s Unspecified transport:%d", __func__, transport);
842 break;
843 }
844 return status;
845 }
846
BTM_CancelRemoteDeviceName(void)847 tBTM_STATUS bluetooth::shim::BTM_CancelRemoteDeviceName(void) {
848 return Stack::GetInstance()->GetBtm()->CancelAllReadRemoteDeviceName();
849 }
850
BTM_InqDbRead(const RawAddress & p_bda)851 tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbRead(const RawAddress& p_bda) {
852 LOG_INFO("UNIMPLEMENTED %s", __func__);
853 return nullptr;
854 }
855
BTM_InqDbFirst(void)856 tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbFirst(void) {
857 LOG_INFO("UNIMPLEMENTED %s", __func__);
858 return nullptr;
859 }
860
BTM_InqDbNext(tBTM_INQ_INFO * p_cur)861 tBTM_INQ_INFO* bluetooth::shim::BTM_InqDbNext(tBTM_INQ_INFO* p_cur) {
862 LOG_INFO("UNIMPLEMENTED %s", __func__);
863 CHECK(p_cur != nullptr);
864 return nullptr;
865 }
866
BTM_ClearInqDb(const RawAddress * p_bda)867 tBTM_STATUS bluetooth::shim::BTM_ClearInqDb(const RawAddress* p_bda) {
868 LOG_INFO("UNIMPLEMENTED %s", __func__);
869 if (p_bda == nullptr) {
870 // clear all entries
871 } else {
872 // clear specific entry
873 }
874 return BTM_NO_RESOURCES;
875 }
876
BTM_WriteEIR(BT_HDR * p_buff)877 tBTM_STATUS bluetooth::shim::BTM_WriteEIR(BT_HDR* p_buff) {
878 LOG_INFO("UNIMPLEMENTED %s", __func__);
879 CHECK(p_buff != nullptr);
880 osi_free(p_buff);
881 return BTM_NO_RESOURCES;
882 }
883
BTM_HasEirService(const uint32_t * p_eir_uuid,uint16_t uuid16)884 bool bluetooth::shim::BTM_HasEirService(const uint32_t* p_eir_uuid,
885 uint16_t uuid16) {
886 LOG_INFO("UNIMPLEMENTED %s", __func__);
887 CHECK(p_eir_uuid != nullptr);
888 return false;
889 }
890
BTM_HasInquiryEirService(tBTM_INQ_RESULTS * p_results,uint16_t uuid16)891 tBTM_EIR_SEARCH_RESULT bluetooth::shim::BTM_HasInquiryEirService(
892 tBTM_INQ_RESULTS* p_results, uint16_t uuid16) {
893 LOG_INFO("UNIMPLEMENTED %s", __func__);
894 CHECK(p_results != nullptr);
895 return BTM_EIR_UNKNOWN;
896 }
897
BTM_AddEirService(uint32_t * p_eir_uuid,uint16_t uuid16)898 void bluetooth::shim::BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16) {
899 LOG_INFO("UNIMPLEMENTED %s", __func__);
900 CHECK(p_eir_uuid != nullptr);
901 }
902
BTM_RemoveEirService(uint32_t * p_eir_uuid,uint16_t uuid16)903 void bluetooth::shim::BTM_RemoveEirService(uint32_t* p_eir_uuid,
904 uint16_t uuid16) {
905 LOG_INFO("UNIMPLEMENTED %s", __func__);
906 CHECK(p_eir_uuid != nullptr);
907 }
908
BTM_GetEirSupportedServices(uint32_t * p_eir_uuid,uint8_t ** p,uint8_t max_num_uuid16,uint8_t * p_num_uuid16)909 uint8_t bluetooth::shim::BTM_GetEirSupportedServices(uint32_t* p_eir_uuid,
910 uint8_t** p,
911 uint8_t max_num_uuid16,
912 uint8_t* p_num_uuid16) {
913 LOG_INFO("UNIMPLEMENTED %s", __func__);
914 CHECK(p_eir_uuid != nullptr);
915 CHECK(p != nullptr);
916 CHECK(*p != nullptr);
917 CHECK(p_num_uuid16 != nullptr);
918 return BTM_NO_RESOURCES;
919 }
920
BTM_GetEirUuidList(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)921 uint8_t bluetooth::shim::BTM_GetEirUuidList(uint8_t* p_eir, size_t eir_len,
922 uint8_t uuid_size,
923 uint8_t* p_num_uuid,
924 uint8_t* p_uuid_list,
925 uint8_t max_num_uuid) {
926 LOG_INFO("UNIMPLEMENTED %s", __func__);
927 CHECK(p_eir != nullptr);
928 CHECK(p_num_uuid != nullptr);
929 CHECK(p_uuid_list != nullptr);
930 return 0;
931 }
932
BTM_SecAddBleDevice(const RawAddress & bd_addr,tBT_DEVICE_TYPE dev_type,tBLE_ADDR_TYPE addr_type)933 void bluetooth::shim::BTM_SecAddBleDevice(const RawAddress& bd_addr,
934 tBT_DEVICE_TYPE dev_type,
935 tBLE_ADDR_TYPE addr_type) {
936 LOG_INFO("UNIMPLEMENTED %s", __func__);
937 }
938
BTM_SecAddBleKey(const RawAddress & bd_addr,tBTM_LE_KEY_VALUE * p_le_key,tBTM_LE_KEY_TYPE key_type)939 void bluetooth::shim::BTM_SecAddBleKey(const RawAddress& bd_addr,
940 tBTM_LE_KEY_VALUE* p_le_key,
941 tBTM_LE_KEY_TYPE key_type) {
942 LOG_INFO("UNIMPLEMENTED %s", __func__);
943 CHECK(p_le_key != nullptr);
944 }
945
BTM_BleLoadLocalKeys(uint8_t key_type,tBTM_BLE_LOCAL_KEYS * p_key)946 void bluetooth::shim::BTM_BleLoadLocalKeys(uint8_t key_type,
947 tBTM_BLE_LOCAL_KEYS* p_key) {
948 LOG_INFO("UNIMPLEMENTED %s", __func__);
949 CHECK(p_key != nullptr);
950 }
951
952 static Octet16 bogus_root;
953
954 /** Returns local device encryption root (ER) */
BTM_GetDeviceEncRoot()955 const Octet16& bluetooth::shim::BTM_GetDeviceEncRoot() {
956 LOG_INFO("UNIMPLEMENTED %s", __func__);
957 return bogus_root;
958 }
959
960 /** Returns local device identity root (IR). */
BTM_GetDeviceIDRoot()961 const Octet16& bluetooth::shim::BTM_GetDeviceIDRoot() {
962 LOG_INFO("UNIMPLEMENTED %s", __func__);
963 return bogus_root;
964 }
965
966 /** Return local device DHK. */
BTM_GetDeviceDHK()967 const Octet16& bluetooth::shim::BTM_GetDeviceDHK() {
968 LOG_INFO("UNIMPLEMENTED %s", __func__);
969 return bogus_root;
970 }
971
BTM_ReadConnectionAddr(const RawAddress & remote_bda,RawAddress & local_conn_addr,tBLE_ADDR_TYPE * p_addr_type)972 void bluetooth::shim::BTM_ReadConnectionAddr(const RawAddress& remote_bda,
973 RawAddress& local_conn_addr,
974 tBLE_ADDR_TYPE* p_addr_type) {
975 LOG_INFO("UNIMPLEMENTED %s", __func__);
976 CHECK(p_addr_type != nullptr);
977 }
978
BTM_ReadRemoteConnectionAddr(const RawAddress & pseudo_addr,RawAddress & conn_addr,tBLE_ADDR_TYPE * p_addr_type)979 bool bluetooth::shim::BTM_ReadRemoteConnectionAddr(
980 const RawAddress& pseudo_addr, RawAddress& conn_addr,
981 tBLE_ADDR_TYPE* p_addr_type) {
982 LOG_INFO("UNIMPLEMENTED %s", __func__);
983 CHECK(p_addr_type != nullptr);
984 return false;
985 }
986
BTM_SecurityGrant(const RawAddress & bd_addr,uint8_t res)987 void bluetooth::shim::BTM_SecurityGrant(const RawAddress& bd_addr,
988 uint8_t res) {
989 LOG_INFO("UNIMPLEMENTED %s", __func__);
990 }
991
BTM_BleOobDataReply(const RawAddress & bd_addr,uint8_t res,uint8_t len,uint8_t * p_data)992 void bluetooth::shim::BTM_BleOobDataReply(const RawAddress& bd_addr,
993 uint8_t res, uint8_t len,
994 uint8_t* p_data) {
995 LOG_INFO("UNIMPLEMENTED %s", __func__);
996 CHECK(p_data != nullptr);
997 }
998
BTM_BleSecureConnectionOobDataReply(const RawAddress & bd_addr,uint8_t * p_c,uint8_t * p_r)999 void bluetooth::shim::BTM_BleSecureConnectionOobDataReply(
1000 const RawAddress& bd_addr, uint8_t* p_c, uint8_t* p_r) {
1001 LOG_INFO("UNIMPLEMENTED %s", __func__);
1002 CHECK(p_c != nullptr);
1003 CHECK(p_r != nullptr);
1004 }
1005
BTM_BleSetConnScanParams(uint32_t scan_interval,uint32_t scan_window)1006 void bluetooth::shim::BTM_BleSetConnScanParams(uint32_t scan_interval,
1007 uint32_t scan_window) {
1008 LOG_INFO("UNIMPLEMENTED %s", __func__);
1009 }
1010
BTM_BleSetPrefConnParams(const RawAddress & bd_addr,uint16_t min_conn_int,uint16_t max_conn_int,uint16_t peripheral_latency,uint16_t supervision_tout)1011 void bluetooth::shim::BTM_BleSetPrefConnParams(const RawAddress& bd_addr,
1012 uint16_t min_conn_int,
1013 uint16_t max_conn_int,
1014 uint16_t peripheral_latency,
1015 uint16_t supervision_tout) {
1016 LOG_INFO("UNIMPLEMENTED %s", __func__);
1017 }
1018
BTM_ReadDevInfo(const RawAddress & remote_bda,tBT_DEVICE_TYPE * p_dev_type,tBLE_ADDR_TYPE * p_addr_type)1019 void bluetooth::shim::BTM_ReadDevInfo(const RawAddress& remote_bda,
1020 tBT_DEVICE_TYPE* p_dev_type,
1021 tBLE_ADDR_TYPE* p_addr_type) {
1022 LOG_INFO("UNIMPLEMENTED %s", __func__);
1023 CHECK(p_dev_type != nullptr);
1024 CHECK(p_addr_type != nullptr);
1025 }
1026
BTM_ReadConnectedTransportAddress(RawAddress * remote_bda,tBT_TRANSPORT transport)1027 bool bluetooth::shim::BTM_ReadConnectedTransportAddress(
1028 RawAddress* remote_bda, tBT_TRANSPORT transport) {
1029 LOG_INFO("UNIMPLEMENTED %s", __func__);
1030 CHECK(remote_bda != nullptr);
1031 return false;
1032 }
1033
BTM_BleReceiverTest(uint8_t rx_freq,tBTM_CMPL_CB * p_cmd_cmpl_cback)1034 void bluetooth::shim::BTM_BleReceiverTest(uint8_t rx_freq,
1035 tBTM_CMPL_CB* p_cmd_cmpl_cback) {
1036 LOG_INFO("UNIMPLEMENTED %s", __func__);
1037 CHECK(p_cmd_cmpl_cback != nullptr);
1038 }
1039
BTM_BleTransmitterTest(uint8_t tx_freq,uint8_t test_data_len,uint8_t packet_payload,tBTM_CMPL_CB * p_cmd_cmpl_cback)1040 void bluetooth::shim::BTM_BleTransmitterTest(uint8_t tx_freq,
1041 uint8_t test_data_len,
1042 uint8_t packet_payload,
1043 tBTM_CMPL_CB* p_cmd_cmpl_cback) {
1044 LOG_INFO("UNIMPLEMENTED %s", __func__);
1045 CHECK(p_cmd_cmpl_cback != nullptr);
1046 }
1047
BTM_BleTestEnd(tBTM_CMPL_CB * p_cmd_cmpl_cback)1048 void bluetooth::shim::BTM_BleTestEnd(tBTM_CMPL_CB* p_cmd_cmpl_cback) {
1049 LOG_INFO("UNIMPLEMENTED %s", __func__);
1050 CHECK(p_cmd_cmpl_cback != nullptr);
1051 }
1052
BTM_UseLeLink(const RawAddress & raw_address)1053 bool bluetooth::shim::BTM_UseLeLink(const RawAddress& raw_address) {
1054 return Stack::GetInstance()->GetBtm()->UseLeLink(raw_address);
1055 }
1056
BTM_BleReadPhy(const RawAddress & bd_addr,base::Callback<void (uint8_t tx_phy,uint8_t rx_phy,uint8_t status)> cb)1057 void bluetooth::shim::BTM_BleReadPhy(
1058 const RawAddress& bd_addr,
1059 base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb) {
1060 LOG_INFO("UNIMPLEMENTED %s", __func__);
1061 }
1062
BTM_BleSetPhy(const RawAddress & bd_addr,uint8_t tx_phys,uint8_t rx_phys,uint16_t phy_options)1063 void bluetooth::shim::BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys,
1064 uint8_t rx_phys, uint16_t phy_options) {
1065 LOG_INFO("UNIMPLEMENTED %s", __func__);
1066 }
1067
BTM_BleDataSignature(const RawAddress & bd_addr,uint8_t * p_text,uint16_t len,BLE_SIGNATURE signature)1068 bool bluetooth::shim::BTM_BleDataSignature(const RawAddress& bd_addr,
1069 uint8_t* p_text, uint16_t len,
1070 BLE_SIGNATURE signature) {
1071 LOG_INFO("UNIMPLEMENTED %s", __func__);
1072 CHECK(p_text != nullptr);
1073 return false;
1074 }
1075
BTM_BleVerifySignature(const RawAddress & bd_addr,uint8_t * p_orig,uint16_t len,uint32_t counter,uint8_t * p_comp)1076 bool bluetooth::shim::BTM_BleVerifySignature(const RawAddress& bd_addr,
1077 uint8_t* p_orig, uint16_t len,
1078 uint32_t counter,
1079 uint8_t* p_comp) {
1080 LOG_INFO("UNIMPLEMENTED %s", __func__);
1081 CHECK(p_orig != nullptr);
1082 CHECK(p_comp != nullptr);
1083 return false;
1084 }
1085
BTM_GetLeSecurityState(const RawAddress & bd_addr,uint8_t * p_le_dev_sec_flags,uint8_t * p_le_key_size)1086 bool bluetooth::shim::BTM_GetLeSecurityState(const RawAddress& bd_addr,
1087 uint8_t* p_le_dev_sec_flags,
1088 uint8_t* p_le_key_size) {
1089 LOG_INFO("UNIMPLEMENTED %s", __func__);
1090 CHECK(p_le_dev_sec_flags != nullptr);
1091 CHECK(p_le_key_size != nullptr);
1092 return false;
1093 }
1094
BTM_BleSecurityProcedureIsRunning(const RawAddress & bd_addr)1095 bool bluetooth::shim::BTM_BleSecurityProcedureIsRunning(
1096 const RawAddress& bd_addr) {
1097 LOG_INFO("UNIMPLEMENTED %s", __func__);
1098 return false;
1099 }
1100
BTM_BleGetSupportedKeySize(const RawAddress & bd_addr)1101 uint8_t bluetooth::shim::BTM_BleGetSupportedKeySize(const RawAddress& bd_addr) {
1102 LOG_INFO("UNIMPLEMENTED %s", __func__);
1103 return 0;
1104 }
1105
1106 /**
1107 * This function update(add,delete or clear) the adv local name filtering
1108 * condition.
1109 */
BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,tBTM_BLE_PF_FILT_INDEX filt_index,std::vector<uint8_t> name,tBTM_BLE_PF_CFG_CBACK cb)1110 void bluetooth::shim::BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,
1111 tBTM_BLE_PF_FILT_INDEX filt_index,
1112 std::vector<uint8_t> name,
1113 tBTM_BLE_PF_CFG_CBACK cb) {
1114 LOG_INFO("UNIMPLEMENTED %s", __func__);
1115 }
1116
BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,tBTM_BLE_PF_FILT_INDEX filt_index)1117 void bluetooth::shim::BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,
1118 tBTM_BLE_PF_FILT_INDEX filt_index) {
1119 LOG_INFO("UNIMPLEMENTED %s", __func__);
1120 }
1121
BTM_LE_PF_manu_data(tBTM_BLE_SCAN_COND_OP action,tBTM_BLE_PF_FILT_INDEX filt_index,uint16_t company_id,uint16_t company_id_mask,std::vector<uint8_t> data,std::vector<uint8_t> data_mask,tBTM_BLE_PF_CFG_CBACK cb)1122 void bluetooth::shim::BTM_LE_PF_manu_data(
1123 tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_INDEX filt_index,
1124 uint16_t company_id, uint16_t company_id_mask, std::vector<uint8_t> data,
1125 std::vector<uint8_t> data_mask, tBTM_BLE_PF_CFG_CBACK cb) {
1126 LOG_INFO("UNIMPLEMENTED %s", __func__);
1127 }
1128
BTM_LE_PF_srvc_data_pattern(tBTM_BLE_SCAN_COND_OP action,tBTM_BLE_PF_FILT_INDEX filt_index,std::vector<uint8_t> data,std::vector<uint8_t> data_mask,tBTM_BLE_PF_CFG_CBACK cb)1129 void bluetooth::shim::BTM_LE_PF_srvc_data_pattern(
1130 tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_INDEX filt_index,
1131 std::vector<uint8_t> data, std::vector<uint8_t> data_mask,
1132 tBTM_BLE_PF_CFG_CBACK cb) {
1133 LOG_INFO("UNIMPLEMENTED %s", __func__);
1134 }
1135
BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,tBTM_BLE_PF_FILT_INDEX filt_index,tBLE_BD_ADDR addr,tBTM_BLE_PF_CFG_CBACK cb)1136 void bluetooth::shim::BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
1137 tBTM_BLE_PF_FILT_INDEX filt_index,
1138 tBLE_BD_ADDR addr,
1139 tBTM_BLE_PF_CFG_CBACK cb) {
1140 LOG_INFO("UNIMPLEMENTED %s", __func__);
1141 }
1142
BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action,tBTM_BLE_PF_FILT_INDEX filt_index,tBTM_BLE_PF_COND_TYPE filter_type,const bluetooth::Uuid & uuid,tBTM_BLE_PF_LOGIC_TYPE cond_logic,const bluetooth::Uuid & uuid_mask,tBTM_BLE_PF_CFG_CBACK cb)1143 void bluetooth::shim::BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
1144 tBTM_BLE_PF_FILT_INDEX filt_index,
1145 tBTM_BLE_PF_COND_TYPE filter_type,
1146 const bluetooth::Uuid& uuid,
1147 tBTM_BLE_PF_LOGIC_TYPE cond_logic,
1148 const bluetooth::Uuid& uuid_mask,
1149 tBTM_BLE_PF_CFG_CBACK cb) {
1150 LOG_INFO("UNIMPLEMENTED %s", __func__);
1151 }
1152
BTM_LE_PF_set(tBTM_BLE_PF_FILT_INDEX filt_index,std::vector<ApcfCommand> commands,tBTM_BLE_PF_CFG_CBACK cb)1153 void bluetooth::shim::BTM_LE_PF_set(tBTM_BLE_PF_FILT_INDEX filt_index,
1154 std::vector<ApcfCommand> commands,
1155 tBTM_BLE_PF_CFG_CBACK cb) {
1156 LOG_INFO("UNIMPLEMENTED %s", __func__);
1157 }
1158
BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index,tBTM_BLE_PF_CFG_CBACK cb)1159 void bluetooth::shim::BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index,
1160 tBTM_BLE_PF_CFG_CBACK cb) {
1161 LOG_INFO("UNIMPLEMENTED %s", __func__);
1162 }
1163
BTM_BleAdvFilterParamSetup(int action,tBTM_BLE_PF_FILT_INDEX filt_index,std::unique_ptr<btgatt_filt_param_setup_t> p_filt_params,tBTM_BLE_PF_PARAM_CB cb)1164 void bluetooth::shim::BTM_BleAdvFilterParamSetup(
1165 int action, tBTM_BLE_PF_FILT_INDEX filt_index,
1166 std::unique_ptr<btgatt_filt_param_setup_t> p_filt_params,
1167 tBTM_BLE_PF_PARAM_CB cb) {
1168 LOG_INFO("UNIMPLEMENTED %s", __func__);
1169 }
1170
BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy)1171 void bluetooth::shim::BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy) {
1172 LOG_INFO("UNIMPLEMENTED %s", __func__);
1173 }
1174
BTM_BleEnableDisableFilterFeature(uint8_t enable,tBTM_BLE_PF_STATUS_CBACK p_stat_cback)1175 void bluetooth::shim::BTM_BleEnableDisableFilterFeature(
1176 uint8_t enable, tBTM_BLE_PF_STATUS_CBACK p_stat_cback) {
1177 LOG_INFO("UNIMPLEMENTED %s", __func__);
1178 }
1179
BTM_BleMaxMultiAdvInstanceCount()1180 uint8_t bluetooth::shim::BTM_BleMaxMultiAdvInstanceCount() {
1181 return Stack::GetInstance()->GetBtm()->GetNumberOfAdvertisingInstances();
1182 }
1183
BTM_BleLocalPrivacyEnabled(void)1184 bool bluetooth::shim::BTM_BleLocalPrivacyEnabled(void) {
1185 return controller_get_interface()->supports_ble_privacy();
1186 }
1187
BTM_SecBond(const RawAddress & bd_addr,tBLE_ADDR_TYPE addr_type,tBT_TRANSPORT transport,int device_type)1188 tBTM_STATUS bluetooth::shim::BTM_SecBond(const RawAddress& bd_addr,
1189 tBLE_ADDR_TYPE addr_type,
1190 tBT_TRANSPORT transport,
1191 int device_type) {
1192 return Stack::GetInstance()->GetBtm()->CreateBond(bd_addr, addr_type,
1193 transport, device_type);
1194 }
1195
BTM_SecRegister(const tBTM_APPL_INFO * bta_callbacks)1196 bool bluetooth::shim::BTM_SecRegister(const tBTM_APPL_INFO* bta_callbacks) {
1197 CHECK(bta_callbacks != nullptr);
1198 LOG_INFO("%s Registering security application", __func__);
1199
1200 if (bta_callbacks->p_pin_callback == nullptr) {
1201 LOG_INFO("UNIMPLEMENTED %s pin_callback", __func__);
1202 }
1203
1204 if (bta_callbacks->p_link_key_callback == nullptr) {
1205 LOG_INFO("UNIMPLEMENTED %s link_key_callback", __func__);
1206 }
1207
1208 if (bta_callbacks->p_auth_complete_callback == nullptr) {
1209 LOG_INFO("UNIMPLEMENTED %s auth_complete_callback", __func__);
1210 }
1211
1212 if (bta_callbacks->p_bond_cancel_cmpl_callback == nullptr) {
1213 LOG_INFO("UNIMPLEMENTED %s bond_cancel_complete_callback", __func__);
1214 }
1215
1216 if (bta_callbacks->p_le_callback == nullptr) {
1217 LOG_INFO("UNIMPLEMENTED %s le_callback", __func__);
1218 }
1219
1220 if (bta_callbacks->p_le_key_callback == nullptr) {
1221 LOG_INFO("UNIMPLEMENTED %s le_key_callback", __func__);
1222 }
1223
1224 ShimBondListener::GetInstance()->SetBtaCallbacks(bta_callbacks);
1225
1226 bluetooth::shim::GetSecurityModule()
1227 ->GetSecurityManager()
1228 ->RegisterCallbackListener(ShimBondListener::GetInstance(),
1229 bluetooth::shim::GetGdShimHandler());
1230
1231 ShimUi::GetInstance()->SetBtaCallbacks(bta_callbacks);
1232
1233 bluetooth::shim::GetSecurityModule()
1234 ->GetSecurityManager()
1235 ->SetUserInterfaceHandler(ShimUi::GetInstance(),
1236 bluetooth::shim::GetGdShimHandler());
1237
1238 return true;
1239 }
1240
BTM_SecBondCancel(const RawAddress & bd_addr)1241 tBTM_STATUS bluetooth::shim::BTM_SecBondCancel(const RawAddress& bd_addr) {
1242 if (Stack::GetInstance()->GetBtm()->CancelBond(bd_addr)) {
1243 return BTM_SUCCESS;
1244 } else {
1245 return BTM_UNKNOWN_ADDR;
1246 }
1247 }
1248
BTM_SecAddDevice(const RawAddress & bd_addr,DEV_CLASS dev_class,BD_NAME bd_name,uint8_t * features,LinkKey * link_key,uint8_t key_type,uint8_t pin_length)1249 bool bluetooth::shim::BTM_SecAddDevice(const RawAddress& bd_addr,
1250 DEV_CLASS dev_class, BD_NAME bd_name,
1251 uint8_t* features, LinkKey* link_key,
1252 uint8_t key_type, uint8_t pin_length) {
1253 // Check if GD has a security record for the device
1254 return BTM_SUCCESS;
1255 }
1256
BTM_SecDeleteDevice(const RawAddress & bd_addr)1257 bool bluetooth::shim::BTM_SecDeleteDevice(const RawAddress& bd_addr) {
1258 return Stack::GetInstance()->GetBtm()->RemoveBond(bd_addr);
1259 }
1260
BTM_ConfirmReqReply(tBTM_STATUS res,const RawAddress & bd_addr)1261 void bluetooth::shim::BTM_ConfirmReqReply(tBTM_STATUS res,
1262 const RawAddress& bd_addr) {
1263 // Send for both Classic and LE until we can determine the type
1264 bool accept = res == BTM_SUCCESS;
1265 hci::AddressWithType address = ToAddressWithType(bd_addr, 0);
1266 hci::AddressWithType address2 = ToAddressWithType(bd_addr, 1);
1267 auto security_manager =
1268 bluetooth::shim::GetSecurityModule()->GetSecurityManager();
1269 if (ShimUi::GetInstance()->waiting_for_pairing_prompt_) {
1270 LOG(INFO) << "interpreting confirmation as pairing accept " << address;
1271 security_manager->OnPairingPromptAccepted(address, accept);
1272 security_manager->OnPairingPromptAccepted(address2, accept);
1273 ShimUi::GetInstance()->waiting_for_pairing_prompt_ = false;
1274 } else {
1275 LOG(INFO) << "interpreting confirmation as yes/no confirmation " << address;
1276 security_manager->OnConfirmYesNo(address, accept);
1277 security_manager->OnConfirmYesNo(address2, accept);
1278 }
1279 }
1280
BTM_GetHCIConnHandle(const RawAddress & remote_bda,tBT_TRANSPORT transport)1281 uint16_t bluetooth::shim::BTM_GetHCIConnHandle(const RawAddress& remote_bda,
1282 tBT_TRANSPORT transport) {
1283 return Stack::GetInstance()->GetBtm()->GetAclHandle(remote_bda, transport);
1284 }
1285
remote_name_request_complete_noop(void * p_name)1286 static void remote_name_request_complete_noop(void* p_name){
1287 // Should notify BTM_Sec, but we should use GD SMP.
1288 };
1289
SendRemoteNameRequest(const RawAddress & raw_address)1290 void bluetooth::shim::SendRemoteNameRequest(const RawAddress& raw_address) {
1291 Stack::GetInstance()->GetBtm()->ReadClassicRemoteDeviceName(
1292 raw_address, remote_name_request_complete_noop);
1293 }
1294
btm_sec_mx_access_request(const RawAddress & bd_addr,bool is_originator,uint16_t security_requirement,tBTM_SEC_CALLBACK * p_callback,void * p_ref_data)1295 tBTM_STATUS bluetooth::shim::btm_sec_mx_access_request(
1296 const RawAddress& bd_addr, bool is_originator,
1297 uint16_t security_requirement, tBTM_SEC_CALLBACK* p_callback,
1298 void* p_ref_data) {
1299 // Security has already been fulfilled by the l2cap connection, so reply back
1300 // that everything is totally fine and legit and definitely not two kids in a
1301 // trenchcoat
1302
1303 if (p_callback) {
1304 (*p_callback)(&bd_addr, false, p_ref_data, BTM_SUCCESS);
1305 }
1306 return BTM_SUCCESS;
1307 }
1308
BTM_SetEncryption(const RawAddress & bd_addr,tBT_TRANSPORT transport,tBTM_SEC_CALLBACK * p_callback,void * p_ref_data,tBTM_BLE_SEC_ACT sec_act)1309 tBTM_STATUS bluetooth::shim::BTM_SetEncryption(const RawAddress& bd_addr,
1310 tBT_TRANSPORT transport,
1311 tBTM_SEC_CALLBACK* p_callback,
1312 void* p_ref_data,
1313 tBTM_BLE_SEC_ACT sec_act) {
1314 // When we just bond a device, encryption is already done
1315 (*p_callback)(&bd_addr, transport, p_ref_data, BTM_SUCCESS);
1316
1317 // TODO(hsz): Re-encrypt the link after first bonded
1318
1319 return BTM_SUCCESS;
1320 }
1321
BTM_SecClearSecurityFlags(const RawAddress & bd_addr)1322 void bluetooth::shim::BTM_SecClearSecurityFlags(const RawAddress& bd_addr) {
1323 // TODO(optedoblivion): Call RemoveBond on device address
1324 }
1325
BTM_SecReadDevName(const RawAddress & address)1326 char* bluetooth::shim::BTM_SecReadDevName(const RawAddress& address) {
1327 static char name[] = "TODO: See if this is needed";
1328 return name;
1329 }
1330
BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK * p_callback)1331 bool bluetooth::shim::BTM_SecAddRmtNameNotifyCallback(
1332 tBTM_RMT_NAME_CALLBACK* p_callback) {
1333 // TODO(optedoblivion): keep track of callback
1334 LOG_WARN("Unimplemented");
1335 return true;
1336 }
1337
BTM_SecDeleteRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK * p_callback)1338 bool bluetooth::shim::BTM_SecDeleteRmtNameNotifyCallback(
1339 tBTM_RMT_NAME_CALLBACK* p_callback) {
1340 // TODO(optedoblivion): stop keeping track of callback
1341 LOG_WARN("Unimplemented");
1342 return true;
1343 }
1344
BTM_PINCodeReply(const RawAddress & bd_addr,uint8_t res,uint8_t pin_len,uint8_t * p_pin)1345 void bluetooth::shim::BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res,
1346 uint8_t pin_len, uint8_t* p_pin) {
1347 ASSERT_LOG(!bluetooth::shim::is_gd_shim_enabled(), "Unreachable code path");
1348 }
1349
BTM_RemoteOobDataReply(tBTM_STATUS res,const RawAddress & bd_addr,const Octet16 & c,const Octet16 & r)1350 void bluetooth::shim::BTM_RemoteOobDataReply(tBTM_STATUS res,
1351 const RawAddress& bd_addr,
1352 const Octet16& c,
1353 const Octet16& r) {
1354 ASSERT_LOG(!bluetooth::shim::is_gd_shim_enabled(), "Unreachable code path");
1355 }
1356
BTM_SetDeviceClass(DEV_CLASS dev_class)1357 tBTM_STATUS bluetooth::shim::BTM_SetDeviceClass(DEV_CLASS dev_class) {
1358 // TODO(optedoblivion): see if we need this, I don't think we do
1359 LOG_WARN("Unimplemented");
1360 return BTM_SUCCESS;
1361 }
1362