Merge "audio: Update HIDL VTS VtsHalAudioPolicyV1_0TargetTest" into main
diff --git a/audio/policy/1.0/vts/functional/Android.bp b/audio/policy/1.0/vts/functional/Android.bp
index c2335e4..ccdd771 100644
--- a/audio/policy/1.0/vts/functional/Android.bp
+++ b/audio/policy/1.0/vts/functional/Android.bp
@@ -10,6 +10,11 @@
cc_test {
name: "VtsHalAudioPolicyV1_0TargetTest",
+ defaults: [
+ "latest_android_hardware_audio_common_ndk_static",
+ "latest_android_hardware_audio_core_ndk_static",
+ "latest_android_media_audio_common_types_ndk_static",
+ ],
srcs: [
"ValidateEngineConfiguration.cpp",
],
@@ -17,6 +22,7 @@
"libxml2",
"liblog",
"libmedia_helper",
+ "libaidlvintf_gtest_helper",
"libaudiopolicycapengine_config",
"libaudiopolicycomponents",
"libaudiopolicyengine_config",
@@ -33,6 +39,8 @@
],
shared_libs: [
"libaudiofoundation",
+ "libbinder_ndk",
+ "libvintf",
],
// Use test_config for vts suite.
// TODO(b/146104851): Add auto-gen rules and remove it.
diff --git a/audio/policy/1.0/vts/functional/ValidateEngineConfiguration.cpp b/audio/policy/1.0/vts/functional/ValidateEngineConfiguration.cpp
index 5741fa9..0472174 100644
--- a/audio/policy/1.0/vts/functional/ValidateEngineConfiguration.cpp
+++ b/audio/policy/1.0/vts/functional/ValidateEngineConfiguration.cpp
@@ -16,6 +16,9 @@
#include <EngineConfig.h>
#include <ParameterManagerWrapper.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/audio/core/IConfig.h>
+#include <android/binder_manager.h>
#include <gtest/gtest.h>
@@ -34,12 +37,30 @@
static const std::string configurableConfig =
"parameter-framework/ParameterFrameworkConfigurationPolicy.xml";
+static bool deviceUsesAidlHal() {
+ using aidl::android::hardware::audio::core::IConfig;
+
+ const auto configName = android::getAidlHalInstanceNames(IConfig::descriptor);
+ if (!configName.empty()) {
+ ndk::SpAIBinder binder =
+ ndk::SpAIBinder(AServiceManager_waitForService(configName[0].c_str()));
+ if (binder != nullptr) {
+ std::shared_ptr<IConfig> configItf = IConfig::fromBinder(binder);
+ return configItf != nullptr;
+ }
+ }
+ return false;
+}
+
/**
* @brief TEST to ensure the audio policy engine configuration file is validating schemas.
* Note: this configuration file is not mandatory, an hardcoded fallback is provided, so
* it does not fail if not found.
*/
TEST(ValidateConfiguration, audioPolicyEngineConfiguration) {
+ if (deviceUsesAidlHal()) {
+ GTEST_SKIP() << "Device uses AIDL HAL, n-op.";
+ }
RecordProperty("description",
"Verify that the audio policy engine configuration file "
"is valid according to the schemas");
@@ -48,11 +69,12 @@
}
/**
- * @brief deviceUsesConfigurableEngine checks if the configuration file for
- * the engine presents on the device AND
- * for the configurable engine (aka Parameter-Framework top configuration file) presents.
+ * @brief deviceUsesHidlConfigurableEngine checks if there is no AIDL HAL,
+ * AND the configuration file for the engine presents on the device
+ * AND for the configurable engine (aka Parameter-Framework top configuration file) presents.
*/
-static bool deviceUsesConfigurableEngine() {
+static bool deviceUsesHidlConfigurableEngine() {
+ if (deviceUsesAidlHal()) return false;
return android::hardware::audio::common::test::utility::validateXmlMultipleLocations<true>(
"", "", "", config.c_str(), android::audio_get_configuration_paths(),
schema.c_str()) &&
@@ -62,8 +84,8 @@
}
TEST(ValidateConfiguration, audioPolicyEngineConfigurable) {
- if (!deviceUsesConfigurableEngine()) {
- GTEST_SKIP() << "Device using legacy engine without parameter-framework, n-op.";
+ if (!deviceUsesHidlConfigurableEngine()) {
+ GTEST_SKIP() << "Device uses AIDL HAL or legacy engine without parameter-framework, n-op.";
}
RecordProperty("description",
"Verify that the audio policy engine PFW configuration files "
@@ -78,7 +100,8 @@
ASSERT_EQ(result.nbSkippedElement, 0) << "skipped %zu elements " << result.nbSkippedElement;
std::unique_ptr<android::audio_policy::ParameterManagerWrapper> policyParameterMgr(
- new android::audio_policy::ParameterManagerWrapper(validateSchema, schemasUri));
+ new android::audio_policy::ParameterManagerWrapper(
+ true /*useLegacyConfigurationFile*/, validateSchema, schemasUri));
ASSERT_NE(nullptr, policyParameterMgr) << "failed to create Audio Policy Engine PFW";
// Load the criterion types and criteria