maos: pre-fill doh.maproj.org in the Private DNS hostname dialog
- Commit
1d5dffa11846a0f5798a338d48f3c7c256e74e58- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 14:19 UTC (18 days ago)
- Parents
ad48e25
When the user opens the Private DNS mode dialog and chooses the "Private DNS provider hostname" option, the hostname field now comes pre-filled with doh.maproj.org — our RFC 8484 DNS-over-HTTPS server (companion server commit adds GET/POST /dns-query on that hostname, proxied to an upstream resolver behind a TTL cache). Seam choice: the least invasive correct one. The patch touches only PrivateDnsModeDialogPreference.onBindDialogView in packages/apps/Settings: when ConnectivitySettingsManager.getPrivateDnsHostname returns empty (Settings.Global PRIVATE_DNS_SPECIFIER unset — it returns the raw Global string, null when never set), the EditText is seeded with doh.maproj.org instead of the empty string. Nothing is persisted by opening the dialog: doSaveButton only calls setPrivateDnsHostname when the provider mode is still selected at Save, and it validates the text as before. A hostname the user already set is never overwritten. The alternative seam — a SettingsProvider default for private_dns_specifier in frameworks/base — was rejected: it would change the global default for every device and every mode (including users who never open this dialog), a broader change than the ask, and it would live in frameworks/base rather than with the other Settings endpoint patches. Patch conventions: a new per-repo patch file patches/packages_apps_Settings_private_dns_prefill.patch, registered in apply_maos_patches in build-maos.sh right after packages_apps_Settings_widevine_servers.patch (its target file is untouched by settings.patch and the string patches, so ordering against them does not matter). The ~/maos tree copy stays pristine: the patch was produced with git diff, the file was reverted, and a full apply / apply --reverse cycle was run against the pristine file. Verification: git apply --check on the pristine PrivateDnsModeDialogPreference.java passes, git apply --reverse --check passes after applying, the patched file was reverse-applied and the tree restored (git status clean for that file), and bash -n build-maos.sh passes. The change uses only TextUtils.isEmpty plus a string literal; the existing hostname validation in doSaveButton (InternetDomainName.isValid) accepts doh.maproj.org. Not verified: an on-device open of Settings > Network & internet > Private DNS showing the pre-filled field — that needs a flashed MAOS build with this patch. Owner DNS note: this prefill is only useful once doh.maproj.org resolves and serves; that needs the Cloudflare-proxied A record from the server commit. Until then, choosing the pre-filled hostname yields a resolver that does not answer yet.
Diff
build-maos.sh
diff --git a/build-maos.sh b/build-maos.shindex 580d96b..59cd6e0 100755--- a/build-maos.sh+++ b/build-maos.sh@@ -285,6 +285,7 @@ apply_maos_patches() { "packages/apps/Settings:settings.patch" \ "packages/apps/Settings:packages_apps_Settings_ct_rkp_servers.patch" \ "packages/apps/Settings:packages_apps_Settings_widevine_servers.patch" \+ "packages/apps/Settings:packages_apps_Settings_private_dns_prefill.patch" \ "packages/apps/SetupWizard2:setupwizard2.patch" \ "external/roboto-fonts:roboto_fonts.patch" \ "packages/apps/GmsCompat:gmscompat.patch" \
patches/packages_apps_Settings_private_dns_prefill.patch
diff --git a/patches/packages_apps_Settings_private_dns_prefill.patch b/patches/packages_apps_Settings_private_dns_prefill.patchnew file mode 100644index 0000000..73176c0--- /dev/null+++ b/patches/packages_apps_Settings_private_dns_prefill.patch@@ -0,0 +1,30 @@+diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java+index b9836f1b86d..0b8a3ed2ede 100644+--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java++++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java+@@ -31,6 +31,7 @@ import android.net.ConnectivitySettingsManager;+ import android.os.UserHandle;+ import android.os.UserManager;+ import android.text.Editable;++import android.text.TextUtils;+ import android.text.TextWatcher;+ import android.text.method.LinkMovementMethod;+ import android.util.AttributeSet;+@@ -154,7 +155,16 @@ public class PrivateDnsModeDialogPreference extends CustomDialogPreferenceCompat+ mHostnameLayout = view.findViewById(R.id.private_dns_mode_provider_hostname_layout);+ mHostnameText = view.findViewById(R.id.private_dns_mode_provider_hostname);+ if (mHostnameText != null) {+- mHostnameText.setText(ConnectivitySettingsManager.getPrivateDnsHostname(context));++ final String currentHostname =++ ConnectivitySettingsManager.getPrivateDnsHostname(context);++ // MAOS: pre-fill our DoH resolver (doh.maproj.org, RFC 8484++ // DNS-over-HTTPS) so choosing "Private DNS provider hostname"++ // needs no typing. This is only a suggestion in the text++ // field: it is persisted solely when the user keeps that mode++ // and taps Save (see doSaveButton), and a hostname the user++ // already set is never overwritten.++ mHostnameText.setText(++ TextUtils.isEmpty(currentHostname) ? "doh.maproj.org" : currentHostname);+ mHostnameText.addTextChangedListener(this);+ }+