Add unit tests for external stylus fusion
Add unit tests to demystify the external stylus fusion process and to
document its current behavior.
A fused external stylus reports pressure through a separate input
device. That pressure information is then fused with touches from the
touchscreen.
Bug: 246394583
Test: atest inputflinger_tests
Change-Id: I289e4470eb9383bc9e203bff8f76609b0d533e51
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 3947cf7..286e1f5 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -31,13 +31,6 @@
// --- Constants ---
-// Maximum amount of latency to add to touch events while waiting for data from an
-// external stylus.
-static constexpr nsecs_t EXTERNAL_STYLUS_DATA_TIMEOUT = ms2ns(72);
-
-// Maximum amount of time to wait on touch data before pushing out new pressure data.
-static constexpr nsecs_t TOUCH_DATA_TIMEOUT = ms2ns(20);
-
// Artificial latency on synthetic events created from stylus data without corresponding touch
// data.
static constexpr nsecs_t STYLUS_DATA_LATENCY = ms2ns(10);
@@ -1760,7 +1753,7 @@
out += dispatchPointerGestures(when, readTime, 0 /*policyFlags*/, true /*isTimeout*/);
}
} else if (mDeviceMode == DeviceMode::DIRECT) {
- if (mExternalStylusFusionTimeout < when) {
+ if (mExternalStylusFusionTimeout <= when) {
out += processRawTouches(true /*timeout*/);
} else if (mExternalStylusFusionTimeout != LLONG_MAX) {
getContext()->requestTimeoutAtTime(mExternalStylusFusionTimeout);