From 97ff21c74619269a8c7dc9d8ff1485200db58d8c Mon Sep 17 00:00:00 2001 From: cyBerta Date: Mon, 9 Oct 2017 15:22:23 +0200 Subject: #8758 fix switching providers --- app/src/main/java/se/leap/bitmaskclient/eip/EIP.java | 1 + .../main/java/se/leap/bitmaskclient/eip/GatewaysManager.java | 11 ++++++++--- .../java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/se') diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 5b72a4e7..eb83814a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -170,6 +170,7 @@ public final class EIP extends IntentService { } private void updateGateways() { + gateways_manager.clearGatewaysAndProfiles(); gateways_manager.fromEipServiceJson(eip_definition); gatewaysToPreferences(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java index f41049c5..6a7e3d0b 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java @@ -143,15 +143,20 @@ public class GatewaysManager { return result; } + protected void clearGatewaysAndProfiles() { + gateways.clear(); + ArrayList profiles = new ArrayList<>(profile_manager.getProfiles()); + for (VpnProfile profile : profiles) { + profile_manager.removeProfile(context, profile); + } + } + private void addGateway(Gateway gateway) { removeDuplicatedGateway(gateway); - gateways.add(gateway); VpnProfile profile = gateway.getProfile(); profile_manager.addProfile(profile); - //profile_manager.saveProfile(context, profile); - //profile_manager.saveProfileList(context); } private void removeDuplicatedGateway(Gateway gateway) { diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java index 0b9c5832..10a95dfb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/VpnConfigGenerator.java @@ -56,7 +56,7 @@ public class VpnConfigGenerator { String key = keys.next().toString(); common_options += key + " "; - for (String word : general_configuration.getString(key).split(" ")) + for (String word : String.valueOf(general_configuration.get(key)).split(" ")) common_options += word + " "; common_options += new_line; -- cgit v1.2.3