From e363a611d2e9771337189e006e0fdbc6da08b3b7 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 3 Jan 2024 14:58:08 -0800 Subject: [PATCH] Null out launcher reference to prevent leak Bug: 314806687 Flag: None Test: Enabled flag and played with taskbar/home transitions, seemed fine Change-Id: I86ab417eccf1fd6255195025890a1b93bf5d3bb4 --- .../android/launcher3/HomeTransitionController.java | 10 ++++------ .../launcher3/uioverrides/QuickstepLauncher.java | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/quickstep/src/com/android/launcher3/HomeTransitionController.java b/quickstep/src/com/android/launcher3/HomeTransitionController.java index b264115bf3..2b50283acd 100644 --- a/quickstep/src/com/android/launcher3/HomeTransitionController.java +++ b/quickstep/src/com/android/launcher3/HomeTransitionController.java @@ -28,19 +28,16 @@ import com.android.wm.shell.transition.IHomeTransitionListener; */ public class HomeTransitionController { - private final QuickstepLauncher mLauncher; + @Nullable private QuickstepLauncher mLauncher; @Nullable private IHomeTransitionListener mHomeTransitionListener; - public HomeTransitionController(QuickstepLauncher launcher) { + public void registerHomeTransitionListener(QuickstepLauncher launcher) { mLauncher = launcher; - } - - public void registerHomeTransitionListener() { mHomeTransitionListener = new IHomeTransitionListener.Stub() { @Override public void onHomeVisibilityChanged(boolean isVisible) { MAIN_EXECUTOR.execute(() -> { - if (mLauncher.getTaskbarUIController() != null) { + if (mLauncher != null && mLauncher.getTaskbarUIController() != null) { mLauncher.getTaskbarUIController().onLauncherVisibilityChanged(isVisible); } }); @@ -53,5 +50,6 @@ public class HomeTransitionController { public void unregisterHomeTransitionListener() { SystemUiProxy.INSTANCE.get(mLauncher).setHomeTransitionListener(null); mHomeTransitionListener = null; + mLauncher = null; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index a065387e2f..f45ddb6754 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -266,8 +266,8 @@ public class QuickstepLauncher extends Launcher { mAppTransitionManager.registerRemoteTransitions(); if (FeatureFlags.enableHomeTransitionListener()) { - mHomeTransitionController = new HomeTransitionController(this); - mHomeTransitionController.registerHomeTransitionListener(); + mHomeTransitionController = new HomeTransitionController(); + mHomeTransitionController.registerHomeTransitionListener(this); } mTISBindHelper = new TISBindHelper(this, this::onTISConnected);