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

Commit 47e8074d authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Update histories simultaneously."

parents eab51de4 b44de0d9
Loading
Loading
Loading
Loading
+32 −37
Original line number Diff line number Diff line
@@ -4850,42 +4850,6 @@ final class ActivityStack {
     * @return Returns true if the move completed, false if not.
     */
    final boolean moveTaskToBackLocked(int task, ActivityRecord reason) {
        if (!newMoveTaskToBackLocked(task, reason)) {
            return false;
        }

        final int N = mHistory.size();
        int bottom = 0;
        int pos = 0;

        // Shift all activities with this task down to the bottom
        // of the stack, keeping them in the same internal order.
        while (pos < N) {
            ActivityRecord r = mHistory.get(pos);
            if (localLOGV) Slog.v(
                TAG, "At " + pos + " ckp " + r.task + ": " + r);
            if (r.task.taskId == task) {
                if (localLOGV) Slog.v(TAG, "Removing and adding at " + (N-1));
                if (DEBUG_ADD_REMOVE) {
                    RuntimeException here = new RuntimeException("here");
                    here.fillInStackTrace();
                    Slog.i(TAG, "Removing and adding activity " + r + " to stack at "
                            + bottom, here);
                }
                mHistory.remove(pos);
                mHistory.add(bottom, r);
                bottom++;
            }
            pos++;
        }
        if (VALIDATE_TASK_REPLACE) {
            verifyActivityRecords(true);
        }

        return true;
    }

    final boolean newMoveTaskToBackLocked(int task, ActivityRecord reason) {
        Slog.i(TAG, "moveTaskToBack: " + task);

        // If we have a watcher, preflight the move before committing to it.  First check
@@ -4917,6 +4881,36 @@ final class ActivityStack {
        mTaskHistory.remove(tr);
        mTaskHistory.add(0, tr);

        // BEGIN REGION TO REMOVE.
        final int N = mHistory.size();
        int bottom = 0;
        int pos = 0;

        // Shift all activities with this task down to the bottom
        // of the stack, keeping them in the same internal order.
        while (pos < N) {
            ActivityRecord r = mHistory.get(pos);
            if (localLOGV) Slog.v(
                TAG, "At " + pos + " ckp " + r.task + ": " + r);
            if (r.task.taskId == task) {
                if (localLOGV) Slog.v(TAG, "Removing and adding at " + (N-1));
                if (DEBUG_ADD_REMOVE) {
                    RuntimeException here = new RuntimeException("here");
                    here.fillInStackTrace();
                    Slog.i(TAG, "Removing and adding activity " + r + " to stack at "
                            + bottom, here);
                }
                mHistory.remove(pos);
                mHistory.add(bottom, r);
                bottom++;
            }
            pos++;
        }
        if (VALIDATE_TASK_REPLACE) {
            verifyActivityRecords(true);
        }
        // END REGION TO REMOVE

        if (reason != null &&
                (reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
            mService.mWindowManager.prepareAppTransition(AppTransition.TRANSIT_NONE, false);
@@ -4929,6 +4923,7 @@ final class ActivityStack {
                    AppTransition.TRANSIT_TASK_TO_BACK, false);
        }
        mService.mWindowManager.moveTaskToBottom(task);

        if (VALIDATE_TOKENS) {
            validateAppTokensLocked();
        }
+1 −0
Original line number Diff line number Diff line
@@ -3158,6 +3158,7 @@ public class WindowManagerService extends IWindowManager.Stub
            if (mismatch || iterator.hasNext()) {
                Slog.w(TAG, "validateAppTokens: Mismatch! ActivityManager=" + tasks);
                Slog.w(TAG, "validateAppTokens: Mismatch! WindowManager=" + iterator);
                Slog.w(TAG, "validateAppTokens: Mismatch! Callers=" + Debug.getCallers(4));
            }
        }
    }