Merge "Validate vendor display color modes" into qt-dev
am: 1da3d01b5e
Change-Id: Iad3419fbbb43177bb137c17c45b34f494d34ff8b
This commit is contained in:
@@ -162,6 +162,20 @@ public final class ColorDisplayManager {
|
||||
*/
|
||||
public static final int COLOR_MODE_AUTOMATIC = 3;
|
||||
|
||||
/**
|
||||
* Display color mode range reserved for vendor customizations by the RenderIntent definition in
|
||||
* hardware/interfaces/graphics/common/1.1/types.hal. These are NOT directly related to (but ARE
|
||||
* mutually exclusive with) the {@link ColorMode} constants, but ARE directly related (and ARE
|
||||
* mutually exclusive with) the DISPLAY_COLOR_* constants in DisplayTransformManager.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int VENDOR_COLOR_MODE_RANGE_MIN = 256; // 0x100
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static final int VENDOR_COLOR_MODE_RANGE_MAX = 511; // 0x1ff
|
||||
|
||||
private final ColorDisplayManagerInternal mManager;
|
||||
private MetricsLogger mMetricsLogger;
|
||||
|
||||
|
||||
@@ -3455,10 +3455,25 @@ public final class Settings {
|
||||
*/
|
||||
public static final String DISPLAY_COLOR_MODE = "display_color_mode";
|
||||
|
||||
private static final Validator DISPLAY_COLOR_MODE_VALIDATOR =
|
||||
new SettingsValidators.InclusiveIntegerRangeValidator(
|
||||
ColorDisplayManager.COLOR_MODE_NATURAL,
|
||||
ColorDisplayManager.COLOR_MODE_AUTOMATIC);
|
||||
private static final Validator DISPLAY_COLOR_MODE_VALIDATOR = new Validator() {
|
||||
@Override
|
||||
public boolean validate(@Nullable String value) {
|
||||
// Assume the actual validation that this device can properly handle this kind of
|
||||
// color mode further down in ColorDisplayManager / ColorDisplayService.
|
||||
try {
|
||||
final int setting = Integer.parseInt(value);
|
||||
final boolean isInFrameworkRange =
|
||||
setting >= ColorDisplayManager.COLOR_MODE_NATURAL
|
||||
&& setting <= ColorDisplayManager.COLOR_MODE_AUTOMATIC;
|
||||
final boolean isInVendorRange =
|
||||
setting >= ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MIN
|
||||
&& setting <= ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MAX;
|
||||
return isInFrameworkRange || isInVendorRange;
|
||||
} catch (NumberFormatException | NullPointerException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The user selected peak refresh rate in frames per second.
|
||||
|
||||
@@ -89,12 +89,6 @@ public class DisplayTransformManager {
|
||||
private static final int DISPLAY_COLOR_MANAGED = 0;
|
||||
private static final int DISPLAY_COLOR_UNMANAGED = 1;
|
||||
private static final int DISPLAY_COLOR_ENHANCED = 2;
|
||||
/**
|
||||
* Display color mode range reserved for vendor customizations by the RenderIntent definition in
|
||||
* hardware/interfaces/graphics/common/1.1/types.hal.
|
||||
*/
|
||||
private static final int VENDOR_MODE_RANGE_MIN = 256; // 0x100
|
||||
private static final int VENDOR_MODE_RANGE_MAX = 511; // 0x1ff
|
||||
|
||||
/**
|
||||
* Map of level -> color transformation matrix.
|
||||
@@ -270,7 +264,8 @@ public class DisplayTransformManager {
|
||||
} else if (colorMode == ColorDisplayManager.COLOR_MODE_AUTOMATIC) {
|
||||
applySaturation(COLOR_SATURATION_NATURAL);
|
||||
setDisplayColor(DISPLAY_COLOR_ENHANCED);
|
||||
} else if (colorMode >= VENDOR_MODE_RANGE_MIN && colorMode <= VENDOR_MODE_RANGE_MAX) {
|
||||
} else if (colorMode >= ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MIN
|
||||
&& colorMode <= ColorDisplayManager.VENDOR_COLOR_MODE_RANGE_MAX) {
|
||||
applySaturation(COLOR_SATURATION_NATURAL);
|
||||
setDisplayColor(colorMode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user