From 229a880486fd617f31cf6c29f2575a895ca2eb8b Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Thu, 28 Jul 2022 21:58:56 +0000 Subject: 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 --- services/inputflinger/UnwantedInteractionBlocker.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'services/inputflinger/UnwantedInteractionBlocker.cpp') diff --git a/services/inputflinger/UnwantedInteractionBlocker.cpp b/services/inputflinger/UnwantedInteractionBlocker.cpp index a8e495f235..2193b7c4f0 100644 --- a/services/inputflinger/UnwantedInteractionBlocker.cpp +++ b/services/inputflinger/UnwantedInteractionBlocker.cpp @@ -58,8 +58,7 @@ static bool isFromTouchscreen(int32_t source) { } static ::base::TimeTicks toChromeTimestamp(nsecs_t eventTime) { - return ::base::TimeTicks::UnixEpoch() + - ::base::Milliseconds(static_cast(ns2ms(eventTime))); + return ::base::TimeTicks::UnixEpoch() + ::base::TimeDelta::FromNanosecondsD(eventTime); } /** -- cgit v1.2.3-59-g8ed1b