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

Commit f66e6fc5 authored by Zheng Pan's avatar Zheng Pan Committed by Android (Google) Code Review
Browse files

Merge "When wallpaper target is under keyguard, use keyguard" into 24D1-dev

parents b0079067 6f24f35f
Loading
Loading
Loading
Loading
+16 −15
Original line number Original line Diff line number Diff line
@@ -157,14 +157,22 @@ class WallpaperController {
            mFindResults.setUseTopWallpaperAsTarget(true);
            mFindResults.setUseTopWallpaperAsTarget(true);
        }
        }


        if (mService.mPolicy.isKeyguardLocked() && w.canShowWhenLocked()) {
        if (mService.mPolicy.isKeyguardLocked()) {
            if (w.canShowWhenLocked()) {
                if (mService.mPolicy.isKeyguardOccluded() || (useShellTransition
                if (mService.mPolicy.isKeyguardOccluded() || (useShellTransition
                        ? w.inTransition() : mService.mPolicy.isKeyguardUnoccluding())) {
                        ? w.inTransition() : mService.mPolicy.isKeyguardUnoccluding())) {
                // The lowest show when locked window decides whether we need to put the wallpaper
                    // The lowest show-when-locked window decides whether to show wallpaper.
                // behind.
                    mFindResults.mNeedsShowWhenLockedWallpaper = !isFullscreen(w.mAttrs)
                    mFindResults.mNeedsShowWhenLockedWallpaper = !isFullscreen(w.mAttrs)
                            || (w.mActivityRecord != null && !w.mActivityRecord.fillsParent());
                            || (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
        final boolean animationWallpaper = animatingContainer != null
@@ -200,14 +208,7 @@ class WallpaperController {


    private boolean isRecentsTransitionTarget(WindowState w) {
    private boolean isRecentsTransitionTarget(WindowState w) {
        if (w.mTransitionController.isShellTransitionsEnabled()) {
        if (w.mTransitionController.isShellTransitionsEnabled()) {
            // Because the recents activity is invisible in background while keyguard is occluded
            return false;
            // (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());
        }
        }
        // The window is either the recents activity or is in the task animating by the recents.
        // The window is either the recents activity or is in the task animating by the recents.
        final RecentsAnimationController controller = mService.getRecentsAnimationController();
        final RecentsAnimationController controller = mService.getRecentsAnimationController();
+6 −4
Original line number Original line 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.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
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.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeFalse;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -305,12 +307,12 @@ public class WallpaperControllerTests extends WindowTestsBase {
        final WallpaperController wallpaperController = mDisplayContent.mWallpaperController;
        final WallpaperController wallpaperController = mDisplayContent.mWallpaperController;
        wallpaperController.adjustWallpaperWindows();
        wallpaperController.adjustWallpaperWindows();
        // Wallpaper is visible because the show-when-locked activity is translucent.
        // Wallpaper is visible because the show-when-locked activity is translucent.
        assertTrue(wallpaperController.isWallpaperTarget(wallpaperWindow));
        assertSame(wallpaperWindow, wallpaperController.getWallpaperTarget());


        behind.mActivityRecord.setShowWhenLocked(true);
        behind.mActivityRecord.setShowWhenLocked(true);
        wallpaperController.adjustWallpaperWindows();
        wallpaperController.adjustWallpaperWindows();
        // Wallpaper is invisible because the lowest show-when-locked activity is opaque.
        // 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
        // A show-when-locked wallpaper is used for lockscreen. So the top wallpaper should
        // be the one that is not show-when-locked.
        // 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.
        // The activity in restore-below task should not be the target if keyguard is not locked.
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();
        assertNotEquals(appWin, mDisplayContent.mWallpaperController.getWallpaperTarget());
        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();
        doReturn(true).when(mDisplayContent).isKeyguardLocked();
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();
        assertEquals(appWin, mDisplayContent.mWallpaperController.getWallpaperTarget());
        assertNotEquals(appWin, mDisplayContent.mWallpaperController.getWallpaperTarget());
    }
    }


    @Test
    @Test