summaryrefslogtreecommitdiff
path: root/src/org/protonaosp/deviceconfig/BootReceiver.java
diff options
context:
space:
mode:
authorDanny Lin <danny@kdrag0n.dev>2022-03-08 20:58:50 -0800
committerSemavi Ulusoy <doc.divxm@gmail.com>2022-03-24 21:53:57 +0300
commit59471670139aea2074e57001f5dd49453c031040 (patch)
tree6fafdc73909bcd9b50a5acf7c26c2db4693928c5 /src/org/protonaosp/deviceconfig/BootReceiver.java
parent7d4d85eb342fb57d280c63e435f7fbd23494f822 (diff)
Add soft config type for user-persistent settingsHEADu14.0t13.0s12.1
Some device configs, such as the location indicator flag, can easily be reused for user-facing settings rather than adding a new setting and hook it up. To accommodate such cases, add a new "soft" config type where configs are only set on boot if they don't already have a value. This allows provisioning an initial value while allowing user choices to persist after that. Change-Id: I2c88fc34d2609c1953b385abc6c151207779009a
Diffstat (limited to 'src/org/protonaosp/deviceconfig/BootReceiver.java')
-rw-r--r--src/org/protonaosp/deviceconfig/BootReceiver.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/org/protonaosp/deviceconfig/BootReceiver.java b/src/org/protonaosp/deviceconfig/BootReceiver.java
index 12ee2d2..d241ff3 100644
--- a/src/org/protonaosp/deviceconfig/BootReceiver.java
+++ b/src/org/protonaosp/deviceconfig/BootReceiver.java
@@ -34,11 +34,13 @@ public class BootReceiver extends BroadcastReceiver {
}
private void updateDefaultConfigs(Context context) {
- updateConfig(context, R.array.configs_base);
- updateConfig(context, R.array.configs_device);
+ updateConfig(context, R.array.configs_base, false);
+ updateConfig(context, R.array.configs_base_soft, true);
+
+ updateConfig(context, R.array.configs_device, false);
}
- private void updateConfig(Context context, int configArray) {
+ private void updateConfig(Context context, int configArray, boolean isSoft) {
// Set current properties
String[] rawProperties = context.getResources().getStringArray(configArray);
for (String property : rawProperties) {
@@ -54,7 +56,10 @@ public class BootReceiver extends BroadcastReceiver {
value = kv[1];
}
- DeviceConfig.setProperty(namespace, key, value, false);
+ // Skip soft configs that already have values
+ if (!isSoft || DeviceConfig.getString(namespace, key, null) == null) {
+ DeviceConfig.setProperty(namespace, key, value, false);
+ }
}
}
}