mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Fixing wrong velocity state when there are too few samples
Bug: 160568387
Change-Id: I32b3b7ee1bff5595941fc0c0b37c9f5a28d1a1fa
(cherry picked from commit 48afb6b3b9)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user