Merge "camera2: legacy: disable shutter sounds unconditionally via camera2 api" into lmp-dev
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index eadfa73..310ab76 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -1558,6 +1558,26 @@
return _enableShutterSound(enabled);
}
+ /**
+ * Disable the shutter sound unconditionally.
+ *
+ * <p>
+ * This is only guaranteed to work for legacy cameras
+ * (i.e. initialized with {@link #cameraInitUnspecified}). Trying to call this on
+ * a regular camera will force a conditional check in the camera service.
+ * </p>
+ *
+ * @return {@code true} if the shutter sound state was successfully
+ * changed. {@code false} if the shutter sound state could not be
+ * changed. {@code true} is also returned if shutter sound playback
+ * is already set to the requested state.
+ *
+ * @hide
+ */
+ public final boolean disableShutterSound() {
+ return _enableShutterSound(/*enabled*/false);
+ }
+
private native final boolean _enableShutterSound(boolean enabled);
/**
diff --git a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java
index c68d8c3..5cbf109 100644
--- a/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java
+++ b/core/java/android/hardware/camera2/legacy/CameraDeviceUserShim.java
@@ -56,6 +56,7 @@
* Keep up to date with ICameraDeviceUser.aidl.
* </p>
*/
+@SuppressWarnings("deprecation")
public class CameraDeviceUserShim implements ICameraDeviceUser {
private static final String TAG = "CameraDeviceUserShim";
@@ -259,6 +260,7 @@
super(l);
}
+ @Override
public void handleMessage(Message msg) {
try {
switch (msg.what) {
@@ -320,6 +322,9 @@
// Check errors old HAL initialization
CameraBinderDecorator.throwOnError(initErrors);
+ // Disable shutter sounds (this will work unconditionally) for api2 clients
+ legacyCamera.disableShutterSound();
+
CameraInfo info = new CameraInfo();
Camera.getCameraInfo(cameraId, info);