summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2024-04-24 10:22:13 +0200
committercyBerta <cyberta@riseup.net>2024-04-24 10:22:13 +0200
commit19da621bebb11c1ca6723959e668ad0258929097 (patch)
tree6f9ee28f9d060d4d5ee42944f8771185d310f13b /app/src/main/java
parent2b91434f585e52fbfc229a50a36a04ef6cb8ce76 (diff)
temporary workaround that stores provider setup updates if app is in background during setup. Fixes an app crash during provider setup while app is in background
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java7
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java26
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java14
3 files changed, 41 insertions, 6 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java b/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
index ed95b75c..e96ded90 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/EipSetupObserver.java
@@ -81,7 +81,6 @@ import se.leap.bitmaskclient.base.utils.PreferenceHelper;
import se.leap.bitmaskclient.providersetup.ProviderAPI;
import se.leap.bitmaskclient.providersetup.ProviderAPICommand;
import se.leap.bitmaskclient.providersetup.ProviderSetupObservable;
-import se.leap.bitmaskclient.providersetup.activities.SetupActivity;
import se.leap.bitmaskclient.tor.TorServiceCommand;
import se.leap.bitmaskclient.tor.TorStatusObservable;
@@ -246,9 +245,7 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
//no break, continue with next case
case CORRECTLY_DOWNLOADED_VPN_CERTIFICATE:
if (ProviderSetupObservable.getProgress() > 0 && !activityForeground.get()) {
- Intent activityIntent = new Intent(appContext, SetupActivity.class);
- activityIntent.setAction(Intent.ACTION_MAIN);
- appContext.startActivity(activityIntent);
+ ProviderSetupObservable.storeLastResult(resultCode, resultData);
}
break;
case TOR_TIMEOUT:
@@ -270,6 +267,8 @@ public class EipSetupObserver extends BroadcastReceiver implements VpnStatus.Sta
for (EipSetupListener listener : listeners) {
listener.handleProviderApiEvent(intent);
}
+
+
}
private void maybeStartEipService(Bundle resultData) {
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java
index c882b0bb..1446d5ec 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderSetupObservable.java
@@ -16,6 +16,8 @@ package se.leap.bitmaskclient.providersetup;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+import android.os.Bundle;
+
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -45,13 +47,15 @@ public class ProviderSetupObservable {
public static final String PROPERTY_CHANGE = "ProviderSetupObservable";
private final HandlerInterface handler;
private long lastUpdate = 0;
+ private int resultCode = 0;
+ private Bundle resultData;
private ProviderSetupObservable() {
handler = HandlerProvider.get();
changeSupport = new PropertyChangeSupport(this);
-
+ resultData = new Bundle();
}
public void addObserver(PropertyChangeListener propertyChangeListener) {
@@ -70,6 +74,14 @@ public class ProviderSetupObservable {
return instance;
}
+ public static void storeLastResult(int resultCode, Bundle resultData) {
+ if (getInstance().canceled) {
+ return;
+ }
+ getInstance().resultCode = resultCode;
+ getInstance().resultData = resultData;
+ }
+
public static void updateProgress(int progress) {
if (getInstance().canceled) {
return;
@@ -107,6 +119,8 @@ public class ProviderSetupObservable {
public static void reset() {
getInstance().progress = 0;
+ getInstance().resultCode = 0;
+ getInstance().resultData = new Bundle();
getInstance().changeSupport.firePropertyChange(PROPERTY_CHANGE, null, getInstance());
}
@@ -121,5 +135,15 @@ public class ProviderSetupObservable {
public static void startSetup() {
getInstance().canceled = false;
+ getInstance().resultCode = 0;
+ getInstance().resultData = new Bundle();
+ }
+
+ public static int getResultCode() {
+ return getInstance().resultCode;
+ }
+
+ public static Bundle getResultData() {
+ return getInstance().resultData;
}
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java
index f20bc9b6..078b2e41 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/fragments/ConfigureProviderFragment.java
@@ -111,6 +111,14 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Prop
}
@Override
+ public void onResume() {
+ super.onResume();
+ if (ProviderSetupObservable.getProgress() > 0) {
+ handleResult(ProviderSetupObservable.getResultCode(), ProviderSetupObservable.getResultData());
+ }
+ }
+
+ @Override
public void onDestroyView() {
setupActivityCallback.removeCancelCallback(this);
ProviderSetupObservable.getInstance().deleteObserver(this);
@@ -203,11 +211,15 @@ public class ConfigureProviderFragment extends BaseSetupFragment implements Prop
if (resultData == null) {
resultData = Bundle.EMPTY;
}
+ handleResult(resultCode, resultData);
+ }
+
+ private void handleResult(int resultCode, Bundle resultData) {
Provider provider = resultData.getParcelable(PROVIDER_KEY);
if (ignoreProviderAPIUpdates ||
provider == null ||
(setupActivityCallback.getSelectedProvider() != null &&
- !setupActivityCallback.getSelectedProvider().getMainUrlString().equals(provider.getMainUrlString()))) {
+ !setupActivityCallback.getSelectedProvider().getMainUrlString().equals(provider.getMainUrlString()))) {
return;
}