diff options
author | Arne Schwabe <arne@rfc2549.org> | 2012-08-12 18:52:38 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2012-08-12 18:52:38 +0200 |
commit | bbf93681fe1383c06edc47c89b50d444df57e56b (patch) | |
tree | def0ecbcf1a22ccacbfcf604d6bd034e650031f6 /src/de/blinkt/openvpn/ProfileManager.java | |
parent | 531aadf63b30cdde3604e583a3df03dcbd4521d8 (diff) |
Implement starting a VPN on boot. (closes issue #62)
Diffstat (limited to 'src/de/blinkt/openvpn/ProfileManager.java')
-rw-r--r-- | src/de/blinkt/openvpn/ProfileManager.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/de/blinkt/openvpn/ProfileManager.java b/src/de/blinkt/openvpn/ProfileManager.java index b1321b9..5d498c6 100644 --- a/src/de/blinkt/openvpn/ProfileManager.java +++ b/src/de/blinkt/openvpn/ProfileManager.java @@ -14,12 +14,17 @@ import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import android.preference.PreferenceManager; public class ProfileManager { private static final String PREFS_NAME = "VPNList"; + private static final String ONBOOTPROFILE = "onBootProfile"; + + + private static ProfileManager instance; private HashMap<String,VpnProfile> profiles=new HashMap<String, VpnProfile>(); @@ -47,6 +52,37 @@ public class ProfileManager { return instance; } + public static void onBootDelete(Context c) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c); + Editor prefsedit = prefs.edit(); + prefsedit.putString(ONBOOTPROFILE, null); + prefsedit.apply(); + + } + + public static void setOnBootProfile(Context c, VpnProfile bootprofile) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c); + Editor prefsedit = prefs.edit(); + + prefsedit.putString(ONBOOTPROFILE, bootprofile.getUUIDString()); + prefsedit.apply(); + + } + + public static VpnProfile getOnBootProfile(Context c) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c); + + boolean useStartOnBoot = prefs.getBoolean("restartvpnonboot", false); + + + String mBootProfileUUID = prefs.getString(ONBOOTPROFILE,null); + if(useStartOnBoot && mBootProfileUUID!=null) + return get(c, mBootProfileUUID); + else + return null; + } + + public Collection<VpnProfile> getProfiles() { |