diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 7135c70b644de..cfef431c88a15 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -876,7 +876,7 @@ class ActivityStarter { // In this situation we want to remove all activities from the task up to the one // being started. In most cases this means we are resetting the task to its initial // state. - final ActivityRecord top = intentActivity.task.performClearTaskLocked( + final ActivityRecord top = intentActivity.task.performClearTaskForReuseLocked( mStartActivity, mLaunchFlags); if (top != null) { if (top.frontOfTask) { diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index c6444bfaf26c8..71cfeab0e6277 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -206,7 +206,7 @@ final class TaskRecord { // Used in the unique case where we are clearing the task in order to reuse it. In that case we // do not want to delete the stack when the task goes empty. - boolean mReuseTask = false; + private boolean mReuseTask = false; private Bitmap mLastThumbnail; // Last thumbnail captured for this item. private final File mLastThumbnailFile; // File containing last thumbnail. @@ -777,6 +777,13 @@ final class TaskRecord { mReuseTask = false; } + ActivityRecord performClearTaskForReuseLocked(ActivityRecord newR, int launchFlags) { + mReuseTask = true; + final ActivityRecord result = performClearTaskLocked(newR, launchFlags); + mReuseTask = false; + return result; + } + /** * Perform clear operation as requested by * {@link Intent#FLAG_ACTIVITY_CLEAR_TOP}: search from the top of the