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

Commit 269eef85 authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Set Launcher alpha to 0 during Desktop exit transition.

During the Desktop last-window-close exit transition we are
simultaneously
1. closing a Desktop app
2. closing DesktopWallpaperActivity
3. opening LauncherActivity

Since the Desktop app might not cover the entire screen, and
DesktopWallpaperActivity is transparent - the user will see
LauncherActivity beneath those tasks/windows throughout the exit
animation.

Before this CL the alpha of the leash of LauncherActivity was set to 1
at the beginning of the animation (before the Launcher Workspace view
had time to reset its Views), causing a flicker showing the Workspace
view (icons and widgets) for a single frame.
With this CL we set the alpha of the Launcher leash to 0 at the start of
the Desktop exit animation, so the LauncherActivity and its Workspace
won't show until the Workspace view is ready.

Test: manual
Bug: 366153364
Flag: com.android.window.flags.enable_desktop_windowing_exit_transitions
Change-Id: I8e4d7ef01052e2158a644630f85d2f9ec4e9bda4
parent b16fb234
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -22,8 +22,14 @@ import static android.view.WindowManager.TRANSIT_OLD_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS;
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;

import static com.android.internal.util.Preconditions.checkArgument;
import static com.android.wm.shell.shared.TransitionUtil.isClosingMode;
import static com.android.wm.shell.shared.TransitionUtil.isClosingType;
import static com.android.wm.shell.shared.TransitionUtil.isOpeningMode;

import android.os.IBinder;
import android.os.RemoteException;
import android.util.ArrayMap;
@@ -157,6 +163,9 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
                        t.show(wallpapers[i].leash);
                        t.setAlpha(wallpapers[i].leash, 1.f);
                    }
                    if (ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS.isTrue()) {
                        resetLauncherAlphaOnDesktopExit(info, launcherTask, leashMap, t);
                    }
                } else {
                    if (launcherTask != null) {
                        counterLauncher.addChild(t, leashMap.get(launcherTask.getLeash()));
@@ -236,4 +245,33 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
            }
        };
    }

    /**
     * Reset the alpha of the Launcher leash to give the Launcher time to hide its Views before the
     * exit-desktop animation starts.
     *
     * This method should only be called if the current transition is opening Launcher, otherwise we
     * might not be exiting Desktop Mode.
     */
    private static void resetLauncherAlphaOnDesktopExit(
            TransitionInfo info,
            TransitionInfo.Change launcherChange,
            ArrayMap<SurfaceControl, SurfaceControl> leashMap,
            SurfaceControl.Transaction startTransaction
    ) {
        checkArgument(isOpeningMode(launcherChange.getMode()));
        if (!isClosingType(info.getType())) {
            return;
        }
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
            final TransitionInfo.Change change = info.getChanges().get(i);
            // skip changes that we didn't wrap
            if (!leashMap.containsKey(change.getLeash())) continue;
            // Only make the update if we are closing Desktop tasks.
            if (change.getTaskInfo().isFreeform() && isClosingMode(change.getMode())) {
                startTransaction.setAlpha(leashMap.get(launcherChange.getLeash()), 0f);
                return;
            }
        }
    }
}