Page 1 of 1

Need some assistance on Cell GSM flow

Posted: 30 Jul 2015 13:27
by DataCrypt
I have a Nexus 4 (with Android 5.1.1) and have used Automagic to automatically turn my WiFi on/off using a "Periodic Location Update" every 15m. If the location was at home, the flow would turn WiFi on (as long as battery was ok, etc.), else it would shut WiFi off to save my battery. Has worked great for me. But recently I've seen some apps that control the WiFi via which cell phone tower they're connected to (or around). This type of "check" apparently conserves more battery than doing the "Location Update".

So, I created a flow that has a trigger on "Phone Cell GSM". I'm using the "Classic & Modern" method and collected the cells. Only one showed up (sometimes a second shows up). I chose the one cell under the "Location Area Code (LAC) List" and also the selected the "Cell ID (CID) List" with the one that showed up in there. I set the trigger to activate on "Connected" AND "Disconnected". The very next step after the trigger is a condition where I evaluate an expression "if(connected) true else false;" If True it branches to set WiFi On, if False it branches to Set WiFi Off. When I turned on the flow, it worked and set my WiFi on. Sweet! But whenever I run the flow manually it sets WiFi to Off. Why is "connected" always False when running the flow manually?

1). Is using this Phone GSM trigger better than using the periodic location update from a battery perspective?
2). Should I use two flows instead of one (i.e. one where I just check if I'm "Connected" to a cell tower to turn WiFi on and another flow to check if "Disconnected" to turn WiFi off? I was hoping/thinking that I could do all this in one flow.
3). What would be the best way (examples) of writing this kind of flow?
4). Does anyone know if the Nexus 4 updates the Phone Cell GSM when the screen is off or if I need to "Wake device every 15m" and "Force update"? Seems like the Force causes more battery use and thus this might be equivalent to the location check?

Thank you for your time and help.

Kind Regards,
Data

Re: Need some assistance on Cell GSM flow

Posted: 31 Jul 2015 11:49
by Martin
Hi Data,

I would guess that the Nexus 4 does not properly detect the cell ID when the screen is turned off. This is quite a common behavior and was probably implemented by the manufacturers to reduce battery consumption. Unfortunately my Nexus 4 is broken so I can not test this anymore but I fear that even 'Turn screen on' might be required to get reliable results.

When a flow is manually executed, the variables normally provided by the trigger like cid and connected are not available to the flow which probably causes your condition to always return false and hence executes the 'disconnected' branch.

Most modern Android devices make periodic WiFi scans in the background to help improve the location detection (see system settings->Wi-Fi->menu->Advanced: Scanning always available).

You could take advantage of this mechanism and turn Wi-Fi on, when your Wi-Fi network is available:
-trigger Periodic Timer: every 1m (Don't wake device)
-condition WiFi Available: <your SSID>
--> true: action Set WiFi State: On
--> false: action Set WiFi State: Off
This flow will turn on WiFI slightly delayed since it will turn it on up to 1 minute after it became available.

In summary:
1) Yes, less battery consumption but probably works less reliable due to the screen off problem. The regular location trigger with method 'Modern' should also work quite good and should not consume much battery (depends on Google Play service version so this can change from time to time).
2) One flow should work in this case.
3) I would use the WiFi flow above if the delay is acceptable.
4) One of the workarounds is most likely required, perhaps even 'Turn screen on'.

Regards,
Martin

Re: Need some assistance on Cell GSM flow

Posted: 25 Feb 2016 19:51
by Andynx
Martin wrote: Most modern Android devices make periodic WiFi scans in the background to help improve the location detection (see system settings->Wi-Fi->menu->Advanced: Scanning always available).
Just for the benefit of anybody using Marshmallow, the location of this setting has changed to:
Settings->Location-> then click on the 3 dots (top right hand side of the screen) ->Wifi scanning

Bit concerned that this might cause battery drain, we'll see.