summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java5
-rw-r--r--services/core/java/com/android/server/wm/ActivityStarter.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java34
3 files changed, 44 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 4c392f0906aa..f279221f768c 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -972,6 +972,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (lastLaunchTime == 0) pw.print("0");
else TimeUtils.formatDuration(lastLaunchTime, now, pw);
pw.println();
+ if (mLaunchCookie != null) {
+ pw.print(prefix);
+ pw.print("launchCookie=");
+ pw.println(mLaunchCookie);
+ }
pw.print(prefix); pw.print("mHaveState="); pw.print(mHaveState);
pw.print(" mIcicle="); pw.println(mIcicle);
pw.print(prefix); pw.print("state="); pw.print(mState);
diff --git a/services/core/java/com/android/server/wm/ActivityStarter.java b/services/core/java/com/android/server/wm/ActivityStarter.java
index 1158a9c70158..2ec71d10c36a 100644
--- a/services/core/java/com/android/server/wm/ActivityStarter.java
+++ b/services/core/java/com/android/server/wm/ActivityStarter.java
@@ -2639,6 +2639,11 @@ class ActivityStarter {
intentTask.setWindowingMode(mPreferredWindowingMode);
}
+ // Update the target's launch cookie to those specified in the options if set
+ if (mStartActivity.mLaunchCookie != null) {
+ intentActivity.mLaunchCookie = mStartActivity.mLaunchCookie;
+ }
+
// Need to update mTargetRootTask because if task was moved out of it, the original root
// task may be destroyed.
mTargetRootTask = intentActivity.getRootTask();
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
index 37bc23e6a17d..98260318ea9d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java
@@ -1142,4 +1142,38 @@ public class ActivityStarterTests extends WindowTestsBase {
verify(targetRecord).makeVisibleIfNeeded(null, true);
assertTrue(targetRecord.mVisibleRequested);
}
+
+ @Test
+ public void testLaunchCookie_newAndExistingTask() {
+ final ActivityStarter starter = prepareStarter(0, false);
+
+ // Put an activity on default display as the top focused activity.
+ ActivityRecord r = new ActivityBuilder(mAtm).setCreateTask(true).build();
+
+ // Start an activity with a launch cookie
+ final Binder cookie = new Binder();
+ final ActivityOptions options = ActivityOptions.makeBasic();
+ options.setLaunchCookie(cookie);
+ final Intent intent = new Intent();
+ intent.setComponent(ActivityBuilder.getDefaultComponent());
+ starter.setReason("testLaunchCookie_newTask")
+ .setIntent(intent)
+ .setActivityOptions(options.toBundle())
+ .execute();
+
+ // Verify the cookie is set
+ assertTrue(mRootWindowContainer.topRunningActivity().mLaunchCookie == cookie);
+
+ // Relaunch the activity to bring the task forward
+ final Binder newCookie = new Binder();
+ final ActivityOptions newOptions = ActivityOptions.makeBasic();
+ newOptions.setLaunchCookie(newCookie);
+ starter.setReason("testLaunchCookie_existingTask")
+ .setIntent(intent)
+ .setActivityOptions(newOptions.toBundle())
+ .execute();
+
+ // Verify the cookie is updated
+ assertTrue(mRootWindowContainer.topRunningActivity().mLaunchCookie == newCookie);
+ }
}