From 7cb57e199fbe84654b6f0974e308f91963bdee35 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 10 Nov 2015 13:44:02 -0800 Subject: [PATCH] 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 --- services/core/java/com/android/server/am/RecentTasks.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/RecentTasks.java b/services/core/java/com/android/server/am/RecentTasks.java index 862a9739fe056..c63eaac448d5d 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 @@ class RecentTasks extends ArrayList { 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; }