summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2011-11-15 12:56:55 -0800
committer Jeff Brown <jeffbrown@google.com> 2011-11-15 13:03:11 -0800
commitbc072da931b7b146f19c0ee9dd5dac9a1cccab16 (patch)
tree3c747eab8cc6bb0588f882847e972fe6fafedbd4
parentbf677de46a039e07038511909576bfbf4406f7fd (diff)
POWER key is always a wake key.
This change is useful to ensure that injected POWER key events always wake the device even if the right policy flags were not set. Change-Id: I05b8b35f984f5c9f58b0e9d44bcb6f41a9562fc8
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 921f3313fb0f..a42a433f1fe0 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -2649,6 +2649,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false);
}
+ if (keyCode == KeyEvent.KEYCODE_POWER) {
+ policyFlags |= WindowManagerPolicy.FLAG_WAKE;
+ }
+ final boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE
+ | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;
+
// Basic policy based on screen state and keyguard.
// FIXME: This policy isn't quite correct. We shouldn't care whether the screen
// is on or off, really. We should care about whether the device is in an
@@ -2658,16 +2664,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// the device some other way (which is why we have an exemption here for injected
// events).
int result;
- if (isScreenOn || isInjected) {
+ 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;
} else {
// 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;
-
- final boolean isWakeKey = (policyFlags
- & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0;
if (down && isWakeKey) {
if (keyguardActive) {
// If the keyguard is showing, let it decide what to do with the wake key.