Loading services/core/java/com/android/server/wm/ActivityRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -5695,7 +5695,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A destroyImmediately("stop-config"); mRootWindowContainer.resumeFocusedTasksTopActivities(); } else { mRootWindowContainer.updatePreviousProcess(this); mAtmService.updatePreviousProcess(this); } } mTaskSupervisor.checkReadyForSleepLocked(true /* allowDelay */); Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +18 −1 Original line number Diff line number Diff line Loading @@ -398,7 +398,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { */ volatile WindowProcessController mPreviousProcess; /** The time at which the previous process was last visible. */ long mPreviousProcessVisibleTime; private long mPreviousProcessVisibleTime; /** List of intents that were used to start the most recent tasks. */ private RecentTasks mRecentTasks; Loading Loading @@ -4634,6 +4634,23 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mTopApp = top != null ? top.app : null; } /** * The process state of previous activity is more important than the regular background to keep * around in case the user wants to return to it. */ void updatePreviousProcess(ActivityRecord stoppedActivity) { if (stoppedActivity.app != null && mTopApp != null // Don't replace the previous process if the stopped one is the top, e.g. sleeping. && stoppedActivity.app != mTopApp // The stopped activity must have been visible later than the previous. && stoppedActivity.lastVisibleTime > mPreviousProcessVisibleTime // Home has its own retained state, so don't let it occupy the previous. && stoppedActivity.app != mHomeProcess) { mPreviousProcess = stoppedActivity.app; mPreviousProcessVisibleTime = stoppedActivity.lastVisibleTime; } } void updateActivityUsageStats(ActivityRecord activity, int event) { ComponentName taskRoot = null; final Task task = activity.getTask(); Loading services/core/java/com/android/server/wm/RootWindowContainer.java +0 −28 Original line number Diff line number Diff line Loading @@ -1894,34 +1894,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return task != null && task == getTopDisplayFocusedRootTask(); } void updatePreviousProcess(ActivityRecord r) { // Now that this process has stopped, we may want to consider it to be the previous app to // try to keep around in case the user wants to return to it. // 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 // foreground. WindowProcessController fgApp = getItemFromRootTasks(rootTask -> { if (isTopDisplayFocusedRootTask(rootTask)) { final ActivityRecord resumedActivity = rootTask.getTopResumedActivity(); if (resumedActivity != null) { return resumedActivity.app; } else if (rootTask.getTopPausingActivity() != null) { return rootTask.getTopPausingActivity().app; } } return null; }); // Now set this one as the previous process, only if that really makes sense to. if (r.hasProcess() && fgApp != null && r.app != fgApp && r.lastVisibleTime > mService.mPreviousProcessVisibleTime && r.app != mService.mHomeProcess) { mService.mPreviousProcess = r.app; mService.mPreviousProcessVisibleTime = r.lastVisibleTime; } } boolean attachApplication(WindowProcessController app) throws RemoteException { try { return mAttachApplicationHelper.process(app); Loading services/core/java/com/android/server/wm/Task.java +0 −7 Original line number Diff line number Diff line Loading @@ -217,7 +217,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; /** Loading Loading @@ -3226,12 +3225,6 @@ class Task extends TaskFragment { 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 * flags. See {@link WindowState#canAffectSystemUiFlags()}. Loading services/core/java/com/android/server/wm/WindowContainer.java +0 −41 Original line number Diff line number Diff line Loading @@ -2116,47 +2116,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< return getItemFromTaskDisplayAreas(callback, true /* traverseTopToBottom */); } /** * Finds the first non {@code null} return value from calling the callback on all root * {@link Task} at or below this container. * @param callback Applies on each root {@link Task} found and stops the search if it * returns non {@code null}. * @param traverseTopToBottom If {@code true}, traverses the hierarchy from top-to-bottom in * terms of z-order, else from bottom-to-top. * @return the first returned object that is not {@code null}. Returns {@code null} if not * found. */ @Nullable <R> R getItemFromRootTasks(Function<Task, R> callback, boolean traverseTopToBottom) { int count = mChildren.size(); if (traverseTopToBottom) { for (int i = count - 1; i >= 0; --i) { R result = (R) mChildren.get(i).getItemFromRootTasks(callback, traverseTopToBottom); if (result != null) { return result; } } } else { for (int i = 0; i < count; i++) { R result = (R) mChildren.get(i).getItemFromRootTasks(callback, traverseTopToBottom); if (result != null) { return result; } // Root tasks may be removed from this display. Ensure each task will be processed // and the loop will end. int newCount = mChildren.size(); i -= count - newCount; count = newCount; } } return null; } @Nullable <R> R getItemFromRootTasks(Function<Task, R> callback) { return getItemFromRootTasks(callback, true /* traverseTopToBottom */); } /** * Returns 1, 0, or -1 depending on if this container is greater than, equal to, or lesser than * the input container in terms of z-order. Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -5695,7 +5695,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A destroyImmediately("stop-config"); mRootWindowContainer.resumeFocusedTasksTopActivities(); } else { mRootWindowContainer.updatePreviousProcess(this); mAtmService.updatePreviousProcess(this); } } mTaskSupervisor.checkReadyForSleepLocked(true /* allowDelay */); Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +18 −1 Original line number Diff line number Diff line Loading @@ -398,7 +398,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { */ volatile WindowProcessController mPreviousProcess; /** The time at which the previous process was last visible. */ long mPreviousProcessVisibleTime; private long mPreviousProcessVisibleTime; /** List of intents that were used to start the most recent tasks. */ private RecentTasks mRecentTasks; Loading Loading @@ -4634,6 +4634,23 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mTopApp = top != null ? top.app : null; } /** * The process state of previous activity is more important than the regular background to keep * around in case the user wants to return to it. */ void updatePreviousProcess(ActivityRecord stoppedActivity) { if (stoppedActivity.app != null && mTopApp != null // Don't replace the previous process if the stopped one is the top, e.g. sleeping. && stoppedActivity.app != mTopApp // The stopped activity must have been visible later than the previous. && stoppedActivity.lastVisibleTime > mPreviousProcessVisibleTime // Home has its own retained state, so don't let it occupy the previous. && stoppedActivity.app != mHomeProcess) { mPreviousProcess = stoppedActivity.app; mPreviousProcessVisibleTime = stoppedActivity.lastVisibleTime; } } void updateActivityUsageStats(ActivityRecord activity, int event) { ComponentName taskRoot = null; final Task task = activity.getTask(); Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +0 −28 Original line number Diff line number Diff line Loading @@ -1894,34 +1894,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return task != null && task == getTopDisplayFocusedRootTask(); } void updatePreviousProcess(ActivityRecord r) { // Now that this process has stopped, we may want to consider it to be the previous app to // try to keep around in case the user wants to return to it. // 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 // foreground. WindowProcessController fgApp = getItemFromRootTasks(rootTask -> { if (isTopDisplayFocusedRootTask(rootTask)) { final ActivityRecord resumedActivity = rootTask.getTopResumedActivity(); if (resumedActivity != null) { return resumedActivity.app; } else if (rootTask.getTopPausingActivity() != null) { return rootTask.getTopPausingActivity().app; } } return null; }); // Now set this one as the previous process, only if that really makes sense to. if (r.hasProcess() && fgApp != null && r.app != fgApp && r.lastVisibleTime > mService.mPreviousProcessVisibleTime && r.app != mService.mHomeProcess) { mService.mPreviousProcess = r.app; mService.mPreviousProcessVisibleTime = r.lastVisibleTime; } } boolean attachApplication(WindowProcessController app) throws RemoteException { try { return mAttachApplicationHelper.process(app); Loading
services/core/java/com/android/server/wm/Task.java +0 −7 Original line number Diff line number Diff line Loading @@ -217,7 +217,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; /** Loading Loading @@ -3226,12 +3225,6 @@ class Task extends TaskFragment { 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 * flags. See {@link WindowState#canAffectSystemUiFlags()}. Loading
services/core/java/com/android/server/wm/WindowContainer.java +0 −41 Original line number Diff line number Diff line Loading @@ -2116,47 +2116,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< return getItemFromTaskDisplayAreas(callback, true /* traverseTopToBottom */); } /** * Finds the first non {@code null} return value from calling the callback on all root * {@link Task} at or below this container. * @param callback Applies on each root {@link Task} found and stops the search if it * returns non {@code null}. * @param traverseTopToBottom If {@code true}, traverses the hierarchy from top-to-bottom in * terms of z-order, else from bottom-to-top. * @return the first returned object that is not {@code null}. Returns {@code null} if not * found. */ @Nullable <R> R getItemFromRootTasks(Function<Task, R> callback, boolean traverseTopToBottom) { int count = mChildren.size(); if (traverseTopToBottom) { for (int i = count - 1; i >= 0; --i) { R result = (R) mChildren.get(i).getItemFromRootTasks(callback, traverseTopToBottom); if (result != null) { return result; } } } else { for (int i = 0; i < count; i++) { R result = (R) mChildren.get(i).getItemFromRootTasks(callback, traverseTopToBottom); if (result != null) { return result; } // Root tasks may be removed from this display. Ensure each task will be processed // and the loop will end. int newCount = mChildren.size(); i -= count - newCount; count = newCount; } } return null; } @Nullable <R> R getItemFromRootTasks(Function<Task, R> callback) { return getItemFromRootTasks(callback, true /* traverseTopToBottom */); } /** * Returns 1, 0, or -1 depending on if this container is greater than, equal to, or lesser than * the input container in terms of z-order. Loading