Merge "Wait for KEY_SLEEP UP event before calling goToSleep()" into mnc-dev
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 2839f08..46793b9 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -1087,16 +1087,19 @@
}
}
- private void sleepPress(KeyEvent event) {
+ private void sleepPress(long eventTime) {
+ if (mShortPressOnSleepBehavior == SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME) {
+ launchHomeFromHotKey(false /* awakenDreams */, true /*respectKeyguard*/);
+ }
+ }
+
+ private void sleepRelease(long eventTime) {
switch (mShortPressOnSleepBehavior) {
case SHORT_PRESS_SLEEP_GO_TO_SLEEP:
- mPowerManager.goToSleep(event.getEventTime(),
- PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
- break;
case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME:
- launchHomeFromHotKey(false /* awakenDreams */, true /*respectKeyguard*/);
- mPowerManager.goToSleep(event.getEventTime(),
- PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
+ Slog.i(TAG, "sleepRelease() calling goToSleep(GO_TO_SLEEP_REASON_SLEEP_BUTTON)");
+ mPowerManager.goToSleep(eventTime,
+ PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0);
break;
}
}
@@ -4905,7 +4908,11 @@
if (!mPowerManager.isInteractive()) {
useHapticFeedback = false; // suppress feedback if already non-interactive
}
- sleepPress(event);
+ if (down) {
+ sleepPress(event.getEventTime());
+ } else {
+ sleepRelease(event.getEventTime());
+ }
break;
}