From 88e98e0a853f7530d61aab13dea2bfc9792e3f32 Mon Sep 17 00:00:00 2001 From: Linus Tufvesson Date: Wed, 24 Nov 2021 15:49:43 +0000 Subject: [PATCH] DO NOT MERGE - Exclude TYPE_PRIVATE_PRESENTATION app visiblity These windows can only be placed on private virtual displays, and as such they should not be considered when deciding if an application has any visible windows or not. Bug:205130886 Test:Manually verified that sample from 205130886 no longer allows background activity launches Test: atest CtsActivityManagerBackgroundActivityTestCases Change-Id: I76208722bbb7a407ba1f2dc4305a28226166414d Merged-In: I76208722bbb7a407ba1f2dc4305a28226166414d --- services/core/java/com/android/server/wm/WindowState.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 5e042efa2f112..3fe294e428c59 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -3537,7 +3537,10 @@ class WindowState extends WindowContainer implements WindowManagerP } // Exclude toast because legacy apps may show toast window by themselves, so the misused // apps won't always be considered as foreground state. - if (mAttrs.type >= FIRST_SYSTEM_WINDOW && mAttrs.type != TYPE_TOAST) { + // 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) { mWmService.mAtmService.mActiveUids.onNonAppSurfaceVisibilityChanged(mOwnerUid, shown); } if (mIsImWindow && mWmService.mAccessibilityController != null) {