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

Commit bbe8b190 authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

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

am: 37ccdaa4

Change-Id: I69d1232b7e2b03943937f3be26a7dd25bf808574
parents c4fb856a 37ccdaa4
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();
    }
}