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

Commit f8fe742a authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Reduce confusing usages of checking occluded keyguard

The KeyguardDisplayState#mOccluded state only means that there is
either a top activity which can occlude keyguard or the dream service
is showing. While checking occluded state of keyguard outside of
KeyguardController, the callers usually expect that the keyguard
is also locked.

Bug: 297188512
Test: Disable keyguard and turn off/on screen.
      - Activity with show-when-lock
        The transition type is NONE instead of KEYGUARD_OCCLUDE.
      - Activity without show-when-lock
        No error log about visibility change without a transition.

Change-Id: Ieaad9624d816866cacc5ab5e8b5176ab74219233
parent 7b193950
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2705,8 +2705,7 @@ class ActivityStarter {
            mTransientLaunch = mOptions.getTransientLaunch();
            final KeyguardController kc = mSupervisor.getKeyguardController();
            final int displayId = mPreferredTaskDisplayArea.getDisplayId();
            mDisplayLockAndOccluded = kc.isKeyguardLocked(displayId)
                    && kc.isDisplayOccluded(displayId);
            mDisplayLockAndOccluded = kc.isKeyguardOccluded(displayId);
            // Recents animation on lock screen, do not resume & move launcher to top.
            if (mTransientLaunch && mDisplayLockAndOccluded
                    && mService.getTransitionController().isShellTransitionsEnabled()) {
+1 −1
Original line number Diff line number Diff line
@@ -409,7 +409,7 @@ class BackNavigationController {
    boolean isKeyguardOccluded(WindowState focusWindow) {
        final KeyguardController kc = mWindowManagerService.mAtmService.mKeyguardController;
        final int displayId = focusWindow.getDisplayId();
        return kc.isKeyguardLocked(displayId) && kc.isDisplayOccluded(displayId);
        return kc.isKeyguardOccluded(displayId);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -6527,7 +6527,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     */
    boolean isKeyguardOccluded() {
        return mRootWindowContainer.mTaskSupervisor
                .getKeyguardController().isDisplayOccluded(mDisplayId);
                .getKeyguardController().isKeyguardOccluded(mDisplayId);
    }

    /**
+11 −4
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ class KeyguardController {
        final KeyguardDisplayState state = getDisplayState(displayId);
        return (state.mKeyguardShowing || state.mAodShowing)
                && !state.mKeyguardGoingAway
                && !isDisplayOccluded(displayId);
                && !state.mOccluded;
    }

    /**
@@ -134,8 +134,7 @@ class KeyguardController {
     */
    boolean isKeyguardShowing(int displayId) {
        final KeyguardDisplayState state = getDisplayState(displayId);
        return state.mKeyguardShowing && !state.mKeyguardGoingAway
                && !isDisplayOccluded(displayId);
        return state.mKeyguardShowing && !state.mKeyguardGoingAway && !state.mOccluded;
    }

    /**
@@ -146,6 +145,12 @@ class KeyguardController {
        return state.mKeyguardShowing && !state.mKeyguardGoingAway;
    }

    /** Returns {code @true} if Keyguard is occluded while it is showing and not going away. */
    boolean isKeyguardOccluded(int displayId) {
        final KeyguardDisplayState state = getDisplayState(displayId);
        return state.mKeyguardShowing && !state.mKeyguardGoingAway && state.mOccluded;
    }

    /**
     *
     * @return true if the activity is controlling keyguard state.
@@ -496,7 +501,9 @@ class KeyguardController {
    }

    /**
     * @return true if Keyguard is occluded or the device is dreaming.
     * Returns {@code true} if the top activity on the display can occlude keyguard or the device
     * is dreaming. Note that this method may return {@code true} even if the keyguard is disabled
     * or not showing.
     */
    boolean isDisplayOccluded(int displayId) {
        return getDisplayState(displayId).mOccluded;
+4 −5
Original line number Diff line number Diff line
@@ -2405,6 +2405,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            // Prepare transition before resume top activity, so it can be collected.
            if (!displayShouldSleep && display.mTransitionController.isShellTransitionsEnabled()
                    && !display.mTransitionController.isCollecting()) {
                // Use NONE if keyguard is not showing.
                int transit = TRANSIT_NONE;
                Task startTask = null;
                if (!display.getDisplayPolicy().isAwake()) {
@@ -2416,12 +2417,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                    transit = WindowManager.TRANSIT_KEYGUARD_OCCLUDE;
                    startTask = display.getTaskOccludingKeyguard();
                }
                if (transit != TRANSIT_NONE) {
                display.mTransitionController.requestStartTransition(
                        display.mTransitionController.createTransition(transit),
                        startTask, null /* remoteTransition */, null /* displayChange */);
            }
            }
            // Set the sleeping state of the root tasks on the display.
            display.forAllRootTasks(rootTask -> {
                if (displayShouldSleep) {
Loading