summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/test-current.txt15
-rw-r--r--media/java/android/media/AudioManager.java15
-rw-r--r--media/java/android/media/IAudioService.aidl2
-rw-r--r--media/java/android/media/VolumePolicy.java19
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java7
5 files changed, 56 insertions, 2 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 099dbbc2764f..2ca9f2e8cdd6 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1982,6 +1982,7 @@ package android.media {
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_SETTINGS_PRIVILEGED) public float getRs2Value();
method public int getStreamMinVolumeInt(int);
method @NonNull public java.util.Map<java.lang.Integer,java.lang.Boolean> getSurroundFormats();
+ method @NonNull public android.media.VolumePolicy getVolumePolicy();
method public boolean hasRegisteredDynamicPolicy();
method @RequiresPermission(android.Manifest.permission.MODIFY_AUDIO_SETTINGS_PRIVILEGED) public boolean isCsdEnabled();
method @RequiresPermission(anyOf={android.Manifest.permission.MODIFY_AUDIO_ROUTING, android.Manifest.permission.QUERY_AUDIO_STATE, android.Manifest.permission.MODIFY_AUDIO_SETTINGS_PRIVILEGED}) public boolean isFullVolumeDevice();
@@ -2073,6 +2074,20 @@ package android.media {
method public android.media.PlaybackParams setAudioStretchMode(int);
}
+ public final class VolumePolicy implements android.os.Parcelable {
+ ctor public VolumePolicy(boolean, boolean, boolean, int);
+ method public int describeContents();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field public static final int A11Y_MODE_INDEPENDENT_A11Y_VOLUME = 1; // 0x1
+ field public static final int A11Y_MODE_MEDIA_A11Y_VOLUME = 0; // 0x0
+ field @NonNull public static final android.os.Parcelable.Creator<android.media.VolumePolicy> CREATOR;
+ field @NonNull public static final android.media.VolumePolicy DEFAULT;
+ field public final boolean doNotDisturbWhenSilent;
+ field public final int vibrateToSilentDebounce;
+ field public final boolean volumeDownToEnterSilent;
+ field public final boolean volumeUpToExitSilent;
+ }
+
public static final class VolumeShaper.Configuration.Builder {
method @NonNull public android.media.VolumeShaper.Configuration.Builder setOptionFlags(int);
}
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 124f1f0ddd43..25c767a88b17 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -7435,6 +7435,21 @@ public class AudioManager {
}
/**
+ * @hide
+ * Queries the volume policy
+ * @return the volume policy currently in use
+ */
+ @TestApi
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
+ public @NonNull VolumePolicy getVolumePolicy() {
+ try {
+ return getService().getVolumePolicy();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Set Hdmi Cec system audio mode.
*
* @param on whether to be on system audio mode
diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl
index 08cc126fb1a8..d42b25681e11 100644
--- a/media/java/android/media/IAudioService.aidl
+++ b/media/java/android/media/IAudioService.aidl
@@ -386,6 +386,8 @@ interface IAudioService {
void setVolumePolicy(in VolumePolicy policy);
+ VolumePolicy getVolumePolicy();
+
boolean hasRegisteredDynamicPolicy();
void registerRecordingCallback(in IRecordingConfigDispatcher rcdb);
diff --git a/media/java/android/media/VolumePolicy.java b/media/java/android/media/VolumePolicy.java
index b193b70bac2c..96de72dfd10d 100644
--- a/media/java/android/media/VolumePolicy.java
+++ b/media/java/android/media/VolumePolicy.java
@@ -16,39 +16,53 @@
package android.media;
+import android.annotation.NonNull;
+import android.annotation.SuppressLint;
+import android.annotation.TestApi;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Objects;
/** @hide */
+@TestApi
+@SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public final class VolumePolicy implements Parcelable {
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
+ @NonNull
public static final VolumePolicy DEFAULT = new VolumePolicy(false, false, false, 400);
/**
* Accessibility volume policy where the STREAM_MUSIC volume (i.e. media volume) affects
* the STREAM_ACCESSIBILITY volume, and vice-versa.
*/
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public static final int A11Y_MODE_MEDIA_A11Y_VOLUME = 0;
/**
* Accessibility volume policy where the STREAM_ACCESSIBILITY volume is independent from
* any other volume.
*/
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public static final int A11Y_MODE_INDEPENDENT_A11Y_VOLUME = 1;
/** Allow volume adjustments lower from vibrate to enter ringer mode = silent */
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public final boolean volumeDownToEnterSilent;
/** Allow volume adjustments higher to exit ringer mode = silent */
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public final boolean volumeUpToExitSilent;
/** Automatically enter do not disturb when ringer mode = silent */
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public final boolean doNotDisturbWhenSilent;
/** Only allow volume adjustment from vibrate to silent after this
number of milliseconds since an adjustment from normal to vibrate. */
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public final int vibrateToSilentDebounce;
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public VolumePolicy(boolean volumeDownToEnterSilent, boolean volumeUpToExitSilent,
boolean doNotDisturbWhenSilent, int vibrateToSilentDebounce) {
this.volumeDownToEnterSilent = volumeDownToEnterSilent;
@@ -82,19 +96,22 @@ public final class VolumePolicy implements Parcelable {
&& other.vibrateToSilentDebounce == vibrateToSilentDebounce;
}
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
@Override
public int describeContents() {
return 0;
}
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
@Override
- public void writeToParcel(Parcel dest, int flags) {
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(volumeDownToEnterSilent ? 1 : 0);
dest.writeInt(volumeUpToExitSilent ? 1 : 0);
dest.writeInt(doNotDisturbWhenSilent ? 1 : 0);
dest.writeInt(vibrateToSilentDebounce);
}
+ @SuppressLint("UnflaggedApi") // @TestApi without associated feature.
public static final @android.annotation.NonNull Parcelable.Creator<VolumePolicy> CREATOR
= new Parcelable.Creator<VolumePolicy>() {
@Override
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 6d9b4f547be6..0d309eb6786d 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -977,7 +977,7 @@ public class AudioService extends IAudioService.Stub
private NotificationManager mNm;
private AudioManagerInternal.RingerModeDelegate mRingerModeDelegate;
- private VolumePolicy mVolumePolicy = VolumePolicy.DEFAULT;
+ private volatile VolumePolicy mVolumePolicy = VolumePolicy.DEFAULT;
private long mLoweredFromNormalToVibrateTime;
// Array of Uids of valid assistant services to check if caller is one of them
@@ -12101,6 +12101,11 @@ public class AudioService extends IAudioService.Stub
}
}
+ @Override
+ public VolumePolicy getVolumePolicy() {
+ return mVolumePolicy;
+ }
+
/** Interface used for enforcing the safe hearing standard. */
public interface ISafeHearingVolumeController {
/** Displays an instructional safeguard as required by the safe hearing standard. */