summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java')
-rw-r--r--app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java b/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
index 4cfbcc8e..2a26152e 100644
--- a/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
+++ b/app/src/main/java/de/blinkt/openvpn/core/ProfileManager.java
@@ -1,3 +1,8 @@
+/*
+ * Copyright (c) 2012-2014 Arne Schwabe
+ * Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt
+ */
+
package de.blinkt.openvpn.core;
import java.io.FileNotFoundException;
@@ -23,7 +28,7 @@ public class ProfileManager {
- private static final String ONBOOTPROFILE = "onBootProfile";
+ private static final String LAST_CONNECTED_PROFILE = "lastConnectedProfile";
@@ -65,7 +70,7 @@ public class ProfileManager {
public static void setConntectedVpnProfileDisconnected(Context c) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
- prefsedit.putString(ONBOOTPROFILE, null);
+ prefsedit.putString(LAST_CONNECTED_PROFILE, null);
prefsedit.apply();
}
@@ -74,21 +79,23 @@ public class ProfileManager {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
Editor prefsedit = prefs.edit();
- prefsedit.putString(ONBOOTPROFILE, connectedrofile.getUUIDString());
+ prefsedit.putString(LAST_CONNECTED_PROFILE, connectedrofile.getUUIDString());
prefsedit.apply();
mLastConnectedVpn=connectedrofile;
}
- public static VpnProfile getOnBootProfile(Context c) {
+ public static VpnProfile getLastConnectedProfile(Context c, boolean onBoot) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
boolean useStartOnBoot = prefs.getBoolean("restartvpnonboot", false);
+ if (onBoot && !useStartOnBoot)
+ return null;
- String mBootProfileUUID = prefs.getString(ONBOOTPROFILE,null);
- if(useStartOnBoot && mBootProfileUUID!=null)
- return get(c, mBootProfileUUID);
+ String lastConnectedProfile = prefs.getString(LAST_CONNECTED_PROFILE, null);
+ if(lastConnectedProfile!=null)
+ return get(c, lastConnectedProfile);
else
return null;
}