Loading services/inputflinger/tests/InputReader_test.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -1829,6 +1829,38 @@ TEST_P(TouchIntegrationTest, InputEvent_ProcessPalm) { ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action); } /** * Some drivers historically have reported axis values outside of the range specified in the * evdev axis info. Ensure we don't crash when this happens. For example, a driver may report a * pressure value greater than the reported maximum, since it unclear what specific meaning the * maximum value for pressure has (beyond the maximum value that can be produced by a sensor), * and no units for pressure (resolution) is specified by the evdev documentation. */ TEST_P(TouchIntegrationTest, AcceptsAxisValuesOutsideReportedRange) { const Point centerPoint = mDevice->getCenterPoint(); // Down with pressure outside the reported range mDevice->sendSlot(FIRST_SLOT); mDevice->sendTrackingId(FIRST_TRACKING_ID); mDevice->sendDown(centerPoint); mDevice->sendPressure(UinputTouchScreen::RAW_PRESSURE_MAX + 2); mDevice->sendSync(); ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_DOWN))); // Move to a point outside the reported range mDevice->sendMove(Point(DISPLAY_WIDTH, DISPLAY_HEIGHT) + Point(1, 1)); mDevice->sendSync(); ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_MOVE))); // Up mDevice->sendUp(); mDevice->sendSync(); ASSERT_NO_FATAL_FAILURE( mTestListener->assertNotifyMotionWasCalled(WithMotionAction(AMOTION_EVENT_ACTION_UP))); } TEST_P(TouchIntegrationTest, NotifiesPolicyWhenStylusGestureStarted) { const Point centerPoint = mDevice->getCenterPoint(); Loading services/inputflinger/tests/UinputDevice.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,7 @@ void UinputTouchScreen::configureDevice(int fd, uinput_user_dev* device) { ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y); ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID); ioctl(fd, UI_SET_ABSBIT, ABS_MT_TOOL_TYPE); ioctl(fd, UI_SET_ABSBIT, ABS_MT_PRESSURE); ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT); if (!mPhysicalPort.empty()) { ioctl(fd, UI_SET_PHYS, mPhysicalPort.c_str()); Loading @@ -194,6 +195,8 @@ void UinputTouchScreen::configureDevice(int fd, uinput_user_dev* device) { device->absmax[ABS_MT_TRACKING_ID] = RAW_ID_MAX; device->absmin[ABS_MT_TOOL_TYPE] = MT_TOOL_FINGER; device->absmax[ABS_MT_TOOL_TYPE] = MT_TOOL_MAX; device->absmin[ABS_MT_PRESSURE] = RAW_PRESSURE_MIN; device->absmax[ABS_MT_PRESSURE] = RAW_PRESSURE_MAX; } void UinputTouchScreen::sendSlot(int32_t slot) { Loading @@ -206,6 +209,7 @@ void UinputTouchScreen::sendTrackingId(int32_t trackingId) { void UinputTouchScreen::sendDown(const Point& point) { injectEvent(EV_KEY, BTN_TOUCH, 1); injectEvent(EV_ABS, ABS_MT_PRESSURE, RAW_PRESSURE_MAX); injectEvent(EV_ABS, ABS_MT_POSITION_X, point.x); injectEvent(EV_ABS, ABS_MT_POSITION_Y, point.y); } Loading @@ -215,6 +219,10 @@ void UinputTouchScreen::sendMove(const Point& point) { injectEvent(EV_ABS, ABS_MT_POSITION_Y, point.y); } void UinputTouchScreen::sendPressure(int32_t pressure) { injectEvent(EV_ABS, ABS_MT_PRESSURE, pressure); } void UinputTouchScreen::sendPointerUp() { sendTrackingId(0xffffffff); } Loading services/inputflinger/tests/UinputDevice.h +1 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,7 @@ public: void sendTrackingId(int32_t trackingId); void sendDown(const Point& point); void sendMove(const Point& point); void sendPressure(int32_t pressure); void sendPointerUp(); void sendUp(); void sendToolType(int32_t toolType); Loading Loading
services/inputflinger/tests/InputReader_test.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -1829,6 +1829,38 @@ TEST_P(TouchIntegrationTest, InputEvent_ProcessPalm) { ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action); } /** * Some drivers historically have reported axis values outside of the range specified in the * evdev axis info. Ensure we don't crash when this happens. For example, a driver may report a * pressure value greater than the reported maximum, since it unclear what specific meaning the * maximum value for pressure has (beyond the maximum value that can be produced by a sensor), * and no units for pressure (resolution) is specified by the evdev documentation. */ TEST_P(TouchIntegrationTest, AcceptsAxisValuesOutsideReportedRange) { const Point centerPoint = mDevice->getCenterPoint(); // Down with pressure outside the reported range mDevice->sendSlot(FIRST_SLOT); mDevice->sendTrackingId(FIRST_TRACKING_ID); mDevice->sendDown(centerPoint); mDevice->sendPressure(UinputTouchScreen::RAW_PRESSURE_MAX + 2); mDevice->sendSync(); ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_DOWN))); // Move to a point outside the reported range mDevice->sendMove(Point(DISPLAY_WIDTH, DISPLAY_HEIGHT) + Point(1, 1)); mDevice->sendSync(); ASSERT_NO_FATAL_FAILURE(mTestListener->assertNotifyMotionWasCalled( WithMotionAction(AMOTION_EVENT_ACTION_MOVE))); // Up mDevice->sendUp(); mDevice->sendSync(); ASSERT_NO_FATAL_FAILURE( mTestListener->assertNotifyMotionWasCalled(WithMotionAction(AMOTION_EVENT_ACTION_UP))); } TEST_P(TouchIntegrationTest, NotifiesPolicyWhenStylusGestureStarted) { const Point centerPoint = mDevice->getCenterPoint(); Loading
services/inputflinger/tests/UinputDevice.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -177,6 +177,7 @@ void UinputTouchScreen::configureDevice(int fd, uinput_user_dev* device) { ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y); ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID); ioctl(fd, UI_SET_ABSBIT, ABS_MT_TOOL_TYPE); ioctl(fd, UI_SET_ABSBIT, ABS_MT_PRESSURE); ioctl(fd, UI_SET_PROPBIT, INPUT_PROP_DIRECT); if (!mPhysicalPort.empty()) { ioctl(fd, UI_SET_PHYS, mPhysicalPort.c_str()); Loading @@ -194,6 +195,8 @@ void UinputTouchScreen::configureDevice(int fd, uinput_user_dev* device) { device->absmax[ABS_MT_TRACKING_ID] = RAW_ID_MAX; device->absmin[ABS_MT_TOOL_TYPE] = MT_TOOL_FINGER; device->absmax[ABS_MT_TOOL_TYPE] = MT_TOOL_MAX; device->absmin[ABS_MT_PRESSURE] = RAW_PRESSURE_MIN; device->absmax[ABS_MT_PRESSURE] = RAW_PRESSURE_MAX; } void UinputTouchScreen::sendSlot(int32_t slot) { Loading @@ -206,6 +209,7 @@ void UinputTouchScreen::sendTrackingId(int32_t trackingId) { void UinputTouchScreen::sendDown(const Point& point) { injectEvent(EV_KEY, BTN_TOUCH, 1); injectEvent(EV_ABS, ABS_MT_PRESSURE, RAW_PRESSURE_MAX); injectEvent(EV_ABS, ABS_MT_POSITION_X, point.x); injectEvent(EV_ABS, ABS_MT_POSITION_Y, point.y); } Loading @@ -215,6 +219,10 @@ void UinputTouchScreen::sendMove(const Point& point) { injectEvent(EV_ABS, ABS_MT_POSITION_Y, point.y); } void UinputTouchScreen::sendPressure(int32_t pressure) { injectEvent(EV_ABS, ABS_MT_PRESSURE, pressure); } void UinputTouchScreen::sendPointerUp() { sendTrackingId(0xffffffff); } Loading
services/inputflinger/tests/UinputDevice.h +1 −0 Original line number Diff line number Diff line Loading @@ -189,6 +189,7 @@ public: void sendTrackingId(int32_t trackingId); void sendDown(const Point& point); void sendMove(const Point& point); void sendPressure(int32_t pressure); void sendPointerUp(); void sendUp(); void sendToolType(int32_t toolType); Loading