summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2016-07-07 11:35:13 -0700
committerThe Android Automerger <android-build@google.com>2016-07-07 13:43:28 -0700
commit56f591326f37b84f284918feb48c88daff0c7c72 (patch)
tree901f52a307978647c96fc3dd55f885932a7ff240
parentbd850641ae7cbd0ce56a3f7a69f30ce39ea0c579 (diff)
downloadbase-56f591326f37b84f284918feb48c88daff0c7c72.tar.gz
SoundPool: fix enforced camera shutter sound
Make sure that camera shutter sound is played in total silence DND mode when enforced by country regulation. Bug: 29973005 Change-Id: I208f7ae5b07777eac48597f68feae6358999b2c3
-rw-r--r--media/java/android/media/SoundPool.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java
index 3164930aa749..5ede1d5f7c91 100644
--- a/media/java/android/media/SoundPool.java
+++ b/media/java/android/media/SoundPool.java
@@ -133,6 +133,8 @@ public class SoundPool {
private final IAppOpsService mAppOps;
private final IAppOpsCallback mAppOpsCallback;
+ private static IAudioService sService;
+
/**
* Constructor. Constructs a SoundPool object with the following
* characteristics:
@@ -492,7 +494,34 @@ public class SoundPool {
}
}
+ private static IAudioService getService()
+ {
+ if (sService != null) {
+ return sService;
+ }
+ IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE);
+ sService = IAudioService.Stub.asInterface(b);
+ return sService;
+ }
+
private boolean isRestricted() {
+ IAudioService service = getService();
+ boolean cameraSoundForced = false;
+
+ try {
+ cameraSoundForced = service.isCameraSoundForced();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Cannot access AudioService in isRestricted()");
+ }
+
+ if (cameraSoundForced &&
+ ((mAttributes.getAllFlags() & AudioAttributes.FLAG_AUDIBILITY_ENFORCED) != 0)
+// FIXME: should also check usage when set properly by camera app
+// && (mAttributes.getUsage() == AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
+ ) {
+ return false;
+ }
+
if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
return false;
}