apps: pin WebView allowContentAccess=false for Android 18
- Commit
5210bffddd03ecb6e33339400d0f89382d5d1d6f- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-06 03:23 UTC (16 minutes ago)
- Parents
cd273c3
Android 18 (API 38) flips WebSettings.allowContentAccess from true to false for apps targeting 38. An audit of every WebView creation site in the repo found none that loads content:// into the page: web and its PWA window already pinned false, and the remaining sites load https pages (Uber auth, merchant checkout, Google Voice, Signal captcha) or inline HTML (code preview, office print, SABR attestation, HtmlText, the browser popup window). Pin the safer value explicitly at those ten sites so the target-38 bump is a no-op for them and the intent is visible at each call site, instead of silently changing behaviour when targetSdk moves. Verified: lint, lintVitalRelease and testDevUnitTest green for library:ui, web, taxi, shop, code, office, communicate and youpipe. The one communicate test failure seen in the combined run (Y1RegistrationScreensTest, Room database-closed) passes in isolation and is unrelated to this change.
Diff
code/src/main/java/com/vayunmathur/code/ui/PreviewPage.kt
diff --git a/code/src/main/java/com/vayunmathur/code/ui/PreviewPage.kt b/code/src/main/java/com/vayunmathur/code/ui/PreviewPage.ktindex f32feca83c..d435e53886 100644--- a/code/src/main/java/com/vayunmathur/code/ui/PreviewPage.kt+++ b/code/src/main/java/com/vayunmathur/code/ui/PreviewPage.kt@@ -61,6 +61,8 @@ private fun PreviewWebView(html: String, modifier: Modifier = Modifier) { WebView(ctx).apply { settings.javaScriptEnabled = true settings.domStorageEnabled = true+ // Android 18 (target 38) flips the default to false; preview renders inline HTML via loadDataWithBaseURL, never content://.+ settings.allowContentAccess = false settings.builtInZoomControls = true settings.displayZoomControls = false settings.useWideViewPort = true
communicate/src/dev/java/com/vayunmathur/communicate/ui/signal/SignalCaptchaScreen.kt
diff --git a/communicate/src/dev/java/com/vayunmathur/communicate/ui/signal/SignalCaptchaScreen.kt b/communicate/src/dev/java/com/vayunmathur/communicate/ui/signal/SignalCaptchaScreen.ktindex ea8d26ed64..3012494f3e 100644--- a/communicate/src/dev/java/com/vayunmathur/communicate/ui/signal/SignalCaptchaScreen.kt+++ b/communicate/src/dev/java/com/vayunmathur/communicate/ui/signal/SignalCaptchaScreen.kt@@ -38,6 +38,8 @@ fun SignalCaptchaWebView( ViewGroup.LayoutParams.MATCH_PARENT, ) settings.javaScriptEnabled = true+ // Android 18 (target 38) flips the default to false; captcha only loads https:// pages.+ settings.allowContentAccess = false clearCache(true) webViewClient = object : WebViewClient() { override fun onRenderProcessGone(
communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceWebSender.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceWebSender.kt b/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceWebSender.ktindex 3d1fd67da2..79d753deab 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceWebSender.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/data/googlevoice/GoogleVoiceWebSender.kt@@ -133,6 +133,8 @@ object GoogleVoiceWebSender { CookieManager.getInstance().setAcceptThirdPartyCookies(wv, true) wv.settings.javaScriptEnabled = true wv.settings.domStorageEnabled = true+ // Android 18 (target 38) flips the default to false; the mint WebView only loads https://voice.google.com.+ wv.settings.allowContentAccess = false wv.settings.userAgentString = "Mozilla/5.0 (Linux; Android 14) AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/126.0.0.0 Mobile Safari/537.36"
communicate/src/main/java/com/vayunmathur/communicate/ui/googlevoice/GoogleVoiceSignInScreen.kt
diff --git a/communicate/src/main/java/com/vayunmathur/communicate/ui/googlevoice/GoogleVoiceSignInScreen.kt b/communicate/src/main/java/com/vayunmathur/communicate/ui/googlevoice/GoogleVoiceSignInScreen.ktindex 5459388b48..a0020ec4fb 100644--- a/communicate/src/main/java/com/vayunmathur/communicate/ui/googlevoice/GoogleVoiceSignInScreen.kt+++ b/communicate/src/main/java/com/vayunmathur/communicate/ui/googlevoice/GoogleVoiceSignInScreen.kt@@ -72,6 +72,8 @@ fun GoogleVoiceSignInScreen(onBack: () -> Unit, onSignedIn: () -> Unit) { CookieManager.getInstance().setAcceptThirdPartyCookies(this, true) settings.javaScriptEnabled = true settings.domStorageEnabled = true+ // Android 18 (target 38) flips the default to false; sign-in only loads https://voice.google.com.+ settings.allowContentAccess = false settings.databaseEnabled = true // Voice serves its mobile web app to a Chrome UA; match the RPC UA. settings.userAgentString =
library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.ktindex d91449e494..8e48207e5a 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/HtmlText.kt@@ -100,6 +100,8 @@ fun HtmlText( applyHtmlTextLayout(scrollInternally) settings.loadWithOverviewMode = false settings.displayZoomControls = false+ // Android 18 (target 38) flips the default to false; HtmlText renders generated HTML only, never content://.+ settings.allowContentAccess = false setBackgroundColor(backgroundColor.toArgb()) webViewClient = webClient }
office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentUtils.kt
diff --git a/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentUtils.kt b/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentUtils.ktindex 1b9f306fe8..72e3869405 100644--- a/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentUtils.kt+++ b/office/src/main/java/com/vayunmathur/office/ui/OfficeDocumentUtils.kt@@ -167,6 +167,8 @@ internal fun printDocument(activity: ComponentActivity, document: OdfDocument) { val printManager = activity.getSystemService(android.content.Context.PRINT_SERVICE) as? PrintManager ?: return val html = documentToHtml(document) val webView = WebView(activity)+ // Android 18 (target 38) flips the default to false; the print WebView renders inline HTML only, never content://.+ webView.settings.allowContentAccess = false webView.webViewClient = object : WebViewClient() { override fun onPageFinished(view: WebView?, url: String?) { @Suppress("DEPRECATION")
shop/src/main/java/com/vayunmathur/shop/ui/EmbeddedCheckoutScreen.kt
diff --git a/shop/src/main/java/com/vayunmathur/shop/ui/EmbeddedCheckoutScreen.kt b/shop/src/main/java/com/vayunmathur/shop/ui/EmbeddedCheckoutScreen.ktindex 77f3e34104..6fde50e97f 100644--- a/shop/src/main/java/com/vayunmathur/shop/ui/EmbeddedCheckoutScreen.kt+++ b/shop/src/main/java/com/vayunmathur/shop/ui/EmbeddedCheckoutScreen.kt@@ -155,6 +155,8 @@ private fun CheckoutWebView( WebView(context).apply { settings.javaScriptEnabled = true settings.domStorageEnabled = true+ // Android 18 (target 38) flips the default to false; checkout only loads the merchant https:// continue_url.+ settings.allowContentAccess = false CookieManager.getInstance().setAcceptThirdPartyCookies(this, true) if (WebViewFeature.isFeatureSupported(WebViewFeature.PAYMENT_REQUEST)) { WebSettingsCompat.setPaymentRequestEnabled(settings, true)
taxi/src/main/java/com/vayunmathur/taxi/network/uber/UberWebView.kt
diff --git a/taxi/src/main/java/com/vayunmathur/taxi/network/uber/UberWebView.kt b/taxi/src/main/java/com/vayunmathur/taxi/network/uber/UberWebView.ktindex 8a4449cb0d..769185d236 100644--- a/taxi/src/main/java/com/vayunmathur/taxi/network/uber/UberWebView.kt+++ b/taxi/src/main/java/com/vayunmathur/taxi/network/uber/UberWebView.kt@@ -47,6 +47,8 @@ fun UberWebView( CookieManager.getInstance().setAcceptThirdPartyCookies(this, true) settings.javaScriptEnabled = true settings.domStorageEnabled = true+ // Android 18 (target 38) flips the default to false; this WebView only loads https:// Uber pages, never content://.+ settings.allowContentAccess = false addJavascriptInterface( object { @JavascriptInterface
web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt b/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.ktindex c34cbd8590..874cf00ada 100644--- a/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/WebViewClients.kt@@ -286,6 +286,8 @@ internal fun createBrowserWebChromeClient( val newWebView = WebView(view.context).apply { settings.javaScriptEnabled = viewModel.jsEnabled settings.domStorageEnabled = true+ // Android 18 (target 38) flips the default to false; popup windows must match the main WebView (WebViewSettings).+ settings.allowContentAccess = false settings.applySystemDarkMode() } newWebView.webViewClient = object : WebViewClient() {
youpipe/src/main/java/com/vayunmathur/youpipe/network/sabr/SharedWebViewRuntime.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/network/sabr/SharedWebViewRuntime.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/network/sabr/SharedWebViewRuntime.ktindex b486e4f8a1..19442744b2 100644--- a/youpipe/src/main/java/com/vayunmathur/youpipe/network/sabr/SharedWebViewRuntime.kt+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/network/sabr/SharedWebViewRuntime.kt@@ -291,6 +291,8 @@ class SharedWebViewRuntime private constructor(context: Context) { val settings = view.settings settings.javaScriptEnabled = true settings.domStorageEnabled = false+ // Android 18 (target 38) flips the default to false; attestation renders inline HTML only, never content://.+ settings.allowContentAccess = false settings.userAgentString = USER_AGENT settings.blockNetworkLoads = true if (WebViewFeature.isFeatureSupported(WebViewFeature.SAFE_BROWSING_ENABLE)) {