From c31e994b349de7bada726e00358a2e8d632292e5 Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Mon, 23 May 2022 14:59:05 +0800 Subject: [PATCH] Return the activity type of any child activity in the Task App crashed because the activity type was set to UNDEFINED while the activity was already set to STANDRAD, which is similar to b/228592780. It happened while the task only contains finishing activities. Following commit e79a024, the activity type should be the same with the other activities in the Task even the activity in the Task is currently finishing. Bug: 233550853 Test: Drag settings from taskbar into split Change-Id: I1c1f7b67f019bc1c3a84d38bc0ac6e7c188d1e49 --- services/core/java/com/android/server/wm/TaskFragment.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 22df8b06e398b..324f0296c5ddf 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -103,7 +103,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Objects; import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; @@ -1758,7 +1757,7 @@ class TaskFragment extends WindowContainer { final Task task = isAddingActivity ? getTask() : null; // If this task had any activity before we added this one. - boolean taskHadActivity = task != null && task.getActivity(Objects::nonNull) != null; + boolean taskHadActivity = task != null && task.getTopMostActivity() != null; // getActivityType() looks at the top child, so we need to read the type before adding // a new child in case the new child is on top and UNDEFINED. final int activityType = task != null ? task.getActivityType() : ACTIVITY_TYPE_UNDEFINED; @@ -2171,7 +2170,7 @@ class TaskFragment extends WindowContainer { if (applicationType != ACTIVITY_TYPE_UNDEFINED || !hasChild()) { return applicationType; } - final ActivityRecord activity = getTopNonFinishingActivity(); + final ActivityRecord activity = getTopMostActivity(); return activity != null ? activity.getActivityType() : getTopChild().getActivityType(); }