diff options
| author | 2024-04-22 14:30:18 +0000 | |
|---|---|---|
| committer | 2024-04-23 10:23:49 +0000 | |
| commit | 24cff7df533ecfa09b65328133c30a20255deefc (patch) | |
| tree | 62612c3877c4728b2ec5425e086e3f1ba20ce44f | |
| parent | bf44397daf51cdf27ddafba02f9d2e59778fe244 (diff) | |
uinput: fix timestamps for JSON-style recordings
The previous changes to support specifying timestamps for evemu
recordings inadvertently made injections from JSON-style recordings have
the timestamps at which the injection was scheduled, not when it
happened, causing many events to be injected with very close-together
timestamps. This broke drawing in the tests for some inking libraries,
such as Keep's.
Bug: 330844071
Test: $ atest 'PlatformScenarioTests:android.platform.test.scenario.sysui.stylus.StylusInkingTest#writeText_appearsInShowcaseApp'
(with the @Ignore in StylusInkingTest.kt removed)
Test: replay the recording from b/330844071#comment30, check the curve
is drawn correctly
Test: replay an evemu recording and check that the timestamps shown by
`getevent -lt` are still correct
Change-Id: I5342a79d4f9b53875b9918443bf1f5fd16cd205e
| -rw-r--r-- | cmds/uinput/src/com/android/commands/uinput/Device.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmds/uinput/src/com/android/commands/uinput/Device.java b/cmds/uinput/src/com/android/commands/uinput/Device.java index b452fc7094ba..84a800983265 100644 --- a/cmds/uinput/src/com/android/commands/uinput/Device.java +++ b/cmds/uinput/src/com/android/commands/uinput/Device.java @@ -216,7 +216,7 @@ public class Device { break; } long offsetMicros = args.argl1; - if (mLastInjectTimestampMicros == -1 || offsetMicros == -1) { + if (mLastInjectTimestampMicros == -1) { // There's often a delay of a few milliseconds between the time specified to // Handler.sendMessageAtTime and the handler actually being called, due to // the way threads are scheduled. We don't take this into account when @@ -232,6 +232,9 @@ public class Device { // To prevent this, we need to use the time at which we scheduled this first // batch, rather than the actual current time. mLastInjectTimestampMicros = args.argl2 / 1000; + } else if (offsetMicros == -1) { + // No timestamp offset is specified for this event, so use the current time. + mLastInjectTimestampMicros = SystemClock.uptimeNanos() / 1000; } else { mLastInjectTimestampMicros += offsetMicros; } |