diff options
author | Parménides GV <parmegv@sdf.org> | 2015-03-20 13:22:19 +0100 |
---|---|---|
committer | Parménides GV <parmegv@sdf.org> | 2015-03-20 13:22:19 +0100 |
commit | 966ac406322f0c6b36b2fe746cd3f738bd0f5a00 (patch) | |
tree | d500a1b8656e40234b2091f225d08b4f33fbe724 | |
parent | 30d92be6e9401926d9efaafc332d764211d882e6 (diff) |
Detect error in last 5 lines of the log.
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/EipFragment.java | 5 | ||||
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java | 16 |
2 files changed, 14 insertions, 7 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java index 5e5b76b2..ed507de4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/EipFragment.java @@ -53,7 +53,6 @@ public class EipFragment extends Fragment implements Observer { private boolean is_starting_to_connect; private boolean wants_to_connect; - @Override public void onAttach(Activity activity) { super.onAttach(activity); @@ -293,12 +292,10 @@ public class EipFragment extends Fragment implements Observer { private void setDisconnectedUI(){ hideProgressBar(); adjustSwitch(); - String last_log_message = eip_status.getLastLogMessage(dashboard.getApplicationContext()); - if((last_log_message.contains("error") || last_log_message.contains("ERROR")) + if(eip_status.errorInLast(5, dashboard.getApplicationContext()) && !status_message.getText().toString().equalsIgnoreCase(dashboard.getString(R.string.eip_state_not_connected))){ dashboard.showLog(); } - status_message.setText(dashboard.getString(R.string.eip_state_not_connected)); } private void 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 14158696..adbbaef3 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipStatus.java @@ -136,9 +136,19 @@ public class EipStatus extends Observable implements VpnStatus.StateListener { EipStatus.level = level; } - public String getLastLogMessage(Context context) { - VpnStatus.LogItem[] log = VpnStatus.getlogbuffer(); - return log[log.length-1].getString(context); + public boolean errorInLast(int lines, Context context) { + boolean result = false; + String[] error_keywords = {"error", "ERROR", "fatal", "FATAL"}; + + VpnStatus.LogItem[] log = VpnStatus.getlogbuffer(); + String message = ""; + for (int i = 0; i < lines; i++) { + message = log[log.length-1].getString(context); + for(int j = 0; j < error_keywords.length; j++) + if(message.contains(error_keywords[i])) + result = true; + } + return result; } @Override |