From 0afb7553a9ff35df36cfc8ade9f053a61510e332 Mon Sep 17 00:00:00 2001 From: PeratX <1215714524@qq.com> Date: Sat, 10 Jun 2017 19:55:37 +0800 Subject: [PATCH] Added config file existence check --- app/build.gradle | 2 +- .../itxtech/daedalus/fragment/DnsTestFragment.java | 2 +- .../org/itxtech/daedalus/util/Configurations.java | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5ddd0a9..0605f26 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,7 @@ dependencies { compile 'org.pcap4j:pcap4j-core:1.7.0' compile 'org.pcap4j:pcap4j-packetfactory-propertiesbased:1.7.0' compile 'de.measite.minidns:minidns-core:0.2.1' - compile 'com.google.code.gson:gson:2.8.0' + compile 'com.google.code.gson:gson:2.8.1' compile 'com.google.firebase:firebase-crash:10.2.6' diff --git a/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java b/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java index 7bb46bc..8df053e 100644 --- a/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java +++ b/app/src/main/java/org/itxtech/daedalus/fragment/DnsTestFragment.java @@ -130,7 +130,7 @@ public class DnsTestFragment extends ToolbarFragment { private StringBuilder testServer(DNSQuery dnsQuery, Record.TYPE type, String server, String domain, StringBuilder testText) { - Logger.debug("Testing DNS server" + server); + Logger.debug("Testing DNS server " + server); testText.append(getString(R.string.test_domain)).append(" ").append(domain).append("\n").append(getString(R.string.test_dns_server)).append(" ").append(server); mHandler.obtainMessage(DnsTestHandler.MSG_DISPLAY_STATUS, testText.toString()).sendToTarget(); diff --git a/app/src/main/java/org/itxtech/daedalus/util/Configurations.java b/app/src/main/java/org/itxtech/daedalus/util/Configurations.java index 8402af3..7dd91cb 100644 --- a/app/src/main/java/org/itxtech/daedalus/util/Configurations.java +++ b/app/src/main/java/org/itxtech/daedalus/util/Configurations.java @@ -125,11 +125,13 @@ public class Configurations { public static Configurations load(File file) { Configurations.file = file; Configurations config = null; - try { - config = Daedalus.parseJson(Configurations.class, new JsonReader(new FileReader(file))); - Logger.info("Loading configuration successfully from " + file); - } catch (Exception e) { - Logger.logException(e); + if (file.exists()) { + try { + config = Daedalus.parseJson(Configurations.class, new JsonReader(new FileReader(file))); + Logger.info("Loading configuration successfully from " + file); + } catch (Exception e) { + Logger.logException(e); + } } if (config == null) {