diff options
| author | Jeff Brown <jeffbrown@google.com> | 2011-02-28 18:27:14 -0800 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2011-03-31 19:57:00 -0700 |
| commit | 21bc5c917d4ee2a9b2b8173091e6bba85eaff899 (patch) | |
| tree | f62d92d00808b53244fd6ae31f5efd58e3f08a02 /core/java/android/view/KeyEvent.java | |
| parent | 0029c66203ab9ded4342976bf7a17bb63af8c44a (diff) | |
Add a little input event consistency verifier.
The idea is to assist with debugging by identifying cases in which
the input event stream is corrupted.
Change-Id: I0a00e52bbe2716be1b3dfc7c02a754492d8e7f1f
Diffstat (limited to 'core/java/android/view/KeyEvent.java')
| -rwxr-xr-x | core/java/android/view/KeyEvent.java | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 8070c6a36a4c..4320160c5367 100755 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -1170,7 +1170,18 @@ public class KeyEvent extends InputEvent implements Parcelable { * @hide */ public static final int FLAG_START_TRACKING = 0x40000000; - + + /** + * Private flag that indicates when the system has detected that this key event + * may be inconsistent with respect to the sequence of previously delivered key events, + * such as when a key up event is sent but the key was not down. + * + * @hide + * @see #isTainted + * @see #setTainted + */ + public static final int FLAG_TAINTED = 0x80000000; + /** * Returns the maximum keycode. */ @@ -1535,6 +1546,33 @@ public class KeyEvent extends InputEvent implements Parcelable { } /** + * Obtains a (potentially recycled) copy of another key event. + * + * @hide + */ + public static KeyEvent obtain(KeyEvent other) { + KeyEvent ev = obtain(); + ev.mDownTime = other.mDownTime; + ev.mEventTime = other.mEventTime; + ev.mAction = other.mAction; + ev.mKeyCode = other.mKeyCode; + ev.mRepeatCount = other.mRepeatCount; + ev.mMetaState = other.mMetaState; + ev.mDeviceId = other.mDeviceId; + ev.mScanCode = other.mScanCode; + ev.mFlags = other.mFlags; + ev.mSource = other.mSource; + ev.mCharacters = other.mCharacters; + return ev; + } + + /** @hide */ + @Override + public KeyEvent copy() { + return obtain(this); + } + + /** * Recycles a key event. * Key events should only be recycled if they are owned by the system since user * code expects them to be essentially immutable, "tracking" notwithstanding. @@ -1635,7 +1673,19 @@ public class KeyEvent extends InputEvent implements Parcelable { event.mFlags = flags; return event; } - + + /** @hide */ + @Override + public final boolean isTainted() { + return (mFlags & FLAG_TAINTED) != 0; + } + + /** @hide */ + @Override + public final void setTainted(boolean tainted) { + mFlags = tainted ? mFlags | FLAG_TAINTED : mFlags & ~FLAG_TAINTED; + } + /** * Don't use in new code, instead explicitly check * {@link #getAction()}. |
