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

Commit 5da73506 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add TransitionController to member of WindowContainer

It is used in many places. Add a field to make code cleaner.
No logic change.

Bug: 163976519
Test: CtsActivityManagerDeviceTestCases
Change-Id: Iaf861dfbf5def58f79004c2834d1a22f7ffbcaa7
parent ae8b4690
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1072,7 +1072,7 @@ class ActivityClientController extends IActivityClientController.Stub {
                r.mDisplayContent.mAppTransition.overridePendingAppTransition(
                        packageName, enterAnim, exitAnim, null, null,
                        r.mOverrideTaskTransition);
                mService.getTransitionController().setOverrideAnimation(
                r.mTransitionController.setOverrideAnimation(
                        TransitionInfo.AnimationOptions.makeCustomAnimOptions(packageName,
                                enterAnim, exitAnim, r.mOverrideTaskTransition),
                        null /* startCallback */, null /* finishCallback */);
+19 −21
Original line number Diff line number Diff line
@@ -1532,7 +1532,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }

        // TODO(b/169035022): move to a more-appropriate place.
        mAtmService.getTransitionController().collect(this);
        mTransitionController.collect(this);
        if (prevDc.mOpeningApps.remove(this)) {
            // Transfer opening transition to new display.
            mDisplayContent.mOpeningApps.add(this);
@@ -3090,9 +3090,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

        mAtmService.deferWindowLayout();
        try {
            final Transition newTransition = (!mAtmService.getTransitionController().isCollecting()
                    && mAtmService.getTransitionController().getTransitionPlayer() != null)
                    ? mAtmService.getTransitionController().createTransition(TRANSIT_CLOSE) : null;
            final Transition newTransition = (!mTransitionController.isCollecting()
                    && mTransitionController.getTransitionPlayer() != null)
                    ? mTransitionController.createTransition(TRANSIT_CLOSE) : null;
            mTaskSupervisor.mNoHistoryActivities.remove(this);
            makeFinishingLocked();
            // Make a local reference to its task since this.task could be set to null once this
@@ -3125,7 +3125,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            final boolean endTask = task.getTopNonFinishingActivity() == null
                    && !task.isClearingToReuseTask();
            if (newTransition != null) {
                mAtmService.getTransitionController().requestStartTransition(newTransition,
                mTransitionController.requestStartTransition(newTransition,
                        endTask ? task : null, null /* remote */);
            }
            if (isState(RESUMED)) {
@@ -3553,12 +3553,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (stopped) {
            abortAndClearOptionsAnimation();
        }
        if (mAtmService.getTransitionController().isCollecting()) {
        if (mTransitionController.isCollecting()) {
            // We don't want the finishing to change the transition ready state since there will not
            // be corresponding setReady for finishing.
            mAtmService.getTransitionController().collectExistenceChange(this);
            mTransitionController.collectExistenceChange(this);
        } else {
            mAtmService.getTransitionController().requestTransitionIfNeeded(TRANSIT_CLOSE, this);
            mTransitionController.requestTransitionIfNeeded(TRANSIT_CLOSE, this);
        }
    }

@@ -3810,7 +3810,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        } else if (getDisplayContent().mAppTransition.isTransitionSet()) {
            getDisplayContent().mClosingApps.add(this);
            delayed = true;
        } else if (mAtmService.getTransitionController().inTransition()) {
        } else if (mTransitionController.inTransition()) {
            delayed = true;
        }

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

        // TODO(b/169035022): move to a more-appropriate place.
        mAtmService.getTransitionController().collect(this);
        mTransitionController.collect(this);

        ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                "Removing app %s delayed=%b animation=%s animating=%b", this, delayed,
@@ -4023,7 +4023,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A

                ProtoLog.v(WM_DEBUG_ADD_REMOVE,
                        "Removing starting %s from %s", tStartingWindow, fromActivity);
                mAtmService.getTransitionController().collect(tStartingWindow);
                mTransitionController.collect(tStartingWindow);
                tStartingWindow.reparent(this, POSITION_TOP);

                // Propagate other interesting state between the tokens. If the old token is displayed,
@@ -4049,7 +4049,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    // the token we transfer the animation over. Thus, set this flag to indicate
                    // we've transferred the animation.
                    mUseTransferredAnimation = true;
                } else if (mAtmService.getTransitionController().getTransitionPlayer() != null) {
                } else if (mTransitionController.getTransitionPlayer() != null) {
                    // In the new transit system, just set this every time we transfer the window
                    mUseTransferredAnimation = true;
                }
@@ -4546,8 +4546,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }

        if (options != null) {
            mAtmService.getTransitionController().setOverrideAnimation(options,
                    startCallback, finishCallback);
            mTransitionController.setOverrideAnimation(options, startCallback, finishCallback);
        }
    }

@@ -4778,7 +4777,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                Debug.getCallers(6));

        // Before setting mVisibleRequested so we can track changes.
        mAtmService.getTransitionController().collect(this);
        mTransitionController.collect(this);

        onChildVisibilityRequested(visible);

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

        // If in a transition, defer commits for activities that are going invisible
        if (!visible && mAtmService.getTransitionController().inTransition(this)) {
        if (!visible && inTransition()) {
            return;
        }
        // If we are preparing an app transition, then delay changing
@@ -4977,8 +4976,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     *                this has become invisible.
     */
    private void postApplyAnimation(boolean visible) {
        final boolean usingShellTransitions =
                mAtmService.getTransitionController().getTransitionPlayer() != null;
        final boolean usingShellTransitions = mTransitionController.isShellTransitionsEnabled();
        final boolean delayed = isAnimating(TRANSITION | PARENTS | CHILDREN,
                ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_WINDOW_ANIMATION
                        | ANIMATION_TYPE_RECENTS);
@@ -5428,7 +5426,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // returns. Just need to confirm this reasoning makes sense.
            final boolean deferHidingClient = canEnterPictureInPicture
                    && !isState(STARTED, STOPPING, STOPPED, PAUSED);
            if (!mAtmService.getTransitionController().isShellTransitionsEnabled()
            if (!mTransitionController.isShellTransitionsEnabled()
                    && deferHidingClient && pictureInPictureArgs.isAutoEnterEnabled()) {
                // Go ahead and just put the activity in pip if it supports auto-pip.
                mAtmService.enterPictureInPictureMode(this, pictureInPictureArgs);
@@ -5950,7 +5948,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    void startFreezingScreen(int overrideOriginalDisplayRotation) {
        if (mAtmService.getTransitionController().isShellTransitionsEnabled()) {
        if (mTransitionController.isShellTransitionsEnabled()) {
            return;
        }
        ProtoLog.i(WM_DEBUG_ORIENTATION,
@@ -7596,7 +7594,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    boolean isInTransition() {
        return mAtmService.getTransitionController().inTransition() // Shell transitions.
        return mTransitionController.inTransition() // Shell transitions.
                || isAnimating(PARENTS | TRANSITION); // Legacy transitions.
    }

+10 −9
Original line number Diff line number Diff line
@@ -1564,14 +1564,15 @@ class ActivityStarter {
        // startActivityInner. Otherwise, logic in startActivityInner could start a different
        // transition based on a sub-action.
        // Only do the create here (and defer requestStart) since startActivityInner might abort.
        final Transition newTransition = (!mService.getTransitionController().isCollecting()
                && mService.getTransitionController().getTransitionPlayer() != null)
                ? mService.getTransitionController().createTransition(TRANSIT_OPEN) : null;
        final TransitionController transitionController = r.mTransitionController;
        final Transition newTransition = (!transitionController.isCollecting()
                && transitionController.getTransitionPlayer() != null)
                ? transitionController.createTransition(TRANSIT_OPEN) : null;
        RemoteTransition remoteTransition = r.takeRemoteTransition();
        if (newTransition != null && remoteTransition != null) {
            newTransition.setRemoteTransition(remoteTransition);
        }
        mService.getTransitionController().collect(r);
        transitionController.collect(r);
        final boolean isTransient = r.getOptions() != null && r.getOptions().getTransientLaunch();
        try {
            mService.deferWindowLayout();
@@ -1618,19 +1619,19 @@ class ActivityStarter {
                if (started) {
                    // The activity is started new rather than just brought forward, so record
                    // it as an existence change.
                    mService.getTransitionController().collectExistenceChange(r);
                    transitionController.collectExistenceChange(r);
                }
                if (isTransient) {
                    // `r` isn't guaranteed to be the actual relevant activity, so we must wait
                    // until after we launched to identify the relevant activity.
                    mService.getTransitionController().setTransientLaunch(mLastStartActivityRecord);
                    transitionController.setTransientLaunch(mLastStartActivityRecord);
                }
                if (newTransition != null) {
                    mService.getTransitionController().requestStartTransition(newTransition,
                    transitionController.requestStartTransition(newTransition,
                            mTargetTask, remoteTransition);
                } else if (started) {
                    // Make the collecting transition wait until this request is ready.
                    mService.getTransitionController().setReady(r, false);
                    transitionController.setReady(r, false);
                }
            }
        }
@@ -2769,7 +2770,7 @@ class ActivityStarter {
                mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info,
                mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession,
                mVoiceInteractor, toTop, mStartActivity, mSourceRecord, mOptions);
        mService.getTransitionController().collectExistenceChange(task);
        task.mTransitionController.collectExistenceChange(task);
        addOrReparentStartingActivity(task, "setTaskFromReuseOrCreateNewTask - mReuseTask");

        ProtoLog.v(WM_DEBUG_TASKS, "Starting new activity %s in new task %s",
+7 −7
Original line number Diff line number Diff line
@@ -1385,7 +1385,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
                mUserLeaving = true;
            }

            mService.getTransitionController().requestTransitionIfNeeded(TRANSIT_TO_FRONT,
            task.mTransitionController.requestTransitionIfNeeded(TRANSIT_TO_FRONT,
                    0 /* flags */, task, task /* readyGroupRef */,
                    options != null ? options.getRemoteTransition() : null);
            reason = reason + " findTaskToMoveToFront";
@@ -1561,17 +1561,17 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            return;
        }
        if (task.isVisible()) {
            if (mService.getTransitionController().isCollecting()) {
            if (task.mTransitionController.isCollecting()) {
                // We don't want the finishing to change the transition ready state since there will
                // not be corresponding setReady for finishing.
                mService.getTransitionController().collectExistenceChange(task);
                task.mTransitionController.collectExistenceChange(task);
            } else {
                mService.getTransitionController().requestTransitionIfNeeded(TRANSIT_CLOSE, task);
                task.mTransitionController.requestTransitionIfNeeded(TRANSIT_CLOSE, task);
            }
        } else {
            // Removing a non-visible task doesn't require a transition, but if there is one
            // collecting, this should be a member just in case.
            mService.getTransitionController().collect(task);
            task.mTransitionController.collect(task);
        }
        task.mInRemoveTask = true;
        try {
@@ -1885,7 +1885,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
            final ActivityRecord s = mStoppingActivities.get(i);
            final boolean animating = s.isAnimating(TRANSITION | PARENTS,
                    ANIMATION_TYPE_APP_TRANSITION | ANIMATION_TYPE_RECENTS)
                    || mService.getTransitionController().inTransition(s);
                    || s.inTransition();
            ProtoLog.v(WM_DEBUG_STATES, "Stopping %s: nowVisible=%b animating=%b "
                    + "finishing=%s", s, s.nowVisible, animating, s.finishing);
            if (!animating || mService.mShuttingDown) {
@@ -2186,7 +2186,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        }

        if (!task.supportsSplitScreenWindowingMode() || forceNonResizable) {
            if (mService.getTransitionController().getTransitionPlayer() != null) return;
            if (task.mTransitionController.isShellTransitionsEnabled()) return;
            // Dismiss docked root task. If task appeared to be in docked root task but is not
            // resizable - we need to move it to top of fullscreen root task, otherwise it will
            // be covered.
+1 −1
Original line number Diff line number Diff line
@@ -1547,7 +1547,7 @@ public class AppTransition implements Dump {
    }

    boolean prepareAppTransition(@TransitionType int transit, @TransitionFlags int flags) {
        if (mService.mAtmService.getTransitionController().getTransitionPlayer() != null) {
        if (mDisplayContent.mTransitionController.isShellTransitionsEnabled()) {
            return false;
        }
        mNextAppTransitionRequests.add(transit);
Loading