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

Commit 149d5c86 authored by Louis Chang's avatar Louis Chang
Browse files

Merge RootActivityContainer and RootWindowContainer (85/n)

Bug: 80414790
Test: Existing tests pass
Change-Id: Ica2917099b09e6c091100401645ffcdfff761aa5
parent 610a1260
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ class ActivityMetricsLogger {

        mWindowState = WINDOW_STATE_INVALID;
        ActivityStack stack =
                mSupervisor.mRootActivityContainer.getTopDisplayFocusedStack();
                mSupervisor.mRootWindowContainer.getTopDisplayFocusedStack();
        if (stack == null) {
            return;
        }
@@ -408,7 +408,7 @@ class ActivityMetricsLogger {

        @WindowingMode int windowingMode = stack.getWindowingMode();
        if (windowingMode == WINDOWING_MODE_PINNED) {
            stack = mSupervisor.mRootActivityContainer.findStackBehind(stack);
            stack = mSupervisor.mRootWindowContainer.findStackBehind(stack);
            windowingMode = stack.getWindowingMode();
        }
        switch (windowingMode) {
+19 −19
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    boolean inHistory;  // are we in the history stack?
    final ActivityStackSupervisor mStackSupervisor;
    final RootActivityContainer mRootActivityContainer;
    final RootWindowContainer mRootWindowContainer;

    static final int STARTING_WINDOW_NOT_SHOWN = 0;
    static final int STARTING_WINDOW_SHOWN = 1;
@@ -1564,7 +1564,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        appToken.attach(this);

        mRootActivityContainer = _service.mRootActivityContainer;
        mRootWindowContainer = _service.mRootWindowContainer;
        launchedFromPid = _launchedFromPid;
        launchedFromUid = _launchedFromUid;
        launchedFromPackage = _launchedFromPackage;
@@ -2100,7 +2100,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // {@link #returningOptions} of the activity under this one can be applied in
        // {@link #handleAlreadyVisible()}.
        if (changed || !occludesParent) {
            mRootActivityContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
        }
        return changed;
    }
@@ -2140,7 +2140,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    boolean isFocusable() {
        return mRootActivityContainer.isFocusable(this, isAlwaysFocusable());
        return mRootWindowContainer.isFocusable(this, isAlwaysFocusable());
    }

    boolean isResizeable() {
@@ -2336,7 +2336,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return false;
        }

        if (mRootActivityContainer.getTopResumedActivity() == this
        if (mRootWindowContainer.getTopResumedActivity() == this
                && getDisplayContent().mFocusedApp == this) {
            if (DEBUG_FOCUS) {
                Slog.d(TAG_FOCUS, "moveActivityStackToFront: already on top, activity=" + this);
@@ -2350,7 +2350,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        stack.moveToFront(reason, task);
        // Report top activity change to tracking services and WM
        if (mRootActivityContainer.getTopResumedActivity() == this) {
        if (mRootWindowContainer.getTopResumedActivity() == this) {
            mAtmService.setResumedActivityUncheckLocked(this, reason);
        }
        return true;
@@ -2466,7 +2466,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final boolean shouldAdjustGlobalFocus = mayAdjustTop
                // It must be checked before {@link #makeFinishingLocked} is called, because a stack
                // is not visible if it only contains finishing activities.
                && mRootActivityContainer.isTopDisplayFocusedStack(stack);
                && mRootWindowContainer.isTopDisplayFocusedStack(stack);

        mAtmService.deferWindowLayout();
        try {
@@ -2694,11 +2694,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // If the display does not have running activity, the configuration may need to be
        // updated for restoring original orientation of the display.
        if (next == null) {
            mRootActivityContainer.ensureVisibilityAndConfig(next, getDisplayId(),
            mRootWindowContainer.ensureVisibilityAndConfig(next, getDisplayId(),
                    false /* markFrozenIfConfigChanged */, true /* deferResume */);
        }
        if (activityRemoved) {
            mRootActivityContainer.resumeFocusedStacksTopActivities();
            mRootWindowContainer.resumeFocusedStacksTopActivities();
        }

        if (DEBUG_CONTAINERS) {
@@ -2722,7 +2722,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            mStackSupervisor.mFinishingActivities.add(this);
        }
        resumeKeyDispatchingLocked();
        return mRootActivityContainer.resumeFocusedStacksTopActivities();
        return mRootWindowContainer.resumeFocusedStacksTopActivities();
    }

    /**
@@ -2892,7 +2892,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            removeFromHistory(reason);
        }

        mRootActivityContainer.resumeFocusedStacksTopActivities();
        mRootWindowContainer.resumeFocusedStacksTopActivities();
    }

    /**
@@ -3409,13 +3409,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    void setShowWhenLocked(boolean showWhenLocked) {
        mShowWhenLocked = showWhenLocked;
        mAtmService.mRootActivityContainer.ensureActivitiesVisible(null /* starting */,
        mAtmService.mRootWindowContainer.ensureActivitiesVisible(null /* starting */,
                0 /* configChanges */, false /* preserveWindows */);
    }

    void setInheritShowWhenLocked(boolean inheritShowWhenLocked) {
        mInheritShownWhenLocked = inheritShowWhenLocked;
        mAtmService.mRootActivityContainer.ensureActivitiesVisible(null /* starting */,
        mAtmService.mRootWindowContainer.ensureActivitiesVisible(null /* starting */,
                0 /* configChanges */, false /* preserveWindows */);
    }

@@ -4835,7 +4835,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            }
        }

        mRootActivityContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
        mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
    }

    /**
@@ -4966,9 +4966,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            } else {
                if (deferRelaunchUntilPaused) {
                    destroyImmediately(true /* removeFromApp */, "stop-config");
                    mRootActivityContainer.resumeFocusedStacksTopActivities();
                    mRootWindowContainer.resumeFocusedStacksTopActivities();
                } else {
                    mRootActivityContainer.updatePreviousProcess(this);
                    mRootWindowContainer.updatePreviousProcess(this);
                }
            }
        }
@@ -5428,7 +5428,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // First find the real culprit...  if this activity has stopped, then the key dispatching
        // timeout should not be caused by this.
        if (stopped) {
            final ActivityStack stack = mRootActivityContainer.getTopDisplayFocusedStack();
            final ActivityStack stack = mRootWindowContainer.getTopDisplayFocusedStack();
            // Try to use the one which is closest to top.
            ActivityRecord r = stack.getResumedActivity();
            if (r == null) {
@@ -6104,7 +6104,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        getDisplayContent().mAppTransition.notifyAppTransitionFinishedLocked(token);
        scheduleAnimation();

        if (mAtmService.mRootActivityContainer.allResumedActivitiesIdle()
        if (mAtmService.mRootWindowContainer.allResumedActivitiesIdle()
                || mAtmService.mStackSupervisor.isStoppingNoHistoryActivity()) {
            // If all activities are already idle or there is an activity that must be
            // stopped immediately after visible, then we now need to make sure we perform
@@ -7423,7 +7423,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    boolean isTopRunningActivity() {
        return mRootActivityContainer.topRunningActivity() == this;
        return mRootWindowContainer.topRunningActivity() == this;
    }

    /**
+30 −30
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn

    /** Run all ActivityStacks through this */
    protected final ActivityStackSupervisor mStackSupervisor;
    protected final RootActivityContainer mRootActivityContainer;
    protected final RootWindowContainer mRootWindowContainer;

    private boolean mTopActivityOccludesKeyguard;
    private ActivityRecord mTopDismissingKeyguardActivity;
@@ -443,7 +443,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            if (mUpdateConfig) {
                // Ensure the resumed state of the focus activity if we updated the configuration of
                // any activity.
                mRootActivityContainer.resumeFocusedStacksTopActivities();
                mRootWindowContainer.resumeFocusedStacksTopActivities();
            }
        }

@@ -646,7 +646,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        EventLogTags.writeWmStackCreated(stackId);
        mStackSupervisor = supervisor;
        mAtmService = supervisor.mService;
        mRootActivityContainer = mAtmService.mRootActivityContainer;
        mRootWindowContainer = mAtmService.mRootWindowContainer;
        mHandler = new ActivityStackHandler(supervisor.mLooper);
        mRemoteToken = new RemoteToken(this);
        mCurrentUser = mAtmService.mAmInternal.getCurrentUserId();
@@ -673,7 +673,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            if (DEBUG_STACK) Slog.v(TAG_STACK, "set resumed activity to:" + record + " reason:"
                    + reason);
            setResumedActivity(record, reason + " - onActivityStateChanged");
            if (record == mRootActivityContainer.getTopResumedActivity()) {
            if (record == mRootWindowContainer.getTopResumedActivity()) {
                mAtmService.setResumedActivityUncheckLocked(record, reason);
            }
            mStackSupervisor.mRecentTasks.add(record.getTask());
@@ -983,8 +983,8 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        }

        if (!deferEnsuringVisibility) {
            mRootActivityContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS);
            mRootActivityContainer.resumeFocusedStacksTopActivities();
            mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS);
            mRootWindowContainer.resumeFocusedStacksTopActivities();
        }
    }

@@ -1002,10 +1002,10 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
    /** Resume next focusable stack after reparenting to another display. */
    void postReparent() {
        adjustFocusToNextFocusableStack("reparent", true /* allowFocusSelf */);
        mRootActivityContainer.resumeFocusedStacksTopActivities();
        mRootWindowContainer.resumeFocusedStacksTopActivities();
        // Update visibility of activities before notifying WM. This way it won't try to resize
        // windows that are no longer visible.
        mRootActivityContainer.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */,
        mRootWindowContainer.ensureActivitiesVisible(null /* starting */, 0 /* configChanges */,
                !PRESERVE_WINDOWS);
    }

@@ -1230,7 +1230,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn

    boolean isFocusable() {
        final ActivityRecord r = topRunningActivity();
        return mRootActivityContainer.isFocusable(this, r != null && r.isFocusable());
        return mRootWindowContainer.isFocusable(this, r != null && r.isFocusable());
    }

    boolean isFocusableAndVisible() {
@@ -1395,7 +1395,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        if (prev == null) {
            if (resuming == null) {
                Slog.wtf(TAG, "Trying to pause when nothing is resumed");
                mRootActivityContainer.resumeFocusedStacksTopActivities();
                mRootWindowContainer.resumeFocusedStacksTopActivities();
            }
            return false;
        }
@@ -1485,7 +1485,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            // pause, so just treat it as being paused now.
            if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Activity not running, resuming next.");
            if (resuming == null) {
                mRootActivityContainer.resumeFocusedStacksTopActivities();
                mRootWindowContainer.resumeFocusedStacksTopActivities();
            }
            return false;
        }
@@ -1538,9 +1538,9 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        }

        if (resumeNext) {
            final ActivityStack topStack = mRootActivityContainer.getTopDisplayFocusedStack();
            final ActivityStack topStack = mRootWindowContainer.getTopDisplayFocusedStack();
            if (!topStack.shouldSleepOrShutDownActivities()) {
                mRootActivityContainer.resumeFocusedStacksTopActivities(topStack, prev, null);
                mRootWindowContainer.resumeFocusedStacksTopActivities(topStack, prev, null);
            } else {
                checkReadyForSleep();
                ActivityRecord top = topStack.topRunningActivity();
@@ -1549,7 +1549,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
                    // something. Also if the top activity on the stack is not the just paused
                    // activity, we need to go ahead and resume it to ensure we complete an
                    // in-flight app switch.
                    mRootActivityContainer.resumeFocusedStacksTopActivities();
                    mRootWindowContainer.resumeFocusedStacksTopActivities();
                }
            }
        }
@@ -1580,7 +1580,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            mStackSupervisor.mAppVisibilitiesChangedSinceLastPause = false;
        }

        mRootActivityContainer.ensureActivitiesVisible(resuming, 0, !PRESERVE_WINDOWS);
        mRootWindowContainer.ensureActivitiesVisible(resuming, 0, !PRESERVE_WINDOWS);
    }

    /**
@@ -1786,7 +1786,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
    /**
     * Ensure visibility with an option to also update the configuration of visible activities.
     * @see #ensureActivitiesVisible(ActivityRecord, int, boolean)
     * @see RootActivityContainer#ensureActivitiesVisible(ActivityRecord, int, boolean)
     * @see RootWindowContainer#ensureActivitiesVisible(ActivityRecord, int, boolean)
     */
    // TODO: Should be re-worked based on the fact that each task as a stack in most cases.
    void ensureActivitiesVisible(ActivityRecord starting, int configChanges,
@@ -1988,7 +1988,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
     *
     * NOTE: It is not safe to call this method directly as it can cause an activity in a
     *       non-focused stack to be resumed.
     *       Use {@link RootActivityContainer#resumeFocusedStacksTopActivities} to resume the
     *       Use {@link RootWindowContainer#resumeFocusedStacksTopActivities} to resume the
     *       right activity for the current system state.
     */
    @GuardedBy("mService")
@@ -2059,7 +2059,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            return false;
        }

        mRootActivityContainer.cancelInitializingActivities();
        mRootWindowContainer.cancelInitializingActivities();

        // Remember how we'll process this pause/resume situation, and ensure
        // that the state is reset however we wind up proceeding.
@@ -2093,7 +2093,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        // activity is paused, well that is the state we want.
        if (shouldSleepOrShutDownActivities()
                && mLastPausedActivity == next
                && mRootActivityContainer.allPausedActivitiesComplete()) {
                && mRootWindowContainer.allPausedActivitiesComplete()) {
            // If the current top activity may be able to occlude keyguard but the occluded state
            // has not been set, update visibility and check again if we should continue to resume.
            boolean nothingToResume = true;
@@ -2137,7 +2137,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resuming " + next);

        // If we are currently pausing an activity, then don't do anything until that is done.
        if (!mRootActivityContainer.allPausedActivitiesComplete()) {
        if (!mRootWindowContainer.allPausedActivitiesComplete()) {
            if (DEBUG_SWITCH || DEBUG_PAUSE || DEBUG_STATES) Slog.v(TAG_PAUSE,
                    "resumeTopActivityLocked: Skip resume: some activity pausing.");

@@ -2350,7 +2350,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
                // result of invisible window resize.
                // TODO: Remove this once visibilities are set correctly immediately when
                // starting an activity.
                notUpdated = !mRootActivityContainer.ensureVisibilityAndConfig(next, mDisplayId,
                notUpdated = !mRootWindowContainer.ensureVisibilityAndConfig(next, mDisplayId,
                        true /* markFrozenIfConfigChanged */, false /* deferResume */);
            }

@@ -2481,7 +2481,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
                // Try to move focus to the next visible stack with a running activity if this
                // stack is not covering the entire screen or is on a secondary display with no home
                // stack.
                return mRootActivityContainer.resumeFocusedStacksTopActivities(nextFocusedStack,
                return mRootWindowContainer.resumeFocusedStacksTopActivities(nextFocusedStack,
                        prev, null /* targetOptions */);
            }
        }
@@ -2491,7 +2491,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        ActivityOptions.abort(options);
        if (DEBUG_STATES) Slog.d(TAG_STATES,
                "resumeNextFocusableActivityWhenStackIsEmpty: " + reason + ", go home");
        return mRootActivityContainer.resumeHomeActivity(prev, reason, mDisplayId);
        return mRootWindowContainer.resumeHomeActivity(prev, reason, mDisplayId);
    }

    void startActivityLocked(ActivityRecord r, ActivityRecord focusedTopActivity,
@@ -2698,7 +2698,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
     */
    private ActivityStack adjustFocusToNextFocusableStack(String reason, boolean allowFocusSelf) {
        final ActivityStack stack =
                mRootActivityContainer.getNextFocusableStack(this, !allowFocusSelf);
                mRootWindowContainer.getNextFocusableStack(this, !allowFocusSelf);
        final String myReason = reason + " adjustFocusToNextFocusableStack";
        if (stack == null) {
            return null;
@@ -3070,7 +3070,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
                topActivity.supportsEnterPipOnTaskSwitch = true;
            }

            mRootActivityContainer.resumeFocusedStacksTopActivities();
            mRootWindowContainer.resumeFocusedStacksTopActivities();
            EventLogTags.writeWmTaskToFront(tr.mUserId, tr.mTaskId);
            mAtmService.getTaskChangeNotificationController().notifyTaskMovedToFront(tr.getTaskInfo());
        } finally {
@@ -3138,12 +3138,12 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            // The new top activity is already resumed, so there's a good chance that nothing will
            // get resumed below. So, update visibility now in case the transition is closed
            // prematurely.
            mRootActivityContainer.ensureVisibilityAndConfig(null /* starting */,
            mRootWindowContainer.ensureVisibilityAndConfig(null /* starting */,
                    getDisplay().mDisplayId, false /* markFrozenIfConfigChanged */,
                    false /* deferResume */);
        }

        mRootActivityContainer.resumeFocusedStacksTopActivities();
        mRootWindowContainer.resumeFocusedStacksTopActivities();
        return true;
    }

@@ -3505,7 +3505,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        // The task might have already been running and its visibility needs to be synchronized with
        // the visibility of the stack / windows.
        ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
        mRootActivityContainer.resumeFocusedStacksTopActivities();
        mRootWindowContainer.resumeFocusedStacksTopActivities();
    }

    public void setAlwaysOnTop(boolean alwaysOnTop) {
@@ -3545,7 +3545,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        moveToFront(reason);
        // If the original state is resumed, there is no state change to update focused app.
        // So here makes sure the activity focus is set if it is the top.
        if (origState == RESUMED && r == mRootActivityContainer.getTopResumedActivity()) {
        if (origState == RESUMED && r == mRootWindowContainer.getTopResumedActivity()) {
            mAtmService.setResumedActivityUncheckLocked(r, reason);
        }
    }
@@ -4090,7 +4090,7 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            mStackSupervisor.resizeDockedStackLocked(getRequestedOverrideBounds(), mTmpRect,
                    mTmpRect2, null, null, PRESERVE_WINDOWS);
        }
        mRootActivityContainer.updateUIDsPresentOnDisplay();
        mRootWindowContainer.updateUIDsPresentOnDisplay();

        // Resume next focusable stack after reparenting to another display if we aren't removing
        // the prevous display.
+47 −47

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ public class ActivityStartController {
        options.setLaunchDisplayId(displayId);

        final DisplayContent display =
                mService.mRootActivityContainer.getDisplayContent(displayId);
                mService.mRootWindowContainer.getDisplayContent(displayId);
        // The home activity will be started later, defer resuming to avoid unneccerary operations
        // (e.g. start home recursively) when creating home stack.
        mSupervisor.beginDeferResume();
Loading