From 9d4e9bcebbd97ad51daa0ef15cfba5aabb399bbb Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Wed, 18 Jun 2014 18:34:56 -0700 Subject: Allow a root activity to relinquish task identity If a an acitivty with attribute android:relinquishTaskIdentity true is the root activity of a task then the intent of that task will be that of the first activity in the stack with android:relinquishTaskIdentity set false. The ability to set intent also includes the ability to set the TaskDescription of the task. Fixes bug 15675610. Fixes bug 10428661. Change-Id: Ib28a9eae3b9832eeeef9106adbebe344184ee5ae --- api/current.txt | 2 + core/java/android/content/pm/ActivityInfo.java | 7 +++ core/java/android/content/pm/PackageParser.java | 6 +++ core/res/AndroidManifest.xml | 3 +- core/res/res/values/attrs_manifest.xml | 9 ++++ core/res/res/values/public.xml | 1 + .../java/com/android/server/am/ActivityRecord.java | 13 ++--- .../java/com/android/server/am/ActivityStack.java | 46 +++-------------- .../java/com/android/server/am/TaskRecord.java | 60 +++++++++++++++++++--- 9 files changed, 91 insertions(+), 56 deletions(-) diff --git a/api/current.txt b/api/current.txt index 3b311e31ca0f..03b301335ac8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -957,6 +957,7 @@ package android { field public static final int ratingBarStyleIndicator = 16843280; // 0x1010210 field public static final int ratingBarStyleSmall = 16842877; // 0x101007d field public static final int readPermission = 16842759; // 0x1010007 + field public static final int relinquishTaskIdentity = 16843893; // 0x1010475 field public static final int repeatCount = 16843199; // 0x10101bf field public static final int repeatMode = 16843200; // 0x10101c0 field public static final int reqFiveWayNav = 16843314; // 0x1010232 @@ -8085,6 +8086,7 @@ package android.content.pm { field public static final int FLAG_IMMERSIVE = 2048; // 0x800 field public static final int FLAG_MULTIPROCESS = 1; // 0x1 field public static final int FLAG_NO_HISTORY = 128; // 0x80 + field public static final int FLAG_RELINQUISH_TASK_IDENTITY = 4096; // 0x1000 field public static final int FLAG_SINGLE_USER = 1073741824; // 0x40000000 field public static final int FLAG_STATE_NOT_NEEDED = 16; // 0x10 field public static final int LAUNCH_MULTIPLE = 0; // 0x0 diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index abc8cde2c9eb..bcf1e8760e75 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -251,6 +251,13 @@ public class ActivityInfo extends ComponentInfo * @see android.app.Activity#setImmersive(boolean) */ public static final int FLAG_IMMERSIVE = 0x0800; + /** + * Bit in {@link #flags}: If set, a task rooted at this activity will have its + * baseIntent replaced by the activity immediately above this. Each activity may further + * relinquish its identity to the activity above it using this flag. Set from the + * android.R.attr#relinquishTaskIdentity attribute. + */ + public static final int FLAG_RELINQUISH_TASK_IDENTITY = 0x1000; /** * Bit in {@link #flags} indicating that tasks started with this activity are to be * removed from the recent list of tasks when the last activity in the task is finished. diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index 0b336d011692..b40a441a88d6 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -2629,6 +2629,12 @@ public class PackageParser { false)) { a.info.flags |= ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS; } + + if (sa.getBoolean( + com.android.internal.R.styleable.AndroidManifestActivity_relinquishTaskIdentity, + false)) { + a.info.flags |= ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY; + } } else { a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE; a.info.configChanges = 0; diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 8b5dff014e19..fa1a563e43b9 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2742,7 +2742,8 @@ android:finishOnCloseSystemDialogs="true" android:excludeFromRecents="true" android:multiprocess="true" - android:documentLaunchMode="never"> + android:documentLaunchMode="never" + android:relinquishTaskIdentity="true"> diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 4e06d9a03c5e..fc1d0df86f46 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -985,6 +985,14 @@ Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS} --> + + +