diff options
Diffstat (limited to 'main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java b/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java index b46a8f10..9d59e26b 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java +++ b/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java @@ -51,10 +51,10 @@ public class ProfileManager { return instance.profiles.get(key); } - private static void checkInstance(Context context) { + private synchronized static void checkInstance(Context context) { if (instance == null) { instance = new ProfileManager(); - ProfileEncryption.initMasterCryptAlias(); + ProfileEncryption.initMasterCryptAlias(context); instance.loadVPNList(context); } } @@ -146,7 +146,7 @@ public class ProfileManager { if (encryptedFileOld.exists()) { encryptedFileOld.delete(); } - } catch (IOException ioe) + } catch (IOException | GeneralSecurityException ioe) { VpnStatus.logException(VpnStatus.LogLevel.INFO, "Error trying to write an encrypted VPN profile, disabling " + "encryption", ioe); @@ -174,7 +174,7 @@ public class ProfileManager { } - } catch (IOException | GeneralSecurityException e) { + } catch (IOException e) { VpnStatus.logException("saving VPN profile", e); throw new RuntimeException(e); } @@ -250,7 +250,7 @@ public class ProfileManager { editor.apply(); } - public void addProfile(VpnProfile profile) { + public synchronized void addProfile(VpnProfile profile) { profiles.put(profile.getUUID().toString(), profile); } @@ -259,7 +259,7 @@ public class ProfileManager { * profiles * @param context */ - public void refreshVPNList(Context context) + public synchronized void refreshVPNList(Context context) { SharedPreferences listpref = Preferences.getSharedPreferencesMulti(PREFS_NAME, context); Set<String> vlist = listpref.getStringSet("vpnlist", null); @@ -283,7 +283,7 @@ public class ProfileManager { } } - private void loadVPNList(Context context) { + private synchronized void loadVPNList(Context context) { profiles = new HashMap<>(); SharedPreferences listpref = Preferences.getSharedPreferencesMulti(PREFS_NAME, context); Set<String> vlist = listpref.getStringSet("vpnlist", null); @@ -298,7 +298,7 @@ public class ProfileManager { } } - private void loadVpnEntry(Context context, String vpnentry) { + private synchronized void loadVpnEntry(Context context, String vpnentry) { ObjectInputStream vpnfile = null; try { FileInputStream vpInput; @@ -339,7 +339,7 @@ public class ProfileManager { } } - public void removeProfile(Context context, VpnProfile profile) { + public synchronized void removeProfile(Context context, VpnProfile profile) { String vpnentry = profile.getUUID().toString(); profiles.remove(vpnentry); saveProfileList(context); |