summaryrefslogtreecommitdiff
path: root/src/de/blinkt/openvpn/OpenVpnService.java
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2012-08-28 01:14:05 +0200
committerArne Schwabe <arne@rfc2549.org>2012-08-28 01:14:05 +0200
commit4483c357fee4688a1604dd1cbf5b6262bbbf4e75 (patch)
tree4e915eba8ca868e148f062690e72d9b413e20c1d /src/de/blinkt/openvpn/OpenVpnService.java
parentc6526d53d31c7520c7c6ad575e0f61a40663ab4f (diff)
- Add status message when waiting for network.
- Using a priority higher than PRIORITY_MIN stop the flickering of the notification but make the icon visible again :/
Diffstat (limited to 'src/de/blinkt/openvpn/OpenVpnService.java')
-rw-r--r--src/de/blinkt/openvpn/OpenVpnService.java28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/de/blinkt/openvpn/OpenVpnService.java b/src/de/blinkt/openvpn/OpenVpnService.java
index 41d5b1e..c1fd171 100644
--- a/src/de/blinkt/openvpn/OpenVpnService.java
+++ b/src/de/blinkt/openvpn/OpenVpnService.java
@@ -83,7 +83,7 @@ public class OpenVpnService extends VpnService implements StateListener {
}
}
- private Notification showNotification(String msg, String tickerText, boolean lowpriority) {
+ private void showNotification(String msg, String tickerText, boolean lowpriority) {
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
@@ -98,12 +98,13 @@ public class OpenVpnService extends VpnService implements StateListener {
nbuilder.setContentIntent(getLogPendingIntent());
nbuilder.setSmallIcon(icon);
+
// Try to set the priority available since API 16 (Jellybean)
- if(lowpriority) {
+ if( lowpriority) {
try {
Method setpriority = nbuilder.getClass().getMethod("setPriority", int.class);
// PRIORITY_MIN == -2
- setpriority.invoke(nbuilder, -2 );
+ setpriority.invoke(nbuilder, -1 );
//ignore exception
} catch (NoSuchMethodException nsm) {
@@ -118,13 +119,8 @@ public class OpenVpnService extends VpnService implements StateListener {
Notification notification = nbuilder.getNotification();
-
-
-
mNotificationManager.notify(OPENVPN_STATUS, notification);
startForeground(OPENVPN_STATUS, notification);
- return notification;
-
}
PendingIntent getLogPendingIntent() {
@@ -189,7 +185,7 @@ public class OpenVpnService extends VpnService implements StateListener {
showNotification("Starting VPN " + mProfile.mName,"Starting VPN " + mProfile.mName, false);
- OpenVPN.addSpeedListener(this);
+ OpenVPN.addStateListener(this);
// Set a flag that we are starting a new VPN
mStarting=true;
@@ -425,22 +421,22 @@ public class OpenVpnService extends VpnService implements StateListener {
// Display byte count only after being connected
- if("CONNECTED".equals(state)) {
- mDisplayBytecount = true;
- } else if("BYTECOUNT".equals(state)) {
+ if("BYTECOUNT".equals(state)) {
if(mDisplayBytecount) {
showNotification(logmessage,null,true);
}
} else {
+ if("CONNECTED".equals(state))
+ mDisplayBytecount = true;
+ 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);
- mDisplayBytecount=false;
+
}
}
-
-
-
}