From 7013c869e6f78d03ad626b5d29315dda9ee84fb9 Mon Sep 17 00:00:00 2001 From: Harry Cutts Date: Thu, 15 Sep 2022 13:59:09 +0000 Subject: [PATCH] Add CLASSIFICATION_TWO_FINGER_SCROLL for touchpad scrolling This will be used to denote the single-finger touches that TouchInputMapper creates to simulate scrolling when the user makes two-finger swipes on the touchpad. Bug: 246758376 Test: check new value is sent to a test app when scrolling on a touchpad Change-Id: Id93cba764522e36d850f7013ab8a117f64716fac --- core/api/current.txt | 1 + core/java/android/view/MotionEvent.java | 16 ++++++++++++++-- native/android/input.cpp | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 4d25ad7d8b37f..482d4894a5200 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -49222,6 +49222,7 @@ package android.view { field public static final int CLASSIFICATION_AMBIGUOUS_GESTURE = 1; // 0x1 field public static final int CLASSIFICATION_DEEP_PRESS = 2; // 0x2 field public static final int CLASSIFICATION_NONE = 0; // 0x0 + field public static final int CLASSIFICATION_TWO_FINGER_SWIPE = 3; // 0x3 field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int EDGE_BOTTOM = 2; // 0x2 field public static final int EDGE_LEFT = 4; // 0x4 diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java index ea0012543ba92..5ec7962457744 100644 --- a/core/java/android/view/MotionEvent.java +++ b/core/java/android/view/MotionEvent.java @@ -1457,10 +1457,20 @@ public final class MotionEvent extends InputEvent implements Parcelable { */ public static final int CLASSIFICATION_DEEP_PRESS = 2; + /** + * Classification constant: touchpad scroll. + * + * The current event stream represents the user scrolling with two fingers on a touchpad. + * + * @see #getClassification + */ + public static final int CLASSIFICATION_TWO_FINGER_SWIPE = 3; + /** @hide */ @Retention(SOURCE) @IntDef(prefix = { "CLASSIFICATION" }, value = { - CLASSIFICATION_NONE, CLASSIFICATION_AMBIGUOUS_GESTURE, CLASSIFICATION_DEEP_PRESS}) + CLASSIFICATION_NONE, CLASSIFICATION_AMBIGUOUS_GESTURE, CLASSIFICATION_DEEP_PRESS, + CLASSIFICATION_TWO_FINGER_SWIPE}) public @interface Classification {}; /** @@ -3862,9 +3872,11 @@ public final class MotionEvent extends InputEvent implements Parcelable { return "AMBIGUOUS_GESTURE"; case CLASSIFICATION_DEEP_PRESS: return "DEEP_PRESS"; + case CLASSIFICATION_TWO_FINGER_SWIPE: + return "TWO_FINGER_SWIPE"; } - return "NONE"; + return "UNKNOWN"; } /** diff --git a/native/android/input.cpp b/native/android/input.cpp index a231d8f153e77..812db0f1c507f 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -295,6 +295,8 @@ int32_t AMotionEvent_getClassification(const AInputEvent* motion_event) { return AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE; case android::MotionClassification::DEEP_PRESS: return AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS; + case android::MotionClassification::TWO_FINGER_SWIPE: + return AMOTION_EVENT_CLASSIFICATION_TWO_FINGER_SWIPE; } }