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

Commit 756de71e authored by lumark's avatar lumark Committed by Kevin Haggerty
Browse files

Restrict app transition maximum duration

As WindowState#startAnimation for restricting window animation duration
(currently is 10 secs),

For security reason, we also need to restrict app transition animation
duration as 3 secs to prevent malicious app may set a long duration or
infinity repeat counts through ActivityOption#makeCustomAnimation or
Activity#overridePendingTransition with custom animation set.

Bug: 145728687
Test: manual as issue provided test app
Change-Id: I39051d6e4d2b681ce2becbafe14aab3f3d8ebf6b
(cherry picked from commit 36bcc773)
parent fe0cd263
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ public class AppTransition implements Dump {
    private static final int MAX_CLIP_REVEAL_TRANSITION_DURATION = 420;
    private static final int THUMBNAIL_APP_TRANSITION_DURATION = 336;
    private static final long APP_TRANSITION_TIMEOUT_MS = 5000;
    static final int MAX_APP_TRANSITION_DURATION = 3 * 1000; // 3 secs.

    private final Context mContext;
    private final WindowManagerService mService;
+11 −1
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static android.view.WindowManagerPolicy.TRANSIT_EXIT;
import static android.view.WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
import static com.android.server.wm.AppTransition.MAX_APP_TRANSITION_DURATION;
import static com.android.server.wm.AppWindowAnimator.PROLONG_ANIMATION_AT_END;
import static com.android.server.wm.AppWindowAnimator.PROLONG_ANIMATION_AT_START;
import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_DOCKED_DIVIDER;
@@ -3333,7 +3334,16 @@ public class WindowManagerService extends IWindowManager.Stub
                    mCurConfiguration.orientation, frame, displayFrame, insets, surfaceInsets,
                    isVoiceInteraction, freeform, atoken.mTask.mTaskId);
            if (a != null) {
                if (DEBUG_ANIM) logWithStack(TAG, "Loaded animation " + a + " for " + atoken);
                if (a != null) {
                    // Setup the maximum app transition duration to prevent malicious app may set a long
                    // animation duration or infinite repeat counts for the app transition through
                    // ActivityOption#makeCustomAnimation or WindowManager#overridePendingTransition.
                    a.restrictDuration(MAX_APP_TRANSITION_DURATION);
                }
                if (DEBUG_ANIM) {
                    logWithStack(TAG, "Loaded animation " + a + " for " + atoken
                            + ", duration: " + ((a != null) ? a.getDuration() : 0));
                }
                final int containingWidth = frame.width();
                final int containingHeight = frame.height();
                atoken.mAppAnimator.setAnimation(a, containingWidth, containingHeight,