App Task Started - Requires Reset

Post your questions and help other users.

Moderator: Martin

e-ec-ecu
Posts: 11
Joined: 25 Jul 2017 18:24
Location: Hampton Roads, Virginia, USA

App Task Started - Requires Reset

Post by e-ec-ecu » 25 Jul 2017 20:03

I have been using Automagic Premium for many years now, but never needed to create an account. I just did and wanted to ask a question to this board.

I had a simple flow that increases the screen timeout (10 minutes) when a specific app is running in the foreground (in focus). In addition, I have another flow to UNDO the previous (back to 30 seconds).

For the past few years, it has worked fine. On my Galaxy S8 (with Android 7.0 Nougat), the flow has issues. When the app is in the foreground, the flow works GREAT and the screen will not timeout. When, the app is not in the foreground, the timeout goes back to what I wanted (30 seconds). Sounds good, right? WELL, If I open the app and happen to "swipe down" on my notifications (for example) and then swipe back up to return to the app ... the flow has changed the timeout back to 30 seconds ...even though the app is in focus. The ONLY way to get it to work again is to go into the Automagic Premium app, and then toggle the (on/off) for the "app task started" flow from ON, to OFF, back to ON, then return to the app. All is good again, until I "swipe down" on notifications.

It is almost like the flow only recognizes the initial "app in focus" instance, but when I change focus and go then go back, the "app task started" doesn't "see it" in focus. Any thoughts?

Here are my flows:

*** This is when the app is running in the foreground (in focus)***
- Trigger Type: App Task Started
- Method: Classic
- Package Name: .com.example.app (obviously, just an example here)
_____triggers this action______
- Action Type: Set Screen Timeout
- Screen Timeout: 10 minutes
******************************************************

*** This is when the app is NOT running in the foreground (not in focus)***
- Trigger Type: App Task Ended
- Method: Classic
- Package Name: .com.example.app (obviously, just an example here)
_____triggers this action______
- Action Type: Set Screen Timeout
- Screen Timeout: 30 Seconds
************************************************************

User avatar
Bingwu
Posts: 114
Joined: 26 Feb 2016 10:26

Re: App Task Started - Requires Reset

Post by Bingwu » 25 Jul 2017 20:43

Hello!

Please excuse my poor English.

I do this almost as you do with different apps, but I do not use the trigger "App Task Ended".

I trigger every (*) app with "App Task Started" and set the screen timeout to default.
For certain apps (the same Flow -> Condition: Expression: package_name == XXX) I set the screen timout to a special value.
(Newly I do this with a map.)

This works with Android 6.x and also with 7.x

Of course, the started app loses the focus once you get the notifications
But then the flow is re-executed and the special screen timeout is restored.

greeting
Peter

e-ec-ecu
Posts: 11
Joined: 25 Jul 2017 18:24
Location: Hampton Roads, Virginia, USA

Re: App Task Started - Requires Reset

Post by e-ec-ecu » 26 Jul 2017 02:04

Thank you for the response. I may be confused.

My normal screen timeout is 30 seconds. When an app is running (in focus), I want the screen timeout to be 10 minutes. When that same app closes ... I want it to go back to 30 seconds.

My problem is that it used to work perfectly fine. In the past, I would set an "app task started" to 10 minutes and an "app task ended" to 30 seconds and it used to work great.

My only concern is that Automagic Premium on Android 7.0 (in my case at least) only recognizes the VERY FIRST time the app is in focus. As soon as it loses focus, it doesn't recognize the app being in the foreground unless the app flow is triggered OFF/ON again.

Not sure how the solution you provided applies.

Thanks!

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

Re: App Task Started - Requires Reset

Post by Desmanto » 26 Jul 2017 03:06

I have a similiar trigger, but to set the display to higher brightness and turn off heads-up notif when certain games started. App Task Started works properly at my LP 5.1. When I swipe down notif/quick settings, it will out of foreground. Closing the notif will trigger the flow again.

Probably you can try to add Action notification on screen (toast message) to the App Task Started flow, add variable {triggertime}. Try to debug to see how to trigger it (when the toast message appear). You may try to change the flow execution policy to other (try skip, wait, stop) to see whether it matters.

The other harder workaround, would be using additional plugin App Context. But this requires root and xposed, which is probably not stable yet at nougat.
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.

User avatar
Bingwu
Posts: 114
Joined: 26 Feb 2016 10:26

Re: App Task Started - Requires Reset

Post by Bingwu » 26 Jul 2017 08:25

Hello!

Try this:

Trigger: App Task Startet
Method: Classic
Package Name: *
(Consider each started app)

Action: Screen Timeout
Set Screen Timeout: 30 seconds
(Consider each started app)

Condition: Expression
Expression: package_name == "com.yourspecial.app" <- The package name of your app
(Checks the package name of the started app with the given package name)

result of the condition = yes
Action: Set Screen Timeout
Screen Timeout: 10 minutes
(your special app)

result of the condition = no
nothing
(all other apps - screen timeout stays at 30 seconds)

Your device must of course (still) support a timeout of 10 minutes.
For me this works on different devices (and Apps). (Android 6.x, 7.0 and 7.1.2 - Stock-ROM, Custom-ROM - rooted, non rooted)

I wish you success!
Peter

Example:
screenshot.png
screenshot.png (24.21 KiB) Viewed 26260 times

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

Re: App Task Started - Requires Reset

Post by Desmanto » 26 Jul 2017 12:06

@Bingwu : It will trigger on every app. Doesn't that slow down the whole system? (or at least drain more battery)
And that will spam the set Screen timeout everytime opening a new app. It is better to troubleshoot the App Task Started trigger first.
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.

User avatar
Bingwu
Posts: 114
Joined: 26 Feb 2016 10:26

Re: App Task Started - Requires Reset

Post by Bingwu » 26 Jul 2017 12:47

For me it works with an Asus Nexus 7, a LG Nexus 5 and a Samsung Galaxy S7 edge.
Until recently, it also ran on a Samsung Galaxy S2.
A high battery consumption therefore I could not notice.

The solution shown is an example, I use it even more complex.
You can still add a condition, which queries the last screen timeout.

I also use not every second another app. ;-)

e-ec-ecu
Posts: 11
Joined: 25 Jul 2017 18:24
Location: Hampton Roads, Virginia, USA

Re: App Task Started - Requires Reset

Post by e-ec-ecu » 26 Jul 2017 14:26

@Desmanto. Thanks for the idea on "Notification on screen". I have never done any real troubleshooting in Automagic other than log viewing.

So, I added a "Notification on screen" for both the "App Task Started" and "App Task Ended" that says "Application started" and "Application Closed", respectively.

I ran the application as normal. I received an "Application started" message. I then swiped down on my notifications bar (from the top) and got the "Application closed" message. I THEN swiped the notification bar back up to return to my app .... NOTHING!!

I thought about adding a "sleep" on the "App Task Ended" trigger and wait 10 seconds and then check to see if the app is still not in focus ... but the problem is that "App Task Ended" is not available as a Condition. Only "App Task Running" is available, but it is not supported and doesn't do what I want. I want to check app focus.

Also, when it comes to logs there is nothing to see. Nothing in the logs since nothing was triggered when the app came back into focus.

Any thoughts?

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

Re: App Task Started - Requires Reset

Post by Desmanto » 26 Jul 2017 15:10

@Bingwu : For battery usage, need to have a really isolated experiment to try it out. So far, if you can't notice it, then maybe it doesn't affect much.
However e-ec-ecu's problem was on the Trigger : App Task Started not working as expected. So still need to troubleshoot that trigger first.


@e-ec-ecu : If you swiped down the second time, do the "Application Closed" message appear again? Or just like the "Application Started", it only appears once and the flow must be toggled first before can show the second time?

App Task Started/Ended are events, they can only appear as trigger. To check for current foreground app (state), you should use Condition : App Process Running / App Task Running. However as the help describe, both probably won't work anymore on android 7.0+.

For the Trigger App Task Started, have you tried the second Method using Usage statistics? Did it fail also as the classic method?

Maybe you should tried to check your phone for any kind of permission/monitor which may prohibit automagic from working properly. I have made a long list for Automagic initial setup to ensure it is working properly.
https://www.kaskus.co.id/show_post/5965 ... 8b456b/4/-
However, I typed it in Indonesian casual language, so might be confusing if you use google translate. There are some words I keep the english term, so you can focus on those instead. For Usage statistic, you probably need to turn on app usage access for automagic. It is hidden in some phone, so you might need to use shortcut activity.

There are another way to detect the app is running, using UI events. However it probably will slow the app perfomance as it will trigger in every app window opened
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.

e-ec-ecu
Posts: 11
Joined: 25 Jul 2017 18:24
Location: Hampton Roads, Virginia, USA

Re: App Task Started - Requires Reset

Post by e-ec-ecu » 26 Jul 2017 15:37

@Desmanto - As you suggested, I swiped down twice and it behaved like the "App Task Started" and no message appeared on the second swipe.

BUT!!! I found a really interesting thing during this troubleshooting. It appears to ONLY happen with the notification bar. Here is what I did:

I opened the app, got the "Application Started" message. Swiped down on notifications and got the "Application Stopped" message. Swiped up on notifications to return to the app ... NOTHING.

BUT, If I then simply hit "Recent Apps" button and re-open the Application that is already in focus ... I get the "Application Started" and the screen timeout works fine. I do NOT need to reset the Flow. If I swipe down for notifications, all I have to do is return to the app (which is already running) via the recent apps.

It appears that the App Task Start event doesn't handle the closure of the notification expansion.

Post Reply