It is used to auto turn on GPS when any navigation apps are active and turn off the GPS after 1 minute exit from the apps. This flow require root to run properly (GPS toggling needs root).
There are two triggers, App Task Ended and App Task Started. Please edit this two to match the apps those you use. For example, I just use Google Maps.
The next is expression to check which is the trigger (since we use 2 triggers in single flow). If the trigger is "App Task Started", it will enable the GPS if it is not enabled yet.
If not, it will sleep for 1 minute, then turn the GPS off. You can change the time to your need.
This flow use "Stop the currently ...." Flow execution policy. Which means if you exit from your navigation apps for several seconds (example : checking notification) and open the app again (within that sleep timer), the sleep will be resetted and start counting again only after you really exit from the app. Thus the flow will never wrongly turn off the GPS when you are still using the navigation apps.
UPDATE for non root user
I have modified the flow, changing the GPS action (2 actions) which require root, to Action set system setting, which can be used by non root user, with the help of write secure permission. (Thanks anuraag for the reminder)
http://automagic4android.com/flow.php?i ... 689620708f
Warning : Enabling adb, and using Action Set System Setting improperly can brick your phone. You may lose your data and may need reset your phone. There are cases of bootloop caused by improper modification to the system setting. Make sure you understand the risk before continuing. When in doubt, just stop. Do With Your Own Risk.
To use this flow, you have to grant write secure setting permission to Automagic. if you have grant it (or you have root), you can skip to the Set system setting directly. You need adb for this, of course means a PC. Can be windows (preferred), linux or mac. No root is required, that's why we need the help of adb. Xda has a quite neat tutorial for this : How to Install ADB on Windows, macOS, and Linux. You should check it out.
For windows, the fastest way to install the adb is to use adb installer. Just need to run it as admin, yes yes yes, and it is done.
You might to need to install your phone specific driver to make sure the adb can recognize your phone. My phones are in this category, need to install additional phone driver provided in the internal emulated CD built-in. Do whatever necessary until adb can detect your devices. You might need to disable firewall for a while during the adb command, if the firewall policy is too tight.
At you phone, make sure the USB debugging is on, which is hidden in developer options. To enable developer options (if you haven't), tap 7 times at the build number/kernel version at about phone. After that, go to settings > Developer option > enable the USB Debugging, tap OK for the prompt.
After adb and drivers has been installed properly, and USB debugging has been turned on, connect your phone with the PC using the original cable (or any cable that support data transfer). For some phones, you might need to switch to MTP to enable the USB Debugging detection. You might see some drivers installing if it is the first time you connect the adb.
At PC, open command prompt at the adb folder (or can be anywhere if you install system-wide). Type this command to check if your device has been recognized
Code: Select all
Then type this (or just copy from here) to grant automagic write secure setting permission
Code: Select all
adb shell pm grant ch.gridvision.ppam.androidautomagic android.permission.WRITE_SECURE_SETTINGS
The permission has been granted, now we can continue on the phone. Eject/unmount any mounted drive from you phone and unplug the cable. PC is not needed anymore.
You only need grant the permission once. The permission sustained until you uninstall automagic, factory reset your or change ROM.
The flow is doing the same as the root counterpart. The only changes are the GPS on/off part, replaced by Action Set System Setting.
GPS toggling is stored at system database at Secure Category, with the Name : location_providers_allowed
If you turn off the location feature, this value will be blank (null).
By default, most people just turn on network location (power saving mode) but not using GPS (GPS is off). For that case, the value will be network.
If you turn on GPS as well, the value change to network,gps
So to turn on gps, you will change the value to : network,gps and to turn it off : network
Tap that Set system setting at the end of the flow, you should see the action's setting. By default, the checkbox at the bottom will be unchecked. That is to ensure that you understand the risk of changing system setting directly. Everytime you change the value, you have to check this again. In case you import my flow, this will be unchecked as well. You have to check it first so it won't generate error when you execute it.
But just to make sure that your phone behave the same, turn on your gps, then tap that 3 dots on the right of location_providers_allowed. You should see the value is the network,gps. Select it. Then turn off the GPS, and tap that 3 dots again. You should see the value is network. In case the value at your phone is different than mine, please change it accordingly. After you have make sure everything is correct, check the checkbox that you have verified the setting. Do the same also for the the checkbox to set GPS off.
Once you have verified both Set System Setting action, you can add the apps you want at the triggers and enable the flow. Try to open the apps those you have set and see if the flow works properly. I have tried this at my Pureshot LP 5.1 no root, just grant that write secure permission. The Set system setting successfully turn on/off GPS.
PS: You can use this Set System Setting to automate toggling/changing various of system internal setting. But not everything works in every phone (example airplane toggling doesn't work at my phone). By using Automagic, you don't need to install any additional plugin such as secure setting plugin anymore to do action like these.
Another UPDATE for non root user - Add Choose Navi Apps
I have add additional shortcut trigger that branch to input dialog to select the navi apps. This will ensure automagic always turn on the GPS before the navi app started. This should solve the problem with some phone which delay in detecting App Task Started trigger.
http://automagic4android.com/flow.php?i ... 6ebe4f09e3
I use a very similiar flow pattern from Bender64. He use Google Maps, Sygic and Waze; so I will use them as example. Triggers also have been modified to reflect the change. Add/remove any app you need, make sure to edit the triggers, the input dialog and the parallel branch expression to launch the app. Here, I can't just simply use single condition check anymore, since we have 3 triggers. I should use parallel for efficiency. The input dialog also use 3 parallel expression to check the value (since there are 3 apps)
The flow has been modified a bit in term of logic. You can add the shortcut to the home screen. If the flow is executed from shortcut, then it will shows input dialog, to select from the navi apps. After selected, it will launched the selected app, while turning on GPS. Looking at the sequence, Action Set System Setting (to turn on GPS) should be executed at the same moment as the Launch app. So I believe there will be no more delay, since they have executed at the same time, while loading the navi apps usually takes several seconds to completely started, the GPS should be on already before that. I always try to reuse the action if it is possible to optimize the flow, thus I reuse the action from the "App Task Started" branch.
If there is still delay (which is inconceiveable), then you should copy that condition GPS enabled and Action Set GPS on from "App Task Started" branch, put them between the input dialog and those 3 parallel expressiion. It will definitely no more delay, because the GPS was turned on before launching the app.
Why we still keep the "App Task Started" branch? Because if we switch back to home screen for checking something and switch back, we want to reset the flow timer. Even though the trigger delayed, it is still better that way, rather than have to use shortcut trigger everytime we just need to switch back to previous nav app which has been launched before.