Input: Add isStylusToolType() utility function

Using this utility function will ensure we don't forget to check for
both TOOL_TYPE_STYLUS and TOOL_TYPE_ERASER when we are looking to
identify a stylus.

This will cause a behavior change in UnwantedInteractionBlocker, where
TOOL_TYPE_ERASER was not previously considered a stylus tool.

Bug: None
Test: atest inputflinger_tests
Change-Id: I3dae9b5037d7ac08a5672c6e4d6e3b62ee2bd352
diff --git a/services/inputflinger/UnwantedInteractionBlocker.cpp b/services/inputflinger/UnwantedInteractionBlocker.cpp
index ec41025..c170b81 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.cpp
+++ b/services/inputflinger/UnwantedInteractionBlocker.cpp
@@ -99,14 +99,17 @@
 }
 
 static int getLinuxToolCode(int toolType) {
-    if (toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS) {
-        return BTN_TOOL_PEN;
+    switch (toolType) {
+        case AMOTION_EVENT_TOOL_TYPE_STYLUS:
+            return BTN_TOOL_PEN;
+        case AMOTION_EVENT_TOOL_TYPE_ERASER:
+            return BTN_TOOL_RUBBER;
+        case AMOTION_EVENT_TOOL_TYPE_FINGER:
+            return BTN_TOOL_FINGER;
+        default:
+            ALOGW("Got tool type %" PRId32 ", converting to BTN_TOOL_FINGER", toolType);
+            return BTN_TOOL_FINGER;
     }
-    if (toolType == AMOTION_EVENT_TOOL_TYPE_FINGER) {
-        return BTN_TOOL_FINGER;
-    }
-    ALOGW("Got tool type %" PRId32 ", converting to BTN_TOOL_FINGER", toolType);
-    return BTN_TOOL_FINGER;
 }
 
 static int32_t getActionUpForPointerId(const NotifyMotionArgs& args, int32_t pointerId) {
@@ -195,7 +198,7 @@
 static std::optional<NotifyMotionArgs> removeStylusPointerIds(const NotifyMotionArgs& args) {
     std::set<int32_t> stylusPointerIds;
     for (uint32_t i = 0; i < args.pointerCount; i++) {
-        if (args.pointerProperties[i].toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS) {
+        if (isStylusToolType(args.pointerProperties[i].toolType)) {
             stylusPointerIds.insert(args.pointerProperties[i].id);
         }
     }