diff options
author | Jeff Brown <jeffbrown@google.com> | 2011-03-02 19:23:13 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2011-03-02 19:57:07 -0800 |
commit | 56194ebec6212e229f4ccdaa4b187166d20013ef (patch) | |
tree | 51276000061ba703b6ddda32ecce3ce10a06f4f5 /policy/src | |
parent | 05dc66ada6b61a6bdf806ffaa62617ac5394695d (diff) | |
download | frameworks_base-56194ebec6212e229f4ccdaa4b187166d20013ef.zip frameworks_base-56194ebec6212e229f4ccdaa4b187166d20013ef.tar.gz frameworks_base-56194ebec6212e229f4ccdaa4b187166d20013ef.tar.bz2 |
Wake screen from external HID peripherals.
Added some plumbing to enable the policy to intercept motion
events when the screen is off to handle wakeup if needed.
Added a basic concept of an external device to limit the scope
of the wakeup policy to external devices only. The wakeup policy
for internal devices should be based on explicit rules such as
policy flags in key layout files.
Moved isTouchEvent to native.
Ensure the dispatcher sends the right event type to userActivity
for non-touch pointer events like HOVER_MOVE and SCROLL.
Bug: 3193114
Change-Id: I15dbd48a16810dfaf226ff7ad117d46908ca4f86
Diffstat (limited to 'policy/src')
4 files changed, 45 insertions, 2 deletions
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java index 36afd75..74dde9c 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java @@ -108,7 +108,8 @@ public abstract class KeyguardViewBase extends FrameLayout { * action should be posted to a handler. * * @param keyCode The wake key, which may be relevant for configuring the - * keyguard. + * keyguard. May be {@link KeyEvent#KEYCODE_UNKNOWN} if waking for a reason + * other than a key press. */ abstract public void wakeWhenReadyTq(int keyCode); diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java index edab690..8d70a7b 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java @@ -201,7 +201,8 @@ public class KeyguardViewManager implements KeyguardWindowController { * Be sure not to take any action that takes a long time; any significant * action should be posted to a handler. * - * @param keyCode The wake key. + * @param keyCode The wake key. May be {@link KeyEvent#KEYCODE_UNKNOWN} if waking + * for a reason other than a key press. */ public boolean wakeWhenReadyTq(int keyCode) { if (DEBUG) Log.d(TAG, "wakeWhenReady(" + keyCode + ")"); diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java index b32a729..e7a9eb1 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -810,6 +810,28 @@ public class KeyguardViewMediator implements KeyguardViewCallback, } /** + * When a wake motion such as an external mouse movement is received when the screen + * is off and the keyguard is showing, we need to decide whether to actually turn + * on the screen, and if so, tell the keyguard to prepare itself and poke the wake + * lock when it is ready. + * + * 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() { + 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; + } + + /** * Callbacks from {@link KeyguardViewManager}. */ diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 75ef762..8e18f2a 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -2364,6 +2364,25 @@ public class PhoneWindowManager implements WindowManagerPolicy { return result; } + /** {@inheritDoc} */ + @Override + public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) { + int result = 0; + + final boolean isWakeMotion = (policyFlags + & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; + if (isWakeMotion) { + if (mKeyguardMediator.isShowing()) { + // If the keyguard is showing, let it decide what to do with the wake motion. + mKeyguardMediator.onWakeMotionWhenKeyguardShowingTq(); + } else { + // Otherwise, wake the device ourselves. + result |= ACTION_POKE_USER_ACTIVITY; + } + } + return result; + } + class PassHeadsetKey implements Runnable { KeyEvent mKeyEvent; |