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

This commit is contained in:
Louis Chang
2021-12-07 14:14:29 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 5 deletions

View File

@@ -1451,11 +1451,11 @@ class Task extends TaskFragment {
}
/** 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");
// Only set this based on the first activity
if (!hadChild) {
if (!hadActivity) {
if (r.getActivityType() == ACTIVITY_TYPE_UNDEFINED) {
// 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

View File

@@ -102,6 +102,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -1670,8 +1671,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
boolean isAddingActivity = child.asActivityRecord() != null;
final Task task = isAddingActivity ? getTask() : null;
// If this task had any child before we added this one.
boolean taskHadChild = task != null && task.hasChild();
// If this task had any activity before we added this one.
boolean taskHadActivity = task != null && task.getActivity(Objects::nonNull) != 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;
@@ -1680,7 +1681,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
if (isAddingActivity && task != null) {
child.asActivityRecord().inHistory = true;
task.onDescendantActivityAdded(taskHadChild, activityType, child.asActivityRecord());
task.onDescendantActivityAdded(taskHadActivity, activityType, child.asActivityRecord());
}
}