From 6dfb02da9cd6c28b8a3016cf78454add6408c13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 3 Dec 2013 22:26:31 +0100 Subject: 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. --- src/se/leap/bitmaskclient/Dashboard.java | 7 ++++--- src/se/leap/bitmaskclient/EIP.java | 9 +++++++++ src/se/leap/bitmaskclient/ProviderAPI.java | 5 ++++- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/se/leap/bitmaskclient') 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 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) { -- cgit v1.2.3