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

Commit 785b20f9 authored by Patty Huang's avatar Patty Huang Committed by Gerrit Code Review
Browse files

Merge "Get exact aidl version in HalVersionManager"

parents 63454f8e fc9a0237
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -258,31 +258,6 @@ bool BluetoothAudioClientInterface::SetLowLatencyModeAllowed(bool allowed) {
  return true;
}

int BluetoothAudioClientInterface::GetAidlInterfaceVersion() {
  int aidl_version = -1;
  if (!is_aidl_available()) {
    return aidl_version;
  }

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

  if (provider_factory == nullptr) {
    LOG(ERROR) << __func__ << ", can't get aidl version from unknown factory";
    return aidl_version;
  }

  auto aidl_retval = provider_factory->getInterfaceVersion(&aidl_version);
  if (!aidl_retval.isOk()) {
    LOG(FATAL) << __func__
               << ": BluetoothAudioHal::getInterfaceVersion failure: "
               << aidl_retval.getDescription();
  }

  return aidl_version;
}

int BluetoothAudioClientInterface::StartSession() {
  std::lock_guard<std::mutex> guard(internal_mutex_);
  if (provider_ == nullptr) {
+0 −2
Original line number Diff line number Diff line
@@ -93,8 +93,6 @@ class BluetoothAudioClientInterface {

  static bool is_aidl_available();

  static int GetAidlInterfaceVersion();

 protected:
  mutable std::mutex internal_mutex_;
  /***
+0 −4
Original line number Diff line number Diff line
@@ -643,10 +643,6 @@ AudioConfiguration offload_config_to_hal_audio_config(
  return AudioConfiguration(ucast_config);
}

int GetAidlInterfaceVersion() {
  return BluetoothAudioSinkClientInterface::GetAidlInterfaceVersion();
}

}  // namespace le_audio
}  // namespace aidl
}  // namespace audio
+0 −1
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ bool is_source_hal_enabled();
bool is_sink_hal_enabled();

std::vector<AudioSetConfiguration> get_offload_capabilities();
int GetAidlInterfaceVersion();

class LeAudioTransport {
 public:
+38 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <memory>

#include "aidl/audio_aidl_interfaces.h"
#include "osi/include/log.h"

namespace bluetooth {
namespace audio {
@@ -45,6 +46,8 @@ BluetoothAudioHalVersion HalVersionManager::GetHalVersion() {
BluetoothAudioHalTransport HalVersionManager::GetHalTransport() {
  switch (GetHalVersion()) {
    case BluetoothAudioHalVersion::VERSION_AIDL_V1:
    case BluetoothAudioHalVersion::VERSION_AIDL_V2:
    case BluetoothAudioHalVersion::VERSION_AIDL_V3:
      return BluetoothAudioHalTransport::AIDL;
    case BluetoothAudioHalVersion::VERSION_2_0:
    case BluetoothAudioHalVersion::VERSION_2_1:
@@ -90,10 +93,44 @@ HalVersionManager::GetProvidersFactory_2_0() {
  return providers_factory;
}

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;
    default:
      LOG_ERROR("Unknown AIDL version %d", aidl_version);
      return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
  }

  return BluetoothAudioHalVersion::VERSION_UNAVAILABLE;
}

HalVersionManager::HalVersionManager() {
  if (AServiceManager_checkService(
          kDefaultAudioProviderFactoryInterface.c_str()) != nullptr) {
    hal_version_ = BluetoothAudioHalVersion::VERSION_AIDL_V1;
    hal_version_ = GetAidlInterfaceVersion();
    return;
  }

Loading