summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/VelocityTracker.java37
-rw-r--r--core/jni/android_view_VelocityTracker.cpp5
2 files changed, 28 insertions, 14 deletions
diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java
index 4464d1918565..d31f82398cdf 100644
--- a/core/java/android/view/VelocityTracker.java
+++ b/core/java/android/view/VelocityTracker.java
@@ -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;
/**
diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp
index 05c9f6865061..03e9a6a9d139 100644
--- a/core/jni/android_view_VelocityTracker.cpp
+++ b/core/jni/android_view_VelocityTracker.cpp
@@ -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;
}