Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Propoagate Tap events on Android hybrid views #19608

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,38 @@ private MotionEvent toMotionEvent(float density, PlatformViewsChannel.PlatformVi
MotionEventTracker.MotionEventId motionEventId =
MotionEventTracker.MotionEventId.from(touch.motionEventId);
MotionEvent trackedEvent = motionEventTracker.pop(motionEventId);
if (trackedEvent != null) {
return trackedEvent;
}

// TODO (kaushikiska) : warn that we are potentially using an untracked
// event in the platform views.
// Pointer coordinates in the tracked events are global to FlutterView
// framework converts them to be local to a widget, given that
// motion events operate on local coords, we need to replace these in the tracked
// event with their local counterparts.
PointerProperties[] pointerProperties =
parsePointerPropertiesList(touch.rawPointerPropertiesList)
.toArray(new PointerProperties[touch.pointerCount]);
PointerCoords[] pointerCoords =
parsePointerCoordsList(touch.rawPointerCoords, density)
.toArray(new PointerCoords[touch.pointerCount]);

if (trackedEvent != null) {
return MotionEvent.obtain(
trackedEvent.getDownTime(),
trackedEvent.getEventTime(),
trackedEvent.getAction(),
touch.pointerCount,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with multiple touch, this pointerCount may unmatched with the trackedEvent.getAction() and cause some crash.
for example.
trackedEvent.getAction() -> 0x0106 (ActionIndex = 1, ACITON_POINTER_UP)
but pointerCount from flutter engine missed move event with the pointerUp, pointerCount will be 1

pointerProperties,
pointerCoords,
trackedEvent.getMetaState(),
trackedEvent.getButtonState(),
trackedEvent.getXPrecision(),
trackedEvent.getYPrecision(),
trackedEvent.getDeviceId(),
trackedEvent.getEdgeFlags(),
trackedEvent.getSource(),
trackedEvent.getFlags());
}

// TODO (kaushikiska) : warn that we are potentially using an untracked
// event in the platform views.
return MotionEvent.obtain(
touch.downTime.longValue(),
touch.eventTime.longValue(),
Expand Down