From 319589d126dd5e5fa20ee146f52268c99559f04c Mon Sep 17 00:00:00 2001 From: cyBerta Date: Wed, 3 Jan 2018 15:59:30 +0100 Subject: 8773 preseeded providers implementation for production flavor --- .../bitmaskclient/BaseConfigurationWizard.java | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index 21520dc4..1d675499 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -56,6 +56,7 @@ import se.leap.bitmaskclient.userstatus.SessionDialog; import static android.view.View.GONE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; +import static se.leap.bitmaskclient.ProviderApiBase.ERRORS; /** * abstract base Activity that builds and shows the list of known available providers. @@ -184,10 +185,10 @@ public abstract class BaseConfigurationWizard extends Activity // by the height of mProgressbar (and the height of the first list item) mProgressBar.setVisibility(INVISIBLE); progressbar_description.setVisibility(INVISIBLE); - + mProgressBar.setProgress(0); } - private void showProgressBar() { + protected void showProgressBar() { mProgressBar.setVisibility(VISIBLE); progressbar_description.setVisibility(VISIBLE); } @@ -231,12 +232,11 @@ public abstract class BaseConfigurationWizard extends Activity } } else if (resultCode == ProviderAPI.PROVIDER_NOK) { mConfigState.setAction(PROVIDER_NOT_SET); - hideProgressBar(); preferences.edit().remove(Provider.KEY).apply(); setResult(RESULT_CANCELED, mConfigState); - String reason_to_fail = resultData.getString(ProviderAPI.ERRORS); + String reason_to_fail = resultData.getString(ERRORS); showDownloadFailedDialog(reason_to_fail); } else if (resultCode == ProviderAPI.CORRECTLY_DOWNLOADED_CERTIFICATE) { mProgressBar.incrementProgressBy(1); @@ -293,7 +293,9 @@ public abstract class BaseConfigurationWizard extends Activity cancelSettingUpProvider(); } + @Override public void cancelSettingUpProvider() { + hideProgressBar(); mConfigState.setAction(PROVIDER_NOT_SET); adapter.showAllProviders(); preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply(); @@ -369,18 +371,24 @@ public abstract class BaseConfigurationWizard extends Activity /** * Shows an error dialog, if configuring of a provider failed. * - * @param reason_to_fail + * @param reasonToFail */ - public void showDownloadFailedDialog(String reason_to_fail) { + public void showDownloadFailedDialog(String reasonToFail) { try { FragmentTransaction fragment_transaction = fragment_manager.removePreviousFragment(DownloadFailedDialog.TAG); - - DialogFragment newFragment = DownloadFailedDialog.newInstance(reason_to_fail); + DialogFragment newFragment; + try { + JSONObject errorJson = new JSONObject(reasonToFail); + newFragment = DownloadFailedDialog.newInstance(errorJson); + } catch (JSONException e) { + e.printStackTrace(); + newFragment = DownloadFailedDialog.newInstance(reasonToFail); + } newFragment.show(fragment_transaction, DownloadFailedDialog.TAG); } catch (IllegalStateException e) { e.printStackTrace(); mConfigState.setAction(PENDING_SHOW_FAILED_DIALOG); - mConfigState.putExtra(REASON_TO_FAIL, reason_to_fail); + mConfigState.putExtra(REASON_TO_FAIL, reasonToFail); } } -- cgit v1.2.3 From 81a732702f7b3125ac543f92d8a5ec33cce972fe Mon Sep 17 00:00:00 2001 From: cyBerta Date: Thu, 4 Jan 2018 13:23:58 +0100 Subject: 8773 preseeded providers implementation for insecure flavor --- .../se/leap/bitmaskclient/BaseConfigurationWizard.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index 1d675499..2c169e3d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -216,6 +216,8 @@ public abstract class BaseConfigurationWizard extends Activity String provider_json_string = preferences.getString(Provider.KEY, ""); if (!provider_json_string.isEmpty()) selected_provider.define(new JSONObject(provider_json_string)); + String caCert = preferences.getString(Provider.CA_CERT, ""); + selected_provider.setCACert(caCert); } catch (JSONException e) { e.printStackTrace(); } @@ -301,6 +303,20 @@ public abstract class BaseConfigurationWizard extends Activity preferences.edit().remove(Provider.KEY).remove(Constants.PROVIDER_ALLOW_ANONYMOUS).remove(Constants.PROVIDER_KEY).apply(); } + @Override + public void updateProviderDetails() { + mConfigState.setAction(SETTING_UP_PROVIDER); + Intent provider_API_command = new Intent(this, ProviderAPI.class); + + provider_API_command.setAction(ProviderAPI.UPDATE_PROVIDER_DETAILS); + provider_API_command.putExtra(ProviderAPI.RECEIVER_KEY, providerAPI_result_receiver); + Bundle parameters = new Bundle(); + parameters.putString(Provider.MAIN_URL, selected_provider.getMainUrl().toString()); + provider_API_command.putExtra(ProviderAPI.PARAMETERS, parameters); + + startService(provider_API_command); + } + private void askDashboardToQuitApp() { Intent ask_quit = new Intent(); ask_quit.putExtra(Dashboard.ACTION_QUIT, Dashboard.ACTION_QUIT); -- cgit v1.2.3 From 0b647ea5e7ff67747080b2ffcebc948da0fbecb5 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Tue, 9 Jan 2018 20:55:10 +0100 Subject: 8773 refactoring ProviderAPI for testability, setting up basic unit test framework --- app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index 2c169e3d..c26184bb 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -56,7 +56,7 @@ import se.leap.bitmaskclient.userstatus.SessionDialog; import static android.view.View.GONE; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; -import static se.leap.bitmaskclient.ProviderApiBase.ERRORS; +import static se.leap.bitmaskclient.ProviderAPI.ERRORS; /** * abstract base Activity that builds and shows the list of known available providers. @@ -352,7 +352,7 @@ public abstract class BaseConfigurationWizard extends Activity } /** - * Asks ProviderAPI to download an anonymous (anon) VPN certificate. + * Asks ProviderApiService to download an anonymous (anon) VPN certificate. */ private void downloadVpnCertificate() { Intent provider_API_command = new Intent(this, ProviderAPI.class); -- cgit v1.2.3 From ae8341cf1f563fbcf2bdd6a4eff9525f42e9e995 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Wed, 10 Jan 2018 17:14:45 +0100 Subject: 8773 more test cases and clean-up --- app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java') diff --git a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java index c26184bb..63453ac3 100644 --- a/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java +++ b/app/src/main/java/se/leap/bitmaskclient/BaseConfigurationWizard.java @@ -409,8 +409,6 @@ public abstract class BaseConfigurationWizard extends Activity } - - /** * Once selected a provider, this fragment offers the user to log in, * use it anonymously (if possible) @@ -430,7 +428,6 @@ public abstract class BaseConfigurationWizard extends Activity } } - @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.configuration_wizard_activity, menu); -- cgit v1.2.3