summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-08-19 02:21:22 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-08-19 02:21:22 +0000
commit8f78892826c164898bec2077667a1ae6bd4981da (patch)
tree5536eed44402612e969153d27d3a2b3381f59483
parentafafb7d144fbced4675720d5f8c53a02e1ee27a8 (diff)
parentc7c9e80d58665e698521bc5571a139eab8f655d4 (diff)
downloadLauncher3-android11-s1-release.tar.gz
Merge cherrypicks of [12405309, 12403860, 12405276, 12405277, 12403960, 12403961, 12403861, 12405327, 12405278, 12404928, 12405287, 12405279, 12405385, 12405280] into rvc-releaseandroid-11.0.0_r5android-11.0.0_r4android-11.0.0_r25android-11.0.0_r17android11-s1-releaseandroid11-release
Change-Id: I8374e1c849f6e001e97b19a83b33b8cb26ef5b7b
-rw-r--r--quickstep/src/com/android/quickstep/util/MotionPauseDetector.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index a5d456878a..f60f7ad6d8 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -276,7 +276,7 @@ public class MotionPauseDetector {
private static final int HISTORY_SIZE = 20;
// Position history are stored in a circular array
- private final float[] mHistoricTimes = new float[HISTORY_SIZE];
+ private final long[] mHistoricTimes = new long[HISTORY_SIZE];
private final float[] mHistoricPos = new float[HISTORY_SIZE];
private int mHistoryCount = 0;
private int mHistoryStart = 0;
@@ -292,7 +292,7 @@ public class MotionPauseDetector {
mHistoryCount = mHistoryStart = 0;
}
- private void addPositionAndTime(float eventTime, float eventPosition) {
+ private void addPositionAndTime(long eventTime, float eventPosition) {
mHistoricTimes[mHistoryStart] = eventTime;
mHistoricPos[mHistoryStart] = eventPosition;
mHistoryStart++;
@@ -322,7 +322,7 @@ public class MotionPauseDetector {
* Based on solveUnweightedLeastSquaresDeg2 in VelocityTracker.cpp
*/
private Float solveUnweightedLeastSquaresDeg2(final int pointPos) {
- final float eventTime = mHistoricTimes[pointPos];
+ final long eventTime = mHistoricTimes[pointPos];
float sxi = 0, sxiyi = 0, syi = 0, sxi2 = 0, sxi3 = 0, sxi2yi = 0, sxi4 = 0;
int count = 0;
@@ -332,8 +332,8 @@ public class MotionPauseDetector {
index += HISTORY_SIZE;
}
- float time = mHistoricTimes[index];
- float age = eventTime - time;
+ long time = mHistoricTimes[index];
+ long age = eventTime - time;
if (age > HORIZON_MS) {
break;
}
@@ -358,18 +358,23 @@ public class MotionPauseDetector {
if (count < 3) {
// Too few samples
- if (count == 2) {
- int endPos = pointPos - 1;
- if (endPos < 0) {
- endPos += HISTORY_SIZE;
- }
- float denominator = eventTime - mHistoricTimes[endPos];
- if (denominator != 0) {
- return (eventTime - mHistoricPos[endPos]) / denominator;
-
+ switch (count) {
+ case 2: {
+ int endPos = pointPos - 1;
+ if (endPos < 0) {
+ endPos += HISTORY_SIZE;
+ }
+ long denominator = eventTime - mHistoricTimes[endPos];
+ if (denominator != 0) {
+ return (mHistoricPos[pointPos] - mHistoricPos[endPos]) / denominator;
+ }
}
+ // fall through
+ case 1:
+ return 0f;
+ default:
+ return null;
}
- return null;
}
float Sxx = sxi2 - sxi * sxi / count;