From c3672cd3f7e2bd87d6de9dada499de82b62fae84 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Wed, 5 Nov 2014 15:17:35 -0800 Subject: 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 --- core/java/android/view/MotionEvent.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core/java/android/view/MotionEvent.java') diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index ae39b7aeee6d..1c5c41c74905 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -3168,6 +3168,12 @@ public final class MotionEvent extends InputEvent implements Parcelable { return ev; } + /** @hide */ + @Override + public final void cancel() { + setAction(ACTION_CANCEL); + } + public void writeToParcel(Parcel out, int flags) { out.writeInt(PARCEL_TOKEN_MOTION_EVENT); nativeWriteToParcel(mNativePtr, out); -- cgit v1.2.3