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

Commit 5afd70c5 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Use VelocityTrackerStrategy values from aidl

These values are now defined in aidl so that Java is in sync with
native. Update the Java side to use the values from
IInputConstants.aidl.

Bug: 295290374
Test: none
Change-Id: Ifb1d7cfaba5e8a5867e3b307f1e88005f772e4eb
parent e4cea5d6
Loading
Loading
Loading
Loading
+25 −12
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import android.annotation.IntDef;
import android.compat.annotation.UnsupportedAppUsage;
import android.hardware.input.InputManagerGlobal;
import android.os.IInputConstants;
import android.util.ArrayMap;
import android.util.Pools.SynchronizedPool;

@@ -53,11 +54,13 @@ public final class VelocityTracker {
    public @interface VelocityTrackableMotionEventAxis {}

    /**
     * Velocity Tracker Strategy: Invalid.
     * Use the default Velocity Tracker Strategy. Different axes may use different default
     * strategies.
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_DEFAULT = -1;
    public static final int VELOCITY_TRACKER_STRATEGY_DEFAULT =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_DEFAULT;

    /**
     * Velocity Tracker Strategy: Impulse.
@@ -66,7 +69,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_IMPULSE = 0;
    public static final int VELOCITY_TRACKER_STRATEGY_IMPULSE =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_IMPULSE;

    /**
     * Velocity Tracker Strategy: LSQ1.
@@ -77,7 +81,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_LSQ1 = 1;
    public static final int VELOCITY_TRACKER_STRATEGY_LSQ1 =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_LSQ1;

    /**
     * Velocity Tracker Strategy: LSQ2.
@@ -88,7 +93,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_LSQ2 = 2;
    public static final int VELOCITY_TRACKER_STRATEGY_LSQ2 =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_LSQ2;

    /**
     * Velocity Tracker Strategy: LSQ3.
@@ -98,7 +104,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_LSQ3 = 3;
    public static final int VELOCITY_TRACKER_STRATEGY_LSQ3 =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_LSQ3;

    /**
     * Velocity Tracker Strategy: WLSQ2_DELTA.
@@ -106,7 +113,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_WLSQ2_DELTA = 4;
    public static final int VELOCITY_TRACKER_STRATEGY_WLSQ2_DELTA =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_WLSQ2_DELTA;

    /**
     * Velocity Tracker Strategy: WLSQ2_CENTRAL.
@@ -114,7 +122,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_WLSQ2_CENTRAL = 5;
    public static final int VELOCITY_TRACKER_STRATEGY_WLSQ2_CENTRAL =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_WLSQ2_CENTRAL;

    /**
     * Velocity Tracker Strategy: WLSQ2_RECENT.
@@ -122,7 +131,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_WLSQ2_RECENT = 6;
    public static final int VELOCITY_TRACKER_STRATEGY_WLSQ2_RECENT =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_WLSQ2_RECENT;

    /**
     * Velocity Tracker Strategy: INT1.
@@ -134,7 +144,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_INT1 = 7;
    public static final int VELOCITY_TRACKER_STRATEGY_INT1 =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_INT1;

    /**
     * Velocity Tracker Strategy: INT2.
@@ -144,7 +155,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_INT2 = 8;
    public static final int VELOCITY_TRACKER_STRATEGY_INT2 =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_INT2;

    /**
     * Velocity Tracker Strategy: Legacy.
@@ -155,7 +167,8 @@ public final class VelocityTracker {
     *
     * @hide
     */
    public static final int VELOCITY_TRACKER_STRATEGY_LEGACY = 9;
    public static final int VELOCITY_TRACKER_STRATEGY_LEGACY =
            IInputConstants.VELOCITY_TRACKER_STRATEGY_LEGACY;


    /**
+3 −2
Original line number Diff line number Diff line
@@ -16,13 +16,14 @@

#define LOG_TAG "VelocityTracker-JNI"

#include <android-base/logging.h>
#include <android_runtime/AndroidRuntime.h>
#include <cutils/properties.h>
#include <input/Input.h>
#include <input/VelocityTracker.h>
#include <nativehelper/JNIHelp.h>
#include <nativehelper/ScopedUtfChars.h>
#include <utils/Log.h>

#include "android_view_MotionEvent.h"
#include "core_jni_helpers.h"

@@ -102,7 +103,7 @@ static void android_view_VelocityTracker_nativeAddMovement(JNIEnv* env, jclass c
        jobject eventObj) {
    const MotionEvent* event = android_view_MotionEvent_getNativePtr(env, eventObj);
    if (!event) {
        ALOGW("nativeAddMovement failed because MotionEvent was finalized.");
        LOG(WARNING) << "nativeAddMovement failed because MotionEvent was finalized.";
        return;
    }