summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/base/utils
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/base/utils')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java12
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/PreferenceHelper.java46
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java36
3 files changed, 75 insertions, 19 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
index ca1261a8..102756c4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java
@@ -273,5 +273,17 @@ public class ConfigHelper {
Matcher matcher = IPv4_PATTERN.matcher(ipv4);
return matcher.matches();
}
+
+ public static boolean isCalyxOSWithTetheringSupport(Context context) {
+ return SystemPropertiesHelper.contains("ro.calyxos.version", context) &&
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
+ }
+ // ObfsVpnHelper class allows us to mock BuildConfig.use_obfsvpn while
+ // not mocking the whole ConfigHelper class
+ public static class ObfsVpnHelper {
+ public static boolean useObfsVpn() {
+ return BuildConfig.use_obfsvpn;
+ }
+ }
}
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 08bfbdc3..3a2cf754 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
@@ -1,25 +1,7 @@
package se.leap.bitmaskclient.base.utils;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.Preference;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.WorkerThread;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import de.blinkt.openvpn.VpnProfile;
-import se.leap.bitmaskclient.base.models.Provider;
-import se.leap.bitmaskclient.tor.TorStatusObservable;
-
import static android.content.Context.MODE_PRIVATE;
+import static se.leap.bitmaskclient.base.models.Constants.ALLOW_EXPERIMENTAL_TRANSPORTS;
import static se.leap.bitmaskclient.base.models.Constants.ALLOW_TETHERING_BLUETOOTH;
import static se.leap.bitmaskclient.base.models.Constants.ALLOW_TETHERING_USB;
import static se.leap.bitmaskclient.base.models.Constants.ALLOW_TETHERING_WIFI;
@@ -42,6 +24,24 @@ import static se.leap.bitmaskclient.base.models.Constants.USE_BRIDGES;
import static se.leap.bitmaskclient.base.models.Constants.USE_IPv6_FIREWALL;
import static se.leap.bitmaskclient.base.models.Constants.USE_SNOWFLAKE;
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.WorkerThread;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import de.blinkt.openvpn.VpnProfile;
+import se.leap.bitmaskclient.base.models.Provider;
+import se.leap.bitmaskclient.tor.TorStatusObservable;
+
/**
* Created by cyberta on 18.03.18.
*/
@@ -238,6 +238,14 @@ public class PreferenceHelper {
return getBoolean(context, SHOW_EXPERIMENTAL, false);
}
+ public static void setAllowExperimentalTransports(Context context, boolean show) {
+ putBoolean(context, ALLOW_EXPERIMENTAL_TRANSPORTS, show);
+ }
+
+ public static boolean allowExperimentalTransports(Context context) {
+ return getBoolean(context, ALLOW_EXPERIMENTAL_TRANSPORTS, false);
+ }
+
public static void setUseIPv6Firewall(Context context, boolean useFirewall) {
putBoolean(context, USE_IPv6_FIREWALL, useFirewall);
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java
new file mode 100644
index 00000000..b148f685
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/SystemPropertiesHelper.java
@@ -0,0 +1,36 @@
+package se.leap.bitmaskclient.base.utils;
+
+import android.content.Context;
+
+import java.lang.reflect.Method;
+
+
+public class SystemPropertiesHelper {
+
+ /**
+ * Checks if SystemProperties contains a given key using reflection
+ * @return true if reflection was successful and the key was found
+ */
+ public static boolean contains(String key, Context context) {
+ String result = null;
+ try {
+ ClassLoader cl = context.getClassLoader();
+ @SuppressWarnings("rawtypes")
+ Class SystemProperties = cl.loadClass("android.os.SystemProperties");
+ @SuppressWarnings("rawtypes")
+ Class[] paramTypes= new Class[1];
+ paramTypes[0]= String.class;
+
+ Method get = SystemProperties.getMethod("get", paramTypes);
+ Object[] params= new Object[1];
+ params[0]= key;
+
+ result = (String) get.invoke(SystemProperties, params);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return result != null;
+ }
+}
+