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

Commit 973501cd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move display to bottom only when no next focusable stack"

parents 2e498c24 138ef93c
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -820,8 +820,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
    }

    void positionChildWindowContainerAtBottom(TaskRecord child) {
        // If there are other focusable stacks on the display, the z-order of the display should not
        // be changed just because a task was placed at the bottom. E.g. if it is moving the topmost
        // task to bottom, the next focusable stack on the same display should be focused.
        final ActivityStack nextFocusableStack = getDisplay().getNextFocusableStack(
                child.getStack(), true /* ignoreCurrent */);
        mWindowContainerController.positionChildAtBottom(child.getWindowContainerController(),
                true /* includingParents */);
                nextFocusableStack == null /* includingParents */);
    }

    /**
@@ -1132,8 +1137,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai

        getDisplay().positionChildAtBottom(this, reason);
        if (task != null) {
            // TODO(b/111541062): We probably don't want to change display z-order to bottom just
            // because one of its stacks moved to bottom.
            insertTaskAtBottom(task);
        }
    }
@@ -2912,7 +2915,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
    }

    private void insertTaskAtBottom(TaskRecord task) {
        // Unlike insertTaskAtPosition, this will also position parents of the windowcontroller.
        mTaskHistory.remove(task);
        final int position = getAdjustedPositionForTask(task, 0, null);
        mTaskHistory.add(position, task);
+21 −1
Original line number Diff line number Diff line
@@ -38,9 +38,9 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -252,6 +252,26 @@ public class ActivityStackTests extends ActivityTestsBase {
        assertNotNull(result.mRecord);
    }

    @Test
    public void testMoveStackToBackIncludingParent() {
        final ActivityDisplay display = addNewActivityDisplayAt(ActivityDisplay.POSITION_TOP);
        final ActivityStack stack1 = createStackForShouldBeVisibleTest(display,
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
        final ActivityStack stack2 = createStackForShouldBeVisibleTest(display,
                WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);

        // Do not move display to back because there is still another stack.
        stack2.moveToBack("testMoveStackToBackIncludingParent", stack2.topTask());
        verify(stack2.getWindowContainerController()).positionChildAtBottom(any(),
                eq(false) /* includingParents */);

        // Also move display to back because there is only one stack left.
        display.removeChild(stack1);
        stack2.moveToBack("testMoveStackToBackIncludingParent", stack2.topTask());
        verify(stack2.getWindowContainerController()).positionChildAtBottom(any(),
                eq(true) /* includingParents */);
    }

    @Test
    public void testShouldBeVisible_Fullscreen() throws Exception {
        final TestActivityStack homeStack = createStackForShouldBeVisibleTest(mDefaultDisplay,