From 96d7f9c2d78ac7772e8a6e5cb1b22d3da033be81 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 10 Jan 2024 17:59:28 +0800 Subject: [PATCH] Fix leakage of GestureExclusionListener So the unregister/register are paired when launcher activity is relaunched: Launcher#onDestroy > mSplitWithKeyboardShortcutController.onDestroy() + > RecentsAnimationDeviceState#destroy + > unregisterExclusionListener Launcher#onCreate > setupViews > new SplitWithKeyboardShortcutController > new RecentsAnimationDeviceState > onDisplayInfoChanged > registerExclusionListener Bug: 319133753 Test: Toggle screen resolution many times and check the amount of DisplayContent#mSystemGestureExclusionListeners. Change-Id: I2fb84415db71aaa14e653fea2592d6b9b5adad59 --- .../util/SplitWithKeyboardShortcutController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java b/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java index cb32c6c1e5..b663970f0e 100644 --- a/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java +++ b/quickstep/src/com/android/quickstep/util/SplitWithKeyboardShortcutController.java @@ -53,6 +53,7 @@ public class SplitWithKeyboardShortcutController { private final QuickstepLauncher mLauncher; private final SplitSelectStateController mController; + private final RecentsAnimationDeviceState mDeviceState; private final OverviewComponentObserver mOverviewComponentObserver; private final int mSplitPlaceholderSize; @@ -62,10 +63,9 @@ public class SplitWithKeyboardShortcutController { SplitSelectStateController controller) { mLauncher = launcher; mController = controller; - RecentsAnimationDeviceState deviceState = new RecentsAnimationDeviceState( - launcher.getApplicationContext()); + mDeviceState = new RecentsAnimationDeviceState(launcher.getApplicationContext()); mOverviewComponentObserver = new OverviewComponentObserver(launcher.getApplicationContext(), - deviceState); + mDeviceState); mSplitPlaceholderSize = mLauncher.getResources().getDimensionPixelSize( R.dimen.split_placeholder_size); @@ -97,6 +97,7 @@ public class SplitWithKeyboardShortcutController { public void onDestroy() { mOverviewComponentObserver.onDestroy(); + mDeviceState.destroy(); } private class SplitWithKeyboardShortcutRecentsAnimationListener implements