Ignore virtual presentation windows - RESTRICT AUTOMERGE

Windows of TYPE_PRESENTATION on virtual displays should not be counted
as visible windows to determine if BAL is allowed.

Test: manual test, atest BackgroundActivityLaunchTest
Bug: 264029851, 205130886
Merged-In: I08b16ba1c155e951286ddc22019180cbd6334dfa
Change-Id: I08b16ba1c155e951286ddc22019180cbd6334dfa
This commit is contained in:
Achim Thesmann
2023-05-23 00:26:33 +00:00
parent b145277797
commit bf60a0c6f1

View File

@@ -3539,8 +3539,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
// apps won't always be considered as foreground state.
// Exclude private presentations as they can only be shown on private virtual displays and
// shouldn't be the cause of an app be considered foreground.
if (mAttrs.type >= FIRST_SYSTEM_WINDOW && mAttrs.type != TYPE_TOAST
&& mAttrs.type != TYPE_PRIVATE_PRESENTATION) {
// Exclude presentations on virtual displays as they are not actually visible.
if (mAttrs.type >= FIRST_SYSTEM_WINDOW
&& mAttrs.type != TYPE_TOAST
&& mAttrs.type != TYPE_PRIVATE_PRESENTATION
&& !(mAttrs.type == TYPE_PRESENTATION && isOnVirtualDisplay())
) {
mWmService.mAtmService.mActiveUids.onNonAppSurfaceVisibilityChanged(mOwnerUid, shown);
}
if (mIsImWindow && mWmService.mAccessibilityController != null) {
@@ -3548,6 +3552,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
}
private boolean isOnVirtualDisplay() {
return getDisplayContent().mDisplay.getType() == Display.TYPE_VIRTUAL;
}
private void logExclusionRestrictions(int side) {
if (!logsGestureExclusionRestrictions(this)
|| SystemClock.uptimeMillis() < mLastExclusionLogUptimeMillis[side]