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

Commit e0c542bd authored by Andrii Kulian's avatar Andrii Kulian Committed by Automerger Merge Worker
Browse files

Merge "2/n Move task management logic to TaskContainers" into rvc-dev am: 9cb59370 am: f2a1c68a

Change-Id: I18a6a10e1c284612630214e1b0cdbca2f599e2e6
parents 8ab288e9 f2a1c68a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2504,7 +2504,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    final DisplayContent display = stack.getDisplay();
                    next = display.topRunningActivity();
                    if (next != null) {
                        display.positionStackAtTop(next.getRootTask(),
                        display.mTaskContainers.positionStackAtTop(next.getRootTask(),
                                false /* includingParents */, "finish-display-top");
                    }
                }
@@ -2679,7 +2679,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final ActivityRecord next = display.topRunningActivity();
        final boolean isLastStackOverEmptyHome =
                next == null && stack.isFocusedStackOnDisplay()
                        && display.getOrCreateRootHomeTask() != null;
                        && display.mTaskContainers.getOrCreateRootHomeTask() != null;
        if (isLastStackOverEmptyHome) {
            // Don't destroy activity immediately if this is the last activity on the display and
            // the display contains home stack. Although there is no next activity at the moment,
@@ -4477,7 +4477,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // case where this is the top activity in a pinned stack.
        final boolean isTop = this == stack.getTopNonFinishingActivity();
        final boolean isTopNotPinnedStack = stack.isAttached()
                && stack.getDisplay().isTopNotPinnedStack(stack);
                && stack.getDisplay().mTaskContainers.isTopNotPinnedStack(stack);
        final boolean visibleIgnoringDisplayStatus = stack.checkKeyguardVisibility(this,
                visibleIgnoringKeyguard, isTop && isTopNotPinnedStack);

@@ -7389,7 +7389,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     */
    boolean isResumedActivityOnDisplay() {
        final DisplayContent display = getDisplay();
        return display != null && this == display.getResumedActivity();
        return display != null && this == display.mTaskContainers.getResumedActivity();
    }


+22 −20
Original line number Diff line number Diff line
@@ -670,7 +670,7 @@ class ActivityStack extends Task {
            // Since always on top is only on when the stack is freeform or pinned, the state
            // can be toggled when the windowing mode changes. We must make sure the stack is
            // placed properly when always on top state changes.
            display.positionStackAtTop(this, false /* includingParents */);
            display.mTaskContainers.positionStackAtTop(this, false /* includingParents */);
        }
    }

@@ -742,7 +742,7 @@ class ActivityStack extends Task {
        // Need to make sure windowing mode is supported. If we in the process of creating the stack
        // no need to resolve the windowing mode again as it is already resolved to the right mode.
        if (!creating) {
            windowingMode = display.validateWindowingMode(windowingMode,
            windowingMode = display.mTaskContainers.validateWindowingMode(windowingMode,
                    null /* ActivityRecord */, topTask, getActivityType());
        }
        if (display.getRootSplitScreenPrimaryTask() == this
@@ -752,7 +752,8 @@ class ActivityStack extends Task {
            windowingMode = mRestoreOverrideWindowingMode;
        }

        final boolean alreadyInSplitScreenMode = display.isSplitScreenModeActivated();
        final boolean alreadyInSplitScreenMode = display.mTaskContainers
                .isSplitScreenModeActivated();

        // Don't send non-resizeable notifications if the windowing mode changed was a side effect
        // of us entering split-screen mode.
@@ -769,7 +770,7 @@ class ActivityStack extends Task {
                // warning toast about it.
                mAtmService.getTaskChangeNotificationController()
                        .notifyActivityDismissingDockedStack();
                display.onSplitScreenModeDismissed();
                display.mTaskContainers.onSplitScreenModeDismissed();
            }
        }

@@ -861,7 +862,7 @@ class ActivityStack extends Task {
                // TODO (b/78247419): Fix the rotation animation from fullscreen to minimized mode
                final boolean isRecentsComponentHome =
                        mAtmService.getRecentTasks().isRecentsComponentHomeActivity(mCurrentUser);
                final ActivityStack recentStack = display.getOrCreateStack(
                final ActivityStack recentStack = display.mTaskContainers.getOrCreateStack(
                        WINDOWING_MODE_SPLIT_SCREEN_SECONDARY,
                        isRecentsComponentHome ? ACTIVITY_TYPE_HOME : ACTIVITY_TYPE_RECENTS,
                        true /* onTop */);
@@ -1058,7 +1059,7 @@ class ActivityStack extends Task {
            // cutting between them.
            // TODO(b/70677280): This is a workaround until we can fix as part of b/70677280.
            final ActivityStack topFullScreenStack =
                    display.getTopStackInWindowingMode(WINDOWING_MODE_FULLSCREEN);
                    display.mTaskContainers.getTopStackInWindowingMode(WINDOWING_MODE_FULLSCREEN);
            if (topFullScreenStack != null) {
                final ActivityStack primarySplitScreenStack = display.getRootSplitScreenPrimaryTask();
                if (primarySplitScreenStack != null && display.getIndexOf(topFullScreenStack)
@@ -1071,11 +1072,11 @@ class ActivityStack extends Task {
        if (!isActivityTypeHome() && returnsToHomeStack()) {
            // Make sure the home stack is behind this stack since that is where we should return to
            // when this stack is no longer visible.
            display.moveHomeStackToFront(reason + " returnToHome");
            display.mTaskContainers.moveHomeStackToFront(reason + " returnToHome");
        }

        if (isRootTask()) {
            display.positionStackAtTop(this, false /* includingParents */, reason);
            display.mTaskContainers.positionStackAtTop(this, false /* includingParents */, reason);
        }
        if (task == null) {
            task = this;
@@ -1092,7 +1093,7 @@ class ActivityStack extends Task {
            return;
        }

        getDisplay().positionStackAtBottom(this, reason);
        getDisplay().mTaskContainers.positionStackAtBottom(this, reason);
        if (task != null && task != this) {
            positionChildAtBottom(task);
        }
@@ -1460,7 +1461,7 @@ class ActivityStack extends Task {

    boolean isTopStackOnDisplay() {
        final DisplayContent display = getDisplay();
        return display != null && display.isTopStack(this);
        return display != null && display.mTaskContainers.isTopStack(this);
    }

    /**
@@ -1667,7 +1668,8 @@ class ActivityStack extends Task {
     */
    boolean isTopSplitScreenStack() {
        return inSplitScreenWindowingMode()
                && this == getDisplay().getTopStackInWindowingMode(getWindowingMode());
                && this == getDisplay().mTaskContainers
                .getTopStackInWindowingMode(getWindowingMode());
    }

    /** @return True if the resizing of the primary-split-screen stack affects this stack size. */
@@ -1900,7 +1902,7 @@ class ActivityStack extends Task {

        // If the top activity is the resumed one, nothing to do.
        if (mResumedActivity == next && next.isState(RESUMED)
                && display.allResumedActivitiesComplete()) {
                && display.mTaskContainers.allResumedActivitiesComplete()) {
            // Make sure we have executed any pending transitions, since there
            // should be nothing left to do at this point.
            executeAppTransition(options);
@@ -1979,7 +1981,7 @@ class ActivityStack extends Task {
        mStackSupervisor.setLaunchSource(next.info.applicationInfo.uid);

        ActivityRecord lastResumed = null;
        final ActivityStack lastFocusedStack = display.getLastFocusedStack();
        final ActivityStack lastFocusedStack = display.mTaskContainers.getLastFocusedStack();
        if (lastFocusedStack != null && lastFocusedStack != this) {
            // So, why aren't we using prev here??? See the param comment on the method. prev doesn't
            // represent the last resumed activity. However, the last focus stack does if it isn't null.
@@ -1993,7 +1995,7 @@ class ActivityStack extends Task {
            }
        }

        boolean pausing = display.pauseBackStacks(userLeaving, next);
        boolean pausing = display.mTaskContainers.pauseBackStacks(userLeaving, next);
        if (mResumedActivity != null) {
            if (DEBUG_STATES) Slog.d(TAG_STATES,
                    "resumeTopActivityLocked: Pausing " + mResumedActivity);
@@ -2022,7 +2024,7 @@ class ActivityStack extends Task {
            }
            return true;
        } else if (mResumedActivity == next && next.isState(RESUMED)
                && display.allResumedActivitiesComplete()) {
                && display.mTaskContainers.allResumedActivitiesComplete()) {
            // It is possible for the activity to be resumed when we paused back stacks above if the
            // next activity doesn't have to wait for pause to complete.
            // So, nothing else to-do except:
@@ -2542,7 +2544,7 @@ class ActivityStack extends Task {
        if (stack.isActivityTypeHome() && (top == null || !top.mVisibleRequested)) {
            // If we will be focusing on the home stack next and its current top activity isn't
            // visible, then use the move the home stack task to top to make the activity visible.
            stack.getDisplay().moveHomeActivityToTop(reason);
            stack.getDisplay().mTaskContainers.moveHomeActivityToTop(reason);
            return stack;
        }

@@ -3304,7 +3306,7 @@ class ActivityStack extends Task {
        final boolean wasResumed = topRunningActivity == task.getStack().mResumedActivity;

        boolean toTop = position >= getChildCount();
        boolean includingParents = toTop || getDisplay().getNextFocusableStack(this,
        boolean includingParents = toTop || getDisplay().mTaskContainers.getNextFocusableStack(this,
                true /* ignoreCurrent */) == null;
        if (WindowManagerDebugConfig.DEBUG_STACK) {
            Slog.i(TAG_WM, "positionChildAt: positioning task=" + task + " at " + position);
@@ -3348,7 +3350,7 @@ class ActivityStack extends Task {
        // always on top windows. Since the position the stack should be inserted into is calculated
        // properly in {@link DisplayContent#getTopInsertPosition()} in both cases, we can just
        // request that the stack is put at top here.
        display.positionStackAtTop(this, false /* includingParents */);
        display.mTaskContainers.positionStackAtTop(this, false /* includingParents */);
    }

    /** NOTE: Should only be called from {@link Task#reparent}. */
@@ -3399,7 +3401,7 @@ class ActivityStack extends Task {
            final Task task = getBottomMostTask();
            setWindowingMode(WINDOWING_MODE_UNDEFINED);

            getDisplay().positionStackAtTop(this, false /* includingParents */);
            getDisplay().mTaskContainers.positionStackAtTop(this, false /* includingParents */);

            mStackSupervisor.scheduleUpdatePictureInPictureModeIfNeeded(task, this);
            MetricsLoggerWrapper.logPictureInPictureFullScreen(mAtmService.mContext,
@@ -3519,7 +3521,7 @@ class ActivityStack extends Task {
        // If there are other focusable stacks on the display, the z-order of the display should not
        // be changed just because a task was placed at the bottom. E.g. if it is moving the topmost
        // task to bottom, the next focusable stack on the same display should be focused.
        final ActivityStack nextFocusableStack = getDisplay().getNextFocusableStack(
        final ActivityStack nextFocusableStack = getDisplay().mTaskContainers.getNextFocusableStack(
                child.getStack(), true /* ignoreCurrent */);
        positionChildAtBottom(child, nextFocusableStack == null /* includingParents */);
        child.updateTaskMovement(true);
+10 −9
Original line number Diff line number Diff line
@@ -414,14 +414,15 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                if (mToDisplay.getDisplayId() != stack.getDisplayId()) {
                    mToDisplay.moveStackToDisplay(stack, mOnTop);
                } else if (mOnTop) {
                    mToDisplay.positionStackAtTop(stack, false /* includingParents */);
                    mToDisplay.mTaskContainers.positionStackAtTop(stack,
                            false /* includingParents */);
                } else {
                    mToDisplay.positionStackAtBottom(stack);
                    mToDisplay.mTaskContainers.positionStackAtBottom(stack);
                }
                return;
            }

            final ActivityStack toStack = mToDisplay.getOrCreateStack(
            final ActivityStack toStack = mToDisplay.mTaskContainers.getOrCreateStack(
                    null, mTmpOptions, task, task.getActivityType(), mOnTop);
            if (task == toStack) {
                // The task was reused as the root task.
@@ -1458,7 +1459,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                || (focusedStack != null && focusedStack.isActivityTypeRecents())) {
            // We move home stack to front when we are on a fullscreen display and caller has
            // requested the home activity to move with it. Or the previous stack is recents.
            display.moveHomeStackToFront(reason);
            display.mTaskContainers.moveHomeStackToFront(reason);
        }
    }

@@ -1877,7 +1878,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        mStoppingActivities.remove(r);

        final ActivityStack stack = r.getRootTask();
        if (stack.getDisplay().allResumedActivitiesComplete()) {
        if (stack.getDisplay().mTaskContainers.allResumedActivitiesComplete()) {
            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
            // Make sure activity & window visibility should be identical
            // for all displays in this stage.
@@ -2241,7 +2242,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        final boolean isSecondaryDisplayPreferred =
                (preferredDisplayId != DEFAULT_DISPLAY && preferredDisplayId != INVALID_DISPLAY);
        final boolean inSplitScreenMode = actualStack != null
                && actualStack.getDisplay().isSplitScreenModeActivated();
                && actualStack.getDisplay().mTaskContainers.isSplitScreenModeActivated();
        if (((!inSplitScreenMode && preferredWindowingMode != WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)
                && !isSecondaryDisplayPreferred) || !task.isActivityTypeStandardOrUndefined()) {
            return;
@@ -2289,12 +2290,12 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
            // Dismiss docked stack. If task appeared to be in docked stack but is not resizable -
            // we need to move it to top of fullscreen stack, otherwise it will be covered.
            final DisplayContent display = task.getStack().getDisplay();
            if (display.isSplitScreenModeActivated()) {
            if (display.mTaskContainers.isSplitScreenModeActivated()) {
                // Display a warning toast that we tried to put an app that doesn't support
                // split-screen in split-screen.
                mService.getTaskChangeNotificationController()
                        .notifyActivityDismissingDockedStack();
                display.onSplitScreenModeDismissed();
                display.mTaskContainers.onSplitScreenModeDismissed();
                display.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS,
                        true /* notifyClients */);
            }
@@ -2612,7 +2613,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                // from whatever is started from the recents activity, so move the home stack
                // forward.
                // TODO (b/115289124): Multi-display supports for recents.
                mRootWindowContainer.getDefaultDisplay().moveHomeStackToFront(
                mRootWindowContainer.getDefaultDisplay().mTaskContainers.moveHomeStackToFront(
                        "startActivityFromRecents");
            }

+2 −2
Original line number Diff line number Diff line
@@ -190,8 +190,8 @@ public class ActivityStartController {
        final ActivityStack homeStack;
        try {
            // Make sure home stack exist on display.
            homeStack = display.getOrCreateStack(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME,
                    ON_TOP);
            homeStack = display.mTaskContainers.getOrCreateStack(WINDOWING_MODE_FULLSCREEN,
                    ACTIVITY_TYPE_HOME, ON_TOP);
        } finally {
            mSupervisor.endDeferResume();
        }
+7 −6
Original line number Diff line number Diff line
@@ -2357,7 +2357,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                }
                // Convert some windowing-mode changes into root-task reparents for split-screen.
                if (stack.inSplitScreenWindowingMode()) {
                    stack.getDisplay().onSplitScreenModeDismissed();
                    stack.getDisplay().mTaskContainers.onSplitScreenModeDismissed();

                } else {
                    stack.setWindowingMode(windowingMode);
@@ -2775,7 +2775,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        }

        if (toTop) {
            display.positionStackAt(POSITION_TOP, primarySplitTask, false /* includingParents */);
            display.mTaskContainers.positionStackAt(POSITION_TOP, primarySplitTask,
                    false /* includingParents */);
        }
        WindowContainerTransaction wct = new WindowContainerTransaction();
        wct.reparent(task.getStack().mRemoteToken, primarySplitTask.mRemoteToken, toTop);
@@ -3244,8 +3245,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                }

                final ActivityStack stack = r.getRootTask();
                final Task task = stack.getDisplay().createStack(stack.getWindowingMode(),
                        stack.getActivityType(), !ON_TOP, ainfo, intent,
                final Task task = stack.getDisplay().mTaskContainers.createStack(
                        stack.getWindowingMode(), stack.getActivityType(), !ON_TOP, ainfo, intent,
                        false /* createdByOrganizer */);

                if (!mRecentTasks.addToBottom(task)) {
@@ -3308,10 +3309,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                    throw new IllegalArgumentException("resizeTask not allowed on task=" + task);
                }
                if (bounds == null && stack.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
                    stack = stack.getDisplay().getOrCreateStack(
                    stack = stack.getDisplay().mTaskContainers.getOrCreateStack(
                            WINDOWING_MODE_FULLSCREEN, stack.getActivityType(), ON_TOP);
                } else if (bounds != null && stack.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
                    stack = stack.getDisplay().getOrCreateStack(
                    stack = stack.getDisplay().mTaskContainers.getOrCreateStack(
                            WINDOWING_MODE_FREEFORM, stack.getActivityType(), ON_TOP);
                }

Loading