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

Commit 746a0229 authored by Marzia Favaro's avatar Marzia Favaro Committed by Automerger Merge Worker
Browse files

Merge "Keep track of two top wallpapers to improve the control over each."...

Merge "Keep track of two top wallpapers to improve the control over each." into udc-dev am: a54b7778 am: cfb05591

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22336602



Change-Id: I6a2791ed16a36b8e4a1835381f765d8da4fa631f
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents a56a3a09 cfb05591
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -607,9 +607,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        recordDisplay(wc.getDisplayContent());
        recordDisplay(wc.getDisplayContent());
        if (info.mShowWallpaper) {
        if (info.mShowWallpaper) {
            // Collect the wallpaper token (for isWallpaper(wc)) so it is part of the sync set.
            // Collect the wallpaper token (for isWallpaper(wc)) so it is part of the sync set.
            final WindowState wallpaper =
            final List<WindowState> wallpapers =
                    wc.getDisplayContent().mWallpaperController.getTopVisibleWallpaper();
                    wc.getDisplayContent().mWallpaperController.getAllTopWallpapers();
            if (wallpaper != null) {
            for (int i = wallpapers.size() - 1; i >= 0; i--) {
                WindowState wallpaper = wallpapers.get(i);
                collect(wallpaper.mToken);
                collect(wallpaper.mToken);
            }
            }
        }
        }
+78 −24
Original line number Original line Diff line number Diff line
@@ -124,24 +124,19 @@ class WallpaperController {


    final boolean mIsLockscreenLiveWallpaperEnabled;
    final boolean mIsLockscreenLiveWallpaperEnabled;


    private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> {
    private final Consumer<WindowState> mFindWallpapers = w -> {
        if ((w.mAttrs.type == TYPE_WALLPAPER)) {
        if (w.mAttrs.type == TYPE_WALLPAPER) {
            if (mFindResults.topWallpaper == null || mFindResults.resetTopWallpaper) {
            WallpaperWindowToken token = w.mToken.asWallpaperToken();
            WallpaperWindowToken token = w.mToken.asWallpaperToken();
                if (token == null) {
            if (token.canShowWhenLocked() && !mFindResults.hasTopShowWhenLockedWallpaper()) {
                    Slog.w(TAG, "Window " + w + " has wallpaper type but not wallpaper token");
                mFindResults.setTopShowWhenLockedWallpaper(w);
                    return false;
            } else if (!token.canShowWhenLocked()
                    && !mFindResults.hasTopHideWhenLockedWallpaper()) {
                mFindResults.setTopHideWhenLockedWallpaper(w);
            }
            }
                if (!token.canShowWhenLocked() && mDisplayContent.isKeyguardLocked()) {
                    return false;
                }
                mFindResults.setTopWallpaper(w);
                mFindResults.resetTopWallpaper = false;
            }
            return false;
        }
        }
    };


        mFindResults.resetTopWallpaper = true;
    private final ToBooleanFunction<WindowState> mFindWallpaperTargetFunction = w -> {
        if (!w.mTransitionController.isShellTransitionsEnabled()) {
        if (!w.mTransitionController.isShellTransitionsEnabled()) {
            if (w.mActivityRecord != null && !w.mActivityRecord.isVisible()
            if (w.mActivityRecord != null && !w.mActivityRecord.isVisible()
                    && !w.mActivityRecord.isAnimating(TRANSITION | PARENTS)) {
                    && !w.mActivityRecord.isAnimating(TRANSITION | PARENTS)) {
@@ -668,11 +663,24 @@ class WallpaperController {
            mFindResults.setUseTopWallpaperAsTarget(true);
            mFindResults.setUseTopWallpaperAsTarget(true);
        }
        }


        mDisplayContent.forAllWindows(mFindWallpapers, true /* traverseTopToBottom */);
        mDisplayContent.forAllWindows(mFindWallpaperTargetFunction, true /* traverseTopToBottom */);
        mDisplayContent.forAllWindows(mFindWallpaperTargetFunction, true /* traverseTopToBottom */);


        if (mFindResults.wallpaperTarget == null && mFindResults.useTopWallpaperAsTarget) {
        if (mFindResults.wallpaperTarget == null && mFindResults.useTopWallpaperAsTarget) {
            mFindResults.setWallpaperTarget(mFindResults.topWallpaper);
            mFindResults.setWallpaperTarget(
                    mFindResults.getTopWallpaper(mDisplayContent.isKeyguardLocked()));
        }
    }
    }

    List<WindowState> getAllTopWallpapers() {
        ArrayList<WindowState> wallpapers = new ArrayList<>(2);
        if (mFindResults.hasTopShowWhenLockedWallpaper()) {
            wallpapers.add(mFindResults.mTopWallpaper.mTopShowWhenLockedWallpaper);
        }
        if (mFindResults.hasTopHideWhenLockedWallpaper()) {
            wallpapers.add(mFindResults.mTopWallpaper.mTopHideWhenLockedWallpaper);
        }
        return wallpapers;
    }
    }


    private boolean isFullscreen(WindowManager.LayoutParams attrs) {
    private boolean isFullscreen(WindowManager.LayoutParams attrs) {
@@ -760,10 +768,16 @@ class WallpaperController {
        result.setWallpaperTarget(wallpaperTarget);
        result.setWallpaperTarget(wallpaperTarget);
    }
    }


    /**
     * Change the visibility of the top wallpaper to {@param visibility} and hide all the others.
     */
    private void updateWallpaperTokens(boolean visibility, boolean locked) {
    private void updateWallpaperTokens(boolean visibility, boolean locked) {
        WindowState topWallpaper = mFindResults.getTopWallpaper(locked);
        WallpaperWindowToken topWallpaperToken =
                topWallpaper == null ? null : topWallpaper.mToken.asWallpaperToken();
        for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
        for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
            final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
            final WallpaperWindowToken token = mWallpaperTokens.get(curTokenNdx);
            token.updateWallpaperWindows(visibility && (!locked || token.canShowWhenLocked()));
            token.updateWallpaperWindows(visibility && (token == topWallpaperToken));
        }
        }
    }
    }


@@ -802,7 +816,10 @@ class WallpaperController {
        }
        }


        // Keep both wallpapers visible unless the keyguard is locked (then hide private wp)
        // 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());
            updateWallpaperTokens(visible, mDisplayContent.isKeyguardLocked());
        }


        if (DEBUG_WALLPAPER) {
        if (DEBUG_WALLPAPER) {
            Slog.v(TAG, "adjustWallpaperWindows: wallpaper visibility " + visible
            Slog.v(TAG, "adjustWallpaperWindows: wallpaper visibility " + visible
@@ -1019,14 +1036,52 @@ class WallpaperController {


    /** Helper class for storing the results of a wallpaper target find operation. */
    /** Helper class for storing the results of a wallpaper target find operation. */
    final private static class FindWallpaperTargetResult {
    final private static class FindWallpaperTargetResult {
        WindowState topWallpaper = null;

        static final class TopWallpaper {
            // A wp that can be visible on home screen only
            WindowState mTopHideWhenLockedWallpaper = null;
            // A wallpaper that has permission to be visible on lock screen (lock or shared wp)
            WindowState mTopShowWhenLockedWallpaper = null;

            void reset() {
                mTopHideWhenLockedWallpaper = null;
                mTopShowWhenLockedWallpaper = null;
            }
        }

        TopWallpaper mTopWallpaper = new TopWallpaper();
        boolean useTopWallpaperAsTarget = false;
        boolean useTopWallpaperAsTarget = false;
        WindowState wallpaperTarget = null;
        WindowState wallpaperTarget = null;
        boolean resetTopWallpaper = false;
        boolean isWallpaperTargetForLetterbox = false;
        boolean isWallpaperTargetForLetterbox = false;


        void setTopWallpaper(WindowState win) {
        void setTopHideWhenLockedWallpaper(WindowState win) {
            topWallpaper = win;
            if (DEBUG_WALLPAPER) {
                Slog.v(TAG, "setTopHideWhenLockedWallpaper " + win);
            }
            mTopWallpaper.mTopHideWhenLockedWallpaper = win;
        }

        void setTopShowWhenLockedWallpaper(WindowState win) {
            if (DEBUG_WALLPAPER) {
                Slog.v(TAG, "setTopShowWhenLockedWallpaper " + win);
            }
            mTopWallpaper.mTopShowWhenLockedWallpaper = win;
        }

        boolean hasTopHideWhenLockedWallpaper() {
            return mTopWallpaper.mTopHideWhenLockedWallpaper != null;
        }

        boolean hasTopShowWhenLockedWallpaper() {
            return mTopWallpaper.mTopShowWhenLockedWallpaper != null;
        }

        WindowState getTopWallpaper(boolean isKeyguardLocked) {
            if (!isKeyguardLocked && hasTopHideWhenLockedWallpaper()) {
                return mTopWallpaper.mTopHideWhenLockedWallpaper;
            } else {
                return mTopWallpaper.mTopShowWhenLockedWallpaper;
            }
        }
        }


        void setWallpaperTarget(WindowState win) {
        void setWallpaperTarget(WindowState win) {
@@ -1042,10 +1097,9 @@ class WallpaperController {
        }
        }


        void reset() {
        void reset() {
            topWallpaper = null;
            mTopWallpaper.reset();
            wallpaperTarget = null;
            wallpaperTarget = null;
            useTopWallpaperAsTarget = false;
            useTopWallpaperAsTarget = false;
            resetTopWallpaper = false;
            isWallpaperTargetForLetterbox = false;
            isWallpaperTargetForLetterbox = false;
        }
        }
    }
    }