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

Commit 99b11551 authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Disable overriding task transit animation.

Activities can override transition animation when starting or finishing
activity by calling Activity#overridePendingAppTransition. This change
restricts it in a way such that an activity can do it only when the
transition happens within a same task.

Note that this change is guarded by a property, so by default,
activities can still override any transition animation. In order to
restrict it, the following property must be set:
persist.wm.disable_custom_task_animation

Bug: 162066454
Test: atest ActivityTransitionTests
Change-Id: I235adf73af75883d8e943b6f85d841a729f5bb6b
parent cbf9c819
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -347,6 +347,7 @@ public interface WindowManager extends ViewManager {
            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE,
            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION,
            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER,
            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface TransitionFlags {}
+5 −0
Original line number Diff line number Diff line
@@ -7560,6 +7560,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return mShowForAllUsers || mWmService.isCurrentProfile(mUserId);
    }

    @Override
    boolean canCustomizeAppTransition() {
        return true;
    }

    @Override
    public String toString() {
        if (stringName != null) {
+19 −10
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ public class AppTransition implements Dump {
    private static final int NEXT_TRANSIT_TYPE_REMOTE = 10;

    private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
    private boolean mNextAppTransitionOverrideRequested;

    // These are the possible states for the enter/exit activities during a thumbnail transition
    private static final int THUMBNAIL_TRANSITION_ENTER_SCALE_UP = 0;
@@ -454,6 +455,7 @@ public class AppTransition implements Dump {

    void clear() {
        mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
        mNextAppTransitionOverrideRequested = false;
        mNextAppTransitionPackage = null;
        mNextAppTransitionAnimationsSpecs.clear();
        mRemoteAnimationController = null;
@@ -1574,6 +1576,7 @@ public class AppTransition implements Dump {
     */
    boolean canSkipFirstFrame() {
        return mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM
                && !mNextAppTransitionOverrideRequested
                && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE
                && mNextAppTransitionType != NEXT_TRANSIT_TYPE_CLIP_REVEAL
                && mNextAppTransition != TRANSIT_KEYGUARD_GOING_AWAY;
@@ -1608,6 +1611,11 @@ public class AppTransition implements Dump {
            int orientation, Rect frame, Rect displayFrame, Rect insets,
            @Nullable Rect surfaceInsets, @Nullable Rect stableInsets, boolean isVoiceInteraction,
            boolean freeform, WindowContainer container) {

        if (mNextAppTransitionOverrideRequested && container.canCustomizeAppTransition()) {
            mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
        }

        Animation a;
        if (isKeyguardGoingAwayTransit(transit) && enter) {
            a = loadKeyguardExitAnimation(transit);
@@ -1648,7 +1656,6 @@ public class AppTransition implements Dump {
                    "applyAnimation: anim=%s nextAppTransition=ANIM_CUSTOM transit=%s "
                            + "isEntrance=%b Callers=%s",
                    a, appTransitionToString(transit), enter, Debug.getCallers(3));
            setAppTransitionFinishedCallbackIfNeeded(a);
        } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE) {
            a = loadAnimationRes(mNextAppTransitionPackage, mNextAppTransitionInPlace);
            ProtoLog.v(WM_DEBUG_APP_TRANSITIONS_ANIM,
@@ -1775,6 +1782,7 @@ public class AppTransition implements Dump {
                    a, animAttr, appTransitionToString(transit), enter,
                    Debug.getCallers(3));
        }
        setAppTransitionFinishedCallbackIfNeeded(a);
        return a;
    }

@@ -1816,7 +1824,7 @@ public class AppTransition implements Dump {
            IRemoteCallback startedCallback, IRemoteCallback endedCallback) {
        if (canOverridePendingAppTransition()) {
            clear();
            mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
            mNextAppTransitionOverrideRequested = true;
            mNextAppTransitionPackage = packageName;
            mNextAppTransitionEnter = enterAnim;
            mNextAppTransitionExit = exitAnim;
@@ -2134,15 +2142,16 @@ public class AppTransition implements Dump {
            pw.print(prefix); pw.print("mNextAppTransitionType=");
                    pw.println(transitTypeToString());
        }
        switch (mNextAppTransitionType) {
            case NEXT_TRANSIT_TYPE_CUSTOM:
        if (mNextAppTransitionOverrideRequested
                || mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
            pw.print(prefix); pw.print("mNextAppTransitionPackage=");
            pw.println(mNextAppTransitionPackage);
            pw.print(prefix); pw.print("mNextAppTransitionEnter=0x");
            pw.print(Integer.toHexString(mNextAppTransitionEnter));
            pw.print(" mNextAppTransitionExit=0x");
            pw.println(Integer.toHexString(mNextAppTransitionExit));
                break;
        }
        switch (mNextAppTransitionType) {
            case NEXT_TRANSIT_TYPE_CUSTOM_IN_PLACE:
                pw.print(prefix); pw.print("mNextAppTransitionPackage=");
                        pw.println(mNextAppTransitionPackage);
+8 −0
Original line number Diff line number Diff line
@@ -856,6 +856,14 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        }
    }

    /**
     * @return {@code true} when an application can override an app transition animation on this
     * container.
     */
    boolean canCustomizeAppTransition() {
        return !WindowManagerService.sDisableCustomTaskAnimationProperty;
    }

    /**
     * @return {@code true} when this container or its related containers are running an
     * animation, {@code false} otherwise.