diff --git a/app/src/main/java/com/fox2code/mmm/MainApplication.java b/app/src/main/java/com/fox2code/mmm/MainApplication.java
index 60cb8c4..9b1ee4b 100644
--- a/app/src/main/java/com/fox2code/mmm/MainApplication.java
+++ b/app/src/main/java/com/fox2code/mmm/MainApplication.java
@@ -106,6 +106,10 @@ public class MainApplication extends Application implements CompatActivity.Appli
return getSharedPreferences().getBoolean("pref_wrap_text", false);
}
+ public static boolean isDohEnabled() {
+ return getSharedPreferences().getBoolean("pref_dns_over_https", true);
+ }
+
public static boolean isDeveloper() {
return BuildConfig.DEBUG ||
getSharedPreferences().getBoolean("developer", false);
diff --git a/app/src/main/java/com/fox2code/mmm/NotificationType.java b/app/src/main/java/com/fox2code/mmm/NotificationType.java
index 13c8391..0cb2673 100644
--- a/app/src/main/java/com/fox2code/mmm/NotificationType.java
+++ b/app/src/main/java/com/fox2code/mmm/NotificationType.java
@@ -21,7 +21,6 @@ import java.util.zip.ZipFile;
interface NotificationTypeCst {
String TAG = "NotificationType";
- boolean ROOTLESS_TEST = true;
}
public enum NotificationType implements NotificationTypeCst {
@@ -110,7 +109,7 @@ public enum NotificationType implements NotificationTypeCst {
}, true) {
@Override
public boolean shouldRemove() {
- return (!(ROOTLESS_TEST && BuildConfig.DEBUG)) &&
+ return !BuildConfig.DEBUG &&
(MainApplication.isShowcaseMode() ||
InstallerInitializer.peekMagiskPath() == null);
}
@@ -135,11 +134,13 @@ public enum NotificationType implements NotificationTypeCst {
this(textId, iconId, backgroundAttr, foregroundAttr, null);
}
- NotificationType(@StringRes int textId, int iconId, int backgroundAttr, int foregroundAttr, View.OnClickListener onClickListener) {
- this(textId, iconId, backgroundAttr, foregroundAttr, null, false);
+ NotificationType(@StringRes int textId, int iconId, int backgroundAttr, int foregroundAttr,
+ View.OnClickListener onClickListener) {
+ this(textId, iconId, backgroundAttr, foregroundAttr, onClickListener, false);
}
- NotificationType(@StringRes int textId, int iconId, int backgroundAttr, int foregroundAttr, View.OnClickListener onClickListener, boolean special) {
+ NotificationType(@StringRes int textId, int iconId, int backgroundAttr, int foregroundAttr,
+ View.OnClickListener onClickListener, boolean special) {
this.textId = textId;
this.iconId = iconId;
this.backgroundAttr = backgroundAttr;
diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java
index c191c15..26b91d0 100644
--- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java
+++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java
@@ -107,6 +107,8 @@ public class AndroidacyRepoData extends RepoData {
for (int i = 0; i < len; i++) {
jsonObject = jsonArray.getJSONObject(i);
String moduleId = jsonObject.getString("codename");
+ // Deny remote modules ids shorter than 3 chars
+ if (moduleId.length() < 3) continue;
long lastUpdate = jsonObject.getLong("updated_at") * 1000;
lastLastUpdate = Math.max(lastLastUpdate, lastUpdate);
RepoModule repoModule = this.moduleHashMap.get(moduleId);
diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java
index 0089f69..fdffeba 100644
--- a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java
+++ b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java
@@ -85,8 +85,8 @@ public class RepoData {
for (int i = 0; i < len; i++) {
JSONObject module = array.getJSONObject(i);
String moduleId = module.getString("id");
- // Deny remote modules ids shorter than 3 chars long or that start with a digit
- if (moduleId.length() < 3 || Character.isDigit(moduleId.charAt(0))) continue;
+ // Deny remote modules ids shorter than 3 chars
+ if (moduleId.length() < 3) continue;
long moduleLastUpdate = module.getLong("last_update");
String moduleNotesUrl = module.getString("notes_url");
String modulePropsUrl = module.getString("prop_url");
diff --git a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
index 6b05af5..d5a8589 100644
--- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
+++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
@@ -23,6 +23,7 @@ import com.fox2code.mmm.compat.CompatThemeWrapper;
import com.fox2code.mmm.installer.InstallerInitializer;
import com.fox2code.mmm.repo.RepoData;
import com.fox2code.mmm.repo.RepoManager;
+import com.fox2code.mmm.utils.Http;
import com.fox2code.mmm.utils.IntentHelper;
import com.mikepenz.aboutlibraries.LibsBuilder;
import com.topjohnwu.superuser.internal.UiThreadHandler;
@@ -83,6 +84,10 @@ public class SettingsActivity extends CompatActivity {
}
return true;
});
+ findPreference("pref_dns_over_https").setOnPreferenceChangeListener((p, v) -> {
+ Http.setDoh((Boolean) v);
+ return true;
+ });
if ("dark".equals(themePreference.getValue())) {
findPreference("pref_force_dark_terminal").setEnabled(false);
}
diff --git a/app/src/main/java/com/fox2code/mmm/utils/Http.java b/app/src/main/java/com/fox2code/mmm/utils/Http.java
index b6da90b..4ca5984 100644
--- a/app/src/main/java/com/fox2code/mmm/utils/Http.java
+++ b/app/src/main/java/com/fox2code/mmm/utils/Http.java
@@ -52,9 +52,12 @@ import okio.BufferedSink;
public class Http {
private static final String TAG = "Http";
private static final OkHttpClient httpClient;
+ private static final OkHttpClient httpClientDoH;
private static final OkHttpClient httpClientWithCache;
+ private static final OkHttpClient httpClientWithCacheDoH;
private static final FallBackDNS fallbackDNS;
private static final String androidacyUA;
+ private static boolean doh;
static {
MainApplication mainApplication = MainApplication.getINSTANCE();
@@ -131,26 +134,33 @@ public class Http {
return chain.proceed(request.build());
});
// Fallback DNS cache responses in case request fail but already succeeded once in the past
- httpclientBuilder.dns(fallbackDNS = new FallBackDNS(mainApplication, dns,
+ fallbackDNS = new FallBackDNS(mainApplication, dns,
"github.com", "api.github.com", "raw.githubusercontent.com",
"camo.githubusercontent.com", "user-images.githubusercontent.com",
"cdn.jsdelivr.net", "img.shields.io", "magisk-modules-repo.github.io",
- "www.androidacy.com", "api.androidacy.com"));
+ "www.androidacy.com", "api.androidacy.com");
httpclientBuilder.cookieJar(new CDNCookieJar(true));
+ httpclientBuilder.dns(Dns.SYSTEM);
httpClient = httpclientBuilder.build();
+ httpclientBuilder.dns(fallbackDNS);
+ httpClientDoH = httpclientBuilder.build();
httpclientBuilder.cache(new Cache(
new File(mainApplication.getCacheDir(), "http_cache"),
16L * 1024L * 1024L)); // 16Mib of cache
+ httpclientBuilder.dns(Dns.SYSTEM);
httpClientWithCache = httpclientBuilder.build();
+ httpclientBuilder.dns(fallbackDNS);
+ httpClientWithCacheDoH = httpclientBuilder.build();
Log.i(TAG, "Initialized Http successfully!");
+ doh = MainApplication.isDohEnabled();
}
public static OkHttpClient getHttpClient() {
- return httpClient;
+ return doh ? httpClientDoH : httpClient;
}
public static OkHttpClient getHttpClientWithCache() {
- return httpClientWithCache;
+ return doh ? httpClientWithCacheDoH : httpClientWithCache;
}
public static byte[] doHttpGet(String url,boolean allowCache) throws IOException {
@@ -241,6 +251,11 @@ public class Http {
return androidacyUA;
}
+ public static void setDoh(boolean doh) {
+ Log.d(TAG, "DoH: " + Http.doh + " -> " + doh);
+ Http.doh = doh;
+ }
+
/**
* Cookie jar that allow CDN cookies, reset on app relaunch
* Note: An argument can be made that it allow tracking but
diff --git a/app/src/main/res/drawable/ic_baseline_security_24.xml b/app/src/main/res/drawable/ic_baseline_security_24.xml
new file mode 100644
index 0000000..c9e27cc
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_security_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7998a59..4943369 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -74,7 +74,10 @@
and/or indicating poor module quality, disable at your own risk!
Dns over https
- May fix connections issues in some cases.
+
+ May fix connections issues in some cases.
+ (Does not apply to WebView)
+
Disable extensions
Disable Fox\'s Mmm extensions, this prevent modules from using
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index c1f177c..c53b442 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -71,6 +71,14 @@
app:title="@string/use_magisk_install_command_pref"
app:summary="@string/use_magisk_install_command_desc"
app:singleLineTitle="false" />
+
+