Send correct downtime for motion events in split pointers case
Currently, for split pointer scenario, the down time is still the
the down time for the first pointer on the display. This might not
necessarily be the downTime for a window in split pointer case.
Need to send the correct downTime when we split pointers.
Test: atest inputflinger_tests
Bug: 228331266
Bug: 220109830
Change-Id: I80cf889e3243c39619ba96bd2b74073642cabc36
diff --git a/services/inputflinger/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index 51c6826..cf0c38a 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -30,7 +30,7 @@
}
void TouchState::addOrUpdateWindow(const sp<WindowInfoHandle>& windowHandle, int32_t targetFlags,
- BitSet32 pointerIds) {
+ BitSet32 pointerIds, std::optional<nsecs_t> eventTime) {
if (targetFlags & InputTarget::FLAG_SPLIT) {
split = true;
}
@@ -42,7 +42,13 @@
if (targetFlags & InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT) {
touchedWindow.targetFlags &= ~InputTarget::FLAG_DISPATCH_AS_IS;
}
+ // For cases like hover enter/exit or DISPATCH_AS_OUTSIDE a touch window might not have
+ // downTime set initially. Need to update existing window when an pointer is down for
+ // the window.
touchedWindow.pointerIds.value |= pointerIds.value;
+ if (!touchedWindow.firstDownTimeInTarget.has_value()) {
+ touchedWindow.firstDownTimeInTarget = eventTime;
+ }
return;
}
}
@@ -51,6 +57,7 @@
touchedWindow.windowHandle = windowHandle;
touchedWindow.targetFlags = targetFlags;
touchedWindow.pointerIds = pointerIds;
+ touchedWindow.firstDownTimeInTarget = eventTime;
windows.push_back(touchedWindow);
}