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

Commit 5b4a9a82 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10157673 from 0ccd0938 to udc-qpr1-release

Change-Id: I9ce89707042aa9eb67129afab27cabe05cf1fd72
parents 5297e803 0ccd0938
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -53,17 +53,25 @@ using namespace android::audio::policy::configuration::V7_0;
namespace audiohalcommon = android::hardware::audio::common;
namespace audiomediacommon = android::media::audio::common;

namespace {
constexpr int32_t kAidlVersionThree = 3;
}

class AudioControlAidl : public testing::TestWithParam<std::string> {
  public:
    virtual void SetUp() override {
        audioControl = android::waitForDeclaredService<IAudioControl>(String16(GetParam().c_str()));
        ASSERT_NE(audioControl, nullptr);
        aidlVersion = audioControl->getInterfaceVersion();
    }

    void TearDown() override { audioControl = nullptr; }

    bool isAidlVersionAtleast(int version) const { return aidlVersion >= version; }

    sp<IAudioControl> audioControl;
    int32_t capabilities;
    int32_t aidlVersion;
};

TEST_P(AudioControlAidl, OnSetFadeTowardsFront) {
@@ -250,6 +258,11 @@ struct ModuleChangeCallbackMock : BnModuleChangeCallback {

TEST_P(AudioControlAidl, RegisterModuleChangeCallbackTwiceThrowsException) {
    ALOGI("Register Module change callback test");
    if (!isAidlVersionAtleast(kAidlVersionThree)) {
        GTEST_SKIP() << "Device does not support the new APIs for module change callback";
        return;
    }

    // make sure no stale callbacks.
    audioControl->clearModuleChangeCallback();

@@ -269,6 +282,11 @@ TEST_P(AudioControlAidl, RegisterModuleChangeCallbackTwiceThrowsException) {

TEST_P(AudioControlAidl, RegisterModuleChangeNullCallbackThrowsException) {
    ALOGI("Register Module change callback with nullptr test");
    if (!isAidlVersionAtleast(kAidlVersionThree)) {
        GTEST_SKIP() << "Device does not support the new APIs for module change callback";
        return;
    }

    auto status = audioControl->setModuleChangeCallback(nullptr);
    EXPECT_THAT(status.exceptionCode(),
                AnyOf(Eq(Status::EX_ILLEGAL_ARGUMENT), Eq(Status::EX_UNSUPPORTED_OPERATION)));
+34 −24
Original line number Diff line number Diff line
@@ -27,9 +27,31 @@ namespace hardware {
namespace bluetooth {
namespace audio {

struct BluetoothAudioProviderContext {
  SessionType session_type;
};

static void binderUnlinkedCallbackAidl(void* cookie) {
  LOG(INFO) << __func__;
  BluetoothAudioProviderContext* ctx =
      static_cast<BluetoothAudioProviderContext*>(cookie);
  delete ctx;
}

static void binderDiedCallbackAidl(void* cookie) {
  LOG(INFO) << __func__;
  BluetoothAudioProviderContext* ctx =
      static_cast<BluetoothAudioProviderContext*>(cookie);
  CHECK_NE(ctx, nullptr);

  BluetoothAudioSessionReport::OnSessionEnded(ctx->session_type);
}

BluetoothAudioProvider::BluetoothAudioProvider() {
  death_recipient_ = ::ndk::ScopedAIBinder_DeathRecipient(
      AIBinder_DeathRecipient_new(binderDiedCallbackAidl));
  AIBinder_DeathRecipient_setOnUnlinked(death_recipient_.get(),
                                        binderUnlinkedCallbackAidl);
}

ndk::ScopedAStatus BluetoothAudioProvider::startSession(
@@ -39,17 +61,21 @@ ndk::ScopedAStatus BluetoothAudioProvider::startSession(
    DataMQDesc* _aidl_return) {
  if (host_if == nullptr) {
    *_aidl_return = DataMQDesc();
    LOG(ERROR) << __func__ << " - SessionType=" << toString(session_type_)
               << " Illegal argument";
    return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
  }

  latency_modes_ = latencyModes;
  audio_config_ = std::make_unique<AudioConfiguration>(audio_config);
  stack_iface_ = host_if;
  is_binder_died = false;
  BluetoothAudioProviderContext* cookie =
      new BluetoothAudioProviderContext{session_type_};

  AIBinder_linkToDeath(stack_iface_->asBinder().get(), death_recipient_.get(),
                       this);
                       cookie);

  LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_);
  onSessionReady(_aidl_return);
  return ndk::ScopedAStatus::ok();
}
@@ -60,10 +86,8 @@ ndk::ScopedAStatus BluetoothAudioProvider::endSession() {
  if (stack_iface_ != nullptr) {
    BluetoothAudioSessionReport::OnSessionEnded(session_type_);

    if (!is_binder_died) {
    AIBinder_unlinkToDeath(stack_iface_->asBinder().get(),
                           death_recipient_.get(), this);
    }
  } else {
    LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
              << " has NO session";
@@ -77,10 +101,9 @@ ndk::ScopedAStatus BluetoothAudioProvider::endSession() {

ndk::ScopedAStatus BluetoothAudioProvider::streamStarted(
    BluetoothAudioStatus status) {
  if (stack_iface_ != nullptr) {
    LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
              << ", status=" << toString(status);

  if (stack_iface_ != nullptr) {
    BluetoothAudioSessionReport::ReportControlStatus(session_type_, true,
                                                     status);
  } else {
@@ -108,8 +131,6 @@ ndk::ScopedAStatus BluetoothAudioProvider::streamSuspended(

ndk::ScopedAStatus BluetoothAudioProvider::updateAudioConfiguration(
    const AudioConfiguration& audio_config) {
  LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_);

  if (stack_iface_ == nullptr || audio_config_ == nullptr) {
    LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
              << " has NO session";
@@ -125,13 +146,13 @@ ndk::ScopedAStatus BluetoothAudioProvider::updateAudioConfiguration(
  audio_config_ = std::make_unique<AudioConfiguration>(audio_config);
  BluetoothAudioSessionReport::ReportAudioConfigChanged(session_type_,
                                                        *audio_config_);
  LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
            << " | audio_config=" << audio_config.toString();
  return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus BluetoothAudioProvider::setLowLatencyModeAllowed(
    bool allowed) {
  LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_);

  if (stack_iface_ == nullptr) {
    LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_)
              << " has NO session";
@@ -143,17 +164,6 @@ ndk::ScopedAStatus BluetoothAudioProvider::setLowLatencyModeAllowed(
  return ndk::ScopedAStatus::ok();
}

void BluetoothAudioProvider::binderDiedCallbackAidl(void* ptr) {
  LOG(ERROR) << __func__ << " - BluetoothAudio Service died";
  auto provider = static_cast<BluetoothAudioProvider*>(ptr);
  if (provider == nullptr) {
    LOG(ERROR) << __func__ << ": Null AudioProvider HAL died";
    return;
  }
  provider->is_binder_died = true;
  provider->endSession();
}

}  // namespace audio
}  // namespace bluetooth
}  // namespace hardware
+0 −3
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ class BluetoothAudioProvider : public BnBluetoothAudioProvider {

 protected:
  virtual ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) = 0;
  static void binderDiedCallbackAidl(void* cookie_ptr);

  ::ndk::ScopedAIBinder_DeathRecipient death_recipient_;

@@ -62,9 +61,7 @@ class BluetoothAudioProvider : public BnBluetoothAudioProvider {
  std::unique_ptr<AudioConfiguration> audio_config_ = nullptr;
  SessionType session_type_;
  std::vector<LatencyMode> latency_modes_;
  bool is_binder_died = false;
};

}  // namespace audio
}  // namespace bluetooth
}  // namespace hardware
+7 −1
Original line number Diff line number Diff line
@@ -68,7 +68,13 @@ void TvInput::init() {
::ndk::ScopedAStatus TvInput::setTvMessageEnabled(int32_t deviceId, int32_t streamId,
                                                  TvMessageEventType in_type, bool enabled) {
    ALOGV("%s", __FUNCTION__);
    // TODO: Implement this

    if (mStreamConfigs.count(deviceId) == 0) {
        ALOGW("Device with id %d isn't available", deviceId);
        return ::ndk::ScopedAStatus::fromServiceSpecificError(STATUS_INVALID_ARGUMENTS);
    }

    mTvMessageEventEnabled[deviceId][streamId][in_type] = enabled;
    return ::ndk::ScopedAStatus::ok();
}

+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <aidl/android/hardware/tv/input/TvMessageEventType.h>
#include <fmq/AidlMessageQueue.h>
#include <map>
#include <unordered_map>
#include "TvInputDeviceInfoWrapper.h"
#include "TvStreamConfigWrapper.h"

@@ -38,6 +39,9 @@ namespace hardware {
namespace tv {
namespace input {

using TvMessageEnabledMap = std::unordered_map<
        int32_t, std::unordered_map<int32_t, std::unordered_map<TvMessageEventType, bool>>>;

class TvInput : public BnTvInput {
  public:
    TvInput();
@@ -62,6 +66,7 @@ class TvInput : public BnTvInput {
    shared_ptr<ITvInputCallback> mCallback;
    map<int32_t, shared_ptr<TvInputDeviceInfoWrapper>> mDeviceInfos;
    map<int32_t, map<int32_t, shared_ptr<TvStreamConfigWrapper>>> mStreamConfigs;
    TvMessageEnabledMap mTvMessageEventEnabled;
};

}  // namespace input