From f357c0ca514d73273a18b3896e565b2272e608ad Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Mon, 9 Jun 2014 09:23:27 -0700 Subject: [PATCH] Redefine FLAG_ACTIVITY_NEW_DOCUMENT without NEW_TASK Change definition of FLAG_ACTIVITY_NEW_DOCUMENT from FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET to FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET alone. Also add new documentLaunchMode of "never" to allow activity writers to keep their activity from being launched in document mode. Fixes bug 15468528. Change-Id: Ied11adf97e85c5d3f99f4c0bbbb4a2905dcfb24e --- api/current.txt | 5 +- core/java/android/content/Intent.java | 29 +------ .../java/android/content/pm/ActivityInfo.java | 5 ++ core/res/res/values/attrs_manifest.xml | 27 +++++-- .../server/am/ActivityStackSupervisor.java | 77 +++++++++++-------- .../com/android/server/am/TaskRecord.java | 5 +- 6 files changed, 78 insertions(+), 70 deletions(-) diff --git a/api/current.txt b/api/current.txt index 6cbcadceb07e9..bd9f9906997dc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -7533,12 +7533,12 @@ package android.content { field public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 4194304; // 0x400000 field public static final int FLAG_ACTIVITY_CLEAR_TASK = 32768; // 0x8000 field public static final int FLAG_ACTIVITY_CLEAR_TOP = 67108864; // 0x4000000 - field public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 524288; // 0x80000 + field public static final deprecated int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 524288; // 0x80000 field public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 8388608; // 0x800000 field public static final int FLAG_ACTIVITY_FORWARD_RESULT = 33554432; // 0x2000000 field public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 1048576; // 0x100000 field public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 134217728; // 0x8000000 - field public static final int FLAG_ACTIVITY_NEW_DOCUMENT = 268959744; // 0x10080000 + field public static final int FLAG_ACTIVITY_NEW_DOCUMENT = 524288; // 0x80000 field public static final int FLAG_ACTIVITY_NEW_TASK = 268435456; // 0x10000000 field public static final int FLAG_ACTIVITY_NO_ANIMATION = 65536; // 0x10000 field public static final int FLAG_ACTIVITY_NO_HISTORY = 1073741824; // 0x40000000 @@ -7989,6 +7989,7 @@ package android.content.pm { field public static final android.os.Parcelable.Creator CREATOR; field public static final int DOCUMENT_LAUNCH_ALWAYS = 2; // 0x2 field public static final int DOCUMENT_LAUNCH_INTO_EXISTING = 1; // 0x1 + field public static final int DOCUMENT_LAUNCH_NEVER = 3; // 0x3 field public static final int DOCUMENT_LAUNCH_NONE = 0; // 0x0 field public static final int FLAG_ALLOW_TASK_REPARENTING = 64; // 0x40 field public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 8; // 0x8 diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index bd07470ee5835..186c996568a52 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3712,30 +3712,8 @@ public class Intent implements Parcelable, Cloneable { */ public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; /** - * If set, this marks a point in the task's activity stack that should - * be cleared when the task is reset. That is, the next time the task - * is brought to the foreground with - * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of - * the user re-launching it from home), this activity and all on top of - * it will be finished so that the user does not return to them, but - * instead returns to whatever activity preceeded it. - * - *

When this flag is assigned to the root activity all activities up - * to, but not including the root activity, will be cleared. This prevents - * this flag from being used to finish all activities in a task and thereby - * ending the task. - * - *

This is useful for cases where you have a logical break in your - * application. For example, an e-mail application may have a command - * to view an attachment, which launches an image view activity to - * display it. This activity should be part of the e-mail application's - * task, since it is a part of the task the user is involved in. However, - * if the user leaves that task, and later selects the e-mail app from - * home, we may like them to return to the conversation they were - * viewing, not the picture attachment, since that is confusing. By - * setting this flag when launching the image viewer, that viewer and - * any activities it starts will be removed the next time the user returns - * to mail. + * @deprecated As of API 21 this performs identically to + * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. */ public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; /** @@ -3762,8 +3740,7 @@ public class Intent implements Parcelable, Cloneable { * @see android.R.attr#documentLaunchMode * @see #FLAG_ACTIVITY_MULTIPLE_TASK */ - public static final int FLAG_ACTIVITY_NEW_DOCUMENT = - FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | FLAG_ACTIVITY_NEW_TASK; + public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; /** * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} * callback from occurring on the current frontmost activity before it is diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index cfe471265608f..791e5aa46c7f6 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -83,6 +83,11 @@ public class ActivityInfo extends ComponentInfo * the {@link android.R.attr#documentLaunchMode} attribute. */ public static final int DOCUMENT_LAUNCH_ALWAYS = 2; + /** + * Constant corresponding to never in + * the {@link android.R.attr#documentLaunchMode} attribute. + */ + public static final int DOCUMENT_LAUNCH_NEVER = 3; /** * The document launch mode style requested by the activity. From the * {@link android.R.attr#documentLaunchMode} attribute, one of diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 3a0f7670036e0..814d8fc0c8000 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -898,16 +898,22 @@ android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT} to every Intent used to launch the activity. -

The documentLaunchMode attribute may be assigned one of three values, "none", - "intoExisting" and "always", described in detail below. For values other than - none the activity must be defined with - {@link android.R.attr#launchMode} standard or singleTop. +

The documentLaunchMode attribute may be assigned one of four values, "none", + "intoExisting", "always" and "never", described in detail below. For values other than + none and never the activity must be defined with + {@link android.R.attr#launchMode} standard. If this attribute is not specified, none will be used. Note that none can be overridden at run time if the Intent used - to launch it contains the flag {@link android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT}. + to launch it contains the flag {@link android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT + Intent.FLAG_ACTIVITY_NEW_DOCUMENT}. Similarly intoExisting will be overridden by the flag - {@link android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT} combined with - {@link android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK}. --> + {@link android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT + Intent.FLAG_ACTIVITY_NEW_DOCUMENT} combined with + {@link android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK + Intent.FLAG_ACTIVITY_MULTIPLE_TASK}. If the value of + documentLaunchModes is never then any use of +.........{@link android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT + Intent.FLAG_ACTIVITY_NEW_DOCUMENT} to launch this activity will be ignored. --> + +