Fix incorrect getDeviceAndMixForInputSource matching logic
...and refactor mix matching in AudioPolicyMix.
The logic for matching the mix for output is (not changed) following:
- If any of the exclude criteria are matched, the mix does not match.
- For any of the positive criteria "dimensions" (usage, uid, etc..)
present at least one criterion must match for the mix to match.
The input matching originally didn't follow this logic, it was
implemented in a way that if any criterion matched the whole mix was
considered matched. This also caused that exclude criterion caused
the mix to match anything except the excluded condition (adding
exclude criterion for non-existing UID would cause the mix to always
match). See b/245298949 for more details. With this cl, the input mix
matching follows the same logic as used for output (above).
Bug: 233910083
Bug: 245298949
Test: atest AudioServiceHostTest AudioHostTest AudioPolicyHostTest
Test: audiosystem_tests audiopolicy_tests
Change-Id: Ib4f2e8f3b4c8b39da5688f3d5ba2359af2868957
diff --git a/services/audiopolicy/engineconfigurable/src/Engine.cpp b/services/audiopolicy/engineconfigurable/src/Engine.cpp
index 3d74920..2831a9b 100644
--- a/services/audiopolicy/engineconfigurable/src/Engine.cpp
+++ b/services/audiopolicy/engineconfigurable/src/Engine.cpp
@@ -333,7 +333,7 @@
return device;
}
- device = policyMixes.getDeviceAndMixForInputSource(attr.source,
+ device = policyMixes.getDeviceAndMixForInputSource(attr,
availableInputDevices,
uid,
mix);