Post Reply

[MOD][KERNEL] Touch Wake

28th August 2011, 11:57 PM   |  #1  
Ezekeel's Avatar
OP Retired Recognized Developer
Thanks Meter: 1,713
 
715 posts
Join Date:Joined: Jun 2011
Last week I have released the Screen Dimmer kernel modification. While the feedback was very positive, it became clear that this mod had the limitation that the FLAG_KEEP_SCREEN_ON (set in apps, which prevents the screen lock from activating) was not preventing Screen Dimmer from blanking the screen. So if you wanted to watch a movie and did not want the screen to be dimmed all the time, you had to manually deactivate the Screen Dimmer for this period and re-enable it afterwards. Also the battery drain while the screen was dimmed was much higher compared to a proper screen lock, since only the display and the access to the framebuffer was disabled - the other hardware was still enabled and most importantly the Android OS and the apps were still running.

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):
http://www.pastie.org/2445282


BUGFIX:

Fixed BLN not working properly anymore.

Bug fix: http://www.pastie.org/2446398


BUGFIX #2:

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


BUGFIX #3:

I cleaned up the code a bit for all three mods BLD, Screen Dimmer and Touch Wake.

Bug fix: www.pastie.org/2488785


BUGFIX #4:

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


BUGFIX #5:

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


BUGFIX #6:

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


BUGFIX #7:
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.

Bugfix: http://www.pastie.org/2641540


BUGFIX #8:
For BLD, Screen Dimmer and Touchwake, use mutex_trylock instead of mutex_is_locked/mutex_lock combo to avoid race conditions.

Bugfix: http://www.pastie.org/2710096


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.

https://github.com/Ezekeel/GLaDOS-ne...tree/touchwake



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.
Last edited by Ezekeel; 7th November 2011 at 06:30 PM.
The Following 45 Users Say Thank You to Ezekeel For This Useful Post: [ View ]
29th August 2011, 12:38 AM   |  #2  
reddv1's Avatar
Senior Member
Flag Torrance, CA
Thanks Meter: 334
 
624 posts
Join Date:Joined: Sep 2009
More
Does this depend on screen dimmer code? Cause I'd like to maybe remove screen dimmer and just have this mod.

Also, thanks for putting all this time on these mods. Love your work.

Sent from my Nexus S using xda premium
29th August 2011, 12:43 AM   |  #3  
Ezekeel's Avatar
OP Retired Recognized Developer
Thanks Meter: 1,713
 
715 posts
Join Date:Joined: Jun 2011
The patch file I have provided is for a kernel already including BLD 3 and Screen Dimmer 1 (+ all bugfixes), but the code of Touch Wake does not depend on either Screen Dimmer or BLD - so you can enable BLD, Screen Dimmer and Touch Wake independently from each other in the kernel config and also could remove one tweak entirely from the kernel source if you want.
The Following User Says Thank You to Ezekeel For This Useful Post: [ View ]
29th August 2011, 01:26 AM   |  #4  
morfic's Avatar
Recognized Developer
Flag San Antonio
Thanks Meter: 12,978
 
7,199 posts
Join Date:Joined: Aug 2008
More
Can you stop copy pasting this "couldn't reach morfic"
That would be awesome.
Sent from my Nexus S using Tapatalk
The Following 2 Users Say Thank You to morfic For This Useful Post: [ View ]
29th August 2011, 03:34 AM   |  #5  
Ezekeel's Avatar
OP Retired Recognized Developer
Thanks Meter: 1,713
 
715 posts
Join Date:Joined: Jun 2011
Fixed BLN not working properly anymore.

Bug fix: http://www.pastie.org/2446398
The Following 2 Users Say Thank You to Ezekeel For This Useful Post: [ View ]
29th August 2011, 04:28 AM   |  #6  
Enhanced's Avatar
Senior Member
Thanks Meter: 257
 
1,029 posts
Join Date:Joined: Sep 2010
More
This sounds amazing.

Probably the biggest "mod" to our phones since BLN.

If the battery drain isn't terrible with this mod, I think you have a winner on your hands.

Goodjob.

EDIT: Think you should make an app that allows users to easily change the values. I could see this catching on as much as BLN has.
Last edited by Enhanced; 29th August 2011 at 04:31 AM.
29th August 2011, 04:49 AM   |  #7  
jjhrrsn's Avatar
Senior Member
Flag Portland
Thanks Meter: 212
 
780 posts
Join Date:Joined: Aug 2011
More
Bump sounds ballin

Sent from my Nexus S 4G using xda premium
The Following User Says Thank You to jjhrrsn For This Useful Post: [ View ]
29th August 2011, 06:04 AM   |  #8  
simms22's Avatar
Recognized Contributor
BROOKLYN!
Thanks Meter: 21,592
 
25,984 posts
Join Date:Joined: Jun 2009
works great!

pinned a shortcut to the on/off script onto my homescreen using gscripts. one press turns it on, second press turns it off..

Quote:

expr "(" $(cat /sys/class/misc/touchwake/enabled) - 1 ")" \* -1 > /sys/class/misc/touchwake/enabled

29th August 2011, 08:03 AM   |  #9  
rejanmanis's Avatar
Senior Member
Flag Jakarta
Thanks Meter: 64
 
445 posts
Join Date:Joined: Feb 2011
More
Cool
Quote:
Originally Posted by morfic

Can you stop copy pasting this "couldn't reach morfic"
That would be awesome.
Sent from my Nexus S using Tapatalk

I think those are deleted already. lol.

cool stuff.

so... I presume, when the screen dimmed. the crt animation will appear as well ?

and to mr simms and mr reddv1 , can i have ur test kernel included this TouchWake MOD for any ROM since i used MIUI ROM
Last edited by rejanmanis; 29th August 2011 at 02:20 PM.
29th August 2011, 08:04 AM   |  #10  
nbeebe24's Avatar
Recognized Themer
Thanks Meter: 908
 
2,404 posts
Join Date:Joined: Jun 2009
Donate to Me
More
Sounds like an awesome mod

Sent from my Nexus S using XDA App
Last edited by nbeebe24; 29th August 2011 at 10:04 AM.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Nexus S Android Development by ThreadRank