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

Commit 64a5af0d authored by Ikram Gabiyev's avatar Ikram Gabiyev Committed by Android (Google) Code Review
Browse files

Merge "Let Launcher call finish if cancel with snapshots" into main

parents eac151f3 97c9ecf5
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import static com.android.wm.shell.recents.RecentsTransitionStateListener.TRANSI
import static com.android.wm.shell.shared.ShellSharedConstants.KEY_EXTRA_SHELL_CAN_HAND_OFF_ANIMATION;
import static com.android.wm.shell.shared.split.SplitBounds.KEY_EXTRA_SPLIT_BOUNDS;
import static com.android.wm.shell.transition.Transitions.TRANSIT_END_RECENTS_TRANSITION;
import static com.android.wm.shell.transition.Transitions.TRANSIT_PIP_BOUNDS_CHANGE;
import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_START_RECENTS_TRANSITION;

@@ -111,6 +112,8 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
    // A placeholder for a synthetic transition that isn't backed by a true system transition
    public static final IBinder SYNTHETIC_TRANSITION = new Binder();

    private static final int CANCEL_WITH_SNAPSHOTS_FINISH_TIMEOUT_MS = 200;

    private final Transitions mTransitions;
    private final ShellTaskOrganizer mShellTaskOrganizer;
    private final ShellExecutor mExecutor;
@@ -548,12 +551,30 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
                }
            }
            if (mFinishCB != null) {
                if (withScreenshots) {
                    // Launcher is supposed to apply screenshots, wait for the Recents to draw them,
                    // and Binder call finish into the recents controller on its own.
                    ProtoLog.d(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                            "[%d] RecentsController.cancel: waiting for Launcher to finish",
                            mInstanceId);
                    setupFinishOnTimeout(mTransition);
                } else {
                    finishInner(toHome, false /* userLeave */, null /* finishCb */, "cancel");
                }
            } else {
                cleanUp();
            }
        }

        private void setupFinishOnTimeout(IBinder transitionToken) {
            mExecutor.executeDelayed(() -> {
                if (mTransition == transitionToken && mFinishCB != null) {
                    finishInner(true /* toHome */, false /* userLeave */, null /* finishCb */,
                            "cancel-timeout");
                }
            }, CANCEL_WITH_SNAPSHOTS_FINISH_TIMEOUT_MS);
        }

        /**
         * Sends a cancel message to the recents animation with snapshots. Used to trigger a
         * "replace-with-screenshot" like behavior.
@@ -1075,10 +1096,11 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler,
                return;
            }

            if (info.getType() == TRANSIT_REMOVE_PIP) {
            if (info.getType() == TRANSIT_REMOVE_PIP
                    || info.getType() == TRANSIT_PIP_BOUNDS_CHANGE) {
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                        "[%d] RecentsController.merge: transit_remove_pip", mInstanceId);
                // Cancel the merge if transition is removing PiP; PiP is on top of everything else.
                // Cancel the merge if transition is resizing/removing PiP; PiP is always on top.
                cancel(true /* toHome */, mWillFinishToHome /* withScreenshots */,
                        "transit_remove_pip");
                return;