OSDN Git Service

Do not use raw coordinates in VelocityTracker
authorSiarhei Vishniakou <svv@google.com>
Tue, 13 Nov 2018 21:33:52 +0000 (13:33 -0800)
committerSiarhei Vishniakou <svv@google.com>
Tue, 13 Nov 2018 21:36:49 +0000 (21:36 +0000)
commit4c3137a9d3fe39d09aed664c0405bb219591cc90
tree946a90c1a4bbc2179ffcf626b5914f46b484e180
parent256bb66d02e3cae7a439594a16228d6f462ff9a1
Do not use raw coordinates in VelocityTracker

In P, we switched VelocityTracker to use raw coordinates when
calculating the velocity. While that helped solve the issues with views
being moved while touched, this has broken some other assumptions in the
view hierarchy. Currently during dispatch, MotionEvent coordinates are
getting adjusted as events are passed to the child views.

One example is a rotated ListView. When setRotation is called on a
ListView, ListView continues to use getYVelocity to determine the fling
speed. However, after the view is rotated, its action is in the
horizontal direction. This causes flings on ListView to not work
properly.

Further analysing the View system api, it appears that the problem could
also occur in such cases as scale, where the view gets increased in
size, and MotionEvents are adjusted accordingly.

This issue could have been solved in the view hierarchy by changing the
assumptions and reworking the VelocityTracker usage. However, that is
deemed infeasible.

The switch to raw coordinates was to resolve the issue when a moving
view is trying to calculate the velocity of the fling. Since that no
longer is possible, we will have to use work-arounds for those use
cases. One such example is the SystemUI use case, in PanelView.java.

Bug: 117921784
Bug: 117475766
Test: Sample app from bug 117475766, flings in the horizontal direction
work properly

Change-Id: If4cd6ace0bbef52521e1bbab8d58d649b295e2b7
libs/input/VelocityTracker.cpp