summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Lin <danny@kdrag0n.dev>2020-12-12 01:49:16 -0800
committerDanny Lin <danny@kdrag0n.dev>2020-12-12 16:43:26 -0800
commit2e8d1254157701f4ba1aef7838e6bbc0fd3957dd (patch)
tree38996626a8fb6ad7971a2cb41201a9cc428f5442
parent3b66c3e1b7e0e5bf94873a55b61639744d6a3deb (diff)
SimpleDeviceConfig: Separate base and device configs
Some devices may want to add device-specific DeviceConfig values overlayed in the device tree while retaining the base system configs provided by the ROM.
-rw-r--r--res/values/config.xml3
-rw-r--r--src/org/protonaosp/deviceconfig/BootReceiver.java11
2 files changed, 10 insertions, 4 deletions
diff --git a/res/values/config.xml b/res/values/config.xml
index cc02141..88ac362 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -15,5 +15,6 @@
limitations under the License.
-->
<resources>
- <string-array name="device_config" />
+ <string-array name="configs_base" />
+ <string-array name="configs_device" />
</resources>
diff --git a/src/org/protonaosp/deviceconfig/BootReceiver.java b/src/org/protonaosp/deviceconfig/BootReceiver.java
index 2be918a..a2aca63 100644
--- a/src/org/protonaosp/deviceconfig/BootReceiver.java
+++ b/src/org/protonaosp/deviceconfig/BootReceiver.java
@@ -29,13 +29,18 @@ public class BootReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
new Thread(() -> {
Log.i(TAG, "Updating device config at boot");
- updateConfig(context);
+ updateDefaultConfigs(context);
}).start();
}
- private void updateConfig(Context context) {
+ private void updateDefaultConfigs(Context context) {
+ updateConfig(context, R.array.configs_base);
+ updateConfig(context, R.array.configs_device);
+ }
+
+ private void updateConfig(Context context, int configArray) {
// Set current properties
- String[] rawProperties = context.getResources().getStringArray(R.array.device_config);
+ String[] rawProperties = context.getResources().getStringArray(configArray);
for (String property : rawProperties) {
String[] kv = property.split("=");
String fullKey = kv[0];