AutoTools Turn GPS on when in Google Maps, turn it off otherwise (No Root!)

Enable and disable location settings at will with AutoTools Secure Settings

  1. Robert B

    Robert B New Member

    Joined:
    Jul 11, 2018
    Messages:
    25
    Likes Received:
    1
    Did you use ADB to grant WRITE_SECURE_SETTINGS to AutoTools? Also you can just use the Location Mode in Tasker now instead provided you have done the grant WRITE_SECURE_SETTINGS for Tasker already.
     
  2. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    8,710
    Likes Received:
    736
    Did you do what the error message says?
     
  3. marsui

    marsui New Member

    Joined:
    Oct 2, 2019
    Messages:
    2
    Likes Received:
    0
    So this almost worked for me, there is one problem. When you swipe away the google maps window, and its still running in the background and giving you updates via the notification bar, the GPS gets turned off. So now when I go to my recent apps, to bring the window back (which again is still running and trying to navigate) it says the GPS is off, and has to be turned back on. I only want to turn location off if I completely exit maps, not just close the window and have it navigate to the background. However, if there was a way to write a condition that can detect if maps is showing me notifications, that might work.

    I've attached images.

    1. Loaded maps, picked a random place to navigate to, Location gets turned on, task profile MAPS is active, and the maps window is in the foreground.

    2. I then switched to another app, and maps created the small window overlay, I closed the small window, and navigation is continued via the notification bar (maps is running in background). If you notice, the location icon is now off, and no profile is active.

    3. I went back to the maps app, which was still navigating, using my recent apps button.

    4. Notice that location is still off, and maps is asking me to turn it back on.

    Anyway to fix this?

    Thanks!
     

    Attached Files:

  4. joaomgcd

    joaomgcd Administrator Staff Member

    Joined:
    Feb 3, 2015
    Messages:
    8,710
    Likes Received:
    736
    You could do this:
    • Have a profile to detect if the opened app is Google Maps. In the task set %MapsApp to 1. In the exit task Clear %MapsApp.
    • Have a profile to detect if the Google Maps Notification is present with the AutoNotification Intercept state. In that task set %MapsNotification to 1.In the exit task Clear %MapsNotification.
    • Have a third profile with the Variable State condition where you use the %MapsApp Is Set Or %MapsNotification Is Set condition. In that task toggle GPS on. In the exit task toggle GPS off
    Hope this helps! :)
     
  5. marsui

    marsui New Member

    Joined:
    Oct 2, 2019
    Messages:
    2
    Likes Received:
    0
    Thank you very much, it was very helpful!

    So while implementing this solution, I realized that the app profiles will fire the exit task whenever said app is not in the foreground. In fact, even using split screen mode, only the window that has focus matters, even if one of the windows in split screen has maps as the foreground app. (I was checking variable values using split screen mode).

    Small issue with your solution, but I got it to work by tweaking it slightly. On the Variable State condition, the exit task did not work for me. When I closed the small overlay window, it still turned off location. So I added a condition on the exit task that double checked that %MapsApp Is Not Set AND %MapsNotification Is NOT Set. Then that worked.

    Also another solution was to have two different variable state conditions (instead of using the exit task) and the second variable state condition would check to see if both variable were not set, and then change the location to off.

    Yet another solution, as opposed to using the Variable State condition was to have two variable cleared events:

    1. %MapsApp is cleared, with a condition that %MapsNotification is also cleared.
    2. %MapsNotification is cleared, with a condition that %MapsApp is also cleared.

    I needed two since you cannot have one event that checks two different variables, and since the order of the notification being cleared vs the maps app being cleared cannot be guaranteed.

    I was reading on reddit ways for checking to see if an app is running in the background or not using a plugin, but realistically, I only need GPS on if maps is currently navigating, and that is guaranteed based on the navigation notification. Its a specific notification from maps, sometimes maps gives me notifications after navigating, such as "Did maps get you there OK? or other questions. Those don't happen all the time though, so maybe I can find a way to look for a specific notification - I will worry about that later.

    My last question for: Which is more efficient? Having a Variable state condition, or a variable variable cleared event? On the surface it would seem that the variable state condition is constantly checking variable values, where as the variable cleared event only fires when the variable is cleared, but I'm not certain how each was implemented so this is just a guess.
     

    Attached Files:

Share This Page