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

Commit ca3ac3f7 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Support shell transition for restarting process of activity" into...

Merge "Support shell transition for restarting process of activity" into udc-dev am: 882f5220 am: 0687aefc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22101152



Change-Id: Ie2ce604ff3a56fe1a366b286f3852c0350eceef9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9a674cf3 0687aefc
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ import static android.view.WindowManager.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENAB
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_OPEN_BEHIND;
import static android.view.WindowManager.TRANSIT_OLD_UNSET;
import static android.view.WindowManager.TRANSIT_RELAUNCH;
import static android.window.TransitionInfo.FLAG_IS_OCCLUDED;
import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPIENT;

@@ -5205,7 +5206,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            Slog.w(TAG_WM, "Attempted to set visibility of non-existing app token: " + token);
            return;
        }
        if (visible == mVisibleRequested && visible == mVisible
        if (visible == mVisibleRequested && visible == mVisible && visible == isClientVisible()
                && mTransitionController.isShellTransitionsEnabled()) {
            // For shell transition, it is no-op if there is no state change.
            return;
@@ -9701,9 +9702,36 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }

        if (getParent() != null) {
        if (mTransitionController.isShellTransitionsEnabled()) {
            final Transition transition = new Transition(TRANSIT_RELAUNCH, 0 /* flags */,
                    mTransitionController, mWmService.mSyncEngine);
            final Runnable executeRestart = () -> {
                if (mState != RESTARTING_PROCESS || !attachedToProcess()) {
                    transition.abort();
                    return;
                }
                // Request invisible so there will be a change after the activity is restarted
                // to be visible.
                setVisibleRequested(false);
                transition.collect(this);
                mTransitionController.requestStartTransition(transition, task,
                        null /* remoteTransition */, null /* displayChange */);
                scheduleStopForRestartProcess();
            };
            if (mWmService.mSyncEngine.hasActiveSync()) {
                mWmService.mSyncEngine.queueSyncSet(
                        () -> mTransitionController.moveToCollecting(transition), executeRestart);
            } else {
                mTransitionController.moveToCollecting(transition);
                executeRestart.run();
            }
        } else {
            startFreezingScreen();
            scheduleStopForRestartProcess();
        }
    }

    private void scheduleStopForRestartProcess() {
        // The process will be killed until the activity reports stopped with saved state (see
        // {@link ActivityTaskManagerService.activityStopped}).
        try {