summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/tests/coretests/src/android/provider/DeviceConfigTest.java18
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java11
2 files changed, 26 insertions, 3 deletions
diff --git a/core/tests/coretests/src/android/provider/DeviceConfigTest.java b/core/tests/coretests/src/android/provider/DeviceConfigTest.java
index 84c42dbc14e7..d649b945492b 100644
--- a/core/tests/coretests/src/android/provider/DeviceConfigTest.java
+++ b/core/tests/coretests/src/android/provider/DeviceConfigTest.java
@@ -376,6 +376,24 @@ public class DeviceConfigTest {
}
@Test
+ public void resetToDefault_makeDefault() {
+ DeviceConfig.setProperty(NAMESPACE, KEY, VALUE, true);
+ assertThat(DeviceConfig.getProperty(NAMESPACE, KEY)).isEqualTo(VALUE);
+
+ DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS, NAMESPACE);
+ assertThat(DeviceConfig.getProperty(NAMESPACE, KEY)).isEqualTo(VALUE);
+ }
+
+ @Test
+ public void resetToDefault_doNotMakeDefault() {
+ DeviceConfig.setProperty(NAMESPACE, KEY, VALUE, false);
+ assertThat(DeviceConfig.getProperty(NAMESPACE, KEY)).isEqualTo(VALUE);
+
+ DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS, NAMESPACE);
+ assertThat(DeviceConfig.getProperty(NAMESPACE, KEY)).isNull();
+ }
+
+ @Test
public void getProperties_fullNamespace() {
Properties properties = DeviceConfig.getProperties(NAMESPACE);
assertThat(properties.getKeyset()).isEmpty();
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
index 9934e59d8d56..cd62420f39ac 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
@@ -425,7 +425,8 @@ final class SettingsState {
}
newState = oldState;
} else {
- newState = new Setting(name, value, makeDefault, packageName, tag);
+ newState = new Setting(name, value, makeDefault, packageName, tag,
+ forceNonSystemPackage);
mSettings.put(name, newState);
}
@@ -1173,11 +1174,15 @@ final class SettingsState {
public Setting(String name, String value, boolean makeDefault, String packageName,
String tag) {
+ this(name, value, makeDefault, packageName, tag, false);
+ }
+
+ Setting(String name, String value, boolean makeDefault, String packageName,
+ String tag, boolean forceNonSystemPackage) {
this.name = name;
// overrideableByRestore = true as the first initialization isn't considered a
// modification.
- update(value, makeDefault, packageName, tag, false,
- /* overrideableByRestore */ true);
+ update(value, makeDefault, packageName, tag, forceNonSystemPackage, true);
}
public Setting(String name, String value, String defaultValue,