For devices running Android 13 or higher, the Android framework provides a multilevel control for torch strength. In Android 12 and lower, the framework allows only for turning the torch mode on or off. By supporting multilevel torch strength control, devices can enable use cases such as controlling the brightness of the flashlight based on lighting conditions and sending signals for assistance using a strobe effect by sending quick pulses of light in a row. Another benefit of this feature is that it can improve battery life and performance as the torch mode doesn't always need to be turned on at the maximum strength, which can lead to thermal throttling conditions.
Public APIs
Apps can use the torch strength control feature through the following public APIs and camera characteristics keys. No camera permissions are required for these APIs because the camera isn't accessed.
CameraManager APIs
public void turnOnTorchWithStrengthLevel (String cameraId, int torchStrength)
: Sets the brightness level of the flashlight associated with the givencameraId
value in torch mode. If torch mode is off andtorchStrength
is greater than or equal to1
, the torch turns on with the strength level specified intorchStrength
.public int getTorchStrengthLevel (String cameraId)
: Returns the brightness level of the flash unit associated withcameraId
.
CameraCharacteristics keys
FLASH_INFO_STRENGTH_MAXIMUM_LEVEL
: Maximum brightness level. The camera HAL advertises this feature by setting a value greater than1
.FLASH_INFO_STRENGTH_DEFAULT_LEVEL
: Default flashlight brightness level.
Implementation
To support the torch strength control feature on your device, use the following camera AIDL HAL interfaces:
Location: /camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl
Ensure your HAL implementation advertises the following camera characteristics keys to support the torch brightness control feature:
For a reference Camera HAL implementation supporting torch strength control,
see
EmulatedCameraDeviceHWLImpl.cpp
.
Validation
To validate your implementation of the torch strength control feature, run the following VTS and CTS tests: