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

Commit b1b939d1 authored by Sal Savage's avatar Sal Savage
Browse files

Allow NewAvrcp to manage its own SDP record

Tag: #feature
Bug: 153076316
Test: Build, flash, make sure SDP record matches existing SDP record
Change-Id: Ic5add2091d8e72386dc22811e7e580fd64a278f7
parent 0cf0528e
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -2262,7 +2262,17 @@ void bta_av_dereg_comp(tBTA_AV_DATA* p_data) {

    /* remove the A2DP SDP record, if no more audio stream is left */
    if (!p_cb->reg_audio) {

      /* Only remove the SDP record if we're the ones that created it */
      if (is_new_avrcp_enabled()) {
        APPL_TRACE_DEBUG("%s: newavrcp is the owner of the AVRCP Target SDP "
            "record. Don't dereg the SDP record", __func__);
      } else {
        APPL_TRACE_DEBUG("%s: newavrcp is not enabled. Remove SDP record",
            __func__);
        bta_ar_dereg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL);
      }

      if (p_cb->sdp_a2dp_handle) {
        bta_av_del_sdp_rec(&p_cb->sdp_a2dp_handle);
        p_cb->sdp_a2dp_handle = 0;
+25 −17
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#include "osi/include/osi.h"
#include "osi/include/properties.h"

#include "avrcp_service.h"
#include "bta_av_co.h"
#include "bta_av_int.h"
#include "btif/include/btif_av_co.h"
@@ -477,8 +478,14 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) {
        /* For the Audio Sink role we support additional TG to support
         * absolute volume.
         */
        uint16_t profile_version = AVRC_REV_1_0;
        if (is_new_avrcp_enabled()) {
          APPL_TRACE_DEBUG("%s: newavrcp is the owner of the AVRCP Target SDP "
              "record. Don't create the SDP record", __func__);
        } else {
          APPL_TRACE_DEBUG("%s: newavrcp is not enabled. Create SDP record",
              __func__);

          uint16_t profile_version = AVRC_REV_1_0;
          if (!strncmp(AVRCP_1_6_STRING, avrcp_version,
                      sizeof(AVRCP_1_6_STRING))) {
            profile_version = AVRC_REV_1_6;
@@ -497,6 +504,7 @@ static void bta_av_api_register(tBTA_AV_DATA* p_data) {
              p_bta_av_cfg->avrc_tg_cat,
              (bta_av_cb.features & BTA_AV_FEAT_BROWSE), profile_version);
        }
      }

      /* Set the Capturing service class bit */
      if (profile_initialized == UUID_SERVCLASS_AUDIO_SOURCE)
+34 −0
Original line number Diff line number Diff line
@@ -299,6 +299,40 @@ void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
  }
}

/*******************************************************************************
 *
 * Function         BTA_AddEirUuid
 *
 * Description      Request to add a service class UID to the local
 *                  device's EIR data.
 *
 * Parameters       uuid16 - The service class UUID you wish to add
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_AddEirUuid(uint16_t uuid16) {
  APPL_TRACE_API("%s: %d", __func__, uuid16);
  bta_sys_add_uuid(uuid16);
}

/*******************************************************************************
 *
 * Function         BTA_RemoveEirUuid
 *
 * Description      Request to remove a service class UID from the local
 *                  device's EIR data.
 *
 * Parameters       uuid16 - The service class UUID you wish to remove
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_RemoveEirUuid(uint16_t uuid16) {
  APPL_TRACE_API("%s: %d", __func__, uuid16);
  bta_sys_remove_uuid(uuid16);
}

/*******************************************************************************
 *
 * Function         BTA_DmGetConnectionState
+28 −0
Original line number Diff line number Diff line
@@ -838,6 +838,34 @@ extern tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr);
extern void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
                              tBTA_SERVICE_MASK* p_services);

/*******************************************************************************
 *
 * Function         BTA_AddEirUuid
 *
 * Description      Request to add a new service class UUID to the local
 *                  device's EIR data.
 *
 * Parameters       uuid16 - The service class UUID you wish to add
 *
 * Returns          void
 *
 ******************************************************************************/
extern void BTA_AddEirUuid(uint16_t uuid16);

/*******************************************************************************
 *
 * Function         BTA_RemoveEirUuid
 *
 * Description      Request to remove a service class UID from the local
 *                  device's EIR data.
 *
 * Parameters       uuid16 - The service class UUID you wish to remove
 *
 * Returns          void
 *
 ******************************************************************************/
extern void BTA_RemoveEirUuid(uint16_t uuid16);

/*******************************************************************************
 *
 * Function         BTA_DmGetConnectionState
+37 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <sstream>

#include "btif_av.h"
#include "btif_dm.h"
#include "btif_common.h"
#include "device.h"
#include "stack/include/btu.h"
@@ -60,6 +61,10 @@ class A2dpInterfaceImpl : public A2dpInterface {

class AvrcpInterfaceImpl : public AvrcpInterface {
 public:
  uint16_t GetAvrcpVersion() {
    return AVRC_GetProfileVersion();
  }

  uint16_t AddRecord(uint16_t service_uuid, const char* p_service_name,
                     const char* p_provider_name, uint16_t categories,
                     uint32_t sdp_handle, bool browse_supported,
@@ -69,6 +74,10 @@ class AvrcpInterfaceImpl : public AvrcpInterface {
                          profile_version);
  }

  uint16_t RemoveRecord(uint32_t sdp_handle) {
    return AVRC_RemoveRecord(sdp_handle);
  }

  uint16_t FindService(uint16_t service_uuid, const RawAddress& bd_addr,
                       tAVRC_SDP_DB_PARAMS* p_db,
                       tAVRC_FIND_CBACK p_cback) override {
@@ -287,8 +296,16 @@ void AvrcpService::Init(MediaInterface* media_interface,
                        VolumeInterface* volume_interface) {
  LOG(INFO) << "AVRCP Target Service started";

  // TODO (apanicke): Add a function that sets up the SDP records once we
  // remove the AVRCP SDP setup in AVDTP (bta_av_main.cc)
  profile_version = avrcp_interface_.GetAvrcpVersion();

  uint16_t supported_features = GetSupportedFeatures(profile_version);
  sdp_record_handle = SDP_CreateRecord();

  avrcp_interface_.AddRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET,
                             "AV Remote Control Target", NULL,
                             supported_features, sdp_record_handle, true,
                             profile_version);
  btif_dm_add_uuid_to_eir(UUID_SERVCLASS_AV_REM_CTRL_TARGET);

  media_interface_ = new MediaInterfaceWrapper(media_interface);
  media_interface->RegisterUpdateCallback(instance_);
@@ -306,9 +323,27 @@ void AvrcpService::Init(MediaInterface* media_interface,
  connection_handler_ = ConnectionHandler::Get();
}

uint16_t AvrcpService::GetSupportedFeatures(uint16_t profile_version) {
  switch (profile_version) {
    case AVRC_REV_1_6:
      return AVRCP_SUPF_TG_1_6;
    case AVRC_REV_1_5:
      return AVRCP_SUPF_TG_1_5;
    case AVRC_REV_1_4:
      return AVRCP_SUPF_TG_1_4;
    case AVRC_REV_1_3:
      return AVRCP_SUPF_TG_1_3;
  }
  return AVRCP_SUPF_TG_DEFAULT;
}

void AvrcpService::Cleanup() {
  LOG(INFO) << "AVRCP Target Service stopped";

  avrcp_interface_.RemoveRecord(sdp_record_handle);
  btif_dm_remove_uuid_from_eir(UUID_SERVCLASS_AV_REM_CTRL_TARGET);
  sdp_record_handle = -1;

  connection_handler_->CleanUp();
  connection_handler_ = nullptr;
  if (volume_interface_ != nullptr) {
Loading