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

Commit f9e752d4 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Report moved-to-top as the last launched activity

When starting home while it has an embedded activity on top,
the home activity will reorder to top by
Task#moveTaskFragmentsToBottomIfNeeded

Task
 > TaskFragment > embedded activity
 > HomeActivity

Then the launched activity should be home instead of the
embedded activity.

Fix: 373284518
Flag: EXEMPT bugfix
Test: ActivityStarterTests.testRecordActivityMovementBeforeDeliverToTop
Test: Launch chrome from embedded minus one.
      Swipe up to return to home.
      The launch trace should end by home package instead
      if a long period until minus one activity is visible again.
Change-Id: If93032a18d225469ca05affb1df525659f786586
parent 8ac5a154
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2370,6 +2370,9 @@ class ActivityStarter {
            return START_SUCCESS;
        }

        if (mMovedToTopActivity != null) {
            targetTaskTop = mMovedToTopActivity;
        }
        // The reusedActivity could be finishing, for example of starting an activity with
        // FLAG_ACTIVITY_CLEAR_TOP flag. In that case, use the top running activity in the
        // task instead.
@@ -2608,7 +2611,7 @@ class ActivityStarter {
        mInTaskFragment = null;
        mAddingToTaskFragment = null;
        mAddingToTask = false;

        mMovedToTopActivity = null;
        mSourceRootTask = null;

        mTargetRootTask = null;
+3 −1
Original line number Diff line number Diff line
@@ -1625,16 +1625,18 @@ public class ActivityStarterTests extends WindowTestsBase {
        assertTrue(activityTop.isVisible());
        assertTrue(activityTop.isVisibleRequested());

        final ActivityRecord[] outActivity = new ActivityRecord[1];
        final ActivityStarter starter = prepareStarter(FLAG_ACTIVITY_REORDER_TO_FRONT
                        | FLAG_ACTIVITY_NEW_TASK, false /* mockGetRootTask */);
        starter.mStartActivity = activityBot;
        task.inRecents = true;
        starter.setInTask(task);
        starter.setInTask(task).setOutActivity(outActivity);
        starter.getIntent().setComponent(activityBot.mActivityComponent);
        final int result = starter.setReason("testRecordActivityMovement").execute();

        assertEquals(START_DELIVERED_TO_TOP, result);
        assertNotNull(starter.mMovedToTopActivity);
        assertEquals(activityBot, outActivity[0]);

        final ActivityStarter starter2 = prepareStarter(FLAG_ACTIVITY_REORDER_TO_FRONT
                        | FLAG_ACTIVITY_NEW_TASK, false /* mockGetRootTask */);