summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-09-09 13:22:22 +0200
committerArne Schwabe <arne@rfc2549.org>2012-09-09 13:22:22 +0200
commita5d8b273aba8015eb59029870b1d0c7fce6d168f (patch)
treeec7eceee7bb2f9ee7e432400e0be9e20c66449b7 /src/de/blinkt/openvpn
parent72b1fd17c5178b0faf7a0138c85c570e7e598f9f (diff)
Give all traffic notifications the same time, fixes the blinking notification for me (closes issue #75)
Diffstat (limited to 'src/de/blinkt/openvpn')
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index c1fd1710..ca199cc6 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -60,6 +60,8 @@ public class OpenVpnService extends VpnService implements StateListener {
private boolean mStarting=false;
+ private long mConnecttime;
+
private static final int OPENVPN_STATUS = 1;
@Override
@@ -83,7 +85,7 @@ public class OpenVpnService extends VpnService implements StateListener {
}
}
- private void showNotification(String msg, String tickerText, boolean lowpriority) {
+ private void showNotification(String msg, String tickerText, boolean lowpriority, long when) {
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
@@ -97,6 +99,8 @@ public class OpenVpnService extends VpnService implements StateListener {
nbuilder.setOngoing(true);
nbuilder.setContentIntent(getLogPendingIntent());
nbuilder.setSmallIcon(icon);
+ if(when !=0)
+ nbuilder.setWhen(when);
// Try to set the priority available since API 16 (Jellybean)
@@ -104,7 +108,7 @@ public class OpenVpnService extends VpnService implements StateListener {
try {
Method setpriority = nbuilder.getClass().getMethod("setPriority", int.class);
// PRIORITY_MIN == -2
- setpriority.invoke(nbuilder, -1 );
+ setpriority.invoke(nbuilder, -2 );
//ignore exception
} catch (NoSuchMethodException nsm) {
@@ -182,7 +186,7 @@ public class OpenVpnService extends VpnService implements StateListener {
String profileUUID = intent.getStringExtra(prefix + ".profileUUID");
mProfile = ProfileManager.get(profileUUID);
- showNotification("Starting VPN " + mProfile.mName,"Starting VPN " + mProfile.mName, false);
+ showNotification("Starting VPN " + mProfile.mName,"Starting VPN " + mProfile.mName, false,0);
OpenVPN.addStateListener(this);
@@ -423,19 +427,21 @@ public class OpenVpnService extends VpnService implements StateListener {
if("BYTECOUNT".equals(state)) {
if(mDisplayBytecount) {
- showNotification(logmessage,null,true);
+ showNotification(logmessage,null,true,mConnecttime);
}
} else {
- if("CONNECTED".equals(state))
+ if("CONNECTED".equals(state)) {
mDisplayBytecount = true;
- else
+ mConnecttime = System.currentTimeMillis();
+ } else {
mDisplayBytecount = false;
-
+ }
+
// Other notifications are shown,
// This also mean we are no longer connected, ignore bytecount messages until next
// CONNECTED
String ticker = state.toLowerCase();
- showNotification(state +" " + logmessage,ticker,false);
+ showNotification(state +" " + logmessage,ticker,false,0);
}
}