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

Commit acebdc84 authored by Craig Mautner's avatar Craig Mautner
Browse files

Cleanup the activity before the task and stack

The method cleanupActivityLocked() should be called before
removeActivityFromHistoryLocked(). Previously it didn't matter but
now that we null TaskRecord.stack when removing the last activity
from the task it does.

Fixes NPE in bug 19491381.

Change-Id: Ia6f8f560c0fe4df330577f313e24d7dd02c18409
parent 8ee1d64c
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -2999,6 +2999,8 @@ final class ActivityStack {
     * representation) and cleaning things up as a result of its hosting
     * representation) and cleaning things up as a result of its hosting
     * processing going away, in which case there is no remaining client-side
     * processing going away, in which case there is no remaining client-side
     * state to destroy so only the cleanup here is needed.
     * state to destroy so only the cleanup here is needed.
     *
     * Note: Call before #removeActivityFromHistoryLocked.
     */
     */
    final void cleanUpActivityLocked(ActivityRecord r, boolean cleanServices,
    final void cleanUpActivityLocked(ActivityRecord r, boolean cleanServices,
            boolean setState) {
            boolean setState) {
@@ -3410,7 +3412,7 @@ final class ActivityStack {
                if (DEBUG_CLEANUP) Slog.v(
                if (DEBUG_CLEANUP) Slog.v(
                    TAG, "Record #" + i + " " + r + ": app=" + r.app);
                    TAG, "Record #" + i + " " + r + ": app=" + r.app);
                if (r.app == app) {
                if (r.app == app) {
                    boolean remove;
                    final boolean remove;
                    if ((!r.haveState && !r.stateNotNeeded) || r.finishing) {
                    if ((!r.haveState && !r.stateNotNeeded) || r.finishing) {
                        // Don't currently have state for the activity, or
                        // Don't currently have state for the activity, or
                        // it is finishing -- always remove it.
                        // it is finishing -- always remove it.
@@ -3444,8 +3446,6 @@ final class ActivityStack {
                                mService.updateUsageStats(r, false);
                                mService.updateUsageStats(r, false);
                            }
                            }
                        }
                        }
                        removeActivityFromHistoryLocked(r, "appDied");

                    } else {
                    } else {
                        // We have the current state for this activity, so
                        // We have the current state for this activity, so
                        // it can be restarted later when needed.
                        // it can be restarted later when needed.
@@ -3464,8 +3464,10 @@ final class ActivityStack {
                            r.icicle = null;
                            r.icicle = null;
                        }
                        }
                    }
                    }

                    cleanUpActivityLocked(r, true, true);
                    cleanUpActivityLocked(r, true, true);
                    if (remove) {
                        removeActivityFromHistoryLocked(r, "appDied");
                    }
                }
                }
            }
            }
        }
        }