summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java')
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java34
1 files changed, 10 insertions, 24 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
index 578d95e7..3cb5527b 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java
@@ -49,14 +49,12 @@ import de.blinkt.openvpn.core.VpnStatus.StateListener;
import static de.blinkt.openvpn.core.NetworkSpace.ipAddress;
import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTED;
-import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_NONETWORK;
-import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_NOTCONNECTED;
import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_CONNECTING_NO_SERVER_REPLY_YET;
import static de.blinkt.openvpn.core.VpnStatus.ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT;
+
import se.leap.bitmaskclient.Dashboard;
public class OpenVPNService extends VpnService implements StateListener, Callback, ByteCountListener {
-
public static final String START_SERVICE = "de.blinkt.openvpn.START_SERVICE";
public static final String START_SERVICE_STICKY = "de.blinkt.openvpn.START_SERVICE_STICKY";
public static final String ALWAYS_SHOW_NOTIFICATION = "de.blinkt.openvpn.NOTIFICATION_ALWAYS_VISIBLE";
@@ -126,7 +124,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
synchronized (mProcessLock) {
mProcessThread = null;
}
- mConnecttime = 0;
VpnStatus.removeByteCountListener(this);
unregisterDeviceStateReceiver();
ProfileManager.setConntectedVpnProfileDisconnected(this);
@@ -177,7 +174,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
mNotificationManager.notify(OPENVPN_STATUS, notification);
- //startForeground(OPENVPN_STATUS, notification);
+ startForeground(OPENVPN_STATUS, notification);
}
private int getIconByConnectionStatus(ConnectionStatus level) {
@@ -810,8 +807,11 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
/* Workaround for Lollipop, it does not route traffic to the VPNs own network mask */
- if (mLocalIP.len <= 31 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
- addRoute(mLocalIP);
+ if (mLocalIP.len <= 31 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ CIDRIP interfaceRoute = new CIDRIP(mLocalIP.mIp, mLocalIP.len);
+ interfaceRoute.normalise();
+ addRoute(interfaceRoute);
+ }
// Configurations are sometimes really broken...
@@ -843,21 +843,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
mDisplayBytecount = true;
mConnecttime = System.currentTimeMillis();
lowpriority = true;
- if(mProfile.mPersistTun) {
- NotificationManager ns = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- ns.cancel(OPENVPN_STATUS);
- return;
- }
- } else if (level == LEVEL_NONETWORK || level == LEVEL_NOTCONNECTED) {
- NotificationManager ns = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- ns.cancel(OPENVPN_STATUS);
- return;
- } else if (level != LEVEL_NOTCONNECTED && mConnecttime > 0) {
- mDisplayBytecount = false;
- String msg = "Traffic is blocked until the VPN becomes active.";
- String ticker = msg;
- showNotification(msg, ticker, lowpriority , 0, level);
- return;
} else {
mDisplayBytecount = false;
}
@@ -868,7 +853,8 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
// Does not work :(
String msg = getString(resid);
String ticker = msg;
- showNotification(msg + " " + logmessage, ticker, lowpriority , 0, level);
+ showNotification(msg + " " + logmessage, ticker, lowpriority, 0, level);
+
}
}
@@ -890,7 +876,7 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac
humanReadableByteCount(diffOut / OpenVPNManagement.mBytecountInterval, true));
boolean lowpriority = !mNotificationAlwaysVisible;
- //showNotification(netstat, null, lowpriority, mConnecttime, LEVEL_CONNECTED);
+ showNotification(netstat, null, lowpriority, mConnecttime, LEVEL_CONNECTED);
}
}