From 85e89f2eaaf6e83bc08218e3df11de567de75a0e Mon Sep 17 00:00:00 2001 From: Rucha Katakwar Date: Tue, 12 Oct 2021 10:10:44 -0700 Subject: [PATCH] Camera: Add torch brightness control keys. 1.FLASH_INFO_STRENGTH_MAXIMUM_LEVEL : Number of brightness levels. 2.FLASH_INFO_STRENGTH_DEFAULT_LEVEL : Default brightness level for device in TORCH mode. The API to actually control the torch strength level and tests will be added in the next series of changes. bug: 200174275 Change-Id: I674885a237d734a2a45f40fa0e336b07fa649859 --- core/api/current.txt | 2 ++ .../camera2/CameraCharacteristics.java | 36 +++++++++++++++++++ .../hardware/camera2/CaptureRequest.java | 3 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 454567d7dd699..7dbc68f97c5c7 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18016,6 +18016,8 @@ package android.hardware.camera2 { field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key DISTORTION_CORRECTION_AVAILABLE_MODES; field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key EDGE_AVAILABLE_EDGE_MODES; field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key FLASH_INFO_AVAILABLE; + field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key FLASH_INFO_STRENGTH_DEFAULT_LEVEL; + field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key FLASH_INFO_STRENGTH_MAXIMUM_LEVEL; field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES; field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key INFO_DEVICE_STATE_SENSOR_ORIENTATION_MAP; field @NonNull public static final android.hardware.camera2.CameraCharacteristics.Key INFO_SUPPORTED_HARDWARE_LEVEL; diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java index 9f77a7e72e704..afea4e5f35e38 100644 --- a/core/java/android/hardware/camera2/CameraCharacteristics.java +++ b/core/java/android/hardware/camera2/CameraCharacteristics.java @@ -1319,6 +1319,42 @@ public final class CameraCharacteristics extends CameraMetadata FLASH_INFO_AVAILABLE = new Key("android.flash.info.available", boolean.class); + /** + *

Maximum flashlight brightness level.

+ *

If this value is greater than 1, then the device supports controlling the + * flashlight brightness level via + * {android.hardware.camera2.CameraManager#setTorchStrengthLevel}. + * If this value is equal to 1, flashlight brightness control is not supported. + * This value will be -1 if the flash unit is not available.

+ *

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

+ */ + @PublicKey + @NonNull + public static final Key FLASH_INFO_STRENGTH_MAXIMUM_LEVEL = + new Key("android.flash.info.strengthMaximumLevel", int.class); + + /** + *

Default flashlight brightness level to be set via + * {android.hardware.camera2.CameraManager#setTorchStrengthLevel}.

+ *

If flash unit is available this will be greater than or equal to 1 and less + * or equal to {@link CameraCharacteristics#FLASH_INFO_STRENGTH_MAXIMUM_LEVEL android.flash.info.strengthMaximumLevel}. + * If flash unit is not available this will be set to -1.

+ *

Setting flashlight brightness above the default level + * (i.e.{@link CameraCharacteristics#FLASH_INFO_STRENGTH_DEFAULT_LEVEL android.flash.info.strengthDefaultLevel}) may make the device more + * likely to reach thermal throttling conditions and slow down, or drain the + * battery quicker than normal. To minimize such issues, it is recommended to + * start the flashlight at this default brightness until a user explicitly requests + * a brighter level.

+ *

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

+ * + * @see CameraCharacteristics#FLASH_INFO_STRENGTH_DEFAULT_LEVEL + * @see CameraCharacteristics#FLASH_INFO_STRENGTH_MAXIMUM_LEVEL + */ + @PublicKey + @NonNull + public static final Key FLASH_INFO_STRENGTH_DEFAULT_LEVEL = + new Key("android.flash.info.strengthDefaultLevel", int.class); + /** *

List of hot pixel correction modes for {@link CaptureRequest#HOT_PIXEL_MODE android.hotPixel.mode} that are supported by this * camera device.

diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java index 027681538ce5a..08276ac230326 100644 --- a/core/java/android/hardware/camera2/CaptureRequest.java +++ b/core/java/android/hardware/camera2/CaptureRequest.java @@ -1022,8 +1022,7 @@ public final class CaptureRequest extends CameraMetadata> *

which define a transform from input sensor colors, P_in = [ r g b ], * to output linear sRGB, P_out = [ r' g' b' ],

*

with colors as follows:

- *

-     * r' = I0r + I1g + I2b
+     * 
r' = I0r + I1g + I2b
      * g' = I3r + I4g + I5b
      * b' = I6r + I7g + I8b
      *