Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +11 −6 Original line number Diff line number Diff line Loading @@ -781,20 +781,25 @@ public final class ActivityStackSupervisor implements DisplayListener { } } static int nextTaskIdForUser(int taskId, int userId) { int nextTaskId = taskId + 1; if (nextTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { // Wrap around as there will be smaller task ids that are available now. nextTaskId -= MAX_TASK_IDS_PER_USER; } return nextTaskId; } int getNextTaskIdForUserLocked(int userId) { final int currentTaskId = mCurTaskIdForUser.get(userId, userId * MAX_TASK_IDS_PER_USER); // for a userId u, a taskId can only be in the range // [u*MAX_TASK_IDS_PER_USER, (u+1)*MAX_TASK_IDS_PER_USER-1], so if MAX_TASK_IDS_PER_USER // was 10, user 0 could only have taskIds 0 to 9, user 1: 10 to 19, user 2: 20 to 29, so on. int candidateTaskId = currentTaskId; int candidateTaskId = nextTaskIdForUser(currentTaskId, userId); while (mRecentTasks.taskIdTakenForUserLocked(candidateTaskId, userId) || anyTaskForIdLocked(candidateTaskId, !RESTORE_FROM_RECENTS, INVALID_STACK_ID) != null) { candidateTaskId++; if (candidateTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { // Wrap around as there will be smaller task ids that are available now. candidateTaskId -= MAX_TASK_IDS_PER_USER; } candidateTaskId = nextTaskIdForUser(candidateTaskId, userId); if (candidateTaskId == currentTaskId) { // Something wrong! // All MAX_TASK_IDS_PER_USER task ids are taken up by running tasks for this user Loading services/core/java/com/android/server/wm/DisplayContent.java +10 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,16 @@ class DisplayContent { return mHomeStack; } TaskStack getStackById(int stackId) { for (int i = mStacks.size() - 1; i >= 0; --i) { final TaskStack stack = mStacks.get(i); if (stack.mStackId == stackId) { return stack; } } return null; } void updateDisplayInfo() { mDisplay.getDisplayInfo(mDisplayInfo); mDisplay.getMetrics(mDisplayMetrics); Loading services/core/java/com/android/server/wm/WindowManagerService.java +16 −2 Original line number Diff line number Diff line Loading @@ -5047,18 +5047,32 @@ public class WindowManagerService extends IWindowManager.Stub try { synchronized (mWindowMap) { final DisplayContent displayContent = mDisplayContents.get(displayId); boolean attachedToDisplay = false; if (displayContent != null) { TaskStack stack = mStackIdToStack.get(stackId); if (stack == null) { if (DEBUG_STACK) Slog.d(TAG_WM, "attachStack: stackId=" + stackId); stack = displayContent.getStackById(stackId); if (stack != null) { // It's already attached to the display. Detach and re-attach // because onTop might change, and be sure to clear mDeferDetach! displayContent.detachStack(stack); stack.mDeferDetach = false; attachedToDisplay = true; } else { stack = new TaskStack(this, stackId); } mStackIdToStack.put(stackId, stack); if (stackId == DOCKED_STACK_ID) { getDefaultDisplayContentLocked().mDividerControllerLocked .notifyDockedStackExistsChanged(true); } } if (!attachedToDisplay) { stack.attachDisplayContent(displayContent); } displayContent.attachStack(stack, onTop); if (stack.getRawFullscreen()) { return null; Loading Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +11 −6 Original line number Diff line number Diff line Loading @@ -781,20 +781,25 @@ public final class ActivityStackSupervisor implements DisplayListener { } } static int nextTaskIdForUser(int taskId, int userId) { int nextTaskId = taskId + 1; if (nextTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { // Wrap around as there will be smaller task ids that are available now. nextTaskId -= MAX_TASK_IDS_PER_USER; } return nextTaskId; } int getNextTaskIdForUserLocked(int userId) { final int currentTaskId = mCurTaskIdForUser.get(userId, userId * MAX_TASK_IDS_PER_USER); // for a userId u, a taskId can only be in the range // [u*MAX_TASK_IDS_PER_USER, (u+1)*MAX_TASK_IDS_PER_USER-1], so if MAX_TASK_IDS_PER_USER // was 10, user 0 could only have taskIds 0 to 9, user 1: 10 to 19, user 2: 20 to 29, so on. int candidateTaskId = currentTaskId; int candidateTaskId = nextTaskIdForUser(currentTaskId, userId); while (mRecentTasks.taskIdTakenForUserLocked(candidateTaskId, userId) || anyTaskForIdLocked(candidateTaskId, !RESTORE_FROM_RECENTS, INVALID_STACK_ID) != null) { candidateTaskId++; if (candidateTaskId == (userId + 1) * MAX_TASK_IDS_PER_USER) { // Wrap around as there will be smaller task ids that are available now. candidateTaskId -= MAX_TASK_IDS_PER_USER; } candidateTaskId = nextTaskIdForUser(candidateTaskId, userId); if (candidateTaskId == currentTaskId) { // Something wrong! // All MAX_TASK_IDS_PER_USER task ids are taken up by running tasks for this user Loading
services/core/java/com/android/server/wm/DisplayContent.java +10 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,16 @@ class DisplayContent { return mHomeStack; } TaskStack getStackById(int stackId) { for (int i = mStacks.size() - 1; i >= 0; --i) { final TaskStack stack = mStacks.get(i); if (stack.mStackId == stackId) { return stack; } } return null; } void updateDisplayInfo() { mDisplay.getDisplayInfo(mDisplayInfo); mDisplay.getMetrics(mDisplayMetrics); Loading
services/core/java/com/android/server/wm/WindowManagerService.java +16 −2 Original line number Diff line number Diff line Loading @@ -5047,18 +5047,32 @@ public class WindowManagerService extends IWindowManager.Stub try { synchronized (mWindowMap) { final DisplayContent displayContent = mDisplayContents.get(displayId); boolean attachedToDisplay = false; if (displayContent != null) { TaskStack stack = mStackIdToStack.get(stackId); if (stack == null) { if (DEBUG_STACK) Slog.d(TAG_WM, "attachStack: stackId=" + stackId); stack = displayContent.getStackById(stackId); if (stack != null) { // It's already attached to the display. Detach and re-attach // because onTop might change, and be sure to clear mDeferDetach! displayContent.detachStack(stack); stack.mDeferDetach = false; attachedToDisplay = true; } else { stack = new TaskStack(this, stackId); } mStackIdToStack.put(stackId, stack); if (stackId == DOCKED_STACK_ID) { getDefaultDisplayContentLocked().mDividerControllerLocked .notifyDockedStackExistsChanged(true); } } if (!attachedToDisplay) { stack.attachDisplayContent(displayContent); } displayContent.attachStack(stack, onTop); if (stack.getRawFullscreen()) { return null; Loading