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

Commit bffd889c authored by Chong Zhang's avatar Chong Zhang
Browse files

Revert "Check if task was top of stack before it's removed"

This is no longer needed, since we removed focused activity
in ag/1195645, and no longer reorder tasks in cleanUpActivityLocked.

bug: 29937415

This reverts commit e4cf36fb.
parent 89142e9c
Loading
Loading
Loading
Loading
+6 −15
Original line number Original line Diff line number Diff line
@@ -3874,8 +3874,7 @@ final class ActivityStack {
        r.finishLaunchTickingLocked();
        r.finishLaunchTickingLocked();
    }
    }


    private void removeActivityFromHistoryLocked(
    private void removeActivityFromHistoryLocked(ActivityRecord r, String reason) {
            ActivityRecord r, TaskRecord oldTop, String reason) {
        mStackSupervisor.removeChildActivityContainers(r);
        mStackSupervisor.removeChildActivityContainers(r);
        finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null);
        finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null);
        r.makeFinishingLocked();
        r.makeFinishingLocked();
@@ -3894,11 +3893,10 @@ final class ActivityStack {
            validateAppTokensLocked();
            validateAppTokensLocked();
        }
        }
        final TaskRecord task = r.task;
        final TaskRecord task = r.task;
        final TaskRecord topTask = oldTop != null ? oldTop : topTask();
        if (task != null && task.removeActivity(r)) {
        if (task != null && task.removeActivity(r)) {
            if (DEBUG_STACK) Slog.i(TAG_STACK,
            if (DEBUG_STACK) Slog.i(TAG_STACK,
                    "removeActivityFromHistoryLocked: last activity removed from " + this);
                    "removeActivityFromHistoryLocked: last activity removed from " + this);
            if (mStackSupervisor.isFocusedStack(this) && task == topTask &&
            if (mStackSupervisor.isFocusedStack(this) && task == topTask() &&
                    task.isOverHomeStack()) {
                    task.isOverHomeStack()) {
                mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo(), reason);
                mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo(), reason);
            }
            }
@@ -4034,12 +4032,6 @@ final class ActivityStack {


        boolean removedFromHistory = false;
        boolean removedFromHistory = false;


        // If the activity is finishing, it's no longer considered in topRunningActivityLocked,
        // and cleanUpActivityLocked() may change focus to another activity (or task).
        // Get the current top task now, as removeActivityFromHistoryLocked() below need this
        // to decide whether to return to home stack after removal.
        final TaskRecord topTask = topTask();

        cleanUpActivityLocked(r, false, false);
        cleanUpActivityLocked(r, false, false);


        final boolean hadApp = r.app != null;
        final boolean hadApp = r.app != null;
@@ -4074,8 +4066,7 @@ final class ActivityStack {
                // up.
                // up.
                //Slog.w(TAG, "Exception thrown during finish", e);
                //Slog.w(TAG, "Exception thrown during finish", e);
                if (r.finishing) {
                if (r.finishing) {
                    removeActivityFromHistoryLocked(
                    removeActivityFromHistoryLocked(r, reason + " exceptionInScheduleDestroy");
                            r, topTask, reason + " exceptionInScheduleDestroy");
                    removedFromHistory = true;
                    removedFromHistory = true;
                    skipDestroy = true;
                    skipDestroy = true;
                }
                }
@@ -4106,7 +4097,7 @@ final class ActivityStack {
        } else {
        } else {
            // remove this record from the history.
            // remove this record from the history.
            if (r.finishing) {
            if (r.finishing) {
                removeActivityFromHistoryLocked(r, topTask, reason + " hadNoApp");
                removeActivityFromHistoryLocked(r, reason + " hadNoApp");
                removedFromHistory = true;
                removedFromHistory = true;
            } else {
            } else {
                if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to DESTROYED: " + r + " (no app)");
                if (DEBUG_STATES) Slog.v(TAG_STATES, "Moving to DESTROYED: " + r + " (no app)");
@@ -4137,7 +4128,7 @@ final class ActivityStack {
            if (isInStackLocked(r) != null) {
            if (isInStackLocked(r) != null) {
                if (r.state == ActivityState.DESTROYING) {
                if (r.state == ActivityState.DESTROYING) {
                    cleanUpActivityLocked(r, true, false);
                    cleanUpActivityLocked(r, true, false);
                    removeActivityFromHistoryLocked(r, null, reason);
                    removeActivityFromHistoryLocked(r, reason);
                }
                }
            }
            }
            mStackSupervisor.resumeFocusedStackTopActivityLocked();
            mStackSupervisor.resumeFocusedStackTopActivityLocked();
@@ -4295,7 +4286,7 @@ final class ActivityStack {
                    }
                    }
                    cleanUpActivityLocked(r, true, true);
                    cleanUpActivityLocked(r, true, true);
                    if (remove) {
                    if (remove) {
                        removeActivityFromHistoryLocked(r, null, "appDied");
                        removeActivityFromHistoryLocked(r, "appDied");
                    }
                    }
                }
                }
            }
            }