Store mHistoricTimes as longs intead of floats am: 31ef24c934

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/12375534

Change-Id: Ie82539f445850e62edc424fe088c41cc28890d6b
This commit is contained in:
Tony Wickham authored and Automerger Merge Worker committed 2020-08-14 10:46:38 +00:00
commit 94dbcefe2a
1 file changed
+6 -6
@@ -276,7 +276,7 @@ public class MotionPauseDetector {
private static final int HISTORY_SIZE = 20; private static final int HISTORY_SIZE = 20;
// Position history are stored in a circular array // 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 final float[] mHistoricPos = new float[HISTORY_SIZE];
private int mHistoryCount = 0; private int mHistoryCount = 0;
private int mHistoryStart = 0; private int mHistoryStart = 0;
@@ -292,7 +292,7 @@ public class MotionPauseDetector {
mHistoryCount = mHistoryStart = 0; mHistoryCount = mHistoryStart = 0;
} }
private void addPositionAndTime(float eventTime, float eventPosition) { private void addPositionAndTime(long eventTime, float eventPosition) {
mHistoricTimes[mHistoryStart] = eventTime; mHistoricTimes[mHistoryStart] = eventTime;
mHistoricPos[mHistoryStart] = eventPosition; mHistoricPos[mHistoryStart] = eventPosition;
mHistoryStart++; mHistoryStart++;
@@ -322,7 +322,7 @@ public class MotionPauseDetector {
* Based on solveUnweightedLeastSquaresDeg2 in VelocityTracker.cpp * Based on solveUnweightedLeastSquaresDeg2 in VelocityTracker.cpp
*/ */
private Float solveUnweightedLeastSquaresDeg2(final int pointPos) { 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; float sxi = 0, sxiyi = 0, syi = 0, sxi2 = 0, sxi3 = 0, sxi2yi = 0, sxi4 = 0;
int count = 0; int count = 0;
@@ -332,8 +332,8 @@ public class MotionPauseDetector {
index += HISTORY_SIZE; index += HISTORY_SIZE;
} }
float time = mHistoricTimes[index]; long time = mHistoricTimes[index];
float age = eventTime - time; long age = eventTime - time;
if (age > HORIZON_MS) { if (age > HORIZON_MS) {
break; break;
} }
@@ -364,7 +364,7 @@ public class MotionPauseDetector {
if (endPos < 0) { if (endPos < 0) {
endPos += HISTORY_SIZE; endPos += HISTORY_SIZE;
} }
float denominator = eventTime - mHistoricTimes[endPos]; long denominator = eventTime - mHistoricTimes[endPos];
if (denominator != 0) { if (denominator != 0) {
return (mHistoricPos[pointPos] - mHistoricPos[endPos]) / denominator; return (mHistoricPos[pointPos] - mHistoricPos[endPos]) / denominator;
} }