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
This commit is contained in:
Florence Yang
2023-01-27 18:26:55 +00:00
parent 4e02695e3e
commit 2ea3f16fe7

View File

@@ -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<Color> mMainColors;
private final Map<Integer, Integer> mAllColors;