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

Commit 42caf4a2 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

TouchInputMapper: Fix display association for POINTER mode

POINTER mode in TouchInputMapper is now only used for drawing tablets
and absolute mice; it is no longer used for touchpads. This means
TouchInputMapper can only work with an associated display, so ensure we
don't use the invalid displayId when generating events from these
devices.

Bug: 332683415
Bug: 399982225
Test: Presubmit
Flag: EXEMPT bug fix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8f1a0c3fd97722ad9fe14f380734cfc2a7e31809)
Merged-In: Ice0ee9be87d0582c553ef3743ac3f0d49a12c6ea
Change-Id: Ice0ee9be87d0582c553ef3743ac3f0d49a12c6ea
parent 0fa90334
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -3476,7 +3476,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerMouse(nsecs_t when, nsecs
    }

    return dispatchPointerSimple(when, readTime, policyFlags, down, hovering,
                                 ui::LogicalDisplayId::INVALID);
                                 getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID));
}

std::list<NotifyArgs> TouchInputMapper::abortPointerMouse(nsecs_t when, nsecs_t readTime,
@@ -3967,14 +3967,8 @@ bool TouchInputMapper::markSupportedKeyCodes(uint32_t sourceMask,
}

std::optional<ui::LogicalDisplayId> TouchInputMapper::getAssociatedDisplayId() {
    if (mParameters.hasAssociatedDisplay) {
        if (mDeviceMode == DeviceMode::POINTER) {
            return ui::LogicalDisplayId::INVALID;
        } else {
            return std::make_optional(mViewport.displayId);
        }
    }
    return std::nullopt;
    return mParameters.hasAssociatedDisplay ? std::make_optional(mViewport.displayId)
                                            : std::nullopt;
}

} // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -7534,7 +7534,7 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShouldHandleDisplayId) {

    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
    ASSERT_EQ(ui::LogicalDisplayId::INVALID, motionArgs.displayId);
    ASSERT_EQ(DISPLAY_ID, motionArgs.displayId);
}

/**