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

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

Merge "Checks if an overlay container should be dismissed" into main

parents 06274076 57378016
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -822,11 +822,6 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
        // Checks if container should be updated before apply new parentInfo.
        final boolean shouldUpdateContainer = taskContainer.shouldUpdateContainer(parentInfo);
        taskContainer.updateTaskFragmentParentInfo(parentInfo);
        if (!taskContainer.isVisible()) {
            // Don't update containers if the task is not visible. We only update containers when
            // parentInfo#isVisibleRequested is true.
            return;
        }

        // If the last direct activity of the host task is dismissed and the overlay container is
        // the only taskFragment, the overlay container should also be dismissed.
+27 −1
Original line number Diff line number Diff line
@@ -475,8 +475,10 @@ public class OverlayPresentationTest {
    @Test
    public void testOnTaskFragmentParentInfoChanged_positionOnlyChange_earlyReturn() {
        final TaskFragmentContainer overlayContainer = createTestOverlayContainer(TASK_ID, "test");

        final TaskContainer taskContainer = overlayContainer.getTaskContainer();

        assertThat(taskContainer.getOverlayContainer()).isEqualTo(overlayContainer);

        spyOn(taskContainer);
        final TaskContainer.TaskProperties taskProperties = taskContainer.getTaskProperties();
        final TaskFragmentParentInfo parentInfo = new TaskFragmentParentInfo(
@@ -495,6 +497,30 @@ public class OverlayPresentationTest {
                .that(taskContainer.getOverlayContainer()).isNull();
    }

    @Test
    public void testOnTaskFragmentParentInfoChanged_invisibleTask_callDismissOverlayContainer() {
        final TaskFragmentContainer overlayContainer = createTestOverlayContainer(TASK_ID, "test");
        final TaskContainer taskContainer = overlayContainer.getTaskContainer();

        assertThat(taskContainer.getOverlayContainer()).isEqualTo(overlayContainer);

        spyOn(taskContainer);
        final TaskContainer.TaskProperties taskProperties = taskContainer.getTaskProperties();
        final TaskFragmentParentInfo parentInfo = new TaskFragmentParentInfo(
                new Configuration(taskProperties.getConfiguration()), taskProperties.getDisplayId(),
                false /* visible */, false /* hasDirectActivity */, null /* decorSurface */);

        mSplitController.onTaskFragmentParentInfoChanged(mTransaction, TASK_ID, parentInfo);

        // The parent info must be applied to the task container
        verify(taskContainer).updateTaskFragmentParentInfo(parentInfo);
        verify(mSplitController, never()).updateContainer(any(), any());

        assertWithMessage("The overlay container must still be dismissed even if "
                + "#updateContainer is not called")
                .that(taskContainer.getOverlayContainer()).isNull();
    }

    /**
     * A simplified version of {@link SplitController.ActivityStartMonitor
     * #createOrUpdateOverlayTaskFragmentIfNeeded}