GestureConverter: add classification to fling stops
This fixes fling stopping in Docs by causing the fling stop events to be
sent down its touch event pathway rather than its mouse event one (which
doesn't have the concept of cancellations).
In future we could consider adding a separate classification for fling
stops rather than using the one for the swipe motion itself, but for now
we think it makes semantic sense to have both with the same
classification since they're kind of parts of the same gesture.
Bug: 281106755
Test: with a Google Doc open, fling with two fingers on a touchpad, then
touch the pad again and check that the fling stops without moving
the insertion point
Flag: com.android.input.flags.enable_touchpad_fling_stop
Change-Id: Ia4fb358d510c1058eecee74ad862253d6bd2cd50
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
index 764bb56..39a88e5 100644
--- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
+++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp
@@ -420,8 +420,8 @@
std::list<NotifyArgs> out;
mDownTime = when;
+ mCurrentClassification = MotionClassification::TWO_FINGER_SWIPE;
out += exitHover(when, readTime, xCursorPosition, yCursorPosition);
- // TODO(b/281106755): add a MotionClassification value for fling stops.
out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN,
/*actionButton=*/0, /*buttonState=*/0,
/*pointerCount=*/1, &coords, xCursorPosition,
@@ -431,6 +431,7 @@
/*pointerCount=*/1, &coords, xCursorPosition,
yCursorPosition));
out += enterHover(when, readTime, xCursorPosition, yCursorPosition);
+ mCurrentClassification = MotionClassification::NONE;
return out;
} else {
// Use the tap down state of a fling gesture as an indicator that a contact
diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp
index 337b52b..6a009b2 100644
--- a/services/inputflinger/tests/GestureConverter_test.cpp
+++ b/services/inputflinger/tests/GestureConverter_test.cpp
@@ -1192,12 +1192,12 @@
VariantWith<NotifyMotionArgs>(
WithMotionAction(AMOTION_EVENT_ACTION_CANCEL)),
VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithMotionClassification(MotionClassification::NONE)))));
+ WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(POINTER_X, POINTER_Y),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(POINTER_X, POINTER_Y), WithToolType(ToolType::FINGER),
+ WithDisplayId(ADISPLAY_ID_DEFAULT),
+ WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE)))));
}
TEST_F(GestureConverterTest, Tap) {
@@ -2613,12 +2613,12 @@
VariantWith<NotifyMotionArgs>(
WithMotionAction(AMOTION_EVENT_ACTION_CANCEL)),
VariantWith<NotifyMotionArgs>(
- AllOf(WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER),
- WithMotionClassification(MotionClassification::NONE)))));
+ WithMotionAction(AMOTION_EVENT_ACTION_HOVER_ENTER))));
ASSERT_THAT(args,
- Each(VariantWith<NotifyMotionArgs>(AllOf(WithCoords(0, 0),
- WithToolType(ToolType::FINGER),
- WithDisplayId(ADISPLAY_ID_DEFAULT)))));
+ Each(VariantWith<NotifyMotionArgs>(
+ AllOf(WithCoords(0, 0), WithToolType(ToolType::FINGER),
+ WithDisplayId(ADISPLAY_ID_DEFAULT),
+ WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE)))));
}
TEST_F(GestureConverterTestWithChoreographer, Tap) {