summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiarhei Vishniakou <svv@google.com>2018-11-13 13:33:52 -0800
committerSiarhei Vishniakou <svv@google.com>2018-11-13 21:36:49 +0000
commit4c3137a9d3fe39d09aed664c0405bb219591cc90 (patch)
tree946a90c1a4bbc2179ffcf626b5914f46b484e180
parent256bb66d02e3cae7a439594a16228d6f462ff9a1 (diff)
downloadnative-4c3137a9d3fe39d09aed664c0405bb219591cc90.tar.gz
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
-rw-r--r--libs/input/VelocityTracker.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/input/VelocityTracker.cpp b/libs/input/VelocityTracker.cpp
index c07a81245a..c70ace0fbd 100644
--- a/libs/input/VelocityTracker.cpp
+++ b/libs/input/VelocityTracker.cpp
@@ -325,8 +325,8 @@ void VelocityTracker::addMovement(const MotionEvent* event) {
eventTime = event->getHistoricalEventTime(h);
for (size_t i = 0; i < pointerCount; i++) {
uint32_t index = pointerIndex[i];
- positions[index].x = event->getHistoricalRawX(i, h);
- positions[index].y = event->getHistoricalRawY(i, h);
+ positions[index].x = event->getHistoricalX(i, h);
+ positions[index].y = event->getHistoricalY(i, h);
}
addMovement(eventTime, idBits, positions);
}
@@ -334,8 +334,8 @@ void VelocityTracker::addMovement(const MotionEvent* event) {
eventTime = event->getEventTime();
for (size_t i = 0; i < pointerCount; i++) {
uint32_t index = pointerIndex[i];
- positions[index].x = event->getRawX(i);
- positions[index].y = event->getRawY(i);
+ positions[index].x = event->getX(i);
+ positions[index].y = event->getY(i);
}
addMovement(eventTime, idBits, positions);
}