Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7aafac2 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

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: default avatarKevin Rocard <krocard@google.com>
parent 86535144
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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