From dca1946d4cb70f4aef13ed8c81c8ded15ceb02da Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Sat, 27 Feb 2021 08:38:31 +0000 Subject: Use InputEventAssigner to assign input to frame When a frame is determined to be caused by an input event, it will be labeled with a specific input event id. The newly added entity, InputEventAssigner, is responsible for determining which input event we should use. For regular ACTION_MOVE events, we will take the latest input event as the event that has caused the frame. For the initial gesture (ACTION_DOWN), we will use the first event (the ACTION_DOWN itself) to figure out the down latency. This will allow us to split up 'down' and 'scroll' latencies. Bug: 169866723 Test: looked at the data printed locally to logcat Test: atest InputTests Change-Id: I8513a36960e5d652d07655d1267e758d0c59ced7 --- core/java/android/view/ViewRootImpl.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'core/java/android/view/ViewRootImpl.java') diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index f8e65bd0d056..390e3ae78143 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -457,6 +457,7 @@ public final class ViewRootImpl implements ViewParent, FallbackEventHandler mFallbackEventHandler; final Choreographer mChoreographer; protected final ViewFrameInfo mViewFrameInfo = new ViewFrameInfo(); + private final InputEventAssigner mInputEventAssigner = new InputEventAssigner(); /** * Update the Choreographer's FrameInfo object with the timing information for the current @@ -8352,16 +8353,7 @@ public final class ViewRootImpl implements ViewParent, Trace.traceCounter(Trace.TRACE_TAG_INPUT, mPendingInputEventQueueLengthCounterName, mPendingInputEventCount); - long eventTime = q.mEvent.getEventTimeNano(); - long oldestEventTime = eventTime; - if (q.mEvent instanceof MotionEvent) { - MotionEvent me = (MotionEvent)q.mEvent; - if (me.getHistorySize() > 0) { - oldestEventTime = me.getHistoricalEventTimeNano(0); - } - } - mViewFrameInfo.updateOldestInputEvent(oldestEventTime); - mViewFrameInfo.updateNewestInputEvent(eventTime); + mViewFrameInfo.setInputEvent(mInputEventAssigner.processEvent(q.mEvent)); deliverInputEvent(q); } @@ -8497,6 +8489,11 @@ public final class ViewRootImpl implements ViewParent, consumedBatches = false; } doProcessInputEvents(); + if (consumedBatches) { + // Must be done after we processed the input events, to mark the completion of the frame + // from the input point of view + mInputEventAssigner.onChoreographerCallback(); + } return consumedBatches; } -- cgit v1.2.3