From 43150bfa9377ca7a5fe0e6bfcdc04fb5807501f7 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 8 Nov 2011 20:22:03 -0800 Subject: Wake on volume key when in dock. Bug: 5580373 Change-Id: I847fb10b48c2e5e26cabefea1d630793efc32131 --- .../internal/policy/impl/KeyguardViewMediator.java | 18 +++++++++++++++--- .../internal/policy/impl/PhoneWindowManager.java | 5 +++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java index c802bc1fc626..b5146892244c 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -830,12 +830,13 @@ public class KeyguardViewMediator implements KeyguardViewCallback, * action should be posted to a handler. * * @param keyCode The keycode of the key that woke the device + * @param isDocked True if the device is in the dock * @return Whether we poked the wake lock (and turned the screen on) */ - public boolean onWakeKeyWhenKeyguardShowingTq(int keyCode) { + public boolean onWakeKeyWhenKeyguardShowingTq(int keyCode, boolean isDocked) { if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")"); - if (isWakeKeyWhenKeyguardShowing(keyCode)) { + if (isWakeKeyWhenKeyguardShowing(keyCode, isDocked)) { // give the keyguard view manager a chance to adjust the state of the // keyguard based on the key that woke the device before poking // the wake lock @@ -846,11 +847,22 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } } - private boolean isWakeKeyWhenKeyguardShowing(int keyCode) { + /** + * When the keyguard is showing we ignore some keys that might otherwise typically + * be considered wake keys. We filter them out here. + * + * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it + * is always considered a wake key. + */ + private boolean isWakeKeyWhenKeyguardShowing(int keyCode, boolean isDocked) { switch (keyCode) { + // ignore volume keys unless docked case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: + return isDocked; + + // ignore media and camera keys case KeyEvent.KEYCODE_MUTE: case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY: diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index aa1c81c07b9e..f2d688b978c3 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -2480,7 +2480,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // keyguard, then we need to have it turn on the // screen once it is shown. mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq( - KeyEvent.KEYCODE_POWER); + KeyEvent.KEYCODE_POWER, mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED); } } else { // Light up the keyboard if we are sliding up. @@ -2700,7 +2700,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (down && isWakeKey) { if (keyguardActive) { // If the keyguard is showing, let it decide what to do with the wake key. - mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode); + mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode, + mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED); } else { // Otherwise, wake the device ourselves. result |= ACTION_POKE_USER_ACTIVITY; -- cgit v1.2.3-59-g8ed1b