Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 073673e1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 553d4dfe 48afb6b3
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -358,19 +358,24 @@ public class MotionPauseDetector {

            if (count < 3) {
                // Too few samples
                if (count == 2) {
                switch (count) {
                    case 2: {
                        int endPos = pointPos - 1;
                        if (endPos < 0) {
                            endPos += HISTORY_SIZE;
                        }
                        float denominator = eventTime - mHistoricTimes[endPos];
                        if (denominator != 0) {
                        return (eventTime - mHistoricPos[endPos]) / denominator;

                            return (mHistoricPos[pointPos] - mHistoricPos[endPos]) / denominator;
                        }
                    }
                    // fall through
                    case 1:
                        return 0f;
                    default:
                        return null;
                }
            }

            float Sxx = sxi2 - sxi * sxi / count;
            float Sxy = sxiyi - sxi * syi / count;