InkWindow: Provide a copy of the motion event to view root

When a motion event is enqueued into the view root, the view root
expects to own the event, which means it will finish and recycle the
event if necessary.

In the handwriting pipeline, this event actually comes from an
InputEventReceiver that handles finishing the event, so there is a
chance that the event is finished or recycled twice. Make sure the view
root owns the event that is enqueued into it by providing it with a copy
of the event.

Bug: 277809922
Test: manual, HandwritingIme
Change-Id: I65968d075640c1dd585d5d7b9eadb78e3dff9aa2
This commit is contained in:
Prabir Pradhan
2023-04-12 00:16:04 +00:00
parent ca7c149247
commit c4574fc01f

View File

@@ -195,6 +195,7 @@ final class InkWindow extends PhoneWindow {
Objects.requireNonNull(decor);
final ViewRootImpl viewRoot = decor.getViewRootImpl();
Objects.requireNonNull(viewRoot);
viewRoot.enqueueInputEvent(event);
// The view root will own the event that we enqueue, so provide a copy of the event.
viewRoot.enqueueInputEvent(MotionEvent.obtain(event));
}
}