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

Commit 4b41d4b9 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Avoid creating wallpaper rotation leash if it is not in transition

Because commitVisibleWallpapers is called before calculateTargets,
it doesn't know whether the wallpaper is a transition participant. And
then because getLeashSurface will create the rotation leash directly,
if the wallpaper doesn't have changes, the leash becomes outside the
management of transition. Which could cause wallpaper to show with
unexpected rotation.

This change moves the operation to be after calculateTargets and
calculateTransitionInfo, so it is confirmed that wallpaper is a
transition participant and the rotation leash (if needed) is also
prepared by calculateTransitionInfo.

Bug: 278097747
Bug: 349966512
Flag: com.android.window.flags.ensure_wallpaper_in_transitions
Test: Close any fixed-rotation task into launcher.
Test: "adb shell device_config override windowing_frontend \
  com.android.window.flags.respect_non_top_visible_fixed_orientation \
  true" Reboot. Launch a translucent landscape on portrait home.
  The wallpaper should keep in portrait.
Change-Id: I4b4ae6d76bbe5615f3fde4b497f93584e22850b4
parent 721c657e
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -1766,7 +1766,19 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        }

        for (int i = 0; i < mTargets.size(); ++i) {
            final DisplayArea da = mTargets.get(i).mContainer.asDisplayArea();
            final WindowContainer<?> wc = mTargets.get(i).mContainer;
            final WallpaperWindowToken wp = wc.asWallpaperToken();
            if (wp != null) {
                // If on a rotation leash, the wallpaper token surface needs to be shown explicitly
                // because shell only gets the leash and the wallpaper token surface is not allowed
                // to be changed by non-transition logic until the transition is finished.
                if (Flags.ensureWallpaperInTransitions() && wp.isVisibleRequested()
                        && wp.getFixedRotationLeash() != null) {
                    transaction.show(wp.mSurfaceControl);
                }
                continue;
            }
            final DisplayArea<?> da = wc.asDisplayArea();
            if (da == null) continue;
            if (da.isVisibleRequested()) {
                mController.mValidateDisplayVis.remove(da);
@@ -2168,14 +2180,6 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
                        && !wallpaperIsOwnTarget(wallpaper)) {
                    wallpaper.setVisibleRequested(false);
                }
                if (showWallpaper && Flags.ensureWallpaperInTransitions()
                        && wallpaper.isVisibleRequested()
                        && getLeashSurface(wallpaper, t) != wallpaper.getSurfaceControl()) {
                    // If on a rotation leash, we need to explicitly show the wallpaper surface
                    // because shell only gets the leash and we don't allow non-transition logic
                    // to touch the surfaces until the transition is over.
                    t.show(wallpaper.getSurfaceControl());
                }
            }
        }
    }