diff options
| author | 2020-05-14 13:40:16 +0800 | |
|---|---|---|
| committer | 2020-05-14 13:40:16 +0800 | |
| commit | 87ca32eb79e698acbff7fd2977a5f433a8caf711 (patch) | |
| tree | e40e4f70e4cf01ce38015c3b6bb1826352ca0705 | |
| parent | a24033d8aacc8e96b1fadace0ea1e7e0073335a7 (diff) | |
Do not reuse non-leaf tasks for the starting activity
TV Settings activities were started in home stack because home stack
was originally created from TV Settings FallbackHome activity. So, it
was being reused for the Settings activities.
Only looks for the reused task from leaf tasks and also not setting
task affinity on non-leaf tasks.
Bug: 154517501
Test: start Settings activities and not landing on home stack
Change-Id: I07cb0e40248fd2a37f8e9cfe71d13651aed25207
3 files changed, 29 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index c93b7354999b..2aa85c30166b 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -327,7 +327,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> documentData = isDocument ? intent.getData() : null; if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Looking for task of " + target + " in " + parent); - parent.forAllTasks(this); + parent.forAllLeafTasks(this); } void clear() { diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index b9e65137665a..db419c1aae99 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -942,7 +942,7 @@ class Task extends WindowContainer<WindowContainer> { return; } - affinity = info.taskAffinity; + affinity = isLeafTask() ? info.taskAffinity : null; if (intent == null) { // If this task already has an intent associated with it, don't set the root // affinity -- we don't want it changing after initially set, but the initially @@ -3400,6 +3400,24 @@ class Task extends WindowContainer<WindowContainer> { } @Override + boolean forAllLeafTasks(Function<Task, Boolean> callback) { + boolean isLeafTask = true; + for (int i = mChildren.size() - 1; i >= 0; --i) { + final Task child = mChildren.get(i).asTask(); + if (child != null) { + isLeafTask = false; + if (child.forAllLeafTasks(callback)) { + return true; + } + } + } + if (isLeafTask) { + return callback.apply(this); + } + return false; + } + + @Override Task getTask(Predicate<Task> callback, boolean traverseTopToBottom) { final Task t = super.getTask(callback, traverseTopToBottom); if (t != null) return t; diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 3f8d7b5710aa..5d7ec127da46 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -1552,6 +1552,15 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< return false; } + boolean forAllLeafTasks(Function<Task, Boolean> callback) { + for (int i = mChildren.size() - 1; i >= 0; --i) { + if (mChildren.get(i).forAllLeafTasks(callback)) { + return true; + } + } + return false; + } + /** * For all tasks at or below this container call the callback. * |