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

Commit 883b4082 authored by Jorge Gil's avatar Jorge Gil
Browse files

Prevent task from exiting immersive twice on close

When a task is closing, the full immersive handler restores its bounds
and appends the transition to its list of tracked transitions. It also
add a change to prevent direct enter/exit while a pending transition is
in progress, to prevent the case where a onTaskInfoChanged changing the
immersive state of the app re-triggers an enter/exit while another
enter/exit is already in progress.
Finally, it adjusts the close animation to always animate from the start
bounds, since the taskInfo/end bounds can now be different even on close
transitions.

Flag: com.android.window.flags.enable_fully_immersive_in_desktop
Bug: 373987723
Test: enter desktop immersive, close the task using the header icon,
verify no crash and it animates correctly

Change-Id: I068b925ca45bd68d98434e1105bf0a3716247202
parent b470f9a6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class DesktopFullImmersiveTransitionHandler(

    /** Whether there is an immersive transition that hasn't completed yet. */
    private val inProgress: Boolean
        get() = state != null
        get() = state != null || pendingExternalExitTransitions.isNotEmpty()

    private val rectEvaluator = RectEvaluator()

+2 −2
Original line number Diff line number Diff line
@@ -58,9 +58,9 @@ class DesktopMixedTransitionHandler(
        freeformTaskTransitionHandler.startMinimizedModeTransition(wct)

    /** Starts close transition and handles or delegates desktop task close animation. */
    override fun startRemoveTransition(wct: WindowContainerTransaction?) {
    override fun startRemoveTransition(wct: WindowContainerTransaction?): IBinder {
        requireNotNull(wct)
        transitions.startTransition(WindowManager.TRANSIT_CLOSE, wct, /* handler= */ this)
        return transitions.startTransition(WindowManager.TRANSIT_CLOSE, wct, /* handler= */ this)
    }

    /** Returns null, as it only handles transitions started from Shell. */
+7 −1
Original line number Diff line number Diff line
@@ -461,7 +461,12 @@ class DesktopTasksController(
     * @param displayId display id of the window that's being closed
     * @param taskId task id of the window that's being closed
     */
    fun onDesktopWindowClose(wct: WindowContainerTransaction, displayId: Int, taskId: Int) {
    fun onDesktopWindowClose(
        wct: WindowContainerTransaction,
        displayId: Int,
        taskInfo: RunningTaskInfo,
    ): ((IBinder) -> Unit)? {
        val taskId = taskInfo.taskId
        if (taskRepository.isOnlyVisibleNonClosingTask(taskId)) {
            removeWallpaperActivity(wct)
        }
@@ -472,6 +477,7 @@ class DesktopTasksController(
                taskId
            )
        )
        return immersiveTransitionHandler.exitImmersiveIfApplicable(wct, taskInfo)
    }

    fun minimizeTask(taskInfo: RunningTaskInfo) {
+5 −4
Original line number Diff line number Diff line
@@ -99,9 +99,11 @@ public class FreeformTaskTransitionHandler


    @Override
    public void startRemoveTransition(WindowContainerTransaction wct) {
    public IBinder startRemoveTransition(WindowContainerTransaction wct) {
        final int type = WindowManager.TRANSIT_CLOSE;
        mPendingTransitionTokens.add(mTransitions.startTransition(type, wct, this));
        final IBinder transition = mTransitions.startTransition(type, wct, this);
        mPendingTransitionTokens.add(transition);
        return transition;
    }

    @Override
@@ -229,8 +231,7 @@ public class FreeformTaskTransitionHandler
        SurfaceControl.Transaction t = new SurfaceControl.Transaction();
        SurfaceControl sc = change.getLeash();
        finishT.hide(sc);
        Rect startBounds = new Rect(change.getTaskInfo().configuration.windowConfiguration
                .getBounds());
        final Rect startBounds = new Rect(change.getStartAbsBounds());
        animator.addUpdateListener(animation -> {
            t.setPosition(sc, startBounds.left,
                    startBounds.top + (animation.getAnimatedFraction() * screenHeight));
+2 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public interface FreeformTaskTransitionStarter {
     *
     * @param wct the {@link WindowContainerTransaction} that closes the task
     *
     * @return the started transition
     */
    void startRemoveTransition(WindowContainerTransaction wct);
    IBinder startRemoveTransition(WindowContainerTransaction wct);
}
 No newline at end of file
Loading