From ff2b38e3668f82fc7db2fddf193b72a22b1a37bf Mon Sep 17 00:00:00 2001 From: Luca Zuccarini Date: Thu, 27 Jul 2023 12:11:07 +0000 Subject: [PATCH] Reuse the main depth controller for launch animations. The two controllers don't own any unique state, other than the current depth state. These two _should_ never diverge anyway, because there is only one valid depth at any given time. By using the same controller all the time we can enforce this invariant. Everything else is basically just registered and unregistered listeners, which the main controller already does properly and always has the same state in that regard as the ad-hoc one that we're removing. Finally we don't need to take care of any cleanup explicitly, as we did before. Bug: 293427436 Flag: N/A Test: manual Change-Id: If6ea68847a60254df76e806eac2679ae0415bfe0 --- .../launcher3/QuickstepTransitionManager.java | 9 +++------ .../launcher3/statehandlers/DepthController.java | 12 ------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index cca0fd4e47..4bee82af8c 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1061,9 +1061,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW && BlurUtils.supportsBlursOnWindows(); - LaunchDepthController depthController = new LaunchDepthController(mLauncher); - ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController.stateDepth, - MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher)) + ObjectAnimator backgroundRadiusAnim = + ObjectAnimator.ofFloat(mLauncher.getDepthController().stateDepth, + MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher)) .setDuration(APP_LAUNCH_DURATION); if (allowBlurringLauncher) { @@ -1089,9 +1089,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener new SurfaceControl.Transaction().remove(dimLayer).apply())); } - backgroundRadiusAnim.addListener( - AnimatorListeners.forEndCallback(depthController::dispose)); - return backgroundRadiusAnim; } diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index 882682dc4a..957db6414e 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -94,18 +94,6 @@ public class DepthController extends BaseDepthController implements StateHandler } } - /** - * Cleans up after this controller so it can be garbage collected without leaving traces. - */ - public void dispose() { - removeSecondaryListeners(); - - if (mLauncher.getRootView() != null && mOnAttachListener != null) { - mLauncher.getRootView().removeOnAttachStateChangeListener(mOnAttachListener); - mOnAttachListener = null; - } - } - private void removeSecondaryListeners() { if (mCrossWindowBlurListener != null) { CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener);