Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a4efe7f authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Android (Google) Code Review
Browse files

Merge "Only update launchSource to top activity..." into main

parents 9f2dcd70 d484541a
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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.
@@ -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 =
@@ -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 */);
+16 −0
Original line number Diff line number Diff line
@@ -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() {