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

Commit 85fb19a4 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Change Stack to have generic WindowContainer children (76/n)

- Step towards Tasks containing other Tasks.
- There are several places where we want to perform an operation on all
tasks in a branch of the hierarchy. We end up looping based on the
parent knowing what type of children is in the sub-branch. Instead use
forAllTasks() to perfrom the operation on all tasks in the sub-branch.

Bug: 80414790
Test: Existing tests pass
Change-Id: I5551fe440e56bb8d6982002f93037827b00c70fc
parent affe64c6
Loading
Loading
Loading
Loading
+5 −17
Original line number Diff line number Diff line
@@ -468,7 +468,7 @@ class ActivityDisplay extends DisplayContent {
            if (resumedActivity == null || resumedActivity.app == null) {
                // If previously resumed activity doesn't work either - find the topmost running
                // activity that can be focused.
                resumedActivity = focusedStack.topRunningActivityLocked(true /* focusableOnly */);
                resumedActivity = focusedStack.topRunningActivity(true /* focusableOnly */);
            }
        }
        return resumedActivity;
@@ -832,7 +832,7 @@ class ActivityDisplay extends DisplayContent {
        ActivityRecord topRunning = null;
        final ActivityStack focusedStack = getFocusedStack();
        if (focusedStack != null) {
            topRunning = focusedStack.topRunningActivityLocked();
            topRunning = focusedStack.topRunningActivity();
        }

        // Look in other focusable stacks.
@@ -843,7 +843,7 @@ class ActivityDisplay extends DisplayContent {
                if (stack == focusedStack || !stack.isFocusable()) {
                    continue;
                }
                topRunning = stack.topRunningActivityLocked();
                topRunning = stack.topRunningActivity();
                if (topRunning != null) {
                    break;
                }
@@ -961,12 +961,6 @@ class ActivityDisplay extends DisplayContent {
        super.onConfigurationChanged(newParentConfig);
    }

    void onLockTaskPackagesUpdated() {
        for (int i = getStackCount() - 1; i >= 0; --i) {
            getStackAt(i).onLockTaskPackagesUpdated();
        }
    }

    /** Checks whether the given activity is in size compatibility mode and notifies the change. */
    void handleActivitySizeCompatModeIfNeeded(ActivityRecord r) {
        if (!r.isState(RESUMED) || r.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
@@ -1082,7 +1076,7 @@ class ActivityDisplay extends DisplayContent {
        }

        final ActivityStack stack = getStackCount() == 1 ? getStackAt(0) : null;
        if (stack != null && stack.isActivityTypeHome() && stack.getAllTasks().isEmpty()) {
        if (stack != null && stack.isActivityTypeHome() && !stack.hasChild()) {
            // Release this display if an empty home stack is the only thing left.
            // Since it is the last stack, this display will be released along with the stack
            // removal.
@@ -1318,13 +1312,7 @@ class ActivityDisplay extends DisplayContent {

    @VisibleForTesting
    void removeAllTasks() {
        for (int i = getStackCount() - 1; i >= 0; --i) {
            final ActivityStack stack = getStackAt(i);
            final ArrayList<Task> tasks = stack.getAllTasks();
            for (int j = tasks.size() - 1; j >= 0; --j) {
                stack.removeChild(tasks.get(j), "removeAllTasks");
            }
        }
        mDisplayContent.forAllTasks((t) -> { t.getStack().removeChild(t, "removeAllTasks"); });
    }

    public void dump(PrintWriter pw, String prefix) {
+3 −2
Original line number Diff line number Diff line
@@ -2406,7 +2406,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // We are finishing the top focused activity and its stack has nothing to be focused so
            // the next focusable stack should be focused.
            if (mayAdjustTop
                    && (stack.topRunningActivityLocked() == null || !stack.isFocusable())) {
                    && (stack.topRunningActivity() == null || !stack.isFocusable())) {
                if (shouldAdjustGlobalFocus) {
                    // Move the entire hierarchy to top with updating global top resumed activity
                    // and focused application if needed.
@@ -3440,7 +3440,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    @Override
    ActivityRecord getActivity(Predicate<ActivityRecord> callback, boolean traverseTopToBottom) {
    ActivityRecord getActivity(Predicate<ActivityRecord> callback, boolean traverseTopToBottom,
            WindowContainer boundary) {
        return callback.test(this) ? this : null;
    }

Loading