From 847167fe3d1dce6d1735b2510b8b698aa1a69b2d Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Tue, 9 Aug 2016 09:21:10 -0700 Subject: [PATCH] Limit number of recents entries for an app to maxRecents allowed. Regression in the API caused by the fixes for b/28293748 and b/25460953 which prevented the task entries from been trimmed if the task don't have the same intent filter (additional documents launched will normally have different intent action/filter than the base activity) or it allows multiple task entries. We now trim when we go over the maxRecents allowed in both cases. Bug: 30645949 Bug: 28293748 Bug: 25460953 Change-Id: I74c8ecc38f72a5d03c213dea8d3e62261d42f8f6 --- .../core/java/com/android/server/am/RecentTasks.java | 11 ++++++++--- 1 file changed, 8 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 5c05ab64e199a..beb863b394af4 100644 --- a/services/core/java/com/android/server/am/RecentTasks.java +++ b/services/core/java/com/android/server/am/RecentTasks.java @@ -653,12 +653,17 @@ class RecentTasks extends ArrayList { && task.realActivity.equals(tr.realActivity); // If the document is open in another app or is not the same // document, we don't need to trim it. - if (!sameActivity || !sameIntentFilter || multiTasksAllowed) { + if (!sameActivity) { continue; // Otherwise only trim if we are over our max recents for this task - } else if (maxRecents > 0 && !doTrim) { + } else if (maxRecents > 0) { --maxRecents; - continue; + if (!doTrim || !sameIntentFilter || multiTasksAllowed) { + // We don't want to trim if we are not over the max allowed entries and + // the caller doesn't want us to trim, the tasks are not of the same + // intent filter, or multiple entries fot the task is allowed. + continue; + } } // Hit the maximum number of documents for this task. Fall through // and remove this document from recents.