diff options
3 files changed, 26 insertions, 16 deletions
diff --git a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp index d636d4458f..7b5f8e58c3 100644 --- a/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp +++ b/services/inputflinger/reader/mapper/gestures/GestureConverter.cpp @@ -210,10 +210,12 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT coords.setAxisValue(AMOTION_EVENT_AXIS_Y, yCursorPosition); coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f); mDownTime = when; - out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, - /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, - mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, - yCursorPosition)); + NotifyMotionArgs args = + makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_DOWN, /* actionButton= */ 0, + mButtonState, /* pointerCount= */ 1, mFingerProps.data(), + mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); + args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; + out.push_back(args); } float deltaX = gesture.details.scroll.dx; float deltaY = gesture.details.scroll.dy; @@ -224,9 +226,12 @@ std::list<NotifyArgs> GestureConverter::handleScroll(nsecs_t when, nsecs_t readT // TODO(b/262876643): set AXIS_GESTURE_{X,Y}_OFFSET. coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, -gesture.details.scroll.dx); coords.setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, -gesture.details.scroll.dy); - out.push_back(makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0, - mButtonState, /* pointerCount= */ 1, mFingerProps.data(), - mFakeFingerCoords.data(), xCursorPosition, yCursorPosition)); + NotifyMotionArgs args = + makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_MOVE, /* actionButton= */ 0, + mButtonState, /* pointerCount= */ 1, mFingerProps.data(), + mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); + args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; + out.push_back(args); return out; } @@ -243,10 +248,11 @@ NotifyArgs GestureConverter::handleFling(nsecs_t when, nsecs_t readTime, const G mPointerController->getPosition(&xCursorPosition, &yCursorPosition); mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_X_DISTANCE, 0); mFakeFingerCoords[0].setAxisValue(AMOTION_EVENT_AXIS_GESTURE_SCROLL_Y_DISTANCE, 0); - NotifyArgs args = makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, - /* actionButton= */ 0, mButtonState, /* pointerCount= */ 1, - mFingerProps.data(), mFakeFingerCoords.data(), xCursorPosition, - yCursorPosition); + NotifyMotionArgs args = + makeMotionArgs(when, readTime, AMOTION_EVENT_ACTION_UP, /* actionButton= */ 0, + mButtonState, /* pointerCount= */ 1, mFingerProps.data(), + mFakeFingerCoords.data(), xCursorPosition, yCursorPosition); + args.flags |= AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE; mCurrentClassification = MotionClassification::NONE; return args; } diff --git a/services/inputflinger/tests/GestureConverter_test.cpp b/services/inputflinger/tests/GestureConverter_test.cpp index 9c624ba560..bbf7e8e5a8 100644 --- a/services/inputflinger/tests/GestureConverter_test.cpp +++ b/services/inputflinger/tests/GestureConverter_test.cpp @@ -252,14 +252,16 @@ TEST_F(GestureConverterTest, Scroll) { AllOf(WithMotionAction(AMOTION_EVENT_ACTION_DOWN), WithCoords(POINTER_X, POINTER_Y), WithGestureScrollDistance(0, 0, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), - WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime))); + WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), WithDownTime(downTime), + WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); args.pop_front(); ASSERT_THAT(std::get<NotifyMotionArgs>(args.front()), AllOf(WithMotionAction(AMOTION_EVENT_ACTION_MOVE), WithCoords(POINTER_X, POINTER_Y - 10), WithGestureScrollDistance(0, 10, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), - WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); + WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), + WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); Gesture continueGesture(kGestureScroll, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 0, -5); args = converter.handleGesture(ARBITRARY_TIME, READ_TIME, continueGesture); @@ -269,7 +271,8 @@ TEST_F(GestureConverterTest, Scroll) { WithCoords(POINTER_X, POINTER_Y - 15), WithGestureScrollDistance(0, 5, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), - WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); + WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), + WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); Gesture flingGesture(kGestureFling, ARBITRARY_GESTURE_TIME, ARBITRARY_GESTURE_TIME, 1, 1, GESTURES_FLING_START); @@ -280,7 +283,8 @@ TEST_F(GestureConverterTest, Scroll) { WithCoords(POINTER_X, POINTER_Y - 15), WithGestureScrollDistance(0, 0, EPSILON), WithMotionClassification(MotionClassification::TWO_FINGER_SWIPE), - WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER))); + WithToolType(AMOTION_EVENT_TOOL_TYPE_FINGER), + WithFlags(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE))); } TEST_F(GestureConverterTest, Scroll_Rotated) { diff --git a/services/inputflinger/tests/TestInputListenerMatchers.h b/services/inputflinger/tests/TestInputListenerMatchers.h index edd14f82e7..09f7ae8b1c 100644 --- a/services/inputflinger/tests/TestInputListenerMatchers.h +++ b/services/inputflinger/tests/TestInputListenerMatchers.h @@ -145,7 +145,7 @@ MATCHER_P(WithToolType, toolType, "InputEvent with specified tool type") { MATCHER_P(WithFlags, flags, "InputEvent with specified flags") { *result_listener << "expected flags " << flags << ", but got " << arg.flags; - return arg.flags == flags; + return arg.flags == static_cast<int32_t>(flags); } MATCHER_P(WithMotionClassification, classification, |