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

Commit 8e9b0d1a authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Consolidate the check of isolated nav TF" into main

parents 3e372bd1 28159e52
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -292,8 +292,8 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
            // Resets the isolated navigation and updates the container.
            final TransactionRecord transactionRecord = mTransactionManager.startNewTransaction();
            final WindowContainerTransaction wct = transactionRecord.getTransaction();
            mPresenter.setTaskFragmentIsolatedNavigation(wct,
                    containerToUnpin.getTaskFragmentToken(), false /* isolated */);
            mPresenter.setTaskFragmentIsolatedNavigation(wct, containerToUnpin,
                    false /* isolated */);
            updateContainer(wct, containerToUnpin);
            transactionRecord.apply(false /* shouldApplyIndependently */);
            updateCallbackIfNecessary();
@@ -880,14 +880,12 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
            return true;
        }

        // Skip resolving if the activity is on a pinned TaskFragmentContainer.
        // TODO(b/243518738): skip resolving for overlay container.
        final TaskContainer taskContainer = container != null ? container.getTaskContainer() : null;
        if (container != null && taskContainer != null
                && taskContainer.isTaskFragmentContainerPinned(container)) {
        // Skip resolving if the activity is on an isolated navigated TaskFragmentContainer.
        if (container != null && container.isIsolatedNavigationEnabled()) {
            return true;
        }

        final TaskContainer taskContainer = container != null ? container.getTaskContainer() : null;
        if (!isOnReparent && taskContainer != null
                && taskContainer.getTopNonFinishingTaskFragmentContainer(false /* includePin */)
                        != container) {
@@ -1312,15 +1310,12 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
    @GuardedBy("mLock")
    TaskFragmentContainer resolveStartActivityIntent(@NonNull WindowContainerTransaction wct,
            int taskId, @NonNull Intent intent, @Nullable Activity launchingActivity) {
        // Skip resolving if started from pinned TaskFragmentContainer.
        // TODO(b/243518738): skip resolving for overlay container.
        // Skip resolving if started from an isolated navigated TaskFragmentContainer.
        if (launchingActivity != null) {
            final TaskFragmentContainer taskFragmentContainer = getContainerWithActivity(
                    launchingActivity);
            final TaskContainer taskContainer =
                    taskFragmentContainer != null ? taskFragmentContainer.getTaskContainer() : null;
            if (taskContainer != null && taskContainer.isTaskFragmentContainerPinned(
                    taskFragmentContainer)) {
            if (taskFragmentContainer != null
                    && taskFragmentContainer.isIsolatedNavigationEnabled()) {
                return null;
            }
        }
+15 −2
Original line number Diff line number Diff line
@@ -388,13 +388,26 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
            return;
        }

        setTaskFragmentIsolatedNavigation(wct, secondaryContainer.getTaskFragmentToken(),
                !isStacked /* isolatedNav */);
        setTaskFragmentIsolatedNavigation(wct, secondaryContainer, !isStacked /* isolatedNav */);
        if (isStacked && !splitPinRule.isSticky()) {
            secondaryContainer.getTaskContainer().removeSplitPinContainer();
        }
    }

    /**
     * Sets whether to enable isolated navigation for this {@link TaskFragmentContainer}
     */
    void setTaskFragmentIsolatedNavigation(@NonNull WindowContainerTransaction wct,
                                           @NonNull TaskFragmentContainer taskFragmentContainer,
                                           boolean isolatedNavigationEnabled) {
        if (taskFragmentContainer.isIsolatedNavigationEnabled() == isolatedNavigationEnabled) {
            return;
        }
        taskFragmentContainer.setIsolatedNavigationEnabled(isolatedNavigationEnabled);
        setTaskFragmentIsolatedNavigation(wct, taskFragmentContainer.getTaskFragmentToken(),
                isolatedNavigationEnabled);
    }

    /**
     * Resizes the task fragment if it was already registered. Skips the operation if the container
     * creation has not been reported from the server yet.
+13 −0
Original line number Diff line number Diff line
@@ -160,6 +160,9 @@ class TaskFragmentContainer {
     */
    private boolean mHasCrossProcessActivities;

    /** Whether this TaskFragment enable isolated navigation. */
    private boolean mIsIsolatedNavigationEnabled;

    /**
     * @see #TaskFragmentContainer(Activity, Intent, TaskContainer, SplitController,
     * TaskFragmentContainer, String)
@@ -805,6 +808,16 @@ class TaskFragmentContainer {
        mLastCompanionTaskFragment = fragmentToken;
    }

    /** Returns whether to enable isolated navigation or not. */
    boolean isIsolatedNavigationEnabled() {
        return mIsIsolatedNavigationEnabled;
    }

    /** Sets whether to enable isolated navigation or not. */
    void setIsolatedNavigationEnabled(boolean isolatedNavigationEnabled) {
        mIsIsolatedNavigationEnabled = isolatedNavigationEnabled;
    }

    /**
     * Adds the pending appeared activity that has requested to be launched in this task fragment.
     * @see android.app.ActivityClient#isRequestedToLaunchInTaskFragment
+3 −4
Original line number Diff line number Diff line
@@ -551,13 +551,12 @@ public class SplitControllerTest {
    }

    @Test
    public void testResolveStartActivityIntent_skipIfPinned() {
    public void testResolveStartActivityIntent_skipIfIsolatedNavEnabled() {
        final TaskFragmentContainer container = createMockTaskFragmentContainer(mActivity);
        final TaskContainer taskContainer = container.getTaskContainer();
        spyOn(taskContainer);
        container.setIsolatedNavigationEnabled(true);

        final Intent intent = new Intent();
        setupSplitRule(mActivity, intent);
        doReturn(true).when(taskContainer).isTaskFragmentContainerPinned(container);
        assertNull(mSplitController.resolveStartActivityIntent(mTransaction, TASK_ID, intent,
                mActivity));
    }