DivestOS/Patches/LineageOS-20.0/android_lineage-sdk/0001-Private_DNS-Migration.patch
Tad d1103ddc2f
Churn
Signed-off-by: Tad <tad@spotco.us>
2023-10-13 04:41:22 -04:00

86 lines
5.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Wed, 31 May 2023 12:38:29 -0400
Subject: [PATCH] Migrate Private DNS preset modes to hostname-mode based
Credit: CalyxOS
- Tommy Webb <tommy@calyxinstitute.org>
https://review.calyxos.org/c/CalyxOS/platform_calyx-sdk/+/17311
Change-Id: Ie3990a6e789be22da0c7771d85ad71034ed334eb
---
.../LineageDatabaseHelper.java | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
index 829a5e50..f16f2c7a 100644
--- a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
+++ b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
@@ -120,6 +120,66 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
+
+ // DNS migration XXX: shouldn't be here
+ final String currentPrivateDnsMode = Settings.Global.getString(
+ mContext.getContentResolver(), Settings.Global.PRIVATE_DNS_MODE);
+ if (!"off".equals(currentPrivateDnsMode) && !"hostname".equals(currentPrivateDnsMode) && !"opportunistic".equals(currentPrivateDnsMode)) {
+ Log.d(TAG, "Performing migration for private dns presets");
+ if ("adguard".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "dns.adguard.com");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("appliedprivacy".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "dot1.applied-privacy.net");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("cira".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "protected.canadianshield.cira.ca");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("cleanbrowsing".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "security-filter-dns.cleanbrowsing.org");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("cloudflare".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "security.cloudflare-dns.com");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("cznic".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "odvr.nic.cz");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ }else if ("google".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "dns.google");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("mullvad".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "adblock.dns.mullvad.net");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("quadnine".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "dns.quad9.net");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("restena".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "kaitain.restena.lu");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("switch".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "dns.switch.ch");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("twnic".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "101.101.101.101");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ } else if ("uncensoreddns".equals(currentPrivateDnsMode)) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "anycast.censurfridns.dk");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ }
+ }
}
/**