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

Commit 8862929e authored by Craig Mautner's avatar Craig Mautner
Browse files

Use old task info when creating new task.

When a new task is being created solely to protect the system from an
old task going away, save the info from the old task and use it when
creating a new task.

Fixes bug 11615548.

Change-Id: Ibc3fd15ec4b0d76bce30381fbd83b6899f6a9023
parent 105b9b05
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -1386,17 +1386,22 @@ public final class ActivityStackSupervisor {
            launchFlags |= Intent.FLAG_ACTIVITY_NEW_TASK;
            launchFlags |= Intent.FLAG_ACTIVITY_NEW_TASK;
        }
        }


        ActivityInfo newTaskInfo = null;
        Intent newTaskIntent = null;
        final ActivityStack sourceStack;
        final ActivityStack sourceStack;
        if (sourceRecord != null) {
        if (sourceRecord != null) {
            if (sourceRecord.finishing) {
            if (sourceRecord.finishing) {
                // If the source is finishing, we can't further count it as our source.  This
                // If the source is finishing, we can't further count it as our source.  This
                // is because the task it is associated with may now be empty and on its way out,
                // is because the task it is associated with may now be empty and on its way out,
                // so we don't want to blindly throw it in to that task.  Instead we will take
                // so we don't want to blindly throw it in to that task.  Instead we will take
                // the NEW_TASK flow and try to find a task for it.
                // the NEW_TASK flow and try to find a task for it. But save the task information
                // so it can be used when creating the new task.
                if ((launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
                if ((launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
                    Slog.w(TAG, "startActivity called from finishing " + sourceRecord
                    Slog.w(TAG, "startActivity called from finishing " + sourceRecord
                            + "; forcing " + "Intent.FLAG_ACTIVITY_NEW_TASK for: " + intent);
                            + "; forcing " + "Intent.FLAG_ACTIVITY_NEW_TASK for: " + intent);
                    launchFlags |= Intent.FLAG_ACTIVITY_NEW_TASK;
                    launchFlags |= Intent.FLAG_ACTIVITY_NEW_TASK;
                    newTaskInfo = sourceRecord.info;
                    newTaskIntent = sourceRecord.task.intent;
                }
                }
                sourceRecord = null;
                sourceRecord = null;
                sourceStack = null;
                sourceStack = null;
@@ -1668,8 +1673,10 @@ public final class ActivityStackSupervisor {
            targetStack = adjustStackFocus(r);
            targetStack = adjustStackFocus(r);
            moveHomeStack(targetStack.isHomeStack());
            moveHomeStack(targetStack.isHomeStack());
            if (reuseTask == null) {
            if (reuseTask == null) {
                r.setTask(targetStack.createTaskRecord(getNextTaskId(), r.info, intent, true),
                r.setTask(targetStack.createTaskRecord(getNextTaskId(),
                        null, true);
                        newTaskInfo != null ? newTaskInfo : r.info,
                        newTaskIntent != null ? newTaskIntent : intent,
                        true), null, true);
                if (DEBUG_TASKS) Slog.v(TAG, "Starting new activity " + r + " in new task " +
                if (DEBUG_TASKS) Slog.v(TAG, "Starting new activity " + r + " in new task " +
                        r.task);
                        r.task);
            } else {
            } else {