diff options
author | John Spurlock <jspurlock@google.com> | 2015-02-18 11:58:14 -0500 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2015-02-18 20:48:26 -0500 |
commit | bbfd31a5d4f126167e20fa8bd256c810cf8c2c85 (patch) | |
tree | 39df4b4ce2919465b8983000473ffefd6db7b581 /media | |
parent | fadfc4e11b86d2f66dd56f10120840b772da3bc8 (diff) | |
download | frameworks_base-bbfd31a5d4f126167e20fa8bd256c810cf8c2c85.zip frameworks_base-bbfd31a5d4f126167e20fa8bd256c810cf8c2c85.tar.gz frameworks_base-bbfd31a5d4f126167e20fa8bd256c810cf8c2c85.tar.bz2 |
AudioAttributes: introduce new flags to bypass audio restrictions.
- New @hidden @SystemApi FLAG_BYPASS_INTERRUPTION_POLICY, request
to ignore any current audio restrictions, such as zen mode
content-based notification filtering.
- Wire up FLAG_BYPASS_INTERRUPTION_POLICY to the existing
audio restriction checks in the framework.
- New @hidden @SystemApi FLAG_BYPASS_MUTE, request to play
audibly, even if the underlying stream is muted.
- Wiring up to audio framework TBD.
- Use both of these new flags on the inline volume slider
controls used in Settings, ensuring playback is heard
regardless of the current device filter state.
Bug: 19407114
Change-Id: I3d44394931592ccbc1b61ddd9a4d1cc984da17cc
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(), |