summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-04-20 18:20:05 +0200
committerParménides GV <parmegv@sdf.org>2015-04-22 12:36:39 +0200
commitd486768d6b0664d9032605897c8f1847ef4e3a39 (patch)
treeff82a890fa6477d3c70d70ef33b8044c88fa53ff /app/src/main/java/se/leap/bitmaskclient/eip
parent8862197a0a138f942e9c76a29aaf189f4c5141b4 (diff)
Remove textual status.
I had a difficult moment trying to detect if the LogWindow had already been shown after an error. Finally, I implemented a LogWindowWrapper which contains a field for the reason it was shown, so that we can check if the previous error is the same than the current one leading to the avoidance of the second LogWindow. For this to work, we need to reset that reason each time we trigger a new vpn state (i.e. each time the user taps on the vpn icon).
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java15
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java4
2 files changed, 15 insertions, 4 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
index b7f95277..356cf6b0 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
@@ -137,18 +137,25 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
}
public boolean errorInLast(int lines, Context context) {
- boolean result = false;
+ return !lastError(lines, context).isEmpty();
+ }
+
+ public String lastError(int lines, Context context) {
+ String error = "";
+
String[] error_keywords = {"error", "ERROR", "fatal", "FATAL"};
VpnStatus.LogItem[] log = VpnStatus.getlogbuffer();
String message = "";
for (int i = 1; i <= lines && log.length > i; i++) {
- message = log[log.length - i].getString(context);
+ VpnStatus.LogItem log_item = log[log.length - i];
+ message = log_item.getString(context);
for (int j = 0; j < error_keywords.length; j++)
if (message.contains(error_keywords[j]))
- result = true;
+ error = message;
}
- return result;
+
+ return error;
}
@Override
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
index dac92fe2..cbf0fed2 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/VoidVpnService.java
@@ -50,6 +50,10 @@ public class VoidVpnService extends VpnService {
closeFd();
}
+ public static boolean isRunning() throws NullPointerException {
+ return thread.isAlive() && fd != null;
+ }
+
private static void closeFd() {
try {
if (fd != null)