Loading audio/policy/1.0/vts/functional/Android.bp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,11 @@ package { cc_test { cc_test { name: "VtsHalAudioPolicyV1_0TargetTest", 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: [ srcs: [ "ValidateEngineConfiguration.cpp", "ValidateEngineConfiguration.cpp", ], ], Loading @@ -17,6 +22,7 @@ cc_test { "libxml2", "libxml2", "liblog", "liblog", "libmedia_helper", "libmedia_helper", "libaidlvintf_gtest_helper", "libaudiopolicycapengine_config", "libaudiopolicycapengine_config", "libaudiopolicycomponents", "libaudiopolicycomponents", "libaudiopolicyengine_config", "libaudiopolicyengine_config", Loading @@ -33,6 +39,8 @@ cc_test { ], ], shared_libs: [ shared_libs: [ "libaudiofoundation", "libaudiofoundation", "libbinder_ndk", "libvintf", ], ], // Use test_config for vts suite. // Use test_config for vts suite. // TODO(b/146104851): Add auto-gen rules and remove it. // TODO(b/146104851): Add auto-gen rules and remove it. Loading audio/policy/1.0/vts/functional/ValidateEngineConfiguration.cpp +30 −7 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,9 @@ #include <EngineConfig.h> #include <EngineConfig.h> #include <ParameterManagerWrapper.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> #include <gtest/gtest.h> Loading @@ -34,12 +37,30 @@ static const std::string configurableSchemas = static const std::string configurableConfig = static const std::string configurableConfig = "parameter-framework/ParameterFrameworkConfigurationPolicy.xml"; "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. * @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 * Note: this configuration file is not mandatory, an hardcoded fallback is provided, so * it does not fail if not found. * it does not fail if not found. */ */ TEST(ValidateConfiguration, audioPolicyEngineConfiguration) { TEST(ValidateConfiguration, audioPolicyEngineConfiguration) { if (deviceUsesAidlHal()) { GTEST_SKIP() << "Device uses AIDL HAL, n-op."; } RecordProperty("description", RecordProperty("description", "Verify that the audio policy engine configuration file " "Verify that the audio policy engine configuration file " "is valid according to the schemas"); "is valid according to the schemas"); Loading @@ -48,11 +69,12 @@ TEST(ValidateConfiguration, audioPolicyEngineConfiguration) { } } /** /** * @brief deviceUsesConfigurableEngine checks if the configuration file for * @brief deviceUsesHidlConfigurableEngine checks if there is no AIDL HAL, * the engine presents on the device AND * AND the configuration file for the engine presents on the device * for the configurable engine (aka Parameter-Framework top configuration file) presents. * 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>( return android::hardware::audio::common::test::utility::validateXmlMultipleLocations<true>( "", "", "", config.c_str(), android::audio_get_configuration_paths(), "", "", "", config.c_str(), android::audio_get_configuration_paths(), schema.c_str()) && schema.c_str()) && Loading @@ -62,8 +84,8 @@ static bool deviceUsesConfigurableEngine() { } } TEST(ValidateConfiguration, audioPolicyEngineConfigurable) { TEST(ValidateConfiguration, audioPolicyEngineConfigurable) { if (!deviceUsesConfigurableEngine()) { if (!deviceUsesHidlConfigurableEngine()) { GTEST_SKIP() << "Device using legacy engine without parameter-framework, n-op."; GTEST_SKIP() << "Device uses AIDL HAL or legacy engine without parameter-framework, n-op."; } } RecordProperty("description", RecordProperty("description", "Verify that the audio policy engine PFW configuration files " "Verify that the audio policy engine PFW configuration files " Loading @@ -78,7 +100,8 @@ TEST(ValidateConfiguration, audioPolicyEngineConfigurable) { ASSERT_EQ(result.nbSkippedElement, 0) << "skipped %zu elements " << result.nbSkippedElement; ASSERT_EQ(result.nbSkippedElement, 0) << "skipped %zu elements " << result.nbSkippedElement; std::unique_ptr<android::audio_policy::ParameterManagerWrapper> policyParameterMgr( 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"; ASSERT_NE(nullptr, policyParameterMgr) << "failed to create Audio Policy Engine PFW"; // Load the criterion types and criteria // Load the criterion types and criteria Loading Loading
audio/policy/1.0/vts/functional/Android.bp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,11 @@ package { cc_test { cc_test { name: "VtsHalAudioPolicyV1_0TargetTest", 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: [ srcs: [ "ValidateEngineConfiguration.cpp", "ValidateEngineConfiguration.cpp", ], ], Loading @@ -17,6 +22,7 @@ cc_test { "libxml2", "libxml2", "liblog", "liblog", "libmedia_helper", "libmedia_helper", "libaidlvintf_gtest_helper", "libaudiopolicycapengine_config", "libaudiopolicycapengine_config", "libaudiopolicycomponents", "libaudiopolicycomponents", "libaudiopolicyengine_config", "libaudiopolicyengine_config", Loading @@ -33,6 +39,8 @@ cc_test { ], ], shared_libs: [ shared_libs: [ "libaudiofoundation", "libaudiofoundation", "libbinder_ndk", "libvintf", ], ], // Use test_config for vts suite. // Use test_config for vts suite. // TODO(b/146104851): Add auto-gen rules and remove it. // TODO(b/146104851): Add auto-gen rules and remove it. Loading
audio/policy/1.0/vts/functional/ValidateEngineConfiguration.cpp +30 −7 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,9 @@ #include <EngineConfig.h> #include <EngineConfig.h> #include <ParameterManagerWrapper.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> #include <gtest/gtest.h> Loading @@ -34,12 +37,30 @@ static const std::string configurableSchemas = static const std::string configurableConfig = static const std::string configurableConfig = "parameter-framework/ParameterFrameworkConfigurationPolicy.xml"; "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. * @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 * Note: this configuration file is not mandatory, an hardcoded fallback is provided, so * it does not fail if not found. * it does not fail if not found. */ */ TEST(ValidateConfiguration, audioPolicyEngineConfiguration) { TEST(ValidateConfiguration, audioPolicyEngineConfiguration) { if (deviceUsesAidlHal()) { GTEST_SKIP() << "Device uses AIDL HAL, n-op."; } RecordProperty("description", RecordProperty("description", "Verify that the audio policy engine configuration file " "Verify that the audio policy engine configuration file " "is valid according to the schemas"); "is valid according to the schemas"); Loading @@ -48,11 +69,12 @@ TEST(ValidateConfiguration, audioPolicyEngineConfiguration) { } } /** /** * @brief deviceUsesConfigurableEngine checks if the configuration file for * @brief deviceUsesHidlConfigurableEngine checks if there is no AIDL HAL, * the engine presents on the device AND * AND the configuration file for the engine presents on the device * for the configurable engine (aka Parameter-Framework top configuration file) presents. * 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>( return android::hardware::audio::common::test::utility::validateXmlMultipleLocations<true>( "", "", "", config.c_str(), android::audio_get_configuration_paths(), "", "", "", config.c_str(), android::audio_get_configuration_paths(), schema.c_str()) && schema.c_str()) && Loading @@ -62,8 +84,8 @@ static bool deviceUsesConfigurableEngine() { } } TEST(ValidateConfiguration, audioPolicyEngineConfigurable) { TEST(ValidateConfiguration, audioPolicyEngineConfigurable) { if (!deviceUsesConfigurableEngine()) { if (!deviceUsesHidlConfigurableEngine()) { GTEST_SKIP() << "Device using legacy engine without parameter-framework, n-op."; GTEST_SKIP() << "Device uses AIDL HAL or legacy engine without parameter-framework, n-op."; } } RecordProperty("description", RecordProperty("description", "Verify that the audio policy engine PFW configuration files " "Verify that the audio policy engine PFW configuration files " Loading @@ -78,7 +100,8 @@ TEST(ValidateConfiguration, audioPolicyEngineConfigurable) { ASSERT_EQ(result.nbSkippedElement, 0) << "skipped %zu elements " << result.nbSkippedElement; ASSERT_EQ(result.nbSkippedElement, 0) << "skipped %zu elements " << result.nbSkippedElement; std::unique_ptr<android::audio_policy::ParameterManagerWrapper> policyParameterMgr( 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"; ASSERT_NE(nullptr, policyParameterMgr) << "failed to create Audio Policy Engine PFW"; // Load the criterion types and criteria // Load the criterion types and criteria Loading