DivestOS/Patches/LineageOS-19.1/android_packages_apps_Settings/0004-Private_DNS.patch

315 lines
18 KiB
Diff
Raw Normal View History

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 thirteen DNS providers as available presets.
Credit: CalyxOS
- Chirayu Desai <chirayudesai1@gmail.com>
https://review.calyxos.org/c/CalyxOS/platform_packages_apps_Settings/+/9504
Change-Id: I7e8a320d47e7c5ddbcb9acfaf23032ae92d5d70d
---
res/layout/private_dns_mode_dialog.xml | 52 +++++++++++
res/values/cm_strings.xml | 15 +++
.../PrivateDnsModeDialogPreference.java | 93 +++++++++++++++++++
.../PrivateDnsPreferenceController.java | 67 +++++++++++++
4 files changed, 227 insertions(+)
diff --git a/res/layout/private_dns_mode_dialog.xml b/res/layout/private_dns_mode_dialog.xml
index 12e29e693b..b6745806b5 100644
--- a/res/layout/private_dns_mode_dialog.xml
+++ b/res/layout/private_dns_mode_dialog.xml
@@ -35,6 +35,58 @@
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_cleanbrowsing"
+ 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_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 3ea294b8d5..15c0237c8a 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -81,6 +81,21 @@
<!-- Volume link notification -->
<string name="volume_link_notification_title">Link ring &amp; notification volumes</string>
+ <!-- Private DNS -->
+ <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>
+
<!-- PIN scramble -->
<string name="unlock_scramble_pin_layout_title">Scramble layout</string>
<string name="unlock_scramble_pin_layout_summary">Scramble PIN layout when unlocking device</string>
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 1c3fc76dba..0dfa81c6f3 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -72,9 +72,37 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat
// DNS_MODE -> RadioButton id
private static final Map<Integer, Integer> PRIVATE_DNS_MAP;
+ // Must match ConnectivitySettingsUtils
+ private static final int PRIVATE_DNS_MODE_ADGUARD = 4;
+ private static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5;
+ private static final int PRIVATE_DNS_MODE_CLEANBROWSING = 6;
+ private static final int PRIVATE_DNS_MODE_CIRA = 7;
+ private static final int PRIVATE_DNS_MODE_CZNIC = 8;
+ private static final int PRIVATE_DNS_MODE_CLOUDFLARE = 9;
+ private static final int PRIVATE_DNS_MODE_GOOGLE = 10;
+ private static final int PRIVATE_DNS_MODE_MULLVAD = 11;
+ private static final int PRIVATE_DNS_MODE_QUADNINE = 12;
+ private static final int PRIVATE_DNS_MODE_RESTENA = 13;
+ private static final int PRIVATE_DNS_MODE_SWITCH = 14;
+ private static final int PRIVATE_DNS_MODE_TWNIC = 15;
+ private static final int PRIVATE_DNS_MODE_UNCENSOREDDNS = 16;
+
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_CLEANBROWSING, R.id.private_dns_mode_cleanbrowsing);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CIRA, R.id.private_dns_mode_cira);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CZNIC, R.id.private_dns_mode_cznic);
+ PRIVATE_DNS_MAP.put(PRIVATE_DNS_MODE_CLOUDFLARE, R.id.private_dns_mode_cloudflare);
+ 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);
}
@@ -173,6 +201,45 @@ 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 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);
@@ -212,6 +279,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_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 ed6f9ed955..03f8d230ef 100644
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -65,6 +65,21 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
Settings.Global.getUriFor(PRIVATE_DNS_SPECIFIER),
};
+ // Must match ConnectivitySettingsUtils
+ private static final int PRIVATE_DNS_MODE_ADGUARD = 4;
+ private static final int PRIVATE_DNS_MODE_APPLIEDPRIVACY = 5;
+ private static final int PRIVATE_DNS_MODE_CLEANBROWSING = 6;
+ private static final int PRIVATE_DNS_MODE_CIRA = 7;
+ private static final int PRIVATE_DNS_MODE_CZNIC = 8;
+ private static final int PRIVATE_DNS_MODE_CLOUDFLARE = 9;
+ private static final int PRIVATE_DNS_MODE_GOOGLE = 10;
+ private static final int PRIVATE_DNS_MODE_MULLVAD = 11;
+ private static final int PRIVATE_DNS_MODE_QUADNINE = 12;
+ private static final int PRIVATE_DNS_MODE_RESTENA = 13;
+ private static final int PRIVATE_DNS_MODE_SWITCH = 14;
+ private static final int PRIVATE_DNS_MODE_TWNIC = 15;
+ private static final int PRIVATE_DNS_MODE_UNCENSOREDDNS = 16;
+
private final Handler mHandler;
private final ContentObserver mSettingsObserver;
private final ConnectivityManager mConnectivityManager;
@@ -129,6 +144,58 @@ public class PrivateDnsPreferenceController extends BasePreferenceController
switch (mode) {
case PRIVATE_DNS_MODE_OFF:
return res.getString(R.string.private_dns_mode_off);
+ case PRIVATE_DNS_MODE_ADGUARD:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_adguard)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_APPLIEDPRIVACY:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_appliedprivacy)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CIRA:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cira)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CLEANBROWSING:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cleanbrowsing)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CLOUDFLARE:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cloudflare)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_CZNIC:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_cznic)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_GOOGLE:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_google)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_MULLVAD:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_mullvad)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_QUADNINE:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_quadnine)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_RESTENA:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_restena)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_SWITCH:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_switch)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_TWNIC:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_twnic)
+ : res.getString(R.string.private_dns_mode_provider_failure);
+ case PRIVATE_DNS_MODE_UNCENSOREDDNS:
+ return dnsesResolved
+ ? res.getString(R.string.private_dns_mode_uncensoreddns)
+ : res.getString(R.string.private_dns_mode_provider_failure);
case PRIVATE_DNS_MODE_OPPORTUNISTIC:
return dnsesResolved ? res.getString(R.string.private_dns_mode_on)
: res.getString(R.string.private_dns_mode_opportunistic);