Implement maxRecents and fix TaskPersister bug
Activities can now set the maximum number of times that they will
appear in the recent task lists when using DocCentric mode. The
default number is 15, the min 1, and the max 100.
Also a bug in TaskPersister that deleted files because it did not
properly parse their task ids is fixed.
Fixes bug 13736052.
Change-Id: I7ccb4e6f89d6202ff31c8577bb7b9d8d1b7e5e8d
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index ce83ae6..1df230e 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -96,6 +96,7 @@
/** Takes on same value as first root activity */
boolean isPersistable = false;
+ int maxRecents;
/** Only used for persistable tasks, otherwise 0. The last time this task was moved. Used for
* determining the order when restoring. Sign indicates whether last task movement was to front
@@ -104,6 +105,7 @@
/** True if persistable, has changed, and has not yet been persisted */
boolean needsPersisting = false;
+
/** Launch the home activity when leaving this task. Will be false for tasks that are not on
* Display.DEFAULT_DISPLAY. */
boolean mOnTopOfHome = false;
@@ -301,6 +303,8 @@
if (mActivities.isEmpty()) {
taskType = r.mActivityType;
isPersistable = r.isPersistable();
+ // Clamp to [1, 100].
+ maxRecents = Math.min(Math.max(r.info.maxRecents, 1), 100);
} else {
// Otherwise make all added activities match this one.
r.mActivityType = taskType;