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

Commit dec8e6f0 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Prevent doing redundant task movements"

parents 49818960 c4abd811
Loading
Loading
Loading
Loading
+9 −18
Original line number Diff line number Diff line
@@ -5326,14 +5326,12 @@ class Task extends WindowContainer<WindowContainer> {
            taskDisplayArea.moveHomeStackToFront(reason + " returnToHome");
        }

        if (isRootTask()) {
            taskDisplayArea.positionChildAt(POSITION_TOP, this, false /* includingParents */,
                    reason);
        }
        final Task lastFocusedTask = isRootTask() ? taskDisplayArea.getFocusedStack() : null;
        if (task == null) {
            task = this;
        }
        task.getParent().positionChildAt(POSITION_TOP, task, true /* includingParents */);
        taskDisplayArea.updateLastFocusedRootTask(lastFocusedTask, reason);
    }

    /**
@@ -5356,8 +5354,9 @@ class Task extends WindowContainer<WindowContainer> {
            if (parentTask != null) {
                parentTask.moveToBack(reason, this);
            } else {
                displayArea.positionChildAt(POSITION_BOTTOM, this, false /*includingParents*/,
                        reason);
                final Task lastFocusedTask = displayArea.getFocusedStack();
                displayArea.positionChildAt(POSITION_BOTTOM, this, false /*includingParents*/);
                displayArea.updateLastFocusedRootTask(lastFocusedTask, reason);
            }
            if (task != null && task != this) {
                positionChildAtBottom(task);
@@ -6884,13 +6883,10 @@ class Task extends WindowContainer<WindowContainer> {
            // get calculated incorrectly.
            mDisplayContent.deferUpdateImeTarget();

            // Shift all activities with this task up to the top
            // of the stack, keeping them in the same internal order.
            positionChildAtTop(tr);

            // Don't refocus if invisible to current user
            final ActivityRecord top = tr.getTopNonFinishingActivity();
            if (top == null || !top.okToShowLocked()) {
                positionChildAtTop(tr);
                if (top != null) {
                    mStackSupervisor.mRecentTasks.add(top.getTask());
                }
@@ -6898,20 +6894,15 @@ class Task extends WindowContainer<WindowContainer> {
                return;
            }

            // Set focus to the top running activity of this stack.
            final ActivityRecord r = topRunningActivity();
            if (r != null) {
                r.moveFocusableActivityToTop(reason);
            }
            // Set focus to the top running activity of this task and move all its parents to top.
            top.moveFocusableActivityToTop(reason);

            if (DEBUG_TRANSITION) Slog.v(TAG_TRANSITION, "Prepare to front transition: task=" + tr);
            if (noAnimation) {
                mDisplayContent.prepareAppTransitionOld(TRANSIT_OLD_NONE,
                        false /* alwaysKeepCurrent */);
                mDisplayContent.prepareAppTransition(TRANSIT_NONE);
                if (r != null) {
                    mStackSupervisor.mNoAnimActivities.add(r);
                }
                mStackSupervisor.mNoAnimActivities.add(top);
                ActivityOptions.abort(options);
            } else {
                updateTransitLocked(TRANSIT_OLD_TASK_TO_FRONT, TRANSIT_TO_FRONT,
+18 −23
Original line number Diff line number Diff line
@@ -335,29 +335,6 @@ final class TaskDisplayArea extends DisplayArea<Task> {
        return true;
    }

    void positionChildAt(int position, Task child, boolean includingParents,
            String updateLastFocusedTaskReason) {
        final Task prevFocusedTask = updateLastFocusedTaskReason != null ? getFocusedStack() : null;

        positionChildAt(position, child, includingParents);

        if (updateLastFocusedTaskReason == null) {
            return;
        }

        final Task currentFocusedStack = getFocusedStack();
        if (currentFocusedStack == prevFocusedTask) {
            return;
        }

        mLastFocusedStack = prevFocusedTask;
        EventLogTags.writeWmFocusedStack(mRootWindowContainer.mCurrentUser,
                mDisplayContent.mDisplayId,
                currentFocusedStack == null ? -1 : currentFocusedStack.getRootTaskId(),
                mLastFocusedStack == null ? -1 : mLastFocusedStack.getRootTaskId(),
                updateLastFocusedTaskReason);
    }

    @Override
    void positionChildAt(int position, Task child, boolean includingParents) {
        final boolean moveToTop = position >= getChildCount() - 1;
@@ -1202,6 +1179,24 @@ final class TaskDisplayArea extends DisplayArea<Task> {
        return mLastFocusedStack;
    }

    void updateLastFocusedRootTask(Task prevFocusedTask, String updateLastFocusedTaskReason) {
        if (updateLastFocusedTaskReason == null) {
            return;
        }

        final Task currentFocusedTask = getFocusedStack();
        if (currentFocusedTask == prevFocusedTask) {
            return;
        }

        mLastFocusedStack = prevFocusedTask;
        EventLogTags.writeWmFocusedStack(mRootWindowContainer.mCurrentUser,
                mDisplayContent.mDisplayId,
                currentFocusedTask == null ? -1 : currentFocusedTask.getRootTaskId(),
                mLastFocusedStack == null ? -1 : mLastFocusedStack.getRootTaskId(),
                updateLastFocusedTaskReason);
    }

    boolean allResumedActivitiesComplete() {
        for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) {
            final ActivityRecord r = getStackAt(stackNdx).getResumedActivity();