|
|
@@ -11,6 +11,7 @@ import org.json.JSONObject;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Timer;
|
|
|
|
|
|
import de.robv.android.xposed.XposedBridge;
|
|
|
import de.robv.android.xposed.XposedHelpers;
|
|
|
@@ -48,7 +49,7 @@ public class BaseHook {
|
|
|
|
|
|
private JSONObject config = null;
|
|
|
private File configFile = null;
|
|
|
- private ConfigFileObserver configFileObserver = null;
|
|
|
+ private Timer timer;
|
|
|
|
|
|
public BaseHook(ClassLoader classLoader) {
|
|
|
this.classLoader = classLoader;
|
|
|
@@ -93,17 +94,16 @@ public class BaseHook {
|
|
|
|
|
|
public void setConfigFile(File configFile) {
|
|
|
this.configFile = configFile;
|
|
|
- }
|
|
|
-
|
|
|
- public void readAndObserve() {
|
|
|
- if (configFileObserver != null) {
|
|
|
- configFileObserver.stopWatching();
|
|
|
- }
|
|
|
- if (configFile != null) {
|
|
|
- readConfig();
|
|
|
- configFileObserver = new ConfigFileObserver(configFile, () -> readConfig());
|
|
|
- configFileObserver.startWatching();
|
|
|
+ if (timer != null) {
|
|
|
+ timer.cancel();
|
|
|
}
|
|
|
+ timer = new Timer();
|
|
|
+ timer.schedule(new java.util.TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ readConfig();
|
|
|
+ }
|
|
|
+ }, 0, 3000);
|
|
|
}
|
|
|
|
|
|
public void readConfig() {
|
|
|
@@ -129,7 +129,7 @@ public class BaseHook {
|
|
|
public String getProperty(String key, String defaultValue) {
|
|
|
try {
|
|
|
if (config == null) {
|
|
|
- readAndObserve();
|
|
|
+ readConfig();
|
|
|
}
|
|
|
if (config != null && config.has(key)) {
|
|
|
return config.optString(key, defaultValue);
|