am 93cb8f6b: Merge "Create new window-side task on demand." into klp-dev

* commit '93cb8f6b78079f10836377e825c7f7b63b8e7c21':
  Create new window-side task on demand.
This commit is contained in:
Craig Mautner
2013-10-02 10:49:11 -07:00
committed by Android Git Automerger

View File

@@ -3379,6 +3379,18 @@ public class WindowManagerService extends IWindowManager.Stub
Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId);
} }
private Task createTask(int taskId, int stackId, int userId, AppWindowToken atoken) {
final TaskStack stack = mStackIdToStack.get(stackId);
if (stack == null) {
throw new IllegalArgumentException("addAppToken: invalid stackId=" + stackId);
}
Task task = new Task(atoken, stack, userId);
stack.addTask(task, true);
stack.getDisplayContent().moveStack(stack, true);
mTaskIdToTask.put(taskId, task);
return task;
}
@Override @Override
public void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId, public void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId,
int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId) { int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId) {
@@ -3418,14 +3430,7 @@ public class WindowManagerService extends IWindowManager.Stub
Task task = mTaskIdToTask.get(taskId); Task task = mTaskIdToTask.get(taskId);
if (task == null) { if (task == null) {
TaskStack stack = mStackIdToStack.get(stackId); task = createTask(taskId, stackId, userId, atoken);
if (stack == null) {
throw new IllegalArgumentException("addAppToken: invalid stackId=" + stackId);
}
task = new Task(atoken, stack, userId);
stack.addTask(task, true);
stack.getDisplayContent().moveStack(stack, true);
mTaskIdToTask.put(taskId, task);
} else { } else {
task.addAppToken(addPos, atoken); task.addAppToken(addPos, atoken);
} }
@@ -3459,8 +3464,7 @@ public class WindowManagerService extends IWindowManager.Stub
atoken.groupId = groupId; atoken.groupId = groupId;
Task newTask = mTaskIdToTask.get(groupId); Task newTask = mTaskIdToTask.get(groupId);
if (newTask == null) { if (newTask == null) {
throw new IllegalStateException("setAppGroupId: groupId=" + groupId newTask = createTask(groupId, oldTask.mStack.mStackId, oldTask.mUserId, atoken);
+ " does not exist");
} }
newTask.mAppTokens.add(atoken); newTask.mAppTokens.add(atoken);
} }
@@ -4786,6 +4790,7 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized(mWindowMap) { synchronized(mWindowMap) {
Task task = mTaskIdToTask.get(taskId); Task task = mTaskIdToTask.get(taskId);
if (task == null) { if (task == null) {
// Normal behavior, addAppToken will be called next and task will be created.
return; return;
} }
final TaskStack stack = task.mStack; final TaskStack stack = task.mStack;