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

Commit 81ef0f28 authored by Winson Chung's avatar Winson Chung
Browse files

Track closing tasks so we don't inadvertently hide the leash

- When quickswitching quickly between the same apps, we end up with
  a scenario where we are closing the pausing app (that we are
  initially swiping up from),and also reopening it (from quickswitching
  back to that task).  Currently, the task is untracked (it gets
  removed when a pausing task is closed, yet is still visible on
  screen) and when we receive a new open transition for it, we assume
  the opening is from a hidden state.

  This change just keeps track of these visible-but-closing tasks
  to ensure that we don't inadvertently hide the leash before notifying
  launcher of the new task.

Bug: 296242449
Test: Quickswitch quickly between tasks such that we relaunch a pausing/
      closed task

Change-Id: Iaf8ec9119b9429b264d8a38f8722059c36273a7a
parent 1b2195f6
Loading
Loading
Loading
Loading
+24 −5
Original line number Diff line number Diff line
@@ -218,6 +218,13 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
         */
        private ArrayList<TaskState> mPausingTasks = null;

        /**
         * List of tasks were pausing but closed in a subsequent merged transition. If a
         * closing task is reopened, the leash is not initially hidden since it is already
         * visible.
         */
        private ArrayList<TaskState> mClosingTasks = null;

        /**
         * List of tasks that we are switching to. Upon finish, these will remain visible and
         * on top.
@@ -369,6 +376,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
            }
            mFinishTransaction = null;
            mPausingTasks = null;
            mClosingTasks = null;
            mOpeningTasks = null;
            mInfo = null;
            mTransition = null;
@@ -413,6 +421,7 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
            mFinishCB = finishCB;
            mFinishTransaction = finishT;
            mPausingTasks = new ArrayList<>();
            mClosingTasks = new ArrayList<>();
            mOpeningTasks = new ArrayList<>();
            mLeashMap = new ArrayMap<>();
            mKeyguardLocked = (info.getFlags() & TRANSIT_FLAG_KEYGUARD_LOCKED) != 0;
@@ -659,7 +668,10 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                    final TransitionInfo.Change change = closingTasks.get(i);
                    final int pausingIdx = TaskState.indexOf(mPausingTasks, change);
                    if (pausingIdx >= 0) {
                        mPausingTasks.remove(pausingIdx);
                        // We are closing the pausing task, but it is still visible and can be
                        // restart by another transition prior to this transition finishing
                        final TaskState closingTask = mPausingTasks.remove(pausingIdx);
                        mClosingTasks.add(closingTask);
                        didMergeThings = true;
                        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                                "  closing pausing taskId=%d", change.getTaskInfo().taskId);
@@ -695,7 +707,12 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                for (int i = 0; i < openingTasks.size(); ++i) {
                    final TransitionInfo.Change change = openingTasks.get(i);
                    final boolean isLeaf = openingTaskIsLeafs.get(i) == 1;
                    int pausingIdx = TaskState.indexOf(mPausingTasks, change);
                    final int closingIdx = TaskState.indexOf(mClosingTasks, change);
                    if (closingIdx >= 0) {
                        // Remove opening tasks from closing set
                        mClosingTasks.remove(closingIdx);
                    }
                    final int pausingIdx = TaskState.indexOf(mPausingTasks, change);
                    if (pausingIdx >= 0) {
                        // Something is showing/opening a previously-pausing app.
                        if (isLeaf) {
@@ -718,12 +735,14 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
                        appearedTargets[nextTargetIdx++] = target;
                        // reparent into the original `mInfo` since that's where we are animating.
                        final int rootIdx = TransitionUtil.rootIndexFor(change, mInfo);
                        final boolean wasClosing = closingIdx >= 0;
                        t.reparent(target.leash, mInfo.getRoot(rootIdx).getLeash());
                        t.setLayer(target.leash, layer);
                        // Hide the animation leash, let listener show it.
                        t.hide(target.leash);
                        // Hide the animation leash if not already visible, let listener show it
                        t.setVisibility(target.leash, !wasClosing);
                        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,
                                "  opening new leaf taskId=%d", target.taskId);
                                "  opening new leaf taskId=%d wasClosing=%b",
                                target.taskId, wasClosing);
                        mOpeningTasks.add(new TaskState(change, target.leash));
                    } else {
                        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_RECENTS_TRANSITION,