diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java index 00170cbe53d5b..85aea85907b5e 100644 --- a/core/java/android/view/VelocityTracker.java +++ b/core/java/android/view/VelocityTracker.java @@ -19,7 +19,6 @@ package android.view; import android.annotation.IntDef; import android.compat.annotation.UnsupportedAppUsage; import android.hardware.input.InputManager; -import android.os.Build; import android.util.ArrayMap; import android.util.Pools.SynchronizedPool; @@ -190,8 +189,6 @@ public final class VelocityTracker { private static native void nativeAddMovement(long ptr, MotionEvent event); private static native void nativeComputeCurrentVelocity(long ptr, int units, float maxVelocity); private static native float nativeGetVelocity(long ptr, int axis, int id); - private static native boolean nativeGetEstimator( - long ptr, int axis, int id, Estimator outEstimator); private static native boolean nativeIsAxisSupported(int axis); static { @@ -436,7 +433,7 @@ public final class VelocityTracker { * method: *
Before accessing velocities of an axis using this method, check that your
@@ -467,89 +464,4 @@ public final class VelocityTracker {
public float getAxisVelocity(@VelocityTrackableMotionEventAxis int axis) {
return nativeGetVelocity(mPtr, axis, ACTIVE_POINTER_ID);
}
-
- /**
- * Get an estimator for the movements of a pointer using past movements of the
- * pointer to predict future movements.
- *
- * It is not necessary to call {@link #computeCurrentVelocity(int)} before calling
- * this method.
- *
- * @param axis Which axis's velocity to return.
- * Should be one of the axes defined in {@link MotionEvent}.
- * @param id Which pointer's velocity to return.
- * @param outEstimator The estimator to populate.
- * @return True if an estimator was obtained, false if there is no information
- * available about the pointer.
- *
- * @hide For internal use only. Not a final API.
- */
- public boolean getEstimator(int axis, int id, Estimator outEstimator) {
- if (outEstimator == null) {
- throw new IllegalArgumentException("outEstimator must not be null");
- }
- return nativeGetEstimator(mPtr, axis, id, outEstimator);
- }
-
- /**
- * An estimator for the movements of a pointer based on a polynomial model.
- *
- * The last recorded position of the pointer is at time zero seconds.
- * Past estimated positions are at negative times and future estimated positions
- * are at positive times.
- *
- * First coefficient is position (in units), second is velocity (in units per second),
- * third is acceleration (in units per second squared).
- *
- * @hide For internal use only. Not a final API.
- */
- public static final class Estimator {
- // Must match VelocityTracker::Estimator::MAX_DEGREE
- private static final int MAX_DEGREE = 4;
-
- /**
- * Polynomial coefficients describing motion.
- */
- public final float[] coeff = new float[MAX_DEGREE + 1];
-
- /**
- * Polynomial degree, or zero if only position information is available.
- */
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- public int degree;
-
- /**
- * Confidence (coefficient of determination), between 0 (no fit) and 1 (perfect fit).
- */
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- public float confidence;
-
- /**
- * Gets an estimate of the position of the pointer at the specified time point.
- * @param time The time point in seconds, 0 is the last recorded time.
- * @return The estimated axis value.
- */
- public float estimate(float time) {
- return estimate(time, coeff);
- }
-
- /**
- * Gets the coefficient with the specified index.
- * @param index The index of the coefficient to return.
- * @return The coefficient, or 0 if the index is greater than the degree.
- */
- public float getCoeff(int index) {
- return index <= degree ? coeff[index] : 0;
- }
-
- private float estimate(float time, float[] c) {
- float a = 0;
- float scale = 1;
- for (int i = 0; i <= degree; i++) {
- a += c[i] * scale;
- scale *= time;
- }
- return a;
- }
- }
}
diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java
index c08f26492289b..f55d15de1d514 100644
--- a/core/java/com/android/internal/widget/PointerLocationView.java
+++ b/core/java/com/android/internal/widget/PointerLocationView.java
@@ -92,12 +92,6 @@ public class PointerLocationView extends View implements InputDeviceListener,
private float mBoundingRight;
private float mBoundingBottom;
- // Position estimator.
- private VelocityTracker.Estimator mEstimatorX = new VelocityTracker.Estimator();
- private VelocityTracker.Estimator mAltEstimatorX = new VelocityTracker.Estimator();
- private VelocityTracker.Estimator mEstimatorY = new VelocityTracker.Estimator();
- private VelocityTracker.Estimator mAltEstimatorY = new VelocityTracker.Estimator();
-
@UnsupportedAppUsage
public PointerState() {
}
@@ -669,13 +663,9 @@ public class PointerLocationView extends View implements InputDeviceListener,
ps.addTrace(coords.x, coords.y, true);
ps.mXVelocity = mVelocity.getXVelocity(id);
ps.mYVelocity = mVelocity.getYVelocity(id);
- mVelocity.getEstimator(MotionEvent.AXIS_X, id, ps.mEstimatorX);
- mVelocity.getEstimator(MotionEvent.AXIS_Y, id, ps.mEstimatorY);
if (mAltVelocity != null) {
ps.mAltXVelocity = mAltVelocity.getXVelocity(id);
ps.mAltYVelocity = mAltVelocity.getYVelocity(id);
- mAltVelocity.getEstimator(MotionEvent.AXIS_X, id, ps.mAltEstimatorX);
- mAltVelocity.getEstimator(MotionEvent.AXIS_Y, id, ps.mAltEstimatorY);
}
ps.mToolType = event.getToolType(i);
diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp
index 343e9d8b41ca1..05c9f68650618 100644
--- a/core/jni/android_view_VelocityTracker.cpp
+++ b/core/jni/android_view_VelocityTracker.cpp
@@ -31,13 +31,6 @@ namespace android {
// Special constant to request the velocity of the active pointer.
static const int ACTIVE_POINTER_ID = -1;
-static struct {
- jfieldID coeff;
- jfieldID degree;
- jfieldID confidence;
-} gEstimatorClassInfo;
-
-
// --- VelocityTrackerState ---
class VelocityTrackerState {
@@ -50,7 +43,6 @@ public:
// a subset of the supported axes.
void computeCurrentVelocity(int32_t units, float maxVelocity);
float getVelocity(int32_t axis, int32_t id);
- bool getEstimator(int32_t axis, int32_t id, VelocityTracker::Estimator* outEstimator);
private:
VelocityTracker mVelocityTracker;
@@ -80,11 +72,6 @@ float VelocityTrackerState::getVelocity(int32_t axis, int32_t id) {
return mComputedVelocity.getVelocity(axis, id).value_or(0);
}
-bool VelocityTrackerState::getEstimator(int32_t axis, int32_t id,
- VelocityTracker::Estimator* outEstimator) {
- return mVelocityTracker.getEstimator(axis, id, outEstimator);
-}
-
// Return a strategy enum from integer value.
inline static VelocityTracker::Strategy getStrategyFromInt(const int32_t strategy) {
if (strategy < static_cast