Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b4c4247 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add test to ensure values outside the abs axis range are accepted" into main

parents 31618200 c09ec6d4
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -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();
+8 −0
Original line number Diff line number Diff line
@@ -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());
@@ -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) {
@@ -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);
}
@@ -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);
}
+1 −0
Original line number Diff line number Diff line
@@ -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);