diff options
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index f33ab40..76f29cd 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -3808,14 +3808,11 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (keyCode == KeyEvent.KEYCODE_POWER) { policyFlags |= WindowManagerPolicy.FLAG_WAKE; } - final boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE - | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; if (DEBUG_INPUT) { Log.d(TAG, "interceptKeyTq keycode=" + keyCode + " screenIsOn=" + isScreenOn + " keyguardActive=" + keyguardActive - + " policyFlags=" + Integer.toHexString(policyFlags) - + " isWakeKey=" + isWakeKey); + + " policyFlags=" + Integer.toHexString(policyFlags)); } if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 @@ -3832,6 +3829,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // the device some other way (which is why we have an exemption here for injected // events). int result; + boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE + | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; if (isScreenOn || (isInjected && !isWakeKey)) { // When the screen is on or if the key is injected pass the key to the application. result = ACTION_PASS_TO_USER; @@ -3839,8 +3838,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { // When the screen is off and the key is not injected, determine whether // to wake the device but don't pass the key to the application. result = 0; - if (down && isWakeKey && isWakeKeyWhenScreenOff(keyCode)) { - result |= ACTION_WAKE_UP; + if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { + isWakeKey = false; } } @@ -3950,7 +3949,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } if ((mEndcallBehavior & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { - result = (result & ~ACTION_WAKE_UP) | ACTION_GO_TO_SLEEP; + mPowerManager.goToSleep(event.getEventTime()); + isWakeKey = false; } } } @@ -3994,7 +3994,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { mPowerKeyTriggered = false; cancelPendingScreenshotChordAction(); if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { - result = (result & ~ACTION_WAKE_UP) | ACTION_GO_TO_SLEEP; + mPowerManager.goToSleep(event.getEventTime()); + isWakeKey = false; } mPendingPowerKeyUpCanceled = false; } @@ -4064,6 +4065,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { break; } } + + if (isWakeKey) { + mPowerManager.wakeUp(event.getEventTime()); + } return result; } @@ -4104,13 +4109,13 @@ public class PhoneWindowManager implements WindowManagerPolicy { /** {@inheritDoc} */ @Override - public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) { + public int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags) { int result = 0; final boolean isWakeMotion = (policyFlags & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; if (isWakeMotion) { - result |= ACTION_WAKE_UP; + mPowerManager.wakeUp(whenNanos / 1000000); } return result; } |