Prevent early recent trimming of distinct documents.
Prevent early trimming of documents with distinct
intents. Otherwise when launching a document
from a given activity, existing recent entries
will always be pruned even if they are distinct
documents. We don't have to worry about overflowing
recents, a seperate codepath (from addLocked)
takes care of second pass trimming when we have
exceeded our total max recents.
Bug: 25460953
Change-Id: I71f8c3d46570df2c999f0d986e05515074e0a098
diff --git a/services/core/java/com/android/server/am/RecentTasks.java b/services/core/java/com/android/server/am/RecentTasks.java
index 862a973..c63eaac 100644
--- a/services/core/java/com/android/server/am/RecentTasks.java
+++ b/services/core/java/com/android/server/am/RecentTasks.java
@@ -462,10 +462,12 @@
final boolean sameActivity = task.realActivity != null
&& tr.realActivity != null
&& task.realActivity.equals(tr.realActivity);
- if (!sameActivity) {
+ // If the document is open in another app or is not the same
+ // document, we don't need to trim it.
+ if (!sameActivity || !sameIntent) {
continue;
- }
- if (maxRecents > 0 && !doTrim) {
+ // Otherwise only trim if we are over our max recents for this task
+ } else if (maxRecents > 0 && !doTrim) {
--maxRecents;
continue;
}