Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b959f744 authored by Harry Cutts's avatar Harry Cutts
Browse files

uinput: delay from the end of the last delay

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
Change-Id: I3ceab49bd6f492244e53d3263bf10802353853c2
parent ee829890
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -154,7 +154,8 @@ will be unregistered. There is no explicit command for unregistering a device.

#### `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                |
|:-------------:|:-------------:|:-------------------------- |
+1 −2
Original line number Diff line number Diff line
@@ -149,8 +149,7 @@ public class Device {
     * @param delayNanos  Time to delay in unit of nanoseconds.
     */
    public void addDelayNanos(long delayNanos) {
        mTimeToSendNanos =
                Math.max(SystemClock.uptimeNanos(), mTimeToSendNanos) + delayNanos;
        mTimeToSendNanos += delayNanos;
    }

    /**