Merge "Clear launch root tasks when WM shell is killed" into sc-dev

This commit is contained in:
Louis Chang
2021-03-03 09:16:58 +00:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 6 deletions

View File

@@ -5058,6 +5058,10 @@ class Task extends WindowContainer<WindowContainer> {
}
} else {
// No longer managed by any organizer.
final TaskDisplayArea taskDisplayArea = getDisplayArea();
if (taskDisplayArea != null) {
taskDisplayArea.removeLaunchRootTask(this);
}
setForceHidden(FLAG_FORCE_HIDDEN_FOR_TASK_ORG, false /* set */);
if (mCreatedByOrganizer) {
removeImmediately("setTaskOrganizer");

View File

@@ -1135,12 +1135,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
"Can't set not mCreatedByOrganizer as launch root tr=" + rootTask);
}
LaunchRootTaskDef def = null;
for (int i = mLaunchRootTasks.size() - 1; i >= 0; --i) {
if (mLaunchRootTasks.get(i).task.mTaskId != rootTask.mTaskId) continue;
def = mLaunchRootTasks.get(i);
}
LaunchRootTaskDef def = getLaunchRootTaskDef(rootTask);
if (def != null) {
// Remove so we add to the end of the list.
mLaunchRootTasks.remove(def);
@@ -1156,6 +1151,23 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
}
}
void removeLaunchRootTask(Task rootTask) {
LaunchRootTaskDef def = getLaunchRootTaskDef(rootTask);
if (def != null) {
mLaunchRootTasks.remove(def);
}
}
private @Nullable LaunchRootTaskDef getLaunchRootTaskDef(Task rootTask) {
LaunchRootTaskDef def = null;
for (int i = mLaunchRootTasks.size() - 1; i >= 0; --i) {
if (mLaunchRootTasks.get(i).task.mTaskId != rootTask.mTaskId) continue;
def = mLaunchRootTasks.get(i);
break;
}
return def;
}
Task getLaunchRootTask(int windowingMode, int activityType, ActivityOptions options) {
// Try to use the launch root task in options if available.
if (options != null) {