Skip to content

Commit

Permalink
settings: Use DNSCrypt with Tor
Browse files Browse the repository at this point in the history
  • Loading branch information
syphyr committed Feb 15, 2022
1 parent 6f4e60e commit 5064ace
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<!-- When true enable dnscrypt proxy setting. -->
<bool name="config_enableDnscryptProxy">true</bool>

<!-- When true enable dnscrypt tor setting. -->
<bool name="config_enableDnscryptTor">true</bool>

<!-- carrier tethering default ssid and password begin -->
<bool name="use_empty_password_default">false</bool>
<bool name="hotspot_default_ssid_with_imei_enable">false</bool>
Expand Down
9 changes: 9 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7415,6 +7415,15 @@
<!-- Toast message for dnscrypt proxy -->
<string name="dnscrypt_proxy_toast">Status of DNSCrypt Proxy service changed successfully</string>

<!-- Name of the setting to enable dnscrypt proxy with tor -->
<string name="dnscrypt_tor">Use DNSCrypt Proxy with Tor</string>

<!-- Description of dnscrypt proxy setting with tor -->
<string name="dnscrypt_tor_desc">Send all DNS requests though Tor for additional privacy. Requires restart of DNSCrypt Proxy service</string>

<!-- Toast message for dnscrypt proxy with tor -->
<string name="dnscrypt_tor_toast">Changes successfully made to DNSCrypt Proxy configuration</string>

<!-- Name of the setting to disable the automatic update -->
<string name="ota_disable_automatic_update">Automatic system updates</string>

Expand Down
5 changes: 5 additions & 0 deletions res/xml/development_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
android:title="@string/dnscrypt_proxy"
android:summary="@string/dnscrypt_proxy_desc" />

<SwitchPreference
android:key="dnscrypt_tor"
android:title="@string/dnscrypt_tor"
android:summary="@string/dnscrypt_tor_desc" />

<SwitchPreference
android:key="ota_disable_automatic_update"
android:title="@string/ota_disable_automatic_update" />
Expand Down
30 changes: 30 additions & 0 deletions src/com/android/settings/DevelopmentSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String TUNER_UI_KEY = "tuner_ui";
private static final String COLOR_TEMPERATURE_PROPERTY = "persist.sys.debug.color_temp";
private static final String DNSCRYPT_PROXY_PROPERTY = "persist.privacy.dnscrypt";
private static final String DNSCRYPT_TOR_PROPERTY = "persist.privacy.tor";

private static final String DEBUG_APP_KEY = "debug_app";
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
Expand Down Expand Up @@ -204,6 +205,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities";
private static final String COLOR_TEMPERATURE_KEY = "color_temperature";
private static final String DNSCRYPT_PROXY_KEY = "dnscrypt_proxy";
private static final String DNSCRYPT_TOR_KEY = "dnscrypt_tor";

private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY =
"bluetooth_disable_absolute_volume";
Expand Down Expand Up @@ -336,6 +338,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment

private SwitchPreference mDnscryptProxyPreference;

private SwitchPreference mDnscryptTorPreference;

private SwitchPreference mUpdateRecoveryPreference;

private ListPreference mRootAccess;
Expand Down Expand Up @@ -567,6 +571,15 @@ public void onCreate(Bundle icicle) {
mDnscryptProxyPreference = null;
}

mDnscryptTorPreference = (SwitchPreference) findPreference(DNSCRYPT_TOR_KEY);
if (getResources().getBoolean(R.bool.config_enableDnscryptTor)) {
mAllPrefs.add(mDnscryptTorPreference);
mResetSwitchPrefs.add(mDnscryptTorPreference);
} else {
removePreference(DNSCRYPT_TOR_KEY);
mDnscryptTorPreference = null;
}

mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY);
mRootAccess.setOnPreferenceChangeListener(this);

Expand Down Expand Up @@ -826,6 +839,9 @@ private void updateAllOptions() {
if (mDnscryptProxyPreference != null) {
updateDnscryptProxy();
}
if (mDnscryptTorPreference != null) {
updateDnscryptTor();
}
updateBluetoothDisableAbsVolumeOptions();
updateRootAccessOptions();
updateAdbOverNetwork();
Expand Down Expand Up @@ -1565,6 +1581,18 @@ private void writeDnscryptProxy() {
Toast.makeText(getActivity(), R.string.dnscrypt_proxy_toast, Toast.LENGTH_LONG).show();
}

private void updateDnscryptTor() {
updateSwitchPreference(mDnscryptTorPreference,
SystemProperties.getBoolean(DNSCRYPT_TOR_PROPERTY, false));
}

private void writeDnscryptTor() {
SystemProperties.set(DNSCRYPT_TOR_PROPERTY,
mDnscryptTorPreference.isChecked() ? "1" : "0");
pokeSystemProperties();
Toast.makeText(getActivity(), R.string.dnscrypt_tor_toast, Toast.LENGTH_LONG).show();
}

private void updateUSBAudioOptions() {
updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
Expand Down Expand Up @@ -2282,6 +2310,8 @@ public boolean onPreferenceTreeClick(Preference preference) {
writeColorTemperature();
} else if (preference == mDnscryptProxyPreference) {
writeDnscryptProxy();
} else if (preference == mDnscryptTorPreference) {
writeDnscryptTor();
} else if (preference == mUSBAudio) {
writeUSBAudioOptions();
} else if (preference == mForceResizable) {
Expand Down

0 comments on commit 5064ace

Please sign in to comment.