Skip to content

Commit 3c78702

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Maybe fix issue #7146119: exception in FragmentManager" into jb-mr1-dev
2 parents 39de2b0 + 8d5e6f8 commit 3c78702

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,8 +3612,31 @@ void handleImeFinishedEvent(int seq, boolean handled) {
36123612
finishInputEvent(q, true);
36133613
} else {
36143614
if (q.mEvent instanceof KeyEvent) {
3615+
KeyEvent event = (KeyEvent)q.mEvent;
3616+
if (event.getAction() != KeyEvent.ACTION_UP) {
3617+
// If the window doesn't currently have input focus, then drop
3618+
// this event. This could be an event that came back from the
3619+
// IME dispatch but the window has lost focus in the meantime.
3620+
if (!mAttachInfo.mHasWindowFocus) {
3621+
Slog.w(TAG, "Dropping event due to no window focus: " + event);
3622+
finishInputEvent(q, true);
3623+
return;
3624+
}
3625+
}
36153626
deliverKeyEventPostIme(q);
36163627
} else {
3628+
MotionEvent event = (MotionEvent)q.mEvent;
3629+
if (event.getAction() != MotionEvent.ACTION_CANCEL
3630+
&& event.getAction() != MotionEvent.ACTION_UP) {
3631+
// If the window doesn't currently have input focus, then drop
3632+
// this event. This could be an event that came back from the
3633+
// IME dispatch but the window has lost focus in the meantime.
3634+
if (!mAttachInfo.mHasWindowFocus) {
3635+
Slog.w(TAG, "Dropping event due to no window focus: " + event);
3636+
finishInputEvent(q, true);
3637+
return;
3638+
}
3639+
}
36173640
final int source = q.mEvent.getSource();
36183641
if ((source & InputDevice.SOURCE_CLASS_TRACKBALL) != 0) {
36193642
deliverTrackballEventPostIme(q);

0 commit comments

Comments
 (0)