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

Commit fb9a2c7d authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Apply bounds change on task view change transition

Task view transitions get queued up behind other shell transitions.
After an unfold transition happens, if a task view change transition
is pending, we now include the bounds on the window container transaction.

This largely mitigates the issue around stale task view bounds after
unfolding while the IME is visible. Also worth noting that because the
task view transition gets queued behind the unfold transition, there's
a noticeable delay before the new bounds are applied. To solve this
we should merge the transitions together.

Flag: EXEMPT bug fix
Fix: 390050545
Test: manual
       - have a floating bubble
       - expand and show IME
       - unfold
       - observe bubble has the correct bounds
Change-Id: Ie674f4418a0f579c2ba3d8e0ad553fd3abc4ded4
parent a5c29f6c
Loading
Loading
Loading
Loading
+42 −27
Original line number Diff line number Diff line
@@ -652,9 +652,16 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
                    }
                    continue;
                }
                final Rect boundsOnScreen = tv.prepareOpen(chg.getTaskInfo(), chg.getLeash());
                if (boundsOnScreen != null) {
                    if (wct == null) wct = new WindowContainerTransaction();
                    updateBounds(tv, boundsOnScreen, startTransaction, finishTransaction,
                            chg.getTaskInfo(), chg.getLeash(), wct);
                } else {
                    startTransaction.reparent(chg.getLeash(), tv.getSurfaceControl());
                    finishTransaction.reparent(chg.getLeash(), tv.getSurfaceControl())
                            .setPosition(chg.getLeash(), 0, 0);
                }
                changesHandled++;
            }
        }
@@ -683,6 +690,36 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
            WindowContainerTransaction wct) {
        final Rect boundsOnScreen = taskView.prepareOpen(taskInfo, leash);
        if (boundsOnScreen != null) {
            updateBounds(taskView, boundsOnScreen, startTransaction, finishTransaction, taskInfo,
                    leash, wct);
        } else {
            // The surface has already been destroyed before the task has appeared,
            // so go ahead and hide the task entirely
            wct.setHidden(taskInfo.token, true /* hidden */);
            updateVisibilityState(taskView, false /* visible */);
            // listener callback is below
        }
        if (newTask) {
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(taskInfo.token, true /* intercept */);
        }

        if (taskInfo.taskDescription != null) {
            int backgroundColor = taskInfo.taskDescription.getBackgroundColor();
            taskView.setResizeBgColor(startTransaction, backgroundColor);
        }

        // After the embedded task has appeared, set it to non-trimmable. This is important
        // to prevent recents from trimming and removing the embedded task.
        wct.setTaskTrimmableFromRecents(taskInfo.token, false /* isTrimmableFromRecents */);

        taskView.notifyAppeared(newTask);
    }

    private void updateBounds(TaskViewTaskController taskView, Rect boundsOnScreen,
            SurfaceControl.Transaction startTransaction,
            SurfaceControl.Transaction finishTransaction,
            ActivityManager.RunningTaskInfo taskInfo, SurfaceControl leash,
            WindowContainerTransaction wct) {
        final SurfaceControl tvSurface = taskView.getSurfaceControl();
        // Surface is ready, so just reparent the task to this surface control
        startTransaction.reparent(leash, tvSurface)
@@ -692,7 +729,6 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
        if (finishTransaction != null) {
            finishTransaction.reparent(leash, tvSurface)
                    .setPosition(leash, 0, 0)
                        // TODO: maybe once b/280900002 is fixed this will be unnecessary
                    .setWindowCrop(leash, boundsOnScreen.width(), boundsOnScreen.height());
        }
        if (useRepo()) {
@@ -707,27 +743,6 @@ public class TaskViewTransitions implements Transitions.TransitionHandler, TaskV
        }
        wct.setBounds(taskInfo.token, boundsOnScreen);
        taskView.applyCaptionInsetsIfNeeded();
        } else {
            // The surface has already been destroyed before the task has appeared,
            // so go ahead and hide the task entirely
            wct.setHidden(taskInfo.token, true /* hidden */);
            updateVisibilityState(taskView, false /* visible */);
            // listener callback is below
        }
        if (newTask) {
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(taskInfo.token, true /* intercept */);
        }

        if (taskInfo.taskDescription != null) {
            int backgroundColor = taskInfo.taskDescription.getBackgroundColor();
            taskView.setResizeBgColor(startTransaction, backgroundColor);
        }

        // After the embedded task has appeared, set it to non-trimmable. This is important
        // to prevent recents from trimming and removing the embedded task.
        wct.setTaskTrimmableFromRecents(taskInfo.token, false /* isTrimmableFromRecents */);

        taskView.notifyAppeared(newTask);
    }

    /** Interface for running an external transition in this object's pending queue. */