New to tasker, after reading around a bit, I created a profile for switch Wifi to Mobile Data and back depending on the place i'm at.
To make sure both Wifi and Mobile Data are not on at the same time (if one of them should be a bit flacky), i work with a few wait statements and some variables which tell me if i went through either toggling wifi or mobile data on or off. This works rather nice as long as tasker does the job.
But when i toggle either of them manually (to try something out), things can act up and the according variables are not set/reset then because tasker didn't run through the task for toggling either wifi or mobile data.
Then when fooling around with Tasker, i came accross the Test Net command which can return a yes or no text depending on what state mobile data is on with one nice touch, it also switches the state when mobile data is toggled manually. This text can be stored in whatever variable i want and then used to determine the state of mobile data being on or off which i can then use in my tasks to decide if tasker i has to run through them when everything is running automatic.
Thinking i found the holy grail for the manual toggle not updating the variables problem, i changed all my tasks and replaced my previous variables in which the mobile state was stored to with the one i got from the Test Net command.
This seemed to work nice at first but then at a given point i discovered that the state of variable made with the Test Net command didn't match the true state of the Mobile Data toggle switch.
After lots of trial and error i found out that if Wifi is on (either manually set or set by Tasker), the mobile data variable retrieved from Test Net isn't updated anymore and therefore can give a wrong state if toggled manually and that my tasks don't work anymore when i toggle mobile data manually. If i turn Wifi off and then toggle mobile data, the variable is updated again (but i have to toggle it first) and everything works again.
First i thought i had somewhere some double set/reset of the variable but that was not the case.
To cut a long story short:
The mobile data variable retrieved from the Test Net command to see if mobile data is enabled yes/no isn't updated when wifi is enabled. Bug or not?
Related
I created my 1st Profile(I guess that what it is) last night that I Called Home. I set my location then add a Task to Turn my WiFi On and then Off as needed. How would I now add a New Task to the "Home" where I Turn Off and On my Data package?
Thanks
Just install "Wifi Static" free app from market and it switches wifi and or data network by itself depending on the proximity to the saved wireless network at home or work or starbucks. Try it out, it is preety good.
RonH54 said:
I created my 1st Profile(I guess that what it is) last night that I Called Home. I set my location then add a Task to Turn my WiFi On and then Off as needed. How would I now add a New Task to the "Home" where I Turn Off and On my Data package?
Thanks
Click to expand...
Click to collapse
There is no need to turn off and on your data package. Once you are connected via wifi, android OS automatically disables the 3G data. Then when wifi connection is lost, 3G data is enabled back again. No extra app such as wifi static needed.
I could be wrong, but I am pretty sure this is how android works. You can even notice the little "3G" icon disappearing when you connect via wifi.
Using a Nexus 6 with NP5.
I frequently walk in and out of Wi-Fi range near my home. The Wi-Fi signal gets weak, and data communications start to suck. If I turn off Wi-Fi the phone switches to LTE and everything is fine.
There is an option in Developer options labeled "Aggressive Wi-Fi to Cellular handover." If I enable this option my data connection remains stable because as the Wi-Fi gets weak the phone switches to LTE sooner.
The difficulty is that this setting reverts to "Off" every time the phone reboots.
I have recently started using Tasker and have another task that runs a shell command on boot. That task is working great.
I am trying now to figure out how to change this setting for aggressive cell handover in dev options using a tasker task that I can assign to the same Device Boot event and I am running into difficulty. I simply do not see how to flip this device setting toggle within a tasker task.
Am I missing something? This seems like it would be a simple thing to do, straightforward, and the type of thing Tasker is designed for, but my noob-ness is showing.
I go to Tasks, add a task, name it, add an action, select Settings, but I don't see anything matching "Developer options." If I go to "All Settings" i just get a prompt to enter a variable name. I have no idea what to type to select the variable represented by the "Aggressive Wi-Fi to Cellular handover" toggle option, or if its range is 0/1, true/false, whatever.
Any guidance would be greatly appreciated.
Thanks!
No suggestions? Not possible? Wrong tool?
rgraville said:
No suggestions? Not possible? Wrong tool?
Click to expand...
Click to collapse
on s7 its a built in feature to switch to mobile data when a wifi network is unstable
Android Marshmellow + rooted.
I'm using (like so many) a few profiles/taks to switch from Mobile Data to Wifi when i get home and back when i leave home. Works pretty nice but... not all the time.
The reason behind this is the difference on how Wifi and Mobile Data are activated.
If changed both manually (via the drop down menu) both act as a toggle.
But within tasker this behaviour changes. Wifi has an On / Off option, Mobile Data has to but that doesn't work anymore since Google changed the activation for Mobile Data which means that you can only set it with the help of Active Input and that turns it into a toggle.
And this creates a syncronisation problem between Wifi and Mobile Data.
I'll explain the difference:
If i set Wifi to ON Wifi goes ON.
If i set Wifi again to ON, Wifi stays ON. It will only go OFF when i set it to OFF.
It behaves as a physical switch.
Mobile Data however does not.
If i activate Mobile Data through Active Input and it's OFF, it will go ON. And when it's ON it will go OFF.
It behaves a toggle.
Now this works OK as long as everything is in sync.
If Mobile Data is ON and i reach home, Wifi is turned ON, i get the connected signal and Mobile Data is turned OFF. Same goes the other way, if i leave home, Wifi connection is lost and Wifi is turned Off. When the connection is lost Mobile Data is turned On again. Works nice.
But this can get out of sync because of the switch/toggle behaviour.
Example:
If i'm home, Wifi is ON and Mobile Data is OFF. If i turn Wifi OFF manually , the connection is lost and Mobile Data comes ON. If i turn Wifi back ON, Mobile Data goes OFF again.
But the other way there is a problem. If i'm not home and turn Mobile Data OFF somewhere and reach at home, tasker sees this, turns on Wifi and "toggles" Mobile Data to be OFF but since it's a toggle action, Mobile Data will come ON instead and both are then ON. And from then on the nice syncronisation between Wifi and Mobile Data is gone.
This manual override (like i like to call it) also doesn't update the variable i use which is logical since the Mobile Data wasn't "toggled" through Tasker.
I tried to solve this with a double variable check together with a variable i set when Mobile Data is connected (2G,3G,or 4G) and then toggle Mobile Data according to this and set/reset the variables but while this should work better in theory, it still doesn't work all the time because indoors, Mobile Data connection can be lost and then the Mobile Data toggles again to a state i don't want again setting a desyncronisation between Wifi and Mobile Data. In fact, due to this the syncronisation has become more unstable. So i removed the Mobile Data connected part again.
Questions:
- Is there a way to make Mobile Data work as a switch instead of a toggle?
- If not, is there a way to detect is the Mobile Data button has been touched (which i could then use in a variable)?
I'm using shell commands to switch mobile data on/off.
If your selinux is permissive, simply run a shell command with this:
Code:
svc data enable;
or
Code:
svc data disable;
If your selinux is enforcing, you need to add two lines, so it looks like this:
Code:
setenforce permissive;
svc data enable;
setenforce enforcing;
and respectively
Code:
setenforce permissive;
svc data disable;
setenforce enforcing;
Needless to say, you need root access for this.
I'm afraid that's currently above my head...
To add a shell command:
Code > Run Shell
Tick "root"
Put the codes from above in "Command"
Sukarn said:
To add a shell command:
Code > Run Shell
Tick "root"
Put the codes from above in "Command"
Click to expand...
Click to collapse
Exactly. [emoji106]
If i do that, can you then explain at least what it does exactly?
I guess it will turn on/off mobile data but on what basis?
How do these commands know when to turn it on or off depending on my wifi state?
What does " if your selinix is enforcing" means?
Edit: Got it partly working with the shell commands. Mobile data doesn't always turn off when wifi comes back on and is connected. It still can get out of sync.
It does not check the state of the mobile data if i interact and turn it on/off manually because it doesn't seem to know in what state is after playing around with it manually.
Also, tasker sometimes seems to get stuck somewhere in the middle of the code for disabling the mobile data.
Need to look a bit more into why tommorow...
Update:
Got it fully working with the shell commands and sync between Wifi and Mobile Data seems OK (for now at least).
I'm using the settings get global mobile_date command to put the status into a variable and then work with this and the wifi status variable to toggle Mobile Data on and off.
One thing i haven't found yet is what the settings get mobile_data exactly returns, the state of the toggle button in the notification screen or the state of the mobile data being connected?
Does anyone know of an app that will automatically turn off mobile data when i'm successfully connected to a WiFi connection have have internet access through it.
The app should do something like this...
1. Check for WiFi connection
2. If WiFi = connected, then test WiFi connection
3. If connection = Good, then turn off Mobile Data, else leave Data connection ON
If you suggest Tasker, then you better follow it up with a full write-up on how to set it up on Tasker.
I believe (someone will correct me if I'm wrong) that Android is programmed to use wifi when it's available, even though your data connection looks as if it's on.
If you're not happy with that, Automate It should be able to do something for you. I have Automate It Pro set to turn off wifi & data at midnight, for example, to avoid the nuisance of emails pinging me in the middle of the night. And it switches wifi & sync on at 09:00 each day. Very useful tool, simpler than Tasker, so no tutorial from me...
There are a few Automate apps in the Play Store - it's this one:
https://play.google.com/store/apps/details?id=AutomateIt.mainPackage
This free version allows you 3 (as I recall) triggers - if you need more it's not too expensive to buy Pro.
I use RadioControl to handle that for me.
https://play.google.com/store/apps/details?id=com.nikhilparanjape.radiocontrol&hl=en
It requires root, and it's not perfect. But it works well enough for me.
[NG]Owner
Try smart radio xposed module.
pr0ndigy said:
Does anyone know of an app that will automatically turn off mobile data when i'm successfully connected to a WiFi connection have have internet access through it.
The app should do something like this...
1. Check for WiFi connection
2. If WiFi = connected, then test WiFi connection
3. If connection = Good, then turn off Mobile Data, else leave Data connection ON
If you suggest Tasker, then you better follow it up with a full write-up on how to set it up on Tasker.
Click to expand...
Click to collapse
Tasker does it pretty simply, but it needs root access..
Set up (2) tasks - I called mine Data Off & Data On. You will need to select "Net/Mobile Data" and then set "On" or "Off" respectively. Next set up your profile. Select "State/Net/Wifi Connected", and leave everything empty and save. This will trigger the profile when any wifi is connected. (Optionally, you could set it to your home or work wifi, etc). Your "task" will be "Data Off", then add an "exit task" for "Data On" (by long pressing the Data On and selecting "exit task").
dahawthorne said:
I believe (someone will correct me if I'm wrong) that Android is programmed to use wifi when it's available, even though your data connection looks as if it's on.
Click to expand...
Click to collapse
^^^^ This. Android has done this for years. Some devices have the ability to keep mobile data on with wifi, but those usually default to OFF.
Note in the screenshot below that my Cellular network state (mobile data) is "Disconnected"
Pkt_Lnt said:
^^^^ This. Android has done this for years. Some devices have the ability to keep mobile data on with wifi, but those usually default to OFF.
Note in the screenshot below that my Cellular network state (mobile data) is "Disconnected"
Click to expand...
Click to collapse
Interestingly, I bring up the same screen on my phone (when connected to wifi) and it shows cellular is still connected??
jbaumert said:
Interestingly, I bring up the same screen on my phone (when connected to wifi) and it shows cellular is still connected??
Click to expand...
Click to collapse
Do you have a ROM that has that option and it is enabled?
Pkt_Lnt said:
Do you have a ROM that has that option and it is enabled?
Click to expand...
Click to collapse
Running SIX ROM - Just checked, that option is disabled in the Dev Settings / connected to good wifi / and cellular is active...
¯\_(ツ)_/¯
Now it is a question for that rom dev.
Hey..
I have setup a project to system lock phone (deactivate fingerprint login etc.) if it looses connection to mobile networks. This is extra safety for my in the event someone gets hold of it.
To accomplish this I've setup a profile with the state 'Mobile Network', selected all network modes and used the 'any' trigger and inverted to make trigger whenever the state have no mobile networks. This is tested and works but..
.. whenever WIFI is on it doesn't trigger. If you disable WIFI or it looses WIFI connection it triggers.
Is this bad behavior or am I missing something?
The project in whole still works since an active WIFI connection would give me access to my phone and therefore a system lock is only needed in the event I cant reach it, ie. no WIFI and mobile data.
Thank you.