Merge "Fixing wrong velocity state when there are too few samples" into ub-launcher3-rvc-qpr-dev am: 073673e173

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

Change-Id: I3911c0987c4e5bff00b92d1bb3b6ca6538d6a843
This commit is contained in:
TreeHugger Robot
2020-07-31 18:31:06 +00:00
committed by Automerger Merge Worker

View File

@@ -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;
}
float 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;