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

Commit 0581f5b0 authored by Sunny Goyal's avatar Sunny Goyal Committed by Automerger Merge Worker
Browse files

Fixing wrong velocity state when there are too few samples am: f58a2b9c

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

Change-Id: Id9c756552c08d7690b99987dafadc13448a0c236
parents 33011356 f58a2b9c
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;