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

Commit 6f24f35f authored by Robin Lee's avatar Robin Lee Committed by Cherrypicker Worker
Browse files

When wallpaper target is under keyguard, use keyguard

The case this is specifically aimed at is recent apps over the
lockscreen, where the wallpaper target isn't visible during the
transition or at its end but is replaced by NotificationShade when
it reports finished.

The problem this solves is that the wallpaper visibility cleanup in
Transition.onFinish was run before the NotificationShade had a chance
to make itself wallpaper target, as this was not necessarily
recalculated yet.

For normal app <-> app transitions, wallpaper target is calculated much
earlier during collection. Since keyguard is just a mode of the
notification shade there is no collection to be done for it and so the
wallpaper target change is not knowable upfront.

We don't use the wallpaper as its own target in this case because the
keyguard does not necessarily want a wallpaper - it may become an opaque
window on some form factors / skins.

Bug: 315698413
Test: atest WallpaperControllerTests
Test: atest PlatformScenarioTests:android.platform.test.scenario.sysui.lockscreen.LaunchCameraFromLockScreen
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:719144b3a596a9ca0b7161dfe972eb8843939732)
Merged-In: Iaa631b75d5bc24444bd7c808e0aa056620edcc4b
Change-Id: Iaa631b75d5bc24444bd7c808e0aa056620edcc4b
parent 64ea99b4
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