diff --git a/services/core/java/com/android/server/wm/DisplayArea.java b/services/core/java/com/android/server/wm/DisplayArea.java index b24ab93145b1a..baa27e34d625e 100644 --- a/services/core/java/com/android/server/wm/DisplayArea.java +++ b/services/core/java/com/android/server/wm/DisplayArea.java @@ -551,7 +551,13 @@ public class DisplayArea extends WindowContainer { } final WindowManagerPolicy policy = mWmService.mPolicy; if (policy.isKeyguardHostWindow(w.mAttrs)) { - if (mWmService.mKeyguardGoingAway) { + // Ignore the orientation of keyguard if it is going away or is not showing while + // the device is fully awake. In other words, use the orientation of keyguard if + // its window is visible while the device is going to sleep or is sleeping. + if (!mWmService.mAtmService.isKeyguardLocked() + && mDisplayContent.getDisplayPolicy().isAwake() + // Device is not going to sleep. + && policy.okToAnimate(true /* ignoreScreenOn */)) { return false; } // Consider unoccluding only when all unknown visibilities have been diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 3dbc517af45c3..62d8ace91834b 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1564,12 +1564,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp // window was transferred ({@link #mSkipAppTransitionAnimation}). return false; } - if ((mAppTransition.getTransitFlags() - & WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) != 0) { - // The transition may be finished before keyguard hidden. In order to avoid the - // intermediate orientation change, it is more stable to freeze the display. - return false; - } if (r.isState(RESUMED) && !r.getRootTask().mInResumeTopActivity) { // If the activity is executing or has done the lifecycle callback, use normal // rotation animation so the display info can be updated immediately (see diff --git a/services/core/java/com/android/server/wm/KeyguardController.java b/services/core/java/com/android/server/wm/KeyguardController.java index f8238c1d154ad..3208ae3aa97d4 100644 --- a/services/core/java/com/android/server/wm/KeyguardController.java +++ b/services/core/java/com/android/server/wm/KeyguardController.java @@ -72,7 +72,6 @@ class KeyguardController { private boolean mAodShowing; private boolean mKeyguardGoingAway; private boolean mDismissalRequested; - private int mBeforeUnoccludeTransit; private final SparseArray mDisplayStates = new SparseArray<>(); private final ActivityTaskManagerService mService; private RootWindowContainer mRootWindowContainer; @@ -191,14 +190,11 @@ class KeyguardController { // Irrelevant to AOD. dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */, false /* turningScreenOn */); - setKeyguardGoingAway(false); + mKeyguardGoingAway = false; if (keyguardShowing) { mDismissalRequested = false; } } - // TODO(b/113840485): Check usage for non-default display - mWindowManager.setKeyguardOrAodShowingOnDefaultDisplay( - isKeyguardOrAodShowing(DEFAULT_DISPLAY)); // Update the sleep token first such that ensureActivitiesVisible has correct sleep token // state when evaluating visibilities. @@ -219,8 +215,8 @@ class KeyguardController { } Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "keyguardGoingAway"); mService.deferWindowLayout(); + mKeyguardGoingAway = true; try { - setKeyguardGoingAway(true); EventLogTags.writeWmSetKeyguardShown( 1 /* keyguardShowing */, mAodShowing ? 1 : 0, @@ -258,11 +254,6 @@ class KeyguardController { mWindowManager.dismissKeyguard(callback, message); } - private void setKeyguardGoingAway(boolean keyguardGoingAway) { - mKeyguardGoingAway = keyguardGoingAway; - mWindowManager.setKeyguardGoingAway(keyguardGoingAway); - } - private void failCallback(IKeyguardDismissCallback callback) { try { callback.onDismissError(); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 147260b9e9121..107580686b814 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -483,10 +483,7 @@ public class WindowManagerService extends IWindowManager.Stub private final DisplayAreaPolicy.Provider mDisplayAreaPolicyProvider; final private KeyguardDisableHandler mKeyguardDisableHandler; - // TODO: eventually unify all keyguard state in a common place instead of having it spread over - // AM's KeyguardController and the policy's KeyguardServiceDelegate. - boolean mKeyguardGoingAway; - boolean mKeyguardOrAodShowingOnDefaultDisplay; + // VR Vr2d Display Id. int mVr2dDisplayId = INVALID_DISPLAY; boolean mVrModeEnabled = false; @@ -3072,17 +3069,6 @@ public class WindowManagerService extends IWindowManager.Stub mAtmInternal.notifyKeyguardFlagsChanged(callback, displayId); } - public void setKeyguardGoingAway(boolean keyguardGoingAway) { - synchronized (mGlobalLock) { - mKeyguardGoingAway = keyguardGoingAway; - } - } - - public void setKeyguardOrAodShowingOnDefaultDisplay(boolean showing) { - synchronized (mGlobalLock) { - mKeyguardOrAodShowingOnDefaultDisplay = showing; - } - } // ------------------------------------------------------------- // Misc IWindowSession methods diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 5bc4c82f8d43d..d498d4663d782 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -100,7 +100,6 @@ import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doCallRealMethod; -import android.annotation.SuppressLint; import android.app.ActivityTaskManager; import android.app.WindowConfiguration; import android.app.servertransaction.FixedRotationAdjustmentsItem; @@ -792,15 +791,9 @@ public class DisplayContentTests extends WindowTestsBase { } @Test - @SuppressLint("InlinedApi") public void testOrientationDefinedByKeyguard() { - final DisplayContent dc = createNewDisplay(); - - // When display content is created its configuration is not yet initialized, which could - // cause unnecessary configuration propagation, so initialize it here. - final Configuration config = new Configuration(); - dc.computeScreenConfiguration(config); - dc.onRequestedOverrideConfigurationChanged(config); + final DisplayContent dc = mDisplayContent; + dc.getDisplayPolicy().setAwake(true); // Create a window that requests landscape orientation. It will define device orientation // by default. @@ -815,10 +808,12 @@ public class DisplayContentTests extends WindowTestsBase { SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation()); keyguard.mAttrs.screenOrientation = SCREEN_ORIENTATION_PORTRAIT; + mAtm.mKeyguardController.setKeyguardShown(true /* keyguardShowing */, + false /* aodShowing */); assertEquals("Visible keyguard must influence device orientation", SCREEN_ORIENTATION_PORTRAIT, dc.getOrientation()); - mWm.setKeyguardGoingAway(true); + mAtm.mKeyguardController.keyguardGoingAway(0 /* flags */); assertEquals("Keyguard that is going away must not influence device orientation", SCREEN_ORIENTATION_LANDSCAPE, dc.getOrientation()); }