From 75845ed9a8f38468d70f7f9b0764dc8007c0a70d Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Fri, 26 Feb 2021 00:19:34 +0000 Subject: [PATCH] Adds a removeChangeListener to FeatureFlags$BooleanFlag. This will help us avoid leaks, etc. Also changes ENABLE_SMARTSPACE_ENHANCED back to a DeviceFlag Bug: 181194850 Bug: 181077020 Test: atest NexusLauncherOutOfProcTests:com.android.launcher3.memory.MemoryTests -- --abi armeabi-v7a Change-Id: I6f54af3e6b6302a073b8b7d448ff72b05a803d8f --- .../src/com/android/launcher3/uioverrides/DeviceFlag.java | 8 ++++++++ src/com/android/launcher3/config/FeatureFlags.java | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/DeviceFlag.java b/quickstep/src/com/android/launcher3/uioverrides/DeviceFlag.java index 010694b0c5..bb1f6fcc00 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/DeviceFlag.java +++ b/quickstep/src/com/android/launcher3/uioverrides/DeviceFlag.java @@ -60,6 +60,14 @@ public class DeviceFlag extends DebugFlag { mListeners.add(r); } + @Override + public void removeChangeListener(Runnable r) { + if (mListeners == null) { + return; + } + mListeners.remove(r); + } + private void registerDeviceConfigChangedListener(Context context) { DeviceConfig.addOnPropertiesChangedListener( NAMESPACE_LAUNCHER, diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index ef7bdf41ca..e406e9b8d6 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -158,7 +158,7 @@ public final class FeatureFlags { "ENABLE_SMARTSPACE_UNIVERSAL", false, "Replace Smartspace with a version rendered by System UI."); - public static final BooleanFlag ENABLE_SMARTSPACE_ENHANCED = getDebugFlag( + public static final BooleanFlag ENABLE_SMARTSPACE_ENHANCED = new DeviceFlag( "ENABLE_SMARTSPACE_ENHANCED", false, "Replace Smartspace with the enhanced version. " + "Ignored if ENABLE_SMARTSPACE_UNIVERSAL is enabled."); @@ -263,6 +263,8 @@ public final class FeatureFlags { } public void addChangeListener(Context context, Runnable r) { } + + public void removeChangeListener(Runnable r) {} } public static class DebugFlag extends BooleanFlag {