Merge "Do not override MULTIPLE_TASK flag for singleInstancePerTask" into sc-dev

This commit is contained in:
Louis Chang
2021-04-15 07:35:23 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 3 deletions

View File

@@ -826,7 +826,7 @@
that created the task, and therefore there will only be one instance of this activity
in a task. In constrast to the {@code singleTask} launch mode, this activity can be
started in multiple instances in different tasks if the
{@code FLAG_ACTIVITY_MULTIPLE_TASK} is set.-->
{@code FLAG_ACTIVITY_MULTIPLE_TASK} or {@code FLAG_ACTIVITY_NEW_DOCUMENT} is set.-->
<enum name="singleInstancePerTask" value="4" />
</attr>
<!-- Specify the orientation an activity should be run in. If not

View File

@@ -2721,8 +2721,22 @@ class ActivityStarter {
launchFlags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
break;
case ActivityInfo.DOCUMENT_LAUNCH_NEVER:
launchFlags &=
~(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | FLAG_ACTIVITY_MULTIPLE_TASK);
if (mLaunchMode == LAUNCH_SINGLE_INSTANCE_PER_TASK) {
// Remove MULTIPLE_TASK flag along with NEW_DOCUMENT only if NEW_DOCUMENT
// is set, otherwise we still want to keep the MULTIPLE_TASK flag (if
// any) for singleInstancePerTask that the multiple tasks can be created,
// or a singleInstancePerTask activity is basically the same as a
// singleTask activity when documentLaunchMode set to never.
if ((launchFlags & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
launchFlags &= ~(Intent.FLAG_ACTIVITY_NEW_DOCUMENT
| FLAG_ACTIVITY_MULTIPLE_TASK);
}
} else {
// TODO(b/184903976): Should FLAG_ACTIVITY_MULTIPLE_TASK always be
// removed for document-never activity?
launchFlags &=
~(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | FLAG_ACTIVITY_MULTIPLE_TASK);
}
break;
}
}