From 2b400db392a87cef9c832e1759aa9fc617bd89ec Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 7 May 2025 04:36:04 +0000 Subject: [PATCH] Fix back home animation blurring. Particularly with predictive back in cases that the app doesn't support peeking the home screen, there was a thrashing animation due to a secondary blur animation being applied. So in some cases, it would rapidly alternate between 0 blur and the correct animation blur. This wasn't necessarily user-visible, but likely contributed to some performance jank. Also ensure the scaling workspace blur uses the correct starting depth and duration. Demo: https://drive.google.com/file/d/1AffSvzlXycg8Yl4ULpctKADO6IdvvO3m/view?usp=drive_link&resourcekey=0--zqQ341w7U3MhRBwSYrsyA Bug: 407534544 Test: Manual (predictive back, back without predictive peek, home) Flag: com.android.launcher3.predictive_back_to_home_blur Flag: com.android.launcher3.all_apps_blur Change-Id: I76ed59e99aaef5bd44e8f5b0290f01763a8d4b0f --- .../launcher3/QuickstepTransitionManager.java | 6 ------ .../quickstep/LauncherBackAnimationController.java | 13 ++++++++++--- .../quickstep/util/ScalingWorkspaceRevealAnim.kt | 2 ++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 1a616d0837..dc10c0f638 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1761,12 +1761,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener true /* animateOverviewScrim */, launcherView).getAnimators()); } - if (!areAllTargetsTranslucent(appTargets)) { - anim.play(ObjectAnimator.ofFloat(mLauncher.getDepthController().stateDepth, - MULTI_PROPERTY_VALUE, - BACKGROUND_APP.getDepth(mLauncher), NORMAL.getDepth(mLauncher))); - } - // We play StaggeredWorkspaceAnim as a part of the closing window animation. playWorkspaceReveal = false; } diff --git a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java index 1328699082..11f1b6d37c 100644 --- a/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java +++ b/quickstep/src/com/android/quickstep/LauncherBackAnimationController.java @@ -25,6 +25,7 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE; import static com.android.launcher3.BaseActivity.INVISIBLE_ALL; import static com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS; import static com.android.launcher3.BaseActivity.PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION; +import static com.android.launcher3.Flags.enableOverviewBackgroundWallpaperBlur; import static com.android.window.flags.Flags.predictiveBackThreeButtonNav; import static com.android.window.flags.Flags.removeDepartTargetFromMotion; @@ -98,7 +99,6 @@ public class LauncherBackAnimationController { Flags.predictiveBackToHomePolish() ? 0.75f : 0.85f; private static final float MAX_SCRIM_ALPHA_DARK = 0.8f; private static final float MAX_SCRIM_ALPHA_LIGHT = 0.2f; - private static final int MAX_BLUR_RADIUS = 20; private static final int MIN_BLUR_RADIUS_PRE_COMMIT = 10; private final QuickstepTransitionManager mQuickstepTransitionManager; @@ -130,6 +130,7 @@ public class LauncherBackAnimationController { private ValueAnimator mScrimAlphaAnimator; private float mScrimAlpha; private boolean mOverridingStatusBarFlags; + private int mMaxBlurRadius; private int mLastBlurRadius = 0; private final ComponentCallbacks mComponentCallbacks = new ComponentCallbacks() { @@ -411,7 +412,7 @@ public class LauncherBackAnimationController { final float[] colorComponents = new float[] { 0f, 0f, 0f }; mScrimAlpha = (isDarkTheme) ? MAX_SCRIM_ALPHA_DARK : MAX_SCRIM_ALPHA_LIGHT; - setBlur(MAX_BLUR_RADIUS); + setBlur(mMaxBlurRadius); mTransaction .setColor(mScrimLayer, colorComponents) .setAlpha(mScrimLayer, mScrimAlpha) @@ -439,7 +440,7 @@ public class LauncherBackAnimationController { // Scrim hasn't been attached yet. Let's attach it. addScrimLayer(); } else { - mLastBlurRadius = (int) lerp(MAX_BLUR_RADIUS, MIN_BLUR_RADIUS_PRE_COMMIT, progress); + mLastBlurRadius = (int) lerp(mMaxBlurRadius, MIN_BLUR_RADIUS_PRE_COMMIT, progress); setBlur(mLastBlurRadius); } float screenWidth = mStartRect.width(); @@ -626,6 +627,12 @@ public class LauncherBackAnimationController { : 0; mWindowScaleStartCornerRadius = QuickStepContract.getWindowCornerRadius(mLauncher); mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mLauncher); + if (Flags.allAppsBlur() || enableOverviewBackgroundWallpaperBlur()) { + mMaxBlurRadius = mLauncher.getResources().getDimensionPixelSize( + R.dimen.max_depth_blur_radius_enhanced); + } else { + mMaxBlurRadius = mLauncher.getResources().getInteger(R.integer.max_depth_blur_radius); + } } /** diff --git a/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt b/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt index b1263ff441..273bba8b5f 100644 --- a/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt +++ b/quickstep/src/com/android/quickstep/util/ScalingWorkspaceRevealAnim.kt @@ -147,10 +147,12 @@ class ScalingWorkspaceRevealAnim( } val transitionConfig = StateAnimationConfig() + transitionConfig.duration = SCALE_DURATION_MS // Match the Wallpaper animation to the rest of the content. val depthController = (launcher as? QuickstepLauncher)?.depthController transitionConfig.setInterpolator(StateAnimationConfig.ANIM_DEPTH, SCALE_INTERPOLATOR) + depthController?.stateDepth?.value = LauncherState.BACKGROUND_APP.getDepth(launcher) depthController?.setStateWithAnimation(LauncherState.NORMAL, transitionConfig, animation) // Make sure that the contrast scrim animates correctly if needed.