diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index c78dd5366d31e..b55a1cbe0bed5 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -2317,6 +2317,51 @@ public final class CaptureRequest extends CameraMetadata> public static final Key CONTROL_ZOOM_RATIO = new Key("android.control.zoomRatio", float.class); + /** + *

Framework-only private key which informs camera fwk that the AF regions has been set + * by the client and those regions need not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is + * set to MAXIMUM_RESOLUTION.

+ *

This must be set to TRUE by the camera2 java fwk when the camera client sets + * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}.

+ *

Optional - The value for this key may be {@code null} on some devices.

+ * + * @see CaptureRequest#CONTROL_AF_REGIONS + * @see CaptureRequest#SENSOR_PIXEL_MODE + * @hide + */ + public static final Key CONTROL_AF_REGIONS_SET = + new Key("android.control.afRegionsSet", boolean.class); + + /** + *

Framework-only private key which informs camera fwk that the AE regions has been set + * by the client and those regions need not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is + * set to MAXIMUM_RESOLUTION.

+ *

This must be set to TRUE by the camera2 java fwk when the camera client sets + * {@link CaptureRequest#CONTROL_AE_REGIONS android.control.aeRegions}.

+ *

Optional - The value for this key may be {@code null} on some devices.

+ * + * @see CaptureRequest#CONTROL_AE_REGIONS + * @see CaptureRequest#SENSOR_PIXEL_MODE + * @hide + */ + public static final Key CONTROL_AE_REGIONS_SET = + new Key("android.control.aeRegionsSet", boolean.class); + + /** + *

Framework-only private key which informs camera fwk that the AF regions has been set + * by the client and those regions need not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is + * set to MAXIMUM_RESOLUTION.

+ *

This must be set to TRUE by the camera2 java fwk when the camera client sets + * {@link CaptureRequest#CONTROL_AWB_REGIONS android.control.awbRegions}.

+ *

Optional - The value for this key may be {@code null} on some devices.

+ * + * @see CaptureRequest#CONTROL_AWB_REGIONS + * @see CaptureRequest#SENSOR_PIXEL_MODE + * @hide + */ + public static final Key CONTROL_AWB_REGIONS_SET = + new Key("android.control.awbRegionsSet", boolean.class); + /** *

Operation mode for edge * enhancement.

@@ -3056,6 +3101,21 @@ public final class CaptureRequest extends CameraMetadata> public static final Key SCALER_ROTATE_AND_CROP = new Key("android.scaler.rotateAndCrop", int.class); + /** + *

Framework-only private key which informs camera fwk that the scaler crop region + * ({@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}) has been set by the client and it need + * not be corrected when {@link CaptureRequest#SENSOR_PIXEL_MODE android.sensor.pixelMode} is set to MAXIMUM_RESOLUTION.

+ *

This must be set to TRUE by the camera2 java fwk when the camera client sets + * {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion}.

+ *

Optional - The value for this key may be {@code null} on some devices.

+ * + * @see CaptureRequest#SCALER_CROP_REGION + * @see CaptureRequest#SENSOR_PIXEL_MODE + * @hide + */ + public static final Key SCALER_CROP_REGION_SET = + new Key("android.scaler.cropRegionSet", boolean.class); + /** *

Duration each pixel is exposed to * light.

diff --git a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java index 6cbe107c96f5b..8fd9a6abf7b69 100644 --- a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java +++ b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java @@ -53,6 +53,7 @@ import android.hardware.camera2.params.Capability; import android.hardware.camera2.params.Face; import android.hardware.camera2.params.HighSpeedVideoConfiguration; import android.hardware.camera2.params.LensShadingMap; +import android.hardware.camera2.params.MeteringRectangle; import android.hardware.camera2.params.MandatoryStreamCombination; import android.hardware.camera2.params.MultiResolutionStreamConfigurationMap; import android.hardware.camera2.params.OisSample; @@ -1708,6 +1709,34 @@ public class CameraMetadataNative implements Parcelable { metadata.setGpsLocation((Location) value); } }); + sSetCommandMap.put(CaptureRequest.SCALER_CROP_REGION.getNativeKey(), + new SetCommand() { + @Override + public void setValue(CameraMetadataNative metadata, T value) { + metadata.setScalerCropRegion((Rect) value); + } + }); + sSetCommandMap.put(CaptureRequest.CONTROL_AWB_REGIONS.getNativeKey(), + new SetCommand() { + @Override + public void setValue(CameraMetadataNative metadata, T value) { + metadata.setAWBRegions((MeteringRectangle[]) value); + } + }); + sSetCommandMap.put(CaptureRequest.CONTROL_AF_REGIONS.getNativeKey(), + new SetCommand() { + @Override + public void setValue(CameraMetadataNative metadata, T value) { + metadata.setAFRegions((MeteringRectangle[]) value); + } + }); + sSetCommandMap.put(CaptureRequest.CONTROL_AE_REGIONS.getNativeKey(), + new SetCommand() { + @Override + public void setValue(CameraMetadataNative metadata, T value) { + metadata.setAERegions((MeteringRectangle[]) value); + } + }); } private boolean setAvailableFormats(int[] value) { @@ -1777,6 +1806,42 @@ public class CameraMetadataNative implements Parcelable { return true; } + private boolean setScalerCropRegion(Rect cropRegion) { + if (cropRegion == null) { + return false; + } + setBase(CaptureRequest.SCALER_CROP_REGION_SET, true); + setBase(CaptureRequest.SCALER_CROP_REGION, cropRegion); + return true; + } + + private boolean setAFRegions(MeteringRectangle[] afRegions) { + if (afRegions == null) { + return false; + } + setBase(CaptureRequest.CONTROL_AF_REGIONS_SET, true); + setBase(CaptureRequest.CONTROL_AF_REGIONS, afRegions); + return true; + } + + private boolean setAERegions(MeteringRectangle[] aeRegions) { + if (aeRegions == null) { + return false; + } + setBase(CaptureRequest.CONTROL_AE_REGIONS_SET, true); + setBase(CaptureRequest.CONTROL_AE_REGIONS, aeRegions); + return true; + } + + private boolean setAWBRegions(MeteringRectangle[] awbRegions) { + if (awbRegions == null) { + return false; + } + setBase(CaptureRequest.CONTROL_AWB_REGIONS_SET, true); + setBase(CaptureRequest.CONTROL_AWB_REGIONS, awbRegions); + return true; + } + private void updateNativeAllocation() { long currentBufferSize = nativeGetBufferSize(mMetadataPtr);