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

Commit f47bd5da authored by Vlad Popa's avatar Vlad Popa Committed by Android (Google) Code Review
Browse files

Merge "Allow STREAM_ASSISTANT in VolumeInfo" into main

parents 2828179e 3fde9ff5
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -1423,6 +1423,21 @@ public class AudioManager {
    @Retention(RetentionPolicy.SOURCE)
    public @interface PublicStreamTypes {}

    /** @hide */
    @IntDef(flag = false, prefix = "STREAM", value = {
            STREAM_VOICE_CALL,
            STREAM_SYSTEM,
            STREAM_RING,
            STREAM_MUSIC,
            STREAM_ALARM,
            STREAM_NOTIFICATION,
            STREAM_DTMF,
            STREAM_ACCESSIBILITY,
            STREAM_ASSISTANT }
    )
    @Retention(RetentionPolicy.SOURCE)
    public @interface VolumeControlStreamTypes {}

    /**
     * Returns the volume in dB (decibel) for the given stream type at the given volume index, on
     * the given type of audio output device.
@@ -1478,6 +1493,30 @@ public class AudioManager {
        }
    }

    /**
     * @hide
     * Checks whether a stream type can be used to control the volume (e.g.: as part of a
     * {@link VolumeInfo}.
     * @param streamType
     * @return true if the stream type can be used to control the volume
     */
    public static boolean isVolumeControlStreamType(int streamType) {
        switch (streamType) {
            case STREAM_VOICE_CALL:
            case STREAM_SYSTEM:
            case STREAM_RING:
            case STREAM_MUSIC:
            case STREAM_ALARM:
            case STREAM_NOTIFICATION:
            case STREAM_DTMF:
            case STREAM_ACCESSIBILITY:
            case STREAM_ASSISTANT:
                return true;
            default:
                return false;
        }
    }

    /**
     * Get last audible volume before stream was muted.
     *
+3 −3
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ public final class VolumeInfo implements Parcelable {
     */
    public static final class Builder {
        private boolean mUsesStreamType = true; // false implies AudioVolumeGroup is used
        private @AudioManager.PublicStreamTypes int mStreamType = AudioManager.STREAM_MUSIC;
        private @AudioManager.VolumeControlStreamTypes int mStreamType = AudioManager.STREAM_MUSIC;
        private boolean mHasMuteState = false;
        private boolean mIsMuted = false;
        private int mVolIndex = INDEX_NOT_SET;
@@ -217,8 +217,8 @@ public final class VolumeInfo implements Parcelable {
        /**
         * Builder constructor for stream type-based VolumeInfo
         */
        public Builder(@AudioManager.PublicStreamTypes int streamType) {
            if (!AudioManager.isPublicStreamType(streamType)) {
        public Builder(@AudioManager.VolumeControlStreamTypes int streamType) {
            if (!AudioManager.isVolumeControlStreamType(streamType)) {
                throw new IllegalArgumentException("Not a valid public stream type " + streamType);
            }
            mUsesStreamType = true;