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

Commit 9d48942c authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Narrow down the condition of wallpaper target for occluded keyguard

Previously, keyguard will be selected as the backup wallpaper target
if there keyguard is locked and there is an active transition. That
is to avoid wallpaper from being show/hide in a short time when
running recents transition to close app on keyguard.

The condition was a bit broad so the regular transition will also
keep wallpaper target on keyguard. Which could make the transition
change mode of wallpaper become CHANGE rather than TO_BACK when
launching an occlude-keyguard app and then display rotates. Which
could make the condition of seamless rotation rejects the seamless
effect because it found wallpaper is a changing operation.

To avoid such case, only enable the condition if there is a transient
(recents) transition.

Bug: 333557024
Test: Enable auto rotation. Set a secured lock. Turn off screen.
      Double click power key to launch camera when holding the
      device in landscape. There should not have a rotation animation.
Test: On a secured keyguard. Double click power key to launch camera.
      Swipe from bottom to dismiss camera. The wallpaper target
      should only change to notification shade once.
Test: atest WallpaperControllerTests#testShowWhenLockedWallpaperTarge

Merged-In: I43a29e828798f36f39d38af130f98de7c5859ec6
Change-Id: I43a29e828798f36f39d38af130f98de7c5859ec6
(cherry picked from commit 275e2758)
parent dcefab81
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -493,6 +493,27 @@ class TransitionController {
        return false;
    }

    /** Returns {@code true} if the display contains a transient-launch transition. */
    boolean hasTransientLaunch(@NonNull DisplayContent dc) {
        if (mCollectingTransition != null && mCollectingTransition.hasTransientLaunch()
                && mCollectingTransition.isOnDisplay(dc)) {
            return true;
        }
        for (int i = mWaitingTransitions.size() - 1; i >= 0; --i) {
            final Transition transition = mWaitingTransitions.get(i);
            if (transition.hasTransientLaunch() && transition.isOnDisplay(dc)) {
                return true;
            }
        }
        for (int i = mPlayingTransitions.size() - 1; i >= 0; --i) {
            final Transition transition = mPlayingTransitions.get(i);
            if (transition.hasTransientLaunch() && transition.isOnDisplay(dc)) {
                return true;
            }
        }
        return false;
    }

    boolean isTransientHide(@NonNull Task task) {
        if (mCollectingTransition != null && mCollectingTransition.isInTransientHide(task)) {
            return true;
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ class WallpaperController {
                            || (w.mActivityRecord != null && !w.mActivityRecord.fillsParent());
                }
            } else if (w.hasWallpaper() && mService.mPolicy.isKeyguardHostWindow(w.mAttrs)
                    && w.mTransitionController.isTransitionOnDisplay(mDisplayContent)) {
                    && w.mTransitionController.hasTransientLaunch(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);
+12 −0
Original line number Diff line number Diff line
@@ -314,6 +314,18 @@ public class WallpaperControllerTests extends WindowTestsBase {
        // Wallpaper is invisible because the lowest show-when-locked activity is opaque.
        assertNull(wallpaperController.getWallpaperTarget());

        // Only transient-launch transition will make notification shade as last resort target.
        // This verifies that regular transition won't choose invisible keyguard as the target.
        final WindowState keyguard = createWindow(null /* parent */,
                WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE, "keyguard");
        keyguard.mAttrs.flags |= FLAG_SHOW_WALLPAPER;
        registerTestTransitionPlayer();
        final Transition transition = wallpaperWindow.mTransitionController.createTransition(
                WindowManager.TRANSIT_CHANGE);
        transition.collect(keyguard);
        wallpaperController.adjustWallpaperWindows();
        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.
        final WindowState wallpaperWindow2 = createWallpaperWindow(mDisplayContent);