Skip to content

Commit 2ab53cf

Browse files
committed
Also consider task intent when trimming recent tasks
7cbfcd8 we stopped comparing the tasks realActivity when trimming recent task. This led to task with the same intent been duplicated in the recents list. We now consider the task intent when deciding when to trim like we did pre 510e554. Bug: 22812470 Bug: 22564474 Bug: 18642190 Change-Id: I90b3ab9cf7a06b4691099f697e723d8a54def9fa
1 parent 8dbd484 commit 2ab53cf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

services/core/java/com/android/server/am/RecentTasks.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ final void addLocked(TaskRecord task) {
435435
*/
436436
int trimForTaskLocked(TaskRecord task, boolean doTrim) {
437437
int recentsCount = size();
438-
final boolean document = task.intent != null && task.intent.isDocument();
438+
final Intent intent = task.intent;
439+
final boolean document = intent != null && intent.isDocument();
439440
int maxRecents = task.maxRecents - 1;
440441
for (int i = 0; i < recentsCount; i++) {
441442
final TaskRecord tr = get(i);
@@ -446,12 +447,13 @@ int trimForTaskLocked(TaskRecord task, boolean doTrim) {
446447
if (i > MAX_RECENT_BITMAPS) {
447448
tr.freeLastThumbnail();
448449
}
450+
final Intent trIntent = tr.intent;
449451
final boolean sameAffinity =
450452
task.affinity != null && task.affinity.equals(tr.affinity);
451-
final boolean trIsDocument = tr.intent != null && tr.intent.isDocument();
453+
final boolean sameIntent = (intent != null && intent.filterEquals(trIntent));
454+
final boolean trIsDocument = trIntent != null && trIntent.isDocument();
452455
final boolean bothDocuments = document && trIsDocument;
453-
if (!sameAffinity && !bothDocuments) {
454-
// Not the same affinity and not documents. Move along...
456+
if (!sameAffinity && !sameIntent && !bothDocuments) {
455457
continue;
456458
}
457459

0 commit comments

Comments
 (0)