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

Commit d7579a25 authored by Myles Watson's avatar Myles Watson Committed by Automerger Merge Worker
Browse files

Merge "audio_hal_interface: Remove flag defines" into main am: 3cd97042

parents 7ed106c9 3cd97042
Loading
Loading
Loading
Loading
+0 −45
Original line number Diff line number Diff line
@@ -40,8 +40,6 @@ static const std::string kDefaultAudioProviderFactoryInterface =
std::unique_ptr<HalVersionManager> HalVersionManager::instance_ptr =
    std::make_unique<HalVersionManager>();

#if COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

std::string toString(BluetoothAudioHalTransport transport) {
  switch (transport) {
    case BluetoothAudioHalTransport::UNKNOWN:
@@ -104,49 +102,6 @@ BluetoothAudioHalTransport HalVersionManager::GetHalTransport() {
  return instance_ptr->hal_version_.getTransport();
}

#else  // COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

BluetoothAudioHalTransport HalVersionManager::GetHalTransport() {
  return instance_ptr->hal_transport_;
}

BluetoothAudioHalVersion GetAidlInterfaceVersion() {
  int aidl_version = 0;

  auto provider_factory = IBluetoothAudioProviderFactory::fromBinder(
      ::ndk::SpAIBinder(AServiceManager_waitForService(
          kDefaultAudioProviderFactoryInterface.c_str())));

  if (provider_factory == nullptr) {
    LOG_ERROR("Can't get aidl version from unknown factory");
    return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
  }

  auto aidl_retval = provider_factory->getInterfaceVersion(&aidl_version);
  if (!aidl_retval.isOk()) {
    LOG_ERROR("BluetoothAudioHal::getInterfaceVersion failure: %s",
              aidl_retval.getDescription().c_str());
    return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
  }

  switch (aidl_version) {
    case 1:
      return BluetoothAudioHalVersion::VERSION_AIDL_V1;
    case 2:
      return BluetoothAudioHalVersion::VERSION_AIDL_V2;
    case 3:
      return BluetoothAudioHalVersion::VERSION_AIDL_V3;
    case 4:
      return BluetoothAudioHalVersion::VERSION_AIDL_V4;
    default:
      LOG_ERROR("Unknown AIDL version %d", aidl_version);
      return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
  }
  return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
}

#endif  // COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

BluetoothAudioHalVersion HalVersionManager::GetHalVersion() {
  std::lock_guard<std::mutex> guard(instance_ptr->mutex_);
  return instance_ptr->hal_version_;
+0 −22
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ constexpr char kFullyQualifiedInterfaceName_2_0[] =
constexpr char kFullyQualifiedInterfaceName_2_1[] =
    "android.hardware.bluetooth.audio@2.1::IBluetoothAudioProvidersFactory";

#if COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS
/**
 * The type of HAL transport, it's important to have
 * BluetoothAudioHalTransport::HIDL value defined smaller than
@@ -115,27 +114,6 @@ class BluetoothAudioHalVersion {
  uint16_t mMinor = 0;
};

#else  // COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

enum class BluetoothAudioHalVersion : uint8_t {
  VERSION_UNAVAILABLE = 0,
  VERSION_2_0,
  VERSION_2_1,
  VERSION_AIDL_V1,
  VERSION_AIDL_V2,
  VERSION_AIDL_V3,
  VERSION_AIDL_V4,
};

enum class BluetoothAudioHalTransport : uint8_t {
  // Uninit, default value
  UNKNOWN,
  AIDL,
  HIDL,
};

#endif  // COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

class HalVersionManager {
 public:
  static BluetoothAudioHalVersion GetHalVersion();
+0 −4
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@
namespace bluetooth {
namespace audio {

#if COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

const BluetoothAudioHalVersion BluetoothAudioHalVersion::VERSION_UNAVAILABLE =
    BluetoothAudioHalVersion();
const BluetoothAudioHalVersion BluetoothAudioHalVersion::VERSION_2_0 =
@@ -36,8 +34,6 @@ const BluetoothAudioHalVersion BluetoothAudioHalVersion::VERSION_AIDL_V3 =
const BluetoothAudioHalVersion BluetoothAudioHalVersion::VERSION_AIDL_V4 =
    BluetoothAudioHalVersion(BluetoothAudioHalTransport::AIDL, 4, 0);

#endif  // COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

std::unique_ptr<HalVersionManager> HalVersionManager::instance_ptr = nullptr;

BluetoothAudioHalVersion HalVersionManager::GetHalVersion() {
+0 −3
Original line number Diff line number Diff line
@@ -147,8 +147,6 @@ TEST_F(BluetoothAudioHalVersionTest, versionOperatorGreaterOrEqual) {
               BluetoothAudioHalVersion::VERSION_AIDL_V4);
}

#if COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS

TEST_F_WITH_FLAGS(
    BluetoothAudioHalVersionTest, HIDL_VERSION_2_0,
    REQUIRES_FLAGS_ENABLED(ACONFIG_FLAG(com::android::bluetooth::flags,
@@ -281,4 +279,3 @@ TEST_F_WITH_FLAGS(
  EXPECT_TRUE(BluetoothAudioHalVersion(BluetoothAudioHalTransport::AIDL, 5, 0)
                  .isAIDL());
}
#endif  // #if COM_ANDROID_BLUETOOTH_FLAGS_AUDIO_HAL_VERSION_CLASS