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/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index df7ba49..073c18b 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -229,11 +229,12 @@
dump += StringPrintf(INDENT4 "[%d]: id=%d, x=%d, y=%d, pressure=%d, "
"touchMajor=%d, touchMinor=%d, toolMajor=%d, toolMinor=%d, "
"orientation=%d, tiltX=%d, tiltY=%d, distance=%d, "
- "toolType=%d, isHovering=%s\n",
+ "toolType=%s, isHovering=%s\n",
i, pointer.id, pointer.x, pointer.y, pointer.pressure,
pointer.touchMajor, pointer.touchMinor, pointer.toolMajor,
pointer.toolMinor, pointer.orientation, pointer.tiltX, pointer.tiltY,
- pointer.distance, pointer.toolType, toString(pointer.isHovering));
+ pointer.distance, ftl::enum_string(pointer.toolType).c_str(),
+ toString(pointer.isHovering));
}
dump += StringPrintf(INDENT3 "Last Cooked Button State: 0x%08x\n",
@@ -248,7 +249,7 @@
"pressure=%0.3f, touchMajor=%0.3f, touchMinor=%0.3f, "
"toolMajor=%0.3f, toolMinor=%0.3f, "
"orientation=%0.3f, tilt=%0.3f, distance=%0.3f, "
- "toolType=%d, isHovering=%s\n",
+ "toolType=%s, isHovering=%s\n",
i, pointerProperties.id, pointerCoords.getX(), pointerCoords.getY(),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y),
@@ -260,7 +261,7 @@
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TILT),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_DISTANCE),
- pointerProperties.toolType,
+ ftl::enum_string(pointerProperties.toolType).c_str(),
toString(mLastCookedState.cookedPointerData.isHovering(i)));
}
@@ -1582,10 +1583,10 @@
mCurrentRawState.rawPointerData.pointerForId(id);
if (isStylusToolType(pointer.toolType)) {
mCurrentCookedState.stylusIdBits.markBit(id);
- } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER ||
- pointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+ } else if (pointer.toolType == ToolType::FINGER ||
+ pointer.toolType == ToolType::UNKNOWN) {
mCurrentCookedState.fingerIdBits.markBit(id);
- } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_MOUSE) {
+ } else if (pointer.toolType == ToolType::MOUSE) {
mCurrentCookedState.mouseIdBits.markBit(id);
}
}
@@ -1704,7 +1705,7 @@
PointerCoords& coords = currentPointerData.editPointerCoordsWithId(*mFusedStylusPointerId);
coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pressure);
- if (mExternalStylusState.toolType != AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+ if (mExternalStylusState.toolType != ToolType::UNKNOWN) {
PointerProperties& properties =
currentPointerData.editPointerPropertiesWithId(*mFusedStylusPointerId);
properties.toolType = mExternalStylusState.toolType;
@@ -2678,7 +2679,7 @@
PointerProperties pointerProperties;
pointerProperties.clear();
pointerProperties.id = 0;
- pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ pointerProperties.toolType = ToolType::FINGER;
PointerCoords pointerCoords;
pointerCoords.clear();
@@ -2887,7 +2888,7 @@
mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
@@ -2922,8 +2923,7 @@
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id =
mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType =
- AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
mPointerGesture.tapX);
@@ -3010,7 +3010,7 @@
mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
@@ -3040,9 +3040,10 @@
uint32_t index = mPointerGesture.currentGestureIdToIndex[id];
const PointerProperties& properties = mPointerGesture.currentGestureProperties[index];
const PointerCoords& coords = mPointerGesture.currentGestureCoords[index];
- ALOGD(" currentGesture[%d]: index=%d, toolType=%d, "
+ ALOGD(" currentGesture[%d]: index=%d, toolType=%s, "
"x=%0.3f, y=%0.3f, pressure=%0.3f",
- id, index, properties.toolType, coords.getAxisValue(AMOTION_EVENT_AXIS_X),
+ id, index, ftl::enum_string(properties.toolType).c_str(),
+ coords.getAxisValue(AMOTION_EVENT_AXIS_X),
coords.getAxisValue(AMOTION_EVENT_AXIS_Y),
coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
}
@@ -3051,9 +3052,10 @@
uint32_t index = mPointerGesture.lastGestureIdToIndex[id];
const PointerProperties& properties = mPointerGesture.lastGestureProperties[index];
const PointerCoords& coords = mPointerGesture.lastGestureCoords[index];
- ALOGD(" lastGesture[%d]: index=%d, toolType=%d, "
+ ALOGD(" lastGesture[%d]: index=%d, toolType=%s, "
"x=%0.3f, y=%0.3f, pressure=%0.3f",
- id, index, properties.toolType, coords.getAxisValue(AMOTION_EVENT_AXIS_X),
+ id, index, ftl::enum_string(properties.toolType).c_str(),
+ coords.getAxisValue(AMOTION_EVENT_AXIS_X),
coords.getAxisValue(AMOTION_EVENT_AXIS_Y),
coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE));
}
@@ -3342,7 +3344,7 @@
mPointerGesture.currentGestureIdToIndex[mPointerGesture.activeGestureId] = 0;
mPointerGesture.currentGestureProperties[0].clear();
mPointerGesture.currentGestureProperties[0].id = mPointerGesture.activeGestureId;
- mPointerGesture.currentGestureProperties[0].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[0].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[0].clear();
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X,
mPointerGesture.referenceGestureX);
@@ -3435,7 +3437,7 @@
mPointerGesture.currentGestureProperties[i].clear();
mPointerGesture.currentGestureProperties[i].id = gestureId;
- mPointerGesture.currentGestureProperties[i].toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
+ mPointerGesture.currentGestureProperties[i].toolType = ToolType::FINGER;
mPointerGesture.currentGestureCoords[i].clear();
mPointerGesture.currentGestureCoords[i].setAxisValue(AMOTION_EVENT_AXIS_X,
mPointerGesture.referenceGestureX +