From 7cbfcd88657ac7d5ab1baf8c964b669c9bd21e24 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Mon, 20 Jul 2015 15:43:37 -0700 Subject: [PATCH] Don't duplicate recent tasks of the same affinity. In change 510e554283d3dc250f836cd3e4abc36d87319333 we stated limiting the number of document activity entries in recents by comparing the realActivity of the tasks. This compared was done for all tasks not just document tasks there by breaking the use of task affinity to remove tasks with the same affinity from recent task list. This change limits the compare of realActivity to just document tasks. Bug: 22564474 Bug: 18642190 Change-Id: Idc21ec311f194ab2005cb22380ca56303ae0ad94 --- .../com/android/server/am/RecentTasks.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/am/RecentTasks.java b/services/core/java/com/android/server/am/RecentTasks.java index 9f11def4abdb1..6ee165093e39e 100644 --- a/services/core/java/com/android/server/am/RecentTasks.java +++ b/services/core/java/com/android/server/am/RecentTasks.java @@ -446,13 +446,23 @@ class RecentTasks extends ArrayList { if (i > MAX_RECENT_BITMAPS) { tr.freeLastThumbnail(); } - if (task.realActivity == null || tr.realActivity == null || - !task.realActivity.equals(tr.realActivity)) { + final boolean sameAffinity = + task.affinity != null && task.affinity.equals(tr.affinity); + final boolean trIsDocument = tr.intent != null && tr.intent.isDocument(); + final boolean bothDocuments = document && trIsDocument; + if (!sameAffinity && !bothDocuments) { + // Not the same affinity and not documents. Move along... continue; } - final boolean trIsDocument = tr.intent != null && tr.intent.isDocument(); - if (document && trIsDocument) { - // These are the same document activity (not necessarily the same doc). + + if (bothDocuments) { + // Do these documents belong to the same activity? + final boolean sameActivity = task.realActivity != null + && tr.realActivity != null + && task.realActivity.equals(tr.realActivity); + if (!sameActivity) { + continue; + } if (maxRecents > 0) { --maxRecents; continue;