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

Commit 3b2212ad authored by Matt Sziklay's avatar Matt Sziklay
Browse files

Remove matching taskId check from getTaskScreenshots.

To keep multi-instance functionality consistent with taskbar, remove the matching taskId check so Manage Windows will show a screenshot for the task that called it. Ensure that nothing is done if it is clicked on.

Bug: 416911628
Test: Manual; open multi-instance supported app, launch multiple windows then Manage Windows, confirm requesting instance appears in screenshots
Flag: com.android.window.flags.enable_desktop_windowing_multi_instance_features
Change-Id: I34a4edf031888b7f399cd62f037d0ea58105f88e
parent 11538b19
Loading
Loading
Loading
Loading
+19 −17
Original line number Diff line number Diff line
@@ -850,7 +850,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        mBgExecutor.execute(() -> {
            final ArrayList<Pair<Integer, TaskSnapshot>> snapshotList =
                    getTaskSnapshots(decor.mTaskInfo);
            if (!snapshotList.isEmpty()) {
                mMainExecutor.execute(() -> decor.createManageWindowsMenu(snapshotList));
            }
        });
    }

@@ -915,17 +917,17 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                    ActivityManager.RECENT_WITH_EXCLUDED,
                    activityManager.getCurrentUser().id);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
            ProtoLog.e(WM_SHELL_DESKTOP_MODE,
                    "%s: Error getting recent tasks: %s", TAG, e);
            return new ArrayList<>();
        }
        final String callerPackageName = callerTaskInfo.baseActivity.getPackageName();
        for (ActivityManager.RecentTaskInfo info : recentTasks) {
            if (info.taskId == callerTaskInfo.taskId || info.baseActivity == null) continue;
            if (info.baseActivity == null) continue;
            final String infoPackageName = info.baseActivity.getPackageName();
            if (!infoPackageName.equals(callerPackageName)) {
                continue;
            }
            if (info.baseActivity != null) {
                if (callerPackageName.equals(infoPackageName)) {
            // TODO(b/337903443): Fix this returning null for freeform tasks.
            try {
                TaskSnapshot screenshot = activityTaskManagerService
@@ -936,9 +938,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                }
                snapshotList.add(new Pair(info.taskId, screenshot));
            } catch (RemoteException e) {
                        throw new RuntimeException(e);
                    }
                }
                ProtoLog.e(WM_SHELL_DESKTOP_MODE,
                        "%s: Error getting task snapshot for task %d: %s", TAG, info.taskId, e);
                return new ArrayList<>();
            }
        }
        return snapshotList;
+3 −1
Original line number Diff line number Diff line
@@ -1527,7 +1527,9 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    void createManageWindowsMenu(@NonNull List<Pair<Integer, TaskSnapshot>> snapshotList) {
        final Function1<Integer, Unit> onOpenInstanceListener = (requestedTaskId) -> {
            closeManageWindowsMenu();
            if (mTaskInfo.taskId != requestedTaskId) {
                mWindowDecorationActions.onOpenInstance(mTaskInfo, requestedTaskId);
            }
            return Unit.INSTANCE;
        };
        if (mTaskInfo.isFreeform()) {