From 9913da0b247c10bd85bb961752232de5145e2304 Mon Sep 17 00:00:00 2001 From: tehcneko <7764726+tehcneko@users.noreply.github.com> Date: Wed, 17 Feb 2021 16:44:28 +0800 Subject: [PATCH] [core] Fix config manager --- .../java/io/github/lsposed/lspd/service/ConfigManager.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java b/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java index 8bc8127a..a19ce94c 100644 --- a/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java +++ b/core/src/main/java/io/github/lsposed/lspd/service/ConfigManager.java @@ -83,7 +83,7 @@ public class ConfigManager { private void writeText(@NonNull File file, String value) { try { - Files.write(file.toPath(), value.getBytes(), StandardOpenOption.CREATE_NEW); + Files.write(file.toPath(), value.getBytes(), StandardOpenOption.CREATE); } catch (IOException e) { Log.e(TAG, Log.getStackTraceString(e)); } @@ -104,7 +104,7 @@ public class ConfigManager { } private synchronized void updateConfig() { - resourceHook = resourceHookSwitch.exists(); + resourceHook = readInt(resourceHookSwitch, 0) == 1; variant = readInt(variantSwitch, -1); verboseLog = readInt(verboseLogSwitch, 0) == 1; miscPath = "/data/misc/" + readText(miscFile, "lspd"); @@ -336,14 +336,17 @@ public class ConfigManager { public void setResourceHook(boolean resourceHook) { writeInt(resourceHookSwitch, resourceHook ? 1 : 0); + this.resourceHook = resourceHook; } public void setVerboseLog(boolean verboseLog) { writeInt(verboseLogSwitch, verboseLog ? 1 : 0); + this.verboseLog = verboseLog; } public void setVariant(int variant) { writeInt(variantSwitch, variant); + this.variant = variant; } public boolean isPermissive() {