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

Commit 9a566e3c authored by Josh Yang's avatar Josh Yang
Browse files

Do not bypass wallpaper visibility update during keyguard going away.

Today, KeyguardController explicitly sets the home wallpaper visibility
to visible when keyguard is going away, and wallpaper controller's
visibility update is bypassed during this period.

However, this is redundant and can trigger problems:

1. When keyguard is going away, the WallpaperController already
   correctly sets the home wallpaper to visible. This happens in
   WallpaperController.adjustWallpaperWindows() ->
   WallpaperController.updateWallpaperTokens() where keyguardLocked ==
   false. So it's redundant to explicitly update wallpaper visibility in
   KeyguardController.
2. It's error-prone to assume that keyguard going away animation always
   requires showing home wallpaper. A counter example would be that the
   opening app doesn't have wallpaper. So explicitly setting home
   wallpaper visible is sometimes redundant.
3. We shouldn't skip WallpaperController's visibility update in the middle
   of keyguard going away. See b/290650048#comment6 for an example where
   skipping visibility update causes wallpaper stuck in invisible state.

Bug: 290650048
Test: manual test following scenarios:
      1. On watch, transition is correct between keyguard w/wo wallpaper
         and activity w/wo wallpaper.
Test: atest WallpaperManagerTest
Change-Id: I373760932de76ea89b890e64fbd97fa43600103c
parent fed4f326
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -226,7 +226,6 @@ class KeyguardController {
                final DisplayContent dc = mRootWindowContainer.getDefaultDisplay();
                dc.requestTransitionAndLegacyPrepare(
                        TRANSIT_TO_FRONT, TRANSIT_FLAG_KEYGUARD_APPEARING);
                dc.mWallpaperController.showWallpaperInTransition(false /* showHome */);
                mWindowManager.executeAppTransition();
            }
        }
@@ -283,8 +282,6 @@ class KeyguardController {
                    TRANSIT_TO_BACK, transitFlags, null /* trigger */, dc);
            updateKeyguardSleepToken();

            // Make the home wallpaper visible
            dc.mWallpaperController.showWallpaperInTransition(true /* showHome */);
            // Some stack visibility might change (e.g. docked stack)
            mRootWindowContainer.resumeFocusedTasksTopActivities();
            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
+1 −29
Original line number Diff line number Diff line
@@ -314,31 +314,6 @@ class WallpaperController {
                        || !mWallpaperTarget.mActivityRecord.isWaitingForTransitionStart());
    }

    /**
     * Make one wallpaper visible, according to {@attr showHome}.
     * This is called during the keyguard unlocking transition
     * (see {@link KeyguardController#keyguardGoingAway(int, int)}),
     * or when a keyguard unlock is cancelled (see {@link KeyguardController})
     */
    public void showWallpaperInTransition(boolean showHome) {
        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 the correct wallpaper in transition
            hideWhenLocked.mToken.asWallpaperToken().updateWallpaperWindowsInTransition(showHome);
            showWhenLocked.mToken.asWallpaperToken().updateWallpaperWindowsInTransition(!showHome);
        }
    }

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

        if (!mDisplayContent.isKeyguardGoingAway() || !mIsLockscreenLiveWallpaperEnabled) {
            // When keyguard goes away, KeyguardController handles the visibility
        updateWallpaperTokens(visible, mDisplayContent.isKeyguardLocked());
        }

        if (DEBUG_WALLPAPER) {
            Slog.v(TAG, "adjustWallpaperWindows: wallpaper visibility " + visible
+2 −19
Original line number Diff line number Diff line
@@ -128,20 +128,6 @@ 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",
@@ -212,12 +198,9 @@ class WallpaperWindowToken extends WindowToken {
        commitVisibility(visible);
    }

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

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