Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 786d279f authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Allow TaskDisplayArea to have TaskDisplayArea children (2/n)"

parents 42fa75c7 191d03bc
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -1711,12 +1711,6 @@
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/Session.java"
    },
    "-49129622": {
      "message": "performLayout: Activity exiting now removed %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/TaskDisplayArea.java"
    },
    "-33096143": {
      "message": "applyAnimation: transition animation is disabled or skipped. container=%s",
      "level": "VERBOSE",
@@ -1771,6 +1765,12 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "44438983": {
      "message": "performLayout: Activity exiting now removed %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/DisplayContent.java"
    },
    "45285419": {
      "message": "startingWindow was set but startingSurface==null, couldn't remove",
      "level": "VERBOSE",
@@ -1831,12 +1831,6 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowContextListenerController.java"
    },
    "91350919": {
      "message": "Attempted to set IME flag to a display that does not exist: %d",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "94402792": {
      "message": "Moving to RESUMED: %s (in existing)",
      "level": "VERBOSE",
+69 −10
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.window.DisplayAreaOrganizer.FEATURE_ROOT;
import static android.window.DisplayAreaOrganizer.FEATURE_WINDOWED_MAGNIFICATION;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_BOOT;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
@@ -2256,8 +2257,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    @Nullable
    Task getRootTask(int rootTaskId) {
        return getItemFromTaskDisplayAreas(taskDisplayArea ->
                        taskDisplayArea.getRootTask(rootTaskId));
        return getRootTask(rootTask -> rootTask.getRootTaskId() == rootTaskId);
    }

    int getRootTaskCount() {
@@ -2834,7 +2834,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    void prepareFreezingTaskBounds() {
        forAllTaskDisplayAreas(TaskDisplayArea::prepareFreezingTaskBounds);
        forAllRootTasks(Task::prepareFreezingTaskBounds);
    }

    void rotateBounds(int oldRotation, int newRotation, Rect bounds) {
@@ -4191,8 +4191,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }

        // Initialize state of exiting applications.
        forAllTaskDisplayAreas(taskDisplayArea -> {
            taskDisplayArea.setExitingTokensHasVisible(hasVisible);
        forAllRootTasks(task -> {
            final ArrayList<ActivityRecord> activities = task.mExitingActivities;
            for (int j = activities.size() - 1; j >= 0; --j) {
                activities.get(j).hasVisible = hasVisible;
            }
        });
    }

@@ -4205,7 +4208,22 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }

        // Time to remove any exiting applications?
        forAllTaskDisplayAreas(TaskDisplayArea::removeExistingAppTokensIfPossible);
        forAllRootTasks(task -> {
            final ArrayList<ActivityRecord> activities = task.mExitingActivities;
            for (int j = activities.size() - 1; j >= 0; --j) {
                final ActivityRecord activity = activities.get(j);
                if (!activity.hasVisible && !mDisplayContent.mClosingApps.contains(activity)
                        && (!activity.mIsExiting || activity.isEmpty())) {
                    // Make sure there is no animation running on this activity, so any windows
                    // associated with it will be removed as soon as their animations are
                    // complete.
                    cancelAnimation();
                    ProtoLog.v(WM_DEBUG_ADD_REMOVE,
                            "performLayout: Activity exiting now removed %s", activity);
                    activity.removeIfPossible();
                }
            }
        });
    }

    @Override
@@ -5128,15 +5146,56 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
     */
    void removeRootTasksInWindowingModes(int... windowingModes) {
        forAllTaskDisplayAreas(taskDisplayArea -> {
            taskDisplayArea.removeRootTasksInWindowingModes(windowingModes);
        if (windowingModes == null || windowingModes.length == 0) {
            return;
        }

        // Collect the root tasks that are necessary to be removed instead of performing the removal
        // by looping the children, so that we don't miss any root tasks after the children size
        // changed or reordered.
        final ArrayList<Task> rootTasks = new ArrayList<>();
        forAllRootTasks(rootTask -> {
            for (int windowingMode : windowingModes) {
                if (rootTask.mCreatedByOrganizer
                        || rootTask.getWindowingMode() != windowingMode
                        || !rootTask.isActivityTypeStandardOrUndefined()) {
                    continue;
                }
                rootTasks.add(rootTask);
            }
        });
        for (int i = rootTasks.size() - 1; i >= 0; --i) {
            mRootWindowContainer.mTaskSupervisor.removeRootTask(rootTasks.get(i));
        }
    }

    void removeRootTasksWithActivityTypes(int... activityTypes) {
        forAllTaskDisplayAreas(taskDisplayArea -> {
            taskDisplayArea.removeRootTasksWithActivityTypes(activityTypes);
        if (activityTypes == null || activityTypes.length == 0) {
            return;
        }

        // Collect the root tasks that are necessary to be removed instead of performing the removal
        // by looping the children, so that we don't miss any root tasks after the children size
        // changed or reordered.
        final ArrayList<Task> rootTasks = new ArrayList<>();
        forAllRootTasks(rootTask -> {
            for (int activityType : activityTypes) {
                // Collect the root tasks that are currently being organized.
                if (rootTask.mCreatedByOrganizer) {
                    for (int k = rootTask.getChildCount() - 1; k >= 0; --k) {
                        final Task task = (Task) rootTask.getChildAt(k);
                        if (task.getActivityType() == activityType) {
                            rootTasks.add(task);
                        }
                    }
                } else if (rootTask.getActivityType() == activityType) {
                    rootTasks.add(rootTask);
                }
            }
        });
        for (int i = rootTasks.size() - 1; i >= 0; --i) {
            mRootWindowContainer.mTaskSupervisor.removeRootTask(rootTasks.get(i));
        }
    }

    ActivityRecord topRunningActivity() {
+0 −104
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ADD_REMOVE;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STATES;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_TASKS;
@@ -610,34 +609,6 @@ final class TaskDisplayArea extends DisplayArea<Task> {
        return false;
    }

    void setExitingTokensHasVisible(boolean hasVisible) {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final ArrayList<ActivityRecord> activities = mChildren.get(i).mExitingActivities;
            for (int j = activities.size() - 1; j >= 0; --j) {
                activities.get(j).hasVisible = hasVisible;
            }
        }
    }

    void removeExistingAppTokensIfPossible() {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final ArrayList<ActivityRecord> activities = mChildren.get(i).mExitingActivities;
            for (int j = activities.size() - 1; j >= 0; --j) {
                final ActivityRecord activity = activities.get(j);
                if (!activity.hasVisible && !mDisplayContent.mClosingApps.contains(activity)
                        && (!activity.mIsExiting || activity.isEmpty())) {
                    // Make sure there is no animation running on this activity, so any windows
                    // associated with it will be removed as soon as their animations are
                    // complete.
                    cancelAnimation();
                    ProtoLog.v(WM_DEBUG_ADD_REMOVE,
                            "performLayout: Activity exiting now removed %s", activity);
                    activity.removeIfPossible();
                }
            }
        }
    }

    @Override
    int getOrientation(int candidate) {
        mLastOrientationSource = null;
@@ -894,11 +865,6 @@ final class TaskDisplayArea extends DisplayArea<Task> {
        }
    }

    @Nullable
    Task getRootTask(int rootTaskId) {
        return getRootTask(stack -> stack.getRootTaskId() == rootTaskId);
    }

    /**
     * Returns an existing stack compatible with the windowing mode and activity type or creates one
     * if a compatible stack doesn't exist.
@@ -1296,69 +1262,6 @@ final class TaskDisplayArea extends DisplayArea<Task> {
        }
    }

    /**
     * Removes root tasks in the input windowing modes from the system if they are of activity type
     * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
     */
    void removeRootTasksInWindowingModes(int... windowingModes) {
        if (windowingModes == null || windowingModes.length == 0) {
            return;
        }

        // Collect the root tasks that are necessary to be removed instead of performing the removal
        // by looping the children, so that we don't miss any root tasks after the children size
        // changed or reordered.
        final ArrayList<Task> rootTasks = new ArrayList<>();
        for (int j = windowingModes.length - 1; j >= 0; --j) {
            final int windowingMode = windowingModes[j];
            for (int i = mChildren.size() - 1; i >= 0; --i) {
                final Task rootTask = mChildren.get(i);
                if (rootTask.mCreatedByOrganizer
                        || !rootTask.isActivityTypeStandardOrUndefined()
                        || rootTask.getWindowingMode() != windowingMode) {
                    continue;
                }
                rootTasks.add(rootTask);
            }
        }

        for (int i = rootTasks.size() - 1; i >= 0; --i) {
            mRootWindowContainer.mTaskSupervisor.removeRootTask(rootTasks.get(i));
        }
    }

    void removeRootTasksWithActivityTypes(int... activityTypes) {
        if (activityTypes == null || activityTypes.length == 0) {
            return;
        }

        // Collect the root tasks that are necessary to be removed instead of performing the removal
        // by looping the children, so that we don't miss any root tasks after the children size
        // changed or reordered.
        final ArrayList<Task> rootTasks = new ArrayList<>();
        for (int j = activityTypes.length - 1; j >= 0; --j) {
            final int activityType = activityTypes[j];
            for (int i = mChildren.size() - 1; i >= 0; --i) {
                final Task rootTask = mChildren.get(i);
                // Collect the root tasks that are currently being organized.
                if (rootTask.mCreatedByOrganizer) {
                    for (int k = rootTask.getChildCount() - 1; k >= 0; --k) {
                        final Task task = (Task) rootTask.getChildAt(k);
                        if (task.getActivityType() == activityType) {
                            rootTasks.add(task);
                        }
                    }
                } else if (rootTask.getActivityType() == activityType) {
                    rootTasks.add(rootTask);
                }
            }
        }

        for (int i = rootTasks.size() - 1; i >= 0; --i) {
            mRootWindowContainer.mTaskSupervisor.removeRootTask(rootTasks.get(i));
        }
    }

    void onSplitScreenModeDismissed() {
        // The focused task could be a non-resizeable fullscreen root task that is on top of the
        // other split-screen tasks, therefore had to dismiss split-screen, make sure the current
@@ -1842,13 +1745,6 @@ final class TaskDisplayArea extends DisplayArea<Task> {
        }
    }

    void prepareFreezingTaskBounds() {
        for (int stackNdx = getChildCount() - 1; stackNdx >= 0; --stackNdx) {
            final Task stack = getChildAt(stackNdx);
            stack.prepareFreezingTaskBounds();
        }
    }

    /**
     * Removes the stacks in the node applying the content removal node from the display.
     *