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

Commit cd85aff3 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Simplify some legacy path of resume activity" into main

parents 0acf75e1 ca8afc4c
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -658,7 +658,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

    boolean mVoiceInteraction;

    private int mPendingRelaunchCount;
    int mPendingRelaunchCount;
    long mRelaunchStartTime;

    // True if we are current in the process of removing this app token from the display
@@ -3988,7 +3988,7 @@ 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) {
            mRootWindowContainer.ensureVisibilityAndConfig(next, getDisplayId(),
            mRootWindowContainer.ensureVisibilityAndConfig(null /* starting */, mDisplayContent,
                    true /* deferResume */);
        }
        if (activityRemoved) {
@@ -6463,12 +6463,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * state to match that fact.
     */
    void completeResumeLocked() {
        final boolean wasVisible = mVisibleRequested;
        setVisibility(true);
        if (!wasVisible) {
            // Visibility has changed, so take a note of it so we call the TaskStackChangedListener
            mTaskSupervisor.mAppVisibilitiesChangedSinceLastPause = true;
        }
        idle = false;
        results = null;
        if (newIntents != null && newIntents.size() > 0) {
+1 −1
Original line number Diff line number Diff line
@@ -1625,7 +1625,7 @@ class ActivityStarter {
        final ActivityRecord currentTop = startedActivityRootTask.topRunningActivity();
        if (currentTop != null && currentTop.shouldUpdateConfigForDisplayChanged()) {
            mRootWindowContainer.ensureVisibilityAndConfig(
                    currentTop, currentTop.getDisplayId(), false /* deferResume */);
                    currentTop, currentTop.mDisplayContent, false /* deferResume */);
        }

        if (!avoidMoveToFront() && mDoResume && mRootWindowContainer
+3 −2
Original line number Diff line number Diff line
@@ -842,7 +842,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
                // Deferring resume here because we're going to launch new activity shortly.
                // We don't want to perform a redundant launch of the same record while ensuring
                // configurations and trying to resume top activity of focused root task.
                mRootWindowContainer.ensureVisibilityAndConfig(r, r.getDisplayId(),
                mRootWindowContainer.ensureVisibilityAndConfig(r, r.mDisplayContent,
                        true /* deferResume */);
            }

@@ -1011,7 +1011,8 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        if (andResume && readyToResume()) {
            // As part of the process of launching, ActivityThread also performs
            // a resume.
            rootTask.minimalResumeActivityLocked(r);
            r.setState(RESUMED, "realStartActivityLocked");
            r.completeResumeLocked();
        } else {
            // This activity is not starting in the resumed state... which should look like we asked
            // it to pause+stop (but remain visible), and it has done so and reported back the
+7 −21
Original line number Diff line number Diff line
@@ -1742,30 +1742,21 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
     *
     * @param starting                  The currently starting activity or {@code null} if there is
     *                                  none.
     * @param displayId                 The id of the display where operation is executed.
     * @param displayContent            The display where the operation is executed.
     * @param deferResume               Whether to defer resume while updating config.
     * @return 'true' if starting activity was kept or wasn't provided, 'false' if it was relaunched
     * because of configuration update.
     */
    boolean ensureVisibilityAndConfig(ActivityRecord starting, int displayId, boolean deferResume) {
    void ensureVisibilityAndConfig(@Nullable ActivityRecord starting,
            @NonNull DisplayContent displayContent, boolean deferResume) {
        // First ensure visibility without updating the config just yet. We need this to know what
        // activities are affecting configuration now.
        // Passing null here for 'starting' param value, so that visibility of actual starting
        // activity will be properly updated.
        ensureActivitiesVisible(null /* starting */, false /* notifyClients */);

        if (displayId == INVALID_DISPLAY) {
            // The caller didn't provide a valid display id, skip updating config.
            return true;
        }

        // Force-update the orientation from the WindowManager, since we need the true configuration
        // to send to the client now.
        final DisplayContent displayContent = getDisplayContent(displayId);
        Configuration config = null;
        if (displayContent != null) {
            config = displayContent.updateOrientation(starting, true /* forceUpdate */);
        }
        final Configuration config =
                displayContent.updateOrientation(starting, true /* forceUpdate */);
        // Visibilities may change so let the starting activity have a chance to report. Can't do it
        // when visibility is changed in each AppWindowToken because it may trigger wrong
        // configuration push because the visibility of some activities may not be updated yet.
@@ -1773,13 +1764,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            starting.reportDescendantOrientationChangeIfNeeded();
        }

        if (displayContent != null) {
        // Update the configuration of the activities on the display.
            return displayContent.updateDisplayOverrideConfigurationLocked(config, starting,
                    deferResume);
        } else {
            return true;
        }
        displayContent.updateDisplayOverrideConfigurationLocked(config, starting, deferResume);
    }

    /**
+1 −8
Original line number Diff line number Diff line
@@ -4948,13 +4948,6 @@ class Task extends TaskFragment {
        }
    }

    void minimalResumeActivityLocked(ActivityRecord r) {
        ProtoLog.v(WM_DEBUG_STATES, "Moving to RESUMED: %s (starting new instance) "
                + "callers=%s", r, Debug.getCallers(5));
        r.setState(RESUMED, "minimalResumeActivityLocked");
        r.completeResumeLocked();
    }

    void checkReadyForSleep() {
        if (shouldSleepActivities() && goToSleepIfPossible(false /* shuttingDown */)) {
            mTaskSupervisor.checkReadyForSleepLocked(true /* allowDelay */);
@@ -5863,7 +5856,7 @@ class Task extends TaskFragment {
            }

            mRootWindowContainer.ensureVisibilityAndConfig(null /* starting */,
                    mDisplayContent.mDisplayId, false /* deferResume */);
                    mDisplayContent, false /* deferResume */);
        } finally {
            if (mTransitionController.isShellTransitionsEnabled()) {
                mAtmService.continueWindowLayout();
Loading