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

Commit 00a0969b authored by Winson Chung's avatar Winson Chung
Browse files

Start recents animation to the target task in the stack

- If someone downloads a 3p launcher, there can be multiple tasks in the
  same target stack. When bringing the stack forward for quickstep, also
  bring forward the target task within the stack.

Bug: 77217592
Test: Install 3p launcher, go home (to that launcher), launch an app and
      then swipe up. We expect the default launcher with the overview
      implementation to show instead of the 3p launcher task above it.

Change-Id: I39b1760b5d2536d526749077151b4b2340dd96b2
parent df173b59
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -101,9 +101,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
                        : ACTIVITY_TYPE_HOME;
        final ActivityStack targetStack = mDefaultDisplay.getStack(WINDOWING_MODE_UNDEFINED,
                mTargetActivityType);
        ActivityRecord targetActivity = targetStack != null
                ? targetStack.getTopActivity()
                : null;
        ActivityRecord targetActivity = getTargetActivity(targetStack, intent.getComponent());
        final boolean hasExistingActivity = targetActivity != null;
        if (hasExistingActivity) {
            final ActivityDisplay display = targetActivity.getDisplay();
@@ -149,6 +147,14 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
                display.moveStackBehindBottomMostVisibleStack(targetStack);
                if (DEBUG) Slog.d(TAG, "Moved stack=" + targetStack + " behind stack="
                            + display.getStackAbove(targetStack));

                // If there are multiple tasks in the target stack (ie. the home stack, with 3p
                // and default launchers coexisting), then move the task to the top as a part of
                // moving the stack to the front
                if (targetStack.topTask() != targetActivity.getTask()) {
                    targetStack.addTask(targetActivity.getTask(), true /* toTop */,
                            "startRecentsActivity");
                }
            } else {
                // No recents activity
                ActivityOptions options = ActivityOptions.makeBasic();
@@ -322,4 +328,22 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
        }
        return null;
    }

    /**
     * @return the top activity in the {@param targetStack} matching the {@param component}, or just
     * the top activity of the top task if no task matches the component.
     */
    private ActivityRecord getTargetActivity(ActivityStack targetStack, ComponentName component) {
        if (targetStack == null) {
            return null;
        }

        for (int i = targetStack.getChildCount() - 1; i >= 0; i--) {
            final TaskRecord task = (TaskRecord) targetStack.getChildAt(i);
            if (task.getBaseIntent().getComponent().equals(component)) {
                return task.getTopActivity();
            }
        }
        return targetStack.getTopActivity();
    }
}