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

Commit eae8ce83 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove mNeedsLetterboxedAnimation" into main

parents 7a0f20e2 7801cf7b
Loading
Loading
Loading
Loading
+0 −39
Original line number Diff line number Diff line
@@ -673,9 +673,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()
     */
@@ -5606,18 +5603,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;
@@ -7287,10 +7272,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;
@@ -7308,11 +7289,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.
@@ -7325,17 +7301,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);
        }
@@ -7389,10 +7354,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