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

Commit 67ca933c authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove deferred relaunch

It was changed from defer-destroy to defer-relaunch in commit f81c1d16.
However, it is fine to relaunch directly without waiting for being
paused. Because the client should still handle the lifecycle
sequentially and other non-pausing states also relaunch directly.

Bug: 163976519
Test: CtsWindowManagerDeviceActivity
Test: Declare a PiP activity without handling config change.
      Enter PiP from landscape to portrait.
Change-Id: Ief6fcbb853ab734c4955edc4ed065c659289a2bb
parent a9d2c1f1
Loading
Loading
Loading
Loading
+8 −37
Original line number Diff line number Diff line
@@ -545,9 +545,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    boolean launchFailed;   // set if a launched failed, to abort on 2nd try
    boolean delayedResume;  // not yet resumed because of stopped app switches?
    boolean finishing;      // activity in pending finish list?
    boolean deferRelaunchUntilPaused;   // relaunch of activity is being deferred until pause is
                                        // completed
    boolean preserveWindowOnDeferredRelaunch; // activity windows are preserved on deferred relaunch
    int configChangeFlags;  // which config values have changed
    private boolean keysPaused;     // has key dispatching been paused for it?
    int launchMode;         // the launch mode activity attribute.
@@ -1277,10 +1274,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mDeferHidingClient) {
            pw.println(prefix + "mDeferHidingClient=" + mDeferHidingClient);
        }
        if (deferRelaunchUntilPaused || configChangeFlags != 0) {
            pw.print(prefix); pw.print("deferRelaunchUntilPaused=");
                    pw.print(deferRelaunchUntilPaused);
                    pw.print(" configChangeFlags=");
        if (configChangeFlags != 0) {
            pw.print(prefix); pw.print(" configChangeFlags=");
                    pw.println(Integer.toHexString(configChangeFlags));
        }
        if (mServiceConnectionsHolder != null) {
@@ -2137,7 +2132,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        launchFailed = false;
        delayedResume = false;
        finishing = false;
        deferRelaunchUntilPaused = false;
        keysPaused = false;
        inHistory = false;
        nowVisible = false;
@@ -4096,8 +4090,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Clean up the splash screen if it was still displayed.
        cleanUpSplashScreen();

        deferRelaunchUntilPaused = false;

        if (setState) {
            setState(DESTROYED, "cleanUp");
            if (DEBUG_APP) Slog.v(TAG_APP, "Clearing app during cleanUp for activity " + this);
@@ -6481,9 +6473,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            mAppStopped = true;
            ProtoLog.v(WM_DEBUG_STATES, "Stop failed; moving to STOPPED: %s", this);
            setState(STOPPED, "stopIfPossible");
            if (deferRelaunchUntilPaused) {
                destroyImmediately("stop-except");
            }
        }
    }

@@ -6538,14 +6527,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        if (finishing) {
            abortAndClearOptionsAnimation();
        } else {
            if (deferRelaunchUntilPaused) {
                destroyImmediately("stop-config");
                mRootWindowContainer.resumeFocusedTasksTopActivities();
        } else {
            mAtmService.updatePreviousProcess(this);
        }
        }
        mTaskSupervisor.checkReadyForSleepLocked(true /* allowDelay */);
    }

@@ -9724,23 +9708,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            } else {
                mRelaunchReason = RELAUNCH_REASON_NONE;
            }
            if (mState == PAUSING) {
                // A little annoying: we are waiting for this activity to finish pausing. Let's not
                // do anything now, but just flag that it needs to be restarted when done pausing.
                ProtoLog.v(WM_DEBUG_CONFIGURATION,
                        "Config is skipping already pausing %s", this);
                deferRelaunchUntilPaused = true;
                preserveWindowOnDeferredRelaunch = preserveWindow;
                return true;
            } else {
                ProtoLog.v(WM_DEBUG_CONFIGURATION, "Config is relaunching %s",
                        this);
            ProtoLog.v(WM_DEBUG_CONFIGURATION, "Config is relaunching %s", this);
            if (!mVisibleRequested) {
                ProtoLog.v(WM_DEBUG_STATES, "Config is relaunching invisible "
                        + "activity %s called by %s", this, Debug.getCallers(4));
            }
            relaunchActivityLocked(preserveWindow);
            }

            // All done...  tell the caller we weren't able to keep this activity around.
            return false;
@@ -9958,8 +9931,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mTaskSupervisor.mStoppingActivities.remove(this);

        configChangeFlags = 0;
        deferRelaunchUntilPaused = false;
        preserveWindowOnDeferredRelaunch = false;
    }

    /**
+1 −5
Original line number Diff line number Diff line
@@ -1915,11 +1915,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
                ProtoLog.v(WM_DEBUG_STATES, "Enqueue pending stop if needed: %s "
                                + "wasStopping=%b visibleRequested=%b",  prev,  wasStopping,
                        prev.isVisibleRequested());
                if (prev.deferRelaunchUntilPaused) {
                    // Complete the deferred relaunch that was waiting for pause to complete.
                    ProtoLog.v(WM_DEBUG_STATES, "Re-launching after pause: %s", prev);
                    prev.relaunchActivityLocked(prev.preserveWindowOnDeferredRelaunch);
                } else if (wasStopping) {
                if (wasStopping) {
                    // We are also stopping, the stop request must have gone soon after the pause.
                    // We can't clobber it, because the stop confirmation will not be handled.
                    // We don't need to schedule another stop, we only need to let it happen.