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

Commit 409d712e authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Prevents recursively moving activity to a new expanded container" into main

parents cf708e26 a194c10a
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -1334,14 +1334,25 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
        if (shouldContainerBeExpanded(container)) {
            // Make sure that the existing container is expanded.
            mPresenter.expandTaskFragment(wct, container);
        } else {
            return;
        }

        final SplitContainer splitContainer = getActiveSplitForContainer(container);
        if (splitContainer instanceof SplitPinContainer
                && !container.isPinned() && container.getRunningActivityCount() == 1) {
            // This is already the expected state when the pinned container is shown with an
            // expanded activity in a standalone container on the side. Moving the activity into
            // another new expanded container again is not necessary and could result in
            // recursively creating new TaskFragmentContainers if the activity somehow relaunched.
            return;
        }

        // Put activity into a new expanded container.
        final TaskFragmentContainer newContainer =
                new TaskFragmentContainer.Builder(this, getTaskId(activity), activity)
                        .setPendingAppearedActivity(activity).build();
        mPresenter.expandActivity(wct, newContainer.getTaskFragmentToken(), activity);
    }
    }

    /**
     * Whether the given new launched activity is in a split with a rule matched.