Camera: update camera audio restriction API
Add dedicated get API per API review feedback. Test: updated CTS tests Bug: 140524714 Change-Id: I83ac09da76cc0868c7e993abd6a8c846912b6199
This commit is contained in:
@@ -16906,9 +16906,10 @@ package android.hardware.camera2 {
|
||||
method @NonNull public abstract android.hardware.camera2.CaptureRequest.Builder createReprocessCaptureRequest(@NonNull android.hardware.camera2.TotalCaptureResult) throws android.hardware.camera2.CameraAccessException;
|
||||
method public abstract void createReprocessableCaptureSession(@NonNull android.hardware.camera2.params.InputConfiguration, @NonNull java.util.List<android.view.Surface>, @NonNull android.hardware.camera2.CameraCaptureSession.StateCallback, @Nullable android.os.Handler) throws android.hardware.camera2.CameraAccessException;
|
||||
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 public int getCameraAudioRestriction() 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 int setCameraAudioRestriction(int) throws android.hardware.camera2.CameraAccessException;
|
||||
method public void 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
|
||||
|
||||
@@ -2169,11 +2169,18 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting camera audio restriction mode.
|
||||
* Set camera audio restriction mode.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public native final int setAudioRestriction(int mode);
|
||||
public native final void setAudioRestriction(int mode);
|
||||
|
||||
/**
|
||||
* Get currently applied camera audio restriction mode.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public native final int getAudioRestriction();
|
||||
|
||||
/**
|
||||
* Image size (width and height dimensions).
|
||||
|
||||
@@ -1251,24 +1251,42 @@ public abstract class CameraDevice implements AutoCloseable {
|
||||
* are setting different modes, the system will pick a the mode that's union of
|
||||
* all modes set by CameraDevice.</p>
|
||||
*
|
||||
* <p>The mute settings will be automatically removed when the CameraDevice is closed or
|
||||
* the application is disconnected from the camera.</p>
|
||||
* <p>The mute settings from this CameraDevice will be automatically removed when the
|
||||
* CameraDevice is closed or the application is disconnected from the camera.</p>
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @see #getCameraAudioRestriction
|
||||
*/
|
||||
public @CAMERA_AUDIO_RESTRICTION int setCameraAudioRestriction(
|
||||
public void setCameraAudioRestriction(
|
||||
@CAMERA_AUDIO_RESTRICTION int mode) throws CameraAccessException {
|
||||
throw new UnsupportedOperationException("Subclasses must override this method");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currently applied global camera audio restriction mode.
|
||||
*
|
||||
* <p>Application can use this method to retrieve the system-wide camera audio restriction
|
||||
* settings described in {@link #setCameraAudioRestriction}.</p>
|
||||
*
|
||||
* @return The system-wide mute mode setting resulting from this call
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @see #setCameraAudioRestriction
|
||||
*/
|
||||
public @CAMERA_AUDIO_RESTRICTION int getCameraAudioRestriction() throws CameraAccessException {
|
||||
throw new UnsupportedOperationException("Subclasses must override this method");
|
||||
}
|
||||
|
||||
/**
|
||||
* To be inherited by android.hardware.camera2.* code only.
|
||||
* @hide
|
||||
|
||||
@@ -2570,11 +2570,19 @@ public class CameraDeviceImpl extends CameraDevice
|
||||
}
|
||||
|
||||
@Override
|
||||
public @CAMERA_AUDIO_RESTRICTION int setCameraAudioRestriction(
|
||||
public void setCameraAudioRestriction(
|
||||
@CAMERA_AUDIO_RESTRICTION int mode) throws CameraAccessException {
|
||||
synchronized(mInterfaceLock) {
|
||||
checkIfCameraClosedOrInError();
|
||||
return mRemoteDevice.setCameraAudioRestriction(mode);
|
||||
mRemoteDevice.setCameraAudioRestriction(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @CAMERA_AUDIO_RESTRICTION int getCameraAudioRestriction() throws CameraAccessException {
|
||||
synchronized(mInterfaceLock) {
|
||||
checkIfCameraClosedOrInError();
|
||||
return mRemoteDevice.getGlobalAudioRestriction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,9 +258,18 @@ public class ICameraDeviceUserWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public int setCameraAudioRestriction(int mode) throws CameraAccessException {
|
||||
public void setCameraAudioRestriction(int mode) throws CameraAccessException {
|
||||
try {
|
||||
return mRemoteDevice.setCameraAudioRestriction(mode);
|
||||
mRemoteDevice.setCameraAudioRestriction(mode);
|
||||
} catch (Throwable t) {
|
||||
CameraManager.throwAsPublicException(t);
|
||||
throw new UnsupportedOperationException("Unexpected exception", t);
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlobalAudioRestriction() throws CameraAccessException {
|
||||
try {
|
||||
return mRemoteDevice.getGlobalAudioRestriction();
|
||||
} catch (Throwable t) {
|
||||
CameraManager.throwAsPublicException(t);
|
||||
throw new UnsupportedOperationException("Unexpected exception", t);
|
||||
|
||||
@@ -767,14 +767,25 @@ public class CameraDeviceUserShim implements ICameraDeviceUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setCameraAudioRestriction(int mode) {
|
||||
public void setCameraAudioRestriction(int mode) {
|
||||
if (mLegacyDevice.isClosed()) {
|
||||
String err = "Cannot set camera audio restriction, device has been closed.";
|
||||
Log.e(TAG, err);
|
||||
throw new ServiceSpecificException(ICameraService.ERROR_DISCONNECTED, err);
|
||||
}
|
||||
|
||||
return mLegacyDevice.setAudioRestriction(mode);
|
||||
mLegacyDevice.setAudioRestriction(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGlobalAudioRestriction() {
|
||||
if (mLegacyDevice.isClosed()) {
|
||||
String err = "Cannot set camera audio restriction, device has been closed.";
|
||||
Log.e(TAG, err);
|
||||
throw new ServiceSpecificException(ICameraService.ERROR_DISCONNECTED, err);
|
||||
}
|
||||
|
||||
return mLegacyDevice.getAudioRestriction();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -550,8 +550,12 @@ public class LegacyCameraDevice implements AutoCloseable {
|
||||
return lastFrame;
|
||||
}
|
||||
|
||||
public int setAudioRestriction(int mode) {
|
||||
return mRequestThreadManager.setAudioRestriction(mode);
|
||||
public void setAudioRestriction(int mode) {
|
||||
mRequestThreadManager.setAudioRestriction(mode);
|
||||
}
|
||||
|
||||
public int getAudioRestriction() {
|
||||
return mRequestThreadManager.getAudioRestriction();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1105,9 +1105,16 @@ public class RequestThreadManager {
|
||||
condition.block();
|
||||
}
|
||||
|
||||
public int setAudioRestriction(int mode) {
|
||||
public void setAudioRestriction(int mode) {
|
||||
if (mCamera != null) {
|
||||
return mCamera.setAudioRestriction(mode);
|
||||
mCamera.setAudioRestriction(mode);
|
||||
}
|
||||
throw new IllegalStateException("Camera has been released!");
|
||||
}
|
||||
|
||||
public int getAudioRestriction() {
|
||||
if (mCamera != null) {
|
||||
return mCamera.getAudioRestriction();
|
||||
}
|
||||
throw new IllegalStateException("Camera has been released!");
|
||||
}
|
||||
|
||||
@@ -1023,22 +1023,38 @@ static void android_hardware_Camera_enableFocusMoveCallback(JNIEnv *env, jobject
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t android_hardware_Camera_setAudioRestriction(
|
||||
static void android_hardware_Camera_setAudioRestriction(
|
||||
JNIEnv *env, jobject thiz, jint mode)
|
||||
{
|
||||
ALOGV("setAudioRestriction");
|
||||
sp<Camera> camera = get_native_camera(env, thiz, NULL);
|
||||
if (camera == 0) {
|
||||
jniThrowRuntimeException(env, "camera has been disconnected");
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t ret = camera->setAudioRestriction(mode);
|
||||
if (ret < 0) {
|
||||
jniThrowRuntimeException(env, "Illegal argument or low-level eror");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t android_hardware_Camera_getAudioRestriction(
|
||||
JNIEnv *env, jobject thiz)
|
||||
{
|
||||
ALOGV("getAudioRestriction");
|
||||
sp<Camera> camera = get_native_camera(env, thiz, NULL);
|
||||
if (camera == 0) {
|
||||
jniThrowRuntimeException(env, "camera has been disconnected");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ret = camera->getGlobalAudioRestriction();
|
||||
if (ret < 0) {
|
||||
jniThrowRuntimeException(env, "Illegal argument or low-level eror");
|
||||
return -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1127,8 +1143,11 @@ static const JNINativeMethod camMethods[] = {
|
||||
"(I)V",
|
||||
(void *)android_hardware_Camera_enableFocusMoveCallback},
|
||||
{ "setAudioRestriction",
|
||||
"(I)I",
|
||||
"(I)V",
|
||||
(void *)android_hardware_Camera_setAudioRestriction},
|
||||
{ "getAudioRestriction",
|
||||
"()I",
|
||||
(void *)android_hardware_Camera_getAudioRestriction},
|
||||
};
|
||||
|
||||
struct field {
|
||||
|
||||
Reference in New Issue
Block a user