summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-07-25 11:19:23 +0200
committercyBerta <cyberta@riseup.net>2020-07-25 11:19:23 +0200
commita2af7f5c226db54442220779cef575d82d215485 (patch)
tree5e24c004473bef4de3aba042d88455bdbab46953 /app
parentbdd909d1faae569f27d61ad510d11fad74a5a27c (diff)
get rid of ProviderAPIResultReceiver, rely completely on BroadcastReceivers
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/CustomProviderSetupActivity.java5
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java3
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java57
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java10
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java23
6 files changed, 7 insertions, 103 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/CustomProviderSetupActivity.java b/app/src/main/java/se/leap/bitmaskclient/CustomProviderSetupActivity.java
index 8f17d482..29d1b09e 100644
--- a/app/src/main/java/se/leap/bitmaskclient/CustomProviderSetupActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/CustomProviderSetupActivity.java
@@ -107,11 +107,6 @@ public class CustomProviderSetupActivity extends ProviderSetupBaseActivity {
}
@Override
- public void onReceiveResult(int resultCode, Bundle resultData) {
-
- }
-
- @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) {
setResult(resultCode, data);
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
index 767e6a78..4058b824 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderAPI.java
@@ -62,8 +62,7 @@ public class ProviderAPI extends JobIntentService implements ProviderApiManagerB
BACKEND_ERROR_KEY = "error",
BACKEND_ERROR_MESSAGE = "message",
USER_MESSAGE = "userMessage",
- DOWNLOAD_SERVICE_JSON = "ProviderAPI.DOWNLOAD_SERVICE_JSON",
- PROVIDER_SET_UP = "ProviderAPI.PROVIDER_SET_UP";
+ DOWNLOAD_SERVICE_JSON = "ProviderAPI.DOWNLOAD_SERVICE_JSON";
final public static int
SUCCESSFUL_LOGIN = 3,
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java b/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
deleted file mode 100644
index 9b777e5a..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderAPIResultReceiver.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (c) 2013 LEAP Encryption Access Project and contributers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package se.leap.bitmaskclient;
-
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.ResultReceiver;
-
-/**
- * Implements the ResultReceiver needed by Activities using ProviderAPI to receive the results of its operations.
- *
- * @author parmegv
- */
-public class ProviderAPIResultReceiver extends ResultReceiver {
- private Receiver mReceiver;
-
- public ProviderAPIResultReceiver(Handler handler, Receiver receiver) {
- super(handler);
- setReceiver(receiver);
- // TODO Auto-generated constructor stub
- }
-
- public void setReceiver(Receiver receiver) {
- mReceiver = receiver;
- }
-
- /**
- * Interface to enable ProviderAPIResultReceiver to receive results from the ProviderAPI IntentService.
- *
- * @author parmegv
- */
- public interface Receiver {
- public void onReceiveResult(int resultCode, Bundle resultData);
- }
-
- @Override
- protected void onReceiveResult(int resultCode, Bundle resultData) {
- if (mReceiver != null) {
- mReceiver.onReceiveResult(resultCode, resultData);
- }
- }
-
-}
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
index e5ca184f..8825a818 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderApiManagerBase.java
@@ -92,7 +92,6 @@ import static se.leap.bitmaskclient.ProviderAPI.LOG_OUT;
import static se.leap.bitmaskclient.ProviderAPI.PARAMETERS;
import static se.leap.bitmaskclient.ProviderAPI.PROVIDER_NOK;
import static se.leap.bitmaskclient.ProviderAPI.PROVIDER_OK;
-import static se.leap.bitmaskclient.ProviderAPI.PROVIDER_SET_UP;
import static se.leap.bitmaskclient.ProviderAPI.RECEIVER_KEY;
import static se.leap.bitmaskclient.ProviderAPI.SET_UP_PROVIDER;
import static se.leap.bitmaskclient.ProviderAPI.SIGN_UP;
@@ -249,15 +248,6 @@ public abstract class ProviderApiManagerBase {
}
ProviderObservable.getInstance().getProviderForDns();
break;
- case PROVIDER_SET_UP:
- if(provider.hasEIP() && provider.hasCaCert() && provider.hasDefinition()) {
- if(receiver!= null) {
- result.putParcelable(PROVIDER_KEY, provider);
- receiver.send(PROVIDER_OK, result);
- }
- }
- break;
-
case DOWNLOAD_GEOIP_JSON:
if (!provider.getGeoipUrl().isDefault()) {
boolean startEIP = parameters.getBoolean(EIP_ACTION_START);
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
index a7d0f916..4f555f94 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderListBaseActivity.java
@@ -134,18 +134,6 @@ public abstract class ProviderListBaseActivity extends ProviderSetupBaseActivity
this.provider = handledProvider;
showProviderDetails();
}
- // -----------------------------------------
-
- //TODO: only keep empty method for testing purposes
- @Override
- public void onReceiveResult(int resultCode, Bundle resultData) {
- super.onReceiveResult(resultCode, resultData);
- if (resultCode == AboutFragment.VIEWED) {
- // Do nothing, right now
- // I need this for CW to wait for the About activity to end before going back to Dashboard.
- //FIXME: WEEEIRD!
- }
- }
@OnItemClick(R.id.provider_list)
void onItemSelected(int position) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java
index 396b8b26..89944364 100644
--- a/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/ProviderSetupBaseActivity.java
@@ -19,12 +19,12 @@ package se.leap.bitmaskclient;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
-import android.os.Handler;
+import android.util.Log;
+
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import android.util.Log;
import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
@@ -35,7 +35,6 @@ import static se.leap.bitmaskclient.Constants.PROVIDER_KEY;
import static se.leap.bitmaskclient.Constants.REQUEST_CODE_CONFIGURE_LEAP;
import static se.leap.bitmaskclient.ProviderAPI.DOWNLOAD_VPN_CERTIFICATE;
import static se.leap.bitmaskclient.ProviderAPI.ERRORS;
-import static se.leap.bitmaskclient.ProviderAPI.PROVIDER_SET_UP;
import static se.leap.bitmaskclient.ProviderAPI.UPDATE_PROVIDER_DETAILS;
import static se.leap.bitmaskclient.ProviderSetupInterface.ProviderConfigState.PENDING_SHOW_FAILED_DIALOG;
import static se.leap.bitmaskclient.ProviderSetupInterface.ProviderConfigState.PROVIDER_NOT_SET;
@@ -47,7 +46,7 @@ import static se.leap.bitmaskclient.ProviderSetupInterface.ProviderConfigState.S
* Created by cyberta on 19.08.18.
*/
-public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity implements ProviderAPIResultReceiver.Receiver, ProviderSetupInterface, ProviderSetupFailedDialog.DownloadFailedDialogInterface {
+public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity implements ProviderSetupInterface, ProviderSetupFailedDialog.DownloadFailedDialogInterface {
final public static String TAG = "PoviderSetupActivity";
final private static String ACTIVITY_STATE = "ACTIVITY STATE";
final private static String REASON_TO_FAIL = "REASON TO FAIL";
@@ -60,7 +59,6 @@ public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity
protected boolean testNewURL;
private ProviderApiSetupBroadcastReceiver providerAPIBroadcastReceiver;
- private ProviderAPIResultReceiver providerAPIResultReceiver;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@@ -97,7 +95,6 @@ public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity
@Override
protected void onDestroy() {
super.onDestroy();
- providerAPIResultReceiver = null;
}
@@ -163,15 +160,6 @@ public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity
ProviderAPICommand.execute(this, UPDATE_PROVIDER_DETAILS, provider);
}
- // -------- ProviderAPIResultReceiver.Receiver ---v
- @Override
- public void onReceiveResult(int resultCode, Bundle resultData) {
- if (resultCode == ProviderAPI.PROVIDER_OK) {
- Provider provider = resultData.getParcelable(PROVIDER_KEY);
- handleProviderSetUp(provider);
- }
- }
-
protected void restoreState(Bundle savedInstanceState) {
super.restoreState(savedInstanceState);
if (savedInstanceState == null) {
@@ -184,7 +172,6 @@ public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity
}
private void setUpProviderAPIResultReceiver() {
- providerAPIResultReceiver = new ProviderAPIResultReceiver(new Handler(), this);
providerAPIBroadcastReceiver = new ProviderApiSetupBroadcastReceiver(this);
IntentFilter updateIntentFilter = new IntentFilter(BROADCAST_PROVIDER_API_EVENT);
@@ -203,7 +190,9 @@ public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity
*
*/
public void checkProviderSetUp() {
- ProviderAPICommand.execute(this, PROVIDER_SET_UP, provider, providerAPIResultReceiver);
+ if (provider.isConfigured()) {
+ handleProviderSetUp(provider);
+ }
}
/**