New Foreground app reported isn't updated in some cases when using floating windows.


Skotlex

Members
Apr 9, 2021
1
3
I use Automate to interact with a given app when it's in the foreground, however the "App in foreground" block doesn't always update correctly when using floating windows.
For testing, I use a simple automate task that does an infinite loop of "when foreground app (when changed)" and then report the new foreground package with a toast. The following situations should all produce a toast (foreground app context change), yet a few don't:

  1. Opening an app from launcher- OK
  2. Switching apps from recents menu - OK
  3. Using quick-tile "floating windows" - OK (shows the previous app, the one now using most of the screen, as the active one)
  4. Click on a floating window - OK
  5. Click on the main window when a floating window had the focus - ERROR (no foreground app change reported)
  6. Dismiss (drag up from the bottom handle) a floating window - ERROR (same as above)
  7. Click on the main window when a floating window had the focus and the keyboard is shown, causing the keyboard to be hidden - OK
  8. Open a floating windows from the recents menu - OK
  9. Open launcher using Home button while there's a floating window - OK
  10. Open a floating window using the video-toolbox shortcut - OK

So, basically, use-case scenarios 5/ 6 are the only interactions which don't update the foreground up. In particular, it's annoying if I dismiss a floating window, it's still reported as the foreground app if I ask for it 10 minutes later (assuming I don't trigger any of the OK use-cases).

Alternatively, MIUI could always report the app displayed in the background as the foreground app, which would mean that, instead of fixing use-cases 5 & 6, use cases 4, 8, 10 shouldn't report a foreground app change. Since no other ROM has floating windows, I would guess there isn't an actual guideline on how this reporting should behave, but as it is, it's inconsistent. :)

I use MIUI 12.5 (21.3.24 BETA) on a Xiaomi Redmi Note 9S, but I suspect the bug is global to all versions.