Loading services/core/java/com/android/server/wm/AnimationAdapter.java +11 −8 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.server.wm; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; Loading @@ -32,7 +34,7 @@ import java.io.PrintWriter; * Interface that describes an animation and bridges the animation start to the component * responsible for running the animation. */ @VisibleForTesting @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public interface AnimationAdapter { long STATUS_BAR_TRANSITION_DURATION = 120L; Loading @@ -55,6 +57,7 @@ public interface AnimationAdapter { * @return The background color to use during an animation if getShowBackground returns true. * @see Animation#getBackdropColor() */ @ColorInt default int getBackgroundColor() { return 0; } Loading @@ -70,8 +73,8 @@ public interface AnimationAdapter { * @param type The type of the animation. * @param finishCallback The callback to be invoked when the animation has finished. */ void startAnimation(SurfaceControl animationLeash, Transaction t, @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback); void startAnimation(@NonNull SurfaceControl animationLeash, @NonNull Transaction t, @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback); /** * Called when the animation that was started with {@link #startAnimation} was cancelled by the Loading @@ -79,7 +82,7 @@ public interface AnimationAdapter { * * @param animationLeash The leash passed to {@link #startAnimation}. */ void onAnimationCancelled(SurfaceControl animationLeash); void onAnimationCancelled(@Nullable SurfaceControl animationLeash); /** * @return The approximate duration of the animation, in milliseconds. Loading @@ -95,15 +98,15 @@ public interface AnimationAdapter { */ long getStatusBarTransitionsStartTime(); void dump(PrintWriter pw, String prefix); void dump(@NonNull PrintWriter pw, @NonNull String prefix); default void dumpDebug(ProtoOutputStream proto, long fieldId) { default void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); dumpDebug(proto); proto.end(token); } void dumpDebug(ProtoOutputStream proto); void dumpDebug(@NonNull ProtoOutputStream proto); /** * Gets called when the animation is about to finish and gives the client the opportunity to Loading @@ -113,7 +116,7 @@ public interface AnimationAdapter { * @param endDeferFinishCallback The callback to call when defer finishing should be ended. * @return Whether the client would like to defer the animation finish. */ default boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) { default boolean shouldDeferAnimationFinish(@NonNull Runnable endDeferFinishCallback) { return false; } } services/core/java/com/android/server/wm/AsyncRotationController.java +7 −4 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_TOKEN_TRANSFORM; import android.annotation.IntDef; import android.annotation.NonNull; import android.os.HandlerExecutor; import android.util.ArrayMap; import android.util.Slog; Loading Loading @@ -106,7 +107,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume private int mOriginalRotation; private final boolean mHasScreenRotationAnimation; AsyncRotationController(DisplayContent displayContent) { AsyncRotationController(@NonNull DisplayContent displayContent) { super(displayContent); mService = displayContent.mWmService; mOriginalRotation = displayContent.getWindowConfiguration().getRotation(); Loading Loading @@ -255,7 +256,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume } /** Lets the window fit in new rotation naturally. */ private void finishOp(WindowToken windowToken) { private void finishOp(@NonNull WindowToken windowToken) { final Operation op = mTargetWindowTokens.remove(windowToken); if (op == null) return; if (op.mDrawTransaction != null) { Loading Loading @@ -455,7 +456,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume if (DEBUG) Slog.d(TAG, "hideImeImmediately " + imeWindowToken.getTopChild()); } private void hideImmediately(WindowToken token, @Operation.Action int action) { private void hideImmediately(@NonNull WindowToken token, @Operation.Action int action) { final boolean original = mHideImmediately; mHideImmediately = true; final Operation op = new Operation(action); Loading Loading @@ -496,7 +497,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume * Whether the insets animation leash should use previous position when running fade animation * or seamless transformation in a rotated display. */ boolean shouldFreezeInsetsPosition(WindowState w) { boolean shouldFreezeInsetsPosition(@NonNull WindowState w) { // Non-change transition (OP_APP_SWITCH) and METHOD_BLAST don't use screenshot so the // insets should keep original position before the window is done with new rotation. return mTransitionOp != OP_LEGACY && (isSeamlessTransition() Loading Loading @@ -683,6 +684,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume return true; } @NonNull @Override public Animation getFadeInAnimation() { final Animation anim = super.getFadeInAnimation(); Loading @@ -693,6 +695,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume return anim; } @NonNull @Override public Animation getFadeOutAnimation() { if (mHideImmediately) { Loading services/core/java/com/android/server/wm/BackNavigationController.java +12 −12 Original line number Diff line number Diff line Loading @@ -126,7 +126,6 @@ class BackNavigationController { * for the animation, or null if we don't know how to animate the current window and need to * fallback on dispatching the key event. */ @VisibleForTesting @Nullable BackNavigationInfo startBackNavigation(@NonNull RemoteCallback navigationObserver, BackAnimationAdapter adapter) { Loading Loading @@ -820,7 +819,7 @@ class BackNavigationController { * Notify focus window changed during back navigation. This will cancel the gesture for * scenarios like: a system window popup, or when an activity add a new window. * * This method should only be used to check window-level change, otherwise it may cause * <p>This method should only be used to check window-level change, otherwise it may cause * misjudgment in multi-window mode. For example: in split-screen, when user is * navigating on the top task, bottom task can start a new task, which will gain focus for * a short time, but we should not cancel the navigation. Loading Loading @@ -1494,7 +1493,7 @@ class BackNavigationController { @NonNull private static BackWindowAnimationAdaptor createAdaptor( @NonNull WindowContainer target, boolean isOpen, int switchType, SurfaceControl.Transaction st) { @NonNull SurfaceControl.Transaction st) { final BackWindowAnimationAdaptor adaptor = new BackWindowAnimationAdaptor(target, isOpen, switchType); // Workaround to show TaskFragment which can be hide in Transitions and won't show Loading Loading @@ -1526,7 +1525,7 @@ class BackNavigationController { private Transition mPreparedOpenTransition; BackWindowAnimationAdaptorWrapper(boolean isOpen, int switchType, SurfaceControl.Transaction st, @NonNull WindowContainer... targets) { @NonNull SurfaceControl.Transaction st, @NonNull WindowContainer... targets) { mAdaptors = new BackWindowAnimationAdaptor[targets.length]; for (int i = targets.length - 1; i >= 0; --i) { mAdaptors[i] = createAdaptor(targets[i], isOpen, switchType, st); Loading Loading @@ -1557,7 +1556,8 @@ class BackNavigationController { mPreparedOpenTransition = null; } private RemoteAnimationTarget createWrapTarget(SurfaceControl.Transaction st) { @NonNull private RemoteAnimationTarget createWrapTarget(@NonNull SurfaceControl.Transaction st) { // Special handle for opening two activities together. // If we animate both activities separately, the animation area and rounded corner // would also being handled separately. To make them seem like "open" together, wrap Loading Loading @@ -1726,8 +1726,9 @@ class BackNavigationController { } @Override public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t, int type, SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { public void startAnimation(@NonNull SurfaceControl animationLeash, @NonNull SurfaceControl.Transaction t, @SurfaceAnimator.AnimationType int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { mCapturedLeash = animationLeash; createRemoteAnimationTarget(); final WindowState win = mTarget.asWindowState(); Loading @@ -1735,12 +1736,12 @@ class BackNavigationController { final Rect frame = win.getFrame(); final Point position = new Point(); win.transformFrameToSurfacePosition(frame.left, frame.top, position); t.setPosition(mCapturedLeash, position.x, position.y); t.setPosition(animationLeash, position.x, position.y); } } @Override public void onAnimationCancelled(SurfaceControl animationLeash) { public void onAnimationCancelled(@Nullable SurfaceControl animationLeash) { if (mCapturedLeash == animationLeash) { mCapturedLeash = null; } Loading @@ -1757,15 +1758,14 @@ class BackNavigationController { } @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { pw.print(prefix + "BackWindowAnimationAdaptor mCapturedLeash="); pw.print(mCapturedLeash); pw.println(); } @Override public void dumpDebug(ProtoOutputStream proto) { public void dumpDebug(@NonNull ProtoOutputStream proto) { } RemoteAnimationTarget createRemoteAnimationTarget() { Loading services/core/java/com/android/server/wm/FadeAnimationController.java +28 −23 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.internal.perfetto.protos.Animationadapter.AnimationSpecPro import static android.internal.perfetto.protos.Animationadapter.WindowAnimationSpecProto.ANIMATION; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; import android.view.animation.AccelerateInterpolator; Loading @@ -33,19 +34,21 @@ import java.io.PrintWriter; /** * An animation controller to fade-in/out for a window token. */ public class FadeAnimationController { class FadeAnimationController { static final int SHORT_DURATION_MS = 200; static final int MEDIUM_DURATION_MS = 350; protected final DisplayContent mDisplayContent; @NonNull final DisplayContent mDisplayContent; public FadeAnimationController(DisplayContent displayContent) { FadeAnimationController(@NonNull DisplayContent displayContent) { mDisplayContent = displayContent; } /** * @return a fade-in Animation. */ @NonNull public Animation getFadeInAnimation() { final AlphaAnimation anim = new AlphaAnimation(0f, 1f); anim.setDuration(getScaledDuration(MEDIUM_DURATION_MS)); Loading @@ -56,6 +59,7 @@ public class FadeAnimationController { /** * @return a fade-out Animation. */ @NonNull public Animation getFadeOutAnimation() { final AlphaAnimation anim = new AlphaAnimation(1f, 0f); anim.setDuration(getScaledDuration(SHORT_DURATION_MS)); Loading @@ -68,7 +72,8 @@ public class FadeAnimationController { } /** Run the fade in/out animation for a window token. */ public void fadeWindowToken(boolean show, WindowToken windowToken, int animationType) { void fadeWindowToken(boolean show, @NonNull WindowToken windowToken, @SurfaceAnimator.AnimationType int animationType) { fadeWindowToken(show, windowToken, animationType, null); } Loading @@ -80,30 +85,29 @@ public class FadeAnimationController { * @param animationType the animation type defined in SurfaceAnimator. * @param finishedCallback the callback after the animation finished. */ public void fadeWindowToken(boolean show, WindowToken windowToken, int animationType, SurfaceAnimator.OnAnimationFinishedCallback finishedCallback) { void fadeWindowToken(boolean show, @Nullable WindowToken windowToken, @SurfaceAnimator.AnimationType int animationType, @Nullable SurfaceAnimator.OnAnimationFinishedCallback finishedCallback) { if (windowToken == null || windowToken.getParent() == null) { return; } final Animation animation = show ? getFadeInAnimation() : getFadeOutAnimation(); final FadeAnimationAdapter animationAdapter = animation != null ? createAdapter(createAnimationSpec(animation), show, windowToken) : null; if (animationAdapter == null) { return; } final FadeAnimationAdapter animationAdapter = createAdapter(createAnimationSpec(animation), show, windowToken); windowToken.startAnimation(windowToken.getPendingTransaction(), animationAdapter, show /* hidden */, animationType, finishedCallback); } protected FadeAnimationAdapter createAdapter(LocalAnimationAdapter.AnimationSpec animationSpec, boolean show, WindowToken windowToken) { @NonNull FadeAnimationAdapter createAdapter(@NonNull LocalAnimationAdapter.AnimationSpec animationSpec, boolean show, @NonNull WindowToken windowToken) { return new FadeAnimationAdapter(animationSpec, windowToken.getSurfaceAnimationRunner(), show, windowToken); } protected LocalAnimationAdapter.AnimationSpec createAnimationSpec( @NonNull Animation animation) { @NonNull private LocalAnimationAdapter.AnimationSpec createAnimationSpec(@NonNull Animation animation) { return new LocalAnimationAdapter.AnimationSpec() { final Transformation mTransformation = new Transformation(); Loading @@ -119,7 +123,7 @@ public class FadeAnimationController { } @Override public void apply(SurfaceControl.Transaction t, SurfaceControl leash, public void apply(@NonNull SurfaceControl.Transaction t, @NonNull SurfaceControl leash, long currentPlayTime) { mTransformation.clear(); animation.getTransformation(currentPlayTime, mTransformation); Loading @@ -127,13 +131,13 @@ public class FadeAnimationController { } @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { pw.print(prefix); pw.println(animation); } @Override public void dumpDebugInner(ProtoOutputStream proto) { public void dumpDebugInner(@NonNull ProtoOutputStream proto) { final long token = proto.start(WINDOW); proto.write(ANIMATION, animation.toString()); proto.end(token); Loading @@ -141,20 +145,21 @@ public class FadeAnimationController { }; } protected static class FadeAnimationAdapter extends LocalAnimationAdapter { static class FadeAnimationAdapter extends LocalAnimationAdapter { protected final boolean mShow; @NonNull protected final WindowToken mToken; FadeAnimationAdapter(AnimationSpec windowAnimationSpec, SurfaceAnimationRunner surfaceAnimationRunner, boolean show, WindowToken token) { FadeAnimationAdapter(@NonNull AnimationSpec windowAnimationSpec, @NonNull SurfaceAnimationRunner surfaceAnimationRunner, boolean show, @NonNull WindowToken token) { super(windowAnimationSpec, surfaceAnimationRunner); mShow = show; mToken = token; } @Override public boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) { public boolean shouldDeferAnimationFinish(@NonNull Runnable endDeferFinishCallback) { // Defer the finish callback (restore leash) of the hide animation to ensure the token // stay hidden until it needs to show again. Besides, when starting the show animation, // the previous hide animation will be cancelled, so the callback can be ignored. Loading services/core/java/com/android/server/wm/LocalAnimationAdapter.java +17 −10 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package com.android.server.wm; import static android.internal.perfetto.protos.Animationadapter.AnimationAdapterProto.LOCAL; import static android.internal.perfetto.protos.Animationadapter.LocalAnimationAdapterProto.ANIMATION_SPEC; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.SystemClock; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; Loading @@ -36,11 +38,13 @@ import java.io.PrintWriter; */ class LocalAnimationAdapter implements AnimationAdapter { @NonNull private final AnimationSpec mSpec; @NonNull private final SurfaceAnimationRunner mAnimator; LocalAnimationAdapter(AnimationSpec spec, SurfaceAnimationRunner animator) { LocalAnimationAdapter(@NonNull AnimationSpec spec, @NonNull SurfaceAnimationRunner animator) { mSpec = spec; mAnimator = animator; } Loading @@ -55,20 +59,21 @@ class LocalAnimationAdapter implements AnimationAdapter { return mSpec.getShowBackground(); } @ColorInt @Override public int getBackgroundColor() { return mSpec.getBackgroundColor(); } @Override public void startAnimation(SurfaceControl animationLeash, Transaction t, public void startAnimation(@NonNull SurfaceControl animationLeash, @NonNull Transaction t, @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback) { mAnimator.startAnimation(mSpec, animationLeash, t, () -> finishCallback.onAnimationFinished(type, this)); } @Override public void onAnimationCancelled(SurfaceControl animationLeash) { public void onAnimationCancelled(@Nullable SurfaceControl animationLeash) { mAnimator.onAnimationCancelled(animationLeash); } Loading @@ -83,12 +88,12 @@ class LocalAnimationAdapter implements AnimationAdapter { } @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { mSpec.dump(pw, prefix); } @Override public void dumpDebug(ProtoOutputStream proto) { public void dumpDebug(@NonNull ProtoOutputStream proto) { final long token = proto.start(LOCAL); mSpec.dumpDebug(proto, ANIMATION_SPEC); proto.end(token); Loading Loading @@ -116,6 +121,7 @@ class LocalAnimationAdapter implements AnimationAdapter { /** * @see AnimationAdapter#getBackgroundColor */ @ColorInt default int getBackgroundColor() { return 0; } Loading @@ -139,10 +145,10 @@ class LocalAnimationAdapter implements AnimationAdapter { * @param leash The leash to apply the state to. * @param currentPlayTime The current time of the animation. */ void apply(Transaction t, SurfaceControl leash, long currentPlayTime); void apply(@NonNull Transaction t, @NonNull SurfaceControl leash, long currentPlayTime); /** * @see AppTransition#canSkipFirstFrame * @see WindowAnimationSpec#canSkipFirstFrame */ default boolean canSkipFirstFrame() { return false; Loading @@ -165,16 +171,17 @@ class LocalAnimationAdapter implements AnimationAdapter { return duration > 0 ? currentPlayTime / duration : 1.0f; } void dump(PrintWriter pw, String prefix); void dump(@NonNull PrintWriter pw, @NonNull String prefix); default void dumpDebug(ProtoOutputStream proto, long fieldId) { default void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); dumpDebugInner(proto); proto.end(token); } void dumpDebugInner(ProtoOutputStream proto); void dumpDebugInner(@NonNull ProtoOutputStream proto); @Nullable default WindowAnimationSpec asWindowAnimationSpec() { return null; } Loading Loading
services/core/java/com/android/server/wm/AnimationAdapter.java +11 −8 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.server.wm; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; import android.view.SurfaceControl.Transaction; Loading @@ -32,7 +34,7 @@ import java.io.PrintWriter; * Interface that describes an animation and bridges the animation start to the component * responsible for running the animation. */ @VisibleForTesting @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public interface AnimationAdapter { long STATUS_BAR_TRANSITION_DURATION = 120L; Loading @@ -55,6 +57,7 @@ public interface AnimationAdapter { * @return The background color to use during an animation if getShowBackground returns true. * @see Animation#getBackdropColor() */ @ColorInt default int getBackgroundColor() { return 0; } Loading @@ -70,8 +73,8 @@ public interface AnimationAdapter { * @param type The type of the animation. * @param finishCallback The callback to be invoked when the animation has finished. */ void startAnimation(SurfaceControl animationLeash, Transaction t, @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback); void startAnimation(@NonNull SurfaceControl animationLeash, @NonNull Transaction t, @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback); /** * Called when the animation that was started with {@link #startAnimation} was cancelled by the Loading @@ -79,7 +82,7 @@ public interface AnimationAdapter { * * @param animationLeash The leash passed to {@link #startAnimation}. */ void onAnimationCancelled(SurfaceControl animationLeash); void onAnimationCancelled(@Nullable SurfaceControl animationLeash); /** * @return The approximate duration of the animation, in milliseconds. Loading @@ -95,15 +98,15 @@ public interface AnimationAdapter { */ long getStatusBarTransitionsStartTime(); void dump(PrintWriter pw, String prefix); void dump(@NonNull PrintWriter pw, @NonNull String prefix); default void dumpDebug(ProtoOutputStream proto, long fieldId) { default void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); dumpDebug(proto); proto.end(token); } void dumpDebug(ProtoOutputStream proto); void dumpDebug(@NonNull ProtoOutputStream proto); /** * Gets called when the animation is about to finish and gives the client the opportunity to Loading @@ -113,7 +116,7 @@ public interface AnimationAdapter { * @param endDeferFinishCallback The callback to call when defer finishing should be ended. * @return Whether the client would like to defer the animation finish. */ default boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) { default boolean shouldDeferAnimationFinish(@NonNull Runnable endDeferFinishCallback) { return false; } }
services/core/java/com/android/server/wm/AsyncRotationController.java +7 −4 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_TOKEN_TRANSFORM; import android.annotation.IntDef; import android.annotation.NonNull; import android.os.HandlerExecutor; import android.util.ArrayMap; import android.util.Slog; Loading Loading @@ -106,7 +107,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume private int mOriginalRotation; private final boolean mHasScreenRotationAnimation; AsyncRotationController(DisplayContent displayContent) { AsyncRotationController(@NonNull DisplayContent displayContent) { super(displayContent); mService = displayContent.mWmService; mOriginalRotation = displayContent.getWindowConfiguration().getRotation(); Loading Loading @@ -255,7 +256,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume } /** Lets the window fit in new rotation naturally. */ private void finishOp(WindowToken windowToken) { private void finishOp(@NonNull WindowToken windowToken) { final Operation op = mTargetWindowTokens.remove(windowToken); if (op == null) return; if (op.mDrawTransaction != null) { Loading Loading @@ -455,7 +456,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume if (DEBUG) Slog.d(TAG, "hideImeImmediately " + imeWindowToken.getTopChild()); } private void hideImmediately(WindowToken token, @Operation.Action int action) { private void hideImmediately(@NonNull WindowToken token, @Operation.Action int action) { final boolean original = mHideImmediately; mHideImmediately = true; final Operation op = new Operation(action); Loading Loading @@ -496,7 +497,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume * Whether the insets animation leash should use previous position when running fade animation * or seamless transformation in a rotated display. */ boolean shouldFreezeInsetsPosition(WindowState w) { boolean shouldFreezeInsetsPosition(@NonNull WindowState w) { // Non-change transition (OP_APP_SWITCH) and METHOD_BLAST don't use screenshot so the // insets should keep original position before the window is done with new rotation. return mTransitionOp != OP_LEGACY && (isSeamlessTransition() Loading Loading @@ -683,6 +684,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume return true; } @NonNull @Override public Animation getFadeInAnimation() { final Animation anim = super.getFadeInAnimation(); Loading @@ -693,6 +695,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume return anim; } @NonNull @Override public Animation getFadeOutAnimation() { if (mHideImmediately) { Loading
services/core/java/com/android/server/wm/BackNavigationController.java +12 −12 Original line number Diff line number Diff line Loading @@ -126,7 +126,6 @@ class BackNavigationController { * for the animation, or null if we don't know how to animate the current window and need to * fallback on dispatching the key event. */ @VisibleForTesting @Nullable BackNavigationInfo startBackNavigation(@NonNull RemoteCallback navigationObserver, BackAnimationAdapter adapter) { Loading Loading @@ -820,7 +819,7 @@ class BackNavigationController { * Notify focus window changed during back navigation. This will cancel the gesture for * scenarios like: a system window popup, or when an activity add a new window. * * This method should only be used to check window-level change, otherwise it may cause * <p>This method should only be used to check window-level change, otherwise it may cause * misjudgment in multi-window mode. For example: in split-screen, when user is * navigating on the top task, bottom task can start a new task, which will gain focus for * a short time, but we should not cancel the navigation. Loading Loading @@ -1494,7 +1493,7 @@ class BackNavigationController { @NonNull private static BackWindowAnimationAdaptor createAdaptor( @NonNull WindowContainer target, boolean isOpen, int switchType, SurfaceControl.Transaction st) { @NonNull SurfaceControl.Transaction st) { final BackWindowAnimationAdaptor adaptor = new BackWindowAnimationAdaptor(target, isOpen, switchType); // Workaround to show TaskFragment which can be hide in Transitions and won't show Loading Loading @@ -1526,7 +1525,7 @@ class BackNavigationController { private Transition mPreparedOpenTransition; BackWindowAnimationAdaptorWrapper(boolean isOpen, int switchType, SurfaceControl.Transaction st, @NonNull WindowContainer... targets) { @NonNull SurfaceControl.Transaction st, @NonNull WindowContainer... targets) { mAdaptors = new BackWindowAnimationAdaptor[targets.length]; for (int i = targets.length - 1; i >= 0; --i) { mAdaptors[i] = createAdaptor(targets[i], isOpen, switchType, st); Loading Loading @@ -1557,7 +1556,8 @@ class BackNavigationController { mPreparedOpenTransition = null; } private RemoteAnimationTarget createWrapTarget(SurfaceControl.Transaction st) { @NonNull private RemoteAnimationTarget createWrapTarget(@NonNull SurfaceControl.Transaction st) { // Special handle for opening two activities together. // If we animate both activities separately, the animation area and rounded corner // would also being handled separately. To make them seem like "open" together, wrap Loading Loading @@ -1726,8 +1726,9 @@ class BackNavigationController { } @Override public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t, int type, SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { public void startAnimation(@NonNull SurfaceControl animationLeash, @NonNull SurfaceControl.Transaction t, @SurfaceAnimator.AnimationType int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { mCapturedLeash = animationLeash; createRemoteAnimationTarget(); final WindowState win = mTarget.asWindowState(); Loading @@ -1735,12 +1736,12 @@ class BackNavigationController { final Rect frame = win.getFrame(); final Point position = new Point(); win.transformFrameToSurfacePosition(frame.left, frame.top, position); t.setPosition(mCapturedLeash, position.x, position.y); t.setPosition(animationLeash, position.x, position.y); } } @Override public void onAnimationCancelled(SurfaceControl animationLeash) { public void onAnimationCancelled(@Nullable SurfaceControl animationLeash) { if (mCapturedLeash == animationLeash) { mCapturedLeash = null; } Loading @@ -1757,15 +1758,14 @@ class BackNavigationController { } @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { pw.print(prefix + "BackWindowAnimationAdaptor mCapturedLeash="); pw.print(mCapturedLeash); pw.println(); } @Override public void dumpDebug(ProtoOutputStream proto) { public void dumpDebug(@NonNull ProtoOutputStream proto) { } RemoteAnimationTarget createRemoteAnimationTarget() { Loading
services/core/java/com/android/server/wm/FadeAnimationController.java +28 −23 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.internal.perfetto.protos.Animationadapter.AnimationSpecPro import static android.internal.perfetto.protos.Animationadapter.WindowAnimationSpecProto.ANIMATION; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; import android.view.animation.AccelerateInterpolator; Loading @@ -33,19 +34,21 @@ import java.io.PrintWriter; /** * An animation controller to fade-in/out for a window token. */ public class FadeAnimationController { class FadeAnimationController { static final int SHORT_DURATION_MS = 200; static final int MEDIUM_DURATION_MS = 350; protected final DisplayContent mDisplayContent; @NonNull final DisplayContent mDisplayContent; public FadeAnimationController(DisplayContent displayContent) { FadeAnimationController(@NonNull DisplayContent displayContent) { mDisplayContent = displayContent; } /** * @return a fade-in Animation. */ @NonNull public Animation getFadeInAnimation() { final AlphaAnimation anim = new AlphaAnimation(0f, 1f); anim.setDuration(getScaledDuration(MEDIUM_DURATION_MS)); Loading @@ -56,6 +59,7 @@ public class FadeAnimationController { /** * @return a fade-out Animation. */ @NonNull public Animation getFadeOutAnimation() { final AlphaAnimation anim = new AlphaAnimation(1f, 0f); anim.setDuration(getScaledDuration(SHORT_DURATION_MS)); Loading @@ -68,7 +72,8 @@ public class FadeAnimationController { } /** Run the fade in/out animation for a window token. */ public void fadeWindowToken(boolean show, WindowToken windowToken, int animationType) { void fadeWindowToken(boolean show, @NonNull WindowToken windowToken, @SurfaceAnimator.AnimationType int animationType) { fadeWindowToken(show, windowToken, animationType, null); } Loading @@ -80,30 +85,29 @@ public class FadeAnimationController { * @param animationType the animation type defined in SurfaceAnimator. * @param finishedCallback the callback after the animation finished. */ public void fadeWindowToken(boolean show, WindowToken windowToken, int animationType, SurfaceAnimator.OnAnimationFinishedCallback finishedCallback) { void fadeWindowToken(boolean show, @Nullable WindowToken windowToken, @SurfaceAnimator.AnimationType int animationType, @Nullable SurfaceAnimator.OnAnimationFinishedCallback finishedCallback) { if (windowToken == null || windowToken.getParent() == null) { return; } final Animation animation = show ? getFadeInAnimation() : getFadeOutAnimation(); final FadeAnimationAdapter animationAdapter = animation != null ? createAdapter(createAnimationSpec(animation), show, windowToken) : null; if (animationAdapter == null) { return; } final FadeAnimationAdapter animationAdapter = createAdapter(createAnimationSpec(animation), show, windowToken); windowToken.startAnimation(windowToken.getPendingTransaction(), animationAdapter, show /* hidden */, animationType, finishedCallback); } protected FadeAnimationAdapter createAdapter(LocalAnimationAdapter.AnimationSpec animationSpec, boolean show, WindowToken windowToken) { @NonNull FadeAnimationAdapter createAdapter(@NonNull LocalAnimationAdapter.AnimationSpec animationSpec, boolean show, @NonNull WindowToken windowToken) { return new FadeAnimationAdapter(animationSpec, windowToken.getSurfaceAnimationRunner(), show, windowToken); } protected LocalAnimationAdapter.AnimationSpec createAnimationSpec( @NonNull Animation animation) { @NonNull private LocalAnimationAdapter.AnimationSpec createAnimationSpec(@NonNull Animation animation) { return new LocalAnimationAdapter.AnimationSpec() { final Transformation mTransformation = new Transformation(); Loading @@ -119,7 +123,7 @@ public class FadeAnimationController { } @Override public void apply(SurfaceControl.Transaction t, SurfaceControl leash, public void apply(@NonNull SurfaceControl.Transaction t, @NonNull SurfaceControl leash, long currentPlayTime) { mTransformation.clear(); animation.getTransformation(currentPlayTime, mTransformation); Loading @@ -127,13 +131,13 @@ public class FadeAnimationController { } @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { pw.print(prefix); pw.println(animation); } @Override public void dumpDebugInner(ProtoOutputStream proto) { public void dumpDebugInner(@NonNull ProtoOutputStream proto) { final long token = proto.start(WINDOW); proto.write(ANIMATION, animation.toString()); proto.end(token); Loading @@ -141,20 +145,21 @@ public class FadeAnimationController { }; } protected static class FadeAnimationAdapter extends LocalAnimationAdapter { static class FadeAnimationAdapter extends LocalAnimationAdapter { protected final boolean mShow; @NonNull protected final WindowToken mToken; FadeAnimationAdapter(AnimationSpec windowAnimationSpec, SurfaceAnimationRunner surfaceAnimationRunner, boolean show, WindowToken token) { FadeAnimationAdapter(@NonNull AnimationSpec windowAnimationSpec, @NonNull SurfaceAnimationRunner surfaceAnimationRunner, boolean show, @NonNull WindowToken token) { super(windowAnimationSpec, surfaceAnimationRunner); mShow = show; mToken = token; } @Override public boolean shouldDeferAnimationFinish(Runnable endDeferFinishCallback) { public boolean shouldDeferAnimationFinish(@NonNull Runnable endDeferFinishCallback) { // Defer the finish callback (restore leash) of the hide animation to ensure the token // stay hidden until it needs to show again. Besides, when starting the show animation, // the previous hide animation will be cancelled, so the callback can be ignored. Loading
services/core/java/com/android/server/wm/LocalAnimationAdapter.java +17 −10 Original line number Diff line number Diff line Loading @@ -19,7 +19,9 @@ package com.android.server.wm; import static android.internal.perfetto.protos.Animationadapter.AnimationAdapterProto.LOCAL; import static android.internal.perfetto.protos.Animationadapter.LocalAnimationAdapterProto.ANIMATION_SPEC; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.SystemClock; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; Loading @@ -36,11 +38,13 @@ import java.io.PrintWriter; */ class LocalAnimationAdapter implements AnimationAdapter { @NonNull private final AnimationSpec mSpec; @NonNull private final SurfaceAnimationRunner mAnimator; LocalAnimationAdapter(AnimationSpec spec, SurfaceAnimationRunner animator) { LocalAnimationAdapter(@NonNull AnimationSpec spec, @NonNull SurfaceAnimationRunner animator) { mSpec = spec; mAnimator = animator; } Loading @@ -55,20 +59,21 @@ class LocalAnimationAdapter implements AnimationAdapter { return mSpec.getShowBackground(); } @ColorInt @Override public int getBackgroundColor() { return mSpec.getBackgroundColor(); } @Override public void startAnimation(SurfaceControl animationLeash, Transaction t, public void startAnimation(@NonNull SurfaceControl animationLeash, @NonNull Transaction t, @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback) { mAnimator.startAnimation(mSpec, animationLeash, t, () -> finishCallback.onAnimationFinished(type, this)); } @Override public void onAnimationCancelled(SurfaceControl animationLeash) { public void onAnimationCancelled(@Nullable SurfaceControl animationLeash) { mAnimator.onAnimationCancelled(animationLeash); } Loading @@ -83,12 +88,12 @@ class LocalAnimationAdapter implements AnimationAdapter { } @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { mSpec.dump(pw, prefix); } @Override public void dumpDebug(ProtoOutputStream proto) { public void dumpDebug(@NonNull ProtoOutputStream proto) { final long token = proto.start(LOCAL); mSpec.dumpDebug(proto, ANIMATION_SPEC); proto.end(token); Loading Loading @@ -116,6 +121,7 @@ class LocalAnimationAdapter implements AnimationAdapter { /** * @see AnimationAdapter#getBackgroundColor */ @ColorInt default int getBackgroundColor() { return 0; } Loading @@ -139,10 +145,10 @@ class LocalAnimationAdapter implements AnimationAdapter { * @param leash The leash to apply the state to. * @param currentPlayTime The current time of the animation. */ void apply(Transaction t, SurfaceControl leash, long currentPlayTime); void apply(@NonNull Transaction t, @NonNull SurfaceControl leash, long currentPlayTime); /** * @see AppTransition#canSkipFirstFrame * @see WindowAnimationSpec#canSkipFirstFrame */ default boolean canSkipFirstFrame() { return false; Loading @@ -165,16 +171,17 @@ class LocalAnimationAdapter implements AnimationAdapter { return duration > 0 ? currentPlayTime / duration : 1.0f; } void dump(PrintWriter pw, String prefix); void dump(@NonNull PrintWriter pw, @NonNull String prefix); default void dumpDebug(ProtoOutputStream proto, long fieldId) { default void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); dumpDebugInner(proto); proto.end(token); } void dumpDebugInner(ProtoOutputStream proto); void dumpDebugInner(@NonNull ProtoOutputStream proto); @Nullable default WindowAnimationSpec asWindowAnimationSpec() { return null; } Loading