voiceInteractor);
// add the task to stack first, mTaskPositioner might need the stack association
addTask(task, toTop, false);
- if (mTaskPositioner != null) {
- mTaskPositioner.updateDefaultBounds(task, mTaskHistory, info.layout);
- } else if (mBounds != null && task.mResizeable) {
+ if (!layoutTaskInStack(task, info.layout) && mBounds != null && task.mResizeable) {
task.updateOverrideConfiguration(mBounds);
}
return task;
}
+ boolean layoutTaskInStack(TaskRecord task, ActivityInfo.Layout layout) {
+ if (mTaskPositioner == null) {
+ return false;
+ }
+ mTaskPositioner.updateDefaultBounds(task, mTaskHistory, layout);
+ return true;
+ }
+
ArrayList<TaskRecord> getAllTasks() {
return new ArrayList<>(mTaskHistory);
}
Slog.w(TAG, "positionTaskInStackLocked: no task for id=" + taskId);
return;
}
- ActivityStack stack =
- getStack(stackId, CREATE_IF_NEEDED, !ON_TOP);
- mWindowManager.positionTaskInStack(taskId, stackId, position);
+ final ActivityStack stack = getStack(stackId, CREATE_IF_NEEDED, !ON_TOP);
+
+ task.updateOverrideConfigurationForStack(stack);
+
+ mWindowManager.positionTaskInStack(
+ taskId, stackId, position, task.mBounds, task.mOverrideConfig);
final boolean stackChanged = task.stack != null && task.stack != stack;
if (stackChanged) {
task.stack.removeTask(task, "moveTaskToStack", MOVING);
return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null;
}
+ /** Updates the task's bounds and override configuration to match what is expected for the
+ * input stack. */
+ void updateOverrideConfigurationForStack(ActivityStack inStack) {
+ if (stack != null && stack == inStack) {
+ return;
+ }
+
+ if (inStack.mStackId == FREEFORM_WORKSPACE_STACK_ID) {
+ if (!mResizeable) {
+ throw new IllegalArgumentException("Can not position non-resizeable task="
+ + this + " in stack=" + inStack);
+ }
+ if (mBounds != null) {
+ return;
+ }
+ if (mLastNonFullscreenBounds != null) {
+ updateOverrideConfiguration(mLastNonFullscreenBounds);
+ } else {
+ inStack.layoutTaskInStack(this, null);
+ }
+ } else {
+ updateOverrideConfiguration(inStack.mBounds);
+ }
+ }
+
/**
* Returns the correct stack to use based on task type and currently set bounds,
* regardless of the focused stack and current stack association of the task.
stack.addTask(this, toTop);
}
- void positionTaskInStack(TaskStack stack, int position) {
+ void positionTaskInStack(TaskStack stack, int position, Rect bounds, Configuration config) {
if (mStack != null && stack != mStack) {
if (DEBUG_STACK) Slog.i(TAG, "positionTaskInStack: removing taskId=" + mTaskId
+ " from stack=" + mStack);
mStack.removeTask(this);
}
stack.positionTask(this, position, showForAllUsers());
+ setBounds(bounds, config);
}
boolean removeAppToken(AppWindowToken wtoken) {
}
}
- public void positionTaskInStack(int taskId, int stackId, int position) {
+ public void positionTaskInStack(int taskId, int stackId, int position, Rect bounds,
+ Configuration config) {
synchronized (mWindowMap) {
if (DEBUG_STACK) Slog.i(TAG, "positionTaskInStack: positioning taskId=" + taskId
+ " in stackId=" + stackId + " at " + position);
"positionTaskInStack: could not find stackId=" + stackId);
return;
}
- task.positionTaskInStack(stack, position);
+ task.positionTaskInStack(stack, position, bounds, config);
final DisplayContent displayContent = stack.getDisplayContent();
displayContent.layoutNeeded = true;
mWindowPlacerLocked.performSurfacePlacement();