From eb434ae79f45dfd5c14c0901c414a287221442d4 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 6 Nov 2021 02:52:38 +0100 Subject: fix tor provider setup fallback mechanism --- .../bitmaskclient/base/utils/PreferenceHelper.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'app/src/main/java/se/leap/bitmaskclient/base/utils') 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 { -- cgit v1.2.3