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

Commit 4500e0a7 authored by Marzia Favaro's avatar Marzia Favaro
Browse files

Include the wallpaper visibility change in the existing keyguard

unlocking transition

Bug: 268136910
Bug: 279265182
Test: WallpaperManagerTest

Change-Id: I6904badcfa51d083693fac2079aedc006d3aff64
parent 8d5384a5
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -507,8 +507,12 @@ public class Transitions implements RemoteCallable<Transitions> {
            final int layer;
            // Put all the OPEN/SHOW on top
            if ((change.getFlags() & FLAG_IS_WALLPAPER) != 0) {
                // Wallpaper is always at the bottom.
                layer = -zSplitLine;
                // Wallpaper is always at the bottom, opening wallpaper on top of closing one.
                if (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT) {
                    layer = -zSplitLine + numChanges - i;
                } else {
                    layer = -zSplitLine - i;
                }
            } else if (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT) {
                if (isOpening) {
                    // put on top
+2 −0
Original line number Diff line number Diff line
@@ -269,6 +269,8 @@ class KeyguardController {
                    TRANSIT_TO_BACK, transitFlags, null /* trigger */, dc);
            updateKeyguardSleepToken();

            // Make the home wallpaper visible
            dc.mWallpaperController.showHomeWallpaperInTransition();
            // Some stack visibility might change (e.g. docked stack)
            mRootWindowContainer.resumeFocusedTasksTopActivities();
            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
+26 −0
Original line number Diff line number Diff line
@@ -1283,6 +1283,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        // ActivityRecord#canShowWindows() may reject to show its window. The visibility also
        // needs to be updated for STATE_ABORT.
        commitVisibleActivities(transaction);
        commitVisibleWallpapers();

        // Fall-back to the default display if there isn't one participating.
        final DisplayContent primaryDisplay = !mTargetDisplays.isEmpty() ? mTargetDisplays.get(0)
@@ -1315,6 +1316,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        }
        // Resolve the animating targets from the participants.
        mTargets = calculateTargets(mParticipants, mChanges);

        // Check whether the participants were animated from back navigation.
        mController.mAtm.mBackNavigationController.onTransactionReady(this, mTargets);
        final TransitionInfo info = calculateTransitionInfo(mType, mFlags, mTargets, transaction);
@@ -1591,6 +1593,30 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        }
    }

    /**
     * Reset waitingToshow for all wallpapers, and commit the visibility of the visible ones
     */
    private void commitVisibleWallpapers() {
        boolean showWallpaper = shouldWallpaperBeVisible();
        for (int i = mParticipants.size() - 1; i >= 0; --i) {
            final WallpaperWindowToken wallpaper = mParticipants.valueAt(i).asWallpaperToken();
            if (wallpaper != null) {
                wallpaper.waitingToShow = false;
                if (!wallpaper.isVisible() && wallpaper.isVisibleRequested()) {
                    wallpaper.commitVisibility(showWallpaper);
                }
            }
        }
    }

    private boolean shouldWallpaperBeVisible() {
        for (int i = mParticipants.size() - 1; i >= 0; --i) {
            WindowContainer participant = mParticipants.valueAt(i);
            if (participant.showWallpaper()) return true;
        }
        return false;
    }

    // TODO(b/188595497): Remove after migrating to shell.
    /** @see RecentsAnimationController#attachNavigationBarToApp */
    private void handleLegacyRecentsStartBehavior(DisplayContent dc, TransitionInfo info) {
+25 −1
Original line number Diff line number Diff line
@@ -339,6 +339,31 @@ class WallpaperController {
        }
    }

    /**
     * Change the visibility if wallpaper is home screen only.
     * This is called during the keyguard unlocking transition
     * (see {@link KeyguardController#keyguardGoingAway(int, int)}) and thus assumes that if the
     * system wallpaper is shared with lock, then it needs no animation.
     */
    public void showHomeWallpaperInTransition() {
        updateWallpaperWindowsTarget(mFindResults);

        if (!mFindResults.hasTopShowWhenLockedWallpaper()) {
            Slog.w(TAG, "There is no wallpaper for the lock screen");
            return;
        }
        WindowState hideWhenLocked = mFindResults.mTopWallpaper.mTopHideWhenLockedWallpaper;
        WindowState showWhenLocked = mFindResults.mTopWallpaper.mTopShowWhenLockedWallpaper;
        if (!mFindResults.hasTopHideWhenLockedWallpaper()) {
            // Shared wallpaper, ensure its visibility
            showWhenLocked.mToken.asWallpaperToken().updateWallpaperWindows(true);
        } else {
            // Separate lock and home wallpapers: show home wallpaper and hide lock
            hideWhenLocked.mToken.asWallpaperToken().updateWallpaperWindowsInTransition(true);
            showWhenLocked.mToken.asWallpaperToken().updateWallpaperWindowsInTransition(false);
        }
    }

    void hideDeferredWallpapersIfNeededLegacy() {
        for (int i = mWallpaperTokens.size() - 1; i >= 0; i--) {
            final WallpaperWindowToken token = mWallpaperTokens.get(i);
@@ -815,7 +840,6 @@ class WallpaperController {
            }
        }

        // Keep both wallpapers visible unless the keyguard is locked (then hide private wp)
        if (!mDisplayContent.isKeyguardGoingAway() || !mIsLockscreenLiveWallpaperEnabled) {
            // When keyguard goes away, KeyguardController handles the visibility
            updateWallpaperTokens(visible, mDisplayContent.isKeyguardLocked());
+17 −3
Original line number Diff line number Diff line
@@ -128,6 +128,20 @@ class WallpaperWindowToken extends WindowToken {
        }
    }

    /**
     * Update the visibility of the token to {@param visible}. If a transition will collect the
     * wallpaper, then the visibility will be committed during the execution of the transition.
     *
     * waitingToShow is reset at the beginning of the transition:
     * {@link Transition#onTransactionReady(int, SurfaceControl.Transaction)}
     */
    void updateWallpaperWindowsInTransition(boolean visible) {
        if (mTransitionController.isCollecting() && mVisibleRequested != visible) {
            waitingToShow = true;
        }
        updateWallpaperWindows(visible);
    }

    void updateWallpaperWindows(boolean visible) {
        if (mVisibleRequested != visible) {
            ProtoLog.d(WM_DEBUG_WALLPAPER, "Wallpaper token %s visible=%b",
@@ -199,11 +213,11 @@ class WallpaperWindowToken extends WindowToken {
    }

    /**
     * Commits the visibility of this token. This will directly update the visibility without
     * regard for other state (like being in a transition).
     * Commits the visibility of this token. This will directly update the visibility unless the
     * wallpaper is in a transition.
     */
    void commitVisibility(boolean visible) {
        if (visible == isVisible()) return;
        if (visible == isVisible() || waitingToShow) return;

        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "commitVisibility: %s: visible=%b mVisibleRequested=%b", this,