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

Commit c09120ae authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

[PB] While merge second transition, ignore the change mode target

...if it is closing in second transition.
For unify back transition, system will always enforce the top task or
activity in predictive_back transition as change mode, so when receive
second transition in shell, remove the original change target if the
target becomes close mode.

Flag: com.android.window.flags.unify_back_navigation_transition
Bug: 386916081
Test: trigger predictive_back + close transition by click on the edge
of device, verify predictive back transition handler can organize
normal transition info to default transition handler.

Change-Id: Ic5c3b691ccee899245c2c9d8ab3db13dc5bb7adb
parent 43b05634
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -1469,8 +1469,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                        }
                        moveToTop = change.hasFlags(FLAG_MOVED_TO_TOP);
                        info.getChanges().remove(j);
                    } else if ((openShowWallpaper && change.hasFlags(FLAG_IS_WALLPAPER))
                            || !change.hasFlags(FLAG_BACK_GESTURE_ANIMATED)) {
                    } else if ((openShowWallpaper && change.hasFlags(FLAG_IS_WALLPAPER))) {
                        info.getChanges().remove(j);
                    } else if (!mergePredictive && TransitionUtil.isClosingMode(change.getMode())) {
                        mergePredictive = true;
@@ -1493,6 +1492,13 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                            if (moveToTop) {
                                change.setFlags(change.getFlags() | FLAG_MOVED_TO_TOP);
                            }
                        } else if (Flags.unifyBackNavigationTransition()
                                && change.hasFlags(FLAG_BACK_GESTURE_ANIMATED)
                                && change.getMode() == TRANSIT_CHANGE
                                && isCloseChangeExist(info, change)) {
                            // This is the original top target, don't add it into current transition
                            // if it is closing.
                            continue;
                        }
                        info.getChanges().add(i, change);
                    }
@@ -1824,6 +1830,17 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        return findComponentName(change) != null || findTaskId(change) != INVALID_TASK_ID;
    }

    private static boolean isCloseChangeExist(TransitionInfo info, TransitionInfo.Change change) {
        for (int j = info.getChanges().size() - 1; j >= 0; --j) {
            final TransitionInfo.Change current = info.getChanges().get(j);
            if (TransitionUtil.isClosingMode(current.getMode())
                    && change.getLeash().isSameSurface(current.getLeash())) {
                return true;
            }
        }
        return false;
    }

    // Record the latest back gesture happen on which task.
    static class BackTransitionObserver implements Transitions.TransitionObserver {
        int mFocusedTaskId = INVALID_TASK_ID;