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

Commit e6d280d6 authored by François Gaffie's avatar François Gaffie Committed by Hongwei Wang
Browse files

Use AudioProductStrategies within AudioAttributes



AudioProductStrategies allows to avoid any hard coded operation in AOSP,
and the matching between the stream type and the attributes can also
be exposed by the XML audio policy engine configuration file.
This CL updates the AudioAttributes to make use of product strategies
to implement the legacy conversion between stream type and attributes.
It will continue fallbacking in hard coded mapping.

Bug: 124767636
Test: dumpsys media.audio_policy
Signed-off-by: default avatarFrançois Gaffie <francois.gaffie@renault.com>
Change-Id: I143403a81e363ed064cb8b422e5ca53cb4b6e18b
parent b4264999
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.UnsupportedAppUsage;
import android.media.audiopolicy.AudioProductStrategies;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
@@ -725,6 +726,13 @@ public final class AudioAttributes implements Parcelable {
         */
        @UnsupportedAppUsage
        public Builder setInternalLegacyStreamType(int streamType) {
            final AudioProductStrategies ps = new AudioProductStrategies();
            if (ps.size() > 0) {
                AudioAttributes attributes = ps.getAudioAttributesForLegacyStreamType(streamType);
                if (attributes != null) {
                    return new Builder(attributes);
                }
            }
            switch(streamType) {
                case AudioSystem.STREAM_VOICE_CALL:
                    mContentType = CONTENT_TYPE_SPEECH;
@@ -1100,6 +1108,10 @@ public final class AudioAttributes implements Parcelable {
                    AudioSystem.STREAM_MUSIC : AudioSystem.STREAM_TTS;
        }

        final AudioProductStrategies ps = new AudioProductStrategies();
        if (ps.size() > 0) {
            return ps.getLegacyStreamTypeForAudioAttributes(aa);
        }
        // usage to stream type mapping
        switch (aa.getUsage()) {
            case USAGE_MEDIA: