From c97296e9d9d2bad7bdd2d34c9428ba5f092fa8c1 Mon Sep 17 00:00:00 2001 From: Linus Tufvesson Date: Fri, 5 Aug 2022 15:14:16 +0200 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 --- .../com/android/server/wm/RootWindowContainer.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 8a5f52f8c4536..b9ff000a21294 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -25,6 +25,7 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PER import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_DREAM; import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; +import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; @@ -317,13 +318,17 @@ class RootWindowContainer extends WindowContainer } /** - * Returns true if the callingUid has any non-toast window currently visible to the user. - * Also ignores TYPE_APPLICATION_STARTING, since those windows don't belong to apps. + * Returns {@code true} if the callingUid has any non-toast window currently visible to the + * user. Also ignores {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_STARTING}, + * and{@link android.view.WindowManager.LayoutParams#TYPE_PRIVATE_PRESENTATION}, as they + * should not count towards the apps visibility + * @see WindowState#isNonToastOrStartingOrPrivatePresentation() */ boolean isAnyNonToastWindowVisibleForUid(int callingUid) { return forAllWindows(w -> w.getOwningUid() == callingUid && w.mAttrs.type != TYPE_TOAST - && w.mAttrs.type != TYPE_APPLICATION_STARTING && w.isVisibleNow(), + && w.mAttrs.type != TYPE_APPLICATION_STARTING + && w.mAttrs.type != TYPE_PRIVATE_PRESENTATION && w.isVisibleNow(), true /* traverseTopToBottom */); }