diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java index 280e7dfeac9a6..40b38c0d0c6a2 100644 --- a/core/java/android/webkit/WebSettings.java +++ b/core/java/android/webkit/WebSettings.java @@ -1554,7 +1554,7 @@ public abstract class WebSettings { * @see #getForceDark * @deprecated The "force dark" model previously implemented by WebView was complex * and didn't interoperate well with current Web standards for - * prefers-color-scheme and color-scheme. In apps with + * {@code prefers-color-scheme} and {@code color-scheme}. In apps with * {@code targetSdkVersion} ≥ {@link android.os.Build.VERSION_CODES#TIRAMISU} * this API is a no-op and WebView will always use the dark style defined by web content * authors if the app's theme is dark. To customize the behavior, refer to @@ -1602,6 +1602,61 @@ public abstract class WebSettings { * If Android is applying Force Dark to WebView then WebView will ignore the value of * this setting and behave as if it were set to true. * + *

+ * The deprecated {@link #setForceDark} and related API are no-ops in apps with + * {@code targetSdkVersion} ≥ {@link android.os.Build.VERSION_CODES#TIRAMISU}, + * but they still apply to apps with + * {@code targetSdkVersion} < {@link android.os.Build.VERSION_CODES#TIRAMISU}. + * + *

+ * The below table summarizes how APIs work with different apps. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AppWeb content which uses {@code prefers-color-scheme}Web content which does not use {@code prefers-color-scheme}
App with {@code isLightTheme} True or not setRenders with the light theme defined by the content author.Renders with the default styling defined by the content author.
App with Android forceDark in effectRenders with the dark theme defined by the content author.Renders with the styling modified to dark colors by an algorithm + * if allowed by the content author.
App with {@code isLightTheme} False, + * {@code targetSdkVersion} < {@link android.os.Build.VERSION_CODES#TIRAMISU}, + * and has {@code FORCE_DARK_AUTO}Renders with the dark theme defined by the content author.Renders with the default styling defined by the content author.
App with {@code isLightTheme} False, + * {@code targetSdkVersion} ≥ {@link android.os.Build.VERSION_CODES#TIRAMISU}, + * and {@code setAlgorithmicDarkening(false)}Renders with the dark theme defined by the content author.Renders with the default styling defined by the content author.
App with {@code isLightTheme} False, + * {@code targetSdkVersion} ≥ {@link android.os.Build.VERSION_CODES#TIRAMISU}, + * and {@code setAlgorithmicDarkening(true)}Renders with the dark theme defined by the content author.Renders with the styling modified to dark colors by an algorithm if allowed + * by the content author.
+ *

+ * * @param allow allow algorithmic darkening or not. */ public void setAlgorithmicDarkeningAllowed(boolean allow) {