diff options
author | Fup Duck <fupduck@sacknagel.com> | 2018-02-09 14:33:20 +0100 |
---|---|---|
committer | Fup Duck <fupduck@sacknagel.com> | 2018-02-09 14:33:20 +0100 |
commit | 9f6e74680e5cfe6507bd1e37ea217cf2887af3cc (patch) | |
tree | 5ec6cbcf049278ef496e392f9b3dc54b0147f5aa /app/src/main/java/se/leap | |
parent | 9e6fe0e215e32343b38cdf20080de209a31287dd (diff) |
8827 - resolve discussions
* remove stop for providerApi
* enable retrySetUpProvider
* renamed PROVIDER_KEY for EIP_JSON to PROVIDER_EIP_DEFINITION
Diffstat (limited to 'app/src/main/java/se/leap')
11 files changed, 36 insertions, 49 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java index 2e9e1897..238f0ea1 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java +++ b/app/src/main/java/se/leap/bitmaskclient/ConfigHelper.java @@ -55,7 +55,7 @@ import java.util.Map; import static android.R.attr.name; import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION; import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED; -import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; +import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION; /** * Stores constants, and implements auxiliary methods used across all Bitmask Android classes. @@ -355,7 +355,7 @@ public class ConfigHelper { putString(Provider.MAIN_URL, provider.getMainUrlString()). putString(Provider.KEY, provider.getDefinitionString()). putString(Provider.CA_CERT, provider.getCaCert()). - putString(PROVIDER_KEY, provider.getEipServiceJsonString()). + putString(PROVIDER_EIP_DEFINITION, provider.getEipServiceJsonString()). commit(); String providerDomain = provider.getDomain(); @@ -363,7 +363,7 @@ public class ConfigHelper { putString(Provider.MAIN_URL + "." + providerDomain, provider.getMainUrlString()). putString(Provider.KEY + "." + providerDomain, provider.getDefinitionString()). putString(Provider.CA_CERT + "." + providerDomain, provider.getCaCert()). - putString(PROVIDER_KEY + "." + providerDomain, provider.getEipServiceJsonString()). + putString(PROVIDER_EIP_DEFINITION + "." + providerDomain, provider.getEipServiceJsonString()). apply(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/Constants.java b/app/src/main/java/se/leap/bitmaskclient/Constants.java index 6b5c6bb7..680c10bf 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Constants.java +++ b/app/src/main/java/se/leap/bitmaskclient/Constants.java @@ -58,6 +58,7 @@ public interface Constants { String PROVIDER_PRIVATE_KEY = "Constants.PROVIDER_PRIVATE_KEY"; String PROVIDER_KEY = "Constants.PROVIDER_KEY"; String PROVIDER_CONFIGURED = "Constants.PROVIDER_CONFIGURED"; + String PROVIDER_EIP_DEFINITION = "Constants.EIP_DEFINITION"; ////////////////////////////////////////////// // CREDENTIAL CONSTANTS diff --git a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java index 2f129d02..48dce1c2 100644 --- a/app/src/main/java/se/leap/bitmaskclient/Dashboard.java +++ b/app/src/main/java/se/leap/bitmaskclient/Dashboard.java @@ -47,7 +47,7 @@ import static se.leap.bitmaskclient.Constants.APP_ACTION_QUIT; import static se.leap.bitmaskclient.Constants.EIP_IS_ALWAYS_ON; import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT; import static se.leap.bitmaskclient.Constants.PROVIDER_CONFIGURED; -import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; +import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION; import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP; import static se.leap.bitmaskclient.Constants.REQUEST_CODE_KEY; import static se.leap.bitmaskclient.Constants.REQUEST_CODE_SWITCH_PROVIDER; @@ -161,7 +161,7 @@ public class Dashboard extends ButterKnifeActivity { switch (versionCode) { case 91: // 0.6.0 without Bug #5999 case 101: // 0.8.0 - if (!preferences.getString(PROVIDER_KEY, "").isEmpty()) + if (!preferences.getString(PROVIDER_EIP_DEFINITION, "").isEmpty()) EipCommand.updateEipService(this); break; } diff --git a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java index 8d56cdf8..8a6d981d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/DownloadFailedDialog.java @@ -86,12 +86,13 @@ public class DownloadFailedDialog extends DialogFragment { } @Override + @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(reasonToFail) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { - interface_with_ConfigurationWizard.cancelSettingUpProvider(); + interfaceWithConfigurationWizard.cancelSettingUpProvider(); dialog.dismiss(); } }); @@ -101,7 +102,7 @@ switch (downloadError) { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); - interface_with_ConfigurationWizard.updateProviderDetails(); + interfaceWithConfigurationWizard.updateProviderDetails(); } }); break; @@ -111,7 +112,7 @@ switch (downloadError) { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); - interface_with_ConfigurationWizard.updateProviderDetails(); + interfaceWithConfigurationWizard.updateProviderDetails(); } }); break; @@ -119,7 +120,7 @@ switch (downloadError) { builder.setPositiveButton(R.string.retry, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dismiss(); - interface_with_ConfigurationWizard.retrySetUpProvider(provider); + interfaceWithConfigurationWizard.retrySetUpProvider(provider); } }); break; @@ -137,13 +138,13 @@ switch (downloadError) { void updateProviderDetails(); } - DownloadFailedDialogInterface interface_with_ConfigurationWizard; + DownloadFailedDialogInterface interfaceWithConfigurationWizard; @Override public void onAttach(Context context) { super.onAttach(context); try { - interface_with_ConfigurationWizard = (DownloadFailedDialogInterface) context; + interfaceWithConfigurationWizard = (DownloadFailedDialogInterface) context; } catch (ClassCastException e) { throw new ClassCastException(context.toString() + " must implement NoticeDialogListener"); @@ -152,7 +153,7 @@ switch (downloadError) { @Override public void onCancel(DialogInterface dialog) { - interface_with_ConfigurationWizard.cancelSettingUpProvider(); + interfaceWithConfigurationWizard.cancelSettingUpProvider(); dialog.dismiss(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java index b2a39c1a..969f006a 100644 --- a/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java +++ b/app/src/main/java/se/leap/bitmaskclient/FeatureVersionCode.java @@ -2,4 +2,5 @@ package se.leap.bitmaskclient; public interface FeatureVersionCode { int MULTIPLE_PROFILES = 132; + int RENAMED_EIP_IN_PREFERENCES = 132; } diff --git a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java index 9c047bc9..06a66e43 100644 --- a/app/src/main/java/se/leap/bitmaskclient/MainActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/MainActivity.java @@ -71,11 +71,12 @@ public class MainActivity extends AppCompatActivity { switch (intent.getAction()) { case ACTION_SHOW_VPN_FRAGMENT: fragment = new EipFragment(); + Bundle bundle = new Bundle(); if (intent.hasExtra(ASK_TO_CANCEL_VPN)) { - Bundle bundle = new Bundle(); bundle.putBoolean(ASK_TO_CANCEL_VPN, true); - fragment.setArguments(bundle); } + bundle.putParcelable(PROVIDER_KEY, provider); + fragment.setArguments(bundle); break; default: break; diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java index 73f5c530..4bffd1b2 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java @@ -76,11 +76,6 @@ public class ProviderAPI extends IntentService implements ProviderApiManagerBase } //TODO: refactor me, please! - public static void stop() { - ProviderApiManager.stop(); - } - - //TODO: refactor me, please! //used in insecure flavor only @SuppressLint("unused") public static boolean lastDangerOn() { diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java index 6b6aa89d..f1c0ecef 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java @@ -115,15 +115,10 @@ public abstract class ProviderApiManagerBase { private ProviderApiServiceCallback serviceCallback; - static boolean go_ahead = true; protected SharedPreferences preferences; protected Resources resources; OkHttpClientGenerator clientGenerator; - public static void stop() { - go_ahead = false; - } - ProviderApiManagerBase(SharedPreferences preferences, Resources resources, OkHttpClientGenerator clientGenerator, ProviderApiServiceCallback callback) { this.preferences = preferences; this.resources = resources; @@ -158,12 +153,10 @@ public abstract class ProviderApiManagerBase { } } else if (action.equalsIgnoreCase(SET_UP_PROVIDER)) { Bundle result = setUpProvider(provider, parameters); - if (go_ahead) { - if (result.getBoolean(BROADCAST_RESULT_KEY)) { - sendToReceiverOrBroadcast(receiver, PROVIDER_OK, result, provider); - } else { - sendToReceiverOrBroadcast(receiver, PROVIDER_NOK, result, provider); - } + if (result.getBoolean(BROADCAST_RESULT_KEY)) { + sendToReceiverOrBroadcast(receiver, PROVIDER_OK, result, provider); + } else { + sendToReceiverOrBroadcast(receiver, PROVIDER_NOK, result, provider); } } else if (action.equalsIgnoreCase(SIGN_UP)) { Bundle result = tryToRegister(parameters); diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java index 6a76dd55..6fa3b503 100644 --- a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java @@ -46,7 +46,6 @@ import butterknife.InjectView; import butterknife.OnItemClick; import se.leap.bitmaskclient.fragments.AboutFragment; -import static android.view.View.GONE; import static se.leap.bitmaskclient.Constants.APP_ACTION_QUIT; import static se.leap.bitmaskclient.Constants.BROADCAST_PROVIDER_API_EVENT; import static se.leap.bitmaskclient.Constants.BROADCAST_RESULT_CODE; @@ -229,10 +228,6 @@ public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity } void handleProviderSetupFailed(Bundle resultData) { - mConfigState.setAction(PROVIDER_NOT_SET); - - setResult(RESULT_CANCELED, mConfigState); - reasonToFail = resultData.getString(ERRORS); showDownloadFailedDialog(); } @@ -242,8 +237,7 @@ public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity } void handleIncorrectlyDownloadedCertificate() { - mConfigState.setAction(PROVIDER_NOT_SET); - hideProgressBar(); + cancelSettingUpProvider(); setResult(RESULT_CANCELED, mConfigState); } @@ -289,26 +283,18 @@ public abstract class ProviderListBaseActivity extends ConfigWizardBaseActivity } private void stopSettingUpProvider() { - ProviderAPI.stop(); - loadingScreen.setVisibility(GONE); - cancelSettingUpProvider(); } @Override public void cancelSettingUpProvider() { - hideProgressBar(); mConfigState.setAction(PROVIDER_NOT_SET); + hideProgressBar(); } @Override public void updateProviderDetails() { - mConfigState.setAction(SETTING_UP_PROVIDER); - - Bundle parameters = new Bundle(); - parameters.putString(Provider.MAIN_URL, provider.getMainUrl().toString()); - - ProviderAPICommand.execute(this, UPDATE_PROVIDER_DETAILS, parameters, provider); + ProviderAPICommand.execute(this, UPDATE_PROVIDER_DETAILS, provider); } public void checkProviderSetUp() { diff --git a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java index a7b713c5..288b157f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/StartActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/StartActivity.java @@ -20,6 +20,8 @@ import static se.leap.bitmaskclient.Constants.APP_ACTION_CONFIGURE_ALWAYS_ON_PRO import static se.leap.bitmaskclient.Constants.EIP_ACTION_START; import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT; import static se.leap.bitmaskclient.Constants.PREFERENCES_APP_VERSION; +import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION; +import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP; import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; import static se.leap.bitmaskclient.MainActivity.ACTION_SHOW_VPN_FRAGMENT; @@ -127,6 +129,13 @@ public class StartActivity extends Activity { if (hasNewFeature(FeatureVersionCode.MULTIPLE_PROFILES)) { // TODO prepare usage of multiple profiles } + if (hasNewFeature(FeatureVersionCode.RENAMED_EIP_IN_PREFERENCES)) { + String eipJson = preferences.getString(PROVIDER_KEY, null); + if (eipJson != null) { + preferences.edit().putString(PROVIDER_EIP_DEFINITION, eipJson). + remove(PROVIDER_KEY).apply(); + } + } // ensure all upgrades have passed before storing new information storeAppVersion(); diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java index 474bf045..bfecda22 100644 --- a/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java +++ b/app/src/main/java/se/leap/bitmaskclient/eip/EIP.java @@ -44,7 +44,7 @@ import static se.leap.bitmaskclient.Constants.EIP_ACTION_UPDATE; import static se.leap.bitmaskclient.Constants.EIP_RECEIVER; import static se.leap.bitmaskclient.Constants.EIP_REQUEST; import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT; -import static se.leap.bitmaskclient.Constants.PROVIDER_KEY; +import static se.leap.bitmaskclient.Constants.PROVIDER_EIP_DEFINITION; import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE; import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES; @@ -214,7 +214,7 @@ public final class EIP extends IntentService { private JSONObject eipDefinitionFromPreferences() { JSONObject result = new JSONObject(); try { - String eipDefinitionString = preferences.getString(PROVIDER_KEY, ""); + String eipDefinitionString = preferences.getString(PROVIDER_EIP_DEFINITION, ""); if (!eipDefinitionString.isEmpty()) { result = new JSONObject(eipDefinitionString); } |