From d81ff7be8c2a2ba83b3b9bc7ff487a8a4b194ef8 Mon Sep 17 00:00:00 2001 From: Will Leshner Date: Tue, 13 Dec 2022 15:55:10 -0800 Subject: [PATCH] Fix a flicker when short pressing power button. There is no need to explicitly lock the device on short power button press if not going to a dream. The default behavior already locks the device. This fixes a very short flicker when turning off the screen with the power button. Also fixes a bug where double-tapping locks the device before showing the camera. Bug: 262205573, 262484867 Test: manually by undocking device, tapping the power button, and seeing there is no flicker before the screen turns off. Also, make sure the device is locked after the screen turns off. Change-Id: Iec72119495fb4fd47176094d9a0c33fc312600bd --- .../android/server/policy/PhoneWindowManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 85a2a5d0e0ebf..dbe049a8e18ec 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1049,12 +1049,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { return; } - // Make sure the device locks. Unfortunately, this has the side-effect of briefly revealing - // the lock screen before the dream appears. Note that this locking behavior needs to - // happen regardless of whether we end up dreaming (below) or not. - // TODO(b/261662912): Find a better way to lock the device that doesn't result in jank. - lockNow(null); - // Don't dream if the user isn't user zero. // TODO(b/261907079): Move this check to DreamManagerService#canStartDreamingInternal(). if (ActivityManager.getCurrentUser() != UserHandle.USER_SYSTEM) { @@ -1068,6 +1062,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { return; } + // Make sure the device locks. Unfortunately, this has the side-effect of briefly revealing + // the lock screen before the dream appears. Note that locking is a side-effect of the no + // dream action that is executed if we early return above. + // TODO(b/261662912): Find a better way to lock the device that doesn't result in jank. + lockNow(null); + dreamManagerInternal.requestDream(); }