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.
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.
public void turnOnTorchWithStrengthLevel (String cameraId, int torchStrength): Sets the brightness level of the flashlight associated with the given
cameraIdvalue in torch mode. If torch mode is off and
torchStrengthis greater than or equal to
1, the torch turns on with the strength level specified in
public int getTorchStrengthLevel (String cameraId): Returns the brightness level of the flash unit associated with
FLASH_INFO_STRENGTH_MAXIMUM_LEVEL: Maximum brightness level. The camera HAL advertises this feature by setting a value greater than
FLASH_INFO_STRENGTH_DEFAULT_LEVEL: Default flashlight brightness level.
To support the torch strength control feature on your device, use the following camera AIDL HAL interfaces:
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,
To validate your implementation of the torch strength control feature, run the following VTS and CTS tests: