diff options
| author | Wale Ogunwale <ogunwale@google.com> | 2014-11-05 15:17:35 -0800 |
|---|---|---|
| committer | Wale Ogunwale <ogunwale@google.com> | 2014-11-12 09:23:22 -0800 |
| commit | c3672cd3f7e2bd87d6de9dada499de82b62fae84 (patch) | |
| tree | 50790c0f298cc02eca8860be8208493ef1988843 /core/java/android/view/KeyEvent.java | |
| parent | 89444a380d85f8961a4a900734590571375b4f3f (diff) | |
Cancel or drop key events if activity is stopped.
After an activity instance state is saved due to onStop()/onPause(),
there is a small window where it can still get key events like the
back button since we still allow the ActivityThread to handle
pending messages (like memory trim request) before informing the
activity manager that we are done. If the activity is stopped,
we will now drop non-terminal input events and set the cancel
flag on terminal events.
Bug: 18151331
Change-Id: I370d7c871530eea4b16fa42428d0248f1a87abb6
Diffstat (limited to 'core/java/android/view/KeyEvent.java')
| -rw-r--r-- | core/java/android/view/KeyEvent.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 0701b53e4147..243a0fc17e52 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -2304,6 +2304,16 @@ public class KeyEvent extends InputEvent implements Parcelable { } /** + * Set {@link #FLAG_CANCELED} flag for the key event. + * + * @hide + */ + @Override + public final void cancel() { + mFlags |= FLAG_CANCELED; + } + + /** * Call this during {@link Callback#onKeyDown} to have the system track * the key through its final up (possibly including a long press). Note * that only one key can be tracked at a time -- if another key down |
