Expand the available Private DNS options

Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
Tad 2021-10-22 15:13:29 -04:00
parent a0918b5222
commit 0c793835da
8 changed files with 1134 additions and 211 deletions

View File

@ -1,9 +1,9 @@
From c8583ef74a188973fae22b1589d6634944fada12 Mon Sep 17 00:00:00 2001
From 99006a7ceb6cec2e5d54c9ed25c470c809e56157 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 21 Oct 2021 20:54:37 -0400
Subject: [PATCH] Add more 'Private DNS' options
This adds: Quad9, Cloudflare, and AdGuard
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
@ -16,22 +16,38 @@ Credit: CalyxOS
Signed-off-by: Tad <tad@spotco.us>
Change-Id: Id75a774ce1ed109a83c6a5bf512536c643165d71
---
.../java/android/net/ConnectivityManager.java | 24 +++++++++++++++++++
.../server/connectivity/DnsManager.java | 18 ++++++++++++++
2 files changed, 42 insertions(+)
.../java/android/net/ConnectivityManager.java | 104 ++++++++++++++++++
.../server/connectivity/DnsManager.java | 66 +++++++++++
2 files changed, 170 insertions(+)
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index c5cb1f5b7cf8..e9271b3fe03f 100644
index c5cb1f5b7cf8..e74637792128 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -688,6 +688,18 @@ public class ConnectivityManager {
@@ -688,6 +688,58 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_OFF = "off";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_QUADNINE = "quadnine";
+ public static final String PRIVATE_DNS_MODE_ADGUARD = "adguard";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_APPLIEDPRIVACY = "appliedprivacy";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CLEANBROWSING = "cleanbrowsing";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CIRA = "cira";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CZNIC = "cznic";
+ /**
+ * @hide
+ */
@ -39,62 +55,172 @@ index c5cb1f5b7cf8..e9271b3fe03f 100644
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_ADGUARD = "adguard";
+ public static final String PRIVATE_DNS_MODE_GOOGLE = "google";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_MULLVAD = "mullvad";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_QUADNINE = "quadnine";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_RESTENA = "restena";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_SWITCH = "switch";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_TWNIC = "twnic";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_UNCENSOREDDNS = "uncensoreddns";
/**
* @hide
*/
@@ -696,6 +708,18 @@ public class ConnectivityManager {
@@ -696,6 +748,58 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_PROVIDER_HOSTNAME = "hostname";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY = "dot1.applied-privacy.net";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
+ /**
+ * @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_CLOUDFLARE = "one.one.one.one";
+ public static final String PRIVATE_DNS_SPECIFIER_RESTENA = "kaitain.restena.lu";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
+ 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";
/**
* The default Private DNS mode.
*
diff --git a/services/core/java/com/android/server/connectivity/DnsManager.java b/services/core/java/com/android/server/connectivity/DnsManager.java
index c0beb37577fc..953a0ff57ae5 100644
index c0beb37577fc..97efcd8ff49d 100644
--- a/services/core/java/com/android/server/connectivity/DnsManager.java
+++ b/services/core/java/com/android/server/connectivity/DnsManager.java
@@ -18,8 +18,14 @@ package com.android.server.connectivity;
@@ -18,6 +18,32 @@ package com.android.server.connectivity;
import static android.net.ConnectivityManager.PRIVATE_DNS_DEFAULT_MODE_FALLBACK;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_ADGUARD;
import static android.provider.Settings.Global.DNS_RESOLVER_MIN_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_MAX_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS;
@@ -171,6 +177,18 @@ public class DnsManager {
@@ -171,6 +197,46 @@ public class DnsManager {
return new PrivateDnsConfig(specifier, null);
}
+ if (PRIVATE_DNS_MODE_QUADNINE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ if (PRIVATE_DNS_MODE_ADGUARD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ }
+ if (PRIVATE_DNS_MODE_APPLIEDPRIVACY.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY, null);
+ }
+ if (PRIVATE_DNS_MODE_CIRA.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CIRA, null);
+ }
+ if (PRIVATE_DNS_MODE_CLEANBROWSING.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLEANBROWSING, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CLOUDFLARE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLOUDFLARE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_ADGUARD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ if (PRIVATE_DNS_MODE_CZNIC.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CZNIC, null);
+ }
+ if (PRIVATE_DNS_MODE_GOOGLE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_GOOGLE, null);
+ }
+ if (PRIVATE_DNS_MODE_MULLVAD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_MULLVAD, null);
+ }
+ if (PRIVATE_DNS_MODE_QUADNINE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ }
+ if (PRIVATE_DNS_MODE_RESTENA.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_RESTENA, null);
+ }
+ if (PRIVATE_DNS_MODE_SWITCH.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_SWITCH, null);
+ }
+ if (PRIVATE_DNS_MODE_TWNIC.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_TWNIC, null);
+ }
+ if (PRIVATE_DNS_MODE_UNCENSOREDDNS.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS, null);
+ }
+
return new PrivateDnsConfig(useTls);

View File

@ -1,9 +1,9 @@
From d9fb7d098be24dbb397e525a94f32b36df720e40 Mon Sep 17 00:00:00 2001
From 145b7b0e4d1c0016906110a1cdde90408ae630eb Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 21 Oct 2021 21:09:38 -0400
Subject: [PATCH] Add more 'Private DNS' options
This adds: Quad9, Cloudflare, and AdGuard
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
@ -14,37 +14,107 @@ Credit: CalyxOS
Signed-off-by: Tad <tad@spotco.us>
Change-Id: I423ad5a3c360a687a226e61df3f75b5550f851c0
---
res/layout/private_dns_mode_dialog.xml | 21 +++++++++++++++++++
res/values/cm_strings.xml | 5 +++++
.../PrivateDnsModeDialogPreference.java | 15 +++++++++++++
.../PrivateDnsPreferenceController.java | 15 +++++++++++++
4 files changed, 56 insertions(+)
res/layout/private_dns_mode_dialog.xml | 91 +++++++++++++++++++
res/values/cm_strings.xml | 15 +++
.../PrivateDnsModeDialogPreference.java | 65 +++++++++++++
.../PrivateDnsPreferenceController.java | 65 +++++++++++++
4 files changed, 236 insertions(+)
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index 652bc63ae3..2290a61183 100644
index 652bc63ae3..6106900318 100644
--- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml
@@ -33,6 +33,27 @@
@@ -33,6 +33,97 @@
android:layout_height="wrap_content"
android:layout_margin="8dp"/>
+ <RadioButton
+ android:id="@+id/private_dns_mode_quadnine"
+ android:text="@string/private_dns_mode_quadnine"
+ android:id="@id/private_dns_mode_adguard"
+ android:text="@string/private_dns_mode_adguard"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_cloudflare"
+ android:id="@id/private_dns_mode_appliedprivacy"
+ android:text="@string/private_dns_mode_appliedprivacy"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_cira"
+ android:text="@string/private_dns_mode_cira"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_cleanbrowsing"
+ android:text="@string/private_dns_mode_cleanbrowsing"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_cloudflare"
+ android:text="@string/private_dns_mode_cloudflare"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_adguard"
+ android:text="@string/private_dns_mode_adguard"
+ android:id="@id/private_dns_mode_cznic"
+ android:text="@string/private_dns_mode_cznic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_google"
+ android:text="@string/private_dns_mode_google"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_mullvad"
+ android:text="@string/private_dns_mode_mullvad"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_quadnine"
+ android:text="@string/private_dns_mode_quadnine"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_restena"
+ android:text="@string/private_dns_mode_restena"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_switch"
+ android:text="@string/private_dns_mode_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_twnic"
+ android:text="@string/private_dns_mode_twnic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
+
+ <RadioButton
+ android:id="@id/private_dns_mode_uncensoreddns"
+ android:text="@string/private_dns_mode_uncensoreddns"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="8dp"/>
@ -53,90 +123,200 @@ index 652bc63ae3..2290a61183 100644
android:id="@+id/private_dns_mode_opportunistic"
android:text="@string/private_dns_mode_opportunistic"
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 7d0b80d3c0..a7bf8a7fcf 100644
index 7d0b80d3c0..eea0f5a219 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -337,6 +337,11 @@
@@ -337,6 +337,21 @@
<string name="unlock_scramble_pin_layout_title">Scramble layout</string>
<string name="unlock_scramble_pin_layout_summary">Scramble PIN layout when unlocking device</string>
+ <!-- Private DNS -->
+ <string name="private_dns_mode_quadnine" translatable="false">Quad9</string>
+ <string name="private_dns_mode_cloudflare" translatable="false">Cloudflare</string>
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard</string>
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard (CY)</string>
+ <string name="private_dns_mode_appliedprivacy" translatable="false">AppliedPrivacy (AT)</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>
+
<!-- Proximity wake -->
<string name="proximity_wake_title">Prevent accidental wake-up</string>
<string name="proximity_wake_summary">Check the proximity sensor prior to waking up screen</string>
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 290ffd599e..a59bcac291 100644
index 290ffd599e..a37b535660 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -17,6 +17,9 @@ package com.android.settings.network;
@@ -17,6 +17,19 @@ package com.android.settings.network;
import static android.net.ConnectivityManager.PRIVATE_DNS_DEFAULT_MODE_FALLBACK;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.system.OsConstants.AF_INET;
@@ -68,6 +71,9 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreference imple
@@ -68,6 +81,19 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreference imple
static {
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_QUADNINE, R.id.private_dns_mode_quadnine);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLOUDFLARE, R.id.private_dns_mode_cloudflare);
+ 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_CIRA, R.id.private_dns_mode_cira);
+ 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_CZNIC, R.id.private_dns_mode_cznic);
+ 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_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_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_OPPORTUNISTIC, R.id.private_dns_mode_opportunistic);
PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME, R.id.private_dns_mode_provider);
}
@@ -180,6 +186,15 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreference imple
@@ -180,6 +206,45 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreference imple
case R.id.private_dns_mode_off:
mMode = PRIVATE_DNS_MODE_OFF;
break;
+ case R.id.private_dns_mode_quadnine:
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ case R.id.private_dns_mode_adguard:
+ mMode = PRIVATE_DNS_MODE_ADGUARD;
+ break;
+ case R.id.private_dns_mode_appliedprivacy:
+ mMode = PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+ break;
+ case R.id.private_dns_mode_cira:
+ mMode = PRIVATE_DNS_MODE_CIRA;
+ break;
+ case R.id.private_dns_mode_cleanbrowsing:
+ mMode = PRIVATE_DNS_MODE_CLEANBROWSING;
+ break;
+ case R.id.private_dns_mode_cloudflare:
+ mMode = PRIVATE_DNS_MODE_CLOUDFLARE;
+ break;
+ case R.id.private_dns_mode_adguard:
+ mMode = PRIVATE_DNS_MODE_ADGUARD;
+ case R.id.private_dns_mode_cznic:
+ mMode = PRIVATE_DNS_MODE_CZNIC;
+ break;
+ case R.id.private_dns_mode_google:
+ mMode = PRIVATE_DNS_MODE_GOOGLE;
+ break;
+ case R.id.private_dns_mode_mullvad:
+ mMode = PRIVATE_DNS_MODE_MULLVAD;
+ break;
+ case R.id.private_dns_mode_quadnine:
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ break;
+ case R.id.private_dns_mode_restena:
+ mMode = PRIVATE_DNS_MODE_RESTENA;
+ break;
+ case R.id.private_dns_mode_switch:
+ mMode = PRIVATE_DNS_MODE_SWITCH;
+ break;
+ case R.id.private_dns_mode_twnic:
+ mMode = PRIVATE_DNS_MODE_TWNIC;
+ break;
+ case R.id.private_dns_mode_uncensoreddns:
+ mMode = PRIVATE_DNS_MODE_UNCENSOREDDNS;
+ break;
case R.id.private_dns_mode_opportunistic:
mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
break;
diff --git a/src/com/android/settings/network/PrivateDnsPreferenceController.java b/src/com/android/settings/network/PrivateDnsPreferenceController.java
index 6f38569673..20495388e6 100644
index 6f38569673..956e16a826 100644
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -17,6 +17,9 @@
@@ -17,6 +17,19 @@
package com.android.settings.network;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.provider.Settings.Global.PRIVATE_DNS_DEFAULT_MODE;
@@ -118,6 +121,18 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
@@ -118,6 +131,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_QUADNINE:
+ case PRIVATE_DNS_MODE_ADGUARD:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_quadnine)
+ ? 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_ADGUARD:
+ case PRIVATE_DNS_MODE_CZNIC:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_adguard)
+ ? 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:
// TODO (b/79122154) : create a string specifically for this, instead of

View File

@ -1,9 +1,9 @@
From cb680f5b02741c6770d8f7c356cd5a2d1de46746 Mon Sep 17 00:00:00 2001
From ea55dc9108da5a0e24606a39e791d7f7905ed3c8 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 21 Oct 2021 20:54:37 -0400
Subject: [PATCH] Add more 'Private DNS' options
This adds: Quad9, Cloudflare, and AdGuard
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
@ -16,22 +16,38 @@ Credit: CalyxOS
Signed-off-by: Tad <tad@spotco.us>
Change-Id: Id75a774ce1ed109a83c6a5bf512536c643165d71
---
.../java/android/net/ConnectivityManager.java | 24 +++++++++++++++++++
.../server/connectivity/DnsManager.java | 18 ++++++++++++++
2 files changed, 42 insertions(+)
.../java/android/net/ConnectivityManager.java | 104 ++++++++++++++++++
.../server/connectivity/DnsManager.java | 66 +++++++++++
2 files changed, 170 insertions(+)
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 111a8c48a46c..13d0d699cb2d 100644
index 111a8c48a46c..09b445a57756 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -757,6 +757,18 @@ public class ConnectivityManager {
@@ -757,6 +757,58 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_OFF = "off";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_QUADNINE = "quadnine";
+ public static final String PRIVATE_DNS_MODE_ADGUARD = "adguard";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_APPLIEDPRIVACY = "appliedprivacy";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CLEANBROWSING = "cleanbrowsing";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CIRA = "cira";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CZNIC = "cznic";
+ /**
+ * @hide
+ */
@ -39,61 +55,172 @@ index 111a8c48a46c..13d0d699cb2d 100644
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_ADGUARD = "adguard";
+ public static final String PRIVATE_DNS_MODE_GOOGLE = "google";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_MULLVAD = "mullvad";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_QUADNINE = "quadnine";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_RESTENA = "restena";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_SWITCH = "switch";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_TWNIC = "twnic";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_UNCENSOREDDNS = "uncensoreddns";
/**
* @hide
*/
@@ -765,6 +777,18 @@ public class ConnectivityManager {
@@ -765,6 +817,58 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_PROVIDER_HOSTNAME = "hostname";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY = "dot1.applied-privacy.net";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
+ /**
+ * @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_CLOUDFLARE = "one.one.one.one";
+ public static final String PRIVATE_DNS_SPECIFIER_RESTENA = "kaitain.restena.lu";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
+ 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";
/**
* The default Private DNS mode.
*
diff --git a/services/core/java/com/android/server/connectivity/DnsManager.java b/services/core/java/com/android/server/connectivity/DnsManager.java
index 2321afb7df43..bb4b829d6584 100644
index 2321afb7df43..85b5596ae688 100644
--- a/services/core/java/com/android/server/connectivity/DnsManager.java
+++ b/services/core/java/com/android/server/connectivity/DnsManager.java
@@ -18,7 +18,13 @@ package com.android.server.connectivity;
@@ -18,6 +18,32 @@ package com.android.server.connectivity;
import static android.net.ConnectivityManager.PRIVATE_DNS_DEFAULT_MODE_FALLBACK;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.provider.Settings.Global.DNS_RESOLVER_MAX_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_MIN_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS;
@@ -131,6 +137,18 @@ public class DnsManager {
@@ -131,6 +157,46 @@ public class DnsManager {
return new PrivateDnsConfig(specifier, null);
}
+ if (PRIVATE_DNS_MODE_QUADNINE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ if (PRIVATE_DNS_MODE_ADGUARD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ }
+ if (PRIVATE_DNS_MODE_APPLIEDPRIVACY.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY, null);
+ }
+ if (PRIVATE_DNS_MODE_CIRA.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CIRA, null);
+ }
+ if (PRIVATE_DNS_MODE_CLEANBROWSING.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLEANBROWSING, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CLOUDFLARE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLOUDFLARE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_ADGUARD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ if (PRIVATE_DNS_MODE_CZNIC.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CZNIC, null);
+ }
+ if (PRIVATE_DNS_MODE_GOOGLE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_GOOGLE, null);
+ }
+ if (PRIVATE_DNS_MODE_MULLVAD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_MULLVAD, null);
+ }
+ if (PRIVATE_DNS_MODE_QUADNINE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ }
+ if (PRIVATE_DNS_MODE_RESTENA.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_RESTENA, null);
+ }
+ if (PRIVATE_DNS_MODE_SWITCH.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_SWITCH, null);
+ }
+ if (PRIVATE_DNS_MODE_TWNIC.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_TWNIC, null);
+ }
+ if (PRIVATE_DNS_MODE_UNCENSOREDDNS.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS, null);
+ }
+
return new PrivateDnsConfig(useTls);

View File

@ -1,9 +1,9 @@
From 803814d0fe7363a63ec5b9ad6776e37f5cb14f30 Mon Sep 17 00:00:00 2001
From 2598236b073cab92b0766296467ab12005547a45 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 21 Oct 2021 21:09:38 -0400
Subject: [PATCH] Add more 'Private DNS' options
This adds: Quad9, Cloudflare, and AdGuard
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
@ -14,23 +14,47 @@ Credit: CalyxOS
Signed-off-by: Tad <tad@spotco.us>
Change-Id: I423ad5a3c360a687a226e61df3f75b5550f851c0
---
res/layout/private_dns_mode_dialog.xml | 24 +++++++++++++++++++
res/values/cm_strings.xml | 5 ++++
.../PrivateDnsModeDialogPreference.java | 15 ++++++++++++
.../PrivateDnsPreferenceController.java | 15 ++++++++++++
4 files changed, 59 insertions(+)
res/layout/private_dns_mode_dialog.xml | 104 ++++++++++++++++++
res/values/cm_strings.xml | 15 +++
.../PrivateDnsModeDialogPreference.java | 65 +++++++++++
.../PrivateDnsPreferenceController.java | 65 +++++++++++
4 files changed, 249 insertions(+)
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index 641905dc01..4f13464a27 100644
index 641905dc01..3614dd7cd8 100644
--- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml
@@ -38,6 +38,30 @@
@@ -38,6 +38,110 @@
android:layout_marginStart="8dp"
android:minHeight="48dp"/>
+ <RadioButton
+ android:id="@+id/private_dns_mode_quadnine"
+ android:text="@string/private_dns_mode_quadnine"
+ android:id="@+id/private_dns_mode_adguard"
+ android:text="@string/private_dns_mode_adguard"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_appliedprivacy"
+ android:text="@string/private_dns_mode_appliedprivacy"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_cira"
+ android:text="@string/private_dns_mode_cira"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_cleanbrowsing"
+ android:text="@string/private_dns_mode_cleanbrowsing"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
@ -45,8 +69,64 @@ index 641905dc01..4f13464a27 100644
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_adguard"
+ android:text="@string/private_dns_mode_adguard"
+ android:id="@+id/private_dns_mode_cznic"
+ android:text="@string/private_dns_mode_cznic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_google"
+ android:text="@string/private_dns_mode_google"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_mullvad"
+ android:text="@string/private_dns_mode_mullvad"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_quadnine"
+ android:text="@string/private_dns_mode_quadnine"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_restena"
+ android:text="@string/private_dns_mode_restena"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_switch"
+ android:text="@string/private_dns_mode_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_twnic"
+ android:text="@string/private_dns_mode_twnic"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:minHeight="48dp"/>
+
+ <RadioButton
+ android:id="@+id/private_dns_mode_uncensoreddns"
+ android:text="@string/private_dns_mode_uncensoreddns"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
@ -56,90 +136,200 @@ index 641905dc01..4f13464a27 100644
android:id="@+id/private_dns_mode_opportunistic"
android:text="@string/private_dns_mode_opportunistic"
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 12ad48e683..78f835e4e1 100644
index 12ad48e683..9ed50db5ad 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -104,6 +104,11 @@
@@ -104,6 +104,21 @@
<string name="unlock_scramble_pin_layout_title">Scramble layout</string>
<string name="unlock_scramble_pin_layout_summary">Scramble PIN layout when unlocking device</string>
+ <!-- Private DNS -->
+ <string name="private_dns_mode_quadnine" translatable="false">Quad9</string>
+ <string name="private_dns_mode_cloudflare" translatable="false">Cloudflare</string>
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard</string>
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard (CY)</string>
+ <string name="private_dns_mode_appliedprivacy" translatable="false">AppliedPrivacy (AT)</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>
+
<!-- Volume link notification -->
<string name="volume_link_notification_title">Link ring &amp; notification volumes</string>
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 1655c69cea..26f68f1cf7 100644
index 1655c69cea..0beef5fc13 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -17,6 +17,9 @@ package com.android.settings.network;
@@ -17,6 +17,19 @@ package com.android.settings.network;
import static android.net.ConnectivityManager.PRIVATE_DNS_DEFAULT_MODE_FALLBACK;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
@@ -73,6 +76,9 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
@@ -73,6 +86,19 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
static {
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_QUADNINE, R.id.private_dns_mode_quadnine);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLOUDFLARE, R.id.private_dns_mode_cloudflare);
+ 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_CIRA, R.id.private_dns_mode_cira);
+ 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_CZNIC, R.id.private_dns_mode_cznic);
+ 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_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_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_OPPORTUNISTIC, R.id.private_dns_mode_opportunistic);
PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME, R.id.private_dns_mode_provider);
}
@@ -211,6 +217,15 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
@@ -211,6 +237,45 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
case R.id.private_dns_mode_off:
mMode = PRIVATE_DNS_MODE_OFF;
break;
+ case R.id.private_dns_mode_quadnine:
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ case R.id.private_dns_mode_adguard:
+ mMode = PRIVATE_DNS_MODE_ADGUARD;
+ break;
+ case R.id.private_dns_mode_appliedprivacy:
+ mMode = PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+ break;
+ case R.id.private_dns_mode_cira:
+ mMode = PRIVATE_DNS_MODE_CIRA;
+ break;
+ case R.id.private_dns_mode_cleanbrowsing:
+ mMode = PRIVATE_DNS_MODE_CLEANBROWSING;
+ break;
+ case R.id.private_dns_mode_cloudflare:
+ mMode = PRIVATE_DNS_MODE_CLOUDFLARE;
+ break;
+ case R.id.private_dns_mode_adguard:
+ mMode = PRIVATE_DNS_MODE_ADGUARD;
+ case R.id.private_dns_mode_cznic:
+ mMode = PRIVATE_DNS_MODE_CZNIC;
+ break;
+ case R.id.private_dns_mode_google:
+ mMode = PRIVATE_DNS_MODE_GOOGLE;
+ break;
+ case R.id.private_dns_mode_mullvad:
+ mMode = PRIVATE_DNS_MODE_MULLVAD;
+ break;
+ case R.id.private_dns_mode_quadnine:
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ break;
+ case R.id.private_dns_mode_restena:
+ mMode = PRIVATE_DNS_MODE_RESTENA;
+ break;
+ case R.id.private_dns_mode_switch:
+ mMode = PRIVATE_DNS_MODE_SWITCH;
+ break;
+ case R.id.private_dns_mode_twnic:
+ mMode = PRIVATE_DNS_MODE_TWNIC;
+ break;
+ case R.id.private_dns_mode_uncensoreddns:
+ mMode = PRIVATE_DNS_MODE_UNCENSOREDDNS;
+ break;
case R.id.private_dns_mode_opportunistic:
mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
break;
diff --git a/src/com/android/settings/network/PrivateDnsPreferenceController.java b/src/com/android/settings/network/PrivateDnsPreferenceController.java
index 47c3a95c9f..0a76cc245e 100644
index 47c3a95c9f..1ab3293cfb 100644
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -17,6 +17,9 @@
@@ -17,6 +17,19 @@
package com.android.settings.network;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.provider.Settings.Global.PRIVATE_DNS_DEFAULT_MODE;
@@ -125,6 +128,18 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
@@ -125,6 +138,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_QUADNINE:
+ case PRIVATE_DNS_MODE_ADGUARD:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_quadnine)
+ ? 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_ADGUARD:
+ case PRIVATE_DNS_MODE_CZNIC:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_adguard)
+ ? 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:
// TODO (b/79122154) : create a string specifically for this, instead of

View File

@ -1,9 +1,9 @@
From f62f32f8dc9940f7da0c1f527035367de2ae5fc5 Mon Sep 17 00:00:00 2001
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 21 Oct 2021 20:54:37 -0400
Subject: [PATCH] Add more 'Private DNS' options
This adds: Quad9, Cloudflare, and AdGuard
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
@ -16,22 +16,38 @@ Credit: CalyxOS
Signed-off-by: Tad <tad@spotco.us>
Change-Id: Id75a774ce1ed109a83c6a5bf512536c643165d71
---
.../java/android/net/ConnectivityManager.java | 24 +++++++++++++++++++
.../server/connectivity/DnsManager.java | 18 ++++++++++++++
2 files changed, 42 insertions(+)
.../java/android/net/ConnectivityManager.java | 104 ++++++++++++++++++
.../server/connectivity/DnsManager.java | 66 +++++++++++
2 files changed, 170 insertions(+)
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index ed03f5198d6f..754ee2583002 100644
index ed03f5198d6f..fbd89c72d70f 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -796,6 +796,18 @@ public class ConnectivityManager {
@@ -796,6 +796,58 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_OFF = "off";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_QUADNINE = "quadnine";
+ public static final String PRIVATE_DNS_MODE_ADGUARD = "adguard";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_APPLIEDPRIVACY = "appliedprivacy";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CLEANBROWSING = "cleanbrowsing";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CIRA = "cira";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_CZNIC = "cznic";
+ /**
+ * @hide
+ */
@ -39,61 +55,172 @@ index ed03f5198d6f..754ee2583002 100644
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_ADGUARD = "adguard";
+ public static final String PRIVATE_DNS_MODE_GOOGLE = "google";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_MULLVAD = "mullvad";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_QUADNINE = "quadnine";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_RESTENA = "restena";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_SWITCH = "switch";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_TWNIC = "twnic";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_MODE_UNCENSOREDDNS = "uncensoreddns";
/**
* @hide
*/
@@ -804,6 +816,18 @@ public class ConnectivityManager {
@@ -804,6 +856,58 @@ public class ConnectivityManager {
* @hide
*/
public static final String PRIVATE_DNS_MODE_PROVIDER_HOSTNAME = "hostname";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY = "dot1.applied-privacy.net";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
+ /**
+ * @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_CLOUDFLARE = "one.one.one.one";
+ public static final String PRIVATE_DNS_SPECIFIER_RESTENA = "kaitain.restena.lu";
+ /**
+ * @hide
+ */
+ public static final String PRIVATE_DNS_SPECIFIER_ADGUARD = "dns.adguard.com";
+ 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";
/**
* The default Private DNS mode.
*
diff --git a/services/core/java/com/android/server/connectivity/DnsManager.java b/services/core/java/com/android/server/connectivity/DnsManager.java
index cf6a7f6e8d70..0410d54ac8a7 100644
index cf6a7f6e8d70..5d3de9edc930 100644
--- a/services/core/java/com/android/server/connectivity/DnsManager.java
+++ b/services/core/java/com/android/server/connectivity/DnsManager.java
@@ -18,7 +18,13 @@ package com.android.server.connectivity;
@@ -18,6 +18,32 @@ package com.android.server.connectivity;
import static android.net.ConnectivityManager.PRIVATE_DNS_DEFAULT_MODE_FALLBACK;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.provider.Settings.Global.DNS_RESOLVER_MAX_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_MIN_SAMPLES;
import static android.provider.Settings.Global.DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS;
@@ -136,6 +142,18 @@ public class DnsManager {
@@ -136,6 +162,46 @@ public class DnsManager {
return new PrivateDnsConfig(specifier, null);
}
+ if (PRIVATE_DNS_MODE_QUADNINE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ if (PRIVATE_DNS_MODE_ADGUARD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ }
+ if (PRIVATE_DNS_MODE_APPLIEDPRIVACY.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_APPLIEDPRIVACY, null);
+ }
+ if (PRIVATE_DNS_MODE_CIRA.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CIRA, null);
+ }
+ if (PRIVATE_DNS_MODE_CLEANBROWSING.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLEANBROWSING, null);
+ }
+
+ if (PRIVATE_DNS_MODE_CLOUDFLARE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CLOUDFLARE, null);
+ }
+
+ if (PRIVATE_DNS_MODE_ADGUARD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_ADGUARD, null);
+ if (PRIVATE_DNS_MODE_CZNIC.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_CZNIC, null);
+ }
+ if (PRIVATE_DNS_MODE_GOOGLE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_GOOGLE, null);
+ }
+ if (PRIVATE_DNS_MODE_MULLVAD.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_MULLVAD, null);
+ }
+ if (PRIVATE_DNS_MODE_QUADNINE.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_QUADNINE, null);
+ }
+ if (PRIVATE_DNS_MODE_RESTENA.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_RESTENA, null);
+ }
+ if (PRIVATE_DNS_MODE_SWITCH.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_SWITCH, null);
+ }
+ if (PRIVATE_DNS_MODE_TWNIC.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_TWNIC, null);
+ }
+ if (PRIVATE_DNS_MODE_UNCENSOREDDNS.equals(mode)) {
+ return new PrivateDnsConfig(PRIVATE_DNS_SPECIFIER_UNCENSOREDDNS, null);
+ }
+
return new PrivateDnsConfig(useTls);

View File

@ -3,7 +3,7 @@ From: Tad <tad@spotco.us>
Date: Thu, 21 Oct 2021 21:09:38 -0400
Subject: [PATCH] Add more 'Private DNS' options
This adds: Quad9, Cloudflare, and AdGuard
This adds thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
@ -14,22 +14,34 @@ Credit: CalyxOS
Signed-off-by: Tad <tad@spotco.us>
Change-Id: I423ad5a3c360a687a226e61df3f75b5550f851c0
---
res/layout/private_dns_mode_dialog.xml | 12 +++++++++++
res/values/cm_strings.xml | 5 +++++
.../PrivateDnsModeDialogPreference.java | 21 +++++++++++++++++++
.../PrivateDnsPreferenceController.java | 15 +++++++++++++
4 files changed, 53 insertions(+)
res/layout/private_dns_mode_dialog.xml | 52 +++++++++++
res/values/cm_strings.xml | 15 +++
.../PrivateDnsModeDialogPreference.java | 92 +++++++++++++++++++
.../PrivateDnsPreferenceController.java | 65 +++++++++++++
4 files changed, 224 insertions(+)
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index 0b4f4db6c4..8b1d28450c 100644
index 0b4f4db6c4..ca6a2cf62d 100644
--- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml
@@ -35,6 +35,18 @@
@@ -35,6 +35,58 @@
android:id="@+id/private_dns_mode_off"
layout="@layout/preference_widget_dialog_radiobutton"/>
+ <include
+ android:id="@+id/private_dns_mode_quadnine"
+ android:id="@+id/private_dns_mode_adguard"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_appliedprivacy"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_cira"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_cleanbrowsing"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
@ -37,108 +49,269 @@ index 0b4f4db6c4..8b1d28450c 100644
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_adguard"
+ android:id="@+id/private_dns_mode_cznic"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_google"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_mullvad"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_quadnine"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_restena"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_switch"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_twnic"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_uncensoreddns"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
<include
android:id="@+id/private_dns_mode_opportunistic"
layout="@layout/preference_widget_dialog_radiobutton"/>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index c35c696b16..d18f0af87f 100644
index c35c696b16..0523c1a276 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -177,4 +177,9 @@
<string name="captive_portal_switch_title">Captive portal mode</string>
<string name="captive_portal_switch_summary">Enable or disable the captive portal probing for connection attempts (default ON).</string>
<string name="captive_portal_switch_warning">If you switch off the captive portal, you will not receive connectivity informations any longer. Really switch off?</string>
+
@@ -134,6 +134,21 @@
<string name="unlock_scramble_pin_layout_title">Scramble layout</string>
<string name="unlock_scramble_pin_layout_summary">Scramble PIN layout when unlocking device</string>
+ <!-- Private DNS -->
+ <string name="private_dns_mode_quadnine" translatable="false">Quad9</string>
+ <string name="private_dns_mode_cloudflare" translatable="false">Cloudflare</string>
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard</string>
</resources>
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard (CY)</string>
+ <string name="private_dns_mode_appliedprivacy" translatable="false">AppliedPrivacy (AT)</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>
+
<!-- Proximity wake -->
<string name="proximity_wake_title">Prevent accidental wake-up</string>
<string name="proximity_wake_summary">Check the proximity sensor prior to waking up screen</string>
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 3fc5086cd6..af4b08f3a7 100644
index 3fc5086cd6..abfb5b4470 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -17,6 +17,9 @@ package com.android.settings.network;
@@ -17,6 +17,19 @@ package com.android.settings.network;
import static android.net.ConnectivityManager.PRIVATE_DNS_DEFAULT_MODE_FALLBACK;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
@@ -74,6 +77,9 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
@@ -74,6 +87,19 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
static {
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_QUADNINE, R.id.private_dns_mode_quadnine);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLOUDFLARE, R.id.private_dns_mode_cloudflare);
+ 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_CIRA, R.id.private_dns_mode_cira);
+ 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_CZNIC, R.id.private_dns_mode_cznic);
+ 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_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_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_OPPORTUNISTIC, R.id.private_dns_mode_opportunistic);
PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME, R.id.private_dns_mode_provider);
}
@@ -180,6 +186,15 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
@@ -180,6 +206,46 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
// Initial radio button text
final RadioButton offRadioButton = view.findViewById(R.id.private_dns_mode_off);
offRadioButton.setText(R.string.private_dns_mode_off);
+ final RadioButton quadnineRadioButton =
+ view.findViewById(R.id.private_dns_mode_quadnine);
+ quadnineRadioButton.setText(R.string.private_dns_mode_quadnine);
+ final RadioButton cloudflareRadioButton =
+ view.findViewById(R.id.private_dns_mode_cloudflare);
+ cloudflareRadioButton.setText(R.string.private_dns_mode_cloudflare);
+ final RadioButton adguardRadioButton =
+ view.findViewById(R.id.private_dns_mode_adguard);
+ adguardRadioButton.setText(R.string.private_dns_mode_adguard);
+ final RadioButton appliedprivacyRadioButton =
+ view.findViewById(R.id.private_dns_mode_appliedprivacy);
+ appliedprivacyRadioButton.setText(R.string.private_dns_mode_appliedprivacy);
+ final RadioButton ciraRadioButton =
+ view.findViewById(R.id.private_dns_mode_cira);
+ ciraRadioButton.setText(R.string.private_dns_mode_cira);
+ final RadioButton cleanbrowsingRadioButton =
+ view.findViewById(R.id.private_dns_mode_cleanbrowsing);
+ cleanbrowsingRadioButton.setText(R.string.private_dns_mode_cleanbrowsing);
+ final RadioButton cloudflareRadioButton =
+ view.findViewById(R.id.private_dns_mode_cloudflare);
+ cloudflareRadioButton.setText(R.string.private_dns_mode_cloudflare);
+ final RadioButton cznicRadioButton =
+ view.findViewById(R.id.private_dns_mode_cznic);
+ cznicRadioButton.setText(R.string.private_dns_mode_cznic);
+ final RadioButton googleRadioButton =
+ view.findViewById(R.id.private_dns_mode_google);
+ googleRadioButton.setText(R.string.private_dns_mode_google);
+ final RadioButton mullvadRadioButton =
+ view.findViewById(R.id.private_dns_mode_mullvad);
+ mullvadRadioButton.setText(R.string.private_dns_mode_mullvad);
+ final RadioButton quadnineRadioButton =
+ view.findViewById(R.id.private_dns_mode_quadnine);
+ quadnineRadioButton.setText(R.string.private_dns_mode_quadnine);
+ final RadioButton restenaRadioButton =
+ view.findViewById(R.id.private_dns_mode_restena);
+ restenaRadioButton.setText(R.string.private_dns_mode_restena);
+ final RadioButton switchRadioButton =
+ view.findViewById(R.id.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 =
+ view.findViewById(R.id.private_dns_mode_uncensoreddns);
+ uncensoreddnsRadioButton.setText(R.string.private_dns_mode_uncensoreddns);
+
final RadioButton opportunisticRadioButton =
view.findViewById(R.id.private_dns_mode_opportunistic);
opportunisticRadioButton.setText(R.string.private_dns_mode_opportunistic);
@@ -221,6 +236,12 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
@@ -221,6 +287,32 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.private_dns_mode_off) {
mMode = PRIVATE_DNS_MODE_OFF;
+ } else if (checkedId == R.id.private_dns_mode_quadnine) {
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ } else if (checkedId == R.id.private_dns_mode_cloudflare) {
+ mMode = PRIVATE_DNS_MODE_CLOUDFLARE;
+ } else if (checkedId == R.id.private_dns_mode_adguard) {
+ mMode = PRIVATE_DNS_MODE_ADGUARD;
+ } else if (checkedId == R.id.private_dns_mode_appliedprivacy) {
+ mMode = PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+ } else if (checkedId == R.id.private_dns_mode_cira) {
+ mMode = PRIVATE_DNS_MODE_CIRA;
+ } else if (checkedId == R.id.private_dns_mode_cleanbrowsing) {
+ mMode = PRIVATE_DNS_MODE_CLEANBROWSING;
+ } else if (checkedId == R.id.private_dns_mode_cloudflare) {
+ mMode = PRIVATE_DNS_MODE_CLOUDFLARE;
+ } else if (checkedId == R.id.private_dns_mode_cznic) {
+ mMode = PRIVATE_DNS_MODE_CZNIC;
+ } else if (checkedId == R.id.private_dns_mode_google) {
+ mMode = PRIVATE_DNS_MODE_GOOGLE;
+ } else if (checkedId == R.id.private_dns_mode_mullvad) {
+ mMode = PRIVATE_DNS_MODE_MULLVAD;
+ } else if (checkedId == R.id.private_dns_mode_quadnine) {
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ } else if (checkedId == R.id.private_dns_mode_restena) {
+ mMode = PRIVATE_DNS_MODE_RESTENA;
+ } else if (checkedId == R.id.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) {
+ mMode = PRIVATE_DNS_MODE_UNCENSOREDDNS;
} else if (checkedId == R.id.private_dns_mode_opportunistic) {
mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
} 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
index 84cae88f85..e0d416e412 100644
index 84cae88f85..2f102051d7 100644
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -17,6 +17,9 @@
@@ -17,6 +17,19 @@
package com.android.settings.network;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_ADGUARD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CIRA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLEANBROWSING;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CLOUDFLARE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_CZNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_GOOGLE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_MULLVAD;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_QUADNINE;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_RESTENA;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_SWITCH;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_TWNIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_UNCENSOREDDNS;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.provider.Settings.Global.PRIVATE_DNS_DEFAULT_MODE;
@@ -125,6 +128,18 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
@@ -125,6 +138,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_QUADNINE:
+ case PRIVATE_DNS_MODE_ADGUARD:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_quadnine)
+ ? 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_ADGUARD:
+ case PRIVATE_DNS_MODE_CZNIC:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_adguard)
+ ? 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)

View File

@ -84,5 +84,5 @@ commentPatches android_kernel_xiaomi_sm8250.sh "CVE-2018-5873" "CVE-2020-1749" "
commentPatches android_kernel_yandex_sdm660.sh "CVE-2019-11599" "CVE-2019-14070/ANY/0005.patch" "CVE-2019-19319" "CVE-2020-1749" "CVE-2020-8992" "CVE-2020-16166";
commentPatches android_kernel_zte_msm8930.sh "CVE-2015-2922" "CVE-2017-11015/prima";
commentPatches android_kernel_zte_msm8996.sh "0001-LinuxIncrementals/3.18/3.18.0098-0099.patch" "CVE-2017-13162" "CVE-2017-15951" "CVE-2017-16939" "CVE-2018-17972" "CVE-2019-2214" "CVE-2019-14070" "CVE-2019-16746" "CVE-2020-0427" "CVE-2020-14381" "CVE-2020-16166";
commentPatches android_kernel_zuk_msm8996.sh "0008-Graphene-Kernel_Hardening/4.4/0011.patch" "0008-Graphene-Kernel_Hardening/4.4/0012.patch" "0008-Graphene-Kernel_Hardening/4.4/0014.patch" "CVE-2019-19319" "CVE-2020-1749" "CVE-2020-8992" "CVE-2020-1616";
commentPatches android_kernel_zuk_msm8996.sh "0008-Graphene-Kernel_Hardening/4.4/0011.patch" "0008-Graphene-Kernel_Hardening/4.4/0012.patch" "0008-Graphene-Kernel_Hardening/4.4/0014.patch" "CVE-2019-19319" "CVE-2020-0305" "CVE-2020-1749" "CVE-2020-8992" "CVE-2020-1616";
echo -e "\e[0;32m[SCRIPT COMPLETE] Fixed CVE patchers\e[0m";

View File

@ -96,7 +96,7 @@ git apply $DOS_PATCHES_LINUX_CVES/CVE-2019-20810/4.4/0005.patch
git apply $DOS_PATCHES_LINUX_CVES/CVE-2019-20812/4.4/0006.patch
git apply $DOS_PATCHES_LINUX_CVES/CVE-2020-0009/4.4/0007.patch
git apply $DOS_PATCHES_LINUX_CVES/CVE-2020-0255/4.4/0006.patch
git apply $DOS_PATCHES_LINUX_CVES/CVE-2020-0305/4.4/0005.patch
#git apply $DOS_PATCHES_LINUX_CVES/CVE-2020-0305/4.4/0005.patch
git apply $DOS_PATCHES_LINUX_CVES/CVE-2020-0427/4.4/0002.patch
git apply $DOS_PATCHES_LINUX_CVES/CVE-2020-0429/4.4/0007.patch
git apply $DOS_PATCHES_LINUX_CVES/CVE-2020-0429/4.4/0009.patch