Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check front flash available using camera2 API

I'm testing my camera app on Samsung J7 Pro which have front flash (real hardware LED flash). When I'm checking front flash available with the deprecated Camera API using:

List<String> supportFlashModes = defaultParameters.getSupportedFlashModes();
boolean isSupportedFlashMode = (supportFlashModes != null && supportFlashModes.contains(Camera.Parameters.FLASH_MODE_ON));

it works properly, the supported flash modes return 4 values (on, off, auto_flash, always_flash) for front camera.

But when I'm checking with the new Camera2 API using:

Boolean b = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
boolean isSupportedFlashMode = b != null ? b : false;

isSupportedFlashMode always return false for front camera. And if I check the supported flash modes using:

characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_MODES);

it's also return only 2 values (ae_on, ae_off).

Does anyone know how to solve this? Note that I've just want to check the availability of device's front flash Thank you.

Update

These methods worked fine on my Q-Mobile device (which also have a real LED front flash), but still not working on Samsung J7 Pro. I don't know why?

like image 770
nhoxbypass Avatar asked Mar 22 '18 11:03

nhoxbypass


1 Answers

It seen to be a device related issues. My company app which using camera2 API also faced the same problem.

I've already try to test it with a simple sample and OpenCamera but none of them worked. Then I decided to hold this bug till now because the number of devices that have front flash is small and most of them worked fine.

like image 100
Nha T. Tran Avatar answered Sep 22 '22 23:09

Nha T. Tran