The Atlas of XDA

A few weeks ago, we asked you “How Does Your Location Affect Your Life As A Power User?”. In the days that … more

New Snapdragons: Some Context & Contrast

It hasn’t been a good year for Qualcomm so far. Every device featuring the Snapdragon 810 … more

Google To Launch Next Gen Android One On July 14

The first gen of Android One devices to be launched in India in September 2014 were … more

Droid Turbo Lollipop OTA, 2015 Moto G Leaked – XDA TV

Android Lollipop for the Droid Turbo has been released. That and much more … more

[APP][2.1+][15 Jun - 2.1] Better Wifi on/off

4,502 posts
Thanks Meter: 15,267
By chamonix, Recognized Contributor on 28th July 2012, 12:42 PM
Post Reply Subscribe to Thread Email Thread
Better Wifi on/off is the latest creation of project better. It is an agent managing your Wifi state based on heuristics (set of rules).

This app aims at giving you the control of the Wifi state, optimizing your battery life without losing on user experience.

Better Wifi on/off releases are available from Google Play. Development versions will be made available on xda for testing new features / fixes.

The app is free, fully featured with ads.
If you want to support me and/or get rid of the ads you can purchase a "support-the-dev" version on google play.

What is the motivation behind controlling Wifi?
On paper Wifi is less power hungry than 3G but... some apps behave differently when Wifi is on (DropBox / Google+ uploads, Google Maps location caching), the well known wlan_rx kernel wakelock is a symptom of wakeups caused by uncontrolled Wifi hotspots, the Wifi sleep policy is not working consistently and does solve all problems.

Settings to control Wifi
The preferences allow you to control Wifi.

The basic rules for keeping Wifi on / turning Wifi off are (will vary based on your settings):

When device is turned on Wifi stays on if: "network is connected" AND "the access point is whitelisted" && "wifi is not caged (a connection to can be made)"
When screen goes off Wifi stays on if: "phone is in call" OR "network activity was detected" OR "tethering is on" OR "wakelocks from other apps using network were detected"

There are of course plenty of settings to change that behavior like e.g. keep Wifi on if connected to A/C, leave Wifi on as long as connected to a whitelisted SSID.

This project is open source und the Apache license. Please feel free to browser the repo, review, fork it as you like:

Bugs / Feature requests
Open bugs and feature requests can be found on github here:

If you want to report a bug you can to it there but also simply post it here, I'll take care of documenting it and reply with the issue number for an easier tracking.

- no changes from RC3

- updated russian translation
- added more logging on detected connected SSIDs

#120: a hopefully better fix for cage check timings
#125: added a pref for leaving wfi on when screen goes off but a connection is active

Added direct link to gplay from main screen

#120: start thread for cage check earlier (at wifi on)
Added timed checks
Loading application whitelist is asynchronous

#115 threaded cage check
Added more logging to solve the "alarm: null" error
Updated russian language file
Added timestamps to logcat output

#115: better cage detection
#116: inconsistent messages when enabling/disabling from the widget
#117: inconsistent plug/unplug event messages
#119: null pointer exception with message alarm: null
Fix for detection support the dev version

Older changelogs

#92: enable/disable messages are shown multiple times and are not consistent to the user events

#91: Wifi should be turned off when screen is off and whitelisted a/p gets disconnected

V. on Google Play
No changes from latest RC
Merged to master

#112: A better fix for donation detection

#112: Fixed donation detection
ActionBar style for pre-ICS phones

#110: fixed CDMA cell collection

#104: added share/save feature
#105: handle CDMA cells
#106: event log on whitelist shows %s instead of real value
#107: added "clear cell log"
#108: null pointer is cellinfo is null
#109: blank SSID causes the A/P to be handled as whitelisted

#103: fixed issue with unfinished database transation
Removed pull-to-refresh as no longer maintained
Optimized dialogs

#11: added cell tower awareness and rule to turn Wifi on only if connected of known cell
#102: app wihtelist does not keep checked apps

#98: add check for whitelisted app: when running Wifi will not be turned off

Uses ActionBarSherlock for same UX on all android versions
Use Pull-to-Refresh to update list
#95: enabling with widget turns wifi on
#96: avoid scheduling wifi off when screen goes off but wifi is off already
#100: preference to select between light and dark theme
Added russian

#90: wrong message when user disables/enables processing by tapping the widget

#88: When disregard airplane mode is enabled wifi is not turned on when screen is turned on
#89: disabling / enabling handling based on user action on wifi outside of BWOF should be logged
New readme and rate dialogs

No change from RC1

#82: pref to re-enable BWOF when Wifi is turned on manually
#84: conneting power does not respect airplane mode
#85: when pref is undefined turning screen on enables wifi even if this action is set on unlock

Fixed various FC conditions from logs/gplay dumps

#83: potential FC when opening preferences

No change. Grab it from Google Play

no changes, done all the merging and prepared for release

#39: advanced pref to connect to best available network
#80: make sure to always cancel pending alarms when screen is turned on
#81: allow to disable Wifi on function completely

#77: widget bg is not 100% transparent
#78: screen on/unlock should always make sure that pending alarms for Wifi-off are canceled
#79: losing connection to access point should never cause handling to get disabled, only user turning Wifi off

#19: disable processing when user turns Wifi off using the settings
#70: add second URL for cage detection check
#76: fixed API returning quoted SSIDs (bug found on 4.2)
Compiled with new SDK

#69: locale/tasker plugin to enable/disable processing
#71: reduce event logging
#73: fixes for french
#74: widget to control processing (enable/disable)
#75: pref to ignore airplane mode and still enable/disable Wifi

#68: fixed cage detection

#67: fixed SQLite exception and missing perm

#65: respect airplane mode for all screen events

#61: fixed event log sorting to DESC
#62: whitelist shows quotes around some SSIDs
#63: inconsistent placement of pref "if plugged" between simple and expert mode prefs
#64: changes in SSID whitelist are not reflected immediately

New fix for not always visible event log (is not persisitent)
Check for turning Wifi off now goes on every 15 minutes instead of stopping after 5 retries (needed for #51)
#51: rule for leaving Wifi on when screen goes off and SSID whitelisted
#57: fixed whitelist detection not working in RC4
#58: fixed whitelist prefs for post-GB devices
#59: encoding in pref for network activity
#60: SSID should show configured and not available SSIDs

#51: added rule to not turn Wifi off when screen goes off but a whitelisted SSID is connected to (pref)
#54: Alarm should go on every 15 minutes in order to disconnect when whitelisted SSID is not connected anymore
#55: respect airplane mode (do nothing if detected)
#56: reordered prefs by rules for leaving wifi on "when screen on" and "when screen off"

#50: Wifi off delay labels were misleading
#52: whitelist is no multi select list on SDK >= 11
#53: do not check wakelocks when wifi is turned off as a result of "leave Wifi on" rules

#49: added perm to read logs (pre JB)

Cleaned up home screen, moved "disable" to (advanced) prefs

#48: removed 'grep' command from logcat

#41, 43: option to save preferences / logcat as debug info
#42: repertoed typos
#44: added simple and expert preferences
#45: removed own logfile

#46: removed not requires prefs: leave on if in call and if tethering are both always handled

#40: don't turn Wifi off is Wifi tethering is active
Added german and french translations
#31: wifi goes off when unplugged but screen is on
#32: calling the app from notification does not show even log
#33, 35: make pref labels consistent
#37: alarm for turning Wifi off should not obcess
Fix for Wakelock detection

#36: added wakelock detection to keep Wifi on when background apps (e.g. streaming) are running

#29: a delay of 0 skips some checks before turning Wifi off
#30: fixed binder error
Added better network activity detection before turning Wifi off (besides download manager, see preferences)

#27, #28: added more logging / event logging

Added icons to action bar (ics+)
#17: keep wifi active when screen goes off and downloads are running or queued
#26: keep wifi active when screen goes off and in a call

#20: (another attempt to fix) fast off/on causes Wifi to be turned off be not canceled alarm
#25: editing SSID whitelist causes the correct connection to be re-validated (after the configured timeout)

#21: Wifilock checkbox on main screen is not sticky
#22: Broadcast handler is not allowed to send events to Service
#23: Wifilock pref caused FC
#20: fast off/on causes Wifi to be turned off be not canceled alarm

#8: Wifilock when connected and permanent
#9: option to stay on only if connected to a whitelisted SSID
#13: add Wifi power management: high perf Wifilock
#15: fixed bug not disabling all functions

#7: fix for FC condition on punplug

#5: not all actions are documented on screen
#6: option to hold wakelock during plugged to prevent the phone from sleeping

#1: removed preference "on only if previously on": far too complex to explain
#3: added a preference to disable the handling
#4: preference to leave Wifi on when screen goes off but phone is on charger
- initial beta release
Last edited by chamonix; 15th June 2013 at 10:26 PM. Reason: Release
The Following 155 Users Say Thank You to chamonix For This Useful Post: [ View ]
28th July 2012, 12:43 PM |#2  
chamonix's Avatar
OP Recognized Contributor
Thanks Meter: 15,267
How To
How to report a bug
Reporting this or that is not working does not help. This is a development thread and I expect a minimum set of information:
- What version are you using
- What behavior did you expect
- What behavior did you get
- How to reproduce the problem
- a Log
You can report bugs in this thread or on github (see post #1 for links)

How to request a feature
Simply post what you would like to have. If others (and I) like the idea it will be implemented (as long as possible)
Last edited by chamonix; 28th July 2012 at 01:12 PM.
The Following 7 Users Say Thank You to chamonix For This Useful Post: [ View ]
28th July 2012, 12:43 PM |#3  
chamonix's Avatar
OP Recognized Contributor
Thanks Meter: 15,267
Q: Why would I need an app to control my Wifi state?
A: If you are happy with your settings and your battery life you don't need it

Q: How can I find out if Wifi is draining my battery?
A: Use Better Battery Stats

Q: But Wifi consumes less power than 3G, Why would I want to turn Wifi off?
A: Theoretically true but... Many apps behave differently when Wifi is on, like e.g. Dropbox or Google+ upload features. Besides that the famous wlan_rx kernel wakelocks show that incoming traffic can wake up your phone, causing a lot of overhead. And finally the Wifi sleep policy is not optimal for everyone (if working at all)

Q: Will this app stay free?
A: yes, free with ads but fully featured. There will be a donate version to support me but that version will only remove the ads

Q: Will this app be available on Google Play?
Yes, once out of beta. To be efficient a beta must be limited to a small user group. Besides, psoting feedback in the rating on Google Play is a) lame and b) does not help the devs

Q: Is there a help?
A: No, this app should be self explaining so if you find something unclear please report it as a bug, I'll take care of it.

Q: Why does BWOF disable after a reboot?
A: Certain devices / Android versions seem to have a different handling of turning Wifi off when rebooting, making BWOF believe that Wifi was turned off by user. I have no way of finding out what devices are affected and how to fix this. A workaround is to not enable "Disable when user turns Wifi off".
Last edited by chamonix; 1st June 2013 at 08:48 PM.
The Following 5 Users Say Thank You to chamonix For This Useful Post: [ View ]
28th July 2012, 01:30 PM |#4  
Senior Member
Thanks Meter: 48
Thanks, will give it a try.
28th July 2012, 01:34 PM |#5  
Senior Member
Thanks Meter: 41
Wow, chamonix does it again. You are awesome. Can't wait to see how this works!
28th July 2012, 02:41 PM |#6  
RovG's Avatar
Senior Member
Thanks Meter: 156
Hi Chamonix,

Thank you for another useful creation. :thumbup:

Please can you advise what would happen if wifi is off but mobile data (use packet data) is enabled and an app woke up the device requiring network access? I guess what I am hinting at: will it be possible for this app to disable mobile data as well?

Sent from my GT-I9100 using xda premium
The Following User Says Thank You to RovG For This Useful Post: [ View ]
28th July 2012, 02:51 PM |#7  
Senior Member
Thanks Meter: 43
What you think a option to have WiFi_lock with the WiFi on? Many ppl have issues to transfer files via WiFi and speed go down if display turn off, with this added in you app we can control WiFi all in same place.
Last edited by Edwrib; 28th July 2012 at 02:52 PM. Reason: wrong auto correction.
28th July 2012, 02:58 PM |#8  
chamonix's Avatar
OP Recognized Contributor
Thanks Meter: 15,267
Originally Posted by RovG

Hi Chamonix,

Thank you for another useful creation. :thumbup:

Please can you advise what would happen if wifi is off but mobile data (use packet data) is enabled and an app woke up the device requiring network access? I guess what I am hinting at: will it be possible for this app to disable mobile data as well?

Sent from my GT-I9100 using xda premium

Possible yes but this will never happen!
A) because this app manages wifi and
B) this would cause more drain than anything else as the app would cause partial wakelocks and maybe even wakeups

If you don't want apps to use data select those that have proper settings / implementations
28th July 2012, 03:03 PM |#9  
suku_patel_22's Avatar
Senior Member
Flag Mumbai
Thanks Meter: 975
Well, for the cell based locations, i would suggest to do it based on cell id rather than location provided by network.

Once that is done, this would help me a lot.
28th July 2012, 03:19 PM |#10  
Account currently disabled
Thanks Meter: 270
Looks great! I'm about to try.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes