Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Torch strength control
Stay organized with collections
Save and categorize content based on your preferences.
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
CameraCharacteristics keys
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:
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-26 UTC."],[],[],null,["# Torch strength control\n\nFor devices running Android 13 or higher, the Android\nframework provides a multilevel control for torch strength. In\nAndroid 12 and lower, the framework allows only for\nturning the torch mode on or off. By supporting multilevel torch strength\ncontrol, devices can enable use cases such as controlling the brightness of the\nflashlight based on lighting conditions and sending signals for assistance\nusing a strobe effect by sending quick pulses of light in a row. Another\nbenefit of this feature is that it can improve battery life and performance as\nthe torch mode doesn't always need to be turned on at the maximum strength,\nwhich can lead to thermal throttling conditions.\n\nPublic APIs\n-----------\n\nApps can use the torch strength control feature through the following public\nAPIs and camera characteristics keys. No camera permissions are required for\nthese APIs because the camera isn't accessed.\n\n#### CameraManager APIs\n\n- [`public void turnOnTorchWithStrengthLevel (String cameraId, int torchStrength)`](https://developer.android.com/reference/android/hardware/camera2/CameraManager#turnOnTorchWithStrengthLevel(java.lang.String,%20int)): Sets the brightness level of the flashlight associated with the given `cameraId` value in torch mode. If torch mode is off and `torchStrength` is greater than or equal to `1`, the torch turns on with the strength level specified in `torchStrength`.\n- [`public int getTorchStrengthLevel (String cameraId)`](https://developer.android.com/reference/android/hardware/camera2/CameraManager#getTorchStrengthLevel(java.lang.String)): Returns the brightness level of the flash unit associated with `cameraId`.\n\n#### CameraCharacteristics keys\n\n- [`FLASH_INFO_STRENGTH_MAXIMUM_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_MAXIMUM_LEVEL): Maximum brightness level. The camera HAL advertises this feature by setting a value greater than `1`.\n- [`FLASH_INFO_STRENGTH_DEFAULT_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_DEFAULT_LEVEL): Default flashlight brightness level.\n\nImplementation\n--------------\n\nTo support the torch strength control feature on your device, use the following\ncamera AIDL HAL interfaces:\n\nLocation: `/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl`\n\n- [`void turnOnTorchWithStrengthLevel(int torchStrength)`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl?q=turnOnTorchWithStrengthLevel)\n- [`int getTorchStrengthLevel()`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl?q=getTorchStrengthLevel)\n\nEnsure your HAL implementation advertises the following camera characteristics\nkeys to support the torch brightness control feature:\n\n- [`FLASH_INFO_STRENGTH_MAXIMUM_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_MAXIMUM_LEVEL)\n- [`FLASH_INFO_STRENGTH_DEFAULT_LEVEL`](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_DEFAULT_LEVEL)\n\nFor a reference Camera HAL implementation supporting torch strength control,\nsee\n[`EmulatedCameraDeviceHWLImpl.cpp`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/google/camera/devices/EmulatedCamera/hwl/EmulatedCameraDeviceHWLImpl.cpp).\n\nValidation\n----------\n\nTo validate your implementation of the torch strength control feature, run the\nfollowing VTS and CTS tests:\n\n- VTS: [`/camera/provider/aidl/vts/VtsAidlHalCameraProvider\\_TargetTest.cpp`](https://cs.android.com/android/platform/superproject/+/android-latest-release:hardware/interfaces/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp)\n- CTS: [`/platform/cts/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/camera/src/android/hardware/camera2/cts/FlashlightTest.java)"]]