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

Commit 0eab1427 authored by Evan Rosky's avatar Evan Rosky
Browse files

Make TransitionController's helper handle start and queue

The logic for whether we need to queue a transition or not will be
more complicated once transitions can run in parallel, so move
the decision logic to TransitionController so that it doesn't
need to be repeated everywhere.

Bug: 264536014
Test: Just moving code, so existing test should pass
Change-Id: I89f69054393f4d0f45500869b25e801781d67c76
parent a177e5f1
Loading
Loading
Loading
Loading
+6 −36
Original line number Diff line number Diff line
@@ -175,12 +175,6 @@
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1941440781": {
      "message": "Creating Pending Move-to-back: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/Task.java"
    },
    "-1939861963": {
      "message": "Create root task displayId=%d winMode=%d",
      "level": "VERBOSE",
@@ -631,12 +625,6 @@
      "group": "WM_DEBUG_CONFIGURATION",
      "at": "com\/android\/server\/wm\/ActivityStarter.java"
    },
    "-1484988952": {
      "message": "Creating Pending Multiwindow Fullscreen Request: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityClientController.java"
    },
    "-1483435730": {
      "message": "InsetsSource setWin %s for type %s",
      "level": "DEBUG",
@@ -2605,12 +2593,6 @@
      "group": "WM_DEBUG_ANIM",
      "at": "com\/android\/server\/wm\/WindowState.java"
    },
    "286170861": {
      "message": "Creating Pending Transition for TaskFragment: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/WindowOrganizerController.java"
    },
    "288485303": {
      "message": "Attempted to set remove mode to a display that does not exist: %d",
      "level": "WARN",
@@ -3193,12 +3175,6 @@
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/AppTransitionController.java"
    },
    "800698875": {
      "message": "SyncGroup %d: Started when there is other active SyncGroup",
      "level": "WARN",
      "group": "WM_DEBUG_SYNC_ENGINE",
      "at": "com\/android\/server\/wm\/BLASTSyncEngine.java"
    },
    "801521566": {
      "message": "Content Recording: Attempting to mirror %d from %d but no DisplayContent associated. Changing to mirror default display.",
      "level": "WARN",
@@ -3259,12 +3235,6 @@
      "group": "WM_DEBUG_STATES",
      "at": "com\/android\/server\/wm\/RootWindowContainer.java"
    },
    "898260097": {
      "message": "Creating Pending Pip-Enter: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java"
    },
    "898863925": {
      "message": "Attempted to add QS dialog window with unknown token %s.  Aborting.",
      "level": "WARN",
@@ -4009,12 +3979,6 @@
      "group": "WM_DEBUG_CONTENT_RECORDING",
      "at": "com\/android\/server\/wm\/ContentRecorder.java"
    },
    "1667162379": {
      "message": "Creating Pending Transition: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS",
      "at": "com\/android\/server\/wm\/WindowOrganizerController.java"
    },
    "1670933628": {
      "message": " Setting allReady override",
      "level": "VERBOSE",
@@ -4075,6 +4039,12 @@
      "group": "WM_DEBUG_SYNC_ENGINE",
      "at": "com\/android\/server\/wm\/BLASTSyncEngine.java"
    },
    "1735199721": {
      "message": "Queueing transition: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_WINDOW_TRANSITIONS_MIN",
      "at": "com\/android\/server\/wm\/TransitionController.java"
    },
    "1739298851": {
      "message": "removeWindowToken: Attempted to remove token: %s for non-exiting displayId=%d",
      "level": "WARN",
+5 −13
Original line number Diff line number Diff line
@@ -97,7 +97,6 @@ import android.window.TransitionInfo;

import com.android.internal.app.AssistUtils;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.protolog.ProtoLogGroup;
import com.android.internal.protolog.common.ProtoLog;
import com.android.server.LocalServices;
import com.android.server.Watchdog;
@@ -1142,18 +1141,11 @@ class ActivityClientController extends IActivityClientController.Stub {
        // Initiate the transition.
        final Transition transition = new Transition(TRANSIT_CHANGE, 0 /* flags */, controller,
                mService.mWindowManager.mSyncEngine);
        if (mService.mWindowManager.mSyncEngine.hasActiveSync()) {
            ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                    "Creating Pending Multiwindow Fullscreen Request: %s", transition);
            r.mTransitionController.queueCollecting(transition,
                    () -> {
        r.mTransitionController.startCollectOrQueue(transition,
                (deferred) -> {
                    executeFullscreenRequestTransition(fullscreenRequest, callback, r,
                                transition, true /* queued */);
                            transition, deferred);
                });
        } else {
            executeFullscreenRequestTransition(fullscreenRequest, callback, r, transition,
                    false /* queued */);
        }
    }

    private void executeFullscreenRequestTransition(int fullscreenRequest, IRemoteCallback callback,
+2 −8
Original line number Diff line number Diff line
@@ -9806,7 +9806,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mTransitionController.isShellTransitionsEnabled()) {
            final Transition transition = new Transition(TRANSIT_RELAUNCH, 0 /* flags */,
                    mTransitionController, mWmService.mSyncEngine);
            final Runnable executeRestart = () -> {
            mTransitionController.startCollectOrQueue(transition, (deferred) -> {
                if (mState != RESTARTING_PROCESS || !attachedToProcess()) {
                    transition.abort();
                    return;
@@ -9818,13 +9818,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mTransitionController.requestStartTransition(transition, task,
                        null /* remoteTransition */, null /* displayChange */);
                scheduleStopForRestartProcess();
            };
            if (mWmService.mSyncEngine.hasActiveSync()) {
                mTransitionController.queueCollecting(transition, executeRestart);
            } else {
                mTransitionController.moveToCollecting(transition);
                executeRestart.run();
            }
            });
        } else {
            startFreezingScreen();
            scheduleStopForRestartProcess();
+25 −40
Original line number Diff line number Diff line
@@ -250,7 +250,6 @@ import com.android.internal.notification.SystemNotificationChannels;
import com.android.internal.os.TransferPipe;
import com.android.internal.policy.AttributeCache;
import com.android.internal.policy.KeyguardDismissCallback;
import com.android.internal.protolog.ProtoLogGroup;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.FastPrintWriter;
@@ -2873,10 +2872,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

                final Transition transition = new Transition(TRANSIT_CHANGE, 0 /* flags */,
                        getTransitionController(), mWindowManager.mSyncEngine);
                if (mWindowManager.mSyncEngine.hasActiveSync()) {
                    getTransitionController().queueCollecting(transition,
                            () -> {
                                if (!task.getWindowConfiguration().canResizeTask()) {
                getTransitionController().startCollectOrQueue(transition,
                        (deferred) -> {
                            if (deferred && !task.getWindowConfiguration().canResizeTask()) {
                                Slog.w(TAG, "resizeTask not allowed on task=" + task);
                                transition.abort();
                                return;
@@ -2887,14 +2885,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                            task.resize(bounds, resizeMode, preserveWindow);
                            transition.setReady(task, true);
                        });
                } else {
                    getTransitionController().moveToCollecting(transition);
                    getTransitionController().requestStartTransition(transition, task,
                            null /* remoteTransition */, null /* displayChange */);
                    getTransitionController().collect(task);
                    task.resize(bounds, resizeMode, preserveWindow);
                    transition.setReady(task, true);
                }
            }
        } finally {
            Binder.restoreCallingIdentity(ident);
@@ -3625,30 +3615,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            mActivityClientController.dismissKeyguard(r.token, new KeyguardDismissCallback() {
                @Override
                public void onDismissSucceeded() {
                    if (transition != null && mWindowManager.mSyncEngine.hasActiveSync()) {
                        ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                                "Creating Pending Pip-Enter: %s", transition);
                        getTransitionController().queueCollecting(transition, enterPipRunnable);
                    } else {
                        // Move to collecting immediately to "claim" the sync-engine for this
                        // transition.
                        if (transition != null) {
                            getTransitionController().moveToCollecting(transition);
                    if (transition == null) {
                        mH.post(enterPipRunnable);
                        return;
                    }
                    getTransitionController().startCollectOrQueue(transition, (deferred) -> {
                        if (deferred) {
                            enterPipRunnable.run();
                        } else {
                            mH.post(enterPipRunnable);
                        }
                    });
                }
            }, null /* message */);
        } else {
            // Enter picture in picture immediately otherwise
            if (transition != null && mWindowManager.mSyncEngine.hasActiveSync()) {
                ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                        "Creating Pending Pip-Enter: %s", transition);
                getTransitionController().queueCollecting(transition, enterPipRunnable);
            } else {
            if (transition != null) {
                    getTransitionController().moveToCollecting(transition);
                }
                getTransitionController().startCollectOrQueue(transition,
                        (deferred) -> enterPipRunnable.run());
            } else {
                enterPipRunnable.run();
            }
        }
+11 −5
Original line number Diff line number Diff line
@@ -2328,17 +2328,23 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                // this as a signal to the transition-player.
                final Transition transition = new Transition(TRANSIT_SLEEP, 0 /* flags */,
                        display.mTransitionController, mWmService.mSyncEngine);
                final Runnable sendSleepTransition = () -> {
                final TransitionController.OnStartCollect sendSleepTransition = (deferred) -> {
                    display.mTransitionController.requestStartTransition(transition,
                            null /* trigger */, null /* remote */, null /* display */);
                    // Force playing immediately so that unrelated ops can't be collected.
                    transition.playNow();
                };
                if (display.mTransitionController.isCollecting()) {
                    display.mTransitionController.queueCollecting(transition, sendSleepTransition);
                } else {
                if (!display.mTransitionController.isCollecting()) {
                    // Since this bypasses sync, submit directly ignoring whether sync-engine
                    // is active.
                    if (mWindowManager.mSyncEngine.hasActiveSync()) {
                        Slog.w(TAG, "Ongoing sync outside of a transition.");
                    }
                    display.mTransitionController.moveToCollecting(transition);
                    sendSleepTransition.run();
                    sendSleepTransition.onCollectStarted(false /* deferred */);
                } else {
                    display.mTransitionController.startCollectOrQueue(transition,
                            sendSleepTransition);
                }
            }

Loading