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

Commit 63b8ee36 authored by Shunta Sato's avatar Shunta Sato Committed by Wale Ogunwale
Browse files

Return to Home stack when a context of tasks launched from Home finished

When the following conditions happen together, another context in
Application stack was launched unexpectedly:
- There is a context of tasks in Application stack, which is launched
  from a task on Home stack.
- All tasks/activities in the context are finishing.

Solution:
Add a condition check to see if the task is NOT one of the task
finishing on-top of the top running task.

Bug: 30883775
Test: manual
Author: Ichitaro Kohara <ichitaro.kohara@sonymobile.com>
Change-Id: I5d6097a7c8dc2733ff684957370c987dd158e329
parent ca687ac3
Loading
Loading
Loading
Loading
+20 −3
Original line number Original line Diff line number Diff line
@@ -3215,8 +3215,25 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        r.addResultLocked(null, resultWho, requestCode, resultCode, data);
        r.addResultLocked(null, resultWho, requestCode, resultCode, data);
    }
    }


    /** Returns true if the task is one of the task finishing on-top of the top running task. */
    boolean isATopFinishingTask(TaskRecord task) {
        for (int i = mTaskHistory.size() - 1; i >= 0; --i) {
            final TaskRecord current = mTaskHistory.get(i);
            final ActivityRecord r = current.topRunningActivityLocked();
            if (r != null) {
                // We got a top running activity, so there isn't a top finishing task...
                return false;
            }
            if (current == task) {
                return true;
            }
        }
        return false;
    }

    private void adjustFocusedActivityStackLocked(ActivityRecord r, String reason) {
    private void adjustFocusedActivityStackLocked(ActivityRecord r, String reason) {
        if (!mStackSupervisor.isFocusedStack(this) || mResumedActivity != r) {
        if (!mStackSupervisor.isFocusedStack(this) ||
                ((mResumedActivity != r) && (mResumedActivity != null))) {
            return;
            return;
        }
        }


@@ -3231,8 +3248,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                final TaskRecord task = r.getTask();
                final TaskRecord task = r.getTask();
                final boolean isAssistantOrOverAssistant = task.getStack().isAssistantStack() ||
                final boolean isAssistantOrOverAssistant = task.getStack().isAssistantStack() ||
                        task.isOverAssistantStack();
                        task.isOverAssistantStack();
                if (r.frontOfTask && task == topTask() &&
                if (r.frontOfTask && isATopFinishingTask(task)
                        (task.isOverHomeStack() || isAssistantOrOverAssistant)) {
                        && (task.isOverHomeStack() || isAssistantOrOverAssistant)) {
                    // For non-fullscreen or assistant stack, we want to move the focus to the next
                    // For non-fullscreen or assistant stack, we want to move the focus to the next
                    // visible stack to prevent the home screen from moving to the top and obscuring
                    // visible stack to prevent the home screen from moving to the top and obscuring
                    // other visible stacks.
                    // other visible stacks.