Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,740,721 Members 51,953 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][KERNEL] Touch Wake

Tip us?
 
Ezekeel
Old
(Last edited by Ezekeel; 7th November 2011 at 06:30 PM.)
#1  
Ezekeel's Avatar
Retired Recognized Developer - OP
Thanks Meter 1707
Posts: 715
Join Date: Jun 2011
Default [MOD][KERNEL] Touch Wake

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.
The Following 44 Users Say Thank You to Ezekeel For This Useful Post: [ Click to Expand ]
 
reddv1
Old
#2  
reddv1's Avatar
Senior Member
Thanks Meter 334
Posts: 624
Join Date: Sep 2009
Location: Torrance, CA
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
Phone: Nexus 4 16 GB
Carrier: T-Mobile USA
ROM: AOKP
Kernel: [KERNEL][MOD] Increase Touchscreen Sensitivity 4.2.2

AOKP Kangs Nexus 4&7
 
Ezekeel
Old
#3  
Ezekeel's Avatar
Retired Recognized Developer - OP
Thanks Meter 1707
Posts: 715
Join Date: 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: [ Click to Expand ]
 
morfic
Old
#4  
morfic's Avatar
Recognized Developer
Thanks Meter 12907
Posts: 7,177
Join Date: Aug 2008
Location: San Antonio
Can you stop copy pasting this "couldn't reach morfic"
That would be awesome.
Sent from my Nexus S using Tapatalk
Email me, i suck at replying to PMs.



Direct link to my GIT - http://www.bitbucket.org/morfic/
Direct link to my *old* GIT - http://morfic.euroskank.com/git/

twitter - @morfique
Talk to me on freenode's #trinitykernel
1KBSMtMTDSTr9XU23sYr9wZJBfb2RwpWnf

You may call me "gun powder"
The Following 2 Users Say Thank You to morfic For This Useful Post: [ Click to Expand ]
 
Ezekeel
Old
#5  
Ezekeel's Avatar
Retired Recognized Developer - OP
Thanks Meter 1707
Posts: 715
Join Date: 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: [ Click to Expand ]
 
Enhanced
Old
(Last edited by Enhanced; 29th August 2011 at 04:31 AM.)
#6  
Enhanced's Avatar
Senior Member
Thanks Meter 256
Posts: 1,024
Join Date: Sep 2010
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.
 
jjhrrsn
Old
#7  
jjhrrsn's Avatar
Senior Member
Thanks Meter 211
Posts: 776
Join Date: Aug 2011
Location: Portland
Bump sounds ballin

Sent from my Nexus S 4G using xda premium
The Following User Says Thank You to jjhrrsn For This Useful Post: [ Click to Expand ]
 
simms22
Old
#8  
simms22's Avatar
Recognized Contributor
Thanks Meter 20740
Posts: 24,982
Join Date: Jun 2009
Location: BROOKLYN!
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
Google+ Profile
Twitter Simms22
DerKernel For Trinity kernels and more!
 
rejanmanis
Old
(Last edited by rejanmanis; 29th August 2011 at 02:20 PM.)
#9  
rejanmanis's Avatar
Senior Member
Thanks Meter 64
Posts: 445
Join Date: Feb 2011
Location: Jakarta
Quote:
Originally Posted by morfic View Post
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
 
nbeebe24
Old
(Last edited by nbeebe24; 29th August 2011 at 10:04 AM.)
#10  
nbeebe24's Avatar
Recognized Themer
Thanks Meter 866
Posts: 2,315
Join Date: Jun 2009

 
DONATE TO ME
Sounds like an awesome mod

Sent from my Nexus S using XDA App

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes