From 0384f12056b901358cf34690de3da75e1a4a1db2 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Fri, 10 Jan 2020 19:39:43 +0100 Subject: [PATCH] WM: Refactor DisplayContent.getOrientation in preparation for DisplayArea (2/n) DisplayContent.getOrientation: - When the display is frozen, we no longer need to keep track of the last non-app-window requested orientation, if any, because the case of the keyguard becoming intermittently unoccluded is now handled by the condition just below. - We no longer ignore the above app window containers while the display is frozen. This was originally introduced so we don't pick up the keyguard's orientation during occlusion, but this was no longer necessary once we started tracking the occlusion state explicitly. - The logic for forcing the keyguard orientation whenever it is showing or we're unoccluding is now moved to the NonAppWindowContainer, in preparation for DisplayArea. NonAppWindowContainer.getOrientation: - Cleaned up looking for the orienting view when Keyguard is going away Bug: 147406652 Test: atest WmTests Change-Id: Icb0b6f3e80d26a5ce060f2379ca0ca26f6146bbf --- .../com/android/server/wm/DisplayContent.java | 103 ++++++++---------- .../server/wm/WindowManagerService.java | 10 +- 2 files changed, 49 insertions(+), 64 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index f35a7e6236658..7f30cffedacc3 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -396,14 +396,6 @@ class DisplayContent extends WindowContainer mGetOrientingWindow = w -> { - if (!w.isVisibleLw() || !w.mLegacyPolicyVisibilityAfterAnim) { - return false; + final WindowManagerPolicy policy = mWmService.mPolicy; + if (policy.isKeyguardHostWindow(w.mAttrs)) { + if (mWmService.mKeyguardGoingAway) { + return false; + } + // Consider unoccluding only when all unknown visibilities have been + // resolved, as otherwise we just may be starting another occluding activity. + final boolean isUnoccluding = + mDisplayContent.mAppTransition.getAppTransition() + == TRANSIT_KEYGUARD_UNOCCLUDE + && mDisplayContent.mUnknownAppVisibilityController.allResolved(); + // If keyguard is showing, or we're unoccluding, force the keyguard's orientation, + // even if SystemUI hasn't updated the attrs yet. + if (policy.isKeyguardShowingAndNotOccluded() || isUnoccluding) { + return true; + } } final int req = w.mAttrs.screenOrientation; - if(req == SCREEN_ORIENTATION_UNSPECIFIED || req == SCREEN_ORIENTATION_BEHIND + if (req == SCREEN_ORIENTATION_UNSPECIFIED || req == SCREEN_ORIENTATION_BEHIND || req == SCREEN_ORIENTATION_UNSET) { return false; } @@ -4786,39 +4779,27 @@ class DisplayContent extends WindowContainer callback, boolean traverseTopToBottom) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index c78de42b84ae9..b6e31e608dbc0 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -5948,12 +5948,10 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" apps="); pw.print(mAppsFreezingScreen); final DisplayContent defaultDisplayContent = getDefaultDisplayContentLocked(); pw.print(" mRotation="); pw.print(defaultDisplayContent.getRotation()); - pw.print(" mLastWindowForcedOrientation="); - pw.print(defaultDisplayContent.getLastWindowForcedOrientation()); - pw.print(" mLastOrientation="); - pw.println(defaultDisplayContent.getLastOrientation()); - pw.print(" waitingForConfig="); - pw.println(defaultDisplayContent.mWaitingForConfig); + pw.print(" mLastOrientation="); + pw.println(defaultDisplayContent.getLastOrientation()); + pw.print(" waitingForConfig="); + pw.println(defaultDisplayContent.mWaitingForConfig); pw.print(" Animation settings: disabled="); pw.print(mAnimationsDisabled); pw.print(" window="); pw.print(mWindowAnimationScaleSetting);