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

Commit 3eb79d63 authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: camera service implementation of camera audio restriction API

Changed the binder call return value to the resulting
audio restriction mode.
Also added audio restriction API support for legacy shim
path.

Test: new CTS tests
Bug: 135676184
Change-Id: I412e8f53705f2401995ff828bfdc9a8598dc305a
parent 51d8516b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16904,7 +16904,7 @@ package android.hardware.camera2 {
    method public abstract void createReprocessableCaptureSessionByConfigurations(@NonNull android.hardware.camera2.params.InputConfiguration, @NonNull java.util.List<android.hardware.camera2.params.OutputConfiguration>, @NonNull android.hardware.camera2.CameraCaptureSession.StateCallback, @Nullable android.os.Handler) throws android.hardware.camera2.CameraAccessException;
    method @NonNull public abstract String getId();
    method public boolean isSessionConfigurationSupported(@NonNull android.hardware.camera2.params.SessionConfiguration) throws android.hardware.camera2.CameraAccessException;
    method public void setCameraAudioRestriction(int) throws android.hardware.camera2.CameraAccessException;
    method public int setCameraAudioRestriction(int) throws android.hardware.camera2.CameraAccessException;
    field public static final int AUDIO_RESTRICTION_NONE = 0; // 0x0
    field public static final int AUDIO_RESTRICTION_VIBRATION = 1; // 0x1
    field public static final int AUDIO_RESTRICTION_VIBRATION_SOUND = 3; // 0x3
+7 −0
Original line number Diff line number Diff line
@@ -2168,6 +2168,13 @@ public class Camera {
        return p;
    }

    /**
     * Setting camera audio restriction mode.
     *
     * @hide
     */
    public native final int setAudioRestriction(int mode);

    /**
     * Image size (width and height dimensions).
     * @deprecated We recommend using the new {@link android.hardware.camera2} API for new
+4 −2
Original line number Diff line number Diff line
@@ -1256,14 +1256,16 @@ public abstract class CameraDevice implements AutoCloseable {
     *
     * @param mode An enumeration selecting the audio restriction mode for this camera device.
     *
     * @return The system-wide mute mode setting resulting from this call
     *
     * @throws IllegalArgumentException if the mode is not supported
     *
     * @throws CameraAccessException if the camera device is no longer connected or has
     *                               encountered a fatal error
     * @throws IllegalStateException if the camera device has been closed
     */
    public void setCameraAudioRestriction(@CAMERA_AUDIO_RESTRICTION int mode)
            throws CameraAccessException {
    public @CAMERA_AUDIO_RESTRICTION int setCameraAudioRestriction(
            @CAMERA_AUDIO_RESTRICTION int mode) throws CameraAccessException {
        throw new UnsupportedOperationException("Subclasses must override this method");
    }

+6 −3
Original line number Diff line number Diff line
@@ -2570,8 +2570,11 @@ public class CameraDeviceImpl extends CameraDevice
    }

    @Override
    public void setCameraAudioRestriction(@CAMERA_AUDIO_RESTRICTION int mode) {
        // To be implemented.
        return;
    public @CAMERA_AUDIO_RESTRICTION int setCameraAudioRestriction(
            @CAMERA_AUDIO_RESTRICTION int mode) throws CameraAccessException {
        synchronized(mInterfaceLock) {
            checkIfCameraClosedOrInError();
            return mRemoteDevice.setCameraAudioRestriction(mode);
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -258,4 +258,13 @@ public class ICameraDeviceUserWrapper {
        }
    }

    public int setCameraAudioRestriction(int mode) throws CameraAccessException {
        try {
            return mRemoteDevice.setCameraAudioRestriction(mode);
        } catch (Throwable t) {
            CameraManager.throwAsPublicException(t);
            throw new UnsupportedOperationException("Unexpected exception", t);
        }
    }

}
Loading