diff options
author | cyBerta <cyberta@riseup.net> | 2019-07-06 17:37:48 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-07-12 17:03:55 +0200 |
commit | 65a09aa799e525d3bc60f5f4f489a3d70c6a8554 (patch) | |
tree | 21664e9cc83c368395bacdc8abe3292c9a7db89d /app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java | |
parent | f5b8dae753448ed698486af8b49b977a58d4fcdc (diff) |
get rid of ics-openvpn's ProfileManager, reduces boilerplate and dead code
Diffstat (limited to 'app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java')
-rw-r--r-- | app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java | 33 |
1 files changed, 29 insertions, 4 deletions
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 fa28a875..33851b8f 100644 --- a/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java +++ b/app/src/main/java/de/blinkt/openvpn/core/VpnStatus.java @@ -18,7 +18,9 @@ import java.util.Locale; import java.util.Vector; import java.util.concurrent.CopyOnWriteArrayList; +import de.blinkt.openvpn.VpnProfile; import se.leap.bitmaskclient.R; +import se.leap.bitmaskclient.utils.PreferenceHelper; import static se.leap.bitmaskclient.utils.ConfigHelper.getProviderFormattedString; @@ -39,10 +41,10 @@ public class VpnStatus { private static HandlerThread mHandlerThread; - private static String mLastConnectedVPNUUID; static boolean readFileLog =false; final static java.lang.Object readFileLock = new Object(); + private static VpnProfile lastConnectedProfile; public static TrafficHistory trafficHistory; @@ -136,17 +138,40 @@ public class VpnStatus { } public static void setConnectedVPNProfile(String uuid) { - mLastConnectedVPNUUID = uuid; for (StateListener sl: stateListener) sl.setConnectedVPN(uuid); } - public static String getLastConnectedVPNProfile() + public static String getLastConnectedVPNProfileId() { - return mLastConnectedVPNUUID; + return lastConnectedProfile != null ? lastConnectedProfile.getUUIDString() : null; } + public static VpnProfile getLastConnectedVpnProfile() { + return lastConnectedProfile; + } + + public static VpnProfile getLastConnectedVpnProfile(Context context) { + return PreferenceHelper.getLastConnectedVpnProfile(context); + } + + + /** + * Sets the profile that is connected (to connect if the service restarts) + */ + public static void setLastConnectedVpnProfile(Context context, VpnProfile connectedProfile) { + PreferenceHelper.setLastUsedVpnProfile(context, connectedProfile); + lastConnectedProfile = connectedProfile; + setConnectedVPNProfile(lastConnectedProfile.getUUIDString()); + } + + + public static String getLastConnectedVpnName() { + return lastConnectedProfile != null ? lastConnectedProfile.mName : null; + } + + public static void setTrafficHistory(TrafficHistory trafficHistory) { VpnStatus.trafficHistory = trafficHistory; } |