[G1 Android Development] Loccy:
So I decided to see if I could work around the fact that the keyboard and navigation button backlights on the G1 don't work on ROMs that are taken from keyboard-less devices, e.g. Hero, Eris, Legend, etc. I suspect this will never actually be fixed "properly" because the frameworks etc in such ROM dumps can (in normal circumstances on their intended devices) safely assume there's no keyboard device.

In /sys/class/leds there are "folders" and "files" for each of the lights on the phone, i.e. one for the keyboard backlight, one for the button backlights, the jogball light, and the leds. You can actually manually turn these lights on by piping the number 1 into the brightness file of the corresponding light, e.g. echo 1 > /sys/class/leds/keyboard-backlight will turn the keyboard backlight on.

So, why my script does is sit monitoring logcat for certain lines that indicate appropriate events, and pipe the appropriate number into the right backlight brightness "file" accordingly.

To test, you can push it to your phone as follows:

adb remount (to enable read-write of /system)

adb push lightbodge.txt /system/bin/lightbodge.sh

Then, to test it:

adb shell

chmod 777 /system/bin/lightbodge.sh

sh /system/bin/lightbodge.sh

Note - the filename in the second line is "lightbodge.txt" in one place and "lightbodge.sh" in another. That's not a mistake. The board won't let me attach .sh files.

Check you're happy with it doing what it's supposed to while still connected to your PC. Then, you can do one of two things:

1) just do

su

sh /system/bin/lightbodge.sh &

at a terminal on your phone

or

2) you could probably add it to your a2sd script

Known concerns:

* Bear in mind that I don't have a G1 myself - I have a Magic. So I am dependent on you lot for testing and information! At the moment, it's looking for a "rotate" event because no-one's been able to give me a distinct entry in logcat for the keyboard being opened. So the keyboard light may well come on if you rotate the phone as well as when you pull open the keyboard. Also, if you open the keyboard but aren't triggering a rotate (maybe you were already in landscape?) I'm not sure there's an event for my script to see. Please give me any logcat information you can and join in the discussion so I can get some more info.

* On my MT3G, I'm getting odd results. If my phone is being charged or plugged into the USB in any way - even if the USB is not being used - then it all works as I'd expect. If it's unplugged, it seems oddly unreliable. I need as many testers to try it on their phone and tell me what results they get.

* This script is running once every second, and doing two logcats each time. I'm not convinced about this not being a big hit on performance yet. It needs testing in real life.

How you can help:

* I need as much information about what the G1 does when you pull the keyboard as possible. If anyone can narrow down a consistent logcat line that happens when the keyboard is opened and closed and ONLY when the keyboard is opened/closed, that's the holy grail of this thread at the moment.

* In theory we should be able to do something with LEDs for notifications for things like emails, etc. Again, consistent and unique logcat entries for things like email received, SMS received, would be useful on that front.

* other devs: feel free to tidy up and improve on my script. I freely admit it's just flung together. In particular, there must be a more elegant way of monitoring logcat than what I'm doing. And if any of you can come up with that holy grail logcat line, that'd be great.

Changelog

Version 0.1 (see post 7) - initial version

Version 0.2 - slight tidying up - no reason why you should use it though

Version 0.3 (current version attached to this post)

- changed to detect activities based on log file size rather than grep

- hopefully better logcat triggers being used to the various activities

- tested at least on my MT3G - navigation button lights work when script dumped into A2SD*