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 | 5e7b841c8d5111e6b63e74944903a168939ca723 (patch) | |
tree | f782a9d293893393ce9222a7fe9b29ae46ef91d9 /src/de/blinkt/openvpn/ProfileManager.java | |
parent | 5438e464aaf326973938fee31d91bfdd7ece8f63 (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 b1321b97..5d498c67 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() { |