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

Commit 37ccdaa4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Start recents animation to the target task in the stack" into pi-dev

parents 4bc7dc95 00a0969b
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();
@@ -332,4 +338,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();
    }
}