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

Commit 8219cd56 authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Clean up split state when moving split task to bubble" into main

parents 28cf8606 abd98040
Loading
Loading
Loading
Loading
+39 −15
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip2.phone.transition.PipTransitionUtils;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.splitscreen.SplitScreen;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.splitscreen.StageCoordinator;
import com.android.wm.shell.unfold.UnfoldTransitionHandler;

@@ -353,6 +355,23 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
                transition);
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Animating a mixed transition for "
                + "entering Bubbles while Split-Screen is foreground by %s", handler);

        TransitionInfo.Change bubblingTask = getChangeForBubblingTask(info, bubbleTransitions);
        // find previous split location for other task
        @SplitScreen.StageType int topSplitStageToKeep = SplitScreen.STAGE_TYPE_UNDEFINED;
        for (int i = info.getChanges().size() - 1; i >= 0; i--) {
            TransitionInfo.Change change = info.getChanges().get(i);
            if (change == bubblingTask) continue;
            int prevStage = splitHandler.getSplitItemStage(change.getLastParent());
            if (prevStage != SplitScreen.STAGE_TYPE_UNDEFINED) {
                topSplitStageToKeep = prevStage;
                break;
            }
        }
        splitHandler.prepareDismissAnimation(topSplitStageToKeep,
                SplitScreenController.EXIT_REASON_CHILD_TASK_ENTER_BUBBLE, info, startTransaction,
                finishTransaction);

        // TODO(b/408328557): Migrate to checking transition token
        handler.startAnimation(transition, info, startTransaction, finishTransaction,
                finishCallback);
@@ -367,21 +386,7 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
            @NonNull Transitions.TransitionFinishCallback finishCallback,
            @NonNull BubbleTransitions bubbleTransitions) {
        // Identify the task being launched into a bubble
        TransitionInfo.Change bubblingTask = null;
        for (int i = 0; i < info.getChanges().size(); i++) {
            final TransitionInfo.Change chg = info.getChanges().get(i);
            if (chg.getTaskInfo() != null
                    && chg.getTaskInfo().getActivityType() == ACTIVITY_TYPE_STANDARD) {
                if (!TransitionUtil.isOpeningMode(chg.getMode())
                        && chg.getMode() != TRANSIT_CHANGE) {
                    continue;
                }
                if (!bubbleTransitions.shouldBeAppBubble(chg.getTaskInfo())) {
                    continue;
                }
                bubblingTask = chg;
            }
        }
        TransitionInfo.Change bubblingTask = getChangeForBubblingTask(info, bubbleTransitions);
        if (bubblingTask == null) {
            ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " No bubbling task found");
            return false;
@@ -405,6 +410,25 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
        return true;
    }

    private static @Nullable TransitionInfo.Change getChangeForBubblingTask(
            @NonNull TransitionInfo info, BubbleTransitions bubbleTransitions) {
        for (int i = 0; i < info.getChanges().size(); i++) {
            final TransitionInfo.Change chg = info.getChanges().get(i);
            if (chg.getTaskInfo() != null
                    && chg.getTaskInfo().getActivityType() == ACTIVITY_TYPE_STANDARD) {
                if (!TransitionUtil.isOpeningMode(chg.getMode())
                        && chg.getMode() != TRANSIT_CHANGE) {
                    continue;
                }
                if (!bubbleTransitions.shouldBeAppBubble(chg.getTaskInfo())) {
                    continue;
                }
                return chg;
            }
        }
        return null;
    }

    private boolean animateUnfold(
            @NonNull IBinder transition,
            @NonNull TransitionInfo info,