Loading services/core/java/com/android/server/wm/ActivityRecord.java +5 −0 Original line number Diff line number Diff line Loading @@ -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); Loading services/core/java/com/android/server/wm/ActivityStarter.java +5 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +34 −0 Original line number Diff line number Diff line Loading @@ -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); } } Loading
services/core/java/com/android/server/wm/ActivityRecord.java +5 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
services/core/java/com/android/server/wm/ActivityStarter.java +5 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading
services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +34 −0 Original line number Diff line number Diff line Loading @@ -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); } }