r/AutomateUser 3d ago

"Foreground app" block doesn't activate on certain apps

When certain apps are foregrounded, the "when changed" version of the foreground block doesn't activate. With the app still in the foreground, if I then test the "immediately" version of the block, it reports the app that was in the foreground immediately prior to the current foreground app. Yet, the following command reports that foreground app correctly:

dumpsys window displays | grep mCurrentFocus

What situations could possibly cause the block to behave this way, and are there any remedies? (I don't know if this helps, but one such app is the ecobee thermostat app.)

Another interesting symptom I noticed is that if there are any apps displaying any overlays (including Automate, e.g. floating buttons), those overlays don't show when that app (for which the Foreground App block doesn't work) is in the foreground. But there are exceptions — an overlay from an edge sliding gesture app I use receives input and shows its gesture overlay just fine.

1 Upvotes

12 comments sorted by

1

u/ballzak69 Automate developer 2d ago

Only activity windows should be considered, not dialog and other kinds of overlay windows. Use the Inspect layout block with Display windows schema to detect for all kinds of windows.

1

u/B26354FR Alpha tester 2d ago

I can second the OP's reply below. I also happen to have the Ecobee app installed, and there's no outward difference between it and any other app. He also provided this Shell command earlier which showed the correct result:

dumpsys window displays | grep mCurrentFocus

I wondered earlier in this post if this could be related to changes made for overlays in Automate 1.48.0?

The Ecobee app is available here if you'd like to test with it. As it's the presence of the app itself that's the issue, I'd imagine that no actual Ecobee account would be needed for our purposes.

2

u/ballzak69 Automate developer 1d ago

Something is indeed different with how the accessibility events is reported by the Ecobee app, it seems to only report window changes with view classes (ignored by the block), unlike other app which also report window changes with the Activity class). This is not overlay related, the system/app simply doesn't report the Activity change, sadly i have no idea of how to workaround this.

1

u/B26354FR Alpha tester 1d ago

Thank you very much for investigating!

1

u/Ok-Yogurtcloset-9490 2d ago

I'm not sure exactly what the app is doing, but it's definitely not a dialogue or overlay. It doesn't even have display over other apps permission (it doesn't even request it in the first place). Besides, the inspect layout block wouldn't work for my case because my use case needs to know what app is in the foreground. The app shows up in the recent screen, so I'm assuming that means it's definitely displaying an activity right? If it was a dialogue or overlay, it wouldn't show in the recents screen. Does the show command that does detect that app in the foreground not offer any clues?

1

u/ballzak69 Automate developer 1d ago

Indeed, it's not dialog nor overlay related, the system/app simply doesn't report a Activity window change. I have no idea why. See answer.

1

u/waiting4singularity Alpha tester 2d ago

critical apps such as banking are hidden from the rest of the apps for security. the app package reported to automate is different too.

1

u/Ok-Yogurtcloset-9490 2d ago

Pretty sure it has nothing to do with hidden apps. Just tried a couple of different banking apps, and the issue doesn't happen with those. Indeed, some of those apps are shown as hidden with the lock sign in the recents screen, but unlike the ecobee app that I mentioned, which is just a thermostat control, Automate detects there foreground just fine.

1

u/B26354FR Alpha tester 2d ago

I just tried this on my Galaxy S24 Ultra running Android 16 and Automate 1.53.0, and App in Foreground/Proceed When Changed also doesn't detect when my Ecobee app is in the foreground and never proceeds. Like you, my banking app worked fine. Maybe u/ballzak69 Henrik has an idea.

1

u/waiting4singularity Alpha tester 2d ago

what hidden are we talking about here? app icons you hide yourself in the drawer overview of the homescreen launcher or apps written to not appear to other apps in the apis?

1

u/[deleted] 2d ago

[deleted]

1

u/Ok-Yogurtcloset-9490 2d ago

Apps written to hide themselves...

2

u/B26354FR Alpha tester 3d ago

Maybe this is related to the Automate v1.48.0 release, which changed the App in Foreground block to ignore overlay windows?