Merge "Cleanup SettingsChangeLogger onClose()" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
87abc0644b
@@ -50,6 +50,7 @@ import com.android.launcher3.util.DisplayController;
|
||||
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 @@ import java.util.Optional;
|
||||
* Utility class to log launcher settings changes
|
||||
*/
|
||||
public class SettingsChangeLogger implements
|
||||
DisplayController.DisplayInfoChangeListener, OnSharedPreferenceChangeListener {
|
||||
DisplayController.DisplayInfoChangeListener, OnSharedPreferenceChangeListener,
|
||||
SafeCloseable {
|
||||
|
||||
/**
|
||||
* Singleton instance
|
||||
@@ -188,6 +190,12 @@ public class SettingsChangeLogger implements
|
||||
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;
|
||||
|
||||
@@ -113,7 +113,7 @@ public class LauncherModelHelper {
|
||||
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 @@ public class LauncherModelHelper {
|
||||
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 @@ public class LauncherModelHelper {
|
||||
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 @@ public class LauncherModelHelper {
|
||||
mDbDir = new File(getCacheDir(), UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
public SanboxModelContext allow(MainThreadInitializedObject object) {
|
||||
public SandboxModelContext allow(MainThreadInitializedObject object) {
|
||||
mAllowedObjects.add(object);
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user