2022-10-15 14:51:30 -04:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Tad <tad@spotco.us>
|
|
|
|
Date: Mon, 24 Jun 2019 21:27:26 +0530
|
|
|
|
Subject: [PATCH] Add more 'Private DNS' options
|
|
|
|
|
2023-06-14 19:42:30 -04:00
|
|
|
This adds fifteen DNS providers as available presets.
|
2022-10-15 14:51:30 -04:00
|
|
|
|
|
|
|
Credit: CalyxOS
|
|
|
|
- Chirayu Desai <chirayudesai1@gmail.com>
|
2023-05-31 12:31:07 -04:00
|
|
|
https://review.calyxos.org/c/CalyxOS/platform_packages_apps_Settings/+/17176
|
2022-10-15 14:51:30 -04:00
|
|
|
|
|
|
|
Change-Id: I7e8a320d47e7c5ddbcb9acfaf23032ae92d5d70d
|
|
|
|
---
|
2023-06-14 19:42:30 -04:00
|
|
|
res/layout/private_dns_mode_dialog.xml | 60 ++++++
|
|
|
|
res/values/cm_strings.xml | 46 +++++
|
|
|
|
.../PrivateDnsModeDialogPreference.java | 192 +++++++++++++++++-
|
|
|
|
.../PrivateDnsPreferenceController.java | 40 +++-
|
|
|
|
4 files changed, 333 insertions(+), 5 deletions(-)
|
2022-10-15 14:51:30 -04:00
|
|
|
|
|
|
|
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
|
2023-06-14 19:42:30 -04:00
|
|
|
index 12e29e693b..b264bef20a 100644
|
2022-10-15 14:51:30 -04:00
|
|
|
--- a/res/layout/private_dns_mode_dialog.xml
|
|
|
|
+++ b/res/layout/private_dns_mode_dialog.xml
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -35,6 +35,66 @@
|
2022-10-15 14:51:30 -04:00
|
|
|
android:id="@+id/private_dns_mode_off"
|
|
|
|
layout="@layout/preference_widget_dialog_radiobutton"/>
|
|
|
|
|
|
|
|
+ <include
|
|
|
|
+ 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
|
2023-05-31 12:31:07 -04:00
|
|
|
+ android:id="@+id/private_dns_mode_controld"
|
|
|
|
+ layout="@layout/preference_widget_dialog_radiobutton"/>
|
|
|
|
+
|
|
|
|
+ <include
|
2022-10-15 14:51:30 -04:00
|
|
|
+ android:id="@+id/private_dns_mode_cleanbrowsing"
|
|
|
|
+ layout="@layout/preference_widget_dialog_radiobutton"/>
|
|
|
|
+
|
|
|
|
+ <include
|
2023-05-31 12:31:07 -04:00
|
|
|
+ android:id="@+id/private_dns_mode_cznic"
|
|
|
|
+ layout="@layout/preference_widget_dialog_radiobutton"/>
|
|
|
|
+
|
|
|
|
+ <include
|
2022-10-15 14:51:30 -04:00
|
|
|
+ android:id="@+id/private_dns_mode_cloudflare"
|
|
|
|
+ layout="@layout/preference_widget_dialog_radiobutton"/>
|
|
|
|
+
|
|
|
|
+ <include
|
2023-05-31 12:31:07 -04:00
|
|
|
+ android:id="@+id/private_dns_mode_dnszero"
|
2022-10-15 14:51:30 -04:00
|
|
|
+ layout="@layout/preference_widget_dialog_radiobutton"/>
|
|
|
|
+
|
|
|
|
+ <include
|
2023-06-14 19:42:30 -04:00
|
|
|
+ android:id="@+id/private_dns_mode_dnssb"
|
|
|
|
+ layout="@layout/preference_widget_dialog_radiobutton"/>
|
|
|
|
+
|
|
|
|
+ <include
|
2022-10-15 14:51:30 -04:00
|
|
|
+ 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_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
|
2024-08-17 21:34:17 -04:00
|
|
|
index 698965172f..444f2f9131 100644
|
2022-10-15 14:51:30 -04:00
|
|
|
--- a/res/values/cm_strings.xml
|
|
|
|
+++ b/res/values/cm_strings.xml
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -15,6 +15,52 @@
|
2023-05-31 12:31:07 -04:00
|
|
|
limitations under the License.
|
|
|
|
-->
|
|
|
|
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <!-- Private DNS -->
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard (CT)</string>
|
|
|
|
+ <string name="private_dns_hostname_adguard" translatable="false">dns.adguard.com</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_appliedprivacy" translatable="false">AppliedPrivacy (AT)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_appliedprivacy" translatable="false">dot1.applied-privacy.net</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_cira" translatable="false">CIRA (CA)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_cira" translatable="false">protected.canadianshield.cira.ca</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_cleanbrowsing" translatable="false">CleanBrowsing (US)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_cleanbrowsing" translatable="false">security-filter-dns.cleanbrowsing.org</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_cloudflare" translatable="false">Cloudflare (US)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <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>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_cznic" translatable="false">CZ.NIC (CZ)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <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>
|
|
|
|
+
|
2023-06-14 19:42:30 -04:00
|
|
|
+ <string name="private_dns_mode_dnssb" translatable="false">DNS.SB (DE)</string>
|
|
|
|
+ <string name="private_dns_hostname_dnssb" translatable="false">dot.sb</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_google" translatable="false">Google (US)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_google" translatable="false">dns.google</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_mullvad" translatable="false">Mullvad (SE)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_mullvad" translatable="false">adblock.dns.mullvad.net</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_quadnine" translatable="false">Quad9 (CH)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_quadnine" translatable="false">dns.quad9.net</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_restena" translatable="false">Restena (LU)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_restena" translatable="false">kaitain.restena.lu</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_switch" translatable="false">SWITCH (CH)</string>
|
2023-05-31 12:31:07 -04:00
|
|
|
+ <string name="private_dns_hostname_switch" translatable="false">dns.switch.ch</string>
|
|
|
|
+
|
2022-10-15 14:51:30 -04:00
|
|
|
+ <string name="private_dns_mode_uncensoreddns" translatable="false">UncensoredDNS (DK)</string>
|
2023-06-05 15:47:21 -04:00
|
|
|
+ <string name="private_dns_hostname_uncensoreddns" translatable="false">anycast.censurfridns.dk</string>
|
2022-10-15 14:51:30 -04:00
|
|
|
+
|
2023-05-31 12:31:07 -04:00
|
|
|
<!-- Advanced keyboard settings -->
|
|
|
|
<string name="keyboard_extras_title">Extras</string>
|
|
|
|
<string name="advanced_keyboard_settings_title">Advanced settings</string>
|
2022-10-15 14:51:30 -04:00
|
|
|
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
|
2023-06-14 19:42:30 -04:00
|
|
|
index 5c7c54eda3..4656b73df5 100644
|
2022-10-15 14:51:30 -04:00
|
|
|
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
|
|
|
|
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -72,9 +72,41 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
|
2022-10-15 14:51:30 -04:00
|
|
|
// DNS_MODE -> RadioButton id
|
|
|
|
private static final Map<Integer, Integer> PRIVATE_DNS_MAP;
|
|
|
|
|
2023-05-31 12:31:07 -04:00
|
|
|
+ // Only used in Settings
|
2022-10-15 14:51:30 -04:00
|
|
|
+ private static final int PRIVATE_DNS_MODE_ADGUARD = 4;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5;
|
2023-05-31 12:31:07 -04:00
|
|
|
+ private static final int PRIVATE_DNS_MODE_CIRA = 6;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_CLEANBROWSING = 7;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_CLOUDFLARE = 8;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_CONTROLD = 9;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_CZNIC = 10;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_DNSZERO = 11;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_GOOGLE = 12;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_MULLVAD = 13;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_QUADNINE = 14;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_RESTENA = 15;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_SWITCH = 16;
|
|
|
|
+ private static final int PRIVATE_DNS_MODE_UNCENSOREDDNS = 17;
|
2023-06-14 19:42:30 -04:00
|
|
|
+ private static final int PRIVATE_DNS_MODE_DNSSB = 18;
|
2022-10-15 14:51:30 -04:00
|
|
|
+
|
|
|
|
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_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);
|
2023-05-31 12:31:07 -04:00
|
|
|
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLEANBROWSING, R.id.private_dns_mode_cleanbrowsing);
|
2022-10-15 14:51:30 -04:00
|
|
|
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLOUDFLARE, R.id.private_dns_mode_cloudflare);
|
2023-05-31 12:31:07 -04:00
|
|
|
+ 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);
|
2023-06-14 19:42:30 -04:00
|
|
|
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_DNSSB, R.id.private_dns_mode_dnssb);
|
2022-10-15 14:51:30 -04:00
|
|
|
+ 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_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);
|
|
|
|
}
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -144,6 +176,41 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
|
2023-05-31 12:31:07 -04:00
|
|
|
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;
|
2023-06-14 19:42:30 -04:00
|
|
|
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_dnssb))) {
|
|
|
|
+ mMode = PRIVATE_DNS_MODE_DNSSB;
|
2023-05-31 12:31:07 -04:00
|
|
|
+ } 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);
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -156,6 +223,51 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
|
2022-10-15 14:51:30 -04:00
|
|
|
// 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 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);
|
2023-05-31 12:31:07 -04:00
|
|
|
+ final RadioButton controldRadioButton =
|
|
|
|
+ view.findViewById(R.id.private_dns_mode_controld);
|
|
|
|
+ controldRadioButton.setText(R.string.private_dns_mode_controld);
|
2022-10-15 14:51:30 -04:00
|
|
|
+ final RadioButton cznicRadioButton =
|
|
|
|
+ view.findViewById(R.id.private_dns_mode_cznic);
|
|
|
|
+ cznicRadioButton.setText(R.string.private_dns_mode_cznic);
|
2023-05-31 12:31:07 -04:00
|
|
|
+ final RadioButton dnszeroRadioButton =
|
|
|
|
+ view.findViewById(R.id.private_dns_mode_dnszero);
|
|
|
|
+ dnszeroRadioButton.setText(R.string.private_dns_mode_dnszero);
|
2023-06-14 19:42:30 -04:00
|
|
|
+ final RadioButton dnssbRadioButton =
|
|
|
|
+ view.findViewById(R.id.private_dns_mode_dnssb);
|
|
|
|
+ dnssbRadioButton.setText(R.string.private_dns_mode_dnssb);
|
2022-10-15 14:51:30 -04:00
|
|
|
+ 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 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);
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -181,15 +293,61 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
|
2023-05-31 12:31:07 -04:00
|
|
|
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;
|
2023-06-14 19:42:30 -04:00
|
|
|
+ } else if (mMode == PRIVATE_DNS_MODE_DNSSB) {
|
|
|
|
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_dnssb));
|
|
|
|
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
|
2023-05-31 12:31:07 -04:00
|
|
|
+ } 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -197,6 +355,36 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
|
2022-10-15 14:51:30 -04:00
|
|
|
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_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;
|
2023-05-31 12:31:07 -04:00
|
|
|
+ } else if (checkedId == R.id.private_dns_mode_controld) {
|
|
|
|
+ mMode = PRIVATE_DNS_MODE_CONTROLD;
|
2022-10-15 14:51:30 -04:00
|
|
|
+ } else if (checkedId == R.id.private_dns_mode_cznic) {
|
|
|
|
+ mMode = PRIVATE_DNS_MODE_CZNIC;
|
2023-05-31 12:31:07 -04:00
|
|
|
+ } else if (checkedId == R.id.private_dns_mode_dnszero) {
|
|
|
|
+ mMode = PRIVATE_DNS_MODE_DNSZERO;
|
2023-06-14 19:42:30 -04:00
|
|
|
+ } else if (checkedId == R.id.private_dns_mode_dnssb) {
|
|
|
|
+ mMode = PRIVATE_DNS_MODE_DNSSB;
|
2022-10-15 14:51:30 -04:00
|
|
|
+ } 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_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
|
2023-06-14 19:42:30 -04:00
|
|
|
index 42974be8e0..7b9dd3d36f 100644
|
2022-10-15 14:51:30 -04:00
|
|
|
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
|
|
|
|
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
|
2023-06-14 19:42:30 -04:00
|
|
|
@@ -133,9 +133,43 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
|
2022-10-15 14:51:30 -04:00
|
|
|
return dnsesResolved ? res.getString(R.string.private_dns_mode_on)
|
|
|
|
: res.getString(R.string.private_dns_mode_opportunistic);
|
2023-05-31 12:31:07 -04:00
|
|
|
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);
|
2023-06-14 19:42:30 -04:00
|
|
|
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_dnssb))) {
|
|
|
|
+ return res.getString(R.string.private_dns_mode_dnssb);
|
2023-05-31 12:31:07 -04:00
|
|
|
+ } 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 "";
|
|
|
|
}
|