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

Commit c005809a authored by wilsonshih's avatar wilsonshih
Browse files

[PB] Do not cancel animation from transition.

Since we are migrate PB to shell transition, core does not need to
cancel animation while received another transition, just let the
transition happen, and let shell side to handle it.

Keep track animated target after PB animation finish by detect app
visibility change. When canceled and previous animation was start
with launch behind, start a CLOSE_PREPARE_TRANSITION to collect
changes, as the last step of cancel transition.

In BackTransitionHandler, ignore transition if the content of changes
are not expected, so DefaultTransitionHandler will handle it.

Flag: com.android.window.flags.migrate_predictive_back_transition
Bug: 340386663
Test: trigger close or open transition with a button where close to the
edge of device, so when click on the button, PB and another transition
will be triggered almost at the same time. Verify BackTransitionHandler
can skip PB by changes if possible.

Change-Id: I65ca37905a883a17d1a39dd609fd9e9c91bf8988
parent 856f2751
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -482,6 +482,11 @@ public interface WindowManager extends ViewManager {
     * @hide
     */
    int TRANSIT_PREPARE_BACK_NAVIGATION = 13;
    /**
     * An Activity was going to be invisible from back navigation.
     * @hide
     */
    int TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION = 14;

    /**
     * The first slot for custom transition types. Callers (like Shell) can make use of custom
@@ -512,6 +517,7 @@ public interface WindowManager extends ViewManager {
            TRANSIT_WAKE,
            TRANSIT_SLEEP,
            TRANSIT_PREPARE_BACK_NAVIGATION,
            TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION,
            TRANSIT_FIRST_CUSTOM
    })
    @Retention(RetentionPolicy.SOURCE)
@@ -1926,6 +1932,7 @@ public interface WindowManager extends ViewManager {
            case TRANSIT_WAKE: return "WAKE";
            case TRANSIT_SLEEP: return "SLEEP";
            case TRANSIT_PREPARE_BACK_NAVIGATION: return "PREDICTIVE_BACK";
            case TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION: return "CLOSE_PREDICTIVE_BACK";
            case TRANSIT_FIRST_CUSTOM: return "FIRST_CUSTOM";
            default:
                if (type > TRANSIT_FIRST_CUSTOM) {
+13 −0
Original line number Diff line number Diff line
@@ -699,6 +699,18 @@ public final class WindowContainerTransaction implements Parcelable {
        return this;
    }

    /**
     * Restore the back navigation target from visible to invisible for canceling gesture animation.
     * @hide
     */
    @NonNull
    public WindowContainerTransaction restoreBackNavi() {
        final HierarchyOp hierarchyOp =
                new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_RESTORE_BACK_NAVIGATION)
                        .build();
        mHierarchyOps.add(hierarchyOp);
        return this;
    }
    /**
     * Adds a given {@code Rect} as an insets source frame on the {@code receiver}.
     *
@@ -1436,6 +1448,7 @@ public final class WindowContainerTransaction implements Parcelable {
        public static final int HIERARCHY_OP_TYPE_ADD_TASK_FRAGMENT_OPERATION = 17;
        public static final int HIERARCHY_OP_TYPE_MOVE_PIP_ACTIVITY_TO_PINNED_TASK = 18;
        public static final int HIERARCHY_OP_TYPE_SET_IS_TRIMMABLE = 19;
        public static final int HIERARCHY_OP_TYPE_RESTORE_BACK_NAVIGATION = 20;

        // The following key(s) are for use with mLaunchOptions:
        // When launching a task (eg. from recents), this is the taskId to be launched.
+3 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_PREPARE_BACK_NAVIGATION;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
@@ -59,7 +60,8 @@ public class TransitionUtil {
    public static boolean isOpeningType(@WindowManager.TransitionType int type) {
        return type == TRANSIT_OPEN
                || type == TRANSIT_TO_FRONT
                || type == TRANSIT_KEYGUARD_GOING_AWAY;
                || type == TRANSIT_KEYGUARD_GOING_AWAY
                || type == TRANSIT_PREPARE_BACK_NAVIGATION;
    }

    /** @return true if the transition was triggered by closing something vs opening something */
+268 −14

File changed.

Preview size limit exceeded, changes collapsed.

+11 −0
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ package com.android.wm.shell.transition;
import static android.app.ActivityOptions.ANIM_FROM_STYLE;
import static android.app.ActivityOptions.ANIM_NONE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_PREPARE_BACK_NAVIGATION;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.view.WindowManager.transitTypeToString;
@@ -221,6 +223,15 @@ public class TransitionAnimationHelper {
     */
    public static int getTransitionTypeFromInfo(@NonNull TransitionInfo info) {
        final int type = info.getType();
        // This back navigation is canceled, check whether the transition should be open or close
        if (type == TRANSIT_PREPARE_BACK_NAVIGATION
                || type == TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION) {
            if (!info.getChanges().isEmpty()) {
                final TransitionInfo.Change change = info.getChanges().get(0);
                return TransitionUtil.isOpeningMode(change.getMode())
                        ? TRANSIT_OPEN : TRANSIT_CLOSE;
            }
        }
        // If the info transition type is opening transition, iterate its changes to see if it
        // has any opening change, if none, returns TRANSIT_CLOSE type for closing animation.
        if (type == TRANSIT_OPEN) {
Loading