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

Commit 2934897e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "AudioAttributes: set content type to UNKNOWN for init from stream" into main

parents e09e2341 2eb20ebb
Loading
Loading
Loading
Loading
+45 −44
Original line number Diff line number Diff line
@@ -1167,7 +1167,10 @@ public final class AudioAttributes implements Parcelable {
                                streamType);
                if (attributes != null) {
                    mUsage = attributes.mUsage;
                    mContentType = attributes.mContentType;
                    // on purpose ignoring the content type: stream types are deprecated for
                    // playback, making assumptions about the content type is prone to
                    // interpretation errors for ambiguous types such as STREAM_TTS and STREAM_MUSIC
                    //mContentType = attributes.mContentType;
                    mFlags = attributes.getAllFlags();
                    mMuteHapticChannels = attributes.areHapticChannelsMuted();
                    mIsContentSpatialized = attributes.isContentSpatialized();
@@ -1177,7 +1180,6 @@ public final class AudioAttributes implements Parcelable {
                    mSource = attributes.mSource;
                }
            }
            if (mContentType == CONTENT_TYPE_UNKNOWN) {
            switch (streamType) {
                case AudioSystem.STREAM_VOICE_CALL:
                    mContentType = CONTENT_TYPE_SPEECH;
@@ -1191,9 +1193,6 @@ public final class AudioAttributes implements Parcelable {
                case AudioSystem.STREAM_RING:
                    mContentType = CONTENT_TYPE_SONIFICATION;
                    break;
                    case AudioSystem.STREAM_MUSIC:
                        mContentType = CONTENT_TYPE_MUSIC;
                        break;
                case AudioSystem.STREAM_ALARM:
                    mContentType = CONTENT_TYPE_SONIFICATION;
                    break;
@@ -1217,10 +1216,12 @@ public final class AudioAttributes implements Parcelable {
                case AudioSystem.STREAM_ASSISTANT:
                    mContentType = CONTENT_TYPE_SPEECH;
                    break;
                case AudioSystem.STREAM_MUSIC:
                    // leaving as CONTENT_TYPE_UNKNOWN
                    break;
                default:
                    Log.e(TAG, "Invalid stream type " + streamType + " for AudioAttributes");
            }
            }
            if (mUsage == USAGE_UNKNOWN) {
                mUsage = usageForStreamType(streamType);
            }