Loading services/inputflinger/PointerChoreographer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -368,7 +368,8 @@ void PointerChoreographer::processTouchscreenAndStylusEventLocked(const NotifyMo const uint8_t actionIndex = MotionEvent::getActionIndex(args.action); std::array<uint32_t, MAX_POINTER_ID + 1> idToIndex; BitSet32 idBits; if (maskedAction != AMOTION_EVENT_ACTION_UP && maskedAction != AMOTION_EVENT_ACTION_CANCEL) { if (maskedAction != AMOTION_EVENT_ACTION_UP && maskedAction != AMOTION_EVENT_ACTION_CANCEL && maskedAction != AMOTION_EVENT_ACTION_HOVER_EXIT) { for (size_t i = 0; i < args.getPointerCount(); i++) { if (maskedAction == AMOTION_EVENT_ACTION_POINTER_UP && actionIndex == i) { continue; Loading services/inputflinger/tests/PointerChoreographer_test.cpp +73 −2 Original line number Diff line number Diff line Loading @@ -830,15 +830,20 @@ TEST_F(PointerChoreographerTest, TouchSetsSpots) { pc->assertSpotCount(DISPLAY_ID, 0); } /** * In this test, we simulate the complete event of the stylus approaching and clicking on the * screen, and then leaving the screen. We should ensure that spots are displayed correctly. */ TEST_F(PointerChoreographerTest, TouchSetsSpotsForStylusEvent) { mChoreographer.setShowTouchesEnabled(true); mChoreographer.setStylusPointerIconEnabled(false); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS, DISPLAY_ID)}}); // Emit down event with stylus properties. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, // First, the stylus begin to approach the screen. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) Loading @@ -846,6 +851,72 @@ TEST_F(PointerChoreographerTest, TouchSetsSpotsForStylusEvent) { .build()); auto pc = assertPointerControllerCreated(ControllerType::TOUCH); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_EXIT, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 0); // Now, use stylus touch the screen. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 0); // Then, the stylus start leave from the screen. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_EXIT, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 0); } TEST_F(PointerChoreographerTest, TouchSetsSpotsForTwoDisplays) { Loading Loading
services/inputflinger/PointerChoreographer.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -368,7 +368,8 @@ void PointerChoreographer::processTouchscreenAndStylusEventLocked(const NotifyMo const uint8_t actionIndex = MotionEvent::getActionIndex(args.action); std::array<uint32_t, MAX_POINTER_ID + 1> idToIndex; BitSet32 idBits; if (maskedAction != AMOTION_EVENT_ACTION_UP && maskedAction != AMOTION_EVENT_ACTION_CANCEL) { if (maskedAction != AMOTION_EVENT_ACTION_UP && maskedAction != AMOTION_EVENT_ACTION_CANCEL && maskedAction != AMOTION_EVENT_ACTION_HOVER_EXIT) { for (size_t i = 0; i < args.getPointerCount(); i++) { if (maskedAction == AMOTION_EVENT_ACTION_POINTER_UP && actionIndex == i) { continue; Loading
services/inputflinger/tests/PointerChoreographer_test.cpp +73 −2 Original line number Diff line number Diff line Loading @@ -830,15 +830,20 @@ TEST_F(PointerChoreographerTest, TouchSetsSpots) { pc->assertSpotCount(DISPLAY_ID, 0); } /** * In this test, we simulate the complete event of the stylus approaching and clicking on the * screen, and then leaving the screen. We should ensure that spots are displayed correctly. */ TEST_F(PointerChoreographerTest, TouchSetsSpotsForStylusEvent) { mChoreographer.setShowTouchesEnabled(true); mChoreographer.setStylusPointerIconEnabled(false); mChoreographer.notifyInputDevicesChanged( {/*id=*/0, {generateTestDeviceInfo(DEVICE_ID, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS, DISPLAY_ID)}}); // Emit down event with stylus properties. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, // First, the stylus begin to approach the screen. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) Loading @@ -846,6 +851,72 @@ TEST_F(PointerChoreographerTest, TouchSetsSpotsForStylusEvent) { .build()); auto pc = assertPointerControllerCreated(ControllerType::TOUCH); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_EXIT, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 0); // Now, use stylus touch the screen. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_DOWN, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_MOVE, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_UP, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 0); // Then, the stylus start leave from the screen. mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_ENTER, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_MOVE, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 1); mChoreographer.notifyMotion(MotionArgsBuilder(AMOTION_EVENT_ACTION_HOVER_EXIT, AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_STYLUS) .pointer(STYLUS_POINTER) .deviceId(DEVICE_ID) .displayId(DISPLAY_ID) .build()); pc->assertSpotCount(DISPLAY_ID, 0); } TEST_F(PointerChoreographerTest, TouchSetsSpotsForTwoDisplays) { Loading