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

Commit 789a230c authored by Kazuki Takise's avatar Kazuki Takise
Browse files

Attach background surface to transition root by default

I02cd3a232350a1dc74e755f9445179ccb216507f changed where the
background color surface is attached to from its transition root
to its task display area to avoid the surface from hiding one of
the split tasks unexpectedly.

However, this doesn't work in freeform mode because when an
activity-to-activity transition happens, the background color
should be rendered inside the parent task. Also, there are some
CTS tests that verify that this surface is rendered within the
task when an activity-to-activity transition happens.

This CL limites the original logic only to the split case.
Having this logic for split is okay in freeform mode too.

Bug: 307705229
Test: atest ActivityTransitionTests
Change-Id: I94f0fb792998574fa9fbc36147d9b83af62a7f0a
parent 80697da8
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.app.ActivityOptions.ANIM_SCENE_TRANSITION;
import static android.app.ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN;
import static android.app.ActivityOptions.ANIM_THUMBNAIL_SCALE_UP;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED;
import static android.app.admin.DevicePolicyManager.EXTRA_RESOURCE_TYPE;
@@ -515,7 +516,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        }

        if (backgroundColorForTransition != 0) {
            addBackgroundColorOnTDA(info, backgroundColorForTransition, startTransaction,
            addBackgroundColor(info, backgroundColorForTransition, startTransaction,
                    finishTransaction);
        }

@@ -546,7 +547,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        return true;
    }

    private void addBackgroundColorOnTDA(@NonNull TransitionInfo info,
    private void addBackgroundColor(@NonNull TransitionInfo info,
            @ColorInt int color, @NonNull SurfaceControl.Transaction startTransaction,
            @NonNull SurfaceControl.Transaction finishTransaction) {
        final Color bgColor = Color.valueOf(color);
@@ -558,9 +559,19 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                    .setName("animation-background")
                    .setCallsite("DefaultTransitionHandler")
                    .setColorLayer();
            final SurfaceControl backgroundSurface = colorLayerBuilder.build();

            // Attaching the background surface to the transition root could unexpectedly make it
            // cover one of the split root tasks. To avoid this, put the background surface just
            // above the display area when split is on.
            final boolean isSplitTaskInvolved =
                    info.getChanges().stream().anyMatch(c-> c.getTaskInfo() != null
                            && c.getTaskInfo().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW);
            if (isSplitTaskInvolved) {
                mRootTDAOrganizer.attachToDisplayArea(displayId, colorLayerBuilder);
            final SurfaceControl backgroundSurface = colorLayerBuilder.build();
            } else {
                startTransaction.reparent(backgroundSurface, info.getRootLeash());
            }
            startTransaction.setColor(backgroundSurface, colorArray)
                    .setLayer(backgroundSurface, -1)
                    .show(backgroundSurface);