Modern Apps git

← Modern-Apps.git

web: guard algorithmic-darkening against WebView APKs that throw

Commit
2968049a881b93614e33d5c9da56283fba863b07
Author
Vayun Mathur <[email protected]>
When
2026-11-07 03:55 UTC (29 days ago)
Parents
3197a62
WebSettingsCompat.setAlgorithmicDarkeningAllowed can throw
UnsupportedOperationException on WebView APKs that report
ALGORITHMIC_DARKENING as supported but reject the call. Darkening is
cosmetic, so applyWebViewSettings now ignores that failure instead of
aborting WebView setup.

(cherry picked from commit c72730fc96f6529256bbe5f3ca4da42853e05d4f)

Diff

web/src/main/java/com/vayunmathur/web/ui/WebViewSettings.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/WebViewSettings.kt b/web/src/main/java/com/vayunmathur/web/ui/WebViewSettings.ktindex 07bda2a194..766077626d 100644--- a/web/src/main/java/com/vayunmathur/web/ui/WebViewSettings.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/WebViewSettings.kt@@ -17,7 +17,9 @@ import com.vayunmathur.web.platform.updateStorageFootprint  */ internal fun WebSettings.applySystemDarkMode() {     if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) {-        WebSettingsCompat.setAlgorithmicDarkeningAllowed(this, true)+        // Some WebView APKs report the feature but still throw when it is set;+        // darkening is cosmetic, so failing to enable it must not crash page setup.+        runCatching { WebSettingsCompat.setAlgorithmicDarkeningAllowed(this, true) }     } }