SurfaceFlinger: fix sysprop API condition for color management
Device color management can be set via a dedicated property, or inferred
from two other properties. Currently all 3 properties need to be
specified to *some* value in order for color management to be set as
intended. This fix changes this logic so that if one of the properties
is not specified, the default value for color management is used.
Fixes: 126907354
Test: manual by omitting some of the relevant props from device
makefiles; and atest libsurfaceflinger_unittest
Change-Id: Ic3f76a3e50914906cfd53ec8242dedc2d1585186
diff --git a/services/surfaceflinger/SurfaceFlingerProperties.cpp b/services/surfaceflinger/SurfaceFlingerProperties.cpp
index f2881f5..cb9a6c0 100644
--- a/services/surfaceflinger/SurfaceFlingerProperties.cpp
+++ b/services/surfaceflinger/SurfaceFlingerProperties.cpp
@@ -166,11 +166,15 @@
auto tmpuseColorManagement = SurfaceFlingerProperties::use_color_management();
auto tmpHasHDRDisplay = SurfaceFlingerProperties::has_HDR_display();
auto tmpHasWideColorDisplay = SurfaceFlingerProperties::has_wide_color_display();
- if (tmpuseColorManagement.has_value() && tmpHasHDRDisplay.has_value() &&
- tmpHasWideColorDisplay.has_value()) {
- return *tmpuseColorManagement || *tmpHasHDRDisplay || *tmpHasWideColorDisplay;
- }
- return defaultValue;
+
+ auto tmpuseColorManagementVal = tmpuseColorManagement.has_value() ? *tmpuseColorManagement :
+ defaultValue;
+ auto tmpHasHDRDisplayVal = tmpHasHDRDisplay.has_value() ? *tmpHasHDRDisplay :
+ defaultValue;
+ auto tmpHasWideColorDisplayVal = tmpHasWideColorDisplay.has_value() ? *tmpHasWideColorDisplay :
+ defaultValue;
+
+ return tmpuseColorManagementVal || tmpHasHDRDisplayVal || tmpHasWideColorDisplayVal;
}
int64_t default_composition_dataspace(Dataspace defaultValue) {