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

Commit 9387872d authored by Ted Wang's avatar Ted Wang Committed by Gerrit Code Review
Browse files

Merge "Fix "Disable Absolute Volume" Bluetooth developer option"

parents 72a7366b a7fd72e6
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@
cc_library_static {
cc_library_static {
    name: "libbtdevice",
    name: "libbtdevice",
    defaults: ["fluoride_defaults"],
    defaults: ["fluoride_defaults"],
    host_supported: true,
    local_include_dirs: [
    local_include_dirs: [
        "include",
        "include",
    ],
    ],
+3 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,9 @@ cc_test {
        "libgmock",
        "libgmock",
        "lib-bt-packets",
        "lib-bt-packets",
        "libosi",
        "libosi",
        "liblog",
        "libcutils",
        "libbtdevice",
        "avrcp-target-service",
        "avrcp-target-service",
    ],
    ],
    sanitize: {
    sanitize: {
+22 −2
Original line number Original line Diff line number Diff line
@@ -28,7 +28,9 @@
// TODO (apanicke): Remove dependency on this header once we cleanup feature
// TODO (apanicke): Remove dependency on this header once we cleanup feature
// handling.
// handling.
#include "bta/include/bta_av_api.h"
#include "bta/include/bta_av_api.h"
#include "device/include/interop.h"
#include "osi/include/allocator.h"
#include "osi/include/allocator.h"
#include "osi/include/properties.h"


namespace bluetooth {
namespace bluetooth {
namespace avrcp {
namespace avrcp {
@@ -41,6 +43,20 @@ ConnectionHandler* ConnectionHandler::Get() {
  return instance_;
  return instance_;
}
}


bool IsAbsoluteVolumeEnabled(const RawAddress* bdaddr) {
  char volume_disabled[PROPERTY_VALUE_MAX] = {0};
  osi_property_get("persist.bluetooth.disableabsvol", volume_disabled, "false");
  if (strncmp(volume_disabled, "true", 4) == 0) {
    LOG(INFO) << "Absolute volume disabled by property";
    return false;
  }
  if (interop_match_addr(INTEROP_DISABLE_ABSOLUTE_VOLUME, bdaddr)) {
    LOG(INFO) << "Absolute volume disabled by IOP table";
    return false;
  }
  return true;
}

bool ConnectionHandler::Initialize(const ConnectionCallback& callback,
bool ConnectionHandler::Initialize(const ConnectionCallback& callback,
                                   AvrcpInterface* avrcp, SdpInterface* sdp,
                                   AvrcpInterface* avrcp, SdpInterface* sdp,
                                   VolumeInterface* vol) {
                                   VolumeInterface* vol) {
@@ -429,8 +445,10 @@ void ConnectionHandler::SdpCb(const RawAddress& bdaddr, SdpCallback cb,
          if (categories & AVRC_SUPF_CT_CAT2) {
          if (categories & AVRC_SUPF_CT_CAT2) {
            LOG(INFO) << __PRETTY_FUNCTION__ << ": Device " << bdaddr.ToString()
            LOG(INFO) << __PRETTY_FUNCTION__ << ": Device " << bdaddr.ToString()
                      << " supports advanced control";
                      << " supports advanced control";
            if (IsAbsoluteVolumeEnabled(&bdaddr)) {
              peer_features |= (BTA_AV_FEAT_ADV_CTRL);
              peer_features |= (BTA_AV_FEAT_ADV_CTRL);
            }
            }
          }
          if (categories & AVRC_SUPF_CT_BROWSE) {
          if (categories & AVRC_SUPF_CT_BROWSE) {
            LOG(INFO) << __PRETTY_FUNCTION__ << ": Device " << bdaddr.ToString()
            LOG(INFO) << __PRETTY_FUNCTION__ << ": Device " << bdaddr.ToString()
                      << " supports browsing";
                      << " supports browsing";
@@ -468,12 +486,14 @@ void ConnectionHandler::SdpCb(const RawAddress& bdaddr, SdpCallback cb,
          if (categories & AVRC_SUPF_CT_CAT2) {
          if (categories & AVRC_SUPF_CT_CAT2) {
            LOG(INFO) << __PRETTY_FUNCTION__ << ": Device " << bdaddr.ToString()
            LOG(INFO) << __PRETTY_FUNCTION__ << ": Device " << bdaddr.ToString()
                      << " supports advanced control";
                      << " supports advanced control";
            if (IsAbsoluteVolumeEnabled(&bdaddr)) {
              peer_features |= (BTA_AV_FEAT_ADV_CTRL);
              peer_features |= (BTA_AV_FEAT_ADV_CTRL);
            }
            }
          }
          }
        }
        }
      }
      }
    }
    }
  }


  osi_free(disc_db);
  osi_free(disc_db);