Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6653362f authored by Igor Murashkin's avatar Igor Murashkin
Browse files

camera2: legacy: disable shutter sounds unconditionally via camera2 api

Bug: 17109582
Change-Id: Ieb3fc61ff111d792cc657c018e278349c25472cf
parent a66c40bf
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1558,6 +1558,26 @@ public class Camera {
        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);

    /**
+5 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import java.util.List;
 * 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 @@ public class CameraDeviceUserShim implements ICameraDeviceUser {
                super(l);
            }

            @Override
            public void handleMessage(Message msg) {
                try {
                    switch (msg.what) {
@@ -320,6 +322,9 @@ public class CameraDeviceUserShim implements ICameraDeviceUser {
        // 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);