summaryrefslogtreecommitdiff
path: root/src
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
commit807c3c2118e09707a1d6265e681e664b78a11f80 (patch)
tree59444373e09979e6ea8b1f4b1e08f95b3ad1819d /src
parentad76d3e79a4f34686459dc78e3a17b295f52464d (diff)
Give all traffic notifications the same time, fixes the blinking notification for me (closes issue #75)
Diffstat (limited to 'src')
-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 c1fd171..ca199cc 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);
}
}