1 /******************************************************************************
2 *
3 * Copyright 2003-2014 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 /******************************************************************************
20 *
21 * This is the API implementation file for the BTA device manager.
22 *
23 ******************************************************************************/
24
25 #include <base/bind.h>
26 #include <vector>
27
28 #include "bt_target.h" // Must be first to define build configuration
29
30 #include "bta/dm/bta_dm_int.h"
31 #include "osi/include/allocator.h"
32 #include "stack/btm/btm_sec.h"
33 #include "stack/include/btm_api.h"
34 #include "stack/include/btu.h" // do_in_main_thread
35 #include "types/bluetooth/uuid.h"
36 #include "types/raw_address.h"
37
38 using bluetooth::Uuid;
39
40 /*****************************************************************************
41 * Constants
42 ****************************************************************************/
43
44 static const tBTA_SYS_REG bta_dm_search_reg = {bta_dm_search_sm_execute,
45 bta_dm_search_sm_disable};
46
BTA_dm_init()47 void BTA_dm_init() {
48 bta_sys_register(BTA_ID_DM_SEARCH, &bta_dm_search_reg);
49 /* if UUID list is not provided as static data */
50 bta_sys_eir_register(bta_dm_eir_update_uuid);
51 bta_sys_cust_eir_register(bta_dm_eir_update_cust_uuid);
52 }
53
54 /** Enables bluetooth device under test mode */
BTA_EnableTestMode(void)55 void BTA_EnableTestMode(void) {
56 do_in_main_thread(FROM_HERE,
57 base::Bind(base::IgnoreResult(BTM_EnableTestMode)));
58 }
59
60 /** This function sets the Bluetooth name of local device */
BTA_DmSetDeviceName(char * p_name)61 void BTA_DmSetDeviceName(char* p_name) {
62 std::vector<uint8_t> name(BD_NAME_LEN + 1);
63 strlcpy((char*)name.data(), p_name, BD_NAME_LEN + 1);
64
65 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_set_dev_name, name));
66 }
67
68 /*******************************************************************************
69 *
70 * Function BTA_DmSearch
71 *
72 * Description This function searches for peer Bluetooth devices. It
73 * performs an inquiry and gets the remote name for devices.
74 * Service discovery is done if services is non zero
75 *
76 *
77 * Returns void
78 *
79 ******************************************************************************/
BTA_DmSearch(tBTA_DM_SEARCH_CBACK * p_cback,bool is_bonding_or_sdp)80 void BTA_DmSearch(tBTA_DM_SEARCH_CBACK* p_cback, bool is_bonding_or_sdp) {
81 tBTA_DM_API_SEARCH* p_msg =
82 (tBTA_DM_API_SEARCH*)osi_calloc(sizeof(tBTA_DM_API_SEARCH));
83
84 /* Queue request if a device is bonding or performing service discovery */
85 if (is_bonding_or_sdp) {
86 p_msg->hdr.event = BTA_DM_API_QUEUE_SEARCH_EVT;
87 } else {
88 p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
89 }
90 p_msg->p_cback = p_cback;
91
92 bta_sys_sendmsg(p_msg);
93 }
94
95 /*******************************************************************************
96 *
97 * Function BTA_DmSearchCancel
98 *
99 * Description This function cancels a search initiated by BTA_DmSearch
100 *
101 *
102 * Returns void
103 *
104 ******************************************************************************/
BTA_DmSearchCancel(void)105 void BTA_DmSearchCancel(void) {
106 bta_dm_search_clear_queue();
107
108 switch (bta_dm_search_get_state()) {
109 case BTA_DM_SEARCH_IDLE:
110 bta_dm_search_cancel_notify();
111 break;
112 case BTA_DM_SEARCH_ACTIVE:
113 bta_dm_search_set_state(BTA_DM_SEARCH_CANCELLING);
114 bta_dm_search_cancel();
115 break;
116 case BTA_DM_SEARCH_CANCELLING:
117 bta_dm_search_cancel_notify();
118 break;
119 case BTA_DM_DISCOVER_ACTIVE:
120 bta_dm_search_set_state(BTA_DM_SEARCH_CANCELLING);
121 bta_dm_search_cancel_notify();
122 break;
123 }
124 }
125
126 /*******************************************************************************
127 *
128 * Function BTA_DmDiscover
129 *
130 * Description This function does service discovery for services of a
131 * peer device
132 *
133 *
134 * Returns void
135 *
136 ******************************************************************************/
BTA_DmDiscover(const RawAddress & bd_addr,tBTA_DM_SEARCH_CBACK * p_cback,tBT_TRANSPORT transport,bool is_bonding_or_sdp)137 void BTA_DmDiscover(const RawAddress& bd_addr, tBTA_DM_SEARCH_CBACK* p_cback,
138 tBT_TRANSPORT transport, bool is_bonding_or_sdp) {
139 tBTA_DM_API_DISCOVER* p_msg =
140 (tBTA_DM_API_DISCOVER*)osi_calloc(sizeof(tBTA_DM_API_DISCOVER));
141
142 if (is_bonding_or_sdp) {
143 p_msg->hdr.event = BTA_DM_API_QUEUE_DISCOVER_EVT;
144 } else {
145 p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
146 }
147 p_msg->bd_addr = bd_addr;
148 p_msg->transport = transport;
149 p_msg->p_cback = p_cback;
150
151 bta_sys_sendmsg(p_msg);
152 }
153
154 /** This function initiates a bonding procedure with a peer device */
BTA_DmBond(const RawAddress & bd_addr,tBLE_ADDR_TYPE addr_type,tBT_TRANSPORT transport,int device_type)155 void BTA_DmBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
156 tBT_TRANSPORT transport, int device_type) {
157 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_bond, bd_addr, addr_type,
158 transport, device_type));
159 }
160
161 /** This function cancels the bonding procedure with a peer device
162 */
BTA_DmBondCancel(const RawAddress & bd_addr)163 void BTA_DmBondCancel(const RawAddress& bd_addr) {
164 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_bond_cancel, bd_addr));
165 }
166
167 /*******************************************************************************
168 *
169 * Function BTA_DmPinReply
170 *
171 * Description This function provides a pincode for a remote device when
172 * one is requested by DM through BTA_DM_PIN_REQ_EVT
173 *
174 *
175 * Returns void
176 *
177 ******************************************************************************/
BTA_DmPinReply(const RawAddress & bd_addr,bool accept,uint8_t pin_len,uint8_t * p_pin)178 void BTA_DmPinReply(const RawAddress& bd_addr, bool accept, uint8_t pin_len,
179 uint8_t* p_pin) {
180 std::unique_ptr<tBTA_DM_API_PIN_REPLY> msg =
181 std::make_unique<tBTA_DM_API_PIN_REPLY>();
182
183 msg->bd_addr = bd_addr;
184 msg->accept = accept;
185 if (accept) {
186 msg->pin_len = pin_len;
187 memcpy(msg->p_pin, p_pin, pin_len);
188 }
189
190 do_in_main_thread(FROM_HERE,
191 base::Bind(bta_dm_pin_reply, base::Passed(&msg)));
192 }
193
194 /*******************************************************************************
195 *
196 * Function BTA_DmLocalOob
197 *
198 * Description This function retrieves the OOB data from local controller.
199 * The result is reported by:
200 * - bta_dm_co_loc_oob_ext() if device supports secure
201 * connections (SC)
202 * - bta_dm_co_loc_oob() if device doesn't support SC
203 *
204 * Returns void
205 *
206 ******************************************************************************/
BTA_DmLocalOob(void)207 void BTA_DmLocalOob(void) {
208 do_in_main_thread(FROM_HERE, base::Bind(BTM_ReadLocalOobData));
209 }
210
211 /*******************************************************************************
212 *
213 * Function BTA_DmConfirm
214 *
215 * Description This function accepts or rejects the numerical value of the
216 * Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
217 *
218 * Returns void
219 *
220 ******************************************************************************/
BTA_DmConfirm(const RawAddress & bd_addr,bool accept)221 void BTA_DmConfirm(const RawAddress& bd_addr, bool accept) {
222 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_confirm, bd_addr, accept));
223 }
224
225 /*******************************************************************************
226 *
227 * Function BTA_DmAddDevice
228 *
229 * Description This function adds a device to the security database list of
230 * peer device
231 *
232 *
233 * Returns void
234 *
235 ******************************************************************************/
BTA_DmAddDevice(const RawAddress & bd_addr,DEV_CLASS dev_class,const LinkKey & link_key,uint8_t key_type,uint8_t pin_length)236 void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
237 const LinkKey& link_key, uint8_t key_type,
238 uint8_t pin_length) {
239 std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg =
240 std::make_unique<tBTA_DM_API_ADD_DEVICE>();
241
242 msg->bd_addr = bd_addr;
243 msg->link_key_known = true;
244 msg->key_type = key_type;
245 msg->link_key = link_key;
246
247 /* Load device class if specified */
248 if (dev_class) {
249 msg->dc_known = true;
250 memcpy(msg->dc, dev_class, DEV_CLASS_LEN);
251 }
252
253 memset(msg->bd_name, 0, BD_NAME_LEN + 1);
254 msg->pin_length = pin_length;
255
256 do_in_main_thread(FROM_HERE,
257 base::Bind(bta_dm_add_device, base::Passed(&msg)));
258 }
259
260 /** This function removes a device fromthe security database list of peer
261 * device. It manages unpairing even while connected */
BTA_DmRemoveDevice(const RawAddress & bd_addr)262 tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr) {
263 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_remove_device, bd_addr));
264 return BTA_SUCCESS;
265 }
266
267 /*******************************************************************************
268 *
269 * Function BTA_GetEirService
270 *
271 * Description This function is called to get BTA service mask from EIR.
272 *
273 * Parameters p_eir - pointer of EIR significant part
274 * p_services - return the BTA service mask
275 *
276 * Returns None
277 *
278 ******************************************************************************/
279 extern const uint16_t bta_service_id_to_uuid_lkup_tbl[];
BTA_GetEirService(uint8_t * p_eir,size_t eir_len,tBTA_SERVICE_MASK * p_services)280 void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
281 tBTA_SERVICE_MASK* p_services) {
282 uint8_t xx, yy;
283 uint8_t num_uuid, max_num_uuid = 32;
284 uint8_t uuid_list[32 * Uuid::kNumBytes16];
285 uint16_t* p_uuid16 = (uint16_t*)uuid_list;
286 tBTA_SERVICE_MASK mask;
287
288 BTM_GetEirUuidList(p_eir, eir_len, Uuid::kNumBytes16, &num_uuid, uuid_list,
289 max_num_uuid);
290 for (xx = 0; xx < num_uuid; xx++) {
291 mask = 1;
292 for (yy = 0; yy < BTA_MAX_SERVICE_ID; yy++) {
293 if (*(p_uuid16 + xx) == bta_service_id_to_uuid_lkup_tbl[yy]) {
294 *p_services |= mask;
295 break;
296 }
297 mask <<= 1;
298 }
299
300 /* for HSP v1.2 only device */
301 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HEADSET_HS)
302 *p_services |= BTA_HSP_SERVICE_MASK;
303
304 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SOURCE)
305 *p_services |= BTA_HL_SERVICE_MASK;
306
307 if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SINK)
308 *p_services |= BTA_HL_SERVICE_MASK;
309 }
310 }
311
312 /*******************************************************************************
313 *
314 * Function BTA_AddEirUuid
315 *
316 * Description Request to add a service class UID to the local
317 * device's EIR data.
318 *
319 * Parameters uuid16 - The service class UUID you wish to add
320 *
321 * Returns void
322 *
323 ******************************************************************************/
BTA_AddEirUuid(uint16_t uuid16)324 void BTA_AddEirUuid(uint16_t uuid16) {
325 APPL_TRACE_API("%s: %d", __func__, uuid16);
326 bta_sys_add_uuid(uuid16);
327 }
328
329 /*******************************************************************************
330 *
331 * Function BTA_RemoveEirUuid
332 *
333 * Description Request to remove a service class UID from the local
334 * device's EIR data.
335 *
336 * Parameters uuid16 - The service class UUID you wish to remove
337 *
338 * Returns void
339 *
340 ******************************************************************************/
BTA_RemoveEirUuid(uint16_t uuid16)341 void BTA_RemoveEirUuid(uint16_t uuid16) {
342 APPL_TRACE_API("%s: %d", __func__, uuid16);
343 bta_sys_remove_uuid(uuid16);
344 }
345
346 /*******************************************************************************
347 *
348 * Function BTA_DmGetConnectionState
349 *
350 * Description Returns whether the remote device is currently connected.
351 *
352 * Returns 0 if the device is NOT connected.
353 *
354 ******************************************************************************/
BTA_DmGetConnectionState(const RawAddress & bd_addr)355 bool BTA_DmGetConnectionState(const RawAddress& bd_addr) {
356 tBTA_DM_PEER_DEVICE* p_dev = bta_dm_find_peer_device(bd_addr);
357 return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED);
358 }
359
360 /*******************************************************************************
361 * Device Identification (DI) Server Functions
362 ******************************************************************************/
363 /*******************************************************************************
364 *
365 * Function BTA_DmSetLocalDiRecord
366 *
367 * Description This function adds a DI record to the local SDP database.
368 *
369 * Returns BTA_SUCCESS if record set sucessfully, otherwise error code.
370 *
371 ******************************************************************************/
BTA_DmSetLocalDiRecord(tSDP_DI_RECORD * p_device_info,uint32_t * p_handle)372 tBTA_STATUS BTA_DmSetLocalDiRecord(tSDP_DI_RECORD* p_device_info,
373 uint32_t* p_handle) {
374 tBTA_STATUS status = BTA_FAILURE;
375
376 if (bta_dm_di_cb.di_num < BTA_DI_NUM_MAX) {
377 if (SDP_SetLocalDiRecord((tSDP_DI_RECORD*)p_device_info, p_handle) ==
378 SDP_SUCCESS) {
379 if (!p_device_info->primary_record) {
380 bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = *p_handle;
381 bta_dm_di_cb.di_num++;
382 }
383
384 bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION);
385 status = BTA_SUCCESS;
386 }
387 }
388
389 return status;
390 }
391
392 /*******************************************************************************
393 *
394 * Function BTA_DmAddBleKey
395 *
396 * Description Add/modify LE device information. This function will be
397 * normally called during host startup to restore all required
398 * information stored in the NVRAM.
399 *
400 * Parameters: bd_addr - BD address of the peer
401 * p_le_key - LE key values.
402 * key_type - LE SMP key type.
403 *
404 * Returns BTA_SUCCESS if successful
405 * BTA_FAIL if operation failed.
406 *
407 ******************************************************************************/
BTA_DmAddBleKey(const RawAddress & bd_addr,tBTA_LE_KEY_VALUE * p_le_key,tBTM_LE_KEY_TYPE key_type)408 void BTA_DmAddBleKey(const RawAddress& bd_addr, tBTA_LE_KEY_VALUE* p_le_key,
409 tBTM_LE_KEY_TYPE key_type) {
410 do_in_main_thread(
411 FROM_HERE, base::Bind(bta_dm_add_blekey, bd_addr, *p_le_key, key_type));
412 }
413
414 /*******************************************************************************
415 *
416 * Function BTA_DmAddBleDevice
417 *
418 * Description Add a BLE device. This function will be normally called
419 * during host startup to restore all required information
420 * for a LE device stored in the NVRAM.
421 *
422 * Parameters: bd_addr - BD address of the peer
423 * dev_type - Remote device's device type.
424 * addr_type - LE device address type.
425 *
426 * Returns void
427 *
428 ******************************************************************************/
BTA_DmAddBleDevice(const RawAddress & bd_addr,tBLE_ADDR_TYPE addr_type,tBT_DEVICE_TYPE dev_type)429 void BTA_DmAddBleDevice(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
430 tBT_DEVICE_TYPE dev_type) {
431 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_add_ble_device, bd_addr,
432 addr_type, dev_type));
433 }
434
435 /*******************************************************************************
436 *
437 * Function BTA_DmBlePasskeyReply
438 *
439 * Description Send BLE SMP passkey reply.
440 *
441 * Parameters: bd_addr - BD address of the peer
442 * accept - passkey entry sucessful or declined.
443 * passkey - passkey value, must be a 6 digit number,
444 * can be lead by 0.
445 *
446 * Returns void
447 *
448 ******************************************************************************/
BTA_DmBlePasskeyReply(const RawAddress & bd_addr,bool accept,uint32_t passkey)449 void BTA_DmBlePasskeyReply(const RawAddress& bd_addr, bool accept,
450 uint32_t passkey) {
451 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_ble_passkey_reply, bd_addr,
452 accept, accept ? passkey : 0));
453 }
454
455 /*******************************************************************************
456 *
457 * Function BTA_DmBleConfirmReply
458 *
459 * Description Send BLE SMP SC user confirmation reply.
460 *
461 * Parameters: bd_addr - BD address of the peer
462 * accept - numbers to compare are the same or
463 * different.
464 *
465 * Returns void
466 *
467 ******************************************************************************/
BTA_DmBleConfirmReply(const RawAddress & bd_addr,bool accept)468 void BTA_DmBleConfirmReply(const RawAddress& bd_addr, bool accept) {
469 do_in_main_thread(FROM_HERE,
470 base::Bind(bta_dm_ble_confirm_reply, bd_addr, accept));
471 }
472
473 /*******************************************************************************
474 *
475 * Function BTA_DmBleSecurityGrant
476 *
477 * Description Grant security request access.
478 *
479 * Parameters: bd_addr - BD address of the peer
480 * res - security grant status.
481 *
482 * Returns void
483 *
484 ******************************************************************************/
BTA_DmBleSecurityGrant(const RawAddress & bd_addr,tBTA_DM_BLE_SEC_GRANT res)485 void BTA_DmBleSecurityGrant(const RawAddress& bd_addr,
486 tBTA_DM_BLE_SEC_GRANT res) {
487 do_in_main_thread(FROM_HERE, base::Bind(BTM_SecurityGrant, bd_addr, res));
488 }
489
490 /*******************************************************************************
491 *
492 * Function BTA_DmSetBlePrefConnParams
493 *
494 * Description This function is called to set the preferred connection
495 * parameters when default connection parameter is not desired.
496 *
497 * Parameters: bd_addr - BD address of the peripheral
498 * scan_interval - scan interval
499 * scan_window - scan window
500 * min_conn_int - minimum preferred connection interval
501 * max_conn_int - maximum preferred connection interval
502 * peripheral_latency - preferred peripheral latency
503 * supervision_tout - preferred supervision timeout
504 *
505 *
506 * Returns void
507 *
508 ******************************************************************************/
BTA_DmSetBlePrefConnParams(const RawAddress & bd_addr,uint16_t min_conn_int,uint16_t max_conn_int,uint16_t peripheral_latency,uint16_t supervision_tout)509 void BTA_DmSetBlePrefConnParams(const RawAddress& bd_addr,
510 uint16_t min_conn_int, uint16_t max_conn_int,
511 uint16_t peripheral_latency,
512 uint16_t supervision_tout) {
513 do_in_main_thread(
514 FROM_HERE,
515 base::Bind(bta_dm_ble_set_conn_params, bd_addr, min_conn_int,
516 max_conn_int, peripheral_latency, supervision_tout));
517 }
518
519 /*******************************************************************************
520 *
521 * Function BTA_DmBleUpdateConnectionParam
522 *
523 * Description Update connection parameters, can only be used when
524 * connection is up.
525 *
526 * Parameters: bd_addr - BD address of the peer
527 * min_int - minimum connection interval,
528 * [0x0004 ~ 0x4000]
529 * max_int - maximum connection interval,
530 * [0x0004 ~ 0x4000]
531 * latency - peripheral latency [0 ~ 500]
532 * timeout - supervision timeout [0x000a ~ 0xc80]
533 *
534 * Returns void
535 *
536 ******************************************************************************/
BTA_DmBleUpdateConnectionParams(const RawAddress & bd_addr,uint16_t min_int,uint16_t max_int,uint16_t latency,uint16_t timeout,uint16_t min_ce_len,uint16_t max_ce_len)537 void BTA_DmBleUpdateConnectionParams(const RawAddress& bd_addr,
538 uint16_t min_int, uint16_t max_int,
539 uint16_t latency, uint16_t timeout,
540 uint16_t min_ce_len, uint16_t max_ce_len) {
541 do_in_main_thread(
542 FROM_HERE, base::Bind(bta_dm_ble_update_conn_params, bd_addr, min_int,
543 max_int, latency, timeout, min_ce_len, max_ce_len));
544 }
545
546 /*******************************************************************************
547 *
548 * Function BTA_DmBleConfigLocalPrivacy
549 *
550 * Description Enable/disable privacy on the local device
551 *
552 * Parameters: privacy_enable - enable/disabe privacy on remote device.
553 *
554 * Returns void
555 *
556 ******************************************************************************/
BTA_DmBleConfigLocalPrivacy(bool privacy_enable)557 void BTA_DmBleConfigLocalPrivacy(bool privacy_enable) {
558 #if (BLE_PRIVACY_SPT == TRUE)
559 do_in_main_thread(
560 FROM_HERE, base::Bind(bta_dm_ble_config_local_privacy, privacy_enable));
561 #else
562 UNUSED(privacy_enable);
563 #endif
564 }
565
566 /*******************************************************************************
567 *
568 * Function BTA_DmBleGetEnergyInfo
569 *
570 * Description This function is called to obtain the energy info
571 *
572 * Parameters p_cmpl_cback - Command complete callback
573 *
574 * Returns void
575 *
576 ******************************************************************************/
BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK * p_cmpl_cback)577 void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK* p_cmpl_cback) {
578 do_in_main_thread(FROM_HERE,
579 base::Bind(bta_dm_ble_get_energy_info, p_cmpl_cback));
580 }
581
582 /** This function is to set maximum LE data packet size */
BTA_DmBleRequestMaxTxDataLength(const RawAddress & remote_device)583 void BTA_DmBleRequestMaxTxDataLength(const RawAddress& remote_device) {
584 do_in_main_thread(FROM_HERE,
585 base::Bind(bta_dm_ble_set_data_length, remote_device));
586 }
587
588 /*******************************************************************************
589 *
590 * Function BTA_DmSetEncryption
591 *
592 * Description This function is called to ensure that connection is
593 * encrypted. Should be called only on an open connection.
594 * Typically only needed for connections that first want to
595 * bring up unencrypted links, then later encrypt them.
596 *
597 * Parameters: bd_addr - Address of the peer device
598 * transport - transport of the link to be encruypted
599 * p_callback - Pointer to callback function to indicat the
600 * link encryption status
601 * sec_act - This is the security action to indicate
602 * what kind of BLE security level is required
603 * for the BLE link if BLE is supported.
604 * Note: This parameter is ignored for the
605 * BR/EDR or if BLE is not supported.
606 *
607 * Returns void
608 *
609 ******************************************************************************/
BTA_DmSetEncryption(const RawAddress & bd_addr,tBT_TRANSPORT transport,tBTA_DM_ENCRYPT_CBACK * p_callback,tBTM_BLE_SEC_ACT sec_act)610 void BTA_DmSetEncryption(const RawAddress& bd_addr, tBT_TRANSPORT transport,
611 tBTA_DM_ENCRYPT_CBACK* p_callback,
612 tBTM_BLE_SEC_ACT sec_act) {
613 APPL_TRACE_API("%s", __func__);
614 do_in_main_thread(FROM_HERE, base::Bind(bta_dm_set_encryption, bd_addr,
615 transport, p_callback, sec_act));
616 }
617
618 /*******************************************************************************
619 *
620 * Function BTA_DmCloseACL
621 *
622 * Description This function force to close an ACL connection and remove
623 * the device from the security database list of known devices.
624 *
625 * Parameters: bd_addr - Address of the peer device
626 * remove_dev - remove device or not after link down
627 *
628 * Returns void
629 *
630 ******************************************************************************/
BTA_DmCloseACL(const RawAddress & bd_addr,bool remove_dev,tBT_TRANSPORT transport)631 void BTA_DmCloseACL(const RawAddress& bd_addr, bool remove_dev,
632 tBT_TRANSPORT transport) {
633 do_in_main_thread(
634 FROM_HERE, base::Bind(bta_dm_close_acl, bd_addr, remove_dev, transport));
635 }
636
637 /*******************************************************************************
638 *
639 * Function BTA_DmBleObserve
640 *
641 * Description This procedure keep the device listening for advertising
642 * events from a broadcast device.
643 *
644 * Parameters start: start or stop observe.
645 *
646 * Returns void
647
648 *
649 * Returns void.
650 *
651 ******************************************************************************/
BTA_DmBleObserve(bool start,uint8_t duration,tBTA_DM_SEARCH_CBACK * p_results_cb)652 extern void BTA_DmBleObserve(bool start, uint8_t duration,
653 tBTA_DM_SEARCH_CBACK* p_results_cb) {
654 APPL_TRACE_API("%s:start = %d ", __func__, start);
655 do_in_main_thread(
656 FROM_HERE, base::Bind(bta_dm_ble_observe, start, duration, p_results_cb));
657 }
658
659 /*******************************************************************************
660 *
661 * Function BTA_VendorInit
662 *
663 * Description This function initializes vendor specific
664 *
665 * Returns void
666 *
667 ******************************************************************************/
BTA_VendorInit(void)668 void BTA_VendorInit(void) { APPL_TRACE_API("BTA_VendorInit"); }
669