Loading media/java/android/media/AudioManager.java +39 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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. * Loading media/java/android/media/VolumeInfo.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading
media/java/android/media/AudioManager.java +39 −0 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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. * Loading
media/java/android/media/VolumeInfo.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading