diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/AudioAttributes.java | 17 | ||||
-rw-r--r-- | media/java/android/media/AudioTrack.java | 3 | ||||
-rw-r--r-- | media/java/android/media/MediaPlayer.java | 6 | ||||
-rw-r--r-- | media/java/android/media/SoundPool.java | 3 |
4 files changed, 28 insertions, 1 deletions
diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java index ca242e4..97919a9 100644 --- a/media/java/android/media/AudioAttributes.java +++ b/media/java/android/media/AudioAttributes.java @@ -209,8 +209,23 @@ public final class AudioAttributes implements Parcelable { @SystemApi public final static int FLAG_HW_HOTWORD = 0x1 << 5; + /** + * @hide + * Flag requesting audible playback even under limited interruptions. + */ + @SystemApi + public final static int FLAG_BYPASS_INTERRUPTION_POLICY = 0x1 << 6; + + /** + * @hide + * Flag requesting audible playback even when the underlying stream is muted. + */ + @SystemApi + public final static int FLAG_BYPASS_MUTE = 0x1 << 7; + private final static int FLAG_ALL = FLAG_AUDIBILITY_ENFORCED | FLAG_SECURE | FLAG_SCO | - FLAG_BEACON | FLAG_HW_AV_SYNC | FLAG_HW_HOTWORD; + FLAG_BEACON | FLAG_HW_AV_SYNC | FLAG_HW_HOTWORD | FLAG_BYPASS_INTERRUPTION_POLICY | + FLAG_BYPASS_MUTE; private final static int FLAG_ALL_PUBLIC = FLAG_AUDIBILITY_ENFORCED | FLAG_HW_AV_SYNC; private int mUsage = USAGE_UNKNOWN; diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index caccb6e..cd78234 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -1178,6 +1178,9 @@ public class AudioTrack } private boolean isRestricted() { + if ((mAttributes.getFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) { + return false; + } try { final int usage = AudioAttributes.usageForLegacyStreamType(mStreamType); final int mode = mAppOps.checkAudioOperation(AppOpsManager.OP_PLAY_AUDIO, usage, diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index 615dac2..fc372eb 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -604,6 +604,7 @@ public class MediaPlayer implements SubtitleController.Listener private final IAppOpsService mAppOps; private int mStreamType = AudioManager.USE_DEFAULT_STREAM_TYPE; private int mUsage = -1; + private boolean mBypassInterruptionPolicy; /** * Default constructor. Consider using one of the create() methods for @@ -1169,6 +1170,9 @@ public class MediaPlayer implements SubtitleController.Listener private native void _start() throws IllegalStateException; private boolean isRestricted() { + if (mBypassInterruptionPolicy) { + return false; + } try { final int usage = mUsage != -1 ? mUsage : AudioAttributes.usageForLegacyStreamType(getAudioStreamType()); @@ -1560,6 +1564,8 @@ public class MediaPlayer implements SubtitleController.Listener throw new IllegalArgumentException(msg); } mUsage = attributes.getUsage(); + mBypassInterruptionPolicy = (attributes.getFlags() + & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0; Parcel pattributes = Parcel.obtain(); attributes.writeToParcel(pattributes, AudioAttributes.FLATTEN_TAGS); setParameter(KEY_PARAMETER_AUDIO_ATTRIBUTES, pattributes); diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java index 32d5b82..db6b38b 100644 --- a/media/java/android/media/SoundPool.java +++ b/media/java/android/media/SoundPool.java @@ -608,6 +608,9 @@ public class SoundPool { int priority, int loop, float rate); private boolean isRestricted() { + if ((mAttributes.getFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) { + return false; + } try { final int mode = mAppOps.checkAudioOperation(AppOpsManager.OP_PLAY_AUDIO, mAttributes.getUsage(), |