summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values/attrs_manifest.xml2
-rw-r--r--services/core/java/com/android/server/wm/ActivityStarter.java18
2 files changed, 17 insertions, 3 deletions
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index c51b2d84ab6d..588ae79cda1d 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -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
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 75a188ed86a2..1158a9c70158 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -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;
}
}