20.0 Private DNS work

- Simplify Private DNS preset patchsets
  based on updated CalyxOS patchset
  TODO: backport this

- Add DoH endpoints for all of the presets
  Disabled, very few hosts actually support DoH/3

Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
Tad 2023-05-31 12:31:07 -04:00
parent 8a43be3c58
commit e696cceac9
No known key found for this signature in database
GPG Key ID: B286E9F57A07424B
6 changed files with 449 additions and 602 deletions

View File

@ -1,144 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Tue, 21 Dec 2021 05:13:40 +0530
Subject: [PATCH] Add more 'Private DNS' options
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
https://review.calyxos.org/c/CalyxOS/platform_frameworks_libs_net/+/9676
Signed-off-by: Tad <tad@spotco.us>
Change-Id: Ide577115925a2a4991332524f670899f4d33f2a3
---
.../util/ConnectivitySettingsUtils.java | 91 +++++++++++++++++++
1 file changed, 91 insertions(+)
diff --git a/common/framework/com/android/net/module/util/ConnectivitySettingsUtils.java b/common/framework/com/android/net/module/util/ConnectivitySettingsUtils.java
index b7eb70b0..3e8dd2e2 100644
--- a/common/framework/com/android/net/module/util/ConnectivitySettingsUtils.java
+++ b/common/framework/com/android/net/module/util/ConnectivitySettingsUtils.java
@@ -32,10 +32,36 @@ public class ConnectivitySettingsUtils {
public static final int PRIVATE_DNS_MODE_OFF = 1;
public static final int PRIVATE_DNS_MODE_OPPORTUNISTIC = 2;
public static final int PRIVATE_DNS_MODE_PROVIDER_HOSTNAME = 3;
+ public static final int PRIVATE_DNS_MODE_ADGUARD = 4;
+ public static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5;
+ public static final int PRIVATE_DNS_MODE_CLEANBROWSING = 6;
+ public static final int PRIVATE_DNS_MODE_CIRA = 7;
+ public static final int PRIVATE_DNS_MODE_CZNIC = 8;
+ public static final int PRIVATE_DNS_MODE_CLOUDFLARE = 9;
+ public static final int PRIVATE_DNS_MODE_GOOGLE = 10;
+ public static final int PRIVATE_DNS_MODE_MULLVAD = 11;
+ public static final int PRIVATE_DNS_MODE_QUADNINE = 12;
+ public static final int PRIVATE_DNS_MODE_RESTENA = 13;
+ public static final int PRIVATE_DNS_MODE_SWITCH = 14;
+ public static final int PRIVATE_DNS_MODE_TWNIC = 15;
+ public static final int PRIVATE_DNS_MODE_UNCENSOREDDNS = 16;
public static final String PRIVATE_DNS_DEFAULT_MODE = "private_dns_default_mode";
public static final String PRIVATE_DNS_MODE = "private_dns_mode";
public static final String PRIVATE_DNS_MODE_OFF_STRING = "off";
+ public static final String PRIVATE_DNS_MODE_ADGUARD_STRING = "adguard";
+ public static final String PRIVATE_DNS_MODE_APPLIEDPRIVACY_STRING = "appliedprivacy";
+ public static final String PRIVATE_DNS_MODE_CLEANBROWSING_STRING = "cleanbrowsing";
+ public static final String PRIVATE_DNS_MODE_CIRA_STRING = "cira";
+ public static final String PRIVATE_DNS_MODE_CZNIC_STRING = "cznic";
+ public static final String PRIVATE_DNS_MODE_CLOUDFLARE_STRING = "cloudflare";
+ public static final String PRIVATE_DNS_MODE_GOOGLE_STRING = "google";
+ public static final String PRIVATE_DNS_MODE_MULLVAD_STRING = "mullvad";
+ public static final String PRIVATE_DNS_MODE_QUADNINE_STRING = "quadnine";
+ public static final String PRIVATE_DNS_MODE_RESTENA_STRING = "restena";
+ public static final String PRIVATE_DNS_MODE_SWITCH_STRING = "switch";
+ public static final String PRIVATE_DNS_MODE_TWNIC_STRING = "twnic";
+ public static final String PRIVATE_DNS_MODE_UNCENSOREDDNS_STRING = "uncensoreddns";
public static final String PRIVATE_DNS_MODE_OPPORTUNISTIC_STRING = "opportunistic";
public static final String PRIVATE_DNS_MODE_PROVIDER_HOSTNAME_STRING = "hostname";
public static final String PRIVATE_DNS_SPECIFIER = "private_dns_specifier";
@@ -50,6 +76,32 @@ public class ConnectivitySettingsUtils {
switch (mode) {
case PRIVATE_DNS_MODE_OFF:
return PRIVATE_DNS_MODE_OFF_STRING;
+ case PRIVATE_DNS_MODE_ADGUARD:
+ return PRIVATE_DNS_MODE_ADGUARD_STRING;
+ case PRIVATE_DNS_MODE_APPLIEDPRIVACY:
+ return PRIVATE_DNS_MODE_APPLIEDPRIVACY_STRING;
+ case PRIVATE_DNS_MODE_CLEANBROWSING:
+ return PRIVATE_DNS_MODE_CLEANBROWSING_STRING;
+ case PRIVATE_DNS_MODE_CIRA:
+ return PRIVATE_DNS_MODE_CIRA_STRING;
+ case PRIVATE_DNS_MODE_CZNIC:
+ return PRIVATE_DNS_MODE_CZNIC_STRING;
+ case PRIVATE_DNS_MODE_CLOUDFLARE:
+ return PRIVATE_DNS_MODE_CLOUDFLARE_STRING;
+ case PRIVATE_DNS_MODE_GOOGLE:
+ return PRIVATE_DNS_MODE_GOOGLE_STRING;
+ case PRIVATE_DNS_MODE_MULLVAD:
+ return PRIVATE_DNS_MODE_MULLVAD_STRING;
+ case PRIVATE_DNS_MODE_QUADNINE:
+ return PRIVATE_DNS_MODE_QUADNINE_STRING;
+ case PRIVATE_DNS_MODE_RESTENA:
+ return PRIVATE_DNS_MODE_RESTENA_STRING;
+ case PRIVATE_DNS_MODE_SWITCH:
+ return PRIVATE_DNS_MODE_SWITCH_STRING;
+ case PRIVATE_DNS_MODE_TWNIC:
+ return PRIVATE_DNS_MODE_TWNIC_STRING;
+ case PRIVATE_DNS_MODE_UNCENSOREDDNS:
+ return PRIVATE_DNS_MODE_UNCENSOREDDNS_STRING;
case PRIVATE_DNS_MODE_OPPORTUNISTIC:
return PRIVATE_DNS_MODE_OPPORTUNISTIC_STRING;
case PRIVATE_DNS_MODE_PROVIDER_HOSTNAME:
@@ -63,6 +115,32 @@ public class ConnectivitySettingsUtils {
switch (mode) {
case "off":
return PRIVATE_DNS_MODE_OFF;
+ case "adguard":
+ return PRIVATE_DNS_MODE_ADGUARD;
+ case "appliedprivacy":
+ return PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+ case "cleanbrowsing":
+ return PRIVATE_DNS_MODE_CLEANBROWSING;
+ case "cira":
+ return PRIVATE_DNS_MODE_CIRA;
+ case "cznic":
+ return PRIVATE_DNS_MODE_CZNIC;
+ case "cloudflare":
+ return PRIVATE_DNS_MODE_CLOUDFLARE;
+ case "google":
+ return PRIVATE_DNS_MODE_GOOGLE;
+ case "mullvad":
+ return PRIVATE_DNS_MODE_MULLVAD;
+ case "quadnine":
+ return PRIVATE_DNS_MODE_QUADNINE;
+ case "restena":
+ return PRIVATE_DNS_MODE_RESTENA;
+ case "switch":
+ return PRIVATE_DNS_MODE_SWITCH;
+ case "twnic":
+ return PRIVATE_DNS_MODE_TWNIC;
+ case "uncensoreddns":
+ return PRIVATE_DNS_MODE_UNCENSOREDDNS;
case "hostname":
return PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
case "opportunistic":
@@ -96,6 +174,19 @@ public class ConnectivitySettingsUtils {
*/
public static void setPrivateDnsMode(@NonNull Context context, int mode) {
if (!(mode == PRIVATE_DNS_MODE_OFF
+ || mode == PRIVATE_DNS_MODE_ADGUARD
+ || mode == PRIVATE_DNS_MODE_APPLIEDPRIVACY
+ || mode == PRIVATE_DNS_MODE_CLEANBROWSING
+ || mode == PRIVATE_DNS_MODE_CIRA
+ || mode == PRIVATE_DNS_MODE_CZNIC
+ || mode == PRIVATE_DNS_MODE_CLOUDFLARE
+ || mode == PRIVATE_DNS_MODE_GOOGLE
+ || mode == PRIVATE_DNS_MODE_MULLVAD
+ || mode == PRIVATE_DNS_MODE_QUADNINE
+ || mode == PRIVATE_DNS_MODE_RESTENA
+ || mode == PRIVATE_DNS_MODE_SWITCH
+ || mode == PRIVATE_DNS_MODE_TWNIC
+ || mode == PRIVATE_DNS_MODE_UNCENSOREDDNS
|| mode == PRIVATE_DNS_MODE_OPPORTUNISTIC
|| mode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME)) {
throw new IllegalArgumentException("Invalid private dns mode: " + mode);

View File

@ -0,0 +1,93 @@
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 | 61 +++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
index 6bde4192..f0ece387 100644
--- a/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
+++ b/packages/LineageSettingsProvider/src/org/lineageos/lineagesettings/LineageDatabaseHelper.java
@@ -162,6 +162,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, "unicast.censurfridns.dk");
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext,
+ ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ }
+ }
}
/**
@@ -459,6 +519,7 @@ public class LineageDatabaseHelper extends SQLiteOpenHelper{
oldSetting);
upgradeVersion = 18;
}
+
// *** Remember to update DATABASE_VERSION above!
if (upgradeVersion != newVersion) {
Log.wtf(TAG, "warning: upgrading settings database to version "

View File

@ -3,25 +3,25 @@ From: Tad <tad@spotco.us>
Date: Mon, 24 Jun 2019 21:27:26 +0530 Date: Mon, 24 Jun 2019 21:27:26 +0530
Subject: [PATCH] Add more 'Private DNS' options Subject: [PATCH] Add more 'Private DNS' options
This adds thirteen DNS providers as available presets. This adds fourteen DNS providers as available presets.
Credit: CalyxOS Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com> - Chirayu Desai <chirayudesai1@gmail.com>
https://review.calyxos.org/c/CalyxOS/platform_packages_apps_Settings/+/9504 https://review.calyxos.org/c/CalyxOS/platform_packages_apps_Settings/+/17176
Change-Id: I7e8a320d47e7c5ddbcb9acfaf23032ae92d5d70d Change-Id: I7e8a320d47e7c5ddbcb9acfaf23032ae92d5d70d
--- ---
res/layout/private_dns_mode_dialog.xml | 52 +++++++++++ res/layout/private_dns_mode_dialog.xml | 56 ++++++
res/values/cm_strings.xml | 15 +++ res/values/cm_strings.xml | 43 +++++
.../PrivateDnsModeDialogPreference.java | 93 +++++++++++++++++++ .../PrivateDnsModeDialogPreference.java | 180 +++++++++++++++++-
.../PrivateDnsPreferenceController.java | 67 +++++++++++++ .../PrivateDnsPreferenceController.java | 38 +++-
4 files changed, 227 insertions(+) 4 files changed, 312 insertions(+), 5 deletions(-)
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index 12e29e693b..b6745806b5 100644 index 12e29e693b..feaaabac3d 100644
--- a/res/layout/private_dns_mode_dialog.xml --- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml +++ b/res/layout/private_dns_mode_dialog.xml
@@ -35,6 +35,58 @@ @@ -35,6 +35,62 @@
android:id="@+id/private_dns_mode_off" android:id="@+id/private_dns_mode_off"
layout="@layout/preference_widget_dialog_radiobutton"/> layout="@layout/preference_widget_dialog_radiobutton"/>
@ -38,15 +38,23 @@ index 12e29e693b..b6745806b5 100644
+ layout="@layout/preference_widget_dialog_radiobutton"/> + layout="@layout/preference_widget_dialog_radiobutton"/>
+ +
+ <include + <include
+ android:id="@+id/private_dns_mode_controld"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_cleanbrowsing" + android:id="@+id/private_dns_mode_cleanbrowsing"
+ layout="@layout/preference_widget_dialog_radiobutton"/> + layout="@layout/preference_widget_dialog_radiobutton"/>
+ +
+ <include + <include
+ android:id="@+id/private_dns_mode_cznic"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_cloudflare" + android:id="@+id/private_dns_mode_cloudflare"
+ layout="@layout/preference_widget_dialog_radiobutton"/> + layout="@layout/preference_widget_dialog_radiobutton"/>
+ +
+ <include + <include
+ android:id="@+id/private_dns_mode_cznic" + android:id="@+id/private_dns_mode_dnszero"
+ layout="@layout/preference_widget_dialog_radiobutton"/> + layout="@layout/preference_widget_dialog_radiobutton"/>
+ +
+ <include + <include
@ -70,10 +78,6 @@ index 12e29e693b..b6745806b5 100644
+ layout="@layout/preference_widget_dialog_radiobutton"/> + layout="@layout/preference_widget_dialog_radiobutton"/>
+ +
+ <include + <include
+ android:id="@+id/private_dns_mode_twnic"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_uncensoreddns" + android:id="@+id/private_dns_mode_uncensoreddns"
+ layout="@layout/preference_widget_dialog_radiobutton"/> + layout="@layout/preference_widget_dialog_radiobutton"/>
+ +
@ -81,74 +85,144 @@ index 12e29e693b..b6745806b5 100644
android:id="@+id/private_dns_mode_opportunistic" android:id="@+id/private_dns_mode_opportunistic"
layout="@layout/preference_widget_dialog_radiobutton"/> layout="@layout/preference_widget_dialog_radiobutton"/>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index e78fa63658..14a89a9b04 100644 index e78fa63658..809b07744a 100644
--- a/res/values/cm_strings.xml --- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml
@@ -146,6 +146,21 @@ @@ -15,6 +15,49 @@
<string name="data_usage_app_restrict_wifi">Wi\u2011Fi data</string> limitations under the License.
<string name="data_usage_app_restrict_wifi_summary">Enable usage of Wi\u2011Fi data</string> -->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Private DNS --> + <!-- Private DNS -->
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard (CY)</string> + <string name="private_dns_mode_adguard" translatable="false">AdGuard (CT)</string>
+ <string name="private_dns_mode_appliedprivacy" translatable="false">AppliedPrivacy (AT)</string> + <string name="private_dns_hostname_adguard" translatable="false">dns.adguard.com</string>
+ <string name="private_dns_mode_cira" translatable="false">CIRA (CA)</string>
+ <string name="private_dns_mode_cleanbrowsing" translatable="false">CleanBrowsing (US)</string>
+ <string name="private_dns_mode_cloudflare" translatable="false">Cloudflare (US)</string>
+ <string name="private_dns_mode_cznic" translatable="false">CZ.NIC (CZ)</string>
+ <string name="private_dns_mode_google" translatable="false">Google (US)</string>
+ <string name="private_dns_mode_mullvad" translatable="false">Mullvad (SE)</string>
+ <string name="private_dns_mode_quadnine" translatable="false">Quad9 (CH)</string>
+ <string name="private_dns_mode_restena" translatable="false">Restena (LU)</string>
+ <string name="private_dns_mode_switch" translatable="false">SWITCH (CH)</string>
+ <string name="private_dns_mode_twnic" translatable="false">TW.NIC (TW)</string>
+ <string name="private_dns_mode_uncensoreddns" translatable="false">UncensoredDNS (DK)</string>
+ +
<!-- PIN scramble --> + <string name="private_dns_mode_appliedprivacy" translatable="false">AppliedPrivacy (AT)</string>
<string name="unlock_scramble_pin_layout_title">Scramble layout</string> + <string name="private_dns_hostname_appliedprivacy" translatable="false">dot1.applied-privacy.net</string>
<string name="unlock_scramble_pin_layout_summary">Scramble PIN layout when unlocking device</string> +
+ <string name="private_dns_mode_cira" translatable="false">CIRA (CA)</string>
+ <string name="private_dns_hostname_cira" translatable="false">protected.canadianshield.cira.ca</string>
+
+ <string name="private_dns_mode_cleanbrowsing" translatable="false">CleanBrowsing (US)</string>
+ <string name="private_dns_hostname_cleanbrowsing" translatable="false">security-filter-dns.cleanbrowsing.org</string>
+
+ <string name="private_dns_mode_cloudflare" translatable="false">Cloudflare (US)</string>
+ <string name="private_dns_hostname_cloudflare" translatable="false">security.cloudflare-dns.com</string>
+
+ <string name="private_dns_mode_controld" translatable="false">Control D (CA)</string>
+ <string name="private_dns_hostname_controld" translatable="false">p2.freedns.controld.com</string>
+
+ <string name="private_dns_mode_cznic" translatable="false">CZ.NIC (CZ)</string>
+ <string name="private_dns_hostname_cznic" translatable="false">odvr.nic.cz</string>
+
+ <string name="private_dns_mode_dnszero" translatable="false">DNS0 (FR)</string>
+ <string name="private_dns_hostname_dnszero" translatable="false">zero.dns0.eu</string>
+
+ <string name="private_dns_mode_google" translatable="false">Google (US)</string>
+ <string name="private_dns_hostname_google" translatable="false">dns.google</string>
+
+ <string name="private_dns_mode_mullvad" translatable="false">Mullvad (SE)</string>
+ <string name="private_dns_hostname_mullvad" translatable="false">adblock.dns.mullvad.net</string>
+
+ <string name="private_dns_mode_quadnine" translatable="false">Quad9 (CH)</string>
+ <string name="private_dns_hostname_quadnine" translatable="false">dns.quad9.net</string>
+
+ <string name="private_dns_mode_restena" translatable="false">Restena (LU)</string>
+ <string name="private_dns_hostname_restena" translatable="false">kaitain.restena.lu</string>
+
+ <string name="private_dns_mode_switch" translatable="false">SWITCH (CH)</string>
+ <string name="private_dns_hostname_switch" translatable="false">dns.switch.ch</string>
+
+ <string name="private_dns_mode_uncensoreddns" translatable="false">UncensoredDNS (DK)</string>
+ <string name="private_dns_hostname_uncensoreddns" translatable="false">unicast.censurfridns.dk</string>
+
<!-- Advanced keyboard settings -->
<string name="keyboard_extras_title">Extras</string>
<string name="advanced_keyboard_settings_title">Advanced settings</string>
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 5c7c54eda3..7088f7b372 100644 index 5c7c54eda3..c321b6cbaf 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java --- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java +++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -72,9 +72,37 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat @@ -72,9 +72,39 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
// DNS_MODE -> RadioButton id // DNS_MODE -> RadioButton id
private static final Map<Integer, Integer> PRIVATE_DNS_MAP; private static final Map<Integer, Integer> PRIVATE_DNS_MAP;
+ // Must match ConnectivitySettingsUtils + // Only used in Settings
+ private static final int PRIVATE_DNS_MODE_ADGUARD = 4; + private static final int PRIVATE_DNS_MODE_ADGUARD = 4;
+ private static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5; + private static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5;
+ private static final int PRIVATE_DNS_MODE_CLEANBROWSING = 6; + private static final int PRIVATE_DNS_MODE_CIRA = 6;
+ private static final int PRIVATE_DNS_MODE_CIRA = 7; + private static final int PRIVATE_DNS_MODE_CLEANBROWSING = 7;
+ private static final int PRIVATE_DNS_MODE_CZNIC = 8; + private static final int PRIVATE_DNS_MODE_CLOUDFLARE = 8;
+ private static final int PRIVATE_DNS_MODE_CLOUDFLARE = 9; + private static final int PRIVATE_DNS_MODE_CONTROLD = 9;
+ private static final int PRIVATE_DNS_MODE_GOOGLE = 10; + private static final int PRIVATE_DNS_MODE_CZNIC = 10;
+ private static final int PRIVATE_DNS_MODE_MULLVAD = 11; + private static final int PRIVATE_DNS_MODE_DNSZERO = 11;
+ private static final int PRIVATE_DNS_MODE_QUADNINE = 12; + private static final int PRIVATE_DNS_MODE_GOOGLE = 12;
+ private static final int PRIVATE_DNS_MODE_RESTENA = 13; + private static final int PRIVATE_DNS_MODE_MULLVAD = 13;
+ private static final int PRIVATE_DNS_MODE_SWITCH = 14; + private static final int PRIVATE_DNS_MODE_QUADNINE = 14;
+ private static final int PRIVATE_DNS_MODE_TWNIC = 15; + private static final int PRIVATE_DNS_MODE_RESTENA = 15;
+ private static final int PRIVATE_DNS_MODE_UNCENSOREDDNS = 16; + private static final int PRIVATE_DNS_MODE_SWITCH = 16;
+ private static final int PRIVATE_DNS_MODE_UNCENSOREDDNS = 17;
+ +
static { static {
PRIVATE_DNS_MAP = new HashMap<>(); PRIVATE_DNS_MAP = new HashMap<>();
PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_OFF, R.id.private_dns_mode_off); PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_OFF, R.id.private_dns_mode_off);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_ADGUARD, R.id.private_dns_mode_adguard); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_ADGUARD, R.id.private_dns_mode_adguard);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_APPLIEDPRIVACY, R.id.private_dns_mode_appliedprivacy); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_APPLIEDPRIVACY, R.id.private_dns_mode_appliedprivacy);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLEANBROWSING, R.id.private_dns_mode_cleanbrowsing);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CIRA, R.id.private_dns_mode_cira); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CIRA, R.id.private_dns_mode_cira);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CZNIC, R.id.private_dns_mode_cznic); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLEANBROWSING, R.id.private_dns_mode_cleanbrowsing);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLOUDFLARE, R.id.private_dns_mode_cloudflare); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLOUDFLARE, R.id.private_dns_mode_cloudflare);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CONTROLD, R.id.private_dns_mode_controld);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CZNIC, R.id.private_dns_mode_cznic);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_DNSZERO, R.id.private_dns_mode_dnszero);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_GOOGLE, R.id.private_dns_mode_google); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_GOOGLE, R.id.private_dns_mode_google);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_MULLVAD, R.id.private_dns_mode_mullvad); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_MULLVAD, R.id.private_dns_mode_mullvad);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_QUADNINE, R.id.private_dns_mode_quadnine); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_QUADNINE, R.id.private_dns_mode_quadnine);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_RESTENA, R.id.private_dns_mode_restena); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_RESTENA, R.id.private_dns_mode_restena);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_SWITCH, R.id.private_dns_mode_switch); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_SWITCH, R.id.private_dns_mode_switch);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_TWNIC, R.id.private_dns_mode_twnic);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_UNCENSOREDDNS, R.id.private_dns_mode_uncensoreddns); + PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_UNCENSOREDDNS, R.id.private_dns_mode_uncensoreddns);
PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_OPPORTUNISTIC, R.id.private_dns_mode_opportunistic); PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_OPPORTUNISTIC, R.id.private_dns_mode_opportunistic);
PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME, R.id.private_dns_mode_provider); PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME, R.id.private_dns_mode_provider);
} }
@@ -156,6 +184,45 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat @@ -144,6 +174,39 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
final ContentResolver contentResolver = context.getContentResolver();
mMode = ConnectivitySettingsManager.getPrivateDnsMode(context);
+ if (mMode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME) {
+ final String privateDnsHostname =
+ ConnectivitySettingsManager.getPrivateDnsHostname(context);
+ if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_adguard))) {
+ mMode = PRIVATE_DNS_MODE_ADGUARD;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_appliedprivacy))) {
+ mMode = PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cira))) {
+ mMode = PRIVATE_DNS_MODE_CIRA;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cleanbrowsing))) {
+ mMode = PRIVATE_DNS_MODE_CLEANBROWSING;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cloudflare))) {
+ mMode = PRIVATE_DNS_MODE_CLOUDFLARE;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_controld))) {
+ mMode = PRIVATE_DNS_MODE_CONTROLD;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cznic))) {
+ mMode = PRIVATE_DNS_MODE_CZNIC;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_dnszero))) {
+ mMode = PRIVATE_DNS_MODE_DNSZERO;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_google))) {
+ mMode = PRIVATE_DNS_MODE_GOOGLE;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_mullvad))) {
+ mMode = PRIVATE_DNS_MODE_MULLVAD;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_quadnine))) {
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_restena))) {
+ mMode = PRIVATE_DNS_MODE_RESTENA;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_switch))) {
+ mMode = PRIVATE_DNS_MODE_SWITCH;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_uncensoreddns))) {
+ mMode = PRIVATE_DNS_MODE_UNCENSOREDDNS;
+ }
+ }
mEditText = view.findViewById(R.id.private_dns_mode_provider_hostname);
mEditText.addTextChangedListener(this);
@@ -156,6 +219,48 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
// Initial radio button text // Initial radio button text
final RadioButton offRadioButton = view.findViewById(R.id.private_dns_mode_off); final RadioButton offRadioButton = view.findViewById(R.id.private_dns_mode_off);
offRadioButton.setText(R.string.private_dns_mode_off); offRadioButton.setText(R.string.private_dns_mode_off);
@ -167,9 +241,15 @@ index 5c7c54eda3..7088f7b372 100644
+ final RadioButton cloudflareRadioButton = + final RadioButton cloudflareRadioButton =
+ view.findViewById(R.id.private_dns_mode_cloudflare); + view.findViewById(R.id.private_dns_mode_cloudflare);
+ cloudflareRadioButton.setText(R.string.private_dns_mode_cloudflare); + cloudflareRadioButton.setText(R.string.private_dns_mode_cloudflare);
+ final RadioButton controldRadioButton =
+ view.findViewById(R.id.private_dns_mode_controld);
+ controldRadioButton.setText(R.string.private_dns_mode_controld);
+ final RadioButton cznicRadioButton = + final RadioButton cznicRadioButton =
+ view.findViewById(R.id.private_dns_mode_cznic); + view.findViewById(R.id.private_dns_mode_cznic);
+ cznicRadioButton.setText(R.string.private_dns_mode_cznic); + cznicRadioButton.setText(R.string.private_dns_mode_cznic);
+ final RadioButton dnszeroRadioButton =
+ view.findViewById(R.id.private_dns_mode_dnszero);
+ dnszeroRadioButton.setText(R.string.private_dns_mode_dnszero);
+ final RadioButton googleRadioButton = + final RadioButton googleRadioButton =
+ view.findViewById(R.id.private_dns_mode_google); + view.findViewById(R.id.private_dns_mode_google);
+ googleRadioButton.setText(R.string.private_dns_mode_google); + googleRadioButton.setText(R.string.private_dns_mode_google);
@ -185,16 +265,74 @@ index 5c7c54eda3..7088f7b372 100644
+ final RadioButton switchRadioButton = + final RadioButton switchRadioButton =
+ view.findViewById(R.id.private_dns_mode_switch); + view.findViewById(R.id.private_dns_mode_switch);
+ switchRadioButton.setText(R.string.private_dns_mode_switch); + switchRadioButton.setText(R.string.private_dns_mode_switch);
+ final RadioButton twnicRadioButton =
+ view.findViewById(R.id.private_dns_mode_twnic);
+ twnicRadioButton.setText(R.string.private_dns_mode_twnic);
+ final RadioButton uncensoreddnsRadioButton = + final RadioButton uncensoreddnsRadioButton =
+ view.findViewById(R.id.private_dns_mode_uncensoreddns); + view.findViewById(R.id.private_dns_mode_uncensoreddns);
+ uncensoreddnsRadioButton.setText(R.string.private_dns_mode_uncensoreddns); + uncensoreddnsRadioButton.setText(R.string.private_dns_mode_uncensoreddns);
final RadioButton opportunisticRadioButton = final RadioButton opportunisticRadioButton =
view.findViewById(R.id.private_dns_mode_opportunistic); view.findViewById(R.id.private_dns_mode_opportunistic);
opportunisticRadioButton.setText(R.string.private_dns_mode_opportunistic); opportunisticRadioButton.setText(R.string.private_dns_mode_opportunistic);
@@ -197,6 +264,32 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat @@ -181,15 +286,58 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
final Context context = getContext();
+ int modeToSet = mMode;
if (mMode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME) {
// Only clickable if hostname is valid, so we could save it safely
ConnectivitySettingsManager.setPrivateDnsHostname(context,
mEditText.getText().toString());
+ } else if (mMode == PRIVATE_DNS_MODE_ADGUARD) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_adguard));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_APPLIEDPRIVACY) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_appliedprivacy));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CIRA) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cira));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CLEANBROWSING) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cleanbrowsing));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CLOUDFLARE) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cloudflare));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CONTROLD) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_controld));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CZNIC) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cznic));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_DNSZERO) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_dnszero));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_GOOGLE) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_google));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_MULLVAD) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_mullvad));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_QUADNINE) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_quadnine));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_RESTENA) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_restena));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_SWITCH) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_switch));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_UNCENSOREDDNS) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_uncensoreddns));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
}
FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context,
- SettingsEnums.ACTION_PRIVATE_DNS_MODE, mMode);
- ConnectivitySettingsManager.setPrivateDnsMode(context, mMode);
+ SettingsEnums.ACTION_PRIVATE_DNS_MODE, modeToSet);
+ ConnectivitySettingsManager.setPrivateDnsMode(context, modeToSet);
}
}
@@ -197,6 +345,34 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
public void onCheckedChanged(RadioGroup group, int checkedId) { public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.private_dns_mode_off) { if (checkedId == R.id.private_dns_mode_off) {
mMode = PRIVATE_DNS_MODE_OFF; mMode = PRIVATE_DNS_MODE_OFF;
@ -208,8 +346,12 @@ index 5c7c54eda3..7088f7b372 100644
+ mMode = PRIVATE_DNS_MODE_CLEANBROWSING; + mMode = PRIVATE_DNS_MODE_CLEANBROWSING;
+ } else if (checkedId == R.id.private_dns_mode_cloudflare) { + } else if (checkedId == R.id.private_dns_mode_cloudflare) {
+ mMode = PRIVATE_DNS_MODE_CLOUDFLARE; + mMode = PRIVATE_DNS_MODE_CLOUDFLARE;
+ } else if (checkedId == R.id.private_dns_mode_controld) {
+ mMode = PRIVATE_DNS_MODE_CONTROLD;
+ } else if (checkedId == R.id.private_dns_mode_cznic) { + } else if (checkedId == R.id.private_dns_mode_cznic) {
+ mMode = PRIVATE_DNS_MODE_CZNIC; + mMode = PRIVATE_DNS_MODE_CZNIC;
+ } else if (checkedId == R.id.private_dns_mode_dnszero) {
+ mMode = PRIVATE_DNS_MODE_DNSZERO;
+ } else if (checkedId == R.id.private_dns_mode_google) { + } else if (checkedId == R.id.private_dns_mode_google) {
+ mMode = PRIVATE_DNS_MODE_GOOGLE; + mMode = PRIVATE_DNS_MODE_GOOGLE;
+ } else if (checkedId == R.id.private_dns_mode_mullvad) { + } else if (checkedId == R.id.private_dns_mode_mullvad) {
@ -220,95 +362,57 @@ index 5c7c54eda3..7088f7b372 100644
+ mMode = PRIVATE_DNS_MODE_RESTENA; + mMode = PRIVATE_DNS_MODE_RESTENA;
+ } else if (checkedId == R.id.private_dns_mode_switch) { + } else if (checkedId == R.id.private_dns_mode_switch) {
+ mMode = PRIVATE_DNS_MODE_SWITCH; + mMode = PRIVATE_DNS_MODE_SWITCH;
+ } else if (checkedId == R.id.private_dns_mode_twnic) {
+ mMode = PRIVATE_DNS_MODE_TWNIC;
+ } else if (checkedId == R.id.private_dns_mode_uncensoreddns) { + } else if (checkedId == R.id.private_dns_mode_uncensoreddns) {
+ mMode = PRIVATE_DNS_MODE_UNCENSOREDDNS; + mMode = PRIVATE_DNS_MODE_UNCENSOREDDNS;
} else if (checkedId == R.id.private_dns_mode_opportunistic) { } else if (checkedId == R.id.private_dns_mode_opportunistic) {
mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC; mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
} else if (checkedId == R.id.private_dns_mode_provider) { } else if (checkedId == R.id.private_dns_mode_provider) {
diff --git a/src/com/android/settings/network/PrivateDnsPreferenceController.java b/src/com/android/settings/network/PrivateDnsPreferenceController.java diff --git a/src/com/android/settings/network/PrivateDnsPreferenceController.java b/src/com/android/settings/network/PrivateDnsPreferenceController.java
index ed6f9ed955..03f8d230ef 100644 index ed6f9ed955..4258e6c039 100644
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java --- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java +++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -65,6 +65,21 @@ public class PrivateDnsPreferenceController extends BasePreferenceController @@ -133,9 +133,41 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
Settings.Global.getUriFor(PRIVATE_DNS_SPECIFIER),
};
+ // Must match ConnectivitySettingsUtils
+ private static final int PRIVATE_DNS_MODE_ADGUARD = 4;
+ private static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5;
+ private static final int PRIVATE_DNS_MODE_CLEANBROWSING = 6;
+ private static final int PRIVATE_DNS_MODE_CIRA = 7;
+ private static final int PRIVATE_DNS_MODE_CZNIC = 8;
+ private static final int PRIVATE_DNS_MODE_CLOUDFLARE = 9;
+ private static final int PRIVATE_DNS_MODE_GOOGLE = 10;
+ private static final int PRIVATE_DNS_MODE_MULLVAD = 11;
+ private static final int PRIVATE_DNS_MODE_QUADNINE = 12;
+ private static final int PRIVATE_DNS_MODE_RESTENA = 13;
+ private static final int PRIVATE_DNS_MODE_SWITCH = 14;
+ private static final int PRIVATE_DNS_MODE_TWNIC = 15;
+ private static final int PRIVATE_DNS_MODE_UNCENSOREDDNS = 16;
+
private final Handler mHandler;
private final ContentObserver mSettingsObserver;
private final ConnectivityManager mConnectivityManager;
@@ -129,6 +144,58 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
switch (mode) {
case PRIVATE_DNS_MODE_OFF:
return res.getString(R.string.private_dns_mode_off);
+ case PRIVATE_DNS_MODE_ADGUARD:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_adguard)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_APPLIEDPRIVACY:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_appliedprivacy)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CIRA:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cira)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CLEANBROWSING:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cleanbrowsing)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CLOUDFLARE:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cloudflare)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CZNIC:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cznic)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_GOOGLE:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_google)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_MULLVAD:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_mullvad)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_QUADNINE:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_quadnine)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_RESTENA:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_restena)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_SWITCH:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_switch)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_TWNIC:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_twnic)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_UNCENSOREDDNS:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_uncensoreddns)
+ : res.getString(R.string.private_dns_mode_provider_failure);
case PRIVATE_DNS_MODE_OPPORTUNISTIC:
return dnsesResolved ? res.getString(R.string.private_dns_mode_on) return dnsesResolved ? res.getString(R.string.private_dns_mode_on)
: res.getString(R.string.private_dns_mode_opportunistic); : res.getString(R.string.private_dns_mode_opportunistic);
case PRIVATE_DNS_MODE_PROVIDER_HOSTNAME:
- return dnsesResolved
- ? PrivateDnsModeDialogPreference.getHostnameFromSettings(cr)
- : res.getString(R.string.private_dns_mode_provider_failure);
+ if (!dnsesResolved) {
+ return res.getString(R.string.private_dns_mode_provider_failure);
+ }
+ final String privateDnsHostname =
+ ConnectivitySettingsManager.getPrivateDnsHostname(mContext);
+ if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_adguard))) {
+ return res.getString(R.string.private_dns_mode_adguard);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_appliedprivacy))) {
+ return res.getString(R.string.private_dns_mode_appliedprivacy);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cira))) {
+ return res.getString(R.string.private_dns_mode_cira);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cleanbrowsing))) {
+ return res.getString(R.string.private_dns_mode_cleanbrowsing);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cloudflare))) {
+ return res.getString(R.string.private_dns_mode_cloudflare);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_controld))) {
+ return res.getString(R.string.private_dns_mode_controld);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cznic))) {
+ return res.getString(R.string.private_dns_mode_cznic);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_dnszero))) {
+ return res.getString(R.string.private_dns_mode_dnszero);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_google))) {
+ return res.getString(R.string.private_dns_mode_google);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_mullvad))) {
+ return res.getString(R.string.private_dns_mode_mullvad);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_quadnine))) {
+ return res.getString(R.string.private_dns_mode_quadnine);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_restena))) {
+ return res.getString(R.string.private_dns_mode_restena);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_switch))) {
+ return res.getString(R.string.private_dns_mode_switch);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_uncensoreddns))) {
+ return res.getString(R.string.private_dns_mode_uncensoreddns);
+ }
+ return PrivateDnsModeDialogPreference.getHostnameFromSettings(cr);
}
return "";
}

View File

@ -1,314 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Mon, 24 Jun 2019 21:27:35 +0530
Subject: [PATCH] Add more 'Private DNS' options
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
https://review.calyxos.org/c/CalyxOS/platform_packages_modules_Connectivity/+/9588
Change-Id: I4e51da9d8fe08d1c4a287808f4464c0338b40334
---
.../net/ConnectivitySettingsManager.java | 170 ++++++++++++++++++
.../server/connectivity/DnsManager.java | 78 ++++++++
2 files changed, 248 insertions(+)
diff --git a/framework/src/android/net/ConnectivitySettingsManager.java b/framework/src/android/net/ConnectivitySettingsManager.java
index 32f831979..021937cce 100644
--- a/framework/src/android/net/ConnectivitySettingsManager.java
+++ b/framework/src/android/net/ConnectivitySettingsManager.java
@@ -351,6 +351,84 @@ public class ConnectivitySettingsManager {
*/
public static final int PRIVATE_DNS_MODE_OFF = ConnectivitySettingsUtils.PRIVATE_DNS_MODE_OFF;
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_ADGUARD =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_ADGUARD;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_CLEANBROWSING =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_CLEANBROWSING;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_CIRA =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_CIRA;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_CZNIC =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_CZNIC;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_CLOUDFLARE =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_CLOUDFLARE;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_GOOGLE =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_GOOGLE;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_MULLVAD =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_MULLVAD;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_QUADNINE =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_QUADNINE;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_RESTENA =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_RESTENA;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_SWITCH =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_SWITCH;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_TWNIC =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_TWNIC;
+
+ /**
+ * @hide
+ */
+ public static final int PRIVATE_DNS_MODE_UNCENSOREDDNS =
+ ConnectivitySettingsUtils.PRIVATE_DNS_MODE_UNCENSOREDDNS;
+
/**
* One of the private DNS modes that indicates the private DNS mode is automatic, which
* will try to use the current DNS as private DNS.
@@ -366,10 +444,89 @@ public class ConnectivitySettingsManager {
public static final int PRIVATE_DNS_MODE_PROVIDER_HOSTNAME =
ConnectivitySettingsUtils.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY = "dot1.applied-privacy.net";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_CIRA = "protected.canadianshield.cira.ca";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_CZNIC = "odvr.nic.cz";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_CLEANBROWSING = "security-filter-dns.cleanbrowsing.org";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_CLOUDFLARE = "security.cloudflare-dns.com";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_GOOGLE = "dns.google";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_MULLVAD = "adblock.doh.mullvad.net";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_QUADNINE = "dns.quad9.net";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_RESTENA = "kaitain.restena.lu";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_SWITCH = "dns.switch.ch";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_TWNIC = "101.101.101.101";
+
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS = "unicast.censurfridns.dk";
+
+
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(value = {
PRIVATE_DNS_MODE_OFF,
+ PRIVATE_DNS_MODE_ADGUARD,
+ PRIVATE_DNS_MODE_APPLIEDPRIVACY,
+ PRIVATE_DNS_MODE_CLEANBROWSING,
+ PRIVATE_DNS_MODE_CIRA,
+ PRIVATE_DNS_MODE_CZNIC,
+ PRIVATE_DNS_MODE_CLOUDFLARE,
+ PRIVATE_DNS_MODE_GOOGLE,
+ PRIVATE_DNS_MODE_MULLVAD,
+ PRIVATE_DNS_MODE_QUADNINE,
+ PRIVATE_DNS_MODE_RESTENA,
+ PRIVATE_DNS_MODE_SWITCH,
+ PRIVATE_DNS_MODE_TWNIC,
+ PRIVATE_DNS_MODE_UNCENSOREDDNS,
PRIVATE_DNS_MODE_OPPORTUNISTIC,
PRIVATE_DNS_MODE_PROVIDER_HOSTNAME,
})
@@ -806,6 +963,19 @@ public class ConnectivitySettingsManager {
public static void setPrivateDnsDefaultMode(@NonNull Context context,
@NonNull @PrivateDnsMode int mode) {
if (!(mode == PRIVATE_DNS_MODE_OFF
+ || mode == PRIVATE_DNS_MODE_ADGUARD
+ || mode == PRIVATE_DNS_MODE_APPLIEDPRIVACY
+ || mode == PRIVATE_DNS_MODE_CLEANBROWSING
+ || mode == PRIVATE_DNS_MODE_CIRA
+ || mode == PRIVATE_DNS_MODE_CZNIC
+ || mode == PRIVATE_DNS_MODE_CLOUDFLARE
+ || mode == PRIVATE_DNS_MODE_GOOGLE
+ || mode == PRIVATE_DNS_MODE_MULLVAD
+ || mode == PRIVATE_DNS_MODE_QUADNINE
+ || mode == PRIVATE_DNS_MODE_RESTENA
+ || mode == PRIVATE_DNS_MODE_SWITCH
+ || mode == PRIVATE_DNS_MODE_TWNIC
+ || mode == PRIVATE_DNS_MODE_UNCENSOREDDNS
|| mode == PRIVATE_DNS_MODE_OPPORTUNISTIC
|| mode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME)) {
throw new IllegalArgumentException("Invalid private dns mode");
diff --git a/service/src/com/android/server/connectivity/DnsManager.java b/service/src/com/android/server/connectivity/DnsManager.java
index 1493cae79..2a5058c3c 100644
--- a/service/src/com/android/server/connectivity/DnsManager.java
+++ b/service/src/com/android/server/connectivity/DnsManager.java
@@ -23,8 +23,34 @@ import static android.net.ConnectivitySettingsManager.DNS_RESOLVER_SUCCESS_THRES
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_DEFAULT_MODE;
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE;
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_ADGUARD;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_CLEANBROWSING;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_CIRA;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_CZNIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_GOOGLE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_MULLVAD;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_RESTENA;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_SWITCH;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_TWNIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS;
import static android.net.resolv.aidl.IDnsResolverUnsolicitedEventListener.VALIDATION_RESULT_FAILURE;
import static android.net.resolv.aidl.IDnsResolverUnsolicitedEventListener.VALIDATION_RESULT_SUCCESS;
@@ -141,6 +167,58 @@ public class DnsManager {
return new PrivateDnsConfig(specifier, null);
}
+ if (PRIVATE_DNS_MODE_ADGUARD == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ }
+
+ if (PRIVATE_DNS_MODE_APPLIEDPRIVACY == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CLEANBROWSING == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLEANBROWSING, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CIRA == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CIRA, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CZNIC == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CZNIC, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CLOUDFLARE == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLOUDFLARE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_GOOGLE == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_GOOGLE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_MULLVAD == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_MULLVAD, null);
+ }
+
+ if (PRIVATE_DNS_MODE_QUADNINE == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_RESTENA == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_RESTENA, null);
+ }
+
+ if (PRIVATE_DNS_MODE_SWITCH == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_SWITCH, null);
+ }
+
+ if (PRIVATE_DNS_MODE_TWNIC == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_TWNIC, null);
+ }
+
+ if (PRIVATE_DNS_MODE_UNCENSOREDDNS == mode) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS, null);
+ }
+
return new PrivateDnsConfig(useTls);
}

View File

@ -0,0 +1,111 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Wed, 31 May 2023 18:16:06 -0400
Subject: [PATCH] Add more DoH endpoints
Change-Id: I72884caa00d7de91a940a1b2683713d73824e1db
Signed-off-by: Tad <tad@spotco.us>
---
PrivateDnsConfiguration.h | 82 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 1 deletion(-)
diff --git a/PrivateDnsConfiguration.h b/PrivateDnsConfiguration.h
index 0f3c09dc..3c593369 100644
--- a/PrivateDnsConfiguration.h
+++ b/PrivateDnsConfiguration.h
@@ -237,7 +237,7 @@ class PrivateDnsConfiguration {
// TODO: Move below DoH relevant stuff into Rust implementation.
std::map<unsigned, DohIdentity> mDohTracker GUARDED_BY(mPrivateDnsLock);
- std::array<DohProviderEntry, 4> mAvailableDoHProviders = {{
+ std::array<DohProviderEntry, 8> mAvailableDoHProviders = {{
{"Google",
{"2001:4860:4860::8888", "2001:4860:4860::8844", "8.8.8.8", "8.8.4.4"},
"dns.google",
@@ -248,6 +248,86 @@ class PrivateDnsConfiguration {
"cloudflare-dns.com",
"https://cloudflare-dns.com/dns-query",
false},
+ {"Cloudflare-Security",
+ {"2606:4700:4700::1112", "2606:4700:4700::1002", "1.0.0.2", "1.1.1.2"},
+ "security.cloudflare-dns.com",
+ "https://security.cloudflare-dns.com/dns-query",
+ false},
+ {"AdGuard",
+ {"2a10:50c0::ad1:ff", "2a10:50c0::ad2:ff", "94.140.14.14", "94.140.15.15"},
+ "dns.adguard-dns.com",
+ "https://dns.adguard-dns.com/dns-query",
+ false},
+ /*{"AppliedPrivacy",
+ {"2a02:1b8:10:234::2", "146.255.56.98"},
+ "dot1.applied-privacy.net",
+ "https://doh.applied-privacy.net/query",
+ false},
+ {"CIRA",
+ {"2620:10a:80bb::20", "2620:10a:80bc::20", "149.112.121.20", "149.112.122.20"},
+ "protected.canadianshield.cira.ca",
+ "https://protected.canadianshield.cira.ca/dns-query",
+ false},
+ {"CleanBrowsing-Security",
+ {"185.228.168.9"},
+ "security-filter-dns.cleanbrowsing.org",
+ "https://doh.cleanbrowsing.org/doh/security-filter",
+ false},
+ {"ControlD-P2",
+ {"2606:1a40::11", "76.76.2.11"},
+ "p2.freedns.controld.com",
+ "https://freedns.controld.com/p2",
+ false},
+ {"CZNIC",
+ {"2001:148f:ffff::1", "2001:148f:fffe::1", "193.17.47.1", "185.43.135.1"},
+ "odvr.nic.cz",
+ "https://odvr.nic.cz/doh",
+ false},*/
+ {"DNSZERO",
+ {"2a0f:fc80::", "2a0f:fc81::", "193.110.81.0", "185.253.5.0"},
+ "dns0.eu",
+ "https://dns0.eu",
+ false},
+ {"DNSZERO-ZERO",
+ {"2a0f:fc80::9", "2a0f:fc81::9", "185.253.5.9", "193.110.81.9"},
+ "zero.dns0.eu",
+ "https://zero.dns0.eu",
+ false},
+ /*{"Mullvad",
+ {"2a07:e340::2", "194.242.2.2"},
+ "dns.mullvad.net",
+ "https://dns.mullvad.net/dns-query",
+ false},
+ {"Mullvad-AdBlock",
+ {"2a07:e340::3", "194.242.2.3"},
+ "adblock.dns.mullvad.net",
+ "https://adblock.dns.mullvad.net/dns-query",
+ false},
+ {"QuadNine",
+ {"2620:fe::9", "2620:fe::fe", "9.9.9.9", "149.112.112.112"},
+ "dns.quad9.net",
+ "https://dns.quad9.net/dns-query",
+ false},
+ {"Restena",
+ {"2001:a18:1::29", "158.64.1.29"},
+ "kaitain.restena.lu",
+ "https://kaitain.restena.lu/dns-query",
+ false},
+ {"SWITCH",
+ {"2001:620:0:ff::3", "2001:620:0:ff::2", "130.59.31.251", "130.59.31.248"},
+ "dns.switch.ch",
+ "https://dns.switch.ch/dns-query",
+ false},
+ {"UncensoredDNS-Anycast",
+ {"2001:67c:28a4::", "91.239.100.100"},
+ "anycast.uncensoreddns.org",
+ "https://anycast.uncensoreddns.org/dns-query",
+ false},
+ {"UncensoredDNS-Unicast",
+ {"2a01:3a0:53:53::", "89.233.43.71"},
+ "unicast.uncensoreddns.org",
+ "https://unicast.uncensoreddns.org/dns-query",
+ false},*/
// The DoH providers for testing only.
// Using ResolverTestProvider requires that the DnsResolver is configured by someone

View File

@ -199,10 +199,6 @@ if enterAndClear "frameworks/ex"; then
if [ "$DOS_GRAPHENE_CONSTIFY" = true ]; then applyPatch "$DOS_PATCHES/android_frameworks_ex/0001-constify_JNINativeMethod.patch"; fi; #Constify JNINativeMethod tables (GrapheneOS) if [ "$DOS_GRAPHENE_CONSTIFY" = true ]; then applyPatch "$DOS_PATCHES/android_frameworks_ex/0001-constify_JNINativeMethod.patch"; fi; #Constify JNINativeMethod tables (GrapheneOS)
fi; fi;
if enterAndClear "frameworks/libs/net"; then
applyPatch "$DOS_PATCHES/android_frameworks_libs_net/0001-Private_DNS.patch"; #More 'Private DNS' options (heavily based off of a CalyxOS patch)
fi;
if enterAndClear "frameworks/libs/systemui"; then if enterAndClear "frameworks/libs/systemui"; then
applyPatch "$DOS_PATCHES/android_frameworks_libs_systemui/0001-Icon_Cache.patch"; #Invalidate icon cache between OS releases (GrapheneOS) applyPatch "$DOS_PATCHES/android_frameworks_libs_systemui/0001-Icon_Cache.patch"; #Invalidate icon cache between OS releases (GrapheneOS)
fi; fi;
@ -256,6 +252,7 @@ fi;
fi; fi;
if enterAndClear "lineage-sdk"; then if enterAndClear "lineage-sdk"; then
applyPatch "$DOS_PATCHES/android_lineage-sdk/0001-Private_DNS-Migration.patch"; #Migrate Private DNS preset modes to hostname-mode based (heavily based off of a CalyxOS patch)
if [ "$DOS_DEBLOBBER_REMOVE_AUDIOFX" = true ]; then awk -i inplace '!/LineageAudioService/' lineage/res/res/values/config.xml; fi; #Remove AudioFX if [ "$DOS_DEBLOBBER_REMOVE_AUDIOFX" = true ]; then awk -i inplace '!/LineageAudioService/' lineage/res/res/values/config.xml; fi; #Remove AudioFX
fi; fi;
@ -331,13 +328,13 @@ if enterAndClear "packages/modules/Connectivity"; then
applyPatch "$DOS_PATCHES/android_packages_modules_Connectivity/0001-Network_Permission-1.patch"; #Skip reportNetworkConnectivity() when permission is revoked (GrapheneOS) applyPatch "$DOS_PATCHES/android_packages_modules_Connectivity/0001-Network_Permission-1.patch"; #Skip reportNetworkConnectivity() when permission is revoked (GrapheneOS)
applyPatch "$DOS_PATCHES/android_packages_modules_Connectivity/0001-Network_Permission-2.patch"; #Enforce INTERNET permission per-uid instead of per-appId (GrapheneOS) applyPatch "$DOS_PATCHES/android_packages_modules_Connectivity/0001-Network_Permission-2.patch"; #Enforce INTERNET permission per-uid instead of per-appId (GrapheneOS)
applyPatch "$DOS_PATCHES/android_packages_modules_Connectivity/0001-Network_Permission-3.patch"; #Don't crash INTERNET-unaware apps that try to access NsdManager (GrapheneOS) applyPatch "$DOS_PATCHES/android_packages_modules_Connectivity/0001-Network_Permission-3.patch"; #Don't crash INTERNET-unaware apps that try to access NsdManager (GrapheneOS)
applyPatch "$DOS_PATCHES/android_packages_modules_Connectivity/0002-Private_DNS.patch"; #More 'Private DNS' options (heavily based off of a CalyxOS patch)
fi; fi;
if enterAndClear "packages/modules/DnsResolver"; then if enterAndClear "packages/modules/DnsResolver"; then
applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Cache.patch"; #DnsResolver: Sort and cache hosts file data for fast lookup (tdm) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Cache.patch"; #DnsResolver: Sort and cache hosts file data for fast lookup (tdm)
applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Wildcards.patch"; #DnsResolver: Support wildcards in cached hosts file (tdm) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0001-Hosts_Wildcards.patch"; #DnsResolver: Support wildcards in cached hosts file (tdm)
applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0002-hosts_toggle.patch"; #Add a toggle to disable /etc/hosts lookup (DivestOS) applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0002-hosts_toggle.patch"; #Add a toggle to disable /etc/hosts lookup (DivestOS)
#applyPatch "$DOS_PATCHES/android_packages_modules_DnsResolver/0004-More-DoH.patch"; #Add more DoH endpoints (DivestOS)
fi; fi;
if enterAndClear "packages/modules/NetworkStack"; then if enterAndClear "packages/modules/NetworkStack"; then