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

Commit aba3b4b4 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

audiopolicy: Fix dump for AudioPolicyMix criterias

The dump code was not using AudioMixMatchCriterion class fields
correctly.

Bug: 112151391
Test: 1. run and pause AudioPolicyTest#testMixByUidCapturing
      2. adb shell dumpsys media.audio_policy

Change-Id: I5f74a0e6dc1a7039eab1470402179b7f9d1cd962
parent c70268aa
Loading
Loading
Loading
Loading
+20 −23
Original line number Diff line number Diff line
@@ -47,32 +47,29 @@ void AudioPolicyMix::dump(String8 *dst, int spaces, int index) const

    int indexCriterion = 0;
    for (const auto &criterion : mCriteria) {
        dst->appendFormat("%*s- Criterion %d:\n", spaces + 2, "", indexCriterion++);

        std::string usageLiteral;
        if (!UsageTypeConverter::toString(criterion.mValue.mUsage, usageLiteral)) {
            ALOGE("%s: failed to convert usage %d", __FUNCTION__, criterion.mValue.mUsage);
            return;
        }
        dst->appendFormat("%*s- Usage:%s\n", spaces + 4, "", usageLiteral.c_str());

        if (mMixType == MIX_TYPE_RECORDERS) {
            std::string sourceLiteral;
            if (!SourceTypeConverter::toString(criterion.mValue.mSource, sourceLiteral)) {
                ALOGE("%s: failed to convert source %d", __FUNCTION__, criterion.mValue.mSource);
                return;
            }
            dst->appendFormat("%*s- Source:%s\n", spaces + 4, "", sourceLiteral.c_str());
        dst->appendFormat("%*s- Criterion %d: ", spaces + 2, "", indexCriterion++);

        std::string ruleType, ruleValue;
        bool unknownRule = !RuleTypeConverter::toString(criterion.mRule, ruleType);
        switch (criterion.mRule & ~RULE_EXCLUSION_MASK) { // no need to match RULE_EXCLUDE_...
        case RULE_MATCH_ATTRIBUTE_USAGE:
            UsageTypeConverter::toString(criterion.mValue.mUsage, ruleValue);
            break;
        case RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET:
            SourceTypeConverter::toString(criterion.mValue.mSource, ruleValue);
            break;
        case RULE_MATCH_UID:
            ruleValue = std::to_string(criterion.mValue.mUid);
            break;
        default:
            unknownRule = true;
        }
        dst->appendFormat("%*s- Uid:%d\n", spaces + 4, "", criterion.mValue.mUid);

        std::string ruleLiteral;
        if (!RuleTypeConverter::toString(criterion.mRule, ruleLiteral)) {
            ALOGE("%s: failed to convert source %d", __FUNCTION__,criterion.mRule);
            return;
        if (!unknownRule) {
            dst->appendFormat("%s %s\n", ruleType.c_str(), ruleValue.c_str());
        } else {
            dst->appendFormat("Unknown rule type value 0x%x\n", criterion.mRule);
        }
        dst->appendFormat("%*s- Rule:%s\n", spaces + 4, "", ruleLiteral.c_str());
    }
}

+0 −1
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ const RouteFlagTypeConverter::Table RouteFlagTypeConverter::mTable[] = {

template <>
const RuleTypeConverter::Table RuleTypeConverter::mTable[] = {
    MAKE_STRING_FROM_ENUM(RULE_EXCLUSION_MASK),
    MAKE_STRING_FROM_ENUM(RULE_MATCH_ATTRIBUTE_USAGE),
    MAKE_STRING_FROM_ENUM(RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET),
    MAKE_STRING_FROM_ENUM(RULE_MATCH_UID),