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

Commit b9df0ebc authored by wilsonshih's avatar wilsonshih
Browse files

Polish close translucent task animation when combines with other changes.

When closing a translucent activity, it typically triggers a single
"close" transition. However, if that activity also launches another
activity, the original task beneath the translucent activity will also
participate in the transition, affecting the z-order of the transiton.
- Do not adjust focus task while finish activity, which can affects the
order before next change become visible.
- Keep the wallpaper always at the bottom in Shell.
- Choose cross-fade animation when a close wallpaper transition includes
an open target.

Flag: com.android.window.flags.polish_close_wallpaper_includes_open_change
Bug: 421436197
Test: 1. Launch a translucent activity.
2. Finish the translucent activity, and then launch a new task from it.
3. Verify the translucent activity remain on top, and play cross-fade
animation between open-close targets.

Change-Id: I1f6d52af00c50dc8c83b3eaceabab8950e15e3a0
parent 904b96b1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -466,6 +466,16 @@ flag {
    }
}

flag {
    name: "polish_close_wallpaper_includes_open_change"
    namespace: "windowing_frontend"
    description: "Record the initial z-order while collecting window containers, keep the wallpaper always at the bottom, and use a cross-fade animation when a close wallpaper transition includes an open target."
    bug: "421436197"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "predictive_back_callback_cancellation_fix"
    namespace: "windowing_frontend"
+15 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.TransitionInfo.FLAGS_IS_NON_APP_WINDOW;
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;
import static android.window.TransitionInfo.FLAG_TRANSLUCENT;

import static com.android.internal.policy.TransitionAnimation.WALLPAPER_TRANSITION_CLOSE;
@@ -46,6 +47,7 @@ import android.view.InsetsSource;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.window.TransitionInfo;

@@ -163,6 +165,19 @@ public class TransitionAnimationHelper {
        }

        Animation a = null;
        if (com.android.window.flags.Flags.polishCloseWallpaperIncludesOpenChange()) {
            if (animAttr == R.styleable.WindowAnimation_wallpaperCloseExitAnimation) {
                // A closing wallpaper doesn't need an animation.
                if (change.hasFlags(FLAG_IS_WALLPAPER)) {
                    animAttr = 0;
                } else {
                    // TODO (b/421436197): Modify wallpaper_close_exit.xml when clean up the flag.
                    a = new AlphaAnimation(1.0f /* fromAlpha */, 0.0f /* toAlpha */);
                    a.setDuration(275 /* durationMillis */);
                    return a;
                }
            }
        }
        if (animAttr != 0) {
            if (overrideType == ANIM_FROM_STYLE && !isTask) {
                final TransitionInfo.AnimationOptions.CustomActivityTransition customTransition =
+2 −1
Original line number Diff line number Diff line
@@ -618,7 +618,8 @@ public class Transitions implements RemoteCallable<Transitions>,
                return zSplitLine + numChanges - i;
            }
        } else if (mode == TRANSIT_CLOSE || mode == TRANSIT_TO_BACK) {
            if (isOpening) {
            if (isOpening || (change.hasFlags(FLAG_IS_WALLPAPER)
                    && com.android.window.flags.Flags.polishCloseWallpaperIncludesOpenChange())) {
                // put on bottom and leave visible
                return zSplitLine - i;
            } else {
+2 −1
Original line number Diff line number Diff line
@@ -3590,7 +3590,8 @@ final class ActivityRecord extends WindowToken {
        }

        final Task rootTask = getRootTask();
        final boolean mayAdjustTop = (isState(RESUMED) || rootTask.getTopResumedActivity() == null)
        final boolean mayAdjustTop = !Flags.polishCloseWallpaperIncludesOpenChange()
                && (isState(RESUMED) || rootTask.getTopResumedActivity() == null)
                && rootTask.isFocusedRootTaskOnDisplay()
                // Do not adjust focus task because the task will be reused to launch new activity.
                && !task.isClearingToReuseTask();