Loading services/core/java/com/android/server/wm/ActivityStarter.java +7 −4 Original line number Diff line number Diff line Loading @@ -293,7 +293,8 @@ class ActivityStarter { private IVoiceInteractor mVoiceInteractor; // Last activity record we attempted to start private ActivityRecord mLastStartActivityRecord; @VisibleForTesting ActivityRecord mLastStartActivityRecord; // The result of the last activity we attempted to start. private int mLastStartActivityResult; // Time in milli seconds we attempted to start the last activity. Loading Loading @@ -2010,9 +2011,6 @@ class ActivityStarter { activity.destroyIfPossible("Removes redundant singleInstance"); } } if (mLastStartActivityRecord != null) { targetTaskTop.mLaunchSourceType = mLastStartActivityRecord.mLaunchSourceType; } recordTransientLaunchIfNeeded(targetTaskTop); // Recycle the target task for this launch. startResult = Loading Loading @@ -2451,6 +2449,11 @@ class ActivityStarter { ? targetTask.getTopNonFinishingActivity() : targetTaskTop; // The mLastStartActivityRecord isn't added to task, update latest launch source to top // activity before creating starting window. if (mLastStartActivityRecord != null && targetTaskTop != mLastStartActivityRecord) { targetTaskTop.mLaunchSourceType = mLastStartActivityRecord.mLaunchSourceType; } if (mMovedToFront) { // We moved the task to front, use starting window to hide initial drawn delay. targetTaskTop.showStartingWindow(true /* taskSwitch */); Loading services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +16 −0 Original line number Diff line number Diff line Loading @@ -1780,6 +1780,22 @@ public class ActivityStarterTests extends WindowTestsBase { assertNotEquals(inTask, target.getTask()); } @Test public void testLaunchActivitySourceRemain() { final ActivityStarter starter = prepareStarter(0, false); final ActivityRecord baseActivity = new ActivityBuilder(mAtm) .setCreateTask(true) .build(); baseActivity.mLaunchSourceType = ActivityRecord.LAUNCH_SOURCE_TYPE_HOME; final ActivityRecord targetRecord = new ActivityBuilder(mAtm).build(); targetRecord.mLaunchSourceType = ActivityRecord.LAUNCH_SOURCE_TYPE_APPLICATION; starter.mLastStartActivityRecord = targetRecord; startActivityInner(starter, targetRecord, baseActivity, null /* options */, null /* inTask */, null /* inTaskFragment */); assertEquals(baseActivity.getTask(), targetRecord.getTask()); assertEquals(ActivityRecord.LAUNCH_SOURCE_TYPE_HOME, baseActivity.mLaunchSourceType); } @EnableFlags(Flags.FLAG_ONLY_REUSE_BUBBLED_TASK_WHEN_LAUNCHED_FROM_BUBBLE) @Test public void launchActivity_reusesBubbledTask() { Loading Loading
services/core/java/com/android/server/wm/ActivityStarter.java +7 −4 Original line number Diff line number Diff line Loading @@ -293,7 +293,8 @@ class ActivityStarter { private IVoiceInteractor mVoiceInteractor; // Last activity record we attempted to start private ActivityRecord mLastStartActivityRecord; @VisibleForTesting ActivityRecord mLastStartActivityRecord; // The result of the last activity we attempted to start. private int mLastStartActivityResult; // Time in milli seconds we attempted to start the last activity. Loading Loading @@ -2010,9 +2011,6 @@ class ActivityStarter { activity.destroyIfPossible("Removes redundant singleInstance"); } } if (mLastStartActivityRecord != null) { targetTaskTop.mLaunchSourceType = mLastStartActivityRecord.mLaunchSourceType; } recordTransientLaunchIfNeeded(targetTaskTop); // Recycle the target task for this launch. startResult = Loading Loading @@ -2451,6 +2449,11 @@ class ActivityStarter { ? targetTask.getTopNonFinishingActivity() : targetTaskTop; // The mLastStartActivityRecord isn't added to task, update latest launch source to top // activity before creating starting window. if (mLastStartActivityRecord != null && targetTaskTop != mLastStartActivityRecord) { targetTaskTop.mLaunchSourceType = mLastStartActivityRecord.mLaunchSourceType; } if (mMovedToFront) { // We moved the task to front, use starting window to hide initial drawn delay. targetTaskTop.showStartingWindow(true /* taskSwitch */); Loading
services/tests/wmtests/src/com/android/server/wm/ActivityStarterTests.java +16 −0 Original line number Diff line number Diff line Loading @@ -1780,6 +1780,22 @@ public class ActivityStarterTests extends WindowTestsBase { assertNotEquals(inTask, target.getTask()); } @Test public void testLaunchActivitySourceRemain() { final ActivityStarter starter = prepareStarter(0, false); final ActivityRecord baseActivity = new ActivityBuilder(mAtm) .setCreateTask(true) .build(); baseActivity.mLaunchSourceType = ActivityRecord.LAUNCH_SOURCE_TYPE_HOME; final ActivityRecord targetRecord = new ActivityBuilder(mAtm).build(); targetRecord.mLaunchSourceType = ActivityRecord.LAUNCH_SOURCE_TYPE_APPLICATION; starter.mLastStartActivityRecord = targetRecord; startActivityInner(starter, targetRecord, baseActivity, null /* options */, null /* inTask */, null /* inTaskFragment */); assertEquals(baseActivity.getTask(), targetRecord.getTask()); assertEquals(ActivityRecord.LAUNCH_SOURCE_TYPE_HOME, baseActivity.mLaunchSourceType); } @EnableFlags(Flags.FLAG_ONLY_REUSE_BUBBLED_TASK_WHEN_LAUNCHED_FROM_BUBBLE) @Test public void launchActivity_reusesBubbledTask() { Loading