Separate default pointer for mouse and stylus (frameworks/base part)

PointerIcon.TYPE_NOT_SPECIFIED will be used for requesting default
pointer.

For the type, MouseCursorController will decide whether to show mouse or
stylus icon, based on the active source.

Need complement: the resource for default stylus icon should be added.

Test: Manual Test(hover pointer on handwriting area)
Bug: b/215436642
Change-Id: I6a337cb69bea57427f676e561900802270d206ae
diff --git a/libs/input/tests/PointerController_test.cpp b/libs/input/tests/PointerController_test.cpp
index a6a4115..c820d00 100644
--- a/libs/input/tests/PointerController_test.cpp
+++ b/libs/input/tests/PointerController_test.cpp
@@ -35,6 +35,7 @@
     CURSOR_TYPE_ANCHOR,
     CURSOR_TYPE_ADDITIONAL,
     CURSOR_TYPE_ADDITIONAL_ANIM,
+    CURSOR_TYPE_STYLUS,
     CURSOR_TYPE_CUSTOM = -1,
 };
 
@@ -57,6 +58,7 @@
             std::map<PointerIconStyle, PointerAnimation>* outAnimationResources,
             int32_t displayId) override;
     virtual PointerIconStyle getDefaultPointerIconId() override;
+    virtual PointerIconStyle getDefaultStylusIconId() override;
     virtual PointerIconStyle getCustomPointerIconId() override;
     virtual void onPointerDisplayIdChanged(int32_t displayId, float xPos, float yPos) override;
 
@@ -105,6 +107,11 @@
     (*outResources)[static_cast<PointerIconStyle>(cursorType)] = icon;
     (*outAnimationResources)[static_cast<PointerIconStyle>(cursorType)] = anim;
 
+    // CURSOR_TYPE_STYLUS doesn't have animation resource.
+    cursorType = CURSOR_TYPE_STYLUS;
+    loadPointerIconForType(&icon, cursorType);
+    (*outResources)[static_cast<PointerIconStyle>(cursorType)] = icon;
+
     additionalMouseResourcesLoaded = true;
 }
 
@@ -112,6 +119,10 @@
     return static_cast<PointerIconStyle>(CURSOR_TYPE_DEFAULT);
 }
 
+PointerIconStyle MockPointerControllerPolicyInterface::getDefaultStylusIconId() {
+    return static_cast<PointerIconStyle>(CURSOR_TYPE_STYLUS);
+}
+
 PointerIconStyle MockPointerControllerPolicyInterface::getCustomPointerIconId() {
     return static_cast<PointerIconStyle>(CURSOR_TYPE_CUSTOM);
 }
@@ -214,6 +225,21 @@
     mPointerController->reloadPointerResources();
 }
 
+TEST_F(PointerControllerTest, useStylusTypeForStylusHover) {
+    ensureDisplayViewportIsSet();
+    mPointerController->setPresentation(PointerController::Presentation::STYLUS_HOVER);
+    mPointerController->unfade(PointerController::Transition::IMMEDIATE);
+    std::pair<float, float> hotspot = getHotSpotCoordinatesForType(CURSOR_TYPE_STYLUS);
+    EXPECT_CALL(*mPointerSprite, setVisible(true));
+    EXPECT_CALL(*mPointerSprite, setAlpha(1.0f));
+    EXPECT_CALL(*mPointerSprite,
+                setIcon(AllOf(Field(&SpriteIcon::style,
+                                    static_cast<PointerIconStyle>(CURSOR_TYPE_STYLUS)),
+                              Field(&SpriteIcon::hotSpotX, hotspot.first),
+                              Field(&SpriteIcon::hotSpotY, hotspot.second))));
+    mPointerController->reloadPointerResources();
+}
+
 TEST_F(PointerControllerTest, updatePointerIcon) {
     ensureDisplayViewportIsSet();
     mPointerController->setPresentation(PointerController::Presentation::POINTER);