From c1e2804be14d9510575e7af745e122351f9077c7 Mon Sep 17 00:00:00 2001 From: Beverly Date: Thu, 5 Jan 2023 19:33:29 +0000 Subject: [PATCH] Ignore power presses from lift and biometric wake WAKE_REASON_GESTURE previously used to include both WAKE_REASON_LIFT, WAKE_REASON_TAP and WAKE_REASON_BIOMETRIC. Since ag/20794573, these gestures are not not all encompassed by WAKE_REASON_GESTURE. This CL ensures the power suppression logic is still used for wake reason lift and biometric. We intetionally include biometric in case biometrics are related to the power button. We intentionally leave out tap to wake since it's not necessary to gate a power button press due to a wake up from a tap on the screen. Test: Press the power button while performing lift to wake gesture, observe that the device does not go back to sleep Fixes: 264553999 Change-Id: Ia74d30fd808d0a49937f483575b53533b0f1fce7 --- core/java/android/view/WindowManagerPolicyConstants.java | 3 +++ .../java/com/android/server/policy/PhoneWindowManager.java | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/WindowManagerPolicyConstants.java b/core/java/android/view/WindowManagerPolicyConstants.java index 43d427db2c750..4c49f2c049eed 100644 --- a/core/java/android/view/WindowManagerPolicyConstants.java +++ b/core/java/android/view/WindowManagerPolicyConstants.java @@ -169,6 +169,9 @@ public interface WindowManagerPolicyConstants { case PowerManager.WAKE_REASON_POWER_BUTTON: case PowerManager.WAKE_REASON_PLUGGED_IN: case PowerManager.WAKE_REASON_GESTURE: + case PowerManager.WAKE_REASON_TAP: + case PowerManager.WAKE_REASON_LIFT: + case PowerManager.WAKE_REASON_BIOMETRIC: case PowerManager.WAKE_REASON_CAMERA_LAUNCH: case PowerManager.WAKE_REASON_WAKE_KEY: case PowerManager.WAKE_REASON_WAKE_MOTION: diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index de0d1f8f76afb..5285f63dcc44f 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1077,10 +1077,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { // a tendency to hit the power button immediately when they pick up their device, and we // don't want to put the device back to sleep in those cases. final PowerManager.WakeData lastWakeUp = mPowerManagerInternal.getLastWakeup(); - if (lastWakeUp != null && lastWakeUp.wakeReason == PowerManager.WAKE_REASON_GESTURE) { - final int gestureDelayMillis = Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.POWER_BUTTON_SUPPRESSION_DELAY_AFTER_GESTURE_WAKE, - POWER_BUTTON_SUPPRESSION_DELAY_DEFAULT_MILLIS); + if (lastWakeUp != null && (lastWakeUp.wakeReason == PowerManager.WAKE_REASON_GESTURE + || lastWakeUp.wakeReason == PowerManager.WAKE_REASON_LIFT + || lastWakeUp.wakeReason == PowerManager.WAKE_REASON_BIOMETRIC)) { final long now = SystemClock.uptimeMillis(); if (mPowerButtonSuppressionDelayMillis > 0 && (now < lastWakeUp.wakeTime + mPowerButtonSuppressionDelayMillis)) {