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

Commit 3761fe1c authored by Eric Lin's avatar Eric Lin
Browse files

Reset hidden state when reordering bubble task.

When launching a bubbled task A from another bubble B, task A could
sometimes remain hidden. This occurred due to a corner case in
`TaskViewTransitions#prepareOpenAnimation` which sets the task to hidden
before it became visible.

This change addresses the issue by explicitly setting the hidden state
to false when reordering the task without synchronizing visibility with
the force hidden state, which is the path used for bubbles.
Additionally, the parameter `toggleHiddenOnReorder` was renamed to
`syncHiddenWithVisibilityOnReorder` for better clarity.

Bug: 407875076
Flag: com.android.wm.shell.enable_create_any_bubble
Flag: com.android.window.flags.exclude_task_from_recents
Test: atest WMShellUnitTests:TaskViewTransitionsTest
Test: atest WMShellRobolectricTests:BubbleControllerTest
Test: atest WMShellMultivalentTestsOnDevice:BubbleControllerTest
Change-Id: I0aba969c1a856393b4aec614680c14ba1f2f1a98
parent f1fccb2b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -313,7 +313,7 @@ class BubbleControllerTest(flags: FlagsParameterization) {
                taskView,
                true, /* visible */
                true, /* reorder */
                false, /* toggleHiddenOnReorder */
                false, /* syncHiddenWithVisibilityOnReorder */
            )
        } else {
            verify(baseTransitions).setTaskViewVisible(taskView, true /* visible */)
+11 −5
Original line number Diff line number Diff line
@@ -473,7 +473,8 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
    /** See {@link #setTaskViewVisible(TaskViewTaskController, boolean, boolean, boolean)}. */
    public void setTaskViewVisible(TaskViewTaskController taskView, boolean visible,
            boolean reorder) {
        setTaskViewVisible(taskView, visible, reorder, true /* toggleHiddenOnReorder */);
        setTaskViewVisible(taskView, visible, reorder,
                true /* syncHiddenWithVisibilityOnReorder */);
    }

    /**
@@ -484,13 +485,15 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
     *                 be reordered as per the given {@code visible}. For {@code visible = true},
     *                 task will be reordered to top. For {@code visible = false}, task will be
     *                 reordered to the bottom
     * @param toggleHiddenOnReorder Whether to also toggle the hidden state of the task. This only
     *                              takes effect if {@code reorder} is {@code true}.
     * @param syncHiddenWithVisibilityOnReorder Whether to also synchronize the hidden state of
     *                                          the task with the target visibility when
     *                                          reordering. This only takes effect if {@code
     *                                          reorder} is {@code true}.
     * @throws IllegalStateException If the flag {@link FLAG_ENABLE_CREATE_ANY_BUBBLE} and
     *                               {@link FLAG_EXCLUDE_TASK_FROM_RECENTS} are not enabled.
     */
    public void setTaskViewVisible(TaskViewTaskController taskView, boolean visible,
            boolean reorder, boolean toggleHiddenOnReorder) {
            boolean reorder, boolean syncHiddenWithVisibilityOnReorder) {
        final TaskViewRepository.TaskViewState state = useRepo()
                ? mTaskViewRepo.byTaskView(taskView)
                : mTaskViews.get(taskView);
@@ -504,12 +507,15 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV

        final WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.setBounds(taskView.getTaskInfo().token, state.mBounds);
        if (reorder && !toggleHiddenOnReorder) {
        if (reorder && !syncHiddenWithVisibilityOnReorder) {
            if (!BubbleAnythingFlagHelper.enableCreateAnyBubbleWithForceExcludedFromRecents()) {
                throw new IllegalStateException(
                    "Flag " + FLAG_ENABLE_CREATE_ANY_BUBBLE + " and "
                        + FLAG_EXCLUDE_TASK_FROM_RECENTS + " are not enabled");
            }
            // Reset hidden state to fix corner case where surface was destroyed before task
            // appeared in #prepareOpenAnimation.
            wct.setHidden(taskView.getTaskInfo().token, false /* hidden */);
            // Order of setAlwaysOnTop() and reorder() matters; hierarchy ops apply sequentially.
            wct.setAlwaysOnTop(taskView.getTaskInfo().token, visible /* alwaysOnTop */);
        } else {
+3 −2
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ public class TaskViewTransitionsTest extends ShellTestCase {
    }

    @Test
    public void testSetTaskVisibility_reorderNoToggleHidden_resetsAlwaysOnTopAndReorder() {
    public void testSetTaskVisibility_reorderNoHiddenVisibilitySync_resetsAlwaysOnTopAndReorder() {
        assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS);
        assumeTrue(TaskViewTransitions.useRepo());
        assumeTrue(BubbleAnythingFlagHelper.enableCreateAnyBubbleWithForceExcludedFromRecents());
@@ -297,7 +297,7 @@ public class TaskViewTransitionsTest extends ShellTestCase {
        when(mToken.asBinder()).thenReturn(mockBinder);

        mTaskViewTransitions.setTaskViewVisible(mTaskViewTaskController, false /* visible */,
                true /* reorder */, false /* toggleHiddenOnReorder */);
                true /* reorder */, false /* syncHiddenWithVisibilityOnReorder */);

        final TaskViewTransitions.PendingTransition pending =
                mTaskViewTransitions.findPending(mTaskViewTaskController, TRANSIT_TO_BACK);
@@ -306,6 +306,7 @@ public class TaskViewTransitionsTest extends ShellTestCase {
        assertThat(chgs.keySet()).containsExactly(mockBinder);
        assertThat(chgs.get(mockBinder).getConfiguration().windowConfiguration.getBounds())
                .isEqualTo(bounds);
        assertThat(chgs.get(mockBinder).getHidden()).isFalse();
        final List<WindowContainerTransaction.HierarchyOp> ops = pending.mWct.getHierarchyOps();
        assertThat(ops).hasSize(2);
        assertThat(ops.get(0).isAlwaysOnTop()).isFalse();