Add picture and sound profile notification for manage media profile
Add picture and sound profile, they are structured with a profile id
and parameters. Parameters are structured with pre-defined parameters
and a ParcelableHolder for vendor-defined parameters.
Add get and set listener interfaces in IMediaQuality to notify
IMediaQuality about the profile change from the framework and the hal.
Test: mmm
Flag: android.media.tv.flags.media_quality_fw
Bug: 375472716
No-Typo-Check: tru triggers the typo check
Change-Id: I9f7c6c30d73b175fda3d4d889aa142939d8d4b84
diff --git a/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp b/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp
index c11ebcb..f420e02 100644
--- a/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp
+++ b/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp
@@ -20,7 +20,14 @@
#include <aidl/android/hardware/tv/mediaquality/AmbientBacklightEvent.h>
#include <aidl/android/hardware/tv/mediaquality/AmbientBacklightSettings.h>
#include <aidl/android/hardware/tv/mediaquality/BnMediaQualityCallback.h>
+#include <aidl/android/hardware/tv/mediaquality/BnPictureProfileAdjustmentListener.h>
+#include <aidl/android/hardware/tv/mediaquality/BnSoundProfileAdjustmentListener.h>
#include <aidl/android/hardware/tv/mediaquality/IMediaQuality.h>
+#include <aidl/android/hardware/tv/mediaquality/PictureParameters.h>
+#include <aidl/android/hardware/tv/mediaquality/PictureProfile.h>
+#include <aidl/android/hardware/tv/mediaquality/SoundParameters.h>
+#include <aidl/android/hardware/tv/mediaquality/SoundProfile.h>
+
#include <android/binder_auto_utils.h>
#include <android/binder_manager.h>
#include <binder/IServiceManager.h>
@@ -32,7 +39,13 @@
using aidl::android::hardware::tv::mediaquality::AmbientBacklightSettings;
using aidl::android::hardware::tv::mediaquality::AmbientBacklightSource;
using aidl::android::hardware::tv::mediaquality::BnMediaQualityCallback;
+using aidl::android::hardware::tv::mediaquality::BnPictureProfileAdjustmentListener;
+using aidl::android::hardware::tv::mediaquality::BnSoundProfileAdjustmentListener;
using aidl::android::hardware::tv::mediaquality::IMediaQuality;
+using aidl::android::hardware::tv::mediaquality::PictureParameters;
+using aidl::android::hardware::tv::mediaquality::PictureProfile;
+using aidl::android::hardware::tv::mediaquality::SoundParameters;
+using aidl::android::hardware::tv::mediaquality::SoundProfile;
using android::ProcessState;
using android::String16;
using ndk::ScopedAStatus;
@@ -55,6 +68,36 @@
std::function<void(const AmbientBacklightEvent& event)> on_hal_event_cb_;
};
+class PictureProfileAdjustmentListener : public BnPictureProfileAdjustmentListener {
+ public:
+ explicit PictureProfileAdjustmentListener(
+ const std::function<void(const PictureProfile& pictureProfile)>&
+ on_hal_picture_profile_adjust)
+ : on_hal_picture_profile_adjust_(on_hal_picture_profile_adjust) {}
+ ScopedAStatus onPictureProfileAdjusted(const PictureProfile& pictureProfile) override {
+ on_hal_picture_profile_adjust_(pictureProfile);
+ return ScopedAStatus::ok();
+ }
+
+ private:
+ std::function<void(const PictureProfile& pictureProfile)> on_hal_picture_profile_adjust_;
+};
+
+class SoundProfileAdjustmentListener : public BnSoundProfileAdjustmentListener {
+ public:
+ explicit SoundProfileAdjustmentListener(
+ const std::function<void(const SoundProfile& soundProfile)>&
+ on_hal_sound_profile_adjust)
+ : on_hal_sound_profile_adjust_(on_hal_sound_profile_adjust) {}
+ ScopedAStatus onSoundProfileAdjusted(const SoundProfile& soundProfile) override {
+ on_hal_sound_profile_adjust_(soundProfile);
+ return ScopedAStatus::ok();
+ }
+
+ private:
+ std::function<void(const SoundProfile& soundProfile)> on_hal_sound_profile_adjust_;
+};
+
class MediaQualityAidl : public testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
@@ -92,6 +135,34 @@
ASSERT_OK(mediaquality->setCallback(callback));
}
+TEST_P(MediaQualityAidl, TestSetPictureProfileAdjustmentListener) {
+ std::shared_ptr<PictureProfileAdjustmentListener> listener =
+ ndk::SharedRefBase::make<PictureProfileAdjustmentListener>(
+ [](auto /*picture profile*/) { return ScopedAStatus::ok(); });
+ ASSERT_OK(mediaquality->setPictureProfileAdjustmentListener(listener));
+}
+
+TEST_P(MediaQualityAidl, TestGetPictureParameters) {
+ PictureParameters pictureParams;
+ auto result = mediaquality->getPictureParameters(1, &pictureParams);
+ ASSERT_TRUE(result.isOk());
+ ASSERT_EQ(pictureParams.pictureParameters.size(), 2);
+}
+
+TEST_P(MediaQualityAidl, TestSetSoundProfileAdjustmentListener) {
+ std::shared_ptr<SoundProfileAdjustmentListener> listener =
+ ndk::SharedRefBase::make<SoundProfileAdjustmentListener>(
+ [](auto /*sound profile*/) { return ScopedAStatus::ok(); });
+ ASSERT_OK(mediaquality->setSoundProfileAdjustmentListener(listener));
+}
+
+TEST_P(MediaQualityAidl, TestGetSoundParameters) {
+ SoundParameters soundParams;
+ auto result = mediaquality->getSoundParameters(1, &soundParams);
+ ASSERT_TRUE(result.isOk());
+ ASSERT_EQ(soundParams.soundParameters.size(), 2);
+}
+
TEST_P(MediaQualityAidl, TestSetAmbientBacklightDetector) {
AmbientBacklightSettings in_settings = {
.packageName = "com.android.mediaquality",