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

Commit 9f819162 authored by Jorge Gil's avatar Jorge Gil
Browse files

Desks: Do not separate recent tasks into desks without frontend

Check both flags before grouping tasks into per-desk GroupedTaskInfos,
otherwise if there are multiple desks (which can happend during
debugging or by disconnecting an external display) Launcher might try to
create separate Recents tiles for each desk.

Flag: com.android.window.flags.enable_multiple_desktops_backend
Flag: com.android.window.flags.enable_multiple_desktops_frontend
Bug: 414498479
Test: create additional desk with adb command - verify there is only one
desktop tile in overview

Change-Id: I8d4a1e141b7117fbb56de10cb4f811bdd08e843d
parent fb2a0e97
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.util.Slog;
import android.util.SparseIntArray;
import android.window.DesktopExperienceFlags;
import android.window.DesktopModeFlags;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
@@ -580,10 +579,10 @@ public class RecentTasksController implements TaskStackListenerCallback,
     * displays, without adding any desk tasks. This is a preparation step so that tasks can be
     * added to these desks in `generateList()`.
     *
     * This is needed since with the `ENABLE_MULTIPLE_DESKTOPS_BACKEND` flag, we want to include
     * desk even if they're empty (i.e. have no tasks).
     * This is needed since with the multiple-desktops flags, we want to include desk even if
     * they're empty (i.e. have no tasks).
     *
     * @param multipleDesktopsEnabled whether the multiple desktops backend feature is enabled.
     * @param multipleDesktopsEnabled whether the multiple desktops feature is enabled.
     */
    private void initializeDesksMap(boolean multipleDesktopsEnabled) {
        mTmpDesks.clear();
@@ -610,8 +609,13 @@ public class RecentTasksController implements TaskStackListenerCallback,
    private Desk getOrCreateDesk(int deskId) {
        var desk = mTmpDesks.get(deskId);
        if (desk == null) {
            desk = new Desk(deskId,
                    mDesktopUserRepositories.get().getCurrent().getDisplayForDesk(deskId));
            final int displayId;
            if (deskId == INVALID_DESK_ID) {
                displayId = INVALID_DISPLAY;
            } else {
                displayId = mDesktopUserRepositories.get().getCurrent().getDisplayForDesk(deskId);
            }
            desk = new Desk(deskId, displayId);
            mTmpDesks.put(deskId, desk);
        }
        return desk;
@@ -644,8 +648,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
            ProtoLog.v(WM_SHELL_TASK_OBSERVER, "RecentTasksController.generateList(%s)", reason);
        }

        final boolean multipleDesktopsEnabled =
                DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue();
        final boolean multipleDesktopsEnabled = mDesktopState.enableMultipleDesktops();
        initializeDesksMap(multipleDesktopsEnabled);

        // When the multiple desktops feature is enabled, we include all desks even if they're