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

Commit e88e5584 authored by Bryce Lee's avatar Bryce Lee Committed by android-build-merger
Browse files

Merge "Do not set activity's task before clearing in some scenarios." into pi-dev

am: 540f7478

Change-Id: Ida4807ded086a070e2e905f03d298ffd4c6ab98b
parents d2dc31b5 540f7478
Loading
Loading
Loading
Loading
+26 −10
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ import static android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED;
import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
import static android.content.pm.ActivityInfo.DOCUMENT_LAUNCH_ALWAYS;
import static android.content.pm.ActivityInfo.DOCUMENT_LAUNCH_ALWAYS;
import static android.content.pm.ActivityInfo.LAUNCH_MULTIPLE;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TOP;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TOP;
@@ -1205,9 +1206,20 @@ class ActivityStarter {
                return START_RETURN_LOCK_TASK_MODE_VIOLATION;
                return START_RETURN_LOCK_TASK_MODE_VIOLATION;
            }
            }


            if (mStartActivity.getTask() == null) {
            // True if we are clearing top and resetting of a standard (default) launch mode
            // ({@code LAUNCH_MULTIPLE}) activity. The existing activity will be finished.
            final boolean clearTopAndResetStandardLaunchMode =
                    (mLaunchFlags & (FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED))
                            == (FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
                    && mLaunchMode == LAUNCH_MULTIPLE;

            // If mStartActivity does not have a task associated with it, associate it with the
            // reused activity's task. Do not do so if we're clearing top and resetting for a
            // standard launchMode activity.
            if (mStartActivity.getTask() == null && !clearTopAndResetStandardLaunchMode) {
                mStartActivity.setTask(reusedActivity.getTask());
                mStartActivity.setTask(reusedActivity.getTask());
            }
            }

            if (reusedActivity.getTask().intent == null) {
            if (reusedActivity.getTask().intent == null) {
                // This task was started because of movement of the activity based on affinity...
                // This task was started because of movement of the activity based on affinity...
                // Now that we are actually launching it, we can assign the base intent.
                // Now that we are actually launching it, we can assign the base intent.
@@ -1266,11 +1278,14 @@ class ActivityStarter {
                resumeTargetStackIfNeeded();
                resumeTargetStackIfNeeded();
                return START_RETURN_INTENT_TO_CALLER;
                return START_RETURN_INTENT_TO_CALLER;
            }
            }

            if (reusedActivity != null) {
                setTaskFromIntentActivity(reusedActivity);
                setTaskFromIntentActivity(reusedActivity);


                if (!mAddingToTask && mReuseTask == null) {
                if (!mAddingToTask && mReuseTask == null) {
                    // We didn't do anything...  but it was needed (a.k.a., client don't use that
                    // We didn't do anything...  but it was needed (a.k.a., client don't use that
                    // intent!)  And for paranoia, make sure we have correctly resumed the top activity.
                    // intent!)  And for paranoia, make sure we have correctly resumed the top activity.

                    resumeTargetStackIfNeeded();
                    resumeTargetStackIfNeeded();
                    if (outActivity != null && outActivity.length > 0) {
                    if (outActivity != null && outActivity.length > 0) {
                        outActivity[0] = reusedActivity;
                        outActivity[0] = reusedActivity;
@@ -1279,6 +1294,7 @@ class ActivityStarter {
                    return mMovedToFront ? START_TASK_TO_FRONT : START_DELIVERED_TO_TOP;
                    return mMovedToFront ? START_TASK_TO_FRONT : START_DELIVERED_TO_TOP;
                }
                }
            }
            }
        }


        if (mStartActivity.packageName == null) {
        if (mStartActivity.packageName == null) {
            final ActivityStack sourceStack = mStartActivity.resultTo != null
            final ActivityStack sourceStack = mStartActivity.resultTo != null