Loading core/api/system-current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -7879,7 +7879,8 @@ package android.media { method public int getStreamType(); method @NonNull public android.media.audiopolicy.AudioVolumeGroup getVolumeGroup(); method public int getVolumeIndex(); method public boolean hasMuteCommand(); method @Deprecated @FlaggedApi("android.media.audio.device_volume_apis") public boolean hasMuteCommand(); method @FlaggedApi("android.media.audio.device_volume_apis") public boolean hasMuteState(); method public boolean hasStreamType(); method public boolean hasVolumeGroup(); method public boolean isMuted(); media/java/android/media/VolumeInfo.java +29 −14 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package android.media; import static android.media.audio.Flags.FLAG_DEVICE_VOLUME_APIS; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; Loading Loading @@ -44,7 +47,7 @@ public final class VolumeInfo implements Parcelable { private static final String TAG = "VolumeInfo"; private final boolean mUsesStreamType; // false implies AudioVolumeGroup is used private final boolean mHasMuteCommand; private final boolean mHasMuteState; private final boolean mIsMuted; private final int mVolIndex; private final int mMinVolIndex; Loading @@ -55,11 +58,11 @@ public final class VolumeInfo implements Parcelable { private static IAudioService sService; private static VolumeInfo sDefaultVolumeInfo; private VolumeInfo(boolean usesStreamType, boolean hasMuteCommand, boolean isMuted, private VolumeInfo(boolean usesStreamType, boolean hasMuteState, boolean isMuted, int volIndex, int minVolIndex, int maxVolIndex, AudioVolumeGroup volGroup, int streamType) { mUsesStreamType = usesStreamType; mHasMuteCommand = hasMuteCommand; mHasMuteState = hasMuteState; mIsMuted = isMuted; mVolIndex = volIndex; mMinVolIndex = minVolIndex; Loading Loading @@ -117,9 +120,21 @@ public final class VolumeInfo implements Parcelable { /** * Return whether this instance is conveying a mute state * @return true if the muted state was explicitly set for this instance * @deprecated use {@link #hasMuteState()} instead */ @Deprecated @FlaggedApi(FLAG_DEVICE_VOLUME_APIS) public boolean hasMuteCommand() { return mHasMuteCommand; return mHasMuteState; } /** * Return whether this instance is conveying a mute state * @return true if the muted state was explicitly set for this instance */ @FlaggedApi(FLAG_DEVICE_VOLUME_APIS) public boolean hasMuteState() { return mHasMuteState; } /** Loading Loading @@ -192,7 +207,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 boolean mHasMuteCommand = false; private boolean mHasMuteState = false; private boolean mIsMuted = false; private int mVolIndex = INDEX_NOT_SET; private int mMinVolIndex = INDEX_NOT_SET; Loading Loading @@ -228,7 +243,7 @@ public final class VolumeInfo implements Parcelable { Objects.requireNonNull(info); mUsesStreamType = info.mUsesStreamType; mStreamType = info.mStreamType; mHasMuteCommand = info.mHasMuteCommand; mHasMuteState = info.mHasMuteState; mIsMuted = info.mIsMuted; mVolIndex = info.mVolIndex; mMinVolIndex = info.mMinVolIndex; Loading @@ -242,7 +257,7 @@ public final class VolumeInfo implements Parcelable { * @return the same builder instance */ public @NonNull Builder setMuted(boolean isMuted) { mHasMuteCommand = true; mHasMuteState = true; mIsMuted = isMuted; return this; } Loading Loading @@ -306,7 +321,7 @@ public final class VolumeInfo implements Parcelable { throw new IllegalArgumentException("Min volume index:" + mMinVolIndex + " greater than max index:" + mMaxVolIndex); } return new VolumeInfo(mUsesStreamType, mHasMuteCommand, mIsMuted, return new VolumeInfo(mUsesStreamType, mHasMuteState, mIsMuted, mVolIndex, mMinVolIndex, mMaxVolIndex, mVolGroup, mStreamType); } Loading @@ -316,7 +331,7 @@ public final class VolumeInfo implements Parcelable { // Parcelable @Override public int hashCode() { return Objects.hash(mUsesStreamType, mHasMuteCommand, mStreamType, mIsMuted, return Objects.hash(mUsesStreamType, mHasMuteState, mStreamType, mIsMuted, mVolIndex, mMinVolIndex, mMaxVolIndex, mVolGroup); } Loading @@ -328,7 +343,7 @@ public final class VolumeInfo implements Parcelable { VolumeInfo that = (VolumeInfo) o; return ((mUsesStreamType == that.mUsesStreamType) && (mStreamType == that.mStreamType) && (mHasMuteCommand == that.mHasMuteCommand) && (mHasMuteState == that.mHasMuteState) && (mIsMuted == that.mIsMuted) && (mVolIndex == that.mVolIndex) && (mMinVolIndex == that.mMinVolIndex) Loading @@ -341,7 +356,7 @@ public final class VolumeInfo implements Parcelable { return new String("VolumeInfo:" + (mUsesStreamType ? (" streamType:" + mStreamType) : (" volGroup:" + mVolGroup)) + (mHasMuteCommand ? (" muted:" + mIsMuted) : ("[no mute cmd]")) + (mHasMuteState ? (" muted:" + mIsMuted) : ("[no mute cmd]")) + ((mVolIndex != INDEX_NOT_SET) ? (" volIndex:" + mVolIndex) : "") + ((mMinVolIndex != INDEX_NOT_SET) ? (" min:" + mMinVolIndex) : "") + ((mMaxVolIndex != INDEX_NOT_SET) ? (" max:" + mMaxVolIndex) : "")); Loading @@ -356,7 +371,7 @@ public final class VolumeInfo implements Parcelable { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeBoolean(mUsesStreamType); dest.writeInt(mStreamType); dest.writeBoolean(mHasMuteCommand); dest.writeBoolean(mHasMuteState); dest.writeBoolean(mIsMuted); dest.writeInt(mVolIndex); dest.writeInt(mMinVolIndex); Loading @@ -369,7 +384,7 @@ public final class VolumeInfo implements Parcelable { private VolumeInfo(@NonNull Parcel in) { mUsesStreamType = in.readBoolean(); mStreamType = in.readInt(); mHasMuteCommand = in.readBoolean(); mHasMuteState = in.readBoolean(); mIsMuted = in.readBoolean(); mVolIndex = in.readInt(); mMinVolIndex = in.readInt(); Loading @@ -382,7 +397,7 @@ public final class VolumeInfo implements Parcelable { } public static final @NonNull Parcelable.Creator<VolumeInfo> CREATOR = new Parcelable.Creator<VolumeInfo>() { new Parcelable.Creator<>() { /** * Rebuilds a VolumeInfo previously stored with writeToParcel(). * @param p Parcel object to read the VolumeInfo from Loading services/core/java/com/android/server/audio/AudioService.java +5 −2 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import static android.media.audio.Flags.autoPublicVolumeApiHardening; import static android.media.audio.Flags.cacheGetStreamMinMaxVolume; import static android.media.audio.Flags.cacheGetStreamVolume; import static android.media.audio.Flags.concurrentAudioRecordBypassPermission; import static android.media.audio.Flags.deviceVolumeApis; import static android.media.audio.Flags.featureSpatialAudioHeadtrackingLowLatency; import static android.media.audio.Flags.focusFreezeTestApi; import static android.media.audio.Flags.registerVolumeCallbackApiHardening; Loading Loading @@ -4792,7 +4793,8 @@ public class AudioService extends IAudioService.Stub } int index = vi.getVolumeIndex(); if (index == VolumeInfo.INDEX_NOT_SET && !vi.hasMuteCommand()) { boolean hasMuteState = deviceVolumeApis() ? vi.hasMuteState() : vi.hasMuteCommand(); if (index == VolumeInfo.INDEX_NOT_SET && !hasMuteState) { throw new IllegalArgumentException( "changing device volume requires a volume index or mute command"); } Loading @@ -4805,7 +4807,8 @@ public class AudioService extends IAudioService.Stub int index = vi.getVolumeIndex(); // if a stream is not muted but the VolumeInfo is for muting, set the volume index // for the device to min volume if (vi.hasMuteCommand() && vi.isMuted() && !isStreamMute(streamType)) { boolean hasMuteState = deviceVolumeApis() ? vi.hasMuteState() : vi.hasMuteCommand(); if (hasMuteState && vi.isMuted() && !isStreamMute(streamType)) { setStreamVolumeWithAttributionInt(streamType, vss.getMinIndex(), flags, Loading Loading
core/api/system-current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -7879,7 +7879,8 @@ package android.media { method public int getStreamType(); method @NonNull public android.media.audiopolicy.AudioVolumeGroup getVolumeGroup(); method public int getVolumeIndex(); method public boolean hasMuteCommand(); method @Deprecated @FlaggedApi("android.media.audio.device_volume_apis") public boolean hasMuteCommand(); method @FlaggedApi("android.media.audio.device_volume_apis") public boolean hasMuteState(); method public boolean hasStreamType(); method public boolean hasVolumeGroup(); method public boolean isMuted();
media/java/android/media/VolumeInfo.java +29 −14 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package android.media; import static android.media.audio.Flags.FLAG_DEVICE_VOLUME_APIS; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; Loading Loading @@ -44,7 +47,7 @@ public final class VolumeInfo implements Parcelable { private static final String TAG = "VolumeInfo"; private final boolean mUsesStreamType; // false implies AudioVolumeGroup is used private final boolean mHasMuteCommand; private final boolean mHasMuteState; private final boolean mIsMuted; private final int mVolIndex; private final int mMinVolIndex; Loading @@ -55,11 +58,11 @@ public final class VolumeInfo implements Parcelable { private static IAudioService sService; private static VolumeInfo sDefaultVolumeInfo; private VolumeInfo(boolean usesStreamType, boolean hasMuteCommand, boolean isMuted, private VolumeInfo(boolean usesStreamType, boolean hasMuteState, boolean isMuted, int volIndex, int minVolIndex, int maxVolIndex, AudioVolumeGroup volGroup, int streamType) { mUsesStreamType = usesStreamType; mHasMuteCommand = hasMuteCommand; mHasMuteState = hasMuteState; mIsMuted = isMuted; mVolIndex = volIndex; mMinVolIndex = minVolIndex; Loading Loading @@ -117,9 +120,21 @@ public final class VolumeInfo implements Parcelable { /** * Return whether this instance is conveying a mute state * @return true if the muted state was explicitly set for this instance * @deprecated use {@link #hasMuteState()} instead */ @Deprecated @FlaggedApi(FLAG_DEVICE_VOLUME_APIS) public boolean hasMuteCommand() { return mHasMuteCommand; return mHasMuteState; } /** * Return whether this instance is conveying a mute state * @return true if the muted state was explicitly set for this instance */ @FlaggedApi(FLAG_DEVICE_VOLUME_APIS) public boolean hasMuteState() { return mHasMuteState; } /** Loading Loading @@ -192,7 +207,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 boolean mHasMuteCommand = false; private boolean mHasMuteState = false; private boolean mIsMuted = false; private int mVolIndex = INDEX_NOT_SET; private int mMinVolIndex = INDEX_NOT_SET; Loading Loading @@ -228,7 +243,7 @@ public final class VolumeInfo implements Parcelable { Objects.requireNonNull(info); mUsesStreamType = info.mUsesStreamType; mStreamType = info.mStreamType; mHasMuteCommand = info.mHasMuteCommand; mHasMuteState = info.mHasMuteState; mIsMuted = info.mIsMuted; mVolIndex = info.mVolIndex; mMinVolIndex = info.mMinVolIndex; Loading @@ -242,7 +257,7 @@ public final class VolumeInfo implements Parcelable { * @return the same builder instance */ public @NonNull Builder setMuted(boolean isMuted) { mHasMuteCommand = true; mHasMuteState = true; mIsMuted = isMuted; return this; } Loading Loading @@ -306,7 +321,7 @@ public final class VolumeInfo implements Parcelable { throw new IllegalArgumentException("Min volume index:" + mMinVolIndex + " greater than max index:" + mMaxVolIndex); } return new VolumeInfo(mUsesStreamType, mHasMuteCommand, mIsMuted, return new VolumeInfo(mUsesStreamType, mHasMuteState, mIsMuted, mVolIndex, mMinVolIndex, mMaxVolIndex, mVolGroup, mStreamType); } Loading @@ -316,7 +331,7 @@ public final class VolumeInfo implements Parcelable { // Parcelable @Override public int hashCode() { return Objects.hash(mUsesStreamType, mHasMuteCommand, mStreamType, mIsMuted, return Objects.hash(mUsesStreamType, mHasMuteState, mStreamType, mIsMuted, mVolIndex, mMinVolIndex, mMaxVolIndex, mVolGroup); } Loading @@ -328,7 +343,7 @@ public final class VolumeInfo implements Parcelable { VolumeInfo that = (VolumeInfo) o; return ((mUsesStreamType == that.mUsesStreamType) && (mStreamType == that.mStreamType) && (mHasMuteCommand == that.mHasMuteCommand) && (mHasMuteState == that.mHasMuteState) && (mIsMuted == that.mIsMuted) && (mVolIndex == that.mVolIndex) && (mMinVolIndex == that.mMinVolIndex) Loading @@ -341,7 +356,7 @@ public final class VolumeInfo implements Parcelable { return new String("VolumeInfo:" + (mUsesStreamType ? (" streamType:" + mStreamType) : (" volGroup:" + mVolGroup)) + (mHasMuteCommand ? (" muted:" + mIsMuted) : ("[no mute cmd]")) + (mHasMuteState ? (" muted:" + mIsMuted) : ("[no mute cmd]")) + ((mVolIndex != INDEX_NOT_SET) ? (" volIndex:" + mVolIndex) : "") + ((mMinVolIndex != INDEX_NOT_SET) ? (" min:" + mMinVolIndex) : "") + ((mMaxVolIndex != INDEX_NOT_SET) ? (" max:" + mMaxVolIndex) : "")); Loading @@ -356,7 +371,7 @@ public final class VolumeInfo implements Parcelable { public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeBoolean(mUsesStreamType); dest.writeInt(mStreamType); dest.writeBoolean(mHasMuteCommand); dest.writeBoolean(mHasMuteState); dest.writeBoolean(mIsMuted); dest.writeInt(mVolIndex); dest.writeInt(mMinVolIndex); Loading @@ -369,7 +384,7 @@ public final class VolumeInfo implements Parcelable { private VolumeInfo(@NonNull Parcel in) { mUsesStreamType = in.readBoolean(); mStreamType = in.readInt(); mHasMuteCommand = in.readBoolean(); mHasMuteState = in.readBoolean(); mIsMuted = in.readBoolean(); mVolIndex = in.readInt(); mMinVolIndex = in.readInt(); Loading @@ -382,7 +397,7 @@ public final class VolumeInfo implements Parcelable { } public static final @NonNull Parcelable.Creator<VolumeInfo> CREATOR = new Parcelable.Creator<VolumeInfo>() { new Parcelable.Creator<>() { /** * Rebuilds a VolumeInfo previously stored with writeToParcel(). * @param p Parcel object to read the VolumeInfo from Loading
services/core/java/com/android/server/audio/AudioService.java +5 −2 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import static android.media.audio.Flags.autoPublicVolumeApiHardening; import static android.media.audio.Flags.cacheGetStreamMinMaxVolume; import static android.media.audio.Flags.cacheGetStreamVolume; import static android.media.audio.Flags.concurrentAudioRecordBypassPermission; import static android.media.audio.Flags.deviceVolumeApis; import static android.media.audio.Flags.featureSpatialAudioHeadtrackingLowLatency; import static android.media.audio.Flags.focusFreezeTestApi; import static android.media.audio.Flags.registerVolumeCallbackApiHardening; Loading Loading @@ -4792,7 +4793,8 @@ public class AudioService extends IAudioService.Stub } int index = vi.getVolumeIndex(); if (index == VolumeInfo.INDEX_NOT_SET && !vi.hasMuteCommand()) { boolean hasMuteState = deviceVolumeApis() ? vi.hasMuteState() : vi.hasMuteCommand(); if (index == VolumeInfo.INDEX_NOT_SET && !hasMuteState) { throw new IllegalArgumentException( "changing device volume requires a volume index or mute command"); } Loading @@ -4805,7 +4807,8 @@ public class AudioService extends IAudioService.Stub int index = vi.getVolumeIndex(); // if a stream is not muted but the VolumeInfo is for muting, set the volume index // for the device to min volume if (vi.hasMuteCommand() && vi.isMuted() && !isStreamMute(streamType)) { boolean hasMuteState = deviceVolumeApis() ? vi.hasMuteState() : vi.hasMuteCommand(); if (hasMuteState && vi.isMuted() && !isStreamMute(streamType)) { setStreamVolumeWithAttributionInt(streamType, vss.getMinIndex(), flags, Loading