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

Commit 30b5cd7f authored by Josh Yang's avatar Josh Yang
Browse files

[Ambient Touch] Rework input dispatch policies during ambient mode.

1. Simplify wear's special logic in
   shouldDispatchInputWhenNonInteractive().
2. Always pass wakeful motion events to apps during ambient mode.

Test: atest CtsInputTestCases
Test: atest WmTests:PhoneWindowManagerTests
Test: Touch events during ambient mode is received by apps.
Test: Touch events during screen off is not received by apps.
Bug: 270228430
Change-Id: I7ccd0b33f762671f0433d112e9a41397c843dd04
parent c617fdd7
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -4680,7 +4680,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if ((policyFlags & FLAG_WAKE) != 0) {
            if (wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotion,
                    PowerManager.WAKE_REASON_WAKE_MOTION, "android.policy:MOTION")) {
                return 0;
                // Woke up. Pass motion events to user.
                return ACTION_PASS_TO_USER;
            }
        }

@@ -4692,8 +4693,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // there will be no dream to intercept the touch and wake into ambient.  The device should
        // wake up in this case.
        if (isTheaterModeEnabled() && (policyFlags & FLAG_WAKE) != 0) {
            wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotionWhenNotDreaming,
                    PowerManager.WAKE_REASON_WAKE_MOTION, "android.policy:MOTION");
            if (wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotionWhenNotDreaming,
                    PowerManager.WAKE_REASON_WAKE_MOTION, "android.policy:MOTION")) {
                // Woke up. Pass motion events to user.
                return ACTION_PASS_TO_USER;
            }
        }

        return 0;
@@ -4709,28 +4713,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        final boolean displayOff = (display == null
                || display.getState() == STATE_OFF);

        if (displayOff && !mHasFeatureWatch) {
        if (displayOff) {
            return false;
        }

        // Send events to keyguard while the screen is on and it's showing.
        if (isKeyguardShowingAndNotOccluded() && !displayOff) {
        if (isKeyguardShowingAndNotOccluded()) {
            return true;
        }

        // Watches handle BACK and hardware buttons specially
        if (mHasFeatureWatch && (keyCode == KeyEvent.KEYCODE_BACK
                || keyCode == KeyEvent.KEYCODE_STEM_PRIMARY
                || keyCode == KeyEvent.KEYCODE_STEM_1
                || keyCode == KeyEvent.KEYCODE_STEM_2
                || keyCode == KeyEvent.KEYCODE_STEM_3)) {
        // Watches consume all key events during ambient when keyguard is not showing.
        if (mHasFeatureWatch) {
            return false;
        }

        // TODO(b/123372519): Refine when dream can support multi display.
        if (isDefaultDisplay) {
            // Send events to a dozing dream even if the screen is off since the dream
            // is in control of the state of the screen.
            // Send events to a dozing dream since the dream is in control of the state of the
            // screen.
            IDreamManager dreamManager = getDreamManager();

            try {