summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-12-31 16:51:56 +0100
committerParménides GV <parmegv@sdf.org>2014-12-31 16:51:56 +0100
commit8d7bedaa40129ae809f3e1261228b00042872f62 (patch)
tree022a867957c29f26f28638cc0db93ff5bb8b49c8 /app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
parent44b59b984f76da62d409b585047224cb1e958016 (diff)
Don't remove vpn profiles if possible.
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/EIP.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EIP.java20
1 files changed, 13 insertions, 7 deletions
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 3d3070c8..77d0cd82 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java
@@ -101,7 +101,7 @@ public final class EIP extends IntentService {
stopEIP();
else if (action.equals(ACTION_IS_EIP_RUNNING))
isRunning();
- else if (action.equals(ACTION_UPDATE_EIP_SERVICE))
+ else if (action.equals(ACTION_UPDATE_EIP_SERVICE))
updateEIPService();
else if (action.equals(ACTION_CHECK_CERT_VALIDITY))
checkCertValidity();
@@ -174,8 +174,8 @@ public final class EIP extends IntentService {
*/
private void updateEIPService() {
refreshEipDefinition();
- deleteAllVpnProfiles();
- updateGateways();
+ if(eip_definition != null)
+ updateGateways();
tellToReceiver(ACTION_UPDATE_EIP_SERVICE, Activity.RESULT_OK);
}
@@ -204,15 +204,16 @@ public final class EIP extends IntentService {
*/
private void updateGateways(){
try {
- if(eip_definition != null) {
JSONArray gatewaysDefined = eip_definition.getJSONArray("gateways");
for (int i = 0; i < gatewaysDefined.length(); i++) {
JSONObject gw = gatewaysDefined.getJSONObject(i);
if (isOpenVpnGateway(gw)) {
- addGateway(new Gateway(eip_definition, context, gw));
+ Gateway gateway = new Gateway(eip_definition, context, gw);
+ if(!gateways.contains(gateway)) {
+ addGateway(gateway);
+ }
}
}
- }
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -229,8 +230,13 @@ public final class EIP extends IntentService {
}
private void addGateway(Gateway gateway) {
- profile_manager.addProfile(gateway.getProfile());
+ VpnProfile profile = gateway.getProfile();
+ profile_manager.addProfile(profile);
+ profile_manager.saveProfile(context, profile);
+ profile_manager.saveProfileList(context);
+
gateways.add(gateway);
+ Log.d(TAG, "Gateway added: " + gateway.getProfile().getUUIDString());
}
private void checkCertValidity() {