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

Commit d484541a authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

Only update launchSource to top activity...

...if the launch activity isn't added to task.
So the state of the previous activity won't get overwritten by the
subsequent launch, which affects the shouldMoveTaskToBack result.

Flag: EXEMPT bugfix
Bug: 412305625
Test: verify no regression 340401554
Test: atest ActivityStarterTests
Test: launch activity A, then start activity B from A. Verify A won't
be finished with default back navigation.

Change-Id: I2c3129cd0979a23ee85239f9ba0c41efa52c77fe
parent 6e14ced4
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() {