summaryrefslogtreecommitdiff
path: root/src/se/leap/bitmaskclient/EIP.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2014-03-26 12:15:09 +0100
committerParménides GV <parmegv@sdf.org>2014-03-26 12:15:09 +0100
commitc946bed3e63d9d271cd08d4c33e564a157908c36 (patch)
treee5869abb9eb941e340a7968b34225c7a58199161 /src/se/leap/bitmaskclient/EIP.java
parent0323676ef98b12af3c7ce20bf4101bdc900ef654 (diff)
parent8a754e30011bf60ac9bff2cf987c3fa263b3d924 (diff)
Merge branch 'develop' into release-0.5
Diffstat (limited to 'src/se/leap/bitmaskclient/EIP.java')
-rw-r--r--src/se/leap/bitmaskclient/EIP.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java
index 169178d1..e773e3b9 100644
--- a/src/se/leap/bitmaskclient/EIP.java
+++ b/src/se/leap/bitmaskclient/EIP.java
@@ -280,9 +280,9 @@ public final class EIP extends IntentService {
if(parsedEipSerial == 0) {
// Delete all vpn profiles
ProfileManager vpl = ProfileManager.getInstance(context);
- Collection<VpnProfile> profiles = vpl.getProfiles();
- for (VpnProfile profile : profiles){
- vpl.removeProfile(context, profile);
+ VpnProfile[] profiles = (VpnProfile[]) vpl.getProfiles().toArray(new VpnProfile[vpl.getProfiles().size()]);
+ for (int current_profile = 0; current_profile < profiles.length; current_profile++){
+ vpl.removeProfile(context, profiles[current_profile]);
}
}
if (eipDefinition.optInt("serial") > parsedEipSerial)
@@ -332,14 +332,15 @@ public final class EIP extends IntentService {
}
}
- String closestLocation = offsets.firstEntry().getValue().iterator().next();
+
+ String closestLocation = offsets.isEmpty() ? "" : offsets.firstEntry().getValue().iterator().next();
JSONArray gateways = null;
String chosenHost = null;
try {
gateways = eipDefinition.getJSONArray("gateways");
for (int i = 0; i < gateways.length(); i++) {
JSONObject gw = gateways.getJSONObject(i);
- if ( gw.getString("location").equalsIgnoreCase(closestLocation) ){
+ if ( gw.getString("location").equalsIgnoreCase(closestLocation) || closestLocation.isEmpty()){
chosenHost = gw.getString("host");
break;
}