Clear launch root tasks when WM shell is killed
SysUI crashed repeatedly after toggle SystemUIGX when legacy split-screen enabled. NPE was thrown whenever SysUI restarted because the WM Core was unable to add child tasks to the launch root tasks which already being removed from the WM hierarchy. Bug: 180581256 Test: toggle SystemUIGX in split-screen Change-Id: Iede701f8eccfbe726e72273c36bf789e22780d9f
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user