summaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java44
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/models/FeatureVersionCode.java1
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/models/ProviderObservable.java4
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java14
4 files changed, 43 insertions, 20 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
index 1ea574ff..2ccbe514 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java
@@ -89,7 +89,6 @@ public class StartActivity extends Activity{
case UPGRADE:
executeUpgrade();
- // TODO show donation dialog
break;
}
@@ -154,7 +153,19 @@ public class StartActivity extends Activity{
Provider provider = ProviderObservable.getInstance().getCurrentProvider();
if (provider != null && !provider.isDefault()) {
PreferenceHelper.deleteProviderDetailsFromPreferences(preferences, provider.getDomain());
- ProviderObservable.getInstance().updateProvider(null);
+ ProviderObservable.getInstance().updateProvider(new Provider());
+ }
+ }
+
+ if (hasNewFeature(FeatureVersionCode.CALYX_PROVIDER_LILYPAD_UPDATE) && (
+ getPackageName().equals("org.calyxinstitute.vpn") ||
+ ProviderObservable.getInstance().getCurrentProvider().getDomain().equals("calyx.net"))) {
+ // deletion of current configured provider so that a new provider setup is triggered
+ Provider provider = ProviderObservable.getInstance().getCurrentProvider();
+ if (provider != null && !provider.isDefault()) {
+ PreferenceHelper.deleteProviderDetailsFromPreferences(preferences, provider.getDomain());
+ PreferenceHelper.deleteCurrentProviderDetailsFromPreferences(preferences);
+ ProviderObservable.getInstance().updateProvider(new Provider());
}
}
@@ -181,24 +192,19 @@ public class StartActivity extends Activity{
}
private void prepareEIP() {
- boolean providerExists = ProviderObservable.getInstance().getCurrentProvider() != null;
- if (providerExists) {
- Provider provider = ProviderObservable.getInstance().getCurrentProvider();
- if(!provider.isConfigured()) {
- configureLeapProvider();
+ Provider provider = ProviderObservable.getInstance().getCurrentProvider();
+ if (provider.isConfigured()) {
+ Log.d(TAG, "vpn provider is configured");
+ if (getIntent() != null && getIntent().getBooleanExtra(EIP_RESTART_ON_BOOT, false)) {
+ EipCommand.startVPN(this, true);
+ finish();
+ } else if (PreferenceHelper.getRestartOnUpdate(this.getApplicationContext())) {
+ PreferenceHelper.restartOnUpdate(this.getApplicationContext(), false);
+ EipCommand.startVPN(this, false);
+ showMainActivity();
+ finish();
} else {
- Log.d(TAG, "vpn provider is configured");
- if (getIntent() != null && getIntent().getBooleanExtra(EIP_RESTART_ON_BOOT, false)) {
- EipCommand.startVPN(this, true);
- finish();
- } else if (PreferenceHelper.getRestartOnUpdate(this.getApplicationContext())) {
- PreferenceHelper.restartOnUpdate(this.getApplicationContext(), false);
- EipCommand.startVPN(this, false);
- showMainActivity();
- finish();
- } else {
- showMainActivity();
- }
+ showMainActivity();
}
} else {
configureLeapProvider();
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/FeatureVersionCode.java b/app/src/main/java/se/leap/bitmaskclient/base/models/FeatureVersionCode.java
index 7b3f1888..95decb82 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/models/FeatureVersionCode.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/models/FeatureVersionCode.java
@@ -3,4 +3,5 @@ package se.leap.bitmaskclient.base.models;
public interface FeatureVersionCode {
int RENAMED_EIP_IN_PREFERENCES = 132;
int GEOIP_SERVICE = 148;
+ int CALYX_PROVIDER_LILYPAD_UPDATE = 163000;
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/models/ProviderObservable.java b/app/src/main/java/se/leap/bitmaskclient/base/models/ProviderObservable.java
index 19555504..3e1e1fcc 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/models/ProviderObservable.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/models/ProviderObservable.java
@@ -1,5 +1,7 @@
package se.leap.bitmaskclient.base.models;
+import androidx.annotation.NonNull;
+
import java.util.Observable;
/**
@@ -17,7 +19,7 @@ public class ProviderObservable extends Observable {
return instance;
}
- public synchronized void updateProvider(Provider provider) {
+ public synchronized void updateProvider(@NonNull Provider provider) {
instance.currentProvider = provider;
instance.providerForDns = null;
instance.setChanged();
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
index 3a2cf754..22fe42ff 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java
@@ -131,6 +131,20 @@ public class PreferenceHelper {
apply();
}
+ public static void deleteCurrentProviderDetailsFromPreferences(@NonNull SharedPreferences preferences) {
+ preferences.edit().
+ remove(Provider.KEY).
+ remove(Provider.CA_CERT).
+ remove(Provider.PROVIDER_IP).
+ remove(Provider.PROVIDER_API_IP).
+ remove(Provider.MAIN_URL).
+ remove(Provider.GEOIP_URL).
+ remove(PROVIDER_EIP_DEFINITION).
+ remove(PROVIDER_PRIVATE_KEY).
+ remove(PROVIDER_VPN_CERTIFICATE).
+ apply();
+ }
+
public static void setLastAppUpdateCheck(Context context) {
putLong(context, LAST_UPDATE_CHECK, System.currentTimeMillis());
}