From 4460a3cb0dfe10a32ce6697047c7331536233d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 15 Oct 2013 12:26:49 +0200 Subject: Download results stored in static variables. ProviderAPI has now 3 different static variables, each one for the 3 files that have to be downloaded to set up a provider. --- src/se/leap/bitmaskclient/ProviderAPI.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/se/leap') diff --git a/src/se/leap/bitmaskclient/ProviderAPI.java b/src/se/leap/bitmaskclient/ProviderAPI.java index b23bdc7f..bf3cf662 100644 --- a/src/se/leap/bitmaskclient/ProviderAPI.java +++ b/src/se/leap/bitmaskclient/ProviderAPI.java @@ -118,6 +118,11 @@ public class ProviderAPI extends IntentService { INCORRECTLY_DOWNLOADED_ANON_CERTIFICATE = 14 ; + public static boolean + CA_CERT_DOWNLOADED = false, + PROVIDER_JSON_DOWNLOADED = false, + EIP_SERVICE_JSON_DOWNLOADED = false + ; public ProviderAPI() { super("ProviderAPI"); Log.v("ClassName", "Provider API"); @@ -136,14 +141,14 @@ public class ProviderAPI extends IntentService { @Override protected void onHandleIntent(Intent command) { - final ResultReceiver receiver = command.getParcelableExtra("receiver"); + final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY); String action = command.getAction(); Bundle parameters = command.getBundleExtra(PARAMETERS); if(action.equalsIgnoreCase(SET_UP_PROVIDER)) { Bundle result = setUpProvider(parameters); if(result.getBoolean(RESULT_KEY)) { - receiver.send(PROVIDER_OK, result); + receiver.send(PROVIDER_OK, Bundle.EMPTY); } else { receiver.send(PROVIDER_NOK, Bundle.EMPTY); } @@ -424,15 +429,24 @@ public class ProviderAPI extends IntentService { int progress = 0; boolean danger_on = task.getBoolean(ProviderItem.DANGER_ON); String provider_main_url = task.getString(Provider.MAIN_URL); + + result.putBoolean(RESULT_KEY, false); if(downloadCACert(provider_main_url, danger_on)) { broadcast_progress(progress++); - result.putBoolean(RESULT_KEY, true); + CA_CERT_DOWNLOADED = true; if(getAndSetProviderJson(provider_main_url)) { broadcast_progress(progress++); - if(getAndSetEipServiceJson()) + PROVIDER_JSON_DOWNLOADED = true; + if(getAndSetEipServiceJson()) { broadcast_progress(progress++); + EIP_SERVICE_JSON_DOWNLOADED = true; + } } } + + if(CA_CERT_DOWNLOADED && PROVIDER_JSON_DOWNLOADED && EIP_SERVICE_JSON_DOWNLOADED) + result.putBoolean(RESULT_KEY, true); + return result; } -- cgit v1.2.3