Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,733,372 Members 39,271 Now Online
XDA Developers Android and Mobile Development Forum
Announcement from abusalimov: Prevents Wi-Fi from waking up on the lock screen or by application Wi-Fi locks

[MOD][XPOSED][KK] Wi-Fi Deep Sleep

Tip us?
 
abusalimov
Old
#1  
Member - OP
Thanks Meter 62
Posts: 55
Join Date: Mar 2014
Location: St. Petersburg

 
DONATE TO ME
Default [MOD][XPOSED][KK] Wi-Fi Deep Sleep

Only for Android KitKat.

Once installed this mod prevents Wi-Fi from waking up during device sleep mode and when you turn on the screen without unlocking it (to look at the clock, for example).

Background

Normally Wi-Fi can be awakened and kept on due to Wifi locks held by certain applications that often use to abuse this opportunity. This results in Wi-Fi being turned on over up to the half of the total sleep time (or even more) which in turn of course eats the battery. Another issue is that once turned on by a single application it notifies and awakes lots of other apps that may start, for example, their heavy synchronization tasks, etc., making everything even worse.

Auto Wi-Fi apps

Nevertheless, Wifi lock is a good mechanism when used carefully, and generally it should be respected when deciding whether to switch Wi-Fi on and off. This becomes a problem for most of Wi-Fi management apps found in Play Market: they can switch Wi-Fi off in the middle of a Skype call just because the screen was turned off.

The solution

This mod alters a system state machine responsible for managing Wi-Fi so that once put to sleep it can not be woken up by any application that requests a lock. Wi-Fi is only put asleep when no application holds a lock. That is it doesn't cancel locks held already, but once all of them are gone, no one else is able to aquire a new lock until the screen is turned on and unlocked. This doesn't apply to special high performance Wifi lock, it still can be aquired as usual even in asleep mode (anyway, it seems that applications does not use to use this lock too often, so the battery should not became an issue).

Installation
  1. Download and install Xposed framework
  2. Then install Wi-Fi Deep Sleep module and activate it
  3. Reboot
Usage

To make the mod to take an effect proceed to Settings -> Wi-Fi -> Advanced and make sure that:
  • Keep Wi-Fi on during sleep is either Only when plugged in or Never (increases data usage)
  • Scanning always available is turned off
The module provides no user interface, nor it runs any services in a background: only modifies a corresponding part of Android. You won't be able to notice it in the main menu or in a task manager. Think of it as a patch that can be turned on and off through Xposed installer.

Source
The mod is open source (with permissive MIT licence), the source code is available on my GitHub.


XDA:DevDB Information
Wi-Fi Deep Sleep, Xposed for all devices (see above for details)

Contributors
abusalimov
Xposed Package Name: ru.abusalimov.xposed.wifideepsleep

Version Information
Status: Stable
Current Stable Version: 1.0

Created 2014-05-16
Last Updated 2014-05-15
The Following 10 Users Say Thank You to abusalimov For This Useful Post: [ Click to Expand ]
 
Kocayine
Old
#2  
Kocayine's Avatar
Senior Member
Thanks Meter 137
Posts: 954
Join Date: Apr 2012
Interesting. I assume this would mean no push notifications, etc.
Please quote my posts if you are replying to one of my posts, that way I'll get notified.
 
abusalimov
Old
#3  
Member - OP
Thanks Meter 62
Posts: 55
Join Date: Mar 2014
Location: St. Petersburg

 
DONATE TO ME
Quote:
Originally Posted by Kocayine View Post
Interesting. I assume this would mean no push notifications, etc.
Yes, unless there is a mobile network available. That is the mod would be more useful for a phone rather than for a tablet.
The Following User Says Thank You to abusalimov For This Useful Post: [ Click to Expand ]
 
Kocayine
Old
(Last edited by Kocayine; 16th May 2014 at 02:02 AM.)
#4  
Kocayine's Avatar
Senior Member
Thanks Meter 137
Posts: 954
Join Date: Apr 2012
Quote:
Originally Posted by abusalimov View Post
Yes, unless there is a mobile network available. That is the mod would be more useful for a phone rather than for a tablet.
If mobile data is enabled while wifi is connected and running, then screen turns off and wifi goes to deepsleep, does it then use mobile data? I'm having issues sometimes where a "suspend_backoff" wakelock can keep my phone awake indefinitely and it's wifi related. Perhapsthis module could help.

Ah it took me until now to notice it's KK. No chance of a jb version?
Please quote my posts if you are replying to one of my posts, that way I'll get notified.
 
abusalimov
Old
#5  
Member - OP
Thanks Meter 62
Posts: 55
Join Date: Mar 2014
Location: St. Petersburg

 
DONATE TO ME
Quote:
Originally Posted by Kocayine View Post
If mobile data is enabled while wifi is connected and running, then screen turns off and wifi goes to deepsleep, does it then use mobile data? I'm having issues sometimes where a "suspend_backoff" wakelock can keep my phone awake indefinitely and it's wifi related. Perhapsthis module could help.
Yes, once Wi-Fi goes asleep, it instantly connects to use mobile data. This behavior is similar to default one, the only difference is that once it goes to sleep it will not wake up and try reconnect to Wi-Fi constantly, instead it will continue to use mobile data until you turn on and unlock the screen again.

Regarding a weird wakelock, the simplest answer is to try by yourself. Personally I got rid of "wlan_rx_wake" locks (drastically though not completely). I guess this depends on a device.
 
abusalimov
Old
#6  
Member - OP
Thanks Meter 62
Posts: 55
Join Date: Mar 2014
Location: St. Petersburg

 
DONATE TO ME
Quote:
Originally Posted by Kocayine View Post
Ah it took me until now to notice it's KK. No chance of a jb version?
Not in a near future, I'm afraid. In KK they had rewritten the whole Wi-Fi management code from scratch, so for JB it would be a completely different module. Sorry for that.
 
verynuclear
Old
#7  
verynuclear's Avatar
Senior Member
Thanks Meter 182
Posts: 757
Join Date: Aug 2010
Location: UAE
Great module
I was looking for something like this great idea.
Thanks a lot.

Sent from my HTC One using Tapatalk
 
david6910
Old
#8  
david6910's Avatar
Member
Thanks Meter 9
Posts: 96
Join Date: Jan 2011
But if i was downloading a file?
 
robneymcplum
Old
#9  
Senior Member
Thanks Meter 76
Posts: 370
Join Date: Oct 2007
Location: midlands
Probably a really stupid, obvious question but.....

If I turn wifi off manually, as I normally do leaving the house...etc... I assume this module will be of no use to me? Would only work if wifi was on, but not being accesed or used by me? Having wifi off means its off, right?
 
abusalimov
Old
#10  
Member - OP
Thanks Meter 62
Posts: 55
Join Date: Mar 2014
Location: St. Petersburg

 
DONATE TO ME
Quote:
Originally Posted by david6910 View Post
But if i was downloading a file?
This depends on a downloading application. Personally I was only concerned about Skype, which takes necessary locks and prevents this mod to turn off Wi-Fi during a call (unlike most of other apps that turn Wi-Fi off unconditionally).

Again, the mod itself doesn't make a big change to a default behavior. If you switch "Keep Wi-Fi on during sleep" to "Only when plugged in" or "Never" then downloading a file will or will not be interrupted regardless whether you have this mod installed or not. Try the default behavior without the mod to see if downloading will go on after the screen is switched off (plus about 15 minutes timeout). If everything's OK, then installing the mod shouldn't make if worse (it will however prevent an app from using Wi-Fi to download a new file by itself during the night after Wi-Fi goes asleep).

Tags
battery saving, kitkat, wake lock, wi-fi
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes