Merge "SoundPool: fix enforced camera shutter sound" into nyc-dev
This commit is contained in:
@@ -133,6 +133,8 @@ public class SoundPool {
|
|||||||
private final IAppOpsService mAppOps;
|
private final IAppOpsService mAppOps;
|
||||||
private final IAppOpsCallback mAppOpsCallback;
|
private final IAppOpsCallback mAppOpsCallback;
|
||||||
|
|
||||||
|
private static IAudioService sService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Constructs a SoundPool object with the following
|
* Constructor. Constructs a SoundPool object with the following
|
||||||
* characteristics:
|
* 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() {
|
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) {
|
if ((mAttributes.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user