diff options
| author | Josh Tsuji <tsuji@google.com> | 2021-01-20 17:41:35 -0500 |
|---|---|---|
| committer | Josh Tsuji <tsuji@google.com> | 2021-01-20 20:08:37 -0500 |
| commit | cb27bd1a831f77d7c6b6ea8acdc5b8665c6f4eaa (patch) | |
| tree | e6835bc67bb3309cd2c3c5695095fb319aca3b52 /core/java/android/view/WindowManagerPolicyConstants.java | |
| parent | 4cf643e12d6ecd3d3f1de9e8535f5cb85717f2a6 (diff) | |
Adds the power button unlock animation and plumbs detailed wake/sleep reason to System UI.
Test: unlock the phone using either the power button or lifting it
Bug: 169693662
Change-Id: I567555e6ee04f369ce7f4b32744639be70583112
Diffstat (limited to 'core/java/android/view/WindowManagerPolicyConstants.java')
| -rw-r--r-- | core/java/android/view/WindowManagerPolicyConstants.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/core/java/android/view/WindowManagerPolicyConstants.java b/core/java/android/view/WindowManagerPolicyConstants.java index dd55f049b364..7668d80d3cb1 100644 --- a/core/java/android/view/WindowManagerPolicyConstants.java +++ b/core/java/android/view/WindowManagerPolicyConstants.java @@ -17,6 +17,7 @@ package android.view; import android.annotation.IntDef; +import android.os.PowerManager; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -108,6 +109,27 @@ public interface WindowManagerPolicyConstants { void onPointerEvent(MotionEvent motionEvent); } + @IntDef(prefix = { "OFF_BECAUSE_OF_" }, value = { + OFF_BECAUSE_OF_ADMIN, + OFF_BECAUSE_OF_USER, + OFF_BECAUSE_OF_TIMEOUT, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface OffReason{} + + static @OffReason int translateSleepReasonToOffReason( + @PowerManager.GoToSleepReason int reason) { + switch (reason) { + case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN: + return OFF_BECAUSE_OF_ADMIN; + case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT: + case PowerManager.GO_TO_SLEEP_REASON_INATTENTIVE: + return OFF_BECAUSE_OF_TIMEOUT; + default: + return OFF_BECAUSE_OF_USER; + } + } + /** Screen turned off because of a device admin */ int OFF_BECAUSE_OF_ADMIN = 1; /** Screen turned off because of power button */ @@ -137,6 +159,23 @@ public interface WindowManagerPolicyConstants { } } + static @OnReason int translateWakeReasonToOnReason(@PowerManager.WakeReason int reason) { + switch (reason) { + case PowerManager.WAKE_REASON_POWER_BUTTON: + case PowerManager.WAKE_REASON_PLUGGED_IN: + case PowerManager.WAKE_REASON_GESTURE: + case PowerManager.WAKE_REASON_CAMERA_LAUNCH: + case PowerManager.WAKE_REASON_WAKE_KEY: + case PowerManager.WAKE_REASON_WAKE_MOTION: + case PowerManager.WAKE_REASON_LID: + return ON_BECAUSE_OF_USER; + case PowerManager.WAKE_REASON_APPLICATION: + return ON_BECAUSE_OF_APPLICATION; + default: + return ON_BECAUSE_OF_UNKNOWN; + } + } + /** Screen turned on because of a user-initiated action. */ int ON_BECAUSE_OF_USER = 1; /** Screen turned on because of an application request or event */ |
