From d1a092218b4b40cfd53a643e0ae01095815f4b30 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 30 Jun 2015 16:22:05 -0700 Subject: [PATCH] Reland "Fixed constant window switching on lock screen..." This is a manual reland of I3680256d41793f62def42fda00e26db1dcc9, which was certainly merged into lmp-mr1-dev then auto-merged into master but silently lost there for unknown reasons when I8c42a1e6091b0fe1253e90265ac248087e was auto-merged into master. Changes in WindowAnimator.java was already covered by I2933eaf0ab55fe31cb382c46c411033e33a756e0 so this CL does not include that change. Bug: 18021493 Bug: 22158649 Change-Id: Ib1bf9f5bef44d0400230afc32231f7d1f3a1c98b --- core/java/android/view/WindowManagerPolicy.java | 7 ++++--- .../com/android/server/policy/PhoneWindowManager.java | 11 ++++++++--- .../com/android/server/wm/WindowManagerService.java | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index ca5f5ad02dc71..dd6d3ca232f0e 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -913,12 +913,13 @@ public interface WindowManagerPolicy { /** * Called following layout of all window to apply policy to each window. - * + * * @param win The window being positioned. - * @param attrs The LayoutParams of the window. + * @param attrs The LayoutParams of the window. + * @param attached For sub-windows, the window it is attached to. Otherwise null. */ public void applyPostLayoutPolicyLw(WindowState win, - WindowManager.LayoutParams attrs); + WindowManager.LayoutParams attrs, WindowState attached); /** * Called following layout of all windows and after policy has been applied diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index b41dd061a1b51..2f8cef8fb581f 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -4244,7 +4244,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ @Override - public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs) { + public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs, + WindowState attached) { if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" + win.isVisibleOrBehindKeyguardLw()); final int fl = PolicyControl.getWindowFlags(win, attrs); @@ -4289,8 +4290,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } - if (appWindow) { - final IApplicationToken appToken = win.getAppToken(); + final IApplicationToken appToken = win.getAppToken(); + + // For app windows that are not attached, we decide if all windows in the app they + // represent should be hidden or if we should hide the lockscreen. For attached app + // windows we defer the decision to the window it is attached to. + if (appWindow && attached == null) { if (showWhenLocked) { // Remove any previous windows with the same appToken. mAppsToBeHidden.remove(appToken); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b285b663bd149..cee38250bb000 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -9937,7 +9937,7 @@ public class WindowManagerService extends IWindowManager.Stub for (i = windows.size() - 1; i >= 0; i--) { WindowState w = windows.get(i); if (w.mHasSurface) { - mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs); + mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs, w.mAttachedWindow); } } displayContent.pendingLayoutChanges |= mPolicy.finishPostLayoutPolicyLw();