diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index 6d0d505f368a8..93eb3def1a687 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -731,6 +731,8 @@ public final class CaptureRequest extends CameraMetadata> /** *

List of areas to use for * metering.

+ *

Optional. Not available if {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AE android.control.maxRegionsAe} is 0. + * Otherwise will always be present.

*

The coordinate system is based on the active pixel array, * with (0,0) being the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, @@ -746,7 +748,9 @@ public final class CaptureRequest extends CameraMetadata> * outside the used {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} returned in capture result metadata, * the camera device will ignore the sections outside the region and output the * used sections in the result metadata.

+ *

Optional - This value may be {@code null} on some devices.

* + * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE */ @@ -820,6 +824,8 @@ public final class CaptureRequest extends CameraMetadata> /** *

List of areas to use for focus * estimation.

+ *

Optional. Not available if {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AF android.control.maxRegionsAf} is 0. + * Otherwise will always be present.

*

The coordinate system is based on the active pixel array, * with (0,0) being the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, @@ -835,7 +841,9 @@ public final class CaptureRequest extends CameraMetadata> * outside the used {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} returned in capture result metadata, * the camera device will ignore the sections outside the region and output the * used sections in the result metadata.

+ *

Optional - This value may be {@code null} on some devices.

* + * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AF * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE */ @@ -921,6 +929,8 @@ public final class CaptureRequest extends CameraMetadata> /** *

List of areas to use for illuminant * estimation.

+ *

Optional. Not available if {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AWB android.control.maxRegionsAwb} is 0. + * Otherwise will always be present.

*

The coordinate system is based on the active pixel array, * with (0,0) being the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, @@ -936,7 +946,9 @@ public final class CaptureRequest extends CameraMetadata> * outside the used {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} returned in capture result metadata, * the camera device will ignore the sections outside the region and output the * used sections in the result metadata.

+ *

Optional - This value may be {@code null} on some devices.

* + * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AWB * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE */ diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java index 754d83e8da320..01276a28e320f 100644 --- a/core/java/android/hardware/camera2/CaptureResult.java +++ b/core/java/android/hardware/camera2/CaptureResult.java @@ -582,6 +582,8 @@ public class CaptureResult extends CameraMetadata> { /** *

List of areas to use for * metering.

+ *

Optional. Not available if {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AE android.control.maxRegionsAe} is 0. + * Otherwise will always be present.

*

The coordinate system is based on the active pixel array, * with (0,0) being the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, @@ -597,7 +599,9 @@ public class CaptureResult extends CameraMetadata> { * outside the used {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} returned in capture result metadata, * the camera device will ignore the sections outside the region and output the * used sections in the result metadata.

+ *

Optional - This value may be {@code null} on some devices.

* + * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AE * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE */ @@ -870,6 +874,8 @@ public class CaptureResult extends CameraMetadata> { /** *

List of areas to use for focus * estimation.

+ *

Optional. Not available if {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AF android.control.maxRegionsAf} is 0. + * Otherwise will always be present.

*

The coordinate system is based on the active pixel array, * with (0,0) being the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, @@ -885,7 +891,9 @@ public class CaptureResult extends CameraMetadata> { * outside the used {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} returned in capture result metadata, * the camera device will ignore the sections outside the region and output the * used sections in the result metadata.

+ *

Optional - This value may be {@code null} on some devices.

* + * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AF * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE */ @@ -1369,6 +1377,8 @@ public class CaptureResult extends CameraMetadata> { /** *

List of areas to use for illuminant * estimation.

+ *

Optional. Not available if {@link CameraCharacteristics#CONTROL_MAX_REGIONS_AWB android.control.maxRegionsAwb} is 0. + * Otherwise will always be present.

*

The coordinate system is based on the active pixel array, * with (0,0) being the top-left pixel in the active pixel array, and * ({@link CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE android.sensor.info.activeArraySize}.width - 1, @@ -1384,7 +1394,9 @@ public class CaptureResult extends CameraMetadata> { * outside the used {@link CaptureRequest#SCALER_CROP_REGION android.scaler.cropRegion} returned in capture result metadata, * the camera device will ignore the sections outside the region and output the * used sections in the result metadata.

+ *

Optional - This value may be {@code null} on some devices.

* + * @see CameraCharacteristics#CONTROL_MAX_REGIONS_AWB * @see CaptureRequest#SCALER_CROP_REGION * @see CameraCharacteristics#SENSOR_INFO_ACTIVE_ARRAY_SIZE */ diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java index a8d1018d63f6e..3c0e0e44c1ccc 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java +++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java @@ -675,15 +675,13 @@ public class LegacyMetadataMapper { * request.availableRequestKeys */ { - CaptureRequest.Key availableKeys[] = new CaptureRequest.Key[] { + CaptureRequest.Key defaultAvailableKeys[] = new CaptureRequest.Key[] { CaptureRequest.CONTROL_AE_ANTIBANDING_MODE, CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION, CaptureRequest.CONTROL_AE_LOCK, CaptureRequest.CONTROL_AE_MODE, - CaptureRequest.CONTROL_AE_REGIONS, CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, CaptureRequest.CONTROL_AF_MODE, - CaptureRequest.CONTROL_AF_REGIONS, CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AWB_LOCK, CaptureRequest.CONTROL_AWB_MODE, @@ -704,21 +702,32 @@ public class LegacyMetadataMapper { CaptureRequest.SCALER_CROP_REGION, CaptureRequest.STATISTICS_FACE_DETECT_MODE, }; - m.set(REQUEST_AVAILABLE_REQUEST_KEYS, getTagsForKeys(availableKeys)); + ArrayList> availableKeys = + new ArrayList>(Arrays.asList(defaultAvailableKeys)); + + if (p.getMaxNumMeteringAreas() > 0) { + availableKeys.add(CaptureRequest.CONTROL_AE_REGIONS); + } + if (p.getMaxNumFocusAreas() > 0) { + availableKeys.add(CaptureRequest.CONTROL_AF_REGIONS); + } + + CaptureRequest.Key availableRequestKeys[] = + new CaptureRequest.Key[availableKeys.size()]; + availableKeys.toArray(availableRequestKeys); + m.set(REQUEST_AVAILABLE_REQUEST_KEYS, getTagsForKeys(availableRequestKeys)); } /* * request.availableResultKeys */ { - CaptureResult.Key availableKeys[] = new CaptureResult.Key[] { + CaptureResult.Key defaultAvailableKeys[] = new CaptureResult.Key[] { CaptureResult.CONTROL_AE_ANTIBANDING_MODE , CaptureResult.CONTROL_AE_EXPOSURE_COMPENSATION , CaptureResult.CONTROL_AE_LOCK , CaptureResult.CONTROL_AE_MODE , - CaptureResult.CONTROL_AE_REGIONS , CaptureResult.CONTROL_AF_MODE , - CaptureResult.CONTROL_AF_REGIONS , CaptureResult.CONTROL_AF_STATE , CaptureResult.CONTROL_AWB_MODE , CaptureResult.CONTROL_AWB_LOCK , @@ -737,7 +746,20 @@ public class LegacyMetadataMapper { CaptureResult.STATISTICS_FACE_DETECT_MODE , // CaptureResult.STATISTICS_FACES , }; - m.set(REQUEST_AVAILABLE_RESULT_KEYS, getTagsForKeys(availableKeys)); + List> availableKeys = + new ArrayList>(Arrays.asList(defaultAvailableKeys)); + + if (p.getMaxNumMeteringAreas() > 0) { + availableKeys.add(CaptureResult.CONTROL_AE_REGIONS); + } + if (p.getMaxNumFocusAreas() > 0) { + availableKeys.add(CaptureResult.CONTROL_AF_REGIONS); + } + + CaptureResult.Key availableResultKeys[] = + new CaptureResult.Key[availableKeys.size()]; + availableKeys.toArray(availableResultKeys); + m.set(REQUEST_AVAILABLE_RESULT_KEYS, getTagsForKeys(availableResultKeys)); } /* diff --git a/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java b/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java index 090a8221a195c..ddaa6ee77c946 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java +++ b/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java @@ -322,7 +322,7 @@ public class LegacyResultMapper { } // control.aeRegions - { + if (p.getMaxNumMeteringAreas() > 0) { if (VERBOSE) { String meteringAreas = p.get("metering-areas"); Log.v(TAG, "mapAe - parameter dump; metering-areas: " + meteringAreas); @@ -342,7 +342,7 @@ public class LegacyResultMapper { m.set(CaptureResult.CONTROL_AF_MODE, convertLegacyAfMode(p.getFocusMode())); // control.afRegions - { + if (p.getMaxNumFocusAreas() > 0) { if (VERBOSE) { String focusAreas = p.get("focus-areas"); Log.v(TAG, "mapAe - parameter dump; focus-areas: " + focusAreas);