OSDN Git Service

Fix reading attributes for playback restrictions
authorJean-Michel Trivi <jmtrivi@google.com>
Wed, 20 May 2015 20:58:18 +0000 (13:58 -0700)
committerJean-Michel Trivi <jmtrivi@google.com>
Wed, 20 May 2015 20:58:18 +0000 (13:58 -0700)
Playback restrictions can be lifted with the correct flag,
  FLAG_BYPASS_INTERRUPTION_POLICY, but this flag is for the
  system only. As such, it must be read by querying "all
  the flags" with AudioAttributes.getAllFlags() which is a
  system API which returns all the system flags. getFlags()
  only returns the public SDK flags.

Bug 19407114

Change-Id: I22dadfaf5d1b48b3c0754e1e6af00b734d790fec

media/java/android/media/AudioTrack.java
media/java/android/media/MediaPlayer.java
media/java/android/media/SoundPool.java

index d21762b..b8bbab0 100644 (file)
@@ -1502,7 +1502,7 @@ public class AudioTrack
     }
 
     private boolean isRestricted() {
-        if ((mAttributes.getFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
+        if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
             return false;
         }
         try {
index f148606..2e92c40 100644 (file)
@@ -1757,7 +1757,7 @@ public class MediaPlayer implements SubtitleController.Listener
             throw new IllegalArgumentException(msg);
         }
         mUsage = attributes.getUsage();
-        mBypassInterruptionPolicy = (attributes.getFlags()
+        mBypassInterruptionPolicy = (attributes.getAllFlags()
                 & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0;
         Parcel pattributes = Parcel.obtain();
         attributes.writeToParcel(pattributes, AudioAttributes.FLATTEN_TAGS);
index 88d979e..64863c2 100644 (file)
@@ -463,7 +463,7 @@ public class SoundPool {
     }
 
     private boolean isRestricted() {
-        if ((mAttributes.getFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
+        if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
             return false;
         }
         try {