diff --git a/api/current.txt b/api/current.txt
index 4d6e2d6b0e46e..62f351f07aa41 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15786,6 +15786,7 @@ package android.hardware.camera2 {
field public static final android.hardware.camera2.CameraCharacteristics.Key CONTROL_MAX_REGIONS_AWB;
field public static final android.hardware.camera2.CameraCharacteristics.Key> CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE;
field public static final android.hardware.camera2.CameraCharacteristics.Key DEPTH_DEPTH_IS_EXCLUSIVE;
+ field public static final android.hardware.camera2.CameraCharacteristics.Key DISTORTION_CORRECTION_AVAILABLE_MODES;
field public static final android.hardware.camera2.CameraCharacteristics.Key EDGE_AVAILABLE_EDGE_MODES;
field public static final android.hardware.camera2.CameraCharacteristics.Key FLASH_INFO_AVAILABLE;
field public static final android.hardware.camera2.CameraCharacteristics.Key HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES;
@@ -16022,6 +16023,9 @@ package android.hardware.camera2 {
field public static final int CONTROL_SCENE_MODE_THEATRE = 7; // 0x7
field public static final int CONTROL_VIDEO_STABILIZATION_MODE_OFF = 0; // 0x0
field public static final int CONTROL_VIDEO_STABILIZATION_MODE_ON = 1; // 0x1
+ field public static final int DISTORTION_CORRECTION_MODE_FAST = 1; // 0x1
+ field public static final int DISTORTION_CORRECTION_MODE_HIGH_QUALITY = 2; // 0x2
+ field public static final int DISTORTION_CORRECTION_MODE_OFF = 0; // 0x0
field public static final int EDGE_MODE_FAST = 1; // 0x1
field public static final int EDGE_MODE_HIGH_QUALITY = 2; // 0x2
field public static final int EDGE_MODE_OFF = 0; // 0x0
@@ -16174,6 +16178,7 @@ package android.hardware.camera2 {
field public static final android.hardware.camera2.CaptureRequest.Key CONTROL_SCENE_MODE;
field public static final android.hardware.camera2.CaptureRequest.Key CONTROL_VIDEO_STABILIZATION_MODE;
field public static final android.os.Parcelable.Creator CREATOR;
+ field public static final android.hardware.camera2.CaptureRequest.Key DISTORTION_CORRECTION_MODE;
field public static final android.hardware.camera2.CaptureRequest.Key EDGE_MODE;
field public static final android.hardware.camera2.CaptureRequest.Key FLASH_MODE;
field public static final android.hardware.camera2.CaptureRequest.Key HOT_PIXEL_MODE;
@@ -16256,6 +16261,7 @@ package android.hardware.camera2 {
field public static final android.hardware.camera2.CaptureResult.Key CONTROL_POST_RAW_SENSITIVITY_BOOST;
field public static final android.hardware.camera2.CaptureResult.Key CONTROL_SCENE_MODE;
field public static final android.hardware.camera2.CaptureResult.Key CONTROL_VIDEO_STABILIZATION_MODE;
+ field public static final android.hardware.camera2.CaptureResult.Key DISTORTION_CORRECTION_MODE;
field public static final android.hardware.camera2.CaptureResult.Key EDGE_MODE;
field public static final android.hardware.camera2.CaptureResult.Key FLASH_MODE;
field public static final android.hardware.camera2.CaptureResult.Key FLASH_STATE;
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 390b83fe10cfd..e6aaab13e8410 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -3392,6 +3392,21 @@ public final class CameraCharacteristics extends CameraMetadata LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE =
new Key("android.logicalMultiCamera.sensorSyncType", int.class);
+ /**
+ * List of distortion correction modes for {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode} that are
+ * supported by this camera device.
+ * No device is required to support this API; such devices will always list only 'OFF'.
+ * All devices that support this API will list both FAST and HIGH_QUALITY.
+ * Range of valid values:
+ * Any value listed in {@link CaptureRequest#DISTORTION_CORRECTION_MODE android.distortionCorrection.mode}
+ * Optional - This value may be {@code null} on some devices.
+ *
+ * @see CaptureRequest#DISTORTION_CORRECTION_MODE
+ */
+ @PublicKey
+ public static final Key DISTORTION_CORRECTION_AVAILABLE_MODES =
+ new Key("android.distortionCorrection.availableModes", int[].class);
+
/*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
* End generated code
*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 7669c018acd15..7467c3aecb504 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -2729,6 +2729,31 @@ public abstract class CameraMetadata {
*/
public static final int TONEMAP_PRESET_CURVE_REC709 = 1;
+ //
+ // Enumeration values for CaptureRequest#DISTORTION_CORRECTION_MODE
+ //
+
+ /**
+ * No distortion correction is applied.
+ * @see CaptureRequest#DISTORTION_CORRECTION_MODE
+ */
+ public static final int DISTORTION_CORRECTION_MODE_OFF = 0;
+
+ /**
+ * Lens distortion correction is applied without reducing frame rate
+ * relative to sensor output. It may be the same as OFF if distortion correction would
+ * reduce frame rate relative to sensor.
+ * @see CaptureRequest#DISTORTION_CORRECTION_MODE
+ */
+ public static final int DISTORTION_CORRECTION_MODE_FAST = 1;
+
+ /**
+ * High-quality distortion correction is applied, at the cost of
+ * possibly reduced frame rate relative to sensor output.
+ * @see CaptureRequest#DISTORTION_CORRECTION_MODE
+ */
+ public static final int DISTORTION_CORRECTION_MODE_HIGH_QUALITY = 2;
+
//
// Enumeration values for CaptureResult#CONTROL_AE_STATE
//
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index b0cbec71dfe6a..d36785a7cfb68 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -3167,6 +3167,49 @@ public final class CaptureRequest extends CameraMetadata>
public static final Key REPROCESS_EFFECTIVE_EXPOSURE_FACTOR =
new Key("android.reprocess.effectiveExposureFactor", float.class);
+ /**
+ * Mode of operation for the lens distortion correction block.
+ * The lens distortion correction block attempts to improve image quality by fixing
+ * radial, tangential, or other geometric aberrations in the camera device's optics. If
+ * available, the {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} field documents the lens's distortion parameters.
+ * OFF means no distortion correction is done.
+ * FAST/HIGH_QUALITY both mean camera device determined distortion correction will be
+ * applied. HIGH_QUALITY mode indicates that the camera device will use the highest-quality
+ * correction algorithms, even if it slows down capture rate. FAST means the camera device
+ * will not slow down capture rate when applying correction. FAST may be the same as OFF if
+ * any correction at all would slow down capture rate. Every output stream will have a
+ * similar amount of enhancement applied.
+ * The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not
+ * applied to any RAW output. Metadata coordinates such as face rectangles or metering
+ * regions are also not affected by correction.
+ * Applications enabling distortion correction need to pay extra attention when converting
+ * image coordinates between corrected output buffers and the sensor array. For example, if
+ * the app supports tap-to-focus and enables correction, it then has to apply the distortion
+ * model described in {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} to the image buffer tap coordinates to properly
+ * calculate the tap position on the sensor active array to be used with
+ * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}. The same applies in reverse to detected face rectangles if
+ * they need to be drawn on top of the corrected output buffers.
+ * Possible values:
+ *
+ * - {@link #DISTORTION_CORRECTION_MODE_OFF OFF}
+ * - {@link #DISTORTION_CORRECTION_MODE_FAST FAST}
+ * - {@link #DISTORTION_CORRECTION_MODE_HIGH_QUALITY HIGH_QUALITY}
+ *
+ * Available values for this device:
+ * {@link CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES android.distortionCorrection.availableModes}
+ * Optional - This value may be {@code null} on some devices.
+ *
+ * @see CaptureRequest#CONTROL_AF_REGIONS
+ * @see CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES
+ * @see CameraCharacteristics#LENS_DISTORTION
+ * @see #DISTORTION_CORRECTION_MODE_OFF
+ * @see #DISTORTION_CORRECTION_MODE_FAST
+ * @see #DISTORTION_CORRECTION_MODE_HIGH_QUALITY
+ */
+ @PublicKey
+ public static final Key DISTORTION_CORRECTION_MODE =
+ new Key("android.distortionCorrection.mode", int.class);
+
/*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
* End generated code
*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index 633194243512f..bb8226082f038 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -4450,6 +4450,49 @@ public class CaptureResult extends CameraMetadata> {
public static final Key REPROCESS_EFFECTIVE_EXPOSURE_FACTOR =
new Key("android.reprocess.effectiveExposureFactor", float.class);
+ /**
+ * Mode of operation for the lens distortion correction block.
+ * The lens distortion correction block attempts to improve image quality by fixing
+ * radial, tangential, or other geometric aberrations in the camera device's optics. If
+ * available, the {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} field documents the lens's distortion parameters.
+ * OFF means no distortion correction is done.
+ * FAST/HIGH_QUALITY both mean camera device determined distortion correction will be
+ * applied. HIGH_QUALITY mode indicates that the camera device will use the highest-quality
+ * correction algorithms, even if it slows down capture rate. FAST means the camera device
+ * will not slow down capture rate when applying correction. FAST may be the same as OFF if
+ * any correction at all would slow down capture rate. Every output stream will have a
+ * similar amount of enhancement applied.
+ * The correction only applies to processed outputs such as YUV, JPEG, or DEPTH16; it is not
+ * applied to any RAW output. Metadata coordinates such as face rectangles or metering
+ * regions are also not affected by correction.
+ * Applications enabling distortion correction need to pay extra attention when converting
+ * image coordinates between corrected output buffers and the sensor array. For example, if
+ * the app supports tap-to-focus and enables correction, it then has to apply the distortion
+ * model described in {@link CameraCharacteristics#LENS_DISTORTION android.lens.distortion} to the image buffer tap coordinates to properly
+ * calculate the tap position on the sensor active array to be used with
+ * {@link CaptureRequest#CONTROL_AF_REGIONS android.control.afRegions}. The same applies in reverse to detected face rectangles if
+ * they need to be drawn on top of the corrected output buffers.
+ * Possible values:
+ *
+ * - {@link #DISTORTION_CORRECTION_MODE_OFF OFF}
+ * - {@link #DISTORTION_CORRECTION_MODE_FAST FAST}
+ * - {@link #DISTORTION_CORRECTION_MODE_HIGH_QUALITY HIGH_QUALITY}
+ *
+ * Available values for this device:
+ * {@link CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES android.distortionCorrection.availableModes}
+ * Optional - This value may be {@code null} on some devices.
+ *
+ * @see CaptureRequest#CONTROL_AF_REGIONS
+ * @see CameraCharacteristics#DISTORTION_CORRECTION_AVAILABLE_MODES
+ * @see CameraCharacteristics#LENS_DISTORTION
+ * @see #DISTORTION_CORRECTION_MODE_OFF
+ * @see #DISTORTION_CORRECTION_MODE_FAST
+ * @see #DISTORTION_CORRECTION_MODE_HIGH_QUALITY
+ */
+ @PublicKey
+ public static final Key DISTORTION_CORRECTION_MODE =
+ new Key("android.distortionCorrection.mode", int.class);
+
/*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
* End generated code
*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/