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

Commit 535c2121 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Dispatch key events to launcher input consumer.

Fixes: 125495172
Test: Manual
Change-Id: I7d17dd91654c7543afb9e985dee4da8b89da6f08
parent d867ff03
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -27,26 +27,26 @@ import android.os.RemoteException;
import android.util.Log;
import android.view.BatchedInputEventReceiver;
import android.view.Choreographer;
import android.view.IWindowManager;
import android.view.InputChannel;
import android.view.InputEvent;
import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.WindowManagerGlobal;

import java.io.PrintWriter;

/**
 * Manages the input consumer that allows the SystemUI to directly receive touch input.
 * Manages the input consumer that allows the SystemUI to directly receive input.
 */
public class InputConsumerController {

    private static final String TAG = InputConsumerController.class.getSimpleName();

    /**
     * Listener interface for callers to subscribe to touch events.
     * Listener interface for callers to subscribe to input events.
     */
    public interface TouchListener {
        boolean onTouchEvent(MotionEvent ev);
    public interface InputListener {
        /** Handles any input event. */
        boolean onInputEvent(InputEvent ev);
    }

    /**
@@ -71,9 +71,8 @@ public class InputConsumerController {
        public void onInputEvent(InputEvent event) {
            boolean handled = true;
            try {
                if (mListener != null && event instanceof MotionEvent) {
                    MotionEvent ev = (MotionEvent) event;
                    handled = mListener.onTouchEvent(ev);
                if (mListener != null) {
                    handled = mListener.onInputEvent(event);
                }
            } finally {
                finishInputEvent(event, handled);
@@ -86,7 +85,7 @@ public class InputConsumerController {
    private final String mName;

    private InputEventReceiver mInputEventReceiver;
    private TouchListener mListener;
    private InputListener mListener;
    private RegistrationListener mRegistrationListener;

    /**
@@ -115,9 +114,9 @@ public class InputConsumerController {
    }

    /**
     * Sets the touch listener.
     * Sets the input listener.
     */
    public void setTouchListener(TouchListener listener) {
    public void setInputListener(InputListener listener) {
        mListener = listener;
    }

+8 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.RemoteException;
import android.util.Log;
import android.util.Size;
import android.view.IPinnedStackController;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
@@ -206,7 +207,7 @@ public class PipTouchHandler {
        mEnableDimissDragToEdge = res.getBoolean(R.bool.config_pipEnableDismissDragToEdge);

        // Register the listener for input consumer touch events
        inputConsumerController.setTouchListener(this::handleTouchEvent);
        inputConsumerController.setInputListener(this::handleTouchEvent);
        inputConsumerController.setRegistrationListener(this::onRegistrationChanged);
        onRegistrationChanged(inputConsumerController.isRegistered());
    }
@@ -370,11 +371,16 @@ public class PipTouchHandler {
                mMovementBounds, true /* allowMenuTimeout */, willResizeMenu());
    }

    private boolean handleTouchEvent(MotionEvent ev) {
    private boolean handleTouchEvent(InputEvent inputEvent) {
        // Skip any non motion events
        if (!(inputEvent instanceof MotionEvent)) {
            return true;
        }
        // Skip touch handling until we are bound to the controller
        if (mPinnedStackController == null) {
            return true;
        }
        MotionEvent ev = (MotionEvent) inputEvent;

        // Update the touch state
        mTouchState.onTouchEvent(ev);