summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Rocard <krocard@google.com> 2019-03-19 02:52:22 -0700
committer Kevin Rocard <krocard@google.com> 2019-03-21 05:49:06 +0000
commita7aafac2cff169cca322b9c47663eb2ad461009b (patch)
tree75f0257be8ee26bc42317e22a5af4c0eedc98bc0
parent865351445040bb6c9ec8df08d6df0084215c37d3 (diff)
AudioMix: Do not compare rules of different types
That would lead to NullPointerException as some fields of AudioMixMatchCriterion are null in some type but not others. When first registering a UID rule, the register criterion had a null mAttr. If a USAGE criterion was then added, it would be compared to the exsting rule as if it was an USAGE rule. As mAttr was null, a NullPointerException was thrown. Test: first register a UID rule, then a USAGE rule. Test: atest android.media.cts.AudioPlaybackCaptureTest#testCaptureMediaUsage Bug: 111453086 Change-Id: Iece913b87a627171c0a1f872aa57c5125d0ba782 Signed-off-by: Kevin Rocard <krocard@google.com>
-rw-r--r--media/java/android/media/audiopolicy/AudioMixingRule.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/media/java/android/media/audiopolicy/AudioMixingRule.java b/media/java/android/media/audiopolicy/AudioMixingRule.java
index 6c48cdb7b643..d41f416f3d51 100644
--- a/media/java/android/media/audiopolicy/AudioMixingRule.java
+++ b/media/java/android/media/audiopolicy/AudioMixingRule.java
@@ -409,6 +409,10 @@ public class AudioMixingRule {
final int match_rule = rule & ~RULE_EXCLUSION_MASK;
while (crIterator.hasNext()) {
final AudioMixMatchCriterion criterion = crIterator.next();
+
+ if ((criterion.mRule & ~RULE_EXCLUSION_MASK) != match_rule) {
+ continue; // The two rules are not of the same type
+ }
switch (match_rule) {
case RULE_MATCH_ATTRIBUTE_USAGE:
// "usage"-based rule