diff options
author | 2025-03-03 20:10:06 -0800 | |
---|---|---|
committer | 2025-03-03 20:10:06 -0800 | |
commit | eae8ce83aaa370a2efa08ddc338a607ecfbb8c4f (patch) | |
tree | f04710c1606000af29cb278b2d4823532e244801 | |
parent | 7a0f20e2130d3d6b122345387efb6617a5ce147b (diff) | |
parent | 7801cf7b4b5958a0af5a639b99391294dbc8328d (diff) |
Merge "Remove mNeedsLetterboxedAnimation" into main
10 files changed, 15 insertions, 134 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 199a6d85f73f..3cd4db7d8dfc 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -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 diff --git a/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java b/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java index 6873270366ee..27511b2f1668 100644 --- a/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java +++ b/services/core/java/com/android/server/wm/AppCompatLetterboxPolicy.java @@ -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(); - } - } /** diff --git a/services/core/java/com/android/server/wm/AppCompatLetterboxUtils.java b/services/core/java/com/android/server/wm/AppCompatLetterboxUtils.java index 83d7cb7bb960..e5b61db2ef68 100644 --- a/services/core/java/com/android/server/wm/AppCompatLetterboxUtils.java +++ b/services/core/java/com/android/server/wm/AppCompatLetterboxUtils.java @@ -36,12 +36,7 @@ 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); - } + activity.getPosition(outLetterboxPosition); } /** diff --git a/services/core/java/com/android/server/wm/AppCompatRoundedCorners.java b/services/core/java/com/android/server/wm/AppCompatRoundedCorners.java index 8165638d4bda..92b91464312e 100644 --- a/services/core/java/com/android/server/wm/AppCompatRoundedCorners.java +++ b/services/core/java/com/android/server/wm/AppCompatRoundedCorners.java @@ -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 diff --git a/services/core/java/com/android/server/wm/Letterbox.java b/services/core/java/com/android/server/wm/Letterbox.java index 29c0c7b2035e..3a4d2ca8b9bd 100644 --- a/services/core/java/com/android/server/wm/Letterbox.java +++ b/services/core/java/com/android/server/wm/Letterbox.java @@ -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)); } } } diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java index d016e735f0c7..8fe08553db95 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java @@ -251,10 +251,6 @@ class AppCompatActivityRobot { doReturn(mTaskStack.top()).when(mActivityStack.top()).getOrganizedTask(); } - void setIsInLetterboxAnimation(boolean inAnimation) { - doReturn(inAnimation).when(mActivityStack.top()).isInLetterboxAnimation(); - } - void setTopTaskInMultiWindowMode(boolean inMultiWindowMode) { doReturn(inMultiWindowMode).when(mTaskStack.top()).inMultiWindowMode(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java index d38f3b09c4fa..7bcf4eaa7c8b 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxPolicyTest.java @@ -66,7 +66,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { runTestScenario((robot) -> { robot.configureWindowStateWithTaskBar(/* hasTaskBarInsetsRoundedCorners */ true); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -87,7 +86,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { runTestScenario((robot) -> { robot.configureWindowStateWithTaskBar(/* hasTaskBarInsetsRoundedCorners */ false); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -109,7 +107,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { runTestScenario((robot) -> { robot.configureWindowStateWithTaskBar(/* hasTaskBarInsetsRoundedCorners */ true); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -131,7 +128,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { runTestScenario((robot) -> { robot.configureWindowStateWithTaskBar(/* hasTaskBarInsetsRoundedCorners */ true); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -157,7 +153,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { robot.conf().setLetterboxActivityCornersRadius(-1); robot.configureWindowState(); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -184,25 +179,17 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { robot.conf().setLetterboxActivityCornersRadius(15); robot.configureWindowState(); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); robot.resources().configureGetDimensionPixelSize(R.dimen.taskbar_frame_height, 20); robot.setInvCompatState(/* scale */ 0.5f); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ true); - robot.checkWindowStateRoundedCornersRadius(/* expected */ 7); - - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.checkWindowStateRoundedCornersRadius(/* expected */ 7); robot.activity().setTopActivityVisibleRequested(/* isVisibleRequested */ false); robot.activity().setTopActivityVisible(/* isVisible */ false); robot.checkWindowStateRoundedCornersRadius(/* expected */ 0); - - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ true); - robot.checkWindowStateRoundedCornersRadius(/* expected */ 7); }); } @@ -212,7 +199,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { robot.conf().setLetterboxActivityCornersRadius(15); robot.configureWindowState(); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -236,7 +222,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { robot.conf().setLetterboxActivityCornersRadius(15); robot.configureWindowState(); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -260,7 +245,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { robot.conf().setLetterboxActivityCornersRadius(15); robot.configureWindowState(); robot.activity().createActivityWithComponent(); - robot.setTopActivityInLetterboxAnimation(/* inLetterboxAnimation */ false); robot.activity().setTopActivityVisible(/* isVisible */ true); robot.setIsLetterboxedForFixedOrientationAndAspectRatio(/* inLetterbox */ true); robot.conf().setLetterboxActivityCornersRounded(/* rounded */ true); @@ -362,10 +346,6 @@ public class AppCompatLetterboxPolicyTest extends WindowTestsBase { mWindowState.mInvGlobalScale = scale; } - void setTopActivityInLetterboxAnimation(boolean inLetterboxAnimation) { - doReturn(inLetterboxAnimation).when(activity().top()).isInLetterboxAnimation(); - } - void setTopActivityTransparentPolicyRunning(boolean running) { doReturn(running).when(getTransparentPolicy()).isRunning(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxUtilsTest.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxUtilsTest.java index a4a63d266725..ac707d23b492 100644 --- a/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxUtilsTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatLetterboxUtilsTest.java @@ -63,25 +63,10 @@ public class AppCompatLetterboxUtilsTest extends WindowTestsBase { } @Test - public void positionIsFromTaskWhenLetterboxAnimationIsRunning() { + public void positionIsFromActivity() { runTestScenario((robot) -> { robot.activity().createActivityWithComponent(); robot.setTopActivityLetterboxPolicyRunning(true); - robot.activity().setIsInLetterboxAnimation(true); - robot.activity().configureTaskBounds( - new Rect(/* left */ 100, /* top */ 200, /* right */ 300, /* bottom */ 400)); - robot.getLetterboxPosition(); - - robot.assertPosition(/* x */ 100, /* y */ 200); - }); - } - - @Test - public void positionIsFromActivityWhenLetterboxAnimationIsNotRunning() { - runTestScenario((robot) -> { - robot.activity().createActivityWithComponent(); - robot.setTopActivityLetterboxPolicyRunning(true); - robot.activity().setIsInLetterboxAnimation(false); robot.activity().configureTopActivityBounds( new Rect(/* left */ 200, /* top */ 400, /* right */ 300, /* bottom */ 400)); robot.getLetterboxPosition(); diff --git a/services/tests/wmtests/src/com/android/server/wm/LetterboxAttachInputTest.java b/services/tests/wmtests/src/com/android/server/wm/LetterboxAttachInputTest.java index 51e02405e489..8ee5999e7c24 100644 --- a/services/tests/wmtests/src/com/android/server/wm/LetterboxAttachInputTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/LetterboxAttachInputTest.java @@ -38,7 +38,6 @@ import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.annotations.Presubmit; import android.view.InputWindowHandle; -import android.view.SurfaceControl; import android.view.WindowManager; import com.android.server.testutils.StubTransaction; @@ -76,8 +75,7 @@ public class LetterboxAttachInputTest extends WindowTestsBase { doReturn(0.5f).when(letterboxOverrides).getLetterboxWallpaperDarkScrimAlpha(); mWindowState = createWindowState(); mLetterbox = new Letterbox(mSurfaces, StubTransaction::new, - mock(AppCompatReachabilityPolicy.class), letterboxOverrides, - () -> mock(SurfaceControl.class)); + mock(AppCompatReachabilityPolicy.class), letterboxOverrides); mTransaction = spy(StubTransaction.class); } diff --git a/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java b/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java index a51a44f6167b..e5533b659e03 100644 --- a/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/LetterboxTest.java @@ -68,7 +68,6 @@ public class LetterboxTest { private SurfaceControlMocker mSurfaces; private SurfaceControl.Transaction mTransaction; - private SurfaceControl mParentSurface = mock(SurfaceControl.class); private AppCompatLetterboxOverrides mLetterboxOverrides; private WindowState mWindowState; @@ -84,7 +83,7 @@ public class LetterboxTest { doReturn(0.5f).when(mLetterboxOverrides).getLetterboxWallpaperDarkScrimAlpha(); mWindowState = mock(WindowState.class); mLetterbox = new Letterbox(mSurfaces, StubTransaction::new, - mock(AppCompatReachabilityPolicy.class), mLetterboxOverrides, () -> mParentSurface); + mock(AppCompatReachabilityPolicy.class), mLetterboxOverrides); mTransaction = spy(StubTransaction.class); } @@ -259,22 +258,6 @@ public class LetterboxTest { } @Test - public void testNeedsApplySurfaceChanges_setParentSurface() { - mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000)); - applySurfaceChanges(); - - verify(mTransaction).reparent(mSurfaces.top, mParentSurface); - assertFalse(mLetterbox.needsApplySurfaceChanges()); - - mParentSurface = mock(SurfaceControl.class); - - assertTrue(mLetterbox.needsApplySurfaceChanges()); - - applySurfaceChanges(); - verify(mTransaction).reparent(mSurfaces.top, mParentSurface); - } - - @Test public void testApplySurfaceChanges_cornersNotRounded_surfaceFullWindowSurfaceNotCreated() { mLetterbox.layout(new Rect(0, 0, 10, 10), new Rect(0, 1, 10, 10), new Point(1000, 2000)); applySurfaceChanges(); |