I thought that I could do better than that and tried to find a way to achieve the same what Screen Dimmer was doing without running into its limitations. Since the Android OS power manager handles the FLAG_KEEP_SCREEN_ON and also suspends the OS and running apps on a screen lock, I thought why not letting the power manager do its jobs and just prevent the touch controls (screen and keys) from suspending. Then one could wake the device from screen lock by emulating a power button press on touch. After a user defined delay after screen off the touch controls also get suspended. The only complication was to monitor the power button, so one can differentiate between screen timeouts, for which the touch controls should be kept enabled for a certain time, and a screen lock manually triggered by the user by pressing the power button, for which the touch controls should be disabled right away.
So with Touch Wake, one can wake the device from suspend (for a certain user-defined time after screen off) by touching the touchscreen or the touchkeys. Combined with a OS level tweak which disables the lock screen on timeout for a certain time or altogether (for example in CM 7.03, but also available as standalone apps from the Market), one can achieve the same functionality as Screen Dimmer. Compared to Screen Dimmer, Touch Wake has the advantage that the screen will not be blanked as long as the FLAG_KEEP_SCREEN_ON is set and also the battery drain while the screen is off will be significantly less because only the touch controls are kept enabled and the Android OS and running apps are properly put to sleep. For the record, with Touch Wake, while the touch controls are still enabled, the kernel is kept in a wake lock, so the battery drain will still be a little higher than for the normal stock screen lock, however it is a significant improvement over Screen Dimmer.
To enable (disable) wake on touch pass 1 (0) to 'enabled' in /sys/class/misc/touchwake. Pass the delay (until the touch controls will be disabled after screen off) in ms (this is milliseconds; 1000ms = 1s) to 'delay'; a value of 0 for the delay means the touch controls will be kept enabled indefinitely. The default state is disabled and a delay of 45000 = 45s.
Changes to the source (based on kernel with BLD 3 and Screen Dimmer 1):
Fixed BLN not working properly anymore.
Bug fix: http://www.pastie.org/2446398
Fixed the problem with the proximity sensor not reactivating the screen when making calls. Also, since I was in the neighborhood I also fixed the problem with BLD on the i9023.
Bug Fix: http://www.pastie.org/2457092
I cleaned up the code a bit for all three mods BLD, Screen Dimmer and Touch Wake.
Bug fix: www.pastie.org/2488785
Fixed the BLD problem for the i9023 of the touchkey backlights not being re-enabled on touchkey press.
Bug fix: http://www.pastie.org/2499956
Fixed the problem of the touch controls misbehaving after the proximity sensor has blanked the screen during a call.
Bug fix: http://www.pastie.org/2528577
Fixed the problem with BLD on the i9023 of the touchkey backlights getting activated when the bottom of the touchscreen was touched.
Bug fix: http://www.pastie.org/2544546
For Touch Wake, call the suspend function a bit earlier to prevent a rare hiccup happening when the touch controls are pressed in exactly the same moment the screen is disabled.
For BLD, Screen Dimmer and Touchwake, use mutex_trylock instead of mutex_is_locked/mutex_lock combo to avoid race conditions.
No further patches will be published here. I have set up a git repo for all my tweaks. Each mod has its own branch to keep the tweaks cleanly separated and one can simply pull the latest patches from the corresponding branch.
Get Jonathon Grigg's 'Spark Mod Manager' GUI for controlling Touch Wake: http://forum.xda-developers.com/show...php?p=17291034
I do not accept donations and since I reached my 50GB limit of free space on SpiderOak, thanks to all of you kind people who got an account using my referral link, I could not ask for more.
Instead if you really want to donate your hard earned money to someone who deserves and needs it, consider donating to the Free Software Foundation at fsf.org: These guys are at the frontline when it comes to keeping Linux free and fighting these greedy bastards who think they are entitled to collect royalties and other fees from Linux users due to some silly patents - and if Linux falls, Android will be next.