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

Commit f14e16fd authored by Robin Lee's avatar Robin Lee
Browse files

Reintroduce a timeout on going-away transition

This was formerly enforced using the RemoteAnimation framework's
timeouts. Moving to the RemoteTransition framework lost the time
limit, allowing confused state to sometimes persist forever.

On hitting the timeout, keyguardGoingAway will be reset and the
KeyguardService will be told to directly dismiss with no animation
targets. Then it has two options:

- Ignore the callback, and keyguard will show again by default
- Handle the exit animation, and then call setShowing(false)

Thus there should be a correct final state whether the SysUI is
implementing this callback or not.

This can be removed when goingAway is removed.

Test: Manual - test to follow
Flag: com.android.window.flags.keyguard_going_away_timeout
Bug: 343598832
Change-Id: I4c66716dccabdb85aff845684a69fdd938caf639
parent 88248b6b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -64,6 +64,14 @@ flag {
  is_fixed_read_only: true
}

flag {
  name: "keyguard_going_away_timeout"
  namespace: "windowing_frontend"
  description: "Allow a maximum of 10 seconds with keyguardGoingAway=true before force-resetting"
  bug: "343598832"
  is_fixed_read_only: true
}

flag {
  name: "close_to_square_config_includes_status_bar"
  namespace: "windowing_frontend"
+34 −0
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ class KeyguardController {

    private static final int DEFER_WAKE_TRANSITION_TIMEOUT_MS = 5000;

    private static final int GOING_AWAY_TIMEOUT_MS = 10500;

    private final ActivityTaskSupervisor mTaskSupervisor;
    private WindowManagerService mWindowManager;

@@ -232,6 +234,7 @@ class KeyguardController {
                dc.mWallpaperController.adjustWallpaperWindows();
                dc.executeAppTransition();
            }
            scheduleGoingAwayTimeout(displayId);
        }

        // Update the sleep token first such that ensureActivitiesVisible has correct sleep token
@@ -286,6 +289,8 @@ class KeyguardController {
            mRootWindowContainer.ensureActivitiesVisible();
            mRootWindowContainer.addStartingWindowsForVisibleActivities();
            mWindowManager.executeAppTransition();

            scheduleGoingAwayTimeout(displayId);
        } finally {
            mService.continueWindowLayout();
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
@@ -590,6 +595,34 @@ class KeyguardController {
        }
    }

    /**
     * Called when the default display's mKeyguardGoingAway has been left as {@code true} for too
     * long. Send an explicit message to the KeyguardService asking it to wrap up.
     */
    private final Runnable mGoingAwayTimeout = () -> {
        synchronized (mWindowManager.mGlobalLock) {
            KeyguardDisplayState state = getDisplayState(DEFAULT_DISPLAY);
            if (!state.mKeyguardGoingAway) {
                return;
            }
            state.mKeyguardGoingAway = false;
            state.writeEventLog("goingAwayTimeout");
            mWindowManager.mPolicy.startKeyguardExitAnimation(0);
        }
    };

    private void scheduleGoingAwayTimeout(int displayId) {
        if (displayId != DEFAULT_DISPLAY) {
            return;
        }
        if (getDisplayState(displayId).mKeyguardGoingAway) {
            if (!mWindowManager.mH.hasCallbacks(mGoingAwayTimeout)) {
                mWindowManager.mH.postDelayed(mGoingAwayTimeout, GOING_AWAY_TIMEOUT_MS);
            }
        } else {
            mWindowManager.mH.removeCallbacks(mGoingAwayTimeout);
        }
    }

    /** Represents Keyguard state per individual display. */
    private static class KeyguardDisplayState {
@@ -709,6 +742,7 @@ class KeyguardController {
            if (!lastKeyguardGoingAway && mKeyguardGoingAway) {
                writeEventLog("dismissIfInsecure");
                controller.handleDismissInsecureKeyguard(display);
                controller.scheduleGoingAwayTimeout(mDisplayId);
                hasChange = true;
            } else if (lastOccluded != mOccluded) {
                controller.handleOccludedChanged(mDisplayId, mTopOccludesActivity);