From e79a02435d53de0398170cbfd57755c9dabca6c8 Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Mon, 18 Apr 2022 16:26:40 +0800 Subject: [PATCH] Fixes un-setting activity type when embed activity in split-screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An exception was thrown by launching the split-screen from the recent app. It happens while embedding activities in split-screen. System reparent the tasks from split-root to displayArea when return to home screen. The reparent’s action is ignored while dealing with the task whose activity’s type is TYPE_UNDEFINED. Split-screen shell expects the task of activityType is TYPE_STANDARD. That’s why the system throws the legal argument exception because the task is already a child of the root task. The CL looks for the top non-finish activity first before the top child in the task for resolving the task activity type. For example, when add child into TaskFrag#2, this CL resolve the activity type from activity#1 of Task#49. -- Task#49 -- TaskFrag#2 -- activity#2 -- TaskFrag#1 -- activity#1 Bug: 228592780 Test: 1.Drag settings from taskbar into split and launch DWB 2.Return to home and launch the split-screen. Change-Id: I69960b34c909071ce0cce5ff11c630faf6106f6c --- services/core/java/com/android/server/wm/TaskFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index e0346544d528e..15cd296a13b91 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -2144,7 +2144,8 @@ class TaskFragment extends WindowContainer { if (applicationType != ACTIVITY_TYPE_UNDEFINED || !hasChild()) { return applicationType; } - return getTopChild().getActivityType(); + final ActivityRecord activity = getTopNonFinishingActivity(); + return activity != null ? activity.getActivityType() : getTopChild().getActivityType(); } @Override