From 54872c3116a6114aeff0e57bf526c53a6e10dfec Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Thu, 14 Nov 2019 19:41:47 -0800 Subject: [PATCH] Fix hung input event while resizing In onInputEvent inplementation, the finishInputEvent needs to be called always, to report back the input event handling result. The previous implementation will have no call for non-dragging event and throw them away. This caused an ANR. Test: reproduce step in b/144141494 Test: go/wm-smoke Bug: 144141494 Bug: 122726344 Change-Id: If6f8da87609641a62d12712aa6c97a58a06bde60 --- .../java/com/android/server/wm/TaskPositioner.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java index f7b802da88606..a867a5d41e243 100644 --- a/services/core/java/com/android/server/wm/TaskPositioner.java +++ b/services/core/java/com/android/server/wm/TaskPositioner.java @@ -133,14 +133,15 @@ class TaskPositioner implements IBinder.DeathRecipient { @Override public void onInputEvent(InputEvent event) { - if (!(event instanceof MotionEvent) - || (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) { - return; - } - final MotionEvent motionEvent = (MotionEvent) event; boolean handled = false; - try { + // All returns need to be in the try block to make sure the finishInputEvent is + // called correctly. + if (!(event instanceof MotionEvent) + || (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) { + return; + } + final MotionEvent motionEvent = (MotionEvent) event; if (mDragEnded) { // The drag has ended but the clean-up message has not been processed by // window manager. Drop events that occur after this until window manager