From c2de5af5af4e7554f6cded689e99d4c54e9fe8e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 19 Aug 2014 18:20:01 +0200 Subject: Remove all vpn if upgrading to 0.6.0. --- .../se/leap/bitmaskclient/ConfigurationWizard.java | 6 ++-- .../main/java/se/leap/bitmaskclient/Dashboard.java | 33 +++++++++++++--------- app/src/main/java/se/leap/bitmaskclient/EIP.java | 3 ++ .../se/leap/bitmaskclient/ConfigurationWizard.java | 2 +- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java index cf013f3a..153cb731 100644 --- a/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/debug/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -96,7 +96,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - preferences = getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE); + preferences = preferences; setContentView(R.layout.configuration_wizard_activity); mProgressBar = (ProgressBar) findViewById(R.id.progressbar_configuration_wizard); @@ -230,7 +230,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD mProgressBar.setVisibility(ProgressBar.GONE); mProgressBar.setProgress(0); progressbar_description.setVisibility(TextView.GONE); - getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit().remove(Provider.KEY).commit(); + preferences.edit().remove(Provider.KEY).commit(); setting_up_provider = false; showAllProviders(); } @@ -497,7 +497,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD } private void autoSelectProvider(String provider_main_url, boolean danger_on) { - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(ProviderItem.DANGER_ON, danger_on).commit(); + preferences.edit().putBoolean(ProviderItem.DANGER_ON, danger_on).commit(); onItemSelected(getId(provider_main_url)); } diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index fe546a21..74b6f9af 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -104,9 +104,17 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf try { int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; int lastDetectedVersion = preferences.getInt(APP_VERSION, 0); - if(lastDetectedVersion == 0) // New install - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putInt(APP_VERSION, versionCode); - else if(lastDetectedVersion < versionCode) { + preferences.edit().putInt(APP_VERSION, versionCode); + if(lastDetectedVersion != 0) { + switch(versionCode) { + case 90: // 0.6.0 + if(!preferences.getString(EIP.KEY, "").isEmpty()) { + Intent removeVpnProfiles = new Intent(getApplicationContext(), EIP.class); + removeVpnProfiles.setAction(EIP.ACTION_REMOVE_PROFILES); + startService(removeVpnProfiles); + } + } + } } catch (NameNotFoundException e) { } @@ -127,8 +135,8 @@ 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 ){ - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putInt(EIP.PARSED_SERIAL, 0).commit(); - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); + preferences.edit().putInt(EIP.PARSED_SERIAL, 0).commit(); + preferences.edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); Intent updateEIP = new Intent(getApplicationContext(), EIP.class); updateEIP.setAction(EIP.ACTION_UPDATE_EIP_SERVICE); startService(updateEIP); @@ -164,8 +172,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf .setNegativeButton(getResources().getString(R.string.setup_error_close_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - SharedPreferences.Editor prefsEdit = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE).edit(); - prefsEdit.remove(Provider.KEY).commit(); + preferences.edit().remove(Provider.KEY).commit(); finish(); } }) @@ -192,7 +199,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf if ( provider.hasEIP()){ eipFragment = new EipServiceFragment(); if (hide_and_turn_on_eip) { - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().remove(Dashboard.START_ON_BOOT).commit(); + preferences.edit().remove(Dashboard.START_ON_BOOT).commit(); Bundle arguments = new Bundle(); arguments.putBoolean(EipServiceFragment.START_ON_BOOT, true); eipFragment.setArguments(arguments); @@ -209,7 +216,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf public boolean onPrepareOptionsMenu(Menu menu) { JSONObject provider_json; try { - provider_json = new JSONObject(getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE).getString(Provider.KEY, "")); + provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); JSONObject service_description = provider_json.getJSONObject(Provider.SERVICE); boolean authed_eip = preferences.getBoolean(EIP.AUTHED_EIP, false); boolean allow_registered_eip = service_description.getBoolean(Provider.ALLOW_REGISTRATION); @@ -252,12 +259,12 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf return true; case R.id.switch_provider: if (Provider.getInstance().hasEIP()){ - if (getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).getBoolean(EIP.AUTHED_EIP, false)){ + if (preferences.getBoolean(EIP.AUTHED_EIP, false)){ logOut(); } eipStop(); } - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().clear().commit(); + preferences.edit().clear().commit(); startActivityForResult(new Intent(this,ConfigurationWizard.class), SWITCH_PROVIDER); return true; case R.id.login_button: @@ -463,7 +470,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf setResult(RESULT_OK); authed_eip = true; - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); + preferences.edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); invalidateOptionsMenu(); mProgressBar.setVisibility(ProgressBar.GONE); @@ -475,7 +482,7 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf logInDialog(resultData); } else if(resultCode == ProviderAPI.LOGOUT_SUCCESSFUL) { authed_eip = false; - getSharedPreferences(Dashboard.SHARED_PREFERENCES, MODE_PRIVATE).edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); + preferences.edit().putBoolean(EIP.AUTHED_EIP, authed_eip).commit(); mProgressBar.setVisibility(ProgressBar.GONE); mProgressBar.setProgress(0); invalidateOptionsMenu(); diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java index 41299318..686efc69 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java @@ -86,6 +86,7 @@ public final class EIP extends IntentService { public final static String ACTION_STOP_EIP = "se.leap.bitmaskclient.STOP_EIP"; public final static String ACTION_UPDATE_EIP_SERVICE = "se.leap.bitmaskclient.UPDATE_EIP_SERVICE"; public final static String ACTION_IS_EIP_RUNNING = "se.leap.bitmaskclient.IS_RUNNING"; + public final static String ACTION_REMOVE_PROFILES = "se.leap.bitmaskclient.REMOVE_PROFILES"; public final static String EIP_NOTIFICATION = "EIP_NOTIFICATION"; public final static String STATUS = "eip status"; public final static String DATE_FROM_CERTIFICATE = "date from certificate"; @@ -155,6 +156,8 @@ public final class EIP extends IntentService { this.stopEIP(); else if ( action == ACTION_CHECK_CERT_VALIDITY ) this.checkCertValidity(); + else if ( action == ACTION_REMOVE_PROFILES ) + this.deleteAllVpnProfiles(); } /** diff --git a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java index a6b009e3..b5a57234 100644 --- a/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java +++ b/app/src/release/java/se/leap/bitmaskclient/ConfigurationWizard.java @@ -227,7 +227,7 @@ implements ProviderListFragment.Callbacks, NewProviderDialogInterface, ProviderD mProgressBar.setVisibility(ProgressBar.GONE); mProgressBar.setProgress(0); progressbar_description.setVisibility(TextView.GONE); - getSharedPreferences(Dashboard.SHARED_PREFERENCES, Activity.MODE_PRIVATE).edit().remove(Provider.KEY).commit(); + preferences.edit().remove(Provider.KEY).commit(); setting_up_provider = false; showAllProviders(); } -- cgit v1.2.3 From c1d13ccd8f78601142a33273093e1b3cadaead58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 19 Aug 2014 19:43:46 +0200 Subject: Rebuild vpn profiles if upgraded to versionCode 91 --- .../main/java/se/leap/bitmaskclient/Dashboard.java | 20 ++++++++++---------- app/src/main/java/se/leap/bitmaskclient/EIP.java | 8 +++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 74b6f9af..761afc0a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -105,17 +105,17 @@ public class Dashboard extends Activity implements LogInDialog.LogInDialogInterf int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; int lastDetectedVersion = preferences.getInt(APP_VERSION, 0); preferences.edit().putInt(APP_VERSION, versionCode); - if(lastDetectedVersion != 0) { - switch(versionCode) { - case 90: // 0.6.0 - if(!preferences.getString(EIP.KEY, "").isEmpty()) { - Intent removeVpnProfiles = new Intent(getApplicationContext(), EIP.class); - removeVpnProfiles.setAction(EIP.ACTION_REMOVE_PROFILES); - startService(removeVpnProfiles); - } + Log.d("Dashboard", "detected version code: " + versionCode); + Log.d("Dashboard", "last detected version code: " + lastDetectedVersion); + + switch(versionCode) { + case 91: // 0.6.0 without Bug #5999 + if(!preferences.getString(EIP.KEY, "").isEmpty()) { + Intent rebuildVpnProfiles = new Intent(getApplicationContext(), EIP.class); + rebuildVpnProfiles.setAction(EIP.ACTION_REBUILD_PROFILES); + startService(rebuildVpnProfiles); } - - } + } } catch (NameNotFoundException e) { } } diff --git a/app/src/main/java/se/leap/bitmaskclient/EIP.java b/app/src/main/java/se/leap/bitmaskclient/EIP.java index 686efc69..43ad3c1f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/EIP.java @@ -86,7 +86,7 @@ public final class EIP extends IntentService { public final static String ACTION_STOP_EIP = "se.leap.bitmaskclient.STOP_EIP"; public final static String ACTION_UPDATE_EIP_SERVICE = "se.leap.bitmaskclient.UPDATE_EIP_SERVICE"; public final static String ACTION_IS_EIP_RUNNING = "se.leap.bitmaskclient.IS_RUNNING"; - public final static String ACTION_REMOVE_PROFILES = "se.leap.bitmaskclient.REMOVE_PROFILES"; + public final static String ACTION_REBUILD_PROFILES = "se.leap.bitmaskclient.REBUILD_PROFILES"; public final static String EIP_NOTIFICATION = "EIP_NOTIFICATION"; public final static String STATUS = "eip status"; public final static String DATE_FROM_CERTIFICATE = "date from certificate"; @@ -156,8 +156,9 @@ public final class EIP extends IntentService { this.stopEIP(); else if ( action == ACTION_CHECK_CERT_VALIDITY ) this.checkCertValidity(); - else if ( action == ACTION_REMOVE_PROFILES ) - this.deleteAllVpnProfiles(); + else if ( action == ACTION_REBUILD_PROFILES ) { + this.updateGateways(); + } } /** @@ -466,6 +467,7 @@ public final class EIP extends IntentService { cp.parseConfig(new StringReader(certSecretFromSharedPreferences())); cp.parseConfig(new StringReader("remote-cert-tls server")); cp.parseConfig(new StringReader("persist-tun")); + Log.d(TAG, "persist-tun"); VpnProfile vp = cp.convertProfile(); //vp.mAuthenticationType=VpnProfile.TYPE_STATICKEYS; mVpnProfile = vp; -- cgit v1.2.3 From fad9af561c6086f102c9902e8db8c12df5648bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 19 Aug 2014 19:55:08 +0200 Subject: Bump version code for hotfix --- app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 507e5bb0..0c55bf78 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -17,7 +17,7 @@ -- cgit v1.2.3