diff options
| author | 2024-04-23 10:25:17 +0000 | |
|---|---|---|
| committer | 2024-04-23 10:25:17 +0000 | |
| commit | b434eb94faf8aecf7e749baca3bea2f4dbe2b1fb (patch) | |
| tree | a0edcbd1900dad56d00d90ebf24baa58bb546272 | |
| parent | 2f7b477159fa569519936ce4f7fe438f65752e8d (diff) | |
| parent | 24cff7df533ecfa09b65328133c30a20255deefc (diff) | |
Merge "uinput: fix timestamps for JSON-style recordings" into main
| -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 7e99c92fa597..2cac6313f4f5 100644 --- a/cmds/uinput/src/com/android/commands/uinput/Device.java +++ b/cmds/uinput/src/com/android/commands/uinput/Device.java @@ -223,7 +223,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 @@ -239,6 +239,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; } |