Pass latency information from app to input

Once the app learns about the frame's timeline, it will tell
inputdispatcher about it. We are adding a new callback similar to
'finishInputEvent', called 'reportLatencyInfo'.

This will tell inputdispatcher about the queue time and the present time
of each frame that was caused by input.

InputDispatcher will then be able to reconstruct the input event
timeline and report the end-to-end latency metrics.

In a separate CL, we will add LatencyTracker, which will eventually
receive this data.

Using the event id and the provided queue time and present time, we will
be able to reconstruct the end-to-end latency inside LatencyTracker.

Bug: 167947340
Test: atest inputflinger_tests libinput_tests
Change-Id: I181532a01b34eecd186bc3c74db289fc59c5955c
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 397a9d7..de7acf9 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -3290,15 +3290,21 @@
             bool gotOne = false;
             status_t status = OK;
             for (;;) {
-                Result<InputPublisher::Finished> result =
-                        connection->inputPublisher.receiveFinishedSignal();
+                Result<InputPublisher::ConsumerResponse> result =
+                        connection->inputPublisher.receiveConsumerResponse();
                 if (!result.ok()) {
                     status = result.error().code();
                     break;
                 }
-                const InputPublisher::Finished& finished = *result;
-                d->finishDispatchCycleLocked(currentTime, connection, finished.seq,
-                                             finished.handled, finished.consumeTime);
+
+                if (std::holds_alternative<InputPublisher::Finished>(*result)) {
+                    const InputPublisher::Finished& finish =
+                            std::get<InputPublisher::Finished>(*result);
+                    d->finishDispatchCycleLocked(currentTime, connection, finish.seq,
+                                                 finish.handled, finish.consumeTime);
+                } else if (std::holds_alternative<InputPublisher::Timeline>(*result)) {
+                    // TODO(b/167947340): Report this data to LatencyTracker
+                }
                 gotOne = true;
             }
             if (gotOne) {