Add timestamp smoothening for Bluetooth mice and touchpads
While Bluetooth input devices are expected to produce input events at a
consistent rate, the device may batch together several input events and
send them all at once to Android to avoid excessive Bluetooth
communication. When doing so, if the event timestamps are not processed
correctly by the kernel or the device driver, these batched events will
reach inputflinger with very similar timestamps even though they were
generated at a fixed interval.
To prevent negative user experiences with this type of Bluetooth
batching, we enforce an assumption that all Bluetooth devices generate
events at a maximum rate of 250Hz, which means each successive input
event from a Bluetooth device must have a timestamp that is at least 4
milliseconds later than the preceeding event.
Bug: 257124950
Test: atest inputflinger_tests
Test: manual, with Wacom Intuos S
Test: manual, with Apple Magic Trackpad 2
Test: manual, with Logitech MX Master 3
Test: manual, with Sony DualSense Contoller
Change-Id: Ia32bb594d0897e69796bb39f59fcc067cf487ff2
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.h b/services/inputflinger/reader/mapper/TouchInputMapper.h
index 2bb9ece..68cdef0 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.h
@@ -315,7 +315,7 @@
RawPointerAxes mRawPointerAxes;
struct RawState {
- nsecs_t when{};
+ nsecs_t when{std::numeric_limits<nsecs_t>::min()};
nsecs_t readTime{};
// Raw pointer sample data.