Convert tool type to enum class
For better type safety, use enum class when sending tool type.
Bug: 198472780
Test: atest libinput_tests inputflinger_tests
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:09a8fe42ba1d218c2f445e4fd5bc387e260ae067)
Merged-In: I371f08087b9513b6f75966c124de77bc12f8324e
Change-Id: I371f08087b9513b6f75966c124de77bc12f8324e
diff --git a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
index 3f749b1..2a9ace0 100644
--- a/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
+++ b/services/inputflinger/tests/UnwantedInteractionBlocker_test.cpp
@@ -79,7 +79,7 @@
for (size_t i = 0; i < pointerCount; i++) {
pointerProperties[i].clear();
pointerProperties[i].id = i;
- pointerProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties[i].toolType = ToolType::FINGER;
pointerCoords[i].clear();
pointerCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X, points[i].x);
@@ -507,7 +507,7 @@
TEST_F(UnwantedInteractionBlockerTest, NoCrashWhenStylusSourceWithFingerToolIsReceived) {
mBlocker->notifyInputDevicesChanged({generateTestDeviceInfo()});
NotifyMotionArgs args = generateMotionArgs(/*downTime=*/0, /*eventTime=*/1, DOWN, {{1, 2, 3}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ args.pointerProperties[0].toolType = ToolType::FINGER;
args.source = AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
}
@@ -548,15 +548,15 @@
// Now touch down stylus
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/3, DOWN, {{10, 20, 30}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/4, MOVE, {{40, 50, 60}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
args = generateMotionArgs(/*downTime=*/3, /*eventTime=*/5, UP, {{40, 50, 60}});
- args.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args.pointerProperties[0].toolType = ToolType::STYLUS;
args.source |= AINPUT_SOURCE_STYLUS;
mBlocker->notifyMotion(&args);
}
@@ -617,14 +617,14 @@
info.addSource(AINPUT_SOURCE_STYLUS);
mBlocker->notifyInputDevicesChanged({info});
NotifyMotionArgs args1 = generateMotionArgs(/*downTime=*/0, /*eventTime=*/0, DOWN, {{1, 2, 3}});
- args1.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args1.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args1);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(DOWN));
// Move the stylus, setting large TOUCH_MAJOR/TOUCH_MINOR dimensions
NotifyMotionArgs args2 =
generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, MOVE, {{4, 5, 200}});
- args2.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args2.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args2);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
@@ -632,7 +632,7 @@
// it's a palm.
NotifyMotionArgs args3 =
generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, UP, {{4, 5, 200}});
- args3.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args3.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args3);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP));
}
@@ -655,21 +655,21 @@
// Stylus pointer down
NotifyMotionArgs args2 = generateMotionArgs(/*downTime=*/0, RESAMPLE_PERIOD, POINTER_1_DOWN,
{{1, 2, 3}, {10, 20, 30}});
- args2.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args2.pointerProperties[1].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args2);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(POINTER_1_DOWN));
// Large touch oval on the next finger move
NotifyMotionArgs args3 = generateMotionArgs(/*downTime=*/0, 2 * RESAMPLE_PERIOD, MOVE,
{{1, 2, 300}, {11, 21, 30}});
- args3.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args3.pointerProperties[1].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args3);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
// Lift up the finger pointer. It should be canceled due to the heuristic filter.
NotifyMotionArgs args4 = generateMotionArgs(/*downTime=*/0, 3 * RESAMPLE_PERIOD, POINTER_0_UP,
{{1, 2, 300}, {11, 21, 30}});
- args4.pointerProperties[1].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args4.pointerProperties[1].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args4);
mTestListener.assertNotifyMotionWasCalled(
AllOf(WithMotionAction(POINTER_0_UP), WithFlags(FLAG_CANCELED)));
@@ -677,7 +677,7 @@
NotifyMotionArgs args5 =
generateMotionArgs(/*downTime=*/0, 4 * RESAMPLE_PERIOD, MOVE, {{12, 22, 30}});
args5.pointerProperties[0].id = args4.pointerProperties[1].id;
- args5.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args5.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args5);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(MOVE));
@@ -685,7 +685,7 @@
NotifyMotionArgs args6 =
generateMotionArgs(/*downTime=*/0, 5 * RESAMPLE_PERIOD, UP, {{4, 5, 200}});
args6.pointerProperties[0].id = args4.pointerProperties[1].id;
- args6.pointerProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+ args6.pointerProperties[0].toolType = ToolType::STYLUS;
mBlocker->notifyMotion(&args6);
mTestListener.assertNotifyMotionWasCalled(WithMotionAction(UP));
}