Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40039193 authored by Chris Manton's avatar Chris Manton
Browse files

SDP API access

Bug: 267248792
Test: None
No-Typo-Check: legacy code

Change-Id: I978161fec2cc4fd5a88c7ad4b7a2350247232f82
parent 49ef1b54
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -40,8 +40,11 @@
#include "osi/include/osi.h"  // UNUSED_ATTR
#include "stack/include/l2c_api.h"
#include "stack/include/port_api.h"
#include "stack/include/sdp_api.h"
#include "types/raw_address.h"

using namespace bluetooth::legacy::stack::sdp;

/*****************************************************************************
 *  Constants
 ****************************************************************************/
@@ -880,7 +883,8 @@ void bta_ag_handle_collision(tBTA_AG_SCB* p_scb,
                             UNUSED_ATTR const tBTA_AG_DATA& data) {
  /* Cancel SDP if it had been started. */
  if (p_scb->p_disc_db) {
    SDP_CancelServiceSearch(p_scb->p_disc_db);
    get_legacy_stack_sdp_api()->service.SDP_CancelServiceSearch(
        p_scb->p_disc_db);
    bta_ag_free_db(p_scb, tBTA_AG_DATA::kEmpty);
  }

+36 −24
Original line number Diff line number Diff line
@@ -40,8 +40,10 @@
#include "stack/include/btm_api.h"
#include "stack/include/btu.h"  // do_in_main_thread
#include "stack/include/port_api.h"
#include "stack/include/sdp_api.h"
#include "types/bluetooth/uuid.h"

using namespace bluetooth::legacy::stack::sdp;
using bluetooth::Uuid;

/* Number of protocol elements in protocol element list. */
@@ -155,14 +157,14 @@ bool bta_ag_add_record(uint16_t service_uuid, const char* p_service_name,
  proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
  proto_elem_list[1].num_params = 1;
  proto_elem_list[1].params[0] = scn;
  result &=
      SDP_AddProtocolList(sdp_handle, BTA_AG_NUM_PROTO_ELEMS, proto_elem_list);
  result &= get_legacy_stack_sdp_api()->handle.SDP_AddProtocolList(
      sdp_handle, BTA_AG_NUM_PROTO_ELEMS, proto_elem_list);

  /* add service class id list */
  svc_class_id_list[0] = service_uuid;
  svc_class_id_list[1] = UUID_SERVCLASS_GENERIC_AUDIO;
  result &= SDP_AddServiceClassIdList(sdp_handle, BTA_AG_NUM_SVC_ELEMS,
                                      svc_class_id_list);
  result &= get_legacy_stack_sdp_api()->handle.SDP_AddServiceClassIdList(
      sdp_handle, BTA_AG_NUM_SVC_ELEMS, svc_class_id_list);

  /* add profile descriptor list */
  if (service_uuid == UUID_SERVCLASS_AG_HANDSFREE) {
@@ -176,11 +178,12 @@ bool bta_ag_add_record(uint16_t service_uuid, const char* p_service_name,
    profile_uuid = UUID_SERVCLASS_HEADSET;
    version = HSP_VERSION_1_2;
  }
  result &= SDP_AddProfileDescriptorList(sdp_handle, profile_uuid, version);
  result &= get_legacy_stack_sdp_api()->handle.SDP_AddProfileDescriptorList(
      sdp_handle, profile_uuid, version);

  /* add service name */
  if (p_service_name != nullptr && p_service_name[0] != 0) {
    result &= SDP_AddAttribute(
    result &= get_legacy_stack_sdp_api()->handle.SDP_AddAttribute(
        sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
        (uint32_t)(strlen(p_service_name) + 1), (uint8_t*)p_service_name);
  }
@@ -188,8 +191,9 @@ bool bta_ag_add_record(uint16_t service_uuid, const char* p_service_name,
  /* add features and network */
  if (service_uuid == UUID_SERVCLASS_AG_HANDSFREE) {
    network = (features & BTA_AG_FEAT_REJECT) ? 1 : 0;
    result &= SDP_AddAttribute(sdp_handle, ATTR_ID_DATA_STORES_OR_NETWORK,
                               UINT_DESC_TYPE, 1, &network);
    result &= get_legacy_stack_sdp_api()->handle.SDP_AddAttribute(
        sdp_handle, ATTR_ID_DATA_STORES_OR_NETWORK, UINT_DESC_TYPE, 1,
        &network);

    // check property for SWB support
    if (hfp_hal_interface::get_swb_supported()) {
@@ -206,13 +210,13 @@ bool bta_ag_add_record(uint16_t service_uuid, const char* p_service_name,
    if (swb_supported) features |= BTA_AG_FEAT_SWB_SUPPORT;

    UINT16_TO_BE_FIELD(buf, features);
    result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES,
                               UINT_DESC_TYPE, 2, buf);
    result &= get_legacy_stack_sdp_api()->handle.SDP_AddAttribute(
        sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, 2, buf);
  }

  /* add browse group list */
  result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1,
                                browse_list);
  result &= get_legacy_stack_sdp_api()->handle.SDP_AddUuidSequence(
      sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list);

  return result;
}
@@ -237,7 +241,8 @@ void bta_ag_create_records(tBTA_AG_SCB* p_scb, const tBTA_AG_DATA& data) {
    if (services & 1) {
      /* add sdp record if not already registered */
      if (bta_ag_cb.profile[i].sdp_handle == 0) {
        bta_ag_cb.profile[i].sdp_handle = SDP_CreateRecord();
        bta_ag_cb.profile[i].sdp_handle =
            get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
        bta_ag_cb.profile[i].scn = BTM_AllocateSCN();
        bta_ag_add_record(bta_ag_uuid[i], data.api_register.p_name[i],
                          bta_ag_cb.profile[i].scn, data.api_register.features,
@@ -284,7 +289,8 @@ void bta_ag_del_records(tBTA_AG_SCB* p_scb) {
    if (((services & 1) == 1) && ((others & 1) == 0)) {
      APPL_TRACE_DEBUG("bta_ag_del_records %d", i);
      if (bta_ag_cb.profile[i].sdp_handle != 0) {
        SDP_DeleteRecord(bta_ag_cb.profile[i].sdp_handle);
        get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(
            bta_ag_cb.profile[i].sdp_handle);
        bta_ag_cb.profile[i].sdp_handle = 0;
      }
      BTM_FreeSCN(bta_ag_cb.profile[i].scn);
@@ -328,13 +334,15 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
  /* loop through all records we found */
  while (true) {
    /* get next record; if none found, we're done */
    p_rec = SDP_FindServiceInDb(p_scb->p_disc_db, uuid, p_rec);
    p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(p_scb->p_disc_db,
                                                               uuid, p_rec);
    if (p_rec == nullptr) {
      if (uuid == UUID_SERVCLASS_HEADSET_HS) {
        /* Search again in case the peer device uses the old HSP UUID */
        uuid = UUID_SERVCLASS_HEADSET;
        p_scb->peer_version = HSP_VERSION_1_0;
        p_rec = SDP_FindServiceInDb(p_scb->p_disc_db, uuid, p_rec);
        p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
            p_scb->p_disc_db, uuid, p_rec);
        if (p_rec == nullptr) {
          break;
        }
@@ -344,7 +352,8 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {

    /* get scn from proto desc list if initiator */
    if (p_scb->role == BTA_AG_INT) {
      if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
      if (get_legacy_stack_sdp_api()->record.SDP_FindProtocolListElemInRec(
              p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
        p_scb->peer_scn = (uint8_t)pe.params[0];
      } else {
        continue;
@@ -353,7 +362,8 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {

    /* get profile version (if failure, version parameter is not updated) */
    uint16_t peer_version = HFP_HSP_VERSION_UNKNOWN;
    if (!SDP_FindProfileVersionInRec(p_rec, uuid, &peer_version)) {
    if (!get_legacy_stack_sdp_api()->record.SDP_FindProfileVersionInRec(
            p_rec, uuid, &peer_version)) {
      APPL_TRACE_WARNING("%s: Get peer_version failed, using default 0x%04x",
                         __func__, p_scb->peer_version);
      peer_version = p_scb->peer_version;
@@ -373,7 +383,8 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
        }
      }
      /* get features if HFP */
      p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FEATURES);
      p_attr = get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
          p_rec, ATTR_ID_SUPPORTED_FEATURES);
      if (p_attr != nullptr) {
        /* Found attribute. Get value. */
        /* There might be race condition between SDP and BRSF.  */
@@ -415,8 +426,8 @@ bool bta_ag_sdp_find_attr(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
      /* No peer version caching for HSP, use discovered one directly */
      p_scb->peer_version = peer_version;
      /* get features if HSP */
      p_attr =
          SDP_FindAttributeInRec(p_rec, ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL);
      p_attr = get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
          p_rec, ATTR_ID_REMOTE_AUDIO_VOLUME_CONTROL);
      if (p_attr != nullptr) {
        /* Remote volume control of HSP */
        if (p_attr->attr_value.v.u8)
@@ -506,9 +517,10 @@ void bta_ag_do_disc(tBTA_AG_SCB* p_scb, tBTA_SERVICE_MASK service) {
  /* allocate buffer for sdp database */
  p_scb->p_disc_db = (tSDP_DISCOVERY_DB*)osi_malloc(BTA_AG_DISC_BUF_SIZE);
  /* set up service discovery database; attr happens to be attr_list len */
  if (SDP_InitDiscoveryDb(p_scb->p_disc_db, BTA_AG_DISC_BUF_SIZE, num_uuid,
                          uuid_list, num_attr, attr_list)) {
    if (SDP_ServiceSearchAttributeRequest(
  if (get_legacy_stack_sdp_api()->service.SDP_InitDiscoveryDb(
          p_scb->p_disc_db, BTA_AG_DISC_BUF_SIZE, num_uuid, uuid_list, num_attr,
          attr_list)) {
    if (get_legacy_stack_sdp_api()->service.SDP_ServiceSearchAttributeRequest(
            p_scb->peer_addr, p_scb->p_disc_db,
            bta_ag_sdp_cback_tbl[bta_ag_scb_to_idx(p_scb) - 1])) {
      return;
+17 −8
Original line number Diff line number Diff line
@@ -28,8 +28,11 @@
#include "bta/sys/bta_sys.h"
#include "stack/include/avct_api.h"
#include "stack/include/avrc_api.h"
#include "stack/include/sdp_api.h"
#include "types/raw_address.h"

using namespace bluetooth::legacy::stack::sdp;

/* AV control block */
tBTA_AR_CB bta_ar_cb;

@@ -167,7 +170,8 @@ void bta_ar_reg_avrc(uint16_t service_uuid, const char* service_name,
  if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
    if (bta_ar_cb.sdp_tg_handle == 0) {
      bta_ar_cb.tg_registered = mask;
      bta_ar_cb.sdp_tg_handle = SDP_CreateRecord();
      bta_ar_cb.sdp_tg_handle =
          get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
      AVRC_AddRecord(service_uuid, service_name, provider_name, categories,
                     bta_ar_cb.sdp_tg_handle, browse_supported,
                     profile_version, 0);
@@ -180,7 +184,8 @@ void bta_ar_reg_avrc(uint16_t service_uuid, const char* service_name,
    bta_ar_cb.ct_categories[mask - 1] = categories;
    categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1];
    if (bta_ar_cb.sdp_ct_handle == 0) {
      bta_ar_cb.sdp_ct_handle = SDP_CreateRecord();
      bta_ar_cb.sdp_ct_handle =
          get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
      AVRC_AddRecord(service_uuid, service_name, provider_name, categories,
                     bta_ar_cb.sdp_ct_handle, browse_supported,
                     profile_version, 0);
@@ -190,8 +195,9 @@ void bta_ar_reg_avrc(uint16_t service_uuid, const char* service_name,
       * Change supported categories on the second one */
      p = temp;
      UINT16_TO_BE_STREAM(p, categories);
      SDP_AddAttribute(bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES,
                       UINT_DESC_TYPE, (uint32_t)2, (uint8_t*)temp);
      get_legacy_stack_sdp_api()->handle.SDP_AddAttribute(
          bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
          (uint32_t)2, (uint8_t*)temp);
    }
  }
}
@@ -214,7 +220,8 @@ void bta_ar_dereg_avrc(uint16_t service_uuid) {
  if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
    if (bta_ar_cb.sdp_tg_handle && mask == bta_ar_cb.tg_registered) {
      bta_ar_cb.tg_registered = 0;
      SDP_DeleteRecord(bta_ar_cb.sdp_tg_handle);
      get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(
          bta_ar_cb.sdp_tg_handle);
      bta_ar_cb.sdp_tg_handle = 0;
      bta_sys_remove_uuid(service_uuid);
    }
@@ -224,15 +231,17 @@ void bta_ar_dereg_avrc(uint16_t service_uuid) {
      categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1];
      if (!categories) {
        /* no CT is still registered - cleaup */
        SDP_DeleteRecord(bta_ar_cb.sdp_ct_handle);
        get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(
            bta_ar_cb.sdp_ct_handle);
        bta_ar_cb.sdp_ct_handle = 0;
        bta_sys_remove_uuid(service_uuid);
      } else {
        /* change supported categories to the remaning one */
        p = temp;
        UINT16_TO_BE_STREAM(p, categories);
        SDP_AddAttribute(bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES,
                         UINT_DESC_TYPE, (uint32_t)2, (uint8_t*)temp);
        get_legacy_stack_sdp_api()->handle.SDP_AddAttribute(
            bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
            (uint32_t)2, (uint8_t*)temp);
      }
    }
  }
+55 −43
Original line number Diff line number Diff line
@@ -40,8 +40,11 @@
#include "stack/include/acl_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/l2c_api.h"
#include "stack/include/sdp_api.h"
#include "types/raw_address.h"

using namespace bluetooth::legacy::stack::sdp;

/*****************************************************************************
 *  Constants
 ****************************************************************************/
@@ -169,7 +172,7 @@ static void bta_av_close_all_rc(tBTA_AV_CB* p_cb) {
 ******************************************************************************/
static void bta_av_del_sdp_rec(uint32_t* p_sdp_handle) {
  if (*p_sdp_handle != 0) {
    SDP_DeleteRecord(*p_sdp_handle);
    get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(*p_sdp_handle);
    *p_sdp_handle = 0;
  }
}
@@ -1661,12 +1664,13 @@ static void bta_av_store_peer_rc_version() {
  tSDP_DISC_REC* p_rec = NULL;
  uint16_t peer_rc_version = 0; /*Assuming Default peer version as 1.3*/

  if ((p_rec = SDP_FindServiceInDb(
  if ((p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
           p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL)) != NULL) {
    if ((SDP_FindAttributeInRec(p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
    if ((get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
      /* get profile version (if failure, version parameter is not updated) */
      SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL,
                                  &peer_rc_version);
      get_legacy_stack_sdp_api()->record.SDP_FindProfileVersionInRec(
          p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL, &peer_rc_version);
    }
    if (peer_rc_version != 0)
      DEVICE_IOT_CONFIG_ADDR_SET_HEX_IF_GREATER(
@@ -1675,12 +1679,13 @@ static void bta_av_store_peer_rc_version() {
  }

  peer_rc_version = 0;
  if ((p_rec = SDP_FindServiceInDb(
  if ((p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
           p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL)) != NULL) {
    if ((SDP_FindAttributeInRec(p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
    if ((get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
      /* get profile version (if failure, version parameter is not updated) */
      SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL,
                                  &peer_rc_version);
      get_legacy_stack_sdp_api()->record.SDP_FindProfileVersionInRec(
          p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL, &peer_rc_version);
    }
    if (peer_rc_version != 0)
      DEVICE_IOT_CONFIG_ADDR_SET_HEX_IF_GREATER(
@@ -1711,28 +1716,30 @@ tBTA_AV_FEAT bta_av_check_peer_features(uint16_t service_uuid) {
  /* loop through all records we found */
  while (true) {
    /* get next record; if none found, we're done */
    p_rec = SDP_FindServiceInDb(p_cb->p_disc_db, service_uuid, p_rec);
    p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
        p_cb->p_disc_db, service_uuid, p_rec);
    if (p_rec == NULL) {
      break;
    }

    if ((SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_CLASS_ID_LIST)) !=
        NULL) {
    if ((get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_SERVICE_CLASS_ID_LIST)) != NULL) {
      /* find peer features */
      if (SDP_FindServiceInDb(p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL,
                              NULL)) {
      if (get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
              p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL)) {
        peer_features |= BTA_AV_FEAT_RCCT;
      }
      if (SDP_FindServiceInDb(p_cb->p_disc_db,
                              UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL)) {
      if (get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
              p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL)) {
        peer_features |= BTA_AV_FEAT_RCTG;
      }
    }

    if ((SDP_FindAttributeInRec(p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
    if ((get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
      /* get profile version (if failure, version parameter is not updated) */
      SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL,
                                  &peer_rc_version);
      get_legacy_stack_sdp_api()->record.SDP_FindProfileVersionInRec(
          p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL, &peer_rc_version);
      APPL_TRACE_DEBUG("%s: peer_rc_version 0x%x", __func__, peer_rc_version);

      if (peer_rc_version >= AVRC_REV_1_3)
@@ -1740,7 +1747,8 @@ tBTA_AV_FEAT bta_av_check_peer_features(uint16_t service_uuid) {

      if (peer_rc_version >= AVRC_REV_1_4) {
        /* get supported categories */
        p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FEATURES);
        p_attr = get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_SUPPORTED_FEATURES);
        if (p_attr != NULL) {
          categories = p_attr->attr_value.v.u16;
          if (categories & AVRC_SUPF_CT_CAT2)
@@ -1772,29 +1780,30 @@ tBTA_AV_FEAT bta_avk_check_peer_features(uint16_t service_uuid) {
  APPL_TRACE_DEBUG("%s: service_uuid:x%x", __func__, service_uuid);

  /* loop through all records we found */
  tSDP_DISC_REC* p_rec =
      SDP_FindServiceInDb(p_cb->p_disc_db, service_uuid, NULL);
  tSDP_DISC_REC* p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
      p_cb->p_disc_db, service_uuid, NULL);
  while (p_rec) {
    APPL_TRACE_DEBUG("%s: found Service record for x%x", __func__,
                     service_uuid);

    if ((SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_CLASS_ID_LIST)) !=
        NULL) {
    if ((get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_SERVICE_CLASS_ID_LIST)) != NULL) {
      /* find peer features */
      if (SDP_FindServiceInDb(p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL,
                              NULL)) {
      if (get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
              p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL)) {
        peer_features |= BTA_AV_FEAT_RCCT;
      }
      if (SDP_FindServiceInDb(p_cb->p_disc_db,
                              UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL)) {
      if (get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
              p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL)) {
        peer_features |= BTA_AV_FEAT_RCTG;
      }
    }

    if ((SDP_FindAttributeInRec(p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
    if ((get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_BT_PROFILE_DESC_LIST)) != NULL) {
      /* get profile version (if failure, version parameter is not updated) */
      uint16_t peer_rc_version = 0;
      bool val = SDP_FindProfileVersionInRec(
      bool val = get_legacy_stack_sdp_api()->record.SDP_FindProfileVersionInRec(
          p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL, &peer_rc_version);
      APPL_TRACE_DEBUG("%s: peer_rc_version for TG 0x%x, profile_found %d",
                       __func__, peer_rc_version, val);
@@ -1804,7 +1813,8 @@ tBTA_AV_FEAT bta_avk_check_peer_features(uint16_t service_uuid) {

      /* Get supported features */
      tSDP_DISC_ATTR* p_attr =
          SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FEATURES);
          get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
              p_rec, ATTR_ID_SUPPORTED_FEATURES);
      if (p_attr != NULL) {
        uint16_t categories = p_attr->attr_value.v.u16;
        /*
@@ -1831,7 +1841,8 @@ tBTA_AV_FEAT bta_avk_check_peer_features(uint16_t service_uuid) {
      }
    }
    /* get next record; if none found, we're done */
    p_rec = SDP_FindServiceInDb(p_cb->p_disc_db, service_uuid, p_rec);
    p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
        p_cb->p_disc_db, service_uuid, p_rec);
  }
  APPL_TRACE_DEBUG("%s: peer_features:x%x", __func__, peer_features);
  return peer_features;
@@ -1852,12 +1863,12 @@ uint16_t bta_avk_get_cover_art_psm() {
  APPL_TRACE_DEBUG("%s: searching for cover art psm", __func__);
  /* Cover Art L2CAP PSM is only available on a target device */
  tBTA_AV_CB* p_cb = &bta_av_cb;
  tSDP_DISC_REC* p_rec =
      SDP_FindServiceInDb(p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET,
          NULL);
  tSDP_DISC_REC* p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
      p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET, NULL);
  while (p_rec) {
    tSDP_DISC_ATTR* p_attr =
        (SDP_FindAttributeInRec(p_rec, ATTR_ID_ADDITION_PROTO_DESC_LISTS));
        (get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_ADDITION_PROTO_DESC_LISTS));
    /*
     * If we have the Additional Protocol Description Lists attribute then we
     * specifically want the list that is an L2CAP protocol leading to OBEX.
@@ -1931,8 +1942,8 @@ uint16_t bta_avk_get_cover_art_psm() {
      }
    }
    /* get next record; if none found, we're done */
    p_rec = SDP_FindServiceInDb(p_cb->p_disc_db,
        UUID_SERVCLASS_AV_REM_CTRL_TARGET, p_rec);
    p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
        p_cb->p_disc_db, UUID_SERVCLASS_AV_REM_CTRL_TARGET, p_rec);
  }
  /* L2CAP PSM range is 0x1000-0xFFFF so 0x0000 is safe default invalid */
  APPL_TRACE_DEBUG("%s: could not find a BIP psm", __func__);
@@ -2009,14 +2020,15 @@ void bta_av_rc_disc_done(UNUSED_ATTR tBTA_AV_DATA* p_data) {

    /* Change our features if the remote AVRCP version is 1.3 or less */
    tSDP_DISC_REC* p_rec = nullptr;
    p_rec = SDP_FindServiceInDb(p_cb->p_disc_db,
                                UUID_SERVCLASS_AV_REMOTE_CONTROL, p_rec);
    p_rec = get_legacy_stack_sdp_api()->db.SDP_FindServiceInDb(
        p_cb->p_disc_db, UUID_SERVCLASS_AV_REMOTE_CONTROL, p_rec);
    if (p_rec != NULL &&
        SDP_FindAttributeInRec(p_rec, ATTR_ID_BT_PROFILE_DESC_LIST) != NULL) {
        get_legacy_stack_sdp_api()->record.SDP_FindAttributeInRec(
            p_rec, ATTR_ID_BT_PROFILE_DESC_LIST) != NULL) {
      /* get profile version (if failure, version parameter is not updated) */
      uint16_t peer_rc_version = 0xFFFF;  // Don't change the AVRCP version
      SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL,
                                  &peer_rc_version);
      get_legacy_stack_sdp_api()->record.SDP_FindProfileVersionInRec(
          p_rec, UUID_SERVCLASS_AV_REMOTE_CONTROL, &peer_rc_version);
      if (peer_rc_version <= AVRC_REV_1_3) {
        APPL_TRACE_DEBUG("%s: Using AVRCP 1.3 Capabilities with remote device",
                         __func__);
+12 −5
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@

#define LOG_TAG "bt_bta_av"

#include <base/logging.h>

#include <cstdint>

#include "bt_target.h"  // Must be first to define build configuration
@@ -41,10 +43,11 @@
#include "stack/include/acl_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/btm_api.h"
#include "stack/include/sdp_api.h"
#include "types/hci_role.h"
#include "types/raw_address.h"

#include <base/logging.h>
using namespace bluetooth::legacy::stack::sdp;

/*****************************************************************************
 * Constants and types
@@ -143,11 +146,13 @@ static void bta_av_api_enable(tBTA_AV_DATA* p_data) {
      return;
    }
    if (bta_av_cb.sdp_a2dp_handle) {
      SDP_DeleteRecord(bta_av_cb.sdp_a2dp_handle);
      get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(
          bta_av_cb.sdp_a2dp_handle);
      bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
    }
    if (bta_av_cb.sdp_a2dp_snk_handle) {
      SDP_DeleteRecord(bta_av_cb.sdp_a2dp_snk_handle);
      get_legacy_stack_sdp_api()->handle.SDP_DeleteRecord(
          bta_av_cb.sdp_a2dp_snk_handle);
      bta_sys_remove_uuid(UUID_SERVCLASS_AUDIO_SINK);
    }
    // deregister from AVDT
@@ -607,12 +612,14 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) {
      bta_av_cb.sdp_a2dp_snk_handle = 0;
      if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE) {
        /* create the SDP records on the 1st audio channel */
        bta_av_cb.sdp_a2dp_handle = SDP_CreateRecord();
        bta_av_cb.sdp_a2dp_handle =
            get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
        A2DP_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL,
                       A2DP_SUPF_PLAYER, bta_av_cb.sdp_a2dp_handle);
        bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
      } else if (profile_initialized == UUID_SERVCLASS_AUDIO_SINK) {
        bta_av_cb.sdp_a2dp_snk_handle = SDP_CreateRecord();
        bta_av_cb.sdp_a2dp_snk_handle =
            get_legacy_stack_sdp_api()->handle.SDP_CreateRecord();
        A2DP_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_service_name, NULL,
                       A2DP_SUPF_PLAYER, bta_av_cb.sdp_a2dp_snk_handle);
        bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
Loading