summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2013-12-03 22:26:31 +0100
committerParménides GV <parmegv@sdf.org>2013-12-04 16:02:11 +0100
commit6dfb02da9cd6c28b8a3016cf78454add6408c13d (patch)
tree9cfa94e051b93e4b7d80a03b4dcf00d0510742bb
parente26be4756596acf5be292955079ae33f228408d8 (diff)
Vpn profiles get updated after switching provider.
parsedEipSerial wasn't being reset after switching provider, so updating gateways thought there was no real update. After switching provider, we also remove all other vpn profiles.
-rw-r--r--src/se/leap/bitmaskclient/Dashboard.java7
-rw-r--r--src/se/leap/bitmaskclient/EIP.java9
-rw-r--r--src/se/leap/bitmaskclient/ProviderAPI.java5
3 files changed, 17 insertions, 4 deletions
diff --git a/src/se/leap/bitmaskclient/Dashboard.java b/src/se/leap/bitmaskclient/Dashboard.java
index 116d043b..24cf13f6 100644
--- a/src/se/leap/bitmaskclient/Dashboard.java
+++ b/src/se/leap/bitmaskclient/Dashboard.java
@@ -106,7 +106,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
ConfigHelper.setSharedPreferences(getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE));
preferences = ConfigHelper.shared_preferences;
-
+
authed_eip = ConfigHelper.getBoolFromSharedPref(EIP.AUTHED_EIP);
if (ConfigHelper.getStringFromSharedPref(Provider.KEY).isEmpty())
startActivityForResult(new Intent(this,ConfigurationWizard.class),CONFIGURE_LEAP);
@@ -125,14 +125,15 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf
if ( requestCode == CONFIGURE_LEAP || requestCode == SWITCH_PROVIDER) {
// It should be equivalent: if ( (requestCode == CONFIGURE_LEAP) || (data!= null && data.hasExtra(STOP_FIRST))) {
if ( resultCode == RESULT_OK ){
- ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip);
if ((data != null) && (data.hasExtra(STOP_FIRST))){
Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> eipStop!");
eipStop();
- }else{
+ } else{
Log.d(TAG_EIP_FRAGMENT, "onActivityResult() -> has no Extra STOP_FIRST");
}
+ ConfigHelper.saveSharedPref(EIP.PARSED_SERIAL, 0);
+ ConfigHelper.saveSharedPref(EIP.AUTHED_EIP, authed_eip);
startService( new Intent(EIP.ACTION_UPDATE_EIP_SERVICE) );
buildDashboard();
if(data != null && data.hasExtra(LogInDialog.VERB)) {
diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java
index 22f7558d..13261e29 100644
--- a/src/se/leap/bitmaskclient/EIP.java
+++ b/src/se/leap/bitmaskclient/EIP.java
@@ -252,10 +252,19 @@ public final class EIP extends IntentService {
private void updateEIPService() {
try {
eipDefinition = ConfigHelper.getJsonFromSharedPref(EIP.KEY);
+ parsedEipSerial = ConfigHelper.getIntFromSharedPref(PARSED_SERIAL);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+ 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);
+ }
+ }
if (eipDefinition.optInt("serial") > parsedEipSerial)
updateGateways();
}
diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java
index a553851b..871a20dd 100644
--- a/src/se/leap/bitmaskclient/ProviderAPI.java
+++ b/src/se/leap/bitmaskclient/ProviderAPI.java
@@ -229,7 +229,10 @@ public class ProviderAPI extends IntentService {
result.putString(ERRORS, reason_to_fail);
result.putBoolean(RESULT_KEY, false);
}
- else ConfigHelper.saveSharedPref(EIP.KEY, eip_service_json);
+ else {
+ ConfigHelper.saveSharedPref(EIP.KEY, eip_service_json);
+ ConfigHelper.saveSharedPref(EIP.PARSED_SERIAL, 0);
+ }
result.putBoolean(RESULT_KEY, true);
} catch (JSONException e) {