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

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

Add a path to add the PSM of the BIP OBEX server to the SDP record

Tag: #feature
Bug: 153076316
Test: Build, flash, make sure everything still works as no one is using
this code path yet

Change-Id: I672be8c341c453f862a50a9b3cfb4150b9588b2e
parent b1b939d1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ void bta_ar_reg_avrc(uint16_t service_uuid, const char* service_name,
      bta_ar_cb.sdp_tg_handle = SDP_CreateRecord();
      AVRC_AddRecord(service_uuid, service_name, provider_name, categories,
                     bta_ar_cb.sdp_tg_handle, browse_supported,
                     profile_version);
                     profile_version, 0);
      bta_sys_add_uuid(service_uuid);
    }
    /* only one TG is allowed (first-come, first-served).
@@ -180,7 +180,7 @@ void bta_ar_reg_avrc(uint16_t service_uuid, const char* service_name,
      bta_ar_cb.sdp_ct_handle = SDP_CreateRecord();
      AVRC_AddRecord(service_uuid, service_name, provider_name, categories,
                     bta_ar_cb.sdp_ct_handle, browse_supported,
                     profile_version);
                     profile_version, 0);
      bta_sys_add_uuid(service_uuid);
    } else {
      /* multiple CTs are allowed.
+42 −3
Original line number Diff line number Diff line
@@ -68,10 +68,11 @@ class AvrcpInterfaceImpl : public AvrcpInterface {
  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,
                     uint16_t profile_version) override {
                     uint16_t profile_version,
                     uint16_t cover_art_psm) override {
    return AVRC_AddRecord(service_uuid, p_service_name, p_provider_name,
                          categories, sdp_handle, browse_supported,
                          profile_version);
                          profile_version, cover_art_psm);
  }

  uint16_t RemoveRecord(uint32_t sdp_handle) {
@@ -304,7 +305,7 @@ void AvrcpService::Init(MediaInterface* media_interface,
  avrcp_interface_.AddRecord(UUID_SERVCLASS_AV_REM_CTRL_TARGET,
                             "AV Remote Control Target", NULL,
                             supported_features, sdp_record_handle, true,
                             profile_version);
                             profile_version, 0);
  btif_dm_add_uuid_to_eir(UUID_SERVCLASS_AV_REM_CTRL_TARGET);

  media_interface_ = new MediaInterfaceWrapper(media_interface);
@@ -352,6 +353,30 @@ void AvrcpService::Cleanup() {
  delete media_interface_;
}

void AvrcpService::RegisterBipServer(int psm) {
  LOG(INFO) << "AVRCP Target Service has registered a BIP OBEX server, psm="
            << psm;
  avrcp_interface_.RemoveRecord(sdp_record_handle);
  uint16_t supported_features
      = GetSupportedFeatures(profile_version) | AVRC_SUPF_TG_PLAYER_COVER_ART;
  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, psm);
}

void AvrcpService::UnregisterBipServer() {
  LOG(INFO) << "AVRCP Target Service has unregistered a BIP OBEX server";
  avrcp_interface_.RemoveRecord(sdp_record_handle);
  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, 0);
}

AvrcpService* AvrcpService::Get() {
  CHECK(instance_);
  return instance_;
@@ -443,6 +468,20 @@ void AvrcpService::ServiceInterfaceImpl::Init(
                               media_interface, volume_interface));
}

void AvrcpService::ServiceInterfaceImpl::RegisterBipServer(int psm) {
  std::lock_guard<std::mutex> lock(service_interface_lock_);
  CHECK(instance_ != nullptr);
  do_in_main_thread(FROM_HERE, base::Bind(&AvrcpService::RegisterBipServer,
                                          base::Unretained(instance_), psm));
}

void AvrcpService::ServiceInterfaceImpl::UnregisterBipServer() {
  std::lock_guard<std::mutex> lock(service_interface_lock_);
  CHECK(instance_ != nullptr);
  do_in_main_thread(FROM_HERE, base::Bind(&AvrcpService::UnregisterBipServer,
                                          base::Unretained(instance_)));
}

bool AvrcpService::ServiceInterfaceImpl::ConnectDevice(
    const RawAddress& bdaddr) {
  std::lock_guard<std::mutex> lock(service_interface_lock_);
+5 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ class AvrcpService : public MediaCallbacks {
  void Init(MediaInterface* media_interface, VolumeInterface* volume_interface);
  void Cleanup();

  void RegisterBipServer(int psm);
  void UnregisterBipServer();

  void ConnectDevice(const RawAddress& bdaddr);
  void DisconnectDevice(const RawAddress& bdaddr);

@@ -70,6 +73,8 @@ class AvrcpService : public MediaCallbacks {
   public:
    void Init(MediaInterface* media_interface,
              VolumeInterface* volume_interface) override;
    void RegisterBipServer(int psm) override;
    void UnregisterBipServer() override;
    bool ConnectDevice(const RawAddress& bdaddr) override;
    bool DisconnectDevice(const RawAddress& bdaddr) override;
    bool Cleanup() override;
+3 −1
Original line number Diff line number Diff line
@@ -176,6 +176,8 @@ class ServiceInterface {
  // Volume is disabled.
  virtual void Init(MediaInterface* mediaInterface,
                    VolumeInterface* volumeInterface) = 0;
  virtual void RegisterBipServer(int psm) = 0;
  virtual void UnregisterBipServer() = 0;
  virtual bool ConnectDevice(const RawAddress& bdaddr) = 0;
  virtual bool DisconnectDevice(const RawAddress& bdaddr) = 0;
  virtual bool Cleanup() = 0;
+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ class AvrcpInterface {
  virtual 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,
                             uint16_t profile_version) = 0;
                             uint16_t profile_version,
                             uint16_t cover_art_psm) = 0;

  virtual uint16_t RemoveRecord(uint32_t sdp_handle) = 0;

Loading