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

Commit 64512526 authored by Yorke Lee's avatar Yorke Lee
Browse files

Only change bounds if new activity is being added to InTask

When going through the setTaskFromInTask code path, there are multiple
scenarios where an activity isn't actually added to the task.

This change makes it such that the task is only resized if an activity
is actually being added to the task make this more semantically similar
to setTaskFromReuseOrCreateNewTask, where the task is only resized if
it is a newly created task.

This is a cherry-pick of
I111353c76e623925af21a34e395e3d5eb9282e8f

Bug: 35945071
Test: manual - setTaskFromInTask doesn't change bounds if
no new activity is added.
Change-Id: I4b8330ce775ec46812f6095c170a690fdea77736
parent 31426a2e
Loading
Loading
Loading
Loading
+21 −14
Original line number Diff line number Diff line
@@ -1790,21 +1790,7 @@ class ActivityStarter {
            return START_RETURN_LOCK_TASK_MODE_VIOLATION;
        }

        if (mLaunchBounds != null) {
            mInTask.updateOverrideConfiguration(mLaunchBounds);
            int stackId = mInTask.getLaunchStackId();
            if (stackId != mInTask.getStackId()) {
                mInTask.reparent(stackId, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, !ANIMATE,
                        DEFER_RESUME, "inTaskToFront");
                stackId = mInTask.getStackId();
            }
            if (StackId.resizeStackWithLaunchBounds(stackId)) {
                mService.resizeStack(stackId, mLaunchBounds, true, !PRESERVE_WINDOWS, ANIMATE, -1);
            }
        }
        mTargetStack = mInTask.getStack();
        mTargetStack.moveTaskToFrontLocked(
                mInTask, mNoAnimation, mOptions, mStartActivity.appTimeTracker, "inTaskToFront");

        // Check whether we should actually launch the new activity in to the task,
        // or just reuse the current activity on top.
@@ -1813,6 +1799,8 @@ class ActivityStarter {
                && top.userId == mStartActivity.userId) {
            if ((mLaunchFlags & FLAG_ACTIVITY_SINGLE_TOP) != 0
                    || mLaunchSingleTop || mLaunchSingleTask) {
                mTargetStack.moveTaskToFrontLocked(mInTask, mNoAnimation, mOptions,
                        mStartActivity.appTimeTracker, "inTaskToFront");
                ActivityStack.logStartActivity(AM_NEW_INTENT, top, top.task);
                if ((mStartFlags & START_FLAG_ONLY_IF_NEEDED) != 0) {
                    // We don't need to start a new activity, and the client said not to do
@@ -1826,12 +1814,31 @@ class ActivityStarter {
        }

        if (!mAddingToTask) {
            mTargetStack.moveTaskToFrontLocked(mInTask, mNoAnimation, mOptions,
                    mStartActivity.appTimeTracker, "inTaskToFront");
            // We don't actually want to have this activity added to the task, so just
            // stop here but still tell the caller that we consumed the intent.
            ActivityOptions.abort(mOptions);
            return START_TASK_TO_FRONT;
        }

        if (mLaunchBounds != null) {
            mInTask.updateOverrideConfiguration(mLaunchBounds);
            int stackId = mInTask.getLaunchStackId();
            if (stackId != mInTask.getStackId()) {
                mInTask.reparent(stackId, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, !ANIMATE,
                        DEFER_RESUME, "inTaskToFront");
                stackId = mInTask.getStackId();
                mTargetStack = mInTask.getStack();
            }
            if (StackId.resizeStackWithLaunchBounds(stackId)) {
                mService.resizeStack(stackId, mLaunchBounds, true, !PRESERVE_WINDOWS, ANIMATE, -1);
            }
        }

        mTargetStack.moveTaskToFrontLocked(
                mInTask, mNoAnimation, mOptions, mStartActivity.appTimeTracker, "inTaskToFront");

        addOrReparentStartingActivity(mInTask, "setTaskFromInTask");
        if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Starting new activity " + mStartActivity
                + " in explicit task " + mStartActivity.task);