diff options
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 44 | ||||
| -rw-r--r-- | policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java | 65 |
2 files changed, 49 insertions, 60 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 406f644fab95..5397a29cda3b 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -3168,8 +3168,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (lidOpen) { if (keyguardIsShowingTq()) { - mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq( - KeyEvent.KEYCODE_POWER, mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED); + mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(KeyEvent.KEYCODE_POWER); } else { mPowerManager.wakeUp(SystemClock.uptimeMillis()); } @@ -3388,11 +3387,10 @@ 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) { + if (down && isWakeKey && isWakeKeyWhenScreenOff(keyCode)) { if (keyguardActive) { - // If the keyguard is showing, let it decide what to do with the wake key. - mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode, - mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED); + // If the keyguard is showing, let it wake the device when ready. + mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode); } else { // Otherwise, wake the device ourselves. result |= ACTION_WAKE_UP; @@ -3614,6 +3612,40 @@ public class PhoneWindowManager implements WindowManagerPolicy { return result; } + /** + * When the screen is off 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 isWakeKeyWhenScreenOff(int keyCode) { + switch (keyCode) { + // ignore volume keys unless docked + case KeyEvent.KEYCODE_VOLUME_UP: + case KeyEvent.KEYCODE_VOLUME_DOWN: + case KeyEvent.KEYCODE_VOLUME_MUTE: + return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; + + // ignore media and camera keys + case KeyEvent.KEYCODE_MUTE: + case KeyEvent.KEYCODE_HEADSETHOOK: + case KeyEvent.KEYCODE_MEDIA_PLAY: + case KeyEvent.KEYCODE_MEDIA_PAUSE: + case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: + case KeyEvent.KEYCODE_MEDIA_STOP: + case KeyEvent.KEYCODE_MEDIA_NEXT: + case KeyEvent.KEYCODE_MEDIA_PREVIOUS: + case KeyEvent.KEYCODE_MEDIA_REWIND: + case KeyEvent.KEYCODE_MEDIA_RECORD: + case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: + case KeyEvent.KEYCODE_CAMERA: + return false; + } + return true; + } + + /** {@inheritDoc} */ @Override public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) { diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java index 3648d99abbb4..5e192719c42b 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java @@ -175,7 +175,7 @@ public class KeyguardViewMediator { * Does not turn on screen, held while a call to {@link KeyguardViewManager#wakeWhenReadyTq(int)} * is called to make sure the device doesn't sleep before it has a chance to poke * the wake lock. - * @see #wakeWhenReadyLocked(int) + * @see #wakeWhenReady(int) */ private PowerManager.WakeLock mWakeAndHandOff; @@ -935,8 +935,8 @@ public class KeyguardViewMediator { * @see #handleWakeWhenReady * @see #onWakeKeyWhenKeyguardShowingTq(int) */ - private void wakeWhenReadyLocked(int keyCode) { - if (DBG_WAKE) Log.d(TAG, "wakeWhenReadyLocked(" + keyCode + ")"); + private void wakeWhenReady(int keyCode) { + if (DBG_WAKE) Log.d(TAG, "wakeWhenReady(" + keyCode + ")"); /** * acquire the handoff lock that will keep the cpu running. this will @@ -1014,54 +1014,14 @@ public class KeyguardViewMediator { * 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, boolean isDocked) { + public void onWakeKeyWhenKeyguardShowingTq(int keyCode) { if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + 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 - wakeWhenReadyLocked(keyCode); - return true; - } else { - return false; - } - } - - /** - * 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: - case KeyEvent.KEYCODE_MEDIA_PAUSE: - case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: - case KeyEvent.KEYCODE_MEDIA_STOP: - case KeyEvent.KEYCODE_MEDIA_NEXT: - case KeyEvent.KEYCODE_MEDIA_PREVIOUS: - case KeyEvent.KEYCODE_MEDIA_REWIND: - case KeyEvent.KEYCODE_MEDIA_RECORD: - case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: - case KeyEvent.KEYCODE_CAMERA: - return false; - } - return true; + // 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 + wakeWhenReady(keyCode); } /** @@ -1073,17 +1033,14 @@ public class KeyguardViewMediator { * The 'Tq' suffix is per the documentation in {@link WindowManagerPolicy}. * Be sure not to take any action that takes a long time; any significant * action should be posted to a handler. - * - * @return Whether we poked the wake lock (and turned the screen on) */ - public boolean onWakeMotionWhenKeyguardShowingTq() { + public void onWakeMotionWhenKeyguardShowingTq() { if (DEBUG) Log.d(TAG, "onWakeMotionWhenKeyguardShowing()"); // 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 - wakeWhenReadyLocked(KeyEvent.KEYCODE_UNKNOWN); - return true; + wakeWhenReady(KeyEvent.KEYCODE_UNKNOWN); } public void keyguardDone(boolean authenticated, boolean wakeup) { @@ -1350,7 +1307,7 @@ public class KeyguardViewMediator { } /** - * Handle message sent by {@link #wakeWhenReadyLocked(int)} + * Handle message sent by {@link #wakeWhenReady(int)} * @param keyCode The key that woke the device. * @see #WAKE_WHEN_READY */ |