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

Commit e6c74e81 authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "When wallpaper target is under keyguard, use keyguard" into main

parents 69a6ce97 719144b3
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -157,14 +157,22 @@ class WallpaperController {
            mFindResults.setUseTopWallpaperAsTarget(true);
        }

        if (mService.mPolicy.isKeyguardLocked() && w.canShowWhenLocked()) {
        if (mService.mPolicy.isKeyguardLocked()) {
            if (w.canShowWhenLocked()) {
                if (mService.mPolicy.isKeyguardOccluded() || (useShellTransition
                        ? w.inTransition() : mService.mPolicy.isKeyguardUnoccluding())) {
                // The lowest show when locked window decides whether we need to put the wallpaper
                // behind.
                    // The lowest show-when-locked window decides whether to show wallpaper.
                    mFindResults.mNeedsShowWhenLockedWallpaper = !isFullscreen(w.mAttrs)
                            || (w.mActivityRecord != null && !w.mActivityRecord.fillsParent());
                }
            } else if (w.hasWallpaper() && mService.mPolicy.isKeyguardHostWindow(w.mAttrs)
                    && w.mTransitionController.isTransitionOnDisplay(mDisplayContent)) {
                // If we have no candidates at all, notification shade is allowed to be the target
                // of last resort even if it has not been made visible yet.
                if (DEBUG_WALLPAPER) Slog.v(TAG, "Found keyguard as wallpaper target: " + w);
                mFindResults.setWallpaperTarget(w);
                return false;
            }
        }

        final boolean animationWallpaper = animatingContainer != null
@@ -200,14 +208,7 @@ class WallpaperController {

    private boolean isRecentsTransitionTarget(WindowState w) {
        if (w.mTransitionController.isShellTransitionsEnabled()) {
            // Because the recents activity is invisible in background while keyguard is occluded
            // (the activity window is on screen while keyguard is locked) with recents animation,
            // the task animating by recents needs to be wallpaper target to make wallpaper visible.
            // While for unlocked case, because recents activity will be moved to top, it can be
            // the wallpaper target naturally.
            return w.mActivityRecord != null && w.mAttrs.type == TYPE_BASE_APPLICATION
                    && mDisplayContent.isKeyguardLocked()
                    && w.mTransitionController.isTransientHide(w.getTask());
            return false;
        }
        // The window is either the recents activity or is in the task animating by the recents.
        final RecentsAnimationController controller = mService.getRecentsAnimationController();
+6 −4
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -305,12 +307,12 @@ public class WallpaperControllerTests extends WindowTestsBase {
        final WallpaperController wallpaperController = mDisplayContent.mWallpaperController;
        wallpaperController.adjustWallpaperWindows();
        // Wallpaper is visible because the show-when-locked activity is translucent.
        assertTrue(wallpaperController.isWallpaperTarget(wallpaperWindow));
        assertSame(wallpaperWindow, wallpaperController.getWallpaperTarget());

        behind.mActivityRecord.setShowWhenLocked(true);
        wallpaperController.adjustWallpaperWindows();
        // Wallpaper is invisible because the lowest show-when-locked activity is opaque.
        assertTrue(wallpaperController.isWallpaperTarget(null));
        assertNull(wallpaperController.getWallpaperTarget());

        // A show-when-locked wallpaper is used for lockscreen. So the top wallpaper should
        // be the one that is not show-when-locked.
@@ -374,10 +376,10 @@ public class WallpaperControllerTests extends WindowTestsBase {
        // The activity in restore-below task should not be the target if keyguard is not locked.
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();
        assertNotEquals(appWin, mDisplayContent.mWallpaperController.getWallpaperTarget());
        // The activity in restore-below task should be the target if keyguard is occluded.
        // The activity in restore-below task should not be the target if keyguard is occluded.
        doReturn(true).when(mDisplayContent).isKeyguardLocked();
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();
        assertEquals(appWin, mDisplayContent.mWallpaperController.getWallpaperTarget());
        assertNotEquals(appWin, mDisplayContent.mWallpaperController.getWallpaperTarget());
    }

    @Test