Merge "Fixes re-setting activity type when embed activity in split-screen" into sc-v2-dev am: 35eaf77b5d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16408201

Change-Id: I45bacbdb4cd7b4129928bbc8f6b0ee1362ec4736
This commit is contained in:
Louis Chang
2021-12-07 14:26:34 +00:00
committed by Automerger Merge Worker
2 changed files with 6 additions and 5 deletions

View File

@@ -1454,11 +1454,11 @@ class Task extends TaskFragment {
} }
/** Called when an {@link ActivityRecord} is added as a descendant */ /** Called when an {@link ActivityRecord} is added as a descendant */
void onDescendantActivityAdded(boolean hadChild, int activityType, ActivityRecord r) { void onDescendantActivityAdded(boolean hadActivity, int activityType, ActivityRecord r) {
warnForNonLeafTask("onDescendantActivityAdded"); warnForNonLeafTask("onDescendantActivityAdded");
// Only set this based on the first activity // Only set this based on the first activity
if (!hadChild) { if (!hadActivity) {
if (r.getActivityType() == ACTIVITY_TYPE_UNDEFINED) { if (r.getActivityType() == ACTIVITY_TYPE_UNDEFINED) {
// Normally non-standard activity type for the activity record will be set when the // Normally non-standard activity type for the activity record will be set when the
// object is created, however we delay setting the standard application type until // object is created, however we delay setting the standard application type until

View File

@@ -102,6 +102,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
@@ -1670,8 +1671,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
boolean isAddingActivity = child.asActivityRecord() != null; boolean isAddingActivity = child.asActivityRecord() != null;
final Task task = isAddingActivity ? getTask() : null; final Task task = isAddingActivity ? getTask() : null;
// If this task had any child before we added this one. // If this task had any activity before we added this one.
boolean taskHadChild = task != null && task.hasChild(); boolean taskHadActivity = task != null && task.getActivity(Objects::nonNull) != null;
// getActivityType() looks at the top child, so we need to read the type before adding // 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. // a new child in case the new child is on top and UNDEFINED.
final int activityType = task != null ? task.getActivityType() : ACTIVITY_TYPE_UNDEFINED; final int activityType = task != null ? task.getActivityType() : ACTIVITY_TYPE_UNDEFINED;
@@ -1680,7 +1681,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
if (isAddingActivity && task != null) { if (isAddingActivity && task != null) {
child.asActivityRecord().inHistory = true; child.asActivityRecord().inHistory = true;
task.onDescendantActivityAdded(taskHadChild, activityType, child.asActivityRecord()); task.onDescendantActivityAdded(taskHadActivity, activityType, child.asActivityRecord());
} }
} }