Thursday, June 28, 2012

Android | Linux LED control from shell

Recently while playing around with my phone [Xperia X10] . I found a lib in /sys/hw named ,  its a proprietary library for the lights on the phone, that includes camera flash light, notification led and the led below the home|return keys. I wanted to disassemble the file, I thought there might be someway i can control LED's from the shell. Maybe there is a function to control the LED's and I could write a program that could be linked to run, But things turned out to be more simpler. I ran objdump on the file and was pretty much disappointed at the code it generated. I thought maybe strings will hold something for me

$ strings > lights.es209ra_so_str.txt

and voila, the last few lines of the line read

write_int failed to open %s
Rachael lights module
Sony Ericsson Mobile Communications

Then I realized that in linux everything must be implemented as file so I quickly checked into /sys/class/leds  and there was exactly what I wanted

Googled the linux led handling then I came across this file

Linux really did have a plan for handling the led signals. Coming back, I just typed in 1 into the brightness file and voila there it was my camera flash was glowing

Apparently lv5219lg:fled turns out to be the camera flash LED

Mostly all the android phones handle their LED's the similar way. Check yours out, play around, have a nice time... and ya the rest of the LED's work similar way only didn't have time to check the notification ones from terminal emulator ( they seem to be locked when connected to computer or there is a delay setting !!! ). 

No comments:

Post a Comment