diff options
| author | 2022-11-28 15:06:03 -0800 | |
|---|---|---|
| committer | 2022-12-09 08:45:07 -0800 | |
| commit | c5f6dc060408b8ce9ce293ec99c83b17d2ac60bf (patch) | |
| tree | 180ee3f68f04c3e7d3ae137bab9109f3ebaaa8d0 | |
| parent | 1f9eb48888c2c48ae58f3ee63cade5d590bd4c3e (diff) | |
Lock device on short power button press.
If a device is configured to dream on short power press, also make sure
it locks as well.
Also fixes an issue where the screen does not turn off when another
user (not user zero) presses the power button.
Bug: 260135090
Test: manually by configuring device to dream on short power press and
then making sure it is also locked after press.
Change-Id: I16ca4eab7a0e8a3f2ef42c090147bd7e62445c69
| -rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 6d5da3254eac..85a2a5d0e0eb 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1049,6 +1049,19 @@ 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) { + noDreamAction.run(); + return; + } + final DreamManagerInternal dreamManagerInternal = getDreamManagerInternal(); if (dreamManagerInternal == null || !dreamManagerInternal.canStartDreaming(isScreenOn)) { noDreamAction.run(); |