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

Commit c7614db5 authored by wilsonshih's avatar wilsonshih
Browse files

[PB] Migrate visibility change to transition.

There are two possible visibility change during predictive back
animation.

1. No snapshot for previous activity.
Currently core use setLauncherBehind to make previous activity become
visible. To migrate the visibility change in transition, create a
TRANSIT_PREPARE_BACK_NAVIGATION transition in core, and handle that
transition in BackTransitionHandler once it received handleRequest.

2. Close transition after gesture release.
For close home/task/activity case, core should expect a close
transition happen. The BackTransitionHandler can distingush that close
transiton by FLAG_BACK_GESTURE_ANIMATED.

If another transition happen while first transition is playing, just
finish first transition and cancel the predictive back animation, so
the next transition can play by corresponding handler.

In both 1 & 2 case, apply start transaction to remove windowless surface,
and reparent to the exist animation leash if needed. For no transition
cases(i.e. close window) the finish signal still passing by animation
finish callback.

Bug: 347168362
Flag: com.android.window.flags.migrate_predictive_back_transition
Test: atest BackNavigationControllerTests BackAnimationControllerTest
Test: verify back-to-home/cross-activity/cross-task transition can be
closed smoothly after back gesture trigger.

Change-Id: Ic70e16c57b4aca0d4d4275f788985027324b4e4c
parent d44adee6
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -477,6 +477,12 @@ public interface WindowManager extends ViewManager {
     * @hide
     */
    int TRANSIT_SLEEP = 12;
    /**
     * An Activity was going to be visible from back navigation.
     * @hide
     */
    int TRANSIT_PREPARE_BACK_NAVIGATION = 13;

    /**
     * The first slot for custom transition types. Callers (like Shell) can make use of custom
     * transition types for dealing with special cases. These types are effectively ignored by
@@ -505,6 +511,7 @@ public interface WindowManager extends ViewManager {
            TRANSIT_PIP,
            TRANSIT_WAKE,
            TRANSIT_SLEEP,
            TRANSIT_PREPARE_BACK_NAVIGATION,
            TRANSIT_FIRST_CUSTOM
    })
    @Retention(RetentionPolicy.SOURCE)
@@ -1918,6 +1925,7 @@ public interface WindowManager extends ViewManager {
            case TRANSIT_PIP: return "PIP";
            case TRANSIT_WAKE: return "WAKE";
            case TRANSIT_SLEEP: return "SLEEP";
            case TRANSIT_PREPARE_BACK_NAVIGATION: return "PREDICTIVE_BACK";
            case TRANSIT_FIRST_CUSTOM: return "FIRST_CUSTOM";
            default:
                if (type > TRANSIT_FIRST_CUSTOM) {
+10 −0
Original line number Diff line number Diff line
@@ -219,3 +219,13 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}
flag {
  name: "migrate_predictive_back_transition"
  namespace: "windowing_frontend"
  description: "Create transition when visibility change from predictive back"
  bug: "347168362"
  is_fixed_read_only: true
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+302 −6

File changed.

Preview size limit exceeded, changes collapsed.

+4 −2
Original line number Diff line number Diff line
@@ -375,7 +375,8 @@ public abstract class WMShellBaseModule {
            @ShellBackgroundThread Handler backgroundHandler,
            BackAnimationBackground backAnimationBackground,
            Optional<ShellBackAnimationRegistry> shellBackAnimationRegistry,
            ShellCommandHandler shellCommandHandler) {
            ShellCommandHandler shellCommandHandler,
            Transitions transitions) {
        if (BackAnimationController.IS_ENABLED) {
            return shellBackAnimationRegistry.map(
                    (animations) ->
@@ -387,7 +388,8 @@ public abstract class WMShellBaseModule {
                                    context,
                                    backAnimationBackground,
                                    animations,
                                    shellCommandHandler));
                                    shellCommandHandler,
                                    transitions));
        }
        return Optional.empty();
    }
+3 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import static android.window.TransitionInfo.FLAG_STARTING_WINDOW_TRANSFER_RECIPI
import static com.android.window.flags.Flags.enforceShellThreadModel;
import static com.android.window.flags.Flags.ensureWallpaperInTransitions;
import static com.android.systemui.shared.Flags.returnAnimationFrameworkLibrary;
import static com.android.window.flags.Flags.migratePredictiveBackTransition;
import static com.android.wm.shell.shared.TransitionUtil.isClosingType;
import static com.android.wm.shell.shared.TransitionUtil.isOpeningType;
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_SHELL_TRANSITIONS;
@@ -822,7 +823,8 @@ public class Transitions implements RemoteCallable<Transitions>,
            }
            // The change has already animated by back gesture, don't need to play transition
            // animation on it.
            if (change.hasFlags(FLAG_BACK_GESTURE_ANIMATED)) {
            if (!migratePredictiveBackTransition()
                    && change.hasFlags(FLAG_BACK_GESTURE_ANIMATED)) {
                info.getChanges().remove(i);
            }
        }
Loading