From 2ea3f16fe74d1ca4435ec2fadcdd2901364897c9 Mon Sep 17 00:00:00 2001 From: Florence Yang Date: Fri, 27 Jan 2023 18:26:55 +0000 Subject: [PATCH] Enable color threshold editing via SystemProperties Add SystemProperties for when Wallpaper Colors decides to suggest dark text (threshold) and how much noise (amount of dark pixels) to factor in for the wallpaper color decision. This will allow for editing of these properties via the commandline, so that we can find the best threshold for dark/light wallpapers. Bug: 202758428 Test: manual Change-Id: I6e2415e15b41040c5250c46b0f0dbe77e6224f36 --- core/java/android/app/WallpaperColors.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/WallpaperColors.java b/core/java/android/app/WallpaperColors.java index 067a4c3c047ea..a34a50c4b7b07 100644 --- a/core/java/android/app/WallpaperColors.java +++ b/core/java/android/app/WallpaperColors.java @@ -27,6 +27,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; +import android.os.SystemProperties; import android.util.Log; import android.util.MathUtils; import android.util.Size; @@ -101,11 +102,13 @@ public final class WallpaperColors implements Parcelable { // Decides when dark theme is optimal for this wallpaper private static final float DARK_THEME_MEAN_LUMINANCE = 0.3f; // Minimum mean luminosity that an image needs to have to support dark text - private static final float BRIGHT_IMAGE_MEAN_LUMINANCE = 0.7f; + private static final float BRIGHT_IMAGE_MEAN_LUMINANCE = SystemProperties.getInt( + "persist.wallpapercolors.threshold", 70) / 100f; // We also check if the image has dark pixels in it, // to avoid bright images with some dark spots. private static final float DARK_PIXEL_CONTRAST = 5.5f; - private static final float MAX_DARK_AREA = 0.05f; + private static final float MAX_DARK_AREA = SystemProperties.getInt( + "persist.wallpapercolors.max_dark_area", 5) / 100f; private final List mMainColors; private final Map mAllColors;