Cleanup SettingsChangeLogger onClose()
* Correct name for San*d*box
Bug: 280463854
Flag: none
Test: v2/gnl-eng/unbundled/launcher/nexus_unit_test_multi_device_platform
Change-Id: I2446871c8ea0b146ccfa2ea7caa1727aec42dd42
diff --git a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java
index 3d5c143..d3a01f2 100644
--- a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java
+++ b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java
@@ -50,6 +50,7 @@
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.NavigationMode;
+import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.SettingsCache;
import org.xmlpull.v1.XmlPullParser;
@@ -62,7 +63,8 @@
* Utility class to log launcher settings changes
*/
public class SettingsChangeLogger implements
- DisplayController.DisplayInfoChangeListener, OnSharedPreferenceChangeListener {
+ DisplayController.DisplayInfoChangeListener, OnSharedPreferenceChangeListener,
+ SafeCloseable {
/**
* Singleton instance
@@ -188,6 +190,12 @@
prefs.getBoolean(key, lp.defaultValue) ? lp.eventIdOn : lp.eventIdOff));
}
+ @Override
+ public void close() {
+ getPrefs(mContext).unregisterOnSharedPreferenceChangeListener(this);
+ getDevicePrefs(mContext).unregisterOnSharedPreferenceChangeListener(this);
+ }
+
private static class LoggablePref {
public boolean defaultValue;
public int eventIdOn;
diff --git a/tests/src/com/android/launcher3/util/LauncherModelHelper.java b/tests/src/com/android/launcher3/util/LauncherModelHelper.java
index bf31e39..0a5a0e3 100644
--- a/tests/src/com/android/launcher3/util/LauncherModelHelper.java
+++ b/tests/src/com/android/launcher3/util/LauncherModelHelper.java
@@ -113,7 +113,7 @@
private final HashMap<Class, HashMap<String, Field>> mFieldCache = new HashMap<>();
private final MockContentResolver mMockResolver = new MockContentResolver();
public final TestLauncherProvider provider;
- public final SanboxModelContext sandboxContext;
+ public final SandboxModelContext sandboxContext;
public final long defaultProfileId;
@@ -128,7 +128,7 @@
Settings.Global.getString(context.getContentResolver(), "test");
provider = new TestLauncherProvider();
- sandboxContext = new SanboxModelContext();
+ sandboxContext = new SandboxModelContext();
defaultProfileId = UserCache.INSTANCE.get(sandboxContext)
.getSerialNumberForUser(Process.myUserHandle());
setupProvider(LauncherProvider.AUTHORITY, provider);
@@ -446,13 +446,13 @@
return success;
}
- public class SanboxModelContext extends SandboxContext {
+ public class SandboxModelContext extends SandboxContext {
private final ArrayMap<String, Object> mSpiedServices = new ArrayMap<>();
private final PackageManager mPm;
private final File mDbDir;
- SanboxModelContext() {
+ SandboxModelContext() {
super(ApplicationProvider.getApplicationContext(),
UserCache.INSTANCE, InstallSessionHelper.INSTANCE, LauncherPrefs.INSTANCE,
LauncherAppState.INSTANCE, InvariantDeviceProfile.INSTANCE,
@@ -463,7 +463,7 @@
mDbDir = new File(getCacheDir(), UUID.randomUUID().toString());
}
- public SanboxModelContext allow(MainThreadInitializedObject object) {
+ public SandboxModelContext allow(MainThreadInitializedObject object) {
mAllowedObjects.add(object);
return this;
}