From 3c800a49178552d52354592790396a1e1f7ee8ef Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Fri, 15 Apr 2016 19:44:50 -0700 Subject: [PATCH] Set correct stack before restoring tasks When restoring a task when starting it from recents, we need to set all the relevant state for the transition before we actually restore the task and attach the docked stack, as all kinds of weird things might go wrong otherwise. Bug: 28194162 Bug: 27607141 Change-Id: I21d173a43c62d425e507e8cc3a1a576f95cfe048 --- .../server/am/ActivityStackSupervisor.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 762cb1aba7778..8f7f396418df4 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -4356,28 +4356,31 @@ public final class ActivityStackSupervisor implements DisplayListener { ? new ActivityOptions(bOptions) : null; final int launchStackId = (activityOptions != null) ? activityOptions.getLaunchStackId() : INVALID_STACK_ID; - if (launchStackId == HOME_STACK_ID) { throw new IllegalArgumentException("startActivityFromRecentsInner: Task " + taskId + " can't be launch in the home stack."); } + + if (launchStackId == DOCKED_STACK_ID) { + mWindowManager.setDockedStackCreateState( + activityOptions.getDockCreateMode(), null /* initialBounds */); + + // Defer updating the stack in which recents is until the app transition is done, to + // not run into issues where we still need to draw the task in recents but the + // docked stack is already created. + deferUpdateBounds(HOME_STACK_ID); + mWindowManager.prepareAppTransition(TRANSIT_DOCK_TASK_FROM_RECENTS, false); + } + task = anyTaskForIdLocked(taskId, RESTORE_FROM_RECENTS, launchStackId); if (task == null) { + continueUpdateBounds(HOME_STACK_ID); + mWindowManager.executeAppTransition(); throw new IllegalArgumentException( "startActivityFromRecentsInner: Task " + taskId + " not found."); } if (launchStackId != INVALID_STACK_ID) { - if (launchStackId == DOCKED_STACK_ID) { - mWindowManager.setDockedStackCreateState( - activityOptions.getDockCreateMode(), null /* initialBounds */); - - // Defer updating the stack in which recents is until the app transition is done, to - // not run into issues where we still need to draw the task in recents but the - // docked stack is already created. - deferUpdateBounds(HOME_STACK_ID); - mWindowManager.prepareAppTransition(TRANSIT_DOCK_TASK_FROM_RECENTS, false); - } if (task.stack.mStackId != launchStackId) { moveTaskToStackLocked( taskId, launchStackId, ON_TOP, FORCE_FOCUS, "startActivityFromRecents", @@ -4405,12 +4408,12 @@ public final class ActivityStackSupervisor implements DisplayListener { intent = task.intent; intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); userId = task.userId; - int result = mService.startActivityInPackage(callingUid, callingPackage, intent, null, - null, null, 0, 0, bOptions, userId, null, task); - if (launchStackId == DOCKED_STACK_ID) { - setResizingDuringAnimation(task.taskId); - } - return result; + int result = mService.startActivityInPackage(callingUid, callingPackage, intent, null, + null, null, 0, 0, bOptions, userId, null, task); + if (launchStackId == DOCKED_STACK_ID) { + setResizingDuringAnimation(task.taskId); + } + return result; } /**