summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java20
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java8
2 files changed, 13 insertions, 15 deletions
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 663e339e..7bbd032e 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
@@ -35,6 +35,7 @@ import static se.leap.bitmaskclient.base.models.Constants.SHARED_PREFERENCES;
import static se.leap.bitmaskclient.base.models.Constants.SHOW_EXPERIMENTAL;
import static se.leap.bitmaskclient.base.models.Constants.USE_IPv6_FIREWALL;
import static se.leap.bitmaskclient.base.models.Constants.USE_BRIDGES;
+import static se.leap.bitmaskclient.base.models.Constants.USE_TOR;
/**
* Created by cyberta on 18.03.18.
@@ -152,11 +153,18 @@ public class PreferenceHelper {
public static void useBridges(Context context, boolean isEnabled) {
putBoolean(context, USE_BRIDGES, isEnabled);
+ putBoolean(context, USE_TOR, isEnabled);
if (!isEnabled) {
TorStatusObservable.setProxyPort(-1);
}
}
+ // in contrast to USE_BRIDGES, USE_TOR in enabled by default
+ // This way the initial provider setup can rely on tor as fallback circumvention mechanism
+ public static Boolean getUseTor(SharedPreferences preferences) {
+ return preferences.getBoolean(USE_TOR, true);
+ }
+
public static void saveBattery(Context context, boolean isEnabled) {
putBoolean(context, DEFAULT_SHARED_PREFS_BATTERY_SAVER, isEnabled);
}
@@ -221,18 +229,6 @@ public class PreferenceHelper {
putString(context, PREFERRED_CITY, city);
}
- /* public static Boolean useTor(SharedPreferences preferences) {
- return preferences.getBoolean(USE_TOR, true);
- }
-
- public static boolean useTor(Context context) {
- return getBoolean(context, USE_TOR, true);
- }
-
- public static void setUseTor(Context context, boolean useTor) {
- putBoolean(context, USE_TOR, useTor);
- }*/
-
public static JSONObject getEipDefinitionFromPreferences(SharedPreferences preferences) {
JSONObject result = new JSONObject();
try {
diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java
index 555eb21d..c385c4c4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java
+++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiManagerBase.java
@@ -191,7 +191,9 @@ public abstract class ProviderApiManagerBase {
}
try {
- startTorProxy();
+ if (PreferenceHelper.getUseBridges(preferences)) {
+ startTorProxy();
+ }
} catch (InterruptedException | IllegalStateException e) {
e.printStackTrace();
return;
@@ -301,8 +303,8 @@ public abstract class ProviderApiManagerBase {
}
protected boolean startTorProxy() throws InterruptedException, IllegalStateException, TimeoutException {
- if (PreferenceHelper.getUseBridges(preferences) &&
- EipStatus.getInstance().isDisconnected() &&
+ if (EipStatus.getInstance().isDisconnected() &&
+ PreferenceHelper.getUseTor(preferences) &&
serviceCallback.isConnectedToWifi()
) {
serviceCallback.startTorService();