Reland "uinput: delay from the end of the last delay"

(This CL is unchanged. Original description below, with additional Test:
line)

If we want to inject events at predictable times, then we shouldn't take
into account the current time when scheduling those injections, as that
could change depending on the timings of the process sending commands to
uinput. Instead, assume that the process sending commands intends time
offsets between injected events to be as close as possible to those
specified in the delay commands.

Bug: 310958309
Test: atest CtsInputTestCases
Test: atest android.view.cts.input.InputDeviceKeyLayoutMapTest \
            android.view.cts.input.InputDeviceSensorManagerTest \
            --rerun-until-failure=10
Change-Id: Ieaa4f2f06d5e0b7d13abc3afa474948996db7c0a
diff --git a/cmds/uinput/README.md b/cmds/uinput/README.md
index b6e4e0d..f177586 100644
--- a/cmds/uinput/README.md
+++ b/cmds/uinput/README.md
@@ -154,7 +154,8 @@
 
 #### `delay`
 
-Add a delay to command processing
+Add a delay between the processing of commands. The delay will be timed from when the last delay
+ended, rather than from the current time, to allow for more precise timings to be produced.
 
 | Field         | Type          | Description                |
 |:-------------:|:-------------:|:-------------------------- |
diff --git a/cmds/uinput/src/com/android/commands/uinput/Device.java b/cmds/uinput/src/com/android/commands/uinput/Device.java
index 2e4e111..b452fc7 100644
--- a/cmds/uinput/src/com/android/commands/uinput/Device.java
+++ b/cmds/uinput/src/com/android/commands/uinput/Device.java
@@ -149,8 +149,7 @@
      * @param delayNanos  Time to delay in unit of nanoseconds.
      */
     public void addDelayNanos(long delayNanos) {
-        mTimeToSendNanos =
-                Math.max(SystemClock.uptimeNanos(), mTimeToSendNanos) + delayNanos;
+        mTimeToSendNanos += delayNanos;
     }
 
     /**