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

Commit 3c4b9d52 authored by Xin Li's avatar Xin Li Committed by Gerrit Code Review
Browse files

Merge "DO NOT MERGE - Merge RP1A.201005.006"

parents 41e7da24 05a4c9e1
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ public class MotionPauseDetector {
        private static final int HISTORY_SIZE = 20;

        // 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 int mHistoryCount = 0;
        private int mHistoryStart = 0;
@@ -292,7 +292,7 @@ public class MotionPauseDetector {
            mHistoryCount = mHistoryStart = 0;
        }

        private void addPositionAndTime(float eventTime, float eventPosition) {
        private void addPositionAndTime(long eventTime, float eventPosition) {
            mHistoricTimes[mHistoryStart] = eventTime;
            mHistoricPos[mHistoryStart] = eventPosition;
            mHistoryStart++;
@@ -322,7 +322,7 @@ public class MotionPauseDetector {
         * Based on solveUnweightedLeastSquaresDeg2 in VelocityTracker.cpp
         */
        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;
            int count = 0;
@@ -332,8 +332,8 @@ public class MotionPauseDetector {
                    index += HISTORY_SIZE;
                }

                float time = mHistoricTimes[index];
                float age = eventTime - time;
                long time = mHistoricTimes[index];
                long age = eventTime - time;
                if (age > HORIZON_MS) {
                    break;
                }
@@ -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];
                        long 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;