Skip to content

Commit 42caf4a

Browse files
committed
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
1 parent 0fa9033 commit 42caf4a

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

services/inputflinger/reader/mapper/TouchInputMapper.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,7 @@ std::list<NotifyArgs> TouchInputMapper::dispatchPointerMouse(nsecs_t when, nsecs
34763476
}
34773477

34783478
return dispatchPointerSimple(when, readTime, policyFlags, down, hovering,
3479-
ui::LogicalDisplayId::INVALID);
3479+
getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID));
34803480
}
34813481

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

39693969
std::optional<ui::LogicalDisplayId> TouchInputMapper::getAssociatedDisplayId() {
3970-
if (mParameters.hasAssociatedDisplay) {
3971-
if (mDeviceMode == DeviceMode::POINTER) {
3972-
return ui::LogicalDisplayId::INVALID;
3973-
} else {
3974-
return std::make_optional(mViewport.displayId);
3975-
}
3976-
}
3977-
return std::nullopt;
3970+
return mParameters.hasAssociatedDisplay ? std::make_optional(mViewport.displayId)
3971+
: std::nullopt;
39783972
}
39793973

39803974
} // namespace android

services/inputflinger/tests/InputReader_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7534,7 +7534,7 @@ TEST_F(MultiTouchInputMapperTest, Process_Pointer_ShouldHandleDisplayId) {
75347534

75357535
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
75367536
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
7537-
ASSERT_EQ(ui::LogicalDisplayId::INVALID, motionArgs.displayId);
7537+
ASSERT_EQ(DISPLAY_ID, motionArgs.displayId);
75387538
}
75397539

75407540
/**

0 commit comments

Comments
 (0)