I have an application where I need to be able to toggle the flashlight LED accurately to about 1ms, potentially down to 100us.
I've tried doing this in Java using setFlashMode and camera.setParameters. However, it is only accurate to ~100ms, and sometimes worse. I can provide additional code if that will be helpful, but I have a feeling that won't be necessary.
It would be best to write a native C application to do this. However, I haven't been able to find a way to access the LEDs through NDK. It seems I don't have permissions. I've tried some shell commands using adb shell:
$ cat /sys/class/leds/flashlight/brightness
0
#Set the flashlight brighteness to 50%
$ echo 128 > /sys/class/leds/flashlight/brightness
cannot create /sys/class/leds/flashlight/brightness: permission denied
This does work if I am root. However, I'd like my application to work on non-rooted devices.
Is there another way to access the LEDs through NDK?