diff options
| author | Jeff Brown <jeffbrown@google.com> | 2010-10-11 23:32:49 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2010-10-12 00:16:14 -0700 |
| commit | 3122e4488aa0749cbec9890ace22c366e35350c3 (patch) | |
| tree | fed38c07c499413707f543ef9d0bbe45ccdf23c7 /policy | |
| parent | a28d5aff5466a55149b9e6f9cd908fcc225c25ff (diff) | |
| download | frameworks_base-3122e4488aa0749cbec9890ace22c366e35350c3.zip frameworks_base-3122e4488aa0749cbec9890ace22c366e35350c3.tar.gz frameworks_base-3122e4488aa0749cbec9890ace22c366e35350c3.tar.bz2 | |
Improve the input policy handling a bit.
Fixed some issues with Monkeys turning off their own screens. Ook ook!
Added some more comments to explain what's going on.
Change-Id: Id2bc0466161a642a73ef7ef97725d1c81e984b12
Diffstat (limited to 'policy')
| -rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index d9bceec..3cf4360 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -1057,10 +1057,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { @Override public boolean interceptKeyBeforeDispatching(WindowState win, int action, int flags, int keyCode, int metaState, int repeatCount, int policyFlags) { - if ((policyFlags & WindowManagerPolicy.FLAG_TRUSTED) == 0) { - return false; - } - final boolean keyguardOn = keyguardOn(); final boolean down = (action == KeyEvent.ACTION_DOWN); final boolean canceled = ((flags & KeyEvent.FLAG_CANCELED) != 0); @@ -1739,9 +1735,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { public int interceptKeyBeforeQueueing(long whenNanos, int keyCode, boolean down, int policyFlags, boolean isScreenOn) { int result = ACTION_PASS_TO_USER; - if ((policyFlags & WindowManagerPolicy.FLAG_TRUSTED) == 0) { - return result; - } if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0) { performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); @@ -1749,7 +1742,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { final boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; - + + // If the key is injected, pretend that the screen is on and don't let the + // device go to sleep. This feature is mainly used for testing purposes. + final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; + if (isInjected) { + isScreenOn = true; + } + // If screen is off then we treat the case where the keyguard is open but hidden // the same as if it were open and in front. // This will prevent any keys other than the power button from waking the screen @@ -1848,7 +1848,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { || (handled && hungUp && keyCode == KeyEvent.KEYCODE_POWER)) { mShouldTurnOffOnKeyUp = false; } else { - // only try to turn off the screen if we didn't already hang up + // Only try to turn off the screen if we didn't already hang up. mShouldTurnOffOnKeyUp = true; mHandler.postDelayed(mPowerLongPress, ViewConfiguration.getGlobalActionKeyTimeout()); @@ -1871,12 +1871,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (keyguardActive || (sleeps && !gohome) || (gohome && !goHome() && sleeps)) { - // they must already be on the keyguad or home screen, - // go to sleep instead - Log.d(TAG, "I'm tired mEndcallBehavior=0x" - + Integer.toHexString(mEndcallBehavior)); - result &= ~ACTION_POKE_USER_ACTIVITY; - result |= ACTION_GO_TO_SLEEP; + // They must already be on the keyguard or home screen, + // go to sleep instead unless the event was injected. + if (!isInjected) { + Log.d(TAG, "I'm tired mEndcallBehavior=0x" + + Integer.toHexString(mEndcallBehavior)); + result &= ~ACTION_POKE_USER_ACTIVITY; + result |= ACTION_GO_TO_SLEEP; + } } result &= ~ACTION_PASS_TO_USER; } |
