summaryrefslogtreecommitdiff
path: root/src/se/leap/openvpn/OpenVpnService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/se/leap/openvpn/OpenVpnService.java')
-rw-r--r--src/se/leap/openvpn/OpenVpnService.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/se/leap/openvpn/OpenVpnService.java b/src/se/leap/openvpn/OpenVpnService.java
index bec7dcee..620de204 100644
--- a/src/se/leap/openvpn/OpenVpnService.java
+++ b/src/se/leap/openvpn/OpenVpnService.java
@@ -7,7 +7,6 @@ import java.util.Vector;
import se.leap.bitmaskclient.Dashboard;
import se.leap.bitmaskclient.R;
-
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
@@ -103,12 +102,16 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
}
}
- private void showNotification(String msg, String tickerText, boolean lowpriority, long when, boolean persistant) {
+ private void showNotification(String state, String msg, String tickerText, boolean lowpriority, long when, boolean persistant) {
String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
-
-
- int icon = R.drawable.ic_stat_vpn;
+ int icon;
+ if (state.equals("NOPROCESS") || state.equals("AUTH_FAILED") || state.equals("NONETWORK")){
+ icon = R.drawable.ic_vpn_disconnected;
+ }else{
+ icon = R.drawable.ic_stat_vpn;
+ }
+
android.app.Notification.Builder nbuilder = new Notification.Builder(this);
nbuilder.setContentTitle(getString(R.string.notifcation_title,mProfile.mName));
@@ -465,8 +468,7 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
// If the process is not running, ignore any state,
// Notification should be invisible in this state
if(mProcessThread==null)
- return;
-
+ return;
if("CONNECTED".equals(state)) {
mNotificationManager.cancel(OPENVPN_STATUS);
} else if(!"BYTECOUNT".equals(state)) {
@@ -475,8 +477,14 @@ public class OpenVpnService extends VpnService implements StateListener, Callbac
// This also mean we are no longer connected, ignore bytecount messages until next
// CONNECTED
String ticker = getString(resid);
- boolean persist = ("NOPROCESS".equals(state)) ? false : true;
- showNotification(getString(resid) +" " + logmessage,ticker,false,0,persist);
+ boolean persist = false;
+ if (("NOPROCESS".equals(state) ) || ("EXIT").equals(state)){
+ showNotification(state, getString(R.string.eip_state_not_connected), ticker, false, 0, persist);
+ }
+ else{
+ persist = true;
+ showNotification(state, getString(resid) +" " + logmessage,ticker,false,0,persist);
+ }
}
}