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

Commit 95fd1fa0 authored by Mina Granic's avatar Mina Granic
Browse files

Extract onInputEvent to ease testing.

Flag: EXEMPT simple refactoring
Test: atest FrameworksCoreTests:ViewRootImplTest
Bug: 380522059
Change-Id: I2011ea3f73bbff7c65b95792163e1b45f2fe4952
parent 1e379cb5
Loading
Loading
Loading
Loading
+37 −22
Original line number Diff line number Diff line
@@ -10527,28 +10527,7 @@ public final class ViewRootImpl implements ViewParent,
        @Override
        public void onInputEvent(InputEvent event) {
            Trace.traceBegin(Trace.TRACE_TAG_VIEW, "processInputEventForCompatibility");
            List<InputEvent> processedEvents;
            try {
                processedEvents =
                    mInputCompatProcessor.processInputEventForCompatibility(event);
            } finally {
                Trace.traceEnd(Trace.TRACE_TAG_VIEW);
            }
            if (processedEvents != null) {
                if (processedEvents.isEmpty()) {
                    // InputEvent consumed by mInputCompatProcessor
                    finishInputEvent(event, true);
                } else {
                    for (int i = 0; i < processedEvents.size(); i++) {
                        enqueueInputEvent(
                                processedEvents.get(i), this,
                                QueuedInputEvent.FLAG_MODIFIED_FOR_COMPATIBILITY, true);
                    }
                }
            } else {
                enqueueInputEvent(event, this, 0, true);
            }
            processRawInputEvent(event);
        }
        @Override
@@ -10758,6 +10737,42 @@ public final class ViewRootImpl implements ViewParent,
    final InvalidateOnAnimationRunnable mInvalidateOnAnimationRunnable =
            new InvalidateOnAnimationRunnable();
    /**
     * Handle the incoming event.
     *
     * <p>The event will be first sent to the compatibility processor, which could choose to handle
     * it. The compat processor could also choose to produce more synthetic events in response to
     * the incoming one. Events that are not consumed by the compat processor are added to the
     * {@link ViewRootImpl}'s queue for further processing inside ViewRootImpl.
     *
     * @hide
     */
    @VisibleForTesting
    public void processRawInputEvent(InputEvent event) {
        Trace.traceBegin(Trace.TRACE_TAG_VIEW, "processInputEventForCompatibility");
        List<InputEvent> processedEvents;
        try {
            processedEvents =
                    mInputCompatProcessor.processInputEventForCompatibility(event);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_VIEW);
        }
        if (processedEvents != null) {
            if (processedEvents.isEmpty()) {
                // InputEvent consumed by mInputCompatProcessor
                mInputEventReceiver.finishInputEvent(event, true);
            } else {
                for (int i = 0; i < processedEvents.size(); i++) {
                    enqueueInputEvent(
                            processedEvents.get(i), mInputEventReceiver,
                            QueuedInputEvent.FLAG_MODIFIED_FOR_COMPATIBILITY, true);
                }
            }
        } else {
            enqueueInputEvent(event, mInputEventReceiver, 0, true);
        }
    }
    public void dispatchInvalidateDelayed(View view, long delayMilliseconds) {
        Message msg = mHandler.obtainMessage(MSG_INVALIDATE, view);
        mHandler.sendMessageDelayed(msg, delayMilliseconds);