asksven / betterwifionoff Goto Github PK
View Code? Open in Web Editor NEWAn intelligent agent to manage your Wifi status
An intelligent agent to manage your Wifi status
Just installed on my TF101 and was updating a load of apps from Google Play. The screen went off, and a few minutes later I unlocked the screen and the WiFi was off (and then reconnected as expected).
It would be nice if the WiFi wouldn't drop when the screen goes off if there is data transferring (over a given threshold I guess), to avoid aborting any downloads that are in progress.
e.g. "Disable all" and "On when plugged in" still turns on Wifi
ceiverCallNotAllowedException: IntentReceiver components are not allowed to bind to services
E/AndroidRuntime(29242): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2362)
E/AndroidRuntime(29242): at android.app.ActivityThread.access$1500(ActivityThread.java:142)
E/AndroidRuntime(29242): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
E/AndroidRuntime(29242): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29242): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(29242): at android.app.ActivityThread.main(ActivityThread.java:4928)
E/AndroidRuntime(29242): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(29242): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(29242): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime(29242): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
E/AndroidRuntime(29242): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(29242): Caused by: android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to bind to services
E/AndroidRuntime(29242): at android.app.ReceiverRestrictedContext.bindService(ContextImpl.java:142)
E/AndroidRuntime(29242): at com.asksven.betterwifionoff.services.EventWatcherServiceBinder.doBindService(EventWatcherServiceBinder.java:95)
E/AndroidRuntime(29242): at com.asksven.betterwifionoff.services.EventWatcherServiceBinder.getInstance(EventWatcherServiceBinder.java:46)
E/AndroidRuntime(29242): at com.asksven.betterwifionoff.handlers.BroadcastHandler.onReceive(BroadcastHandler.java:122)
E/AndroidRuntime(29242): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2355)
TelephonyManager telephony = (TelephonyManager) mContext
.getSystemService(Context.TELEPHONY_SERVICE);
if (telephony.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK
|| telephony.getCallState() == TelephonyManager.CALL_STATE_RINGING) {
Slog.w(TAG, "Phone is ringing or in a phone call, not enabling power saver");
return;
}
There's a kernel module responsible for creating KWLs on behalf of userland processes. It exposes 2 sysfs entries at /sys/power/wake_lock and wake_unlock.
Any regular process (running as radio or as system) can write to wake_lock to create and lock a KWL with the same name as the passed text. And to unlock it, write the same text to the wake_unlock file.
It is keep going on even I close the WiFi manually.
If in a call section should be leave wifi on if not of
Wifi tethering section should be leave on not of
for consistently purposes under the rules for leaving wifi on add the word in after if plugged to match your language with the other sections.
state machine controlled by prefs "wifi_on_when_previously_on" and "last_action"
Goal:
last action shows what was the last thing done by BetterWifiOnOff
if last_action was on
but wifi is off that means that the user turned it off -> don't turn on
if last action was off
but wifi is on that means that the user turned it on -> don't turn off
Possible rules:
Together with wifi on while plugged a good way to have fast wifi as not every device stays awake while charging
wrong section, will fix but not here but in BBS :-D
0.3
consider the impact of whitelisted SSIDs
In 0.2
If in call (I feel this pref could be removed completely and the behavior aleays be as "on")
If Wifi tethering (I feel this pref could be removed completely and the behavior aleays be as "on"
rationale: if the screen is off but bigger downloads (e.g. google play updates) is running we want to wavoid turning wifi off till it is finished. This may be doable by detecting if a partial wakelock is held.
Also, the "Connection timeout" and its description indicates that it only applies to the "Only if connected" rule but I think it applies to all "Rules for leaving wifi on"
Solution
at 2. remove any pending Wifi off alarms
A "simple" mode would be:
Service setting (all hidden)
Rules for turning Wifi on (all visible)
Rules for leaving Wifi on
Only if connected (on by default but hidden)
Check for cage (off by default but hidden)
If in call (I feel this pref could be removed completely and the behavior aleays be as "on")
If netwotk activity (off by default and hidden)
If wakelock is held (on by default but hidden)
If Wifi tethering (I feel this pref could be removed completely and the behavior aleays be as "on"
Rules whn plugged in
Wifilocks (off by default and hidden)
Rules for turining Wifi off (all on by default and hidden)
Own logfile: not really required as I will provide logcat with grep on BetterWifiOnOff
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.