Wifi switch and Mobile Data toggle problem

Discussion in 'Android Apps & Games' started by Lange_666, Oct 21, 2016.

  1. Lange_666

    Lange_666 New Member
    5

    Sep 30, 2016
    4
    0
    5
    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 (and that i could use as a variable)?
     

    Advertisement
    #1 Lange_666, Oct 21, 2016
    Last edited: Oct 21, 2016
  2. WarriusZero

    WarriusZero Guest

    Do you think you can actually save that much battery by doing all of this?
    I used to have similar tasks and profiles but recent Android OS versions are quite good at not wasting battery life in this area.
     
  3. Thom

    Thom •••
    Guide
    6,143

    Feb 16, 2011
    11,189
    4,561
    6,143
    Male
    Software Developer
    Keene, NH USA
    I am not root-ed. I leave Mobile on all the time.

    I use two profiles ...
    Far
    If my SSIDs are Not Connected
    Wait one minute
    If still Not Connected turn WiFi off

    Near
    If my SSIDs are Near
    Wait one minute
    Turn WiFi on

    The waits are to allow for syncronxation.

    ... Thom
     
  4. Lange_666

    Lange_666 New Member
    5

    Sep 30, 2016
    4
    0
    5
    Probably not but it's more like playing with the device to let it do stuff instead of using it like most people use their 700$ device: just for messages and phone.
     
  5. Lange_666

    Lange_666 New Member
    5

    Sep 30, 2016
    4
    0
    5
    Answering my own questions (after quite a search on the net):
    1: Yes there is via shell commands. If MD is ON and you tell it to be ON again it stays ON and doesn't toggle.
    2: Yes there is too via de %MDSTATE variable (returns a yes or no depending on the Mobile Data state). One twist though, if Wifi is enabled, this %MDSTATE keeps it's last value, even when MD is toggles. Bug in Tasker?
     

Share This Page

Loading...