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

Commit a6863ad6 authored by Michael Wright's avatar Michael Wright Committed by Android (Google) Code Review
Browse files

Merge "Allow for event dispatching when in non-interactive states." into lmp-dev

parents 77a63450 70af00ab
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -770,7 +770,8 @@ public interface WindowManagerPolicy {
    public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);

    /**
     * Called from the input reader thread before a motion is enqueued when the screen is off.
     * Called from the input reader thread before a motion is enqueued when the device is in a
     * non-interactive state.
     *
     * <p>There are some actions that need to be handled here because they
     * affect the power state of the device, for example, waking on motions.
@@ -780,7 +781,7 @@ public interface WindowManagerPolicy {
     *
     * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
     */
    public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags);
    public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags);

    /**
     * Called from the input dispatcher thread before a key is dispatched to a window.
+19 −7
Original line number Diff line number Diff line
@@ -4240,8 +4240,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        int result;
        boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0
                || event.isWakeKey();
        if (interactive || (isInjected && !isWakeKey)) {
            // When the screen is on or if the key is injected pass the key to the application.
        if (interactive
                || (isInjected && !isWakeKey)
                || (!interactive && shouldDispatchInputWhenNonInteractive())) {
            // When the device is interactive, the key is injected, or we're currently dozing in a
            // non-interactive state with the screen on and the keyguard showing,  pass the key to
            // the application.
            result = ACTION_PASS_TO_USER;
            isWakeKey = false;
        } else {
@@ -4548,13 +4552,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    /** {@inheritDoc} */
    @Override
    public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) {
        // We already know this is a wake motion so just wake up.
        // Note that we would observe policyFlags containing
        // FLAG_WAKE and FLAG_INTERACTIVE here.
    public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) {
        if ((policyFlags & FLAG_WAKE) != 0) {
            mPowerManager.wakeUp(whenNanos / 1000000);
            return 0;
        }
        if (shouldDispatchInputWhenNonInteractive()) {
            return ACTION_PASS_TO_USER;
        }
        return 0;
    }

    private boolean shouldDispatchInputWhenNonInteractive() {
        return keyguardIsShowingTq() && mDisplay != null &&
                mDisplay.getState() != Display.STATE_OFF;
    }

    void dispatchMediaKeyWithWakeLock(KeyEvent event) {
        if (DEBUG_INPUT) {
+1 −1
Original line number Diff line number Diff line
@@ -9945,7 +9945,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    }
    private void updateEventDispatchingLocked() {
        mWindowManager.setEventDispatching(mBooted && !mWentToSleep && !mShuttingDown);
        mWindowManager.setEventDispatching(mBooted && !mShuttingDown);
    }
    public void setLockScreenShown(boolean shown) {
+3 −3
Original line number Diff line number Diff line
@@ -1429,8 +1429,8 @@ public class InputManagerService extends IInputManager.Stub
    }

    // Native callback.
    private int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) {
        return mWindowManagerCallbacks.interceptWakeMotionBeforeQueueing(
    private int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) {
        return mWindowManagerCallbacks.interceptMotionBeforeQueueingNonInteractive(
                whenNanos, policyFlags);
    }

@@ -1593,7 +1593,7 @@ public class InputManagerService extends IInputManager.Stub

        public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);

        public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags);
        public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags);

        public long interceptKeyBeforeDispatching(InputWindowHandle focus,
                KeyEvent event, int policyFlags);
+5 −4
Original line number Diff line number Diff line
@@ -365,12 +365,13 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags);
    }

    /* Provides an opportunity for the window manager policy to intercept early
     * motion event processing when the screen is off since these events are normally
    /* Provides an opportunity for the window manager policy to intercept early motion event
     * processing when the device is in a non-interactive state since these events are normally
     * dropped. */
    @Override
    public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) {
        return mService.mPolicy.interceptWakeMotionBeforeQueueing(whenNanos, policyFlags);
    public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) {
        return mService.mPolicy.interceptMotionBeforeQueueingNonInteractive(
                whenNanos, policyFlags);
    }

    /* Provides an opportunity for the window manager policy to process a key before
Loading