Move get picture/sound parameters API to a callback
The getPictureParameters API should be called from the HAL to the
framework. So created
setPictureParametersCallback(IPictureParametersCallback cb) to allow the
HAL receive parameters send from the client(framework).
Test: m on cuttlefish
Bug: 375472716
Flag: android.media.tv.flags.media_quality_fw
Change-Id: Id3b2cb3028d8e02947208de7c442b4d468c61b0a
diff --git a/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/IMediaQuality.aidl b/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/IMediaQuality.aidl
index 006abee..115ada7 100644
--- a/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/IMediaQuality.aidl
+++ b/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/IMediaQuality.aidl
@@ -49,12 +49,12 @@
void setAutoAqEnabled(boolean enable);
android.hardware.tv.mediaquality.IPictureProfileChangedListener getPictureProfileListener();
void setPictureProfileAdjustmentListener(android.hardware.tv.mediaquality.IPictureProfileAdjustmentListener listener);
- android.hardware.tv.mediaquality.PictureParameters getPictureParameters(long pictureProfileId);
void sendDefaultPictureParameters(in android.hardware.tv.mediaquality.PictureParameters pictureParameters);
android.hardware.tv.mediaquality.ISoundProfileChangedListener getSoundProfileListener();
void setSoundProfileAdjustmentListener(android.hardware.tv.mediaquality.ISoundProfileAdjustmentListener listener);
- android.hardware.tv.mediaquality.SoundParameters getSoundParameters(long soundProfileId);
void sendDefaultSoundParameters(in android.hardware.tv.mediaquality.SoundParameters soundParameters);
void getParamCaps(in android.hardware.tv.mediaquality.ParameterName[] paramNames, out android.hardware.tv.mediaquality.ParamCapability[] caps);
void getVendorParamCaps(in android.hardware.tv.mediaquality.VendorParameterIdentifier[] names, out android.hardware.tv.mediaquality.VendorParamCapability[] caps);
+ void setPictureParametersCallback(android.hardware.tv.mediaquality.IPictureParametersCallback callback);
+ void setSoundParametersCallback(android.hardware.tv.mediaquality.ISoundParametersCallback callback);
}
diff --git a/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/IPictureParametersCallback.aidl b/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/IPictureParametersCallback.aidl
new file mode 100644
index 0000000..ccb31c4
--- /dev/null
+++ b/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/IPictureParametersCallback.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.tv.mediaquality;
+@VintfStability
+interface IPictureParametersCallback {
+ android.hardware.tv.mediaquality.PictureParameters getPictureParameters(long pictureProfileId);
+}
diff --git a/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/ISoundParametersCallback.aidl b/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/ISoundParametersCallback.aidl
new file mode 100644
index 0000000..9509006
--- /dev/null
+++ b/tv/mediaquality/aidl/aidl_api/android.hardware.tv.mediaquality/current/android/hardware/tv/mediaquality/ISoundParametersCallback.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.tv.mediaquality;
+@VintfStability
+interface ISoundParametersCallback {
+ android.hardware.tv.mediaquality.SoundParameters getSoundParameters(long SoundProfileId);
+}
diff --git a/tv/mediaquality/aidl/android/hardware/tv/mediaquality/IMediaQuality.aidl b/tv/mediaquality/aidl/android/hardware/tv/mediaquality/IMediaQuality.aidl
index 6a992a1..e12ded0 100644
--- a/tv/mediaquality/aidl/android/hardware/tv/mediaquality/IMediaQuality.aidl
+++ b/tv/mediaquality/aidl/android/hardware/tv/mediaquality/IMediaQuality.aidl
@@ -18,8 +18,10 @@
import android.hardware.tv.mediaquality.AmbientBacklightSettings;
import android.hardware.tv.mediaquality.IMediaQualityCallback;
+import android.hardware.tv.mediaquality.IPictureParametersCallback;
import android.hardware.tv.mediaquality.IPictureProfileAdjustmentListener;
import android.hardware.tv.mediaquality.IPictureProfileChangedListener;
+import android.hardware.tv.mediaquality.ISoundParametersCallback;
import android.hardware.tv.mediaquality.ISoundProfileAdjustmentListener;
import android.hardware.tv.mediaquality.ISoundProfileChangedListener;
import android.hardware.tv.mediaquality.ParamCapability;
@@ -154,14 +156,6 @@
void setPictureProfileAdjustmentListener(IPictureProfileAdjustmentListener listener);
/**
- * Get the picture parameters by PictureProfile id. Check PictureParameters for its' detail.
- *
- * @param pictureProfileId The PictureProfile id that associate with the PictureProfile.
- * @return PictureParameters with all the pre-defined parameters and vendor defined parameters.
- */
- PictureParameters getPictureParameters(long pictureProfileId);
-
- /**
* Send the default picture parameters to the vendor code or HAL to apply the picture
* parameters.
*
@@ -185,14 +179,6 @@
void setSoundProfileAdjustmentListener(ISoundProfileAdjustmentListener listener);
/**
- * Get the sound parameters by SoundProfile id. Check SoundParameters for its' detail.
- *
- * @param soundProfileId The SoundProfile id that associate with a SoundProfile.
- * @return SoundParameters with all the pre-defined parameters and vendor defined parameters.
- */
- SoundParameters getSoundParameters(long soundProfileId);
-
- /**
* Send the default sound parameters to the vendor code or HAL to apply the sound parameters.
*
* @param soundParameters SoundParameters with pre-defined parameters and vendor defined
@@ -209,4 +195,30 @@
* Gets vendor capability information of the given parameters.
*/
void getVendorParamCaps(in VendorParameterIdentifier[] names, out VendorParamCapability[] caps);
+
+ /**
+ * Sets picture parameters callback to get the picture parameters send by the client.
+ *
+ * When the same client registers this callback multiple times, only the most recent
+ * registration will be active. The previous callback will be overwritten.
+ *
+ * When different client registers this callback, it will overwrite the previous registered
+ * client. Only one callback can be active.
+ *
+ * @param callback Callback object to pass PictureParameters.
+ */
+ void setPictureParametersCallback(IPictureParametersCallback callback);
+
+ /**
+ * Sets sound parameters callback to get the sound parameters send by the client.
+ *
+ * When the same client registers this callback multiple times, only the most recent
+ * registration will be active. The previous callback will be overwritten.
+ *
+ * When different client registers this callback, it will overwrite the previous registered
+ * client. Only one callback can be active.
+ *
+ * @param callback Callback object to pass SoundParameters.
+ */
+ void setSoundParametersCallback(ISoundParametersCallback callback);
}
diff --git a/tv/mediaquality/aidl/android/hardware/tv/mediaquality/IPictureParametersCallback.aidl b/tv/mediaquality/aidl/android/hardware/tv/mediaquality/IPictureParametersCallback.aidl
new file mode 100644
index 0000000..b92c775
--- /dev/null
+++ b/tv/mediaquality/aidl/android/hardware/tv/mediaquality/IPictureParametersCallback.aidl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.tv.mediaquality;
+
+import android.hardware.tv.mediaquality.PictureParameters;
+
+@VintfStability
+interface IPictureParametersCallback {
+ /**
+ * Get the picture parameters by PictureProfile id. Check PictureParameters for its' detail.
+ * This is called from the HAL to media quality framework.
+ *
+ * @param pictureProfileId The PictureProfile id that associate with the PictureProfile.
+ * @return PictureParameters with all the pre-defined parameters and vendor defined parameters.
+ */
+ PictureParameters getPictureParameters(long pictureProfileId);
+}
diff --git a/tv/mediaquality/aidl/android/hardware/tv/mediaquality/ISoundParametersCallback.aidl b/tv/mediaquality/aidl/android/hardware/tv/mediaquality/ISoundParametersCallback.aidl
new file mode 100644
index 0000000..856ceb4
--- /dev/null
+++ b/tv/mediaquality/aidl/android/hardware/tv/mediaquality/ISoundParametersCallback.aidl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.tv.mediaquality;
+
+import android.hardware.tv.mediaquality.SoundParameters;
+
+@VintfStability
+interface ISoundParametersCallback {
+ /**
+ * Get the Sound parameters by SoundProfile id. Check SoundParameters for its' detail.
+ * This is called from the HAL to media quality framework.
+ *
+ * @param SoundProfileId The SoundProfile id that associate with the SoundProfile.
+ * @return SoundParameters with all the pre-defined parameters and vendor defined parameters.
+ */
+ SoundParameters getSoundParameters(long SoundProfileId);
+}
diff --git a/tv/mediaquality/aidl/default/hal/media_quality_hal_impl.rs b/tv/mediaquality/aidl/default/hal/media_quality_hal_impl.rs
index 35fb999..190e6a7 100644
--- a/tv/mediaquality/aidl/default/hal/media_quality_hal_impl.rs
+++ b/tv/mediaquality/aidl/default/hal/media_quality_hal_impl.rs
@@ -24,16 +24,16 @@
IPictureProfileChangedListener::IPictureProfileChangedListener,
ParamCapability::ParamCapability,
ParameterName::ParameterName,
- PictureParameter::PictureParameter,
PictureParameters::PictureParameters,
ISoundProfileAdjustmentListener::ISoundProfileAdjustmentListener,
ISoundProfileChangedListener::ISoundProfileChangedListener,
- SoundParameter::SoundParameter,
SoundParameters::SoundParameters,
VendorParamCapability::VendorParamCapability,
VendorParameterIdentifier::VendorParameterIdentifier,
+ IPictureParametersCallback::IPictureParametersCallback,
+ ISoundParametersCallback::ISoundParametersCallback,
};
-use binder::{Interface, ParcelableHolder, Strong};
+use binder::{Interface, Strong};
use std::sync::{Arc, Mutex};
use std::thread;
@@ -54,6 +54,8 @@
Arc<Mutex<Option<Strong<dyn ISoundProfileAdjustmentListener>>>>,
picture_profile_changed_listener: Arc<Mutex<Option<Strong<dyn IPictureProfileChangedListener>>>>,
sound_profile_changed_listener: Arc<Mutex<Option<Strong<dyn ISoundProfileChangedListener>>>>,
+ picture_parameters_callback: Arc<Mutex<Option<Strong<dyn IPictureParametersCallback>>>>,
+ sound_parameters_callback: Arc<Mutex<Option<Strong<dyn ISoundParametersCallback>>>>,
}
impl MediaQualityService {
@@ -75,6 +77,8 @@
sound_profile_adjustment_listener: Arc::new(Mutex::new(None)),
picture_profile_changed_listener: Arc::new(Mutex::new(None)),
sound_profile_changed_listener: Arc::new(Mutex::new(None)),
+ picture_parameters_callback: Arc::new(Mutex::new(None)),
+ sound_parameters_callback: Arc::new(Mutex::new(None)),
}
}
}
@@ -224,25 +228,6 @@
Ok(())
}
- fn getPictureParameters(&self, id: i64) -> binder::Result<PictureParameters>{
- let picture_parameters = match id {
- 1 => {
- vec![
- PictureParameter::Brightness(0.5),
- PictureParameter::Contrast(50),
- ]
- },
- _ => vec![]
- };
-
- let picture_params = PictureParameters {
- pictureParameters: picture_parameters,
- vendorPictureParameters: ParcelableHolder::default(),
- };
-
- Ok(picture_params)
- }
-
fn sendDefaultPictureParameters(&self, _picture_parameters: &PictureParameters) -> binder::Result<()>{
println!("Received picture parameters");
Ok(())
@@ -264,25 +249,6 @@
Ok(())
}
- fn getSoundParameters(&self, id: i64) -> binder::Result<SoundParameters>{
- let sound_parameters = match id {
- 1 => {
- vec![
- SoundParameter::Balance(50),
- SoundParameter::Bass(50),
- ]
- },
- _ => vec![]
- };
-
- let sound_params = SoundParameters {
- soundParameters: sound_parameters,
- vendorSoundParameters: ParcelableHolder::default(),
- };
-
- Ok(sound_params)
- }
-
fn sendDefaultSoundParameters(&self, _sound_parameters: &SoundParameters) -> binder::Result<()>{
println!("Received sound parameters");
Ok(())
@@ -305,4 +271,22 @@
println!("getVendorParamCaps. len= {}", param_names.len());
Ok(())
}
+
+ fn setPictureParametersCallback(
+ &self,
+ callback: &Strong<dyn IPictureParametersCallback>
+ ) -> binder::Result<()> {
+ let mut cb = self.picture_parameters_callback.lock().unwrap();
+ *cb = Some(callback.clone());
+ Ok(())
+ }
+
+ fn setSoundParametersCallback(
+ &self,
+ callback: &Strong<dyn ISoundParametersCallback>
+ ) -> binder::Result<()> {
+ let mut cb = self.sound_parameters_callback.lock().unwrap();
+ *cb = Some(callback.clone());
+ Ok(())
+ }
}
diff --git a/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp b/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp
index b508ed6..c3e25a4 100644
--- a/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp
+++ b/tv/mediaquality/aidl/vts/functional/VtsHalMediaQualityTest.cpp
@@ -23,8 +23,10 @@
#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/PictureParameter.h>
#include <aidl/android/hardware/tv/mediaquality/PictureParameters.h>
#include <aidl/android/hardware/tv/mediaquality/PictureProfile.h>
+#include <aidl/android/hardware/tv/mediaquality/SoundParameter.h>
#include <aidl/android/hardware/tv/mediaquality/SoundParameters.h>
#include <aidl/android/hardware/tv/mediaquality/SoundProfile.h>
@@ -43,8 +45,10 @@
using aidl::android::hardware::tv::mediaquality::BnSoundProfileAdjustmentListener;
using aidl::android::hardware::tv::mediaquality::IMediaQuality;
using aidl::android::hardware::tv::mediaquality::ParamCapability;
+using aidl::android::hardware::tv::mediaquality::PictureParameter;
using aidl::android::hardware::tv::mediaquality::PictureParameters;
using aidl::android::hardware::tv::mediaquality::PictureProfile;
+using aidl::android::hardware::tv::mediaquality::SoundParameter;
using aidl::android::hardware::tv::mediaquality::SoundParameters;
using aidl::android::hardware::tv::mediaquality::SoundProfile;
using aidl::android::hardware::tv::mediaquality::VendorParamCapability;
@@ -162,18 +166,20 @@
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, TestSendDefaultPictureParameters) {
- PictureParameters pictureParams;
- auto result = mediaquality->getPictureParameters(1, &pictureParams);
- ASSERT_TRUE(result.isOk());
- ASSERT_OK(mediaquality->sendDefaultPictureParameters(pictureParams));
+ PictureParameters pictureParameters;
+ std::vector<PictureParameter> picParams;
+
+ PictureParameter brightnessParam;
+ brightnessParam.set<PictureParameter::Tag::brightness>(0.5f);
+ picParams.push_back(brightnessParam);
+
+ PictureParameter contrastParam;
+ contrastParam.set<PictureParameter::Tag::contrast>(50);
+ picParams.push_back(contrastParam);
+
+ pictureParameters.pictureParameters = picParams;
+ ASSERT_OK(mediaquality->sendDefaultPictureParameters(pictureParameters));
}
TEST_P(MediaQualityAidl, TestSetSoundProfileAdjustmentListener) {
@@ -183,18 +189,20 @@
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, TestSendDefaultSoundParameters) {
- SoundParameters soundParams;
- auto result = mediaquality->getSoundParameters(1, &soundParams);
- ASSERT_TRUE(result.isOk());
- ASSERT_OK(mediaquality->sendDefaultSoundParameters(soundParams));
+ SoundParameters soundParameters;
+ std::vector<SoundParameter> soundParams;
+
+ SoundParameter balanceParam;
+ balanceParam.set<SoundParameter::Tag::balance>(50);
+ soundParams.push_back(balanceParam);
+
+ SoundParameter bassParam;
+ bassParam.set<SoundParameter::Tag::bass>(50);
+ soundParams.push_back(bassParam);
+
+ soundParameters.soundParameters = soundParams;
+ ASSERT_OK(mediaquality->sendDefaultSoundParameters(soundParameters));
}
TEST_P(MediaQualityAidl, TestSetAmbientBacklightDetector) {