summaryrefslogtreecommitdiff
path: root/app/src/main/java/se
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2024-01-25 23:55:52 +0100
committercyBerta <cyberta@riseup.net>2024-01-25 23:55:52 +0100
commit6f7b3bbf255b0be4d5ff1bd994aad0d61b8cca8d (patch)
tree8ef413c9187285b6adade91f744948436c3c4258 /app/src/main/java/se
parent9bba7b29a416b2617af033a778ef13a512024502 (diff)
fix ProviderApiManagerTest, sneaking in some missing changes from previous commits as well
Diffstat (limited to 'app/src/main/java/se')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/ConfigHelper.java8
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/base/utils/HandlerProvider.java38
2 files changed, 46 insertions, 0 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 bb9d1196..71fe8eba 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
@@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import de.blinkt.openvpn.core.NativeUtils;
import okhttp3.internal.publicsuffix.PublicSuffixDatabase;
import se.leap.bitmaskclient.BuildConfig;
import se.leap.bitmaskclient.R;
@@ -207,4 +208,11 @@ public class ConfigHelper {
}
return flags;
}
+
+ public static int getTorTimeout() {
+ if (NativeUtils.isUnitTest()) {
+ return 1;
+ }
+ return 180;
+ }
}
diff --git a/app/src/main/java/se/leap/bitmaskclient/base/utils/HandlerProvider.java b/app/src/main/java/se/leap/bitmaskclient/base/utils/HandlerProvider.java
new file mode 100644
index 00000000..d9198ab7
--- /dev/null
+++ b/app/src/main/java/se/leap/bitmaskclient/base/utils/HandlerProvider.java
@@ -0,0 +1,38 @@
+package se.leap.bitmaskclient.base.utils;
+
+import android.os.Handler;
+import android.os.Looper;
+
+public class HandlerProvider {
+
+
+ public interface HandlerInterface {
+ void postDelayed(Runnable r, long delay);
+ }
+
+
+ private static HandlerInterface instance;
+
+ public HandlerProvider(HandlerInterface handlerInterface) {
+ instance = handlerInterface;
+ }
+ public static HandlerInterface get() {
+ if (instance == null) {
+ instance = new DefaultHandler();
+ }
+ return instance;
+ }
+
+ public static class DefaultHandler implements HandlerInterface {
+ Handler handler;
+
+ public DefaultHandler() {
+ this.handler = new Handler(Looper.getMainLooper());
+ }
+ @Override
+ public void postDelayed(Runnable r, long delay) {
+ this.handler.postDelayed(r, delay);
+ }
+ }
+}
+