From e042bf2b22b391f13d8e43ddcd657183992c7197 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Tue, 11 Nov 2014 11:28:43 -0800 Subject: [PATCH] If task isn't found in recents, look in the stacks. It may take an attach to move a task into the recents list. If the timing is right a task may not be in recents by the time we are removing it from the stacks due to a finish. In that case we should look in the stacks for the task as well as looking in recents. Fixes bug 18017409. Change-Id: Idcfe2e263c9d0fe9a063fdf22515ac4e7fe89ecb --- .../server/am/ActivityManagerService.java | 16 +++++++++++++--- .../com/android/server/am/ActivityStack.java | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 1cf96c33a077e..682642e0199c4 100755 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -8160,6 +8160,16 @@ public final class ActivityManagerService extends ActivityManagerNative } } + private TaskRecord taskForIdLocked(int id) { + final TaskRecord task = recentTaskForIdLocked(id); + if (task != null) { + return task; + } + + // Don't give up. Sometimes it just hasn't made it to recents yet. + return mStackSupervisor.anyTaskForIdLocked(id); + } + private TaskRecord recentTaskForIdLocked(int id) { final int N = mRecentTasks.size(); for (int i=0; i