LED Access/Permissions

661 views
Skip to first unread message

engr04

unread,
Apr 25, 2012, 10:40:06 PM4/25/12
to andro...@googlegroups.com
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? 

Dianne Hackborn

unread,
May 3, 2012, 8:50:54 PM5/3/12
to andro...@googlegroups.com
Sorry no there is not.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/qlmnXptzfDMJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Phoenix Wang

unread,
Jul 4, 2016, 12:34:36 PM7/4/16
to android-ndk, nsd...@gmail.com
Hey. I know it's too long ago. But for now I'm doing a similar project as you did. Have you resolved that with NDK? for 100s accuracy? Thanks!

在 2012年4月26日星期四 UTC+2上午4:40:06,engr04写道:

Patrik Hadorn

unread,
Aug 4, 2016, 11:42:19 AM8/4/16
to android-ndk, nsd...@gmail.com
Just as an idea, haven't tried myself, wouldn't you be able to use OpenMAXAL to control the flash of the camera? The headers hint that this functionality is there and you might be able to flash it at the frequency you require.

Glenn Kasten

unread,
Aug 4, 2016, 11:56:07 AM8/4/16
to android-ndk, nsd...@gmail.com
AFAIK the camera portion of OpenMAX AL is not implemented in Android.
Reply all
Reply to author
Forward
0 new messages