Change torch brightness while camera preview is working

In Android 13 (API 33) a new control is appeared to adjust torch brightness:
public void turnOnTorchWithStrengthLevel ( cameraId, int torchStrength)

But invoking this function during a working camera preview raises an Exception:
android.hardware.camera2.CameraAccessException: CAMERA_IN_USE (4): turnOnTorchWithStrengthLevel:2596: Torch for camera “0” is not available due to an existing camera user

The only way to use torch during preview is to adjust capture request builder with option:
builder.set(CaptureRequest.FLASH_MODE, if (isOn) CaptureRequest.FLASH_MODE_TORCH else CaptureRequest.FLASH_MODE_OFF)
But it not allows to modify flashlight brightness.

Hello alexei.maiyorov,
Is this issue only occurring in Samsung Galaxy devices? Have you tried to reproduce the issue on any non-Samsung Device like Pixel? If so, can you share your experience?

Thank you,
Ummey Habiba Bristy
Samsung Developer Program Team

Hi UmmeyHB.
Actually, I haven’t chance to try it on non-Samsung device. I am not really sure, but I almost believe the result will be the same.

Hello alexei.maiyorov,
In which Galaxy devices the issue is reproducing?

Thank you,
Ummey Habiba Bristy
Samsung Developer Program Team

Hello UmmeyHB
S20 and S22 Ultra.