summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-04-20 19:55:00 +0200
committerParménides GV <parmegv@sdf.org>2015-04-22 12:36:39 +0200
commit0a7cb34e42fc3b8bf8623bda45cd4d76079a96c4 (patch)
tree8547d79bf71a99ff091272ca56631b856a197651
parentd486768d6b0664d9032605897c8f1847ef4e3a39 (diff)
Always show the log if an error happens.
I've removed the "reason" management in LogWindowWrapper, letting EipStatus display the error log message only if it's a new one (based on the log buffer position).
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/EipFragment.java7
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java11
2 files changed, 10 insertions, 8 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
index c92ae3cd..a13cab09 100644
--- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java
@@ -103,7 +103,6 @@ public class EipFragment extends Fragment implements Observer {
@OnClick(R.id.vpn_Status_Image)
void handleIcon() {
- LogWindowWrapper.getInstance(dashboard.getApplicationContext()).clearReason();
if (eip_status.isConnected() || eip_status.isConnecting())
handleSwitchOff();
else
@@ -243,11 +242,9 @@ public class EipFragment extends Fragment implements Observer {
private void handleNewState(EipStatus eip_status) {
Context context = dashboard.getApplicationContext();
String error = eip_status.lastError(5, context);
- LogWindowWrapper log_window = LogWindowWrapper.getInstance(context);
- if (!error.isEmpty() && log_window != null && !log_window.reason().equalsIgnoreCase(error)) {
- log_window.showLog();
- log_window.showedBecauseOf(error);
+ if (!error.isEmpty()) {
+ dashboard.showLog();
VoidVpnService.stop();
}
adjustSwitch();
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 356cf6b0..4bfef1cb 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java
@@ -31,7 +31,7 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
wants_to_disconnect = false,
is_connecting = false;
-
+ int last_error_line = 0;
private String state, log_message;
private int localized_res_id;
@@ -146,13 +146,18 @@ public class EipStatus extends Observable implements VpnStatus.StateListener {
String[] error_keywords = {"error", "ERROR", "fatal", "FATAL"};
VpnStatus.LogItem[] log = VpnStatus.getlogbuffer();
+ if(log.length < last_error_line)
+ last_error_line = 0;
String message = "";
for (int i = 1; i <= lines && log.length > i; i++) {
- VpnStatus.LogItem log_item = log[log.length - i];
+ int line = log.length - i;
+ VpnStatus.LogItem log_item = log[line];
message = log_item.getString(context);
for (int j = 0; j < error_keywords.length; j++)
- if (message.contains(error_keywords[j]))
+ if (message.contains(error_keywords[j]) && line > last_error_line) {
error = message;
+ last_error_line = line;
+ }
}
return error;