DivestOS/Patches/LineageOS-20.0/android_packages_apps_Settings/0004-Private_DNS.patch
Tavi f7bb9e0c06
Fixup + Churn
run tested: flame, fajita

Signed-off-by: Tavi <tavi@divested.dev>
2024-08-17 22:17:10 -04:00

440 lines
27 KiB
Diff

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
This adds fifteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
https://review.calyxos.org/c/CalyxOS/platform_packages_apps_Settings/+/17176
Change-Id: I7e8a320d47e7c5ddbcb9acfaf23032ae92d5d70d
---
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(-)
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index 12e29e693b..b264bef20a 100644
--- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml
@@ -35,6 +35,66 @@
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
+ android:id="@+id/private_dns_mode_controld"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_cleanbrowsing"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_cznic"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_cloudflare"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_dnszero"
+ layout="@layout/preference_widget_dialog_radiobutton"/>
+
+ <include
+ android:id="@+id/private_dns_mode_dnssb"
+ 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_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 698965172f..444f2f9131 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -15,6 +15,52 @@
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Private DNS -->
+ <string name="private_dns_mode_adguard" translatable="false">AdGuard (CT)</string>
+ <string name="private_dns_hostname_adguard" translatable="false">dns.adguard.com</string>
+
+ <string name="private_dns_mode_appliedprivacy" translatable="false">AppliedPrivacy (AT)</string>
+ <string name="private_dns_hostname_appliedprivacy" translatable="false">dot1.applied-privacy.net</string>
+
+ <string name="private_dns_mode_cira" translatable="false">CIRA (CA)</string>
+ <string name="private_dns_hostname_cira" translatable="false">protected.canadianshield.cira.ca</string>
+
+ <string name="private_dns_mode_cleanbrowsing" translatable="false">CleanBrowsing (US)</string>
+ <string name="private_dns_hostname_cleanbrowsing" translatable="false">security-filter-dns.cleanbrowsing.org</string>
+
+ <string name="private_dns_mode_cloudflare" translatable="false">Cloudflare (US)</string>
+ <string name="private_dns_hostname_cloudflare" translatable="false">security.cloudflare-dns.com</string>
+
+ <string name="private_dns_mode_controld" translatable="false">Control D (CA)</string>
+ <string name="private_dns_hostname_controld" translatable="false">p2.freedns.controld.com</string>
+
+ <string name="private_dns_mode_cznic" translatable="false">CZ.NIC (CZ)</string>
+ <string name="private_dns_hostname_cznic" translatable="false">odvr.nic.cz</string>
+
+ <string name="private_dns_mode_dnszero" translatable="false">DNS0 (FR)</string>
+ <string name="private_dns_hostname_dnszero" translatable="false">zero.dns0.eu</string>
+
+ <string name="private_dns_mode_dnssb" translatable="false">DNS.SB (DE)</string>
+ <string name="private_dns_hostname_dnssb" translatable="false">dot.sb</string>
+
+ <string name="private_dns_mode_google" translatable="false">Google (US)</string>
+ <string name="private_dns_hostname_google" translatable="false">dns.google</string>
+
+ <string name="private_dns_mode_mullvad" translatable="false">Mullvad (SE)</string>
+ <string name="private_dns_hostname_mullvad" translatable="false">adblock.dns.mullvad.net</string>
+
+ <string name="private_dns_mode_quadnine" translatable="false">Quad9 (CH)</string>
+ <string name="private_dns_hostname_quadnine" translatable="false">dns.quad9.net</string>
+
+ <string name="private_dns_mode_restena" translatable="false">Restena (LU)</string>
+ <string name="private_dns_hostname_restena" translatable="false">kaitain.restena.lu</string>
+
+ <string name="private_dns_mode_switch" translatable="false">SWITCH (CH)</string>
+ <string name="private_dns_hostname_switch" translatable="false">dns.switch.ch</string>
+
+ <string name="private_dns_mode_uncensoreddns" translatable="false">UncensoredDNS (DK)</string>
+ <string name="private_dns_hostname_uncensoreddns" translatable="false">anycast.censurfridns.dk</string>
+
<!-- Advanced keyboard settings -->
<string name="keyboard_extras_title">Extras</string>
<string name="advanced_keyboard_settings_title">Advanced settings</string>
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 5c7c54eda3..4656b73df5 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -72,9 +72,41 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
// DNS_MODE -> RadioButton id
private static final Map<Integer, Integer> PRIVATE_DNS_MAP;
+ // Only used in Settings
+ private static final int PRIVATE_DNS_MODE_ADGUARD = 4;
+ private static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5;
+ private static final int PRIVATE_DNS_MODE_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;
+ private static final int PRIVATE_DNS_MODE_DNSSB = 18;
+
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);
+ 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_CONTROLD, R.id.private_dns_mode_controld);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CZNIC, R.id.private_dns_mode_cznic);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_DNSZERO, R.id.private_dns_mode_dnszero);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_DNSSB, R.id.private_dns_mode_dnssb);
+ 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);
}
@@ -144,6 +176,41 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
final ContentResolver contentResolver = context.getContentResolver();
mMode = ConnectivitySettingsManager.getPrivateDnsMode(context);
+ if (mMode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME) {
+ final String privateDnsHostname =
+ ConnectivitySettingsManager.getPrivateDnsHostname(context);
+ if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_adguard))) {
+ mMode = PRIVATE_DNS_MODE_ADGUARD;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_appliedprivacy))) {
+ mMode = PRIVATE_DNS_MODE_APPLIEDPRIVACY;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cira))) {
+ mMode = PRIVATE_DNS_MODE_CIRA;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cleanbrowsing))) {
+ mMode = PRIVATE_DNS_MODE_CLEANBROWSING;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cloudflare))) {
+ mMode = PRIVATE_DNS_MODE_CLOUDFLARE;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_controld))) {
+ mMode = PRIVATE_DNS_MODE_CONTROLD;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_cznic))) {
+ mMode = PRIVATE_DNS_MODE_CZNIC;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_dnszero))) {
+ mMode = PRIVATE_DNS_MODE_DNSZERO;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_dnssb))) {
+ mMode = PRIVATE_DNS_MODE_DNSSB;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_google))) {
+ mMode = PRIVATE_DNS_MODE_GOOGLE;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_mullvad))) {
+ mMode = PRIVATE_DNS_MODE_MULLVAD;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_quadnine))) {
+ mMode = PRIVATE_DNS_MODE_QUADNINE;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_restena))) {
+ mMode = PRIVATE_DNS_MODE_RESTENA;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_switch))) {
+ mMode = PRIVATE_DNS_MODE_SWITCH;
+ } else if (privateDnsHostname.equals(context.getString(R.string.private_dns_hostname_uncensoreddns))) {
+ mMode = PRIVATE_DNS_MODE_UNCENSOREDDNS;
+ }
+ }
mEditText = view.findViewById(R.id.private_dns_mode_provider_hostname);
mEditText.addTextChangedListener(this);
@@ -156,6 +223,51 @@ 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 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 controldRadioButton =
+ view.findViewById(R.id.private_dns_mode_controld);
+ controldRadioButton.setText(R.string.private_dns_mode_controld);
+ final RadioButton cznicRadioButton =
+ view.findViewById(R.id.private_dns_mode_cznic);
+ cznicRadioButton.setText(R.string.private_dns_mode_cznic);
+ final RadioButton dnszeroRadioButton =
+ view.findViewById(R.id.private_dns_mode_dnszero);
+ dnszeroRadioButton.setText(R.string.private_dns_mode_dnszero);
+ final RadioButton dnssbRadioButton =
+ view.findViewById(R.id.private_dns_mode_dnssb);
+ dnssbRadioButton.setText(R.string.private_dns_mode_dnssb);
+ 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);
@@ -181,15 +293,61 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
final Context context = getContext();
+ int modeToSet = mMode;
if (mMode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME) {
// Only clickable if hostname is valid, so we could save it safely
ConnectivitySettingsManager.setPrivateDnsHostname(context,
mEditText.getText().toString());
+ } else if (mMode == PRIVATE_DNS_MODE_ADGUARD) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_adguard));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_APPLIEDPRIVACY) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_appliedprivacy));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CIRA) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cira));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CLEANBROWSING) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cleanbrowsing));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CLOUDFLARE) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cloudflare));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CONTROLD) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_controld));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_CZNIC) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_cznic));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_DNSZERO) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_dnszero));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_DNSSB) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_dnssb));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_GOOGLE) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_google));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_MULLVAD) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_mullvad));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_QUADNINE) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_quadnine));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_RESTENA) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_restena));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_SWITCH) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_switch));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+ } else if (mMode == PRIVATE_DNS_MODE_UNCENSOREDDNS) {
+ ConnectivitySettingsManager.setPrivateDnsHostname(context, context.getString(R.string.private_dns_hostname_uncensoreddns));
+ modeToSet = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
}
FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context,
- SettingsEnums.ACTION_PRIVATE_DNS_MODE, mMode);
- ConnectivitySettingsManager.setPrivateDnsMode(context, mMode);
+ SettingsEnums.ACTION_PRIVATE_DNS_MODE, modeToSet);
+ ConnectivitySettingsManager.setPrivateDnsMode(context, modeToSet);
}
}
@@ -197,6 +355,36 @@ 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_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_controld) {
+ mMode = PRIVATE_DNS_MODE_CONTROLD;
+ } else if (checkedId == R.id.private_dns_mode_cznic) {
+ mMode = PRIVATE_DNS_MODE_CZNIC;
+ } else if (checkedId == R.id.private_dns_mode_dnszero) {
+ mMode = PRIVATE_DNS_MODE_DNSZERO;
+ } else if (checkedId == R.id.private_dns_mode_dnssb) {
+ mMode = PRIVATE_DNS_MODE_DNSSB;
+ } 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
index 42974be8e0..7b9dd3d36f 100644
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -133,9 +133,43 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
return dnsesResolved ? res.getString(R.string.private_dns_mode_on)
: res.getString(R.string.private_dns_mode_opportunistic);
case PRIVATE_DNS_MODE_PROVIDER_HOSTNAME:
- return dnsesResolved
- ? PrivateDnsModeDialogPreference.getHostnameFromSettings(cr)
- : res.getString(R.string.private_dns_mode_provider_failure);
+ if (!dnsesResolved) {
+ return res.getString(R.string.private_dns_mode_provider_failure);
+ }
+ final String privateDnsHostname =
+ ConnectivitySettingsManager.getPrivateDnsHostname(mContext);
+ if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_adguard))) {
+ return res.getString(R.string.private_dns_mode_adguard);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_appliedprivacy))) {
+ return res.getString(R.string.private_dns_mode_appliedprivacy);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cira))) {
+ return res.getString(R.string.private_dns_mode_cira);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cleanbrowsing))) {
+ return res.getString(R.string.private_dns_mode_cleanbrowsing);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cloudflare))) {
+ return res.getString(R.string.private_dns_mode_cloudflare);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_controld))) {
+ return res.getString(R.string.private_dns_mode_controld);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_cznic))) {
+ return res.getString(R.string.private_dns_mode_cznic);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_dnszero))) {
+ return res.getString(R.string.private_dns_mode_dnszero);
+ } else if (privateDnsHostname.equals(res.getString(R.string.private_dns_hostname_dnssb))) {
+ return res.getString(R.string.private_dns_mode_dnssb);
+ } 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 "";
}