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

Commit 7801cf7b authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove mNeedsLetterboxedAnimation

The field was added in I7c173c8711c9982f5cc66931d36d564abf923a80.
Since the only caller AppTransitionController is removed with
legacy transition, now the field is always false.

Bug: 365884835
Flag: EXEMPT remove outdated code
Test: atest AppCompatLetterboxUtilsTest LetterboxTest
            AppCompatLetterboxPolicyTest

Change-Id: I1be85060f13bc1ba31b48649988fe46e99e2c80c
parent 40aa32b3
Loading
Loading
Loading
Loading
+0 −39
Original line number Diff line number Diff line
@@ -672,9 +672,6 @@ final class ActivityRecord extends WindowToken {
    // TODO(b/317000737): Replace it with visibility states lookup.
    int mTransitionChangeFlags;

    /** Whether we need to setup the animation to animate only within the letterbox. */
    private boolean mNeedsLetterboxedAnimation;

    /**
     * @see #currentLaunchCanTurnScreenOn()
     */
@@ -5580,18 +5577,6 @@ final class ActivityRecord extends WindowToken {
        commitVisibility(visible, performLayout, false /* fromTransition */);
    }

    void setNeedsLetterboxedAnimation(boolean needsLetterboxedAnimation) {
        mNeedsLetterboxedAnimation = needsLetterboxedAnimation;
    }

    boolean isNeedsLetterboxedAnimation() {
        return mNeedsLetterboxedAnimation;
    }

    boolean isInLetterboxAnimation() {
        return mNeedsLetterboxedAnimation && isAnimating();
    }

    /** Updates draw state and shows drawn windows. */
    void commitFinishDrawing(SurfaceControl.Transaction t) {
        boolean committed = false;
@@ -7253,10 +7238,6 @@ final class ActivityRecord extends WindowToken {
                .setParent(getAnimationLeashParent())
                .setName(getSurfaceControl() + " - animation-bounds")
                .setCallsite("ActivityRecord.createAnimationBoundsLayer");
        if (mNeedsLetterboxedAnimation) {
            // Needs to be an effect layer to support rounded corners
            builder.setEffectLayer();
        }
        final SurfaceControl boundsLayer = builder.build();
        t.show(boundsLayer);
        return boundsLayer;
@@ -7274,11 +7255,6 @@ final class ActivityRecord extends WindowToken {

    @Override
    public void onLeashAnimationStarting(Transaction t, SurfaceControl leash) {
        if (mNeedsLetterboxedAnimation) {
            updateLetterboxSurfaceIfNeeded(findMainWindow(), t);
            mNeedsAnimationBoundsLayer = true;
        }

        // If the animation needs to be cropped then an animation bounds layer is created as a
        // child of the root pinned task or animation layer. The leash is then reparented to this
        // new layer.
@@ -7291,17 +7267,6 @@ final class ActivityRecord extends WindowToken {
            t.setLayer(leash, 0);
            t.setLayer(mAnimationBoundsLayer, getLastLayer());

            if (mNeedsLetterboxedAnimation) {
                final int cornerRadius = mAppCompatController.getLetterboxPolicy()
                        .getRoundedCornersRadius(findMainWindow());

                final Rect letterboxInnerBounds = new Rect();
                getLetterboxInnerBounds(letterboxInnerBounds);

                t.setCornerRadius(mAnimationBoundsLayer, cornerRadius)
                        .setCrop(mAnimationBoundsLayer, letterboxInnerBounds);
            }

            // Reparent leash to animation bounds layer.
            t.reparent(leash, mAnimationBoundsLayer);
        }
@@ -7355,10 +7320,6 @@ final class ActivityRecord extends WindowToken {
        }

        mNeedsAnimationBoundsLayer = false;
        if (mNeedsLetterboxedAnimation) {
            mNeedsLetterboxedAnimation = false;
            updateLetterboxSurfaceIfNeeded(findMainWindow(), t);
        }
    }

    @Override
+2 −12
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ class AppCompatLetterboxPolicy {
        }

        final boolean shouldShowLetterboxUi =
                (mActivityRecord.isInLetterboxAnimation() || mActivityRecord.isVisible()
                (mActivityRecord.isVisible()
                        || mActivityRecord.isVisibleRequested())
                        && mainWindow.areAppWindowBoundsLetterboxed()
                        // Check for FLAG_SHOW_WALLPAPER explicitly instead of using
@@ -360,8 +360,7 @@ class AppCompatLetterboxPolicy {
                        .mAppCompatController.getReachabilityPolicy();
                mLetterbox = new Letterbox(() -> mActivityRecord.makeChildSurface(null),
                        mActivityRecord.mWmService.mTransactionFactory,
                        reachabilityPolicy, letterboxOverrides,
                        this::getLetterboxParentSurface);
                        reachabilityPolicy, letterboxOverrides);
                mActivityRecord.mAppCompatController.getReachabilityPolicy()
                        .setLetterboxInnerBoundsSupplier(mLetterbox::getInnerFrame);
            }
@@ -469,15 +468,6 @@ class AppCompatLetterboxPolicy {
        public boolean isFullyTransparentBarAllowed(@NonNull Rect rect) {
            return !isRunning() || mLetterbox.notIntersectsOrFullyContains(rect);
        }

        @Nullable
        private SurfaceControl getLetterboxParentSurface() {
            if (mActivityRecord.isInLetterboxAnimation()) {
                return mActivityRecord.getTask().getSurfaceControl();
            }
            return mActivityRecord.getSurfaceControl();
        }

    }

    /**
+1 −6
Original line number Diff line number Diff line
@@ -36,13 +36,8 @@ class AppCompatLetterboxUtils {
            outLetterboxPosition.set(0, 0);
            return;
        }
        if (activity.isInLetterboxAnimation()) {
            // In this case we attach the letterbox to the task instead of the activity.
            activity.getTask().getPosition(outLetterboxPosition);
        } else {
        activity.getPosition(outLetterboxPosition);
    }
    }

    /**
     * Provides all the available space, in display coordinate, to fill with the letterboxed
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class AppCompatRoundedCorners {
    @VisibleForTesting
    @Nullable
    Rect getCropBoundsIfNeeded(@NonNull final WindowState mainWindow) {
        if (!requiresRoundedCorners(mainWindow) || mActivityRecord.isInLetterboxAnimation()) {
        if (!requiresRoundedCorners(mainWindow)) {
            // We don't want corner radius on the window.
            // In the case the ActivityRecord requires a letterboxed animation we never want
            // rounded corners on the window because rounded corners are applied at the
+8 −15
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ public class Letterbox {

    private final Supplier<SurfaceControl.Builder> mSurfaceControlFactory;
    private final Supplier<SurfaceControl.Transaction> mTransactionFactory;
    private final Supplier<SurfaceControl> mParentSurfaceSupplier;

    private final Rect mOuter = new Rect();
    private final Rect mInner = new Rect();
@@ -83,13 +82,11 @@ public class Letterbox {
    public Letterbox(Supplier<SurfaceControl.Builder> surfaceControlFactory,
            Supplier<SurfaceControl.Transaction> transactionFactory,
            @NonNull AppCompatReachabilityPolicy appCompatReachabilityPolicy,
            @NonNull AppCompatLetterboxOverrides appCompatLetterboxOverrides,
            Supplier<SurfaceControl> parentSurface) {
            @NonNull AppCompatLetterboxOverrides appCompatLetterboxOverrides) {
        mSurfaceControlFactory = surfaceControlFactory;
        mTransactionFactory = transactionFactory;
        mAppCompatReachabilityPolicy = appCompatReachabilityPolicy;
        mAppCompatLetterboxOverrides = appCompatLetterboxOverrides;
        mParentSurfaceSupplier = parentSurface;
    }

    /**
@@ -343,7 +340,6 @@ public class Letterbox {
        private SurfaceControl mInputSurface;
        private Color mColor;
        private boolean mHasWallpaperBackground;
        private SurfaceControl mParentSurface;

        private final Rect mSurfaceFrameRelative = new Rect();
        private final Rect mLayoutFrameGlobal = new Rect();
@@ -437,9 +433,8 @@ public class Letterbox {
                }

                mColor = mAppCompatLetterboxOverrides.getLetterboxBackgroundColor();
                mParentSurface = mParentSurfaceSupplier.get();
                t.setColor(mSurface, getRgbColorArray());
                setPositionAndReparent(t, mSurface);
                setPositionAndCrop(t, mSurface);

                mHasWallpaperBackground = mAppCompatLetterboxOverrides
                        .hasWallpaperBackgroundForLetterbox();
@@ -448,7 +443,7 @@ public class Letterbox {
                t.show(mSurface);

                if (mInputSurface != null) {
                    setPositionAndReparent(inputT, mInputSurface);
                    setPositionAndCrop(inputT, mInputSurface);
                    inputT.setTrustedOverlay(mInputSurface, true);
                    inputT.show(mInputSurface);
                }
@@ -470,12 +465,11 @@ public class Letterbox {
            }
        }

        private void setPositionAndReparent(@NonNull SurfaceControl.Transaction t,
        private void setPositionAndCrop(@NonNull SurfaceControl.Transaction t,
                @NonNull SurfaceControl surface) {
            t.setPosition(surface, mSurfaceFrameRelative.left, mSurfaceFrameRelative.top);
            t.setWindowCrop(surface, mSurfaceFrameRelative.width(),
                    mSurfaceFrameRelative.height());
            t.reparent(surface, mParentSurface);
        }

        private void updateAlphaAndBlur(SurfaceControl.Transaction t) {
@@ -511,14 +505,13 @@ public class Letterbox {

        public boolean needsApplySurfaceChanges() {
            return !mSurfaceFrameRelative.equals(mLayoutFrameRelative)
                    // If mSurfaceFrameRelative is empty then mHasWallpaperBackground, mColor,
                    // and mParentSurface may never be updated in applySurfaceChanges but this
                    // doesn't mean that update is needed.
                    // If mSurfaceFrameRelative is empty, then mHasWallpaperBackground and mColor
                    // may never be updated in applySurfaceChanges but this doesn't mean that
                    // update is needed.
                    || !mSurfaceFrameRelative.isEmpty()
                    && (mAppCompatLetterboxOverrides.hasWallpaperBackgroundForLetterbox()
                        != mHasWallpaperBackground
                    || !mAppCompatLetterboxOverrides.getLetterboxBackgroundColor().equals(mColor)
                    || mParentSurfaceSupplier.get() != mParentSurface);
                    || !mAppCompatLetterboxOverrides.getLetterboxBackgroundColor().equals(mColor));
        }
    }
}
Loading