[AudioPolicy][Engine] Attributes of strategy not populated
The assistant new stream CL has broken the strategies without
stream types. The attributes are not populated anymore preventing
to retrieve the volume group from attributes.
Bug: 136121584
Test: run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioProductStrategyTest
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioVolumeGroupTest
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioVolumeGroupChangeHandlerTest
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testPermissionsForVolumePerAttributes
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testGetAndValidateProductStrategies
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testGetAndValidateVolumeGroups
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testSetGetVolumePerAttributesWithInvalidAttributes
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testSetGetVolumePerAttributes
run cts-dev -m CtsMediaTestCase --test android.media.cts.AudioManagerTest#testVolumeGroupCallback
Change-Id: I15a14e4cf85e6c4bbf09db24bb33b4b9fb9cab54
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
diff --git a/services/audiopolicy/engine/common/src/EngineBase.cpp b/services/audiopolicy/engine/common/src/EngineBase.cpp
index 525e965..c547559 100644
--- a/services/audiopolicy/engine/common/src/EngineBase.cpp
+++ b/services/audiopolicy/engine/common/src/EngineBase.cpp
@@ -125,8 +125,7 @@
}
return volumeGroup;
};
- auto addSupportedStreamAttributes = [](auto &group, auto &volumeGroup, auto &strategy) {
- volumeGroup->addSupportedStream(group.stream);
+ auto addSupportedAttributesToGroup = [](auto &group, auto &volumeGroup, auto &strategy) {
for (const auto &attr : group.attributesVect) {
strategy->addAttributes({group.stream, volumeGroup->getId(), attr});
volumeGroup->addSupportedAttributes(attr);
@@ -166,18 +165,21 @@
const auto &iter = std::find_if(begin(mVolumeGroups), end(mVolumeGroups),
[&group](const auto &volumeGroup) {
return group.volumeGroup == volumeGroup.second->getName(); });
- if (group.stream != AUDIO_STREAM_DEFAULT) {
- if (iter == end(mVolumeGroups)) {
- ALOGW("%s: No configuration of %s found, using default volume configuration"
- , __FUNCTION__, group.volumeGroup.c_str());
- defaultVolumeConfig.name = group.volumeGroup;
- sp<VolumeGroup> volumeGroup =
- loadVolumeConfig(mVolumeGroups, defaultVolumeConfig);
- addSupportedStreamAttributes(group, volumeGroup, strategy);
- } else {
- addSupportedStreamAttributes(group, iter->second, strategy);
- }
+ sp<VolumeGroup> volumeGroup = nullptr;
+ // If no volume group provided for this strategy, creates a new one using
+ // Music Volume Group configuration (considered as the default)
+ if (iter == end(mVolumeGroups)) {
+ ALOGW("%s: No configuration of %s found, using default volume configuration"
+ , __FUNCTION__, group.volumeGroup.c_str());
+ defaultVolumeConfig.name = group.volumeGroup;
+ volumeGroup = loadVolumeConfig(mVolumeGroups, defaultVolumeConfig);
+ } else {
+ volumeGroup = iter->second;
}
+ if (group.stream != AUDIO_STREAM_DEFAULT) {
+ volumeGroup->addSupportedStream(group.stream);
+ }
+ addSupportedAttributesToGroup(group, volumeGroup, strategy);
}
product_strategy_t strategyId = strategy->getId();
mProductStrategies[strategyId] = strategy;