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

Commit 078804cb authored by Jorge Gil's avatar Jorge Gil
Browse files

Desks: Allow restoring desk root tasks on user switch

Prior logic to save visible root tasks on user-switch to restore to when
switching back did not account for non-leaves not being associated to a
particular user, so this change removes all user checks because
visibility is already only possible for the current user.

This fixes an issue with desktop windowing's desk roots and children not
being restored.

Flag: com.android.window.flags.enable_multiple_desktops_backend
Bug: 404591902
Test: with a desktop open, switch users, switch back, check desktop
tasks are restored

Change-Id: I2d5883a274f8ec09778e9f7d36e08741a077034c
parent 1ff45114
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1856,8 +1856,18 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        if (DesktopModeFlags.ENABLE_TOP_VISIBLE_ROOT_TASK_PER_USER_TRACKING.isTrue()) {
            final IntArray visibleRootTasks = new IntArray();
            forAllRootTasks(rootTask -> {
                if ((mCurrentUser == rootTask.mUserId || rootTask.showForAllUsers())
                        && rootTask.isVisible()) {
                final boolean restoreTask;
                if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue()) {
                    // If the task is visible, it should have activities that are visible to
                    // the current user, so don't check for task's user id since it is
                    // redundant and might accidentally exclude a non-leaf tasks that
                    // aren't associated with one particular user.
                    restoreTask = rootTask.isVisible();
                } else {
                    restoreTask = (mCurrentUser == rootTask.mUserId || rootTask.showForAllUsers())
                            && rootTask.isVisible();
                }
                if (restoreTask) {
                    visibleRootTasks.add(rootTask.getRootTaskId());
                }
            }, /* traverseTopToBottom */ false);