"startActivityFromRecentsInner: Task " + taskId + " not found.");
}
- if (launchStackId != INVALID_STACK_ID && task.stack.mStackId != launchStackId) {
+ if (launchStackId != INVALID_STACK_ID) {
if (launchStackId == DOCKED_STACK_ID && bOptions != null) {
ActivityOptions activityOptions = new ActivityOptions(bOptions);
mWindowManager.setDockedStackCreateMode(activityOptions.getDockCreateMode());
}
- mStackSupervisor.moveTaskToStackLocked(
- taskId, launchStackId, ON_TOP, FORCE_FOCUS, "startActivityFromRecents");
+ if (task.stack.mStackId != launchStackId) {
+ mStackSupervisor.moveTaskToStackLocked(
+ taskId, launchStackId, ON_TOP, FORCE_FOCUS, "startActivityFromRecents");
+ }
}
if (task.getRootActivity() != null) {
Rect rect = new Rect();
try {
synchronized (this) {
- TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(
+ taskId, !RESTORE_FROM_RECENTS, INVALID_STACK_ID);
if (task == null) {
Slog.w(TAG, "getTaskBounds: taskId=" + taskId + " not found");
return rect;
}
- mWindowManager.getTaskBounds(task.taskId, rect);
+ if (task.stack != null) {
+ // Return the bounds from window manager since it will be adjusted for various
+ // things like the presense of a docked stack for tasks that aren't resizeable.
+ mWindowManager.getTaskBounds(task.taskId, rect);
+ } else {
+ // Task isn't in window manager yet since it isn't associated with a stack.
+ // Return the persist value from activity manager
+ if (task.mBounds != null) {
+ rect.set(task.mBounds);
+ } else if (task.mLastNonFullscreenBounds != null) {
+ rect.set(task.mLastNonFullscreenBounds);
+ }
+ }
}
} finally {
Binder.restoreCallingIdentity(ident);
task.stack.removeTask(task, "restoreRecentTaskLocked", MOVING);
}
- ActivityStack stack =
+ final ActivityStack stack =
getStack(stackId, CREATE_IF_NEEDED, !ON_TOP);
if (stack == null) {
Slog.w(TAG, "moveTaskToStack: no task for id=" + taskId);
return;
}
- if (StackId.preserveWindowOnTaskMove(stackId)) {
+
+ final ActivityRecord topActivity = task.getTopActivity();
+ if (StackId.preserveWindowOnTaskMove(stackId) && topActivity != null) {
// We are about to relaunch the activity because its configuration changed due to
// being maximized, i.e. size change. The activity will first remove the old window
// and then add a new one. This call will tell window manager about this, so it can
// preserve the old window until the new one is drawn. This prevents having a gap
// between the removal and addition, in which no window is visible. We also want the
// entrance of the new window to be properly animated.
- ActivityRecord r = task.getTopActivity();
- mWindowManager.setReplacingWindow(r.appToken, true /* animate */);
+ mWindowManager.setReplacingWindow(topActivity.appToken, true /* animate */);
}
final ActivityStack stack =
moveTaskToStackUncheckedLocked(task, stackId, toTop, forceFocus,
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
+import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
sb.append(stringName);
sb.append(" U=");
sb.append(userId);
+ sb.append(" StackId=");
+ sb.append(stack != null ? stack.mStackId : INVALID_STACK_ID);
sb.append(" sz=");
sb.append(mActivities.size());
sb.append('}');