diff options
Diffstat (limited to 'app/src/main/java/de')
3 files changed, 25 insertions, 19 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java b/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java index 3e6d23f7..8ee46d77 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java +++ b/app/src/main/java/de/blinkt/openvpn/core/ConnectionStatus.java @@ -21,7 +21,8 @@ public enum ConnectionStatus implements Parcelable { LEVEL_START, LEVEL_AUTH_FAILED, LEVEL_WAITING_FOR_USER_INPUT, - LEVEL_BLOCKING, // used for Bitmask's VoidVPN + LEVEL_BLOCKING, // used for Bitmask's VoidVPN + LEVEL_STOPPING, UNKNOWN_LEVEL; @Override 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 11bc4da3..55e9cfe9 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/app/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -7,12 +7,8 @@ package de.blinkt.openvpn.core; import android.Manifest.permission; import android.annotation.TargetApi; -import android.app.Activity; import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; import android.app.UiModeManager; -import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; @@ -20,17 +16,14 @@ import android.content.pm.ShortcutManager; import android.content.res.Configuration; import android.content.res.Resources; import android.net.ConnectivityManager; -import android.net.Uri; import android.net.VpnService; import android.os.Build; -import android.os.Bundle; import android.os.Handler; import android.os.Handler.Callback; import android.os.IBinder; import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.RemoteException; -import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; import android.system.OsConstants; import android.text.TextUtils; @@ -39,7 +32,6 @@ import android.widget.Toast; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.Inet6Address; import java.net.InetAddress; import java.net.UnknownHostException; @@ -47,8 +39,6 @@ import java.util.Collection; import java.util.Locale; import java.util.Vector; -import de.blinkt.openvpn.LaunchVPN; -import se.leap.bitmaskclient.R; import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.VpnStatus.ByteCountListener; import de.blinkt.openvpn.core.VpnStatus.StateListener; @@ -248,10 +238,14 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac @Override public boolean stopVPN(boolean replaceConnection) throws RemoteException { - if (getManagement() != null) - return getManagement().stopVPN(replaceConnection); - else - return false; + if (getManagement() != null && getManagement().stopVPN(replaceConnection)) { + if (!replaceConnection) { + VpnStatus.updateStateString("NOPROCESS", "VPN STOPPED", R.string.state_noprocess, ConnectionStatus.LEVEL_NOTCONNECTED); + } + return true; + } else { + return false; + } } /** diff --git a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java index 0fae6183..64a87df0 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java +++ b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java @@ -212,7 +212,6 @@ public class VpnStatus { } public interface StateListener { - String STATE_CONNECTRETRY = "CONNECTRETRY"; void updateState(String state, String logmessage, int localizedResId, ConnectionStatus level); void setConnectedVPN(String uuid); @@ -328,22 +327,29 @@ public class VpnStatus { String[] connected = {"CONNECTED"}; String[] notconnected = {"DISCONNECTED", "EXITING"}; + /** + * ignore incoming connection/reconnecting states if vpn is about to shut down + */ for (String x : noreplyet) - if (state.equals(x)) + if (state.equals(x) && !mLaststate.equals("STOPPING")) return ConnectionStatus.LEVEL_CONNECTING_NO_SERVER_REPLY_YET; for (String x : reply) - if (state.equals(x)) + if (state.equals(x) && !mLaststate.equals("STOPPING")) return ConnectionStatus.LEVEL_CONNECTING_SERVER_REPLIED; for (String x : connected) - if (state.equals(x)) + if (state.equals(x) && !mLaststate.equals("STOPPING")) return ConnectionStatus.LEVEL_CONNECTED; for (String x : notconnected) if (state.equals(x)) return ConnectionStatus.LEVEL_NOTCONNECTED; + if (mLaststate.equals("STOPPING")) { + return ConnectionStatus.LEVEL_STOPPING; + } + return ConnectionStatus.UNKNOWN_LEVEL; } @@ -377,6 +383,11 @@ public class VpnStatus { return; } + if (mLaststate.equals("STOPPING") && !state.equals("DISCONNECTED") && !state.equals("EXITING")) { + newLogItem(new LogItem((LogLevel.DEBUG), String.format("Ignoring OpenVPN Status while exiting (%s->%s)", mLastLevel.toString(), level.toString()))); + return; + } + mLaststate = state; mLaststatemsg = msg; mLastStateresid = resid; |