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

Commit fbd3aea8 authored by Issei Suzuki's avatar Issei Suzuki Committed by Android (Google) Code Review
Browse files

Merge "Unify logic to check if either Keygaurd or AOD are showing."

parents b502f171 b9f3d7ce
Loading
Loading
Loading
Loading
+11 −24
Original line number Diff line number Diff line
@@ -90,24 +90,11 @@ class KeyguardController {
    }

    /**
     * @return true if either Keyguard or AOD are showing, not going away, and not being occluded
     *         on the given display, false otherwise.
     * @return true if either 1) AOD is showing, or 2) Keyguard is showing, not going away, and not
     *         being occluded on the given display, false otherwise.
     */
    boolean isKeyguardOrAodShowing(int displayId) {
        return (mKeyguardShowing || mAodShowing) && !mKeyguardGoingAway
                && !isDisplayOccluded(displayId);
    }

    /**
     * @return {@code true} for default display when AOD is showing. Otherwise, same as
     *         {@link #isKeyguardOrAodShowing(int)}
     * TODO(b/125198167): Replace isKeyguardOrAodShowing() by this logic.
     */
    boolean isKeyguardUnoccludedOrAodShowing(int displayId) {
        if (displayId == DEFAULT_DISPLAY && mAodShowing) {
            return true;
        }
        return isKeyguardOrAodShowing(displayId);
        return mAodShowing || isKeyguardShowing(displayId);
    }

    /**
@@ -115,7 +102,7 @@ class KeyguardController {
     *         display, false otherwise
     */
    boolean isKeyguardShowing(int displayId) {
        return mKeyguardShowing && !mKeyguardGoingAway && !isDisplayOccluded(displayId);
        return mKeyguardShowing && !mKeyguardGoingAway && !isKeyguardOccluded(displayId);
    }

    /**
@@ -328,7 +315,7 @@ class KeyguardController {
            return;
        }

        mWindowManager.onKeyguardOccludedChanged(isDisplayOccluded(DEFAULT_DISPLAY));
        mWindowManager.onKeyguardOccludedChanged(isKeyguardOccluded(DEFAULT_DISPLAY));
        if (isKeyguardLocked()) {
            mWindowManager.deferSurfaceLayout();
            try {
@@ -373,7 +360,7 @@ class KeyguardController {
        }
    }

    private boolean isDisplayOccluded(int displayId) {
    private boolean isKeyguardOccluded(int displayId) {
        return getDisplay(displayId).mOccluded;
    }

@@ -391,13 +378,13 @@ class KeyguardController {
        if (mBeforeUnoccludeTransit != TRANSIT_UNSET
                && dc.mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE
                // TODO(b/113840485): Handle app transition for individual display.
                && isDisplayOccluded(DEFAULT_DISPLAY)) {
                && isKeyguardOccluded(DEFAULT_DISPLAY)) {

            // Reuse old transit in case we are occluding Keyguard again, meaning that we never
            // actually occclude/unocclude Keyguard, but just run a normal transition.
            return mBeforeUnoccludeTransit;
            // TODO(b/113840485): Handle app transition for individual display.
        } else if (!isDisplayOccluded(DEFAULT_DISPLAY)) {
        } else if (!isKeyguardOccluded(DEFAULT_DISPLAY)) {

            // Save transit in case we dismiss/occlude Keyguard shortly after.
            mBeforeUnoccludeTransit = dc.mAppTransition.getAppTransition();
@@ -409,7 +396,7 @@ class KeyguardController {

    private void dismissDockedStackIfNeeded() {
        // TODO(b/113840485): Handle docked stack for individual display.
        if (mKeyguardShowing && isDisplayOccluded(DEFAULT_DISPLAY)) {
        if (mKeyguardShowing && isKeyguardOccluded(DEFAULT_DISPLAY)) {
            // The lock screen is currently showing, but is occluded by a window that can
            // show on top of the lock screen. In this can we want to dismiss the docked
            // stack since it will be complicated/risky to try to put the activity on top
@@ -434,9 +421,9 @@ class KeyguardController {

    private void updateKeyguardSleepToken(int displayId) {
        final KeyguardDisplayState state = getDisplay(displayId);
        if (isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken == null) {
        if (isKeyguardOrAodShowing(displayId) && state.mSleepToken == null) {
            state.acquiredSleepToken();
        } else if (!isKeyguardUnoccludedOrAodShowing(displayId) && state.mSleepToken != null) {
        } else if (!isKeyguardOrAodShowing(displayId) && state.mSleepToken != null) {
            state.releaseSleepToken();
        }
    }