1 /******************************************************************************
2 *
3 * Copyright 2003-2012 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 file contains the audio gateway functions performing SDP
22 * operations.
23 *
24 ******************************************************************************/
25
26 #include <base/functional/bind.h>
27 #include <base/location.h>
28 #include <base/logging.h>
29
30 #include "bt_target.h" // Legacy stack config
31 #include "bt_trace.h" // Legacy trace logging
32 #include "bta/ag/bta_ag_int.h"
33 #include "btif/include/btif_config.h"
34 #include "common/init_flags.h"
35 #include "device/include/interop.h"
36 #include "device/include/interop_config.h"
37 #include "os/log.h"
38 #include "osi/include/allocator.h"
39 #include "stack/btm/btm_sco_hfp_hal.h"
40 #include "stack/include/btm_api.h"
41 #include "stack/include/btu.h" // do_in_main_thread
42 #include "stack/include/port_api.h"
43 #include "types/bluetooth/uuid.h"
44
45 using bluetooth::Uuid;
46
47 /* Number of protocol elements in protocol element list. */
48 #define BTA_AG_NUM_PROTO_ELEMS 2
49
50 /* Number of elements in service class id list. */
51 #define BTA_AG_NUM_SVC_ELEMS 2
52
53 /* size of database for service discovery */
54 #ifndef BTA_AG_DISC_BUF_SIZE
55 #define BTA_AG_DISC_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
56 #endif
57
58 /* declare sdp callback functions */
59 void bta_ag_sdp_cback_1(tSDP_RESULT);
60 void bta_ag_sdp_cback_2(tSDP_RESULT);
61 void bta_ag_sdp_cback_3(tSDP_RESULT);
62 void bta_ag_sdp_cback_4(tSDP_RESULT);
63 void bta_ag_sdp_cback_5(tSDP_RESULT);
64 void bta_ag_sdp_cback_6(tSDP_RESULT);
65
66 /* SDP callback function table */
67 typedef tSDP_DISC_CMPL_CB* tBTA_AG_SDP_CBACK;
68 const tBTA_AG_SDP_CBACK bta_ag_sdp_cback_tbl[] = {
69 bta_ag_sdp_cback_1, bta_ag_sdp_cback_2, bta_ag_sdp_cback_3,
70 bta_ag_sdp_cback_4, bta_ag_sdp_cback_5, bta_ag_sdp_cback_6};
71
72 /*******************************************************************************
73 *
74 * Function bta_ag_sdp_cback
75 *
76 * Description SDP callback function.
77 *
78 *
79 * Returns void
80 *
81 ******************************************************************************/
bta_ag_sdp_cback(uint16_t status,uint8_t idx)82 static void bta_ag_sdp_cback(uint16_t status, uint8_t idx) {
83 APPL_TRACE_DEBUG("%s status:0x%x", __func__, status);
84 tBTA_AG_SCB* p_scb = bta_ag_scb_by_idx(idx);
85 if (p_scb) {
86 uint16_t event;
87 /* set event according to int/acp */
88 if (p_scb->role == BTA_AG_ACP) {
89 event = BTA_AG_DISC_ACP_RES_EVT;
90 } else {
91 event = BTA_AG_DISC_INT_RES_EVT;
92 }
93 tBTA_AG_DATA disc_result = {.disc_result = {.status = status}};
94 do_in_main_thread(FROM_HERE, base::Bind(&bta_ag_sm_execute_by_handle, idx,
95 event, disc_result));
96 }
97 }
98
99 /*******************************************************************************
100 *
101 * Function bta_ag_sdp_cback_1 to 6
102 *
103 * Description SDP callback functions. Since there is no way to
104 * distinguish scb from the callback we need separate
105 * callbacks for each scb.
106 *
107 *
108 * Returns void
109 *
110 ******************************************************************************/
bta_ag_sdp_cback_1(tSDP_STATUS status)111 void bta_ag_sdp_cback_1(tSDP_STATUS status) { bta_ag_sdp_cback(status, 1); }
bta_ag_sdp_cback_2(tSDP_STATUS status)112 void bta_ag_sdp_cback_2(tSDP_STATUS status) { bta_ag_sdp_cback(status, 2); }
bta_ag_sdp_cback_3(tSDP_STATUS status)113 void bta_ag_sdp_cback_3(tSDP_STATUS status) { bta_ag_sdp_cback(status, 3); }
bta_ag_sdp_cback_4(tSDP_STATUS status)114 void bta_ag_sdp_cback_4(tSDP_STATUS status) { bta_ag_sdp_cback(status, 4); }
bta_ag_sdp_cback_5(tSDP_STATUS status)115 void bta_ag_sdp_cback_5(tSDP_STATUS status) { bta_ag_sdp_cback(status, 5); }
bta_ag_sdp_cback_6(tSDP_STATUS status)116 void bta_ag_sdp_cback_6(tSDP_STATUS status) { bta_ag_sdp_cback(status, 6); }
117
118 /******************************************************************************
119 *
120 * Function bta_ag_add_record
121 *
122 * Description This function is called by a server application to add
123 * HSP or HFP information to an SDP record. Prior to
124 * calling this function the application must call
125 * SDP_CreateRecord() to create an SDP record.
126 *
127 * Returns true if function execution succeeded,
128 * false if function execution failed.
129 *
130 *****************************************************************************/
bta_ag_add_record(uint16_t service_uuid,const char * p_service_name,uint8_t scn,tBTA_AG_FEAT features,uint32_t sdp_handle)131 bool bta_ag_add_record(uint16_t service_uuid, const char* p_service_name,
132 uint8_t scn, tBTA_AG_FEAT features,
133 uint32_t sdp_handle) {
134 tSDP_PROTOCOL_ELEM proto_elem_list[BTA_AG_NUM_PROTO_ELEMS];
135 uint16_t svc_class_id_list[BTA_AG_NUM_SVC_ELEMS];
136 uint16_t browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP};
137 uint16_t version;
138 uint16_t profile_uuid;
139 uint8_t network;
140 bool result = true;
141 bool codec_supported = false;
142 bool swb_supported = false;
143 uint8_t buf[2];
144
145 APPL_TRACE_DEBUG("%s uuid: %x", __func__, service_uuid);
146 LOG_INFO("features: %d", features);
147
148 for (auto& proto_element : proto_elem_list) {
149 proto_element = {};
150 }
151
152 /* add the protocol element sequence */
153 proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
154 proto_elem_list[0].num_params = 0;
155 proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
156 proto_elem_list[1].num_params = 1;
157 proto_elem_list[1].params[0] = scn;
158 result &=
159 SDP_AddProtocolList(sdp_handle, BTA_AG_NUM_PROTO_ELEMS, proto_elem_list);
160
161 /* add service class id list */
162 svc_class_id_list[0] = service_uuid;
163 svc_class_id_list[1] = UUID_SERVCLASS_GENERIC_AUDIO;
164 result &= SDP_AddServiceClassIdList(sdp_handle, BTA_AG_NUM_SVC_ELEMS,
165 svc_class_id_list);
166
167 /* add profile descriptor list */
168 if (service_uuid == UUID_SERVCLASS_AG_HANDSFREE) {
169 profile_uuid = UUID_SERVCLASS_HF_HANDSFREE;
170 if (bluetooth::common::init_flags::hfp_dynamic_version_is_enabled()) {
171 version = HFP_VERSION_1_6;
172 } else {
173 version = get_default_hfp_version();
174 }
175 } else {
176 profile_uuid = UUID_SERVCLASS_HEADSET;
177 version = HSP_VERSION_1_2;
178 }
179 result &= SDP_AddProfileDescriptorList(sdp_handle, profile_uuid, version);
180
181 /* add service name */
182 if (p_service_name != nullptr && p_service_name[0] != 0) {
183 result &= SDP_AddAttribute(
184 sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
185 (uint32_t)(strlen(p_service_name) + 1), (uint8_t*)p_service_name);
186 }
187
188 /* add features and network */
189 if (service_uuid == UUID_SERVCLASS_AG_HANDSFREE) {
190 network = (features & BTA_AG_FEAT_REJECT) ? 1 : 0;
191 result &= SDP_AddAttribute(sdp_handle, ATTR_ID_DATA_STORES_OR_NETWORK,
192 UINT_DESC_TYPE, 1, &network);
193
194 // check property for SWB support
195 if (hfp_hal_interface::get_swb_supported()) {
196 features |= BTA_AG_FEAT_SWB;
197 }
198
199 if (features & BTA_AG_FEAT_CODEC) codec_supported = true;
200 if (features & BTA_AG_FEAT_SWB) swb_supported = true;
201
202 features &= BTA_AG_SDP_FEAT_SPEC;
203
204 /* Codec bit position is different in SDP and in BRSF */
205 if (codec_supported) features |= BTA_AG_FEAT_WBS_SUPPORT;
206 if (swb_supported) features |= BTA_AG_FEAT_SWB_SUPPORT;
207
208 UINT16_TO_BE_FIELD(buf, features);
209 result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES,
210 UINT_DESC_TYPE, 2, buf);
211 }
212
213 /* add browse group list */
214 result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1,
215 browse_list);
216
217 return result;
218 }
219
220 /*******************************************************************************
221 *
222 * Function bta_ag_create_records
223 *
224 * Description Create SDP records for registered services.
225 *
226 *
227 * Returns void
228 *
229 ******************************************************************************/
bta_ag_create_records(tBTA_AG_SCB * p_scb,const tBTA_AG_DATA & data)230 void bta_ag_create_records(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
231 int i;
232 tBTA_SERVICE_MASK services;
233
234 services = p_scb->reg_services >> BTA_HSP_SERVICE_ID;
235 for (i = 0; i < BTA_AG_NUM_IDX && services != 0; i++, services >>= 1) {
236 /* if service is set in mask */
237 if (services & 1) {
238 /* add sdp record if not already registered */
239 if (bta_ag_cb.profile[i].sdp_handle == 0) {
240 bta_ag_cb.profile[i].sdp_handle = SDP_CreateRecord();
241 bta_ag_cb.profile[i].scn = BTM_AllocateSCN();
242 bta_ag_add_record(bta_ag_uuid[i], data.api_register.p_name[i],
243 bta_ag_cb.profile[i].scn, data.api_register.features,
244 bta_ag_cb.profile[i].sdp_handle);
245 bta_sys_add_uuid(bta_ag_uuid[i]);
246 }
247 }
248 }
249 }
250
251 /*******************************************************************************
252 *
253 * Function bta_ag_del_records
254 *
255 * Description Delete SDP records for any registered services.
256 *
257 *
258 * Returns void
259 *
260 ******************************************************************************/
bta_ag_del_records(tBTA_AG_SCB * p_scb)261 void bta_ag_del_records(tBTA_AG_SCB* p_scb) {
262 tBTA_AG_SCB* p = &bta_ag_cb.scb[0];
263 tBTA_SERVICE_MASK services;
264 tBTA_SERVICE_MASK others = 0;
265 int i;
266
267 /* get services of all other registered servers */
268 for (i = 0; i < BTA_AG_NUM_IDX; i++, p++) {
269 if (p_scb == p) {
270 continue;
271 }
272
273 if (p->in_use && !p->dealloc) {
274 others |= p->reg_services;
275 }
276 }
277
278 others >>= BTA_HSP_SERVICE_ID;
279 services = p_scb->reg_services >> BTA_HSP_SERVICE_ID;
280 for (i = 0; i < BTA_AG_NUM_IDX && services != 0;
281 i++, services >>= 1, others >>= 1) {
282 /* if service registered for this scb and not registered for any other scb
283 */
284 if (((services & 1) == 1) && ((others & 1) == 0)) {
285 APPL_TRACE_DEBUG("bta_ag_del_records %d", i);
286 if (bta_ag_cb.profile[i].sdp_handle != 0) {
287 SDP_DeleteRecord(bta_ag_cb.profile[i].sdp_handle);
288 bta_ag_cb.profile[i].sdp_handle = 0;
289 }
290 BTM_FreeSCN(bta_ag_cb.profile[i].scn);
291 bta_sys_remove_uuid(bta_ag_uuid[i]);
292 }
293 }
294 }
295
296 /*******************************************************************************
297 *
298 * Function bta_ag_sdp_find_attr
299 *
300 * Description Process SDP discovery results to find requested attributes
301 * for requested service.
302 *
303 *
304 * Returns true if results found, false otherwise.
305 *
306 ******************************************************************************/
bta_ag_sdp_find_attr(tBTA_AG_SCB * p_scb,tBTA_SERVICE_MASK service)307 bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
308 tSDP_DISC_REC* p_rec = nullptr;
309 tSDP_DISC_ATTR* p_attr;
310 tSDP_PROTOCOL_ELEM pe;
311 uint16_t uuid;
312 bool result = false;
313
314 if (service & BTA_HFP_SERVICE_MASK) {
315 uuid = UUID_SERVCLASS_HF_HANDSFREE;
316 /* If there is no cached peer version, use default one */
317 if (p_scb->peer_version == HFP_HSP_VERSION_UNKNOWN) {
318 p_scb->peer_version = HFP_VERSION_1_1; /* Default version */
319 }
320 } else if (service & BTA_HSP_SERVICE_MASK && p_scb->role == BTA_AG_INT) {
321 uuid = UUID_SERVCLASS_HEADSET_HS;
322 p_scb->peer_version = HSP_VERSION_1_2; /* Default version */
323 } else {
324 uuid = UUID_SERVCLASS_HEADSET_HS;
325 p_scb->peer_version = HSP_VERSION_1_0;
326 }
327
328 /* loop through all records we found */
329 while (true) {
330 /* get next record; if none found, we're done */
331 p_rec = SDP_FindServiceInDb(p_scb->p_disc_db, uuid, p_rec);
332 if (p_rec == nullptr) {
333 if (uuid == UUID_SERVCLASS_HEADSET_HS) {
334 /* Search again in case the peer device uses the old HSP UUID */
335 uuid = UUID_SERVCLASS_HEADSET;
336 p_scb->peer_version = HSP_VERSION_1_0;
337 p_rec = SDP_FindServiceInDb(p_scb->p_disc_db, uuid, p_rec);
338 if (p_rec == nullptr) {
339 break;
340 }
341 } else
342 break;
343 }
344
345 /* get scn from proto desc list if initiator */
346 if (p_scb->role == BTA_AG_INT) {
347 if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
348 p_scb->peer_scn = (uint8_t)pe.params[0];
349 } else {
350 continue;
351 }
352 }
353
354 /* get profile version (if failure, version parameter is not updated) */
355 uint16_t peer_version = HFP_HSP_VERSION_UNKNOWN;
356 if (!SDP_FindProfileVersionInRec(p_rec, uuid, &peer_version)) {
357 APPL_TRACE_WARNING("%s: Get peer_version failed, using default 0x%04x",
358 __func__, p_scb->peer_version);
359 peer_version = p_scb->peer_version;
360 }
361
362 if (service & BTA_HFP_SERVICE_MASK) {
363 /* Update cached peer version if the new one is different */
364 if (peer_version != p_scb->peer_version) {
365 p_scb->peer_version = peer_version;
366 if (btif_config_set_bin(
367 p_scb->peer_addr.ToString(), HFP_VERSION_CONFIG_KEY,
368 (const uint8_t*)&peer_version, sizeof(peer_version))) {
369 } else {
370 APPL_TRACE_WARNING("%s: Failed to store peer HFP version for %s",
371 __func__,
372 ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
373 }
374 }
375 /* get features if HFP */
376 p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FEATURES);
377 if (p_attr != nullptr &&
378 SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UINT_DESC_TYPE &&
379 SDP_DISC_ATTR_LEN(p_attr->attr_len_type) >= 2) {
380 /* Found attribute. Get value. */
381 /* There might be race condition between SDP and BRSF. */
382 /* Do not update if we already received BRSF. */
383 uint16_t sdp_features = p_attr->attr_value.v.u16;
384 bool sdp_wbs_support = sdp_features & BTA_AG_FEAT_WBS_SUPPORT;
385 if (!p_scb->received_at_bac && sdp_wbs_support) {
386 // Workaround for misbehaving HFs (e.g. some Hyundai car kit) that:
387 // 1. Indicate WBS support in SDP and codec negotiation in BRSF
388 // 2. But do not send required AT+BAC command
389 // Will assume mSBC is enabled and try codec negotiation by default
390 p_scb->codec_updated = true;
391 p_scb->peer_codecs = BTM_SCO_CODEC_CVSD | BTM_SCO_CODEC_MSBC;
392 p_scb->sco_codec = UUID_CODEC_MSBC;
393 }
394 if (sdp_features != p_scb->peer_sdp_features) {
395 p_scb->peer_sdp_features = sdp_features;
396 if (btif_config_set_bin(
397 p_scb->peer_addr.ToString(), HFP_SDP_FEATURES_CONFIG_KEY,
398 (const uint8_t*)&sdp_features, sizeof(sdp_features))) {
399 } else {
400 APPL_TRACE_WARNING(
401 "%s: Failed to store peer HFP SDP Features for %s", __func__,
402 ADDRESS_TO_LOGGABLE_CSTR(p_scb->peer_addr));
403 }
404 }
405 if (p_scb->peer_features == 0) {
406 p_scb->peer_features = sdp_features & HFP_SDP_BRSF_FEATURES_MASK;
407 }
408 /* Remote supports 1.7, store it in HFP 1.7 BL file */
409 if (bluetooth::common::init_flags::hfp_dynamic_version_is_enabled()) {
410 if (p_scb->peer_version == HFP_VERSION_1_7) {
411 interop_database_add_addr(INTEROP_HFP_1_7_ALLOWLIST,
412 &p_scb->peer_addr, 3);
413 }
414 }
415 }
416 } else {
417 /* No peer version caching for HSP, use discovered one directly */
418 p_scb->peer_version = peer_version;
419 /* get features if HSP */
420 p_attr =
421 SDP_FindAttributeInRec(p_rec, ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL);
422 if (p_attr != nullptr &&
423 SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == BOOLEAN_DESC_TYPE &&
424 SDP_DISC_ATTR_LEN(p_attr->attr_len_type) >= 1) {
425 /* Remote volume control of HSP */
426 if (p_attr->attr_value.v.u8)
427 p_scb->peer_features |= BTA_AG_PEER_FEAT_VOL;
428 else
429 p_scb->peer_features &= ~BTA_AG_PEER_FEAT_VOL;
430 }
431 }
432
433 /* found what we needed */
434 result = true;
435 break;
436 }
437 return result;
438 }
439
440 /*******************************************************************************
441 *
442 * Function bta_ag_do_disc
443 *
444 * Description Do service discovery.
445 *
446 *
447 * Returns void
448 *
449 ******************************************************************************/
bta_ag_do_disc(tBTA_AG_SCB * p_scb,tBTA_SERVICE_MASK service)450 void bta_ag_do_disc(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
451 Uuid uuid_list[1];
452 uint16_t num_uuid = 1;
453 uint16_t attr_list[4];
454 uint8_t num_attr;
455
456 /* HFP initiator; get proto list and features */
457 if (service & BTA_HFP_SERVICE_MASK && p_scb->role == BTA_AG_INT) {
458 attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
459 attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
460 attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
461 attr_list[3] = ATTR_ID_SUPPORTED_FEATURES;
462 num_attr = 4;
463 uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HF_HANDSFREE);
464 }
465 /* HFP acceptor; get features */
466 else if (service & BTA_HFP_SERVICE_MASK && p_scb->role == BTA_AG_ACP) {
467 attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
468 attr_list[1] = ATTR_ID_BT_PROFILE_DESC_LIST;
469 attr_list[2] = ATTR_ID_SUPPORTED_FEATURES;
470 num_attr = 3;
471 uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HF_HANDSFREE);
472 }
473 /* HSP initiator; get proto list */
474 else if (service & BTA_HSP_SERVICE_MASK && p_scb->role == BTA_AG_INT) {
475 attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
476 attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
477 attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
478 attr_list[3] = ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL;
479 num_attr = 4;
480 // Although UUID_SERVCLASS_HEADSET_HS (0x1131) is to be used in HSP 1.2,
481 // some HSP 1.2 implementations, such as PTS, still use
482 // UUID_SERVCLASS_HEADSET (0x1108) to store its service record. However,
483 // most of such devices are HSP 1.0 devices.
484 if (p_scb->hsp_version >= HSP_VERSION_1_2) {
485 uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HEADSET_HS);
486 } else {
487 uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HEADSET);
488 }
489 } else {
490 /* HSP acceptor; get features */
491 attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
492 attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
493 attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
494 attr_list[3] = ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL;
495 num_attr = 4;
496
497 if (p_scb->hsp_version >= HSP_VERSION_1_2) {
498 uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HEADSET_HS);
499 } else {
500 /* Legacy from HSP v1.0 */
501 uuid_list[0] = Uuid::From16Bit(UUID_SERVCLASS_HEADSET);
502 }
503 }
504
505 if (p_scb->p_disc_db != nullptr) {
506 LOG_ERROR("Discovery already in progress... returning.");
507 return;
508 }
509
510 /* allocate buffer for sdp database */
511 p_scb->p_disc_db = (tSDP_DISCOVERY_DB*)osi_malloc(BTA_AG_DISC_BUF_SIZE);
512 /* set up service discovery database; attr happens to be attr_list len */
513 if (SDP_InitDiscoveryDb(p_scb->p_disc_db, BTA_AG_DISC_BUF_SIZE, num_uuid,
514 uuid_list, num_attr, attr_list)) {
515 if (SDP_ServiceSearchAttributeRequest(
516 p_scb->peer_addr, p_scb->p_disc_db,
517 bta_ag_sdp_cback_tbl[bta_ag_scb_to_idx(p_scb) - 1])) {
518 return;
519 } else {
520 LOG(ERROR) << __func__ << ": failed to start SDP discovery for "
521 << p_scb->peer_addr;
522 }
523 } else {
524 LOG(ERROR) << __func__ << ": failed to init SDP discovery database for "
525 << p_scb->peer_addr;
526 }
527 // Failure actions
528 bta_ag_free_db(p_scb, tBTA_AG_DATA::kEmpty);
529 bta_ag_sm_execute(p_scb, BTA_AG_DISC_FAIL_EVT, tBTA_AG_DATA::kEmpty);
530 }
531
532 /*******************************************************************************
533 *
534 * Function bta_ag_free_db
535 *
536 * Description Free discovery database.
537 *
538 *
539 * Returns void
540 *
541 ******************************************************************************/
bta_ag_free_db(tBTA_AG_SCB * p_scb,const tBTA_AG_DATA & data)542 void bta_ag_free_db(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
543 osi_free_and_reset((void**)&p_scb->p_disc_db);
544 }
545