From 1ff1aedd94bb676cd089e2ad226acbd03d24053a Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Sun, 18 Oct 2020 11:02:24 -0700 Subject: [PATCH] Don't hide overlays created by recents component Launcher (the recents component) can create critical application overlay windows like taskbar. It is important the user and apps can't hide them similar to overlay windows created by sys-ui. Test: Taskbar isn't hidden when you navigate to settings app. Bug: 169054709 Change-Id: Id2f20a8e721821299c44641fb9e78980f7d281f4 --- services/core/java/com/android/server/wm/Session.java | 7 ++++++- services/core/java/com/android/server/wm/WindowState.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java index f84e70eec6756..1b887a7c91723 100644 --- a/services/core/java/com/android/server/wm/Session.java +++ b/services/core/java/com/android/server/wm/Session.java @@ -84,6 +84,9 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { private final ArraySet mAlertWindowSurfaces = new ArraySet<>(); private final DragDropController mDragDropController; final boolean mCanAddInternalSystemWindow; + // If non-system overlays from this process can be hidden by the user or app using + // HIDE_NON_SYSTEM_OVERLAY_WINDOWS. + final boolean mOverlaysCanBeHidden; final boolean mCanHideNonSystemOverlayWindows; final boolean mCanAcquireSleepToken; private AlertWindowNotification mAlertWindowNotification; @@ -105,6 +108,8 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED; mCanHideNonSystemOverlayWindows = service.mContext.checkCallingOrSelfPermission( HIDE_NON_SYSTEM_OVERLAY_WINDOWS) == PERMISSION_GRANTED; + mOverlaysCanBeHidden = !mCanAddInternalSystemWindow + && !mService.mAtmInternal.isCallerRecents(mUid); mCanAcquireSleepToken = service.mContext.checkCallingOrSelfPermission(DEVICE_POWER) == PERMISSION_GRANTED; mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications; @@ -534,7 +539,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { boolean changed; - if (!mCanAddInternalSystemWindow) { + if (mOverlaysCanBeHidden) { // We want to track non-system signature apps adding alert windows so we can post an // on-going notification for the user to control their visibility. if (visible) { diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 90c3d6cb85af4..d4b6d00c16790 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -3057,7 +3057,7 @@ class WindowState extends WindowContainer implements WindowManagerP } void setForceHideNonSystemOverlayWindowIfNeeded(boolean forceHide) { - if (mOwnerCanAddInternalSystemWindow + if (!mSession.mOverlaysCanBeHidden || (!isSystemAlertWindowType(mAttrs.type) && mAttrs.type != TYPE_TOAST)) { return; }