Do not convert time to float
The conversion of time to float causes weird behaviour. When the time is
received in palm rejection code, the time deltas do not match the
original values seen in Android.
Rather than debug the float conversion, switch to using integral values
for timestamps.
After the switch, printing the time difference shows the values as
expected.
Bug: 240168494
Test: printed diffs of timestamps inside palm rejection code
Test: atest inputflinger_tests
Change-Id: If6af45ba7740de4d70a300a45842bd3d6a069f40
diff --git a/services/inputflinger/UnwantedInteractionBlocker.cpp b/services/inputflinger/UnwantedInteractionBlocker.cpp
index a8e495f..2193b7c 100644
--- a/services/inputflinger/UnwantedInteractionBlocker.cpp
+++ b/services/inputflinger/UnwantedInteractionBlocker.cpp
@@ -58,8 +58,7 @@
}
static ::base::TimeTicks toChromeTimestamp(nsecs_t eventTime) {
- return ::base::TimeTicks::UnixEpoch() +
- ::base::Milliseconds(static_cast<float>(ns2ms(eventTime)));
+ return ::base::TimeTicks::UnixEpoch() + ::base::TimeDelta::FromNanosecondsD(eventTime);
}
/**