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

Commit 8ab705d7 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Remove movement estimates from pointer location

When pointer location is enabled, a line starting from (0,0) is drawn in
both positive and negative directions. This line is used for "movement
estimates", or predicted future coordinates of pointer location using
extrapolation with polynomials.

It's unclear what it's used for, but it is annoying to see on screen
when pointer location is enabled. It also only shows up on flings
directed to the top left corner or to the bottom right corner. It does
not show up otherwise, so it's likely not working as intended anyways.

Fixes: 111195578
Test: enable pointer location, the flings in different directions to
ensure that the line originating from (0,0) is no longer present.
also try flinging with multiple fingers to ensure that no crashes are
observed and velocities are displayed for each finger.

Change-Id: I42b2cbd7deebb2cb3593172156c3d948c8d7ba4d
parent d4fa4586
Loading
Loading
Loading
Loading
+3 −30
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.internal.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Paint.FontMetricsInt;
import android.graphics.RectF;
import android.hardware.input.InputManager;
import android.hardware.input.InputManager.InputDeviceListener;
import android.os.SystemProperties;
@@ -29,12 +29,12 @@ import android.util.Slog;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowInsets;
import android.view.WindowManagerPolicyConstants.PointerEventListener;
import android.view.MotionEvent.PointerCoords;

import java.util.ArrayList;

@@ -105,10 +105,6 @@ public class PointerLocationView extends View implements InputDeviceListener,
        }
    }

    private final int ESTIMATE_PAST_POINTS = 4;
    private final int ESTIMATE_FUTURE_POINTS = 2;
    private final float ESTIMATE_INTERVAL = 0.02f;

    private final InputManager mIm;

    private final ViewConfiguration mVC;
@@ -336,37 +332,14 @@ public class PointerLocationView extends View implements InputDeviceListener,
            }

            if (drawn) {
                // Draw movement estimate curve.
                mPaint.setARGB(128, 128, 0, 128);
                float lx = ps.mEstimator.estimateX(-ESTIMATE_PAST_POINTS * ESTIMATE_INTERVAL);
                float ly = ps.mEstimator.estimateY(-ESTIMATE_PAST_POINTS * ESTIMATE_INTERVAL);
                for (int i = -ESTIMATE_PAST_POINTS + 1; i <= ESTIMATE_FUTURE_POINTS; i++) {
                    float x = ps.mEstimator.estimateX(i * ESTIMATE_INTERVAL);
                    float y = ps.mEstimator.estimateY(i * ESTIMATE_INTERVAL);
                    canvas.drawLine(lx, ly, x, y, mPaint);
                    lx = x;
                    ly = y;
                }

                // Draw velocity vector.
                mPaint.setARGB(255, 255, 64, 128);
                float xVel = ps.mXVelocity * (1000 / 60);
                float yVel = ps.mYVelocity * (1000 / 60);
                canvas.drawLine(lastX, lastY, lastX + xVel, lastY + yVel, mPaint);

                // Draw alternate estimate.
                // Draw velocity vector using an alternate VelocityTracker strategy.
                if (mAltVelocity != null) {
                    mPaint.setARGB(128, 0, 128, 128);
                    lx = ps.mAltEstimator.estimateX(-ESTIMATE_PAST_POINTS * ESTIMATE_INTERVAL);
                    ly = ps.mAltEstimator.estimateY(-ESTIMATE_PAST_POINTS * ESTIMATE_INTERVAL);
                    for (int i = -ESTIMATE_PAST_POINTS + 1; i <= ESTIMATE_FUTURE_POINTS; i++) {
                        float x = ps.mAltEstimator.estimateX(i * ESTIMATE_INTERVAL);
                        float y = ps.mAltEstimator.estimateY(i * ESTIMATE_INTERVAL);
                        canvas.drawLine(lx, ly, x, y, mPaint);
                        lx = x;
                        ly = y;
                    }

                    mPaint.setARGB(255, 64, 255, 128);
                    xVel = ps.mAltXVelocity * (1000 / 60);
                    yVel = ps.mAltYVelocity * (1000 / 60);