Loading services/core/java/com/android/server/wm/DisplayContent.java +10 −14 Original line number Original line Diff line number Diff line Loading @@ -2260,9 +2260,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp taskDisplayArea.getRootTask(rootTaskId)); taskDisplayArea.getRootTask(rootTaskId)); } } protected int getRootTaskCount() { int getRootTaskCount() { return reduceOnAllTaskDisplayAreas((taskDisplayArea, count) -> final int[] count = new int[1]; count + taskDisplayArea.getRootTaskCount(), 0 /* initValue */); forAllRootTasks(task -> { count[0]++; }); return count[0]; } } @VisibleForTesting @VisibleForTesting Loading Loading @@ -5353,19 +5356,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } } // Check if all task display areas have only the empty home stacks left. // Check if all task display areas have only the empty home stacks left. boolean hasNonEmptyHomeStack = forAllTaskDisplayAreas(taskDisplayArea -> { boolean hasNonEmptyHomeStack = forAllRootTasks(stack -> if (taskDisplayArea.getRootTaskCount() != 1) { !stack.isActivityTypeHome() || stack.hasChild()); return true; if (!hasNonEmptyHomeStack && getRootTaskCount() > 0) { } final Task stack = taskDisplayArea.getRootTaskAt(0); return !stack.isActivityTypeHome() || stack.hasChild(); }); if (!hasNonEmptyHomeStack) { // Release this display if only empty home stack(s) are left. This display will be // Release this display if only empty home stack(s) are left. This display will be // released along with the stack(s) removal. // released along with the stack(s) removal. forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(Task::removeIfPossible); taskDisplayArea.getRootTaskAt(0).removeIfPossible(); }); } else if (getTopRootTask() == null) { } else if (getTopRootTask() == null) { removeIfPossible(); removeIfPossible(); mRootWindowContainer.mTaskSupervisor mRootWindowContainer.mTaskSupervisor Loading services/core/java/com/android/server/wm/KeyguardController.java +2 −10 Original line number Original line Diff line number Diff line Loading @@ -594,16 +594,8 @@ class KeyguardController { */ */ @Nullable @Nullable private Task getRootTaskForControllingOccluding(DisplayContent display) { private Task getRootTaskForControllingOccluding(DisplayContent display) { return display.getItemFromTaskDisplayAreas(taskDisplayArea -> { return display.getRootTask(task -> for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { task != null && task.isFocusableAndVisible() && !task.inPinnedWindowingMode()); final Task task = taskDisplayArea.getRootTaskAt(sNdx); if (task != null && task.isFocusableAndVisible() && !task.inPinnedWindowingMode()) { return task; } } return null; }); } } void dumpStatus(PrintWriter pw, String prefix) { void dumpStatus(PrintWriter pw, String prefix) { Loading services/core/java/com/android/server/wm/RecentsAnimation.java +2 −8 Original line number Original line Diff line number Diff line Loading @@ -468,14 +468,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan * @return The top stack that is not always-on-top. * @return The top stack that is not always-on-top. */ */ private Task getTopNonAlwaysOnTopStack() { private Task getTopNonAlwaysOnTopStack() { for (int i = mDefaultTaskDisplayArea.getRootTaskCount() - 1; i >= 0; i--) { return mDefaultTaskDisplayArea.getRootTask(task -> final Task s = mDefaultTaskDisplayArea.getRootTaskAt(i); !task.getWindowConfiguration().isAlwaysOnTop()); if (s.getWindowConfiguration().isAlwaysOnTop()) { continue; } return s; } return null; } } /** /** Loading services/core/java/com/android/server/wm/RootWindowContainer.java +150 −208 Original line number Original line Diff line number Diff line Loading @@ -1835,10 +1835,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> final ArrayList<IBinder> topActivityTokens = new ArrayList<>(); final ArrayList<IBinder> topActivityTokens = new ArrayList<>(); final Task topFocusedStack = getTopDisplayFocusedRootTask(); final Task topFocusedStack = getTopDisplayFocusedRootTask(); // Traverse all displays. // Traverse all displays. forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { // Traverse all stacks on a display area. for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); // Get top activity from a visible stack and add it to the list. // Get top activity from a visible stack and add it to the list. if (stack.shouldBeVisible(null /* starting */)) { if (stack.shouldBeVisible(null /* starting */)) { final ActivityRecord top = stack.getTopNonFinishingActivity(); final ActivityRecord top = stack.getTopNonFinishingActivity(); Loading @@ -1850,7 +1847,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } } } } } } }); }); return topActivityTokens; return topActivityTokens; } } Loading Loading @@ -1892,21 +1888,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // First, found out what is currently the foreground app, so that we don't blow away the // First, found out what is currently the foreground app, so that we don't blow away the // previous app if this activity is being hosted by the process that is actually still the // previous app if this activity is being hosted by the process that is actually still the // foreground. // foreground. WindowProcessController fgApp = reduceOnAllTaskDisplayAreas((taskDisplayArea, app) -> { WindowProcessController fgApp = getItemFromRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (isTopDisplayFocusedRootTask(stack)) { if (isTopDisplayFocusedRootTask(stack)) { final ActivityRecord resumedActivity = stack.getResumedActivity(); final ActivityRecord resumedActivity = stack.getResumedActivity(); if (resumedActivity != null) { if (resumedActivity != null) { app = resumedActivity.app; return resumedActivity.app; } else if (stack.mPausingActivity != null) { } else if (stack.mPausingActivity != null) { app = stack.mPausingActivity.app; return stack.mPausingActivity.app; } break; } } } } return app; return null; }, null /* initValue */); }); // Now set this one as the previous process, only if that really makes sense to. // Now set this one as the previous process, only if that really makes sense to. if (r.hasProcess() && fgApp != null && r.app != fgApp if (r.hasProcess() && fgApp != null && r.app != fgApp Loading @@ -1923,15 +1915,13 @@ class RootWindowContainer extends WindowContainer<DisplayContent> mTmpRemoteException = null; mTmpRemoteException = null; mTmpBoolean = false; // Set to true if an activity was started. mTmpBoolean = false; // Set to true if an activity was started. final DisplayContent display = getChildAt(displayNdx); final DisplayContent display = getChildAt(displayNdx); display.forAllTaskDisplayAreas(displayArea -> { display.forAllRootTasks(rootTask -> { if (mTmpRemoteException != null) { if (mTmpRemoteException != null) { return; return; } } for (int taskNdx = displayArea.getRootTaskCount() - 1; taskNdx >= 0; --taskNdx) { final Task rootTask = displayArea.getRootTaskAt(taskNdx); if (rootTask.getVisibility(null /*starting*/) == TASK_VISIBILITY_INVISIBLE) { if (rootTask.getVisibility(null /*starting*/) == TASK_VISIBILITY_INVISIBLE) { break; return; } } final PooledFunction c = PooledLambda.obtainFunction( final PooledFunction c = PooledLambda.obtainFunction( Loading @@ -1940,10 +1930,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> rootTask.topRunningActivity()); rootTask.topRunningActivity()); rootTask.forAllActivities(c); rootTask.forAllActivities(c); c.recycle(); c.recycle(); if (mTmpRemoteException != null) { return; } } }); }); if (mTmpRemoteException != null) { if (mTmpRemoteException != null) { throw mTmpRemoteException; throw mTmpRemoteException; Loading Loading @@ -2027,11 +2013,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> mCurrentUser = userId; mCurrentUser = userId; mTaskSupervisor.mStartingUsers.add(uss); mTaskSupervisor.mStartingUsers.add(uss); forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); stack.switchUser(userId); stack.switchUser(userId); } }); }); final int restoreStackId = mUserRootTaskInFront.get(userId); final int restoreStackId = mUserRootTaskInFront.get(userId); Loading Loading @@ -2294,20 +2277,14 @@ class RootWindowContainer extends WindowContainer<DisplayContent> */ */ int finishTopCrashedActivities(WindowProcessController app, String reason) { int finishTopCrashedActivities(WindowProcessController app, String reason) { Task focusedStack = getTopDisplayFocusedRootTask(); Task focusedStack = getTopDisplayFocusedRootTask(); Task finishedTask = reduceOnAllTaskDisplayAreas((taskDisplayArea, task) -> { final Task[] finishedTask = new Task[1]; // It is possible that request to finish activity might also remove its task and forAllTasks(stack -> { // stack, so we need to be careful with indexes in the loop and check child count // every time. for (int stackNdx = 0; stackNdx < taskDisplayArea.getRootTaskCount(); ++stackNdx) { final Task stack = taskDisplayArea.getRootTaskAt(stackNdx); final Task t = stack.finishTopCrashedActivityLocked(app, reason); final Task t = stack.finishTopCrashedActivityLocked(app, reason); if (stack == focusedStack || task == null) { if (stack == focusedStack || finishedTask[0] == null) { task = t; finishedTask[0] = t; } } } return task; }); }, null /* initValue */); return finishedTask[0] != null ? finishedTask[0].mTaskId : INVALID_TASK_ID; return finishedTask != null ? finishedTask.mTaskId : INVALID_TASK_ID; } } boolean resumeFocusedTasksTopActivities() { boolean resumeFocusedTasksTopActivities() { Loading @@ -2330,36 +2307,32 @@ class RootWindowContainer extends WindowContainer<DisplayContent> for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) { for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) { final DisplayContent display = getChildAt(displayNdx); final DisplayContent display = getChildAt(displayNdx); final boolean curResult = result; final boolean curResult = result; boolean resumedOnDisplay = display.reduceOnAllTaskDisplayAreas( boolean[] resumedOnDisplay = new boolean[1]; (taskDisplayArea, resumed) -> { display.forAllRootTasks(rootTask -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task rootTask = taskDisplayArea.getRootTaskAt(sNdx); final ActivityRecord topRunningActivity = rootTask.topRunningActivity(); final ActivityRecord topRunningActivity = rootTask.topRunningActivity(); if (!rootTask.isFocusableAndVisible() || topRunningActivity == null) { if (!rootTask.isFocusableAndVisible() || topRunningActivity == null) { continue; return; } } if (rootTask == targetRootTask) { if (rootTask == targetRootTask) { // Simply update the result for targetStack because the targetStack // Simply update the result for targetStack because the targetStack // had already resumed in above. We don't want to resume it again, // had already resumed in above. We don't want to resume it again, // especially in some cases, it would cause a second launch failure // especially in some cases, it would cause a second launch failure // if app process was dead. // if app process was dead. resumed |= curResult; resumedOnDisplay[0] |= curResult; continue; return; } } if (taskDisplayArea.isTopRootTask(rootTask) if (rootTask.getDisplayArea().isTopRootTask(rootTask) && topRunningActivity.isState(RESUMED)) { && topRunningActivity.isState(RESUMED)) { // Kick off any lingering app transitions form the MoveTaskToFront // Kick off any lingering app transitions form the MoveTaskToFront // operation, but only consider the top task and stack on that // operation, but only consider the top task and stack on that // display. // display. rootTask.executeAppTransition(targetOptions); rootTask.executeAppTransition(targetOptions); } else { } else { resumed |= topRunningActivity.makeActiveIfNeeded(target); resumedOnDisplay[0] |= topRunningActivity.makeActiveIfNeeded(target); } } } }); return resumed; result |= resumedOnDisplay[0]; }, false /* initValue */); if (!resumedOnDisplay[0]) { result |= resumedOnDisplay; if (!resumedOnDisplay) { // In cases when there are no valid activities (e.g. device just booted or launcher // In cases when there are no valid activities (e.g. device just booted or launcher // crashed) it's possible that nothing was resumed on a display. Requesting resume // crashed) it's possible that nothing was resumed on a display. Requesting resume // of top activity in focused stack explicitly will make sure that at least home // of top activity in focused stack explicitly will make sure that at least home Loading Loading @@ -2392,9 +2365,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } // Set the sleeping state of the stacks on the display. // Set the sleeping state of the stacks on the display. display.forAllTaskDisplayAreas(taskDisplayArea -> { display.forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (displayShouldSleep) { if (displayShouldSleep) { stack.goToSleepIfPossible(false /* shuttingDown */); stack.goToSleepIfPossible(false /* shuttingDown */); } else { } else { Loading @@ -2416,7 +2387,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> stack.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, stack.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, false /* preserveWindows */); false /* preserveWindows */); } } } }); }); } } } } Loading Loading @@ -2512,13 +2482,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent> /** If displayId == INVALID_DISPLAY, this will get root task infos on all displays */ /** If displayId == INVALID_DISPLAY, this will get root task infos on all displays */ ArrayList<RootTaskInfo> getAllRootTaskInfos(int displayId) { ArrayList<RootTaskInfo> getAllRootTaskInfos(int displayId) { ArrayList<RootTaskInfo> list = new ArrayList<>(); final ArrayList<RootTaskInfo> list = new ArrayList<>(); if (displayId == INVALID_DISPLAY) { if (displayId == INVALID_DISPLAY) { forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); list.add(getRootTaskInfo(stack)); list.add(getRootTaskInfo(stack)); } }); }); return list; return list; } } Loading @@ -2526,11 +2493,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> if (display == null) { if (display == null) { return list; return list; } } display.forAllTaskDisplayAreas(taskDisplayArea -> { display.forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); list.add(getRootTaskInfo(stack)); list.add(getRootTaskInfo(stack)); } }); }); return list; return list; } } Loading Loading @@ -2603,10 +2567,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent> Task findRootTaskBehind(Task rootTask) { Task findRootTaskBehind(Task rootTask) { final TaskDisplayArea taskDisplayArea = rootTask.getDisplayArea(); final TaskDisplayArea taskDisplayArea = rootTask.getDisplayArea(); if (taskDisplayArea != null) { if (taskDisplayArea != null) { for (int i = taskDisplayArea.getRootTaskCount() - 1; i >= 0; i--) { final boolean[] hasFound = new boolean[1]; if (taskDisplayArea.getRootTaskAt(i) == rootTask && i > 0) { // TODO(b/175136051): should this be only the direct child root task? return taskDisplayArea.getRootTaskAt(i - 1); final Task rootTaskBehind = taskDisplayArea.getRootTask(task -> { if (hasFound[0]) { return true; } } hasFound[0] = task == rootTask; return false; }); if (rootTaskBehind != null) { return rootTaskBehind; } } } } throw new IllegalStateException("Failed to find a root task behind root task =" + rootTask throw new IllegalStateException("Failed to find a root task behind root task =" + rootTask Loading Loading @@ -2748,24 +2719,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // Tries to put all activity tasks to sleep. Returns true if all tasks were // Tries to put all activity tasks to sleep. Returns true if all tasks were // successfully put to sleep. // successfully put to sleep. boolean putTasksToSleep(boolean allowDelay, boolean shuttingDown) { boolean putTasksToSleep(boolean allowDelay, boolean shuttingDown) { return reduceOnAllTaskDisplayAreas((taskDisplayArea, result) -> { final boolean[] result = {true}; for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { forAllRootTasks(task -> { // Stacks and activities could be removed while putting activities to sleep if // the app process was gone. This prevents us getting exception by accessing an // invalid stack index. if (sNdx >= taskDisplayArea.getRootTaskCount()) { continue; } final Task task = taskDisplayArea.getRootTaskAt(sNdx); if (allowDelay) { if (allowDelay) { result &= task.goToSleepIfPossible(shuttingDown); result[0] &= task.goToSleepIfPossible(shuttingDown); } else { } else { task.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, task.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, !PRESERVE_WINDOWS); !PRESERVE_WINDOWS); } } } }); return result; return result[0]; }, true /* initValue */); } } void handleAppCrash(WindowProcessController app) { void handleAppCrash(WindowProcessController app) { Loading Loading @@ -3021,11 +2984,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> r.getActivityType()); r.getActivityType()); // Return the topmost valid stack on the display. // Return the topmost valid stack on the display. for (int i = taskDisplayArea.getRootTaskCount() - 1; i >= 0; --i) { final int targetWindowingMode = windowingMode; final Task stack = taskDisplayArea.getRootTaskAt(i); final Task topmostValidStack = taskDisplayArea.getRootTask(stack -> if (isValidLaunchRootTask(stack, r, windowingMode)) { isValidLaunchRootTask(stack, r, targetWindowingMode)); return stack; if (topmostValidStack != null) { } return topmostValidStack; } } // If there is no valid stack on the secondary display area - check if new dynamic stack // If there is no valid stack on the secondary display area - check if new dynamic stack Loading Loading @@ -3260,12 +3223,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } void finishVoiceTask(IVoiceInteractionSession session) { void finishVoiceTask(IVoiceInteractionSession session) { forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { final int numStacks = taskDisplayArea.getRootTaskCount(); for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) { final Task stack = taskDisplayArea.getRootTaskAt(stackNdx); stack.finishVoiceTask(session); stack.finishVoiceTask(session); } }); }); } } Loading Loading @@ -3324,10 +3283,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> boolean allResumedActivitiesVisible() { boolean allResumedActivitiesVisible() { boolean[] foundResumed = {false}; boolean[] foundResumed = {false}; final boolean foundInvisibleResumedActivity = forAllTaskDisplayAreas( final boolean foundInvisibleResumedActivity = forAllRootTasks(stack -> { taskDisplayArea -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); final ActivityRecord r = stack.getResumedActivity(); final ActivityRecord r = stack.getResumedActivity(); if (r != null) { if (r != null) { if (!r.nowVisible) { if (!r.nowVisible) { Loading @@ -3335,7 +3291,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } foundResumed[0] = true; foundResumed[0] = true; } } } return false; return false; }); }); if (foundInvisibleResumedActivity) { if (foundInvisibleResumedActivity) { Loading @@ -3346,10 +3301,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> boolean allPausedActivitiesComplete() { boolean allPausedActivitiesComplete() { boolean[] pausing = {true}; boolean[] pausing = {true}; final boolean hasActivityNotCompleted = forAllTaskDisplayAreas( final boolean hasActivityNotCompleted = forAllRootTasks(stack -> { taskDisplayArea -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); final ActivityRecord r = stack.mPausingActivity; final ActivityRecord r = stack.mPausingActivity; if (r != null && !r.isState(PAUSED, STOPPED, STOPPING, FINISHING)) { if (r != null && !r.isState(PAUSED, STOPPED, STOPPING, FINISHING)) { ProtoLog.d(WM_DEBUG_STATES, "allPausedActivitiesComplete: " ProtoLog.d(WM_DEBUG_STATES, "allPausedActivitiesComplete: " Loading @@ -3360,7 +3312,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return true; return true; } } } } } return false; return false; }); }); if (hasActivityNotCompleted) { if (hasActivityNotCompleted) { Loading Loading @@ -3413,13 +3364,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } void cancelInitializingActivities() { void cancelInitializingActivities() { forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(task -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { // We don't want to clear starting window for activities that aren't occluded // We don't want to clear starting window for activities that aren't occluded // as we need to display their starting window until they are done initializing. // as we need to display their starting window until they are done initializing. taskDisplayArea.getRootTaskAt(sNdx).forAllOccludedActivities( task.forAllOccludedActivities(ActivityRecord::cancelInitializing); ActivityRecord::cancelInitializing); } }); }); } } Loading Loading @@ -3579,14 +3527,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return new ArrayList<>(); return new ArrayList<>(); } } } else { } else { ArrayList<ActivityRecord> activities = new ArrayList<>(); final ArrayList<ActivityRecord> activities = new ArrayList<>(); forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (!dumpVisibleStacksOnly || stack.shouldBeVisible(null)) { if (!dumpVisibleStacksOnly || stack.shouldBeVisible(null)) { activities.addAll(stack.getDumpActivitiesLocked(name)); activities.addAll(stack.getDumpActivitiesLocked(name)); } } } }); }); return activities; return activities; } } Loading Loading @@ -3635,15 +3580,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent> pw.print("Display #"); pw.print("Display #"); pw.print(displayContent.mDisplayId); pw.print(displayContent.mDisplayId); pw.println(" (activities from top to bottom):"); pw.println(" (activities from top to bottom):"); displayContent.forAllTaskDisplayAreas(taskDisplayArea -> { displayContent.forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (needSep[0]) { if (needSep[0]) { pw.println(); pw.println(); } } needSep[0] = stack.dump(fd, pw, dumpAll, dumpClient, dumpPackage, false); needSep[0] = stack.dump(fd, pw, dumpAll, dumpClient, dumpPackage, false); printed[0] |= needSep[0]; printed[0] |= needSep[0]; } }); }); displayContent.forAllTaskDisplayAreas(taskDisplayArea -> { displayContent.forAllTaskDisplayAreas(taskDisplayArea -> { printed[0] |= printThisActivity(pw, taskDisplayArea.getFocusedActivity(), printed[0] |= printThisActivity(pw, taskDisplayArea.getFocusedActivity(), Loading services/core/java/com/android/server/wm/Task.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -3877,6 +3877,13 @@ class Task extends WindowContainer<WindowContainer> { callback.accept(this); callback.accept(this); } } @Override void forAllRootTasks(Consumer<Task> callback, boolean traverseTopToBottom) { if (isRootTask()) { callback.accept(this); } } @Override @Override boolean forAllTasks(Function<Task, Boolean> callback) { boolean forAllTasks(Function<Task, Boolean> callback) { if (super.forAllTasks(callback)) return true; if (super.forAllTasks(callback)) return true; Loading @@ -3901,6 +3908,11 @@ class Task extends WindowContainer<WindowContainer> { return false; return false; } } @Override boolean forAllRootTasks(Function<Task, Boolean> callback, boolean traverseTopToBottom) { return isRootTask() ? callback.apply(this) : false; } @Override @Override Task getTask(Predicate<Task> callback, boolean traverseTopToBottom) { Task getTask(Predicate<Task> callback, boolean traverseTopToBottom) { final Task t = super.getTask(callback, traverseTopToBottom); final Task t = super.getTask(callback, traverseTopToBottom); Loading @@ -3908,6 +3920,18 @@ class Task extends WindowContainer<WindowContainer> { return callback.test(this) ? this : null; return callback.test(this) ? this : null; } } @Nullable @Override Task getRootTask(Predicate<Task> callback, boolean traverseTopToBottom) { return isRootTask() && callback.test(this) ? this : null; } @Nullable @Override <R> R getItemFromRootTasks(Function<Task, R> callback, boolean traverseTopToBottom) { return isRootTask() ? callback.apply(this) : null; } /** /** * @param canAffectSystemUiFlags If false, all windows in this task can not affect SystemUI * @param canAffectSystemUiFlags If false, all windows in this task can not affect SystemUI * flags. See {@link WindowState#canAffectSystemUiFlags()}. * flags. See {@link WindowState#canAffectSystemUiFlags()}. Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +10 −14 Original line number Original line Diff line number Diff line Loading @@ -2260,9 +2260,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp taskDisplayArea.getRootTask(rootTaskId)); taskDisplayArea.getRootTask(rootTaskId)); } } protected int getRootTaskCount() { int getRootTaskCount() { return reduceOnAllTaskDisplayAreas((taskDisplayArea, count) -> final int[] count = new int[1]; count + taskDisplayArea.getRootTaskCount(), 0 /* initValue */); forAllRootTasks(task -> { count[0]++; }); return count[0]; } } @VisibleForTesting @VisibleForTesting Loading Loading @@ -5353,19 +5356,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } } // Check if all task display areas have only the empty home stacks left. // Check if all task display areas have only the empty home stacks left. boolean hasNonEmptyHomeStack = forAllTaskDisplayAreas(taskDisplayArea -> { boolean hasNonEmptyHomeStack = forAllRootTasks(stack -> if (taskDisplayArea.getRootTaskCount() != 1) { !stack.isActivityTypeHome() || stack.hasChild()); return true; if (!hasNonEmptyHomeStack && getRootTaskCount() > 0) { } final Task stack = taskDisplayArea.getRootTaskAt(0); return !stack.isActivityTypeHome() || stack.hasChild(); }); if (!hasNonEmptyHomeStack) { // Release this display if only empty home stack(s) are left. This display will be // Release this display if only empty home stack(s) are left. This display will be // released along with the stack(s) removal. // released along with the stack(s) removal. forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(Task::removeIfPossible); taskDisplayArea.getRootTaskAt(0).removeIfPossible(); }); } else if (getTopRootTask() == null) { } else if (getTopRootTask() == null) { removeIfPossible(); removeIfPossible(); mRootWindowContainer.mTaskSupervisor mRootWindowContainer.mTaskSupervisor Loading
services/core/java/com/android/server/wm/KeyguardController.java +2 −10 Original line number Original line Diff line number Diff line Loading @@ -594,16 +594,8 @@ class KeyguardController { */ */ @Nullable @Nullable private Task getRootTaskForControllingOccluding(DisplayContent display) { private Task getRootTaskForControllingOccluding(DisplayContent display) { return display.getItemFromTaskDisplayAreas(taskDisplayArea -> { return display.getRootTask(task -> for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { task != null && task.isFocusableAndVisible() && !task.inPinnedWindowingMode()); final Task task = taskDisplayArea.getRootTaskAt(sNdx); if (task != null && task.isFocusableAndVisible() && !task.inPinnedWindowingMode()) { return task; } } return null; }); } } void dumpStatus(PrintWriter pw, String prefix) { void dumpStatus(PrintWriter pw, String prefix) { Loading
services/core/java/com/android/server/wm/RecentsAnimation.java +2 −8 Original line number Original line Diff line number Diff line Loading @@ -468,14 +468,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan * @return The top stack that is not always-on-top. * @return The top stack that is not always-on-top. */ */ private Task getTopNonAlwaysOnTopStack() { private Task getTopNonAlwaysOnTopStack() { for (int i = mDefaultTaskDisplayArea.getRootTaskCount() - 1; i >= 0; i--) { return mDefaultTaskDisplayArea.getRootTask(task -> final Task s = mDefaultTaskDisplayArea.getRootTaskAt(i); !task.getWindowConfiguration().isAlwaysOnTop()); if (s.getWindowConfiguration().isAlwaysOnTop()) { continue; } return s; } return null; } } /** /** Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +150 −208 Original line number Original line Diff line number Diff line Loading @@ -1835,10 +1835,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> final ArrayList<IBinder> topActivityTokens = new ArrayList<>(); final ArrayList<IBinder> topActivityTokens = new ArrayList<>(); final Task topFocusedStack = getTopDisplayFocusedRootTask(); final Task topFocusedStack = getTopDisplayFocusedRootTask(); // Traverse all displays. // Traverse all displays. forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { // Traverse all stacks on a display area. for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); // Get top activity from a visible stack and add it to the list. // Get top activity from a visible stack and add it to the list. if (stack.shouldBeVisible(null /* starting */)) { if (stack.shouldBeVisible(null /* starting */)) { final ActivityRecord top = stack.getTopNonFinishingActivity(); final ActivityRecord top = stack.getTopNonFinishingActivity(); Loading @@ -1850,7 +1847,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } } } } } } }); }); return topActivityTokens; return topActivityTokens; } } Loading Loading @@ -1892,21 +1888,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // First, found out what is currently the foreground app, so that we don't blow away the // First, found out what is currently the foreground app, so that we don't blow away the // previous app if this activity is being hosted by the process that is actually still the // previous app if this activity is being hosted by the process that is actually still the // foreground. // foreground. WindowProcessController fgApp = reduceOnAllTaskDisplayAreas((taskDisplayArea, app) -> { WindowProcessController fgApp = getItemFromRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (isTopDisplayFocusedRootTask(stack)) { if (isTopDisplayFocusedRootTask(stack)) { final ActivityRecord resumedActivity = stack.getResumedActivity(); final ActivityRecord resumedActivity = stack.getResumedActivity(); if (resumedActivity != null) { if (resumedActivity != null) { app = resumedActivity.app; return resumedActivity.app; } else if (stack.mPausingActivity != null) { } else if (stack.mPausingActivity != null) { app = stack.mPausingActivity.app; return stack.mPausingActivity.app; } break; } } } } return app; return null; }, null /* initValue */); }); // Now set this one as the previous process, only if that really makes sense to. // Now set this one as the previous process, only if that really makes sense to. if (r.hasProcess() && fgApp != null && r.app != fgApp if (r.hasProcess() && fgApp != null && r.app != fgApp Loading @@ -1923,15 +1915,13 @@ class RootWindowContainer extends WindowContainer<DisplayContent> mTmpRemoteException = null; mTmpRemoteException = null; mTmpBoolean = false; // Set to true if an activity was started. mTmpBoolean = false; // Set to true if an activity was started. final DisplayContent display = getChildAt(displayNdx); final DisplayContent display = getChildAt(displayNdx); display.forAllTaskDisplayAreas(displayArea -> { display.forAllRootTasks(rootTask -> { if (mTmpRemoteException != null) { if (mTmpRemoteException != null) { return; return; } } for (int taskNdx = displayArea.getRootTaskCount() - 1; taskNdx >= 0; --taskNdx) { final Task rootTask = displayArea.getRootTaskAt(taskNdx); if (rootTask.getVisibility(null /*starting*/) == TASK_VISIBILITY_INVISIBLE) { if (rootTask.getVisibility(null /*starting*/) == TASK_VISIBILITY_INVISIBLE) { break; return; } } final PooledFunction c = PooledLambda.obtainFunction( final PooledFunction c = PooledLambda.obtainFunction( Loading @@ -1940,10 +1930,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> rootTask.topRunningActivity()); rootTask.topRunningActivity()); rootTask.forAllActivities(c); rootTask.forAllActivities(c); c.recycle(); c.recycle(); if (mTmpRemoteException != null) { return; } } }); }); if (mTmpRemoteException != null) { if (mTmpRemoteException != null) { throw mTmpRemoteException; throw mTmpRemoteException; Loading Loading @@ -2027,11 +2013,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> mCurrentUser = userId; mCurrentUser = userId; mTaskSupervisor.mStartingUsers.add(uss); mTaskSupervisor.mStartingUsers.add(uss); forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); stack.switchUser(userId); stack.switchUser(userId); } }); }); final int restoreStackId = mUserRootTaskInFront.get(userId); final int restoreStackId = mUserRootTaskInFront.get(userId); Loading Loading @@ -2294,20 +2277,14 @@ class RootWindowContainer extends WindowContainer<DisplayContent> */ */ int finishTopCrashedActivities(WindowProcessController app, String reason) { int finishTopCrashedActivities(WindowProcessController app, String reason) { Task focusedStack = getTopDisplayFocusedRootTask(); Task focusedStack = getTopDisplayFocusedRootTask(); Task finishedTask = reduceOnAllTaskDisplayAreas((taskDisplayArea, task) -> { final Task[] finishedTask = new Task[1]; // It is possible that request to finish activity might also remove its task and forAllTasks(stack -> { // stack, so we need to be careful with indexes in the loop and check child count // every time. for (int stackNdx = 0; stackNdx < taskDisplayArea.getRootTaskCount(); ++stackNdx) { final Task stack = taskDisplayArea.getRootTaskAt(stackNdx); final Task t = stack.finishTopCrashedActivityLocked(app, reason); final Task t = stack.finishTopCrashedActivityLocked(app, reason); if (stack == focusedStack || task == null) { if (stack == focusedStack || finishedTask[0] == null) { task = t; finishedTask[0] = t; } } } return task; }); }, null /* initValue */); return finishedTask[0] != null ? finishedTask[0].mTaskId : INVALID_TASK_ID; return finishedTask != null ? finishedTask.mTaskId : INVALID_TASK_ID; } } boolean resumeFocusedTasksTopActivities() { boolean resumeFocusedTasksTopActivities() { Loading @@ -2330,36 +2307,32 @@ class RootWindowContainer extends WindowContainer<DisplayContent> for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) { for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) { final DisplayContent display = getChildAt(displayNdx); final DisplayContent display = getChildAt(displayNdx); final boolean curResult = result; final boolean curResult = result; boolean resumedOnDisplay = display.reduceOnAllTaskDisplayAreas( boolean[] resumedOnDisplay = new boolean[1]; (taskDisplayArea, resumed) -> { display.forAllRootTasks(rootTask -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task rootTask = taskDisplayArea.getRootTaskAt(sNdx); final ActivityRecord topRunningActivity = rootTask.topRunningActivity(); final ActivityRecord topRunningActivity = rootTask.topRunningActivity(); if (!rootTask.isFocusableAndVisible() || topRunningActivity == null) { if (!rootTask.isFocusableAndVisible() || topRunningActivity == null) { continue; return; } } if (rootTask == targetRootTask) { if (rootTask == targetRootTask) { // Simply update the result for targetStack because the targetStack // Simply update the result for targetStack because the targetStack // had already resumed in above. We don't want to resume it again, // had already resumed in above. We don't want to resume it again, // especially in some cases, it would cause a second launch failure // especially in some cases, it would cause a second launch failure // if app process was dead. // if app process was dead. resumed |= curResult; resumedOnDisplay[0] |= curResult; continue; return; } } if (taskDisplayArea.isTopRootTask(rootTask) if (rootTask.getDisplayArea().isTopRootTask(rootTask) && topRunningActivity.isState(RESUMED)) { && topRunningActivity.isState(RESUMED)) { // Kick off any lingering app transitions form the MoveTaskToFront // Kick off any lingering app transitions form the MoveTaskToFront // operation, but only consider the top task and stack on that // operation, but only consider the top task and stack on that // display. // display. rootTask.executeAppTransition(targetOptions); rootTask.executeAppTransition(targetOptions); } else { } else { resumed |= topRunningActivity.makeActiveIfNeeded(target); resumedOnDisplay[0] |= topRunningActivity.makeActiveIfNeeded(target); } } } }); return resumed; result |= resumedOnDisplay[0]; }, false /* initValue */); if (!resumedOnDisplay[0]) { result |= resumedOnDisplay; if (!resumedOnDisplay) { // In cases when there are no valid activities (e.g. device just booted or launcher // In cases when there are no valid activities (e.g. device just booted or launcher // crashed) it's possible that nothing was resumed on a display. Requesting resume // crashed) it's possible that nothing was resumed on a display. Requesting resume // of top activity in focused stack explicitly will make sure that at least home // of top activity in focused stack explicitly will make sure that at least home Loading Loading @@ -2392,9 +2365,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } // Set the sleeping state of the stacks on the display. // Set the sleeping state of the stacks on the display. display.forAllTaskDisplayAreas(taskDisplayArea -> { display.forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (displayShouldSleep) { if (displayShouldSleep) { stack.goToSleepIfPossible(false /* shuttingDown */); stack.goToSleepIfPossible(false /* shuttingDown */); } else { } else { Loading @@ -2416,7 +2387,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> stack.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, stack.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, false /* preserveWindows */); false /* preserveWindows */); } } } }); }); } } } } Loading Loading @@ -2512,13 +2482,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent> /** If displayId == INVALID_DISPLAY, this will get root task infos on all displays */ /** If displayId == INVALID_DISPLAY, this will get root task infos on all displays */ ArrayList<RootTaskInfo> getAllRootTaskInfos(int displayId) { ArrayList<RootTaskInfo> getAllRootTaskInfos(int displayId) { ArrayList<RootTaskInfo> list = new ArrayList<>(); final ArrayList<RootTaskInfo> list = new ArrayList<>(); if (displayId == INVALID_DISPLAY) { if (displayId == INVALID_DISPLAY) { forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); list.add(getRootTaskInfo(stack)); list.add(getRootTaskInfo(stack)); } }); }); return list; return list; } } Loading @@ -2526,11 +2493,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> if (display == null) { if (display == null) { return list; return list; } } display.forAllTaskDisplayAreas(taskDisplayArea -> { display.forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); list.add(getRootTaskInfo(stack)); list.add(getRootTaskInfo(stack)); } }); }); return list; return list; } } Loading Loading @@ -2603,10 +2567,17 @@ class RootWindowContainer extends WindowContainer<DisplayContent> Task findRootTaskBehind(Task rootTask) { Task findRootTaskBehind(Task rootTask) { final TaskDisplayArea taskDisplayArea = rootTask.getDisplayArea(); final TaskDisplayArea taskDisplayArea = rootTask.getDisplayArea(); if (taskDisplayArea != null) { if (taskDisplayArea != null) { for (int i = taskDisplayArea.getRootTaskCount() - 1; i >= 0; i--) { final boolean[] hasFound = new boolean[1]; if (taskDisplayArea.getRootTaskAt(i) == rootTask && i > 0) { // TODO(b/175136051): should this be only the direct child root task? return taskDisplayArea.getRootTaskAt(i - 1); final Task rootTaskBehind = taskDisplayArea.getRootTask(task -> { if (hasFound[0]) { return true; } } hasFound[0] = task == rootTask; return false; }); if (rootTaskBehind != null) { return rootTaskBehind; } } } } throw new IllegalStateException("Failed to find a root task behind root task =" + rootTask throw new IllegalStateException("Failed to find a root task behind root task =" + rootTask Loading Loading @@ -2748,24 +2719,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // Tries to put all activity tasks to sleep. Returns true if all tasks were // Tries to put all activity tasks to sleep. Returns true if all tasks were // successfully put to sleep. // successfully put to sleep. boolean putTasksToSleep(boolean allowDelay, boolean shuttingDown) { boolean putTasksToSleep(boolean allowDelay, boolean shuttingDown) { return reduceOnAllTaskDisplayAreas((taskDisplayArea, result) -> { final boolean[] result = {true}; for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { forAllRootTasks(task -> { // Stacks and activities could be removed while putting activities to sleep if // the app process was gone. This prevents us getting exception by accessing an // invalid stack index. if (sNdx >= taskDisplayArea.getRootTaskCount()) { continue; } final Task task = taskDisplayArea.getRootTaskAt(sNdx); if (allowDelay) { if (allowDelay) { result &= task.goToSleepIfPossible(shuttingDown); result[0] &= task.goToSleepIfPossible(shuttingDown); } else { } else { task.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, task.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */, !PRESERVE_WINDOWS); !PRESERVE_WINDOWS); } } } }); return result; return result[0]; }, true /* initValue */); } } void handleAppCrash(WindowProcessController app) { void handleAppCrash(WindowProcessController app) { Loading Loading @@ -3021,11 +2984,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> r.getActivityType()); r.getActivityType()); // Return the topmost valid stack on the display. // Return the topmost valid stack on the display. for (int i = taskDisplayArea.getRootTaskCount() - 1; i >= 0; --i) { final int targetWindowingMode = windowingMode; final Task stack = taskDisplayArea.getRootTaskAt(i); final Task topmostValidStack = taskDisplayArea.getRootTask(stack -> if (isValidLaunchRootTask(stack, r, windowingMode)) { isValidLaunchRootTask(stack, r, targetWindowingMode)); return stack; if (topmostValidStack != null) { } return topmostValidStack; } } // If there is no valid stack on the secondary display area - check if new dynamic stack // If there is no valid stack on the secondary display area - check if new dynamic stack Loading Loading @@ -3260,12 +3223,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } void finishVoiceTask(IVoiceInteractionSession session) { void finishVoiceTask(IVoiceInteractionSession session) { forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { final int numStacks = taskDisplayArea.getRootTaskCount(); for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) { final Task stack = taskDisplayArea.getRootTaskAt(stackNdx); stack.finishVoiceTask(session); stack.finishVoiceTask(session); } }); }); } } Loading Loading @@ -3324,10 +3283,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> boolean allResumedActivitiesVisible() { boolean allResumedActivitiesVisible() { boolean[] foundResumed = {false}; boolean[] foundResumed = {false}; final boolean foundInvisibleResumedActivity = forAllTaskDisplayAreas( final boolean foundInvisibleResumedActivity = forAllRootTasks(stack -> { taskDisplayArea -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); final ActivityRecord r = stack.getResumedActivity(); final ActivityRecord r = stack.getResumedActivity(); if (r != null) { if (r != null) { if (!r.nowVisible) { if (!r.nowVisible) { Loading @@ -3335,7 +3291,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } foundResumed[0] = true; foundResumed[0] = true; } } } return false; return false; }); }); if (foundInvisibleResumedActivity) { if (foundInvisibleResumedActivity) { Loading @@ -3346,10 +3301,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> boolean allPausedActivitiesComplete() { boolean allPausedActivitiesComplete() { boolean[] pausing = {true}; boolean[] pausing = {true}; final boolean hasActivityNotCompleted = forAllTaskDisplayAreas( final boolean hasActivityNotCompleted = forAllRootTasks(stack -> { taskDisplayArea -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); final ActivityRecord r = stack.mPausingActivity; final ActivityRecord r = stack.mPausingActivity; if (r != null && !r.isState(PAUSED, STOPPED, STOPPING, FINISHING)) { if (r != null && !r.isState(PAUSED, STOPPED, STOPPING, FINISHING)) { ProtoLog.d(WM_DEBUG_STATES, "allPausedActivitiesComplete: " ProtoLog.d(WM_DEBUG_STATES, "allPausedActivitiesComplete: " Loading @@ -3360,7 +3312,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return true; return true; } } } } } return false; return false; }); }); if (hasActivityNotCompleted) { if (hasActivityNotCompleted) { Loading Loading @@ -3413,13 +3364,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } void cancelInitializingActivities() { void cancelInitializingActivities() { forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(task -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { // We don't want to clear starting window for activities that aren't occluded // We don't want to clear starting window for activities that aren't occluded // as we need to display their starting window until they are done initializing. // as we need to display their starting window until they are done initializing. taskDisplayArea.getRootTaskAt(sNdx).forAllOccludedActivities( task.forAllOccludedActivities(ActivityRecord::cancelInitializing); ActivityRecord::cancelInitializing); } }); }); } } Loading Loading @@ -3579,14 +3527,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return new ArrayList<>(); return new ArrayList<>(); } } } else { } else { ArrayList<ActivityRecord> activities = new ArrayList<>(); final ArrayList<ActivityRecord> activities = new ArrayList<>(); forAllTaskDisplayAreas(taskDisplayArea -> { forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (!dumpVisibleStacksOnly || stack.shouldBeVisible(null)) { if (!dumpVisibleStacksOnly || stack.shouldBeVisible(null)) { activities.addAll(stack.getDumpActivitiesLocked(name)); activities.addAll(stack.getDumpActivitiesLocked(name)); } } } }); }); return activities; return activities; } } Loading Loading @@ -3635,15 +3580,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent> pw.print("Display #"); pw.print("Display #"); pw.print(displayContent.mDisplayId); pw.print(displayContent.mDisplayId); pw.println(" (activities from top to bottom):"); pw.println(" (activities from top to bottom):"); displayContent.forAllTaskDisplayAreas(taskDisplayArea -> { displayContent.forAllRootTasks(stack -> { for (int sNdx = taskDisplayArea.getRootTaskCount() - 1; sNdx >= 0; --sNdx) { final Task stack = taskDisplayArea.getRootTaskAt(sNdx); if (needSep[0]) { if (needSep[0]) { pw.println(); pw.println(); } } needSep[0] = stack.dump(fd, pw, dumpAll, dumpClient, dumpPackage, false); needSep[0] = stack.dump(fd, pw, dumpAll, dumpClient, dumpPackage, false); printed[0] |= needSep[0]; printed[0] |= needSep[0]; } }); }); displayContent.forAllTaskDisplayAreas(taskDisplayArea -> { displayContent.forAllTaskDisplayAreas(taskDisplayArea -> { printed[0] |= printThisActivity(pw, taskDisplayArea.getFocusedActivity(), printed[0] |= printThisActivity(pw, taskDisplayArea.getFocusedActivity(), Loading
services/core/java/com/android/server/wm/Task.java +24 −0 Original line number Original line Diff line number Diff line Loading @@ -3877,6 +3877,13 @@ class Task extends WindowContainer<WindowContainer> { callback.accept(this); callback.accept(this); } } @Override void forAllRootTasks(Consumer<Task> callback, boolean traverseTopToBottom) { if (isRootTask()) { callback.accept(this); } } @Override @Override boolean forAllTasks(Function<Task, Boolean> callback) { boolean forAllTasks(Function<Task, Boolean> callback) { if (super.forAllTasks(callback)) return true; if (super.forAllTasks(callback)) return true; Loading @@ -3901,6 +3908,11 @@ class Task extends WindowContainer<WindowContainer> { return false; return false; } } @Override boolean forAllRootTasks(Function<Task, Boolean> callback, boolean traverseTopToBottom) { return isRootTask() ? callback.apply(this) : false; } @Override @Override Task getTask(Predicate<Task> callback, boolean traverseTopToBottom) { Task getTask(Predicate<Task> callback, boolean traverseTopToBottom) { final Task t = super.getTask(callback, traverseTopToBottom); final Task t = super.getTask(callback, traverseTopToBottom); Loading @@ -3908,6 +3920,18 @@ class Task extends WindowContainer<WindowContainer> { return callback.test(this) ? this : null; return callback.test(this) ? this : null; } } @Nullable @Override Task getRootTask(Predicate<Task> callback, boolean traverseTopToBottom) { return isRootTask() && callback.test(this) ? this : null; } @Nullable @Override <R> R getItemFromRootTasks(Function<Task, R> callback, boolean traverseTopToBottom) { return isRootTask() ? callback.apply(this) : null; } /** /** * @param canAffectSystemUiFlags If false, all windows in this task can not affect SystemUI * @param canAffectSystemUiFlags If false, all windows in this task can not affect SystemUI * flags. See {@link WindowState#canAffectSystemUiFlags()}. * flags. See {@link WindowState#canAffectSystemUiFlags()}. Loading