diff options
author | cyBerta <cyberta@riseup.net> | 2019-09-27 16:25:13 +0200 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2019-09-27 16:25:13 +0200 |
commit | eebba26668588d5e644441b0dbcc04eb9f9f3eac (patch) | |
tree | 9a400d21a6ae0b8c3aa029acf86263d3b94cff3f /app/src/insecure/java | |
parent | 91877ac8ed64927d14c0762cd4402e5ed736fab9 (diff) |
fix error handling for failing fetch of eip-service.json in production flavor and minor refactorings
Diffstat (limited to 'app/src/insecure/java')
-rw-r--r-- | app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java b/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java index 1190d382..e79946bf 100644 --- a/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java +++ b/app/src/insecure/java/se/leap/bitmaskclient/ProviderApiManager.java @@ -135,8 +135,8 @@ public class ProviderApiManager extends ProviderApiManagerBase { private Bundle getAndSetProviderJson(Provider provider, boolean dangerOn) { Bundle result = new Bundle(); - JSONObject providerDefinition = provider.getDefinition(); String caCert = provider.getCaCert(); + JSONObject providerDefinition = provider.getDefinition(); String providerMainUrl = provider.getMainUrlString(); String providerDotJsonString; @@ -161,10 +161,9 @@ public class ProviderApiManager extends ProviderApiManagerBase { result.putBoolean(BROADCAST_RESULT_KEY, true); } catch (JSONException e) { - String reason_to_fail = pickErrorMessage(providerDotJsonString); - result.putString(ERRORS, reason_to_fail); - result.putBoolean(BROADCAST_RESULT_KEY, false); + setErrorResult(result, providerDotJsonString); } + //TODO: check why the following line is not in production result.putParcelable(PROVIDER_KEY, provider); return result; } @@ -185,18 +184,15 @@ public class ProviderApiManager extends ProviderApiManagerBase { JSONObject eipServiceJson = new JSONObject(eipServiceJsonString); if (eipServiceJson.has(ERRORS)) { - String reasonToFail = pickErrorMessage(eipServiceJsonString); - result.putString(ERRORS, reasonToFail); - result.putBoolean(BROADCAST_RESULT_KEY, false); + setErrorResult(result, eipServiceJsonString); } else{ provider.setEipServiceJson(eipServiceJson); result.putBoolean(BROADCAST_RESULT_KEY, true); } } catch (NullPointerException | JSONException e) { - String reasonToFail = pickErrorMessage(eipServiceJsonString); - result.putString(ERRORS, reasonToFail); - result.putBoolean(BROADCAST_RESULT_KEY, false); + setErrorResult(result, eipServiceJsonString); } + //TODO: check why the following line is not in production result.putParcelable(PROVIDER_KEY, provider); return result; } @@ -218,9 +214,7 @@ public class ProviderApiManager extends ProviderApiManagerBase { // probably 204 setErrorResult(result, error_io_exception_user_message, null); } else { - String reasonToFail = pickErrorMessage(certString); - result.putString(ERRORS, reasonToFail); - result.putBoolean(BROADCAST_RESULT_KEY, false); + setErrorResult(result, certString); return result; } } @@ -229,6 +223,7 @@ public class ProviderApiManager extends ProviderApiManagerBase { setErrorResult(result, downloading_vpn_certificate_failed, null); e.printStackTrace(); } + //TODO: check why the following line is not in production result.putParcelable(PROVIDER_KEY, provider); return result; } |