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

Commit 8c7454e6 authored by Andrii Kulian's avatar Andrii Kulian Committed by Automerger Merge Worker
Browse files

Merge "Delete dependent TaskFragments in the same transaction" into sc-v2-dev am: f74b9ddc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15456821

Change-Id: I5db565a10e287001cedfa66b30631e031c1f9077
parents 36411b64 f74b9ddc
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
        // Check if there are no running activities - consider the container empty if there are no
        // non-finishing activities left.
        if (!taskFragmentInfo.hasRunningActivity()) {
            cleanupContainer(container, true /* shouldFinishDependent */);
            mPresenter.cleanupContainer(container, true /* shouldFinishDependent */);
            updateCallbackIfNecessary();
        }
    }
@@ -140,7 +140,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
            return;
        }

        cleanupContainer(container, true /* shouldFinishDependent */);
        mPresenter.cleanupContainer(container, true /* shouldFinishDependent */);
        updateCallbackIfNecessary();
    }

@@ -307,13 +307,10 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
        mSplitContainers.add(splitContainer);
    }

    void cleanupContainer(@NonNull TaskFragmentContainer container, boolean shouldFinishDependent) {
        if (container.isFinished()) {
            return;
        }

        container.finish(shouldFinishDependent);

    /**
     * Removes the container from bookkeeping records.
     */
    void removeContainer(@NonNull TaskFragmentContainer container) {
        // Remove all split containers that included this one
        mContainers.remove(container);
        List<SplitContainer> containersToRemove = new ArrayList<>();
@@ -324,8 +321,6 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
            }
        }
        mSplitContainers.removeAll(containersToRemove);

        mPresenter.deleteContainer(container);
    }

    /**
@@ -462,7 +457,7 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
            return false;
        }

        cleanupContainer(splitContainer.getSecondaryContainer(),
        mPresenter.cleanupContainer(splitContainer.getSecondaryContainer(),
                false /* shouldFinishDependent */);
        return true;
    }
+5 −3
Original line number Diff line number Diff line
@@ -68,11 +68,13 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
    }

    /**
     * Deletes the provided container and updates the presentation if necessary.
     * Deletes the specified container and all other associated and dependent containers in the same
     * transaction.
     */
    void deleteContainer(TaskFragmentContainer container) {
    void cleanupContainer(@NonNull TaskFragmentContainer container, boolean shouldFinishDependent) {
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        deleteTaskFragment(wct, container.getTaskFragmentToken());

        container.finish(shouldFinishDependent, this, wct, mController);

        final TaskFragmentContainer newTopContainer = mController.getTopActiveContainer();
        if (newTopContainer != null) {
+10 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.Rect;
import android.os.Binder;
import android.os.IBinder;
import android.window.TaskFragmentInfo;
import android.window.WindowContainerTransaction;

import java.util.ArrayList;
import java.util.List;
@@ -179,7 +180,8 @@ class TaskFragmentContainer {
     * Removes all activities that belong to this process and finishes other containers/activities
     * configured to finish together.
     */
    void finish(boolean shouldFinishDependent) {
    void finish(boolean shouldFinishDependent, @NonNull SplitPresenter presenter,
            @NonNull WindowContainerTransaction wct, @NonNull SplitController controller) {
        if (mIsFinished) {
            return;
        }
@@ -190,13 +192,19 @@ class TaskFragmentContainer {
            activity.finish();
        }

        // Cleanup the visuals
        presenter.deleteTaskFragment(wct, getTaskFragmentToken());
        // Cleanup the records
        controller.removeContainer(this);

        if (!shouldFinishDependent) {
            return;
        }

        // Finish dependent containers
        for (TaskFragmentContainer container : mContainersToFinishOnExit) {
            container.finish(true /* shouldFinishDependent */);
            container.finish(true /* shouldFinishDependent */, presenter,
                    wct, controller);
        }
        mContainersToFinishOnExit.clear();