Move engine loading out from the AudioPolicyManager
Separating loading of the APM Engine configuration from the APM
initialization. This opens the way for loading the engine
configuration from other sources than the XML file. The APM
receives an engine instance pre-loaded with the configuration on
its creation, regardless of the way the config data has been
obtained.
Bug: 205884982
Test: atest audiopolicy_tests
Test: atest audiosystem_tests
Test: atest audio_health_tests
Test: m audiopolicy_fuzzer
Change-Id: I5185d8e27fccf64ba14856d3a1f0ea07a47f02e0
diff --git a/services/audiopolicy/engineconfigurable/src/Engine.cpp b/services/audiopolicy/engineconfigurable/src/Engine.cpp
index a802646..257d1fc 100644
--- a/services/audiopolicy/engineconfigurable/src/Engine.cpp
+++ b/services/audiopolicy/engineconfigurable/src/Engine.cpp
@@ -68,16 +68,15 @@
Engine::Engine() : mPolicyParameterMgr(new ParameterManagerWrapper())
{
- status_t loadResult = loadAudioPolicyEngineConfig();
+}
+
+status_t Engine::loadFromXmlConfigWithFallback(const std::string& xmlFilePath)
+{
+ status_t loadResult = loadAudioPolicyEngineConfig(xmlFilePath);
if (loadResult < 0) {
ALOGE("Policy Engine configuration is invalid.");
}
-}
-
-Engine::~Engine()
-{
- mStreamCollection.clear();
- mInputSourceCollection.clear();
+ return loadResult;
}
status_t Engine::initCheck()
@@ -179,9 +178,9 @@
return EngineBase::setDeviceConnectionState(device, state);
}
-status_t Engine::loadAudioPolicyEngineConfig()
+status_t Engine::loadAudioPolicyEngineConfig(const std::string& xmlFilePath)
{
- auto result = EngineBase::loadAudioPolicyEngineConfig();
+ auto result = EngineBase::loadAudioPolicyEngineConfig(xmlFilePath);
// Custom XML Parsing
auto loadCriteria= [this](const auto& configCriteria, const auto& configCriterionTypes) {
@@ -401,5 +400,3 @@
} // namespace audio_policy
} // namespace android
-
-