Navigation Apps Auto turn on/off GPS

Share and discuss your flows and ideas with other users.

Moderator: Martin

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Navigation Apps Auto turn on/off GPS

Post by Desmanto » 01 Sep 2017 09:24

I have updated the flow to use input dialog to select the app. Check it out at the OP. ;)
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

tphg
Posts: 57
Joined: 17 Apr 2017 05:31

Re: Navigation Apps Auto turn on/off GPS

Post by tphg » 01 Sep 2017 14:46

Desmanto wrote:I have updated the flow to use input dialog to select the app. Check it out at the OP. ;)
Thank you.
I've just tried it. Problem is still the same: nav app could not detect GPS status that is turned on.
Let me learn then try modifying the flow as per your advice for option 2.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Navigation Apps Auto turn on/off GPS

Post by Desmanto » 01 Sep 2017 15:54

I have started to wonder if the Set System Setting really turn on the GPS at your phone.

Try the action separately in another flow, copy this same Set System Setting to another new flow and put the condition Location enabled : GPS at the bottom of Set System Setting.
Use debug dialog or notification on screen after the condition to check if the GPS is really on.
Try to put sleep 1 second between the Set System Setting and condition Location Enabled, then try to change to 2 seconds, 3, 4, 5 until you got the correct time.

Set System Setting
v
Sleep
v
Location Enabled : GPS
v (true)
Debug Dialog
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

tphg
Posts: 57
Joined: 17 Apr 2017 05:31

Re: Navigation Apps Auto turn on/off GPS

Post by tphg » 02 Sep 2017 01:29

Desmanto wrote:I have started to wonder if the Set System Setting really turn on the GPS at your phone.

Try the action separately in another flow, copy this same Set System Setting to another new flow and put the condition Location enabled : GPS at the bottom of Set System Setting.
Use debug dialog or notification on screen after the condition to check if the GPS is really on.
Try to put sleep 1 second between the Set System Setting and condition Location Enabled, then try to change to 2 seconds, 3, 4, 5 until you got the correct time.

Set System Setting
v
Sleep
v
Location Enabled : GPS
v (true)
Debug Dialog
Yes, the Set System Setting really turn on the GPS at my phone, as I swiped down the notification bar and checked GPS status right after navi app opened.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Navigation Apps Auto turn on/off GPS

Post by Desmanto » 02 Sep 2017 06:03

You should check the delay then. Check how many seconds does it take until GPS is detected as on.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

tphg
Posts: 57
Joined: 17 Apr 2017 05:31

Re: Navigation Apps Auto turn on/off GPS

Post by tphg » 02 Sep 2017 06:58

Sorry how to check delay time, does it show in Automagic log?
Forgot to let you know that, when using your flow I had to change the value from network,gps to +gps, otherwise GPS wouldn't turn on.
I have just tried again, and now Automagic flow is automatically turned off by device with error notification that showed "emergency ended" and that flow changed its color to red in Automagic app screen.
Can you analyze the problem if I send you the log created by Automagic?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Navigation Apps Auto turn on/off GPS

Post by Desmanto » 02 Sep 2017 07:39

At my previous post, which tell you to set the sleep in between. There is a better way to test it though, but I planned to make it perfect and share it as a flow. It is better you just copy that set system setting, and put it after the input dialog. Then from Set system setting, branch out to 3 expression which lead to launch app.

For value change, it is no problem, as long as it turn on/off the GPS.

That emergency stop is automagic feature to prevent run-away flow (flow running continuously and no escape/ending condition). Usually happen in loop or trigger which are executed too often. By default, it is 60, means 60 elements execution, each condition or action counted as 1. If there are 60 elements executed from that flow within a minute, the flow will hit emergency stop and disabled immediately.

It is OK, just reenable it again. It means you test (execute) the flow too often within that minute. 60 is enough in most case, you don't trigger on of your flow hundreds of time within a minute right? Except in flow where there are loops and frequent trigger, then we should raise this value.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

rolltheballaz
Posts: 1
Joined: 30 Oct 2017 01:44

roll the ball

Post by rolltheballaz » 28 Dec 2017 08:17

Thanks for sharing.I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.
- slope game - slope game
- slope game - slope game

syndromtr
Posts: 31
Joined: 01 Feb 2013 13:28

Re: Navigation Apps Auto turn on/off GPS

Post by syndromtr » 29 Dec 2017 18:18

a workaround for non-rooted systems: (use at your own risk! - read below - you can add delays and modify it after trigger...)

flow name : gps off
Trigger : App Task Ended : com.google.android.apps.maps (you can add other software as well, which needs GPS on)

Action : Set System Setting :
Secure
location_mode
0

Action : Set System Setting :
Secure
location_providers_allowed
<blank> (keep it blank)

--------------

flow name : gps on
Trigger : App Task Started : com.google.android.apps.maps (you can add other software as well, which needs GPS on)

Action : Set System Setting :
Secure
location_mode
3

Action : Set System Setting :
Secure
location_providers_allowed
network,gps

--------------

on my system (lenovo k5 note-no root-android 6) secure variable "location_mode" is not present, but only this way it toggles GPS (that variable is from nexus). So, in action, Set System Setting, you need to type it manually as "secure" and give values 0 for off - 3 for on.

what happens: when google map starts, if you double swipe to see quick settings, you'll notice GPS is disabled. but it really works. tested with other navigation-compass apps...

feedback is welcome
Last edited by syndromtr on 29 Dec 2017 19:09, edited 1 time in total.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Navigation Apps Auto turn on/off GPS

Post by Desmanto » 29 Dec 2017 18:25

At some phone, certain system setting value won't sync properly to the quick setting or the toggle if the value modified directly using Set system setting.
At mine, this GPS works. But airplane mode won't work.
Set the airplane mode to 1, the quick setting shows it is on; but airplane mode is not on!
When I tap the airplane mode to turn it off, the icon changed to off, and airplane mode is still off.
Tap again, then icon sync properly now, icon on, airplane mode also on.

So can't guarantee it will work at all phone, but maybe most can. In your case, the real GPS is on, but the quick setting still off (the reverse of my airplane mode :))
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply