Eliminate the usage of ConfigStore in native/libs/gui.
Ideally modules above SurfaceFlinger should query ConfigStore through
ISurfaceComposer APIs. Previously Surface::getWideColorSupport directly
evaluate wide color support for built-in display, we don't want that, we should
align it with SurfaceFlinger.
This patch essentially creates an API to allow other modules to query whether a
given display is a wide color display. As a result, we must enforce that wide
color display board config together with the wide color modes returned from
hardware composer.
BUG: 123312783
Test: Build, flash and boot. Verify in logcat.
Test: SurfaceFlinger_test --gtest_filter=CredentialsTest.IsWideColorDisplay\*
Change-Id: I0a5e3cc404e5365343adb0c9efaee8c13cc49cfe
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index 8560f5e..48b2b80 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -19,6 +19,7 @@
namespace android {
using Transaction = SurfaceComposerClient::Transaction;
+using ui::ColorMode;
namespace {
const String8 DISPLAY_NAME("Credentials Display Test");
@@ -312,4 +313,36 @@
seteuid(AID_BIN);
ASSERT_EQ(PERMISSION_DENIED, sf->getLayerDebugInfo(&outLayers));
}
+
+TEST_F(CredentialsTest, IsWideColorDisplayBasicCorrectness) {
+ sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
+ bool result = false;
+ status_t error = SurfaceComposerClient::isWideColorDisplay(display, &result);
+ ASSERT_EQ(NO_ERROR, error);
+ bool hasWideColorMode = false;
+ Vector<ColorMode> colorModes;
+ SurfaceComposerClient::getDisplayColorModes(display, &colorModes);
+ for (ColorMode colorMode : colorModes) {
+ switch (colorMode) {
+ case ColorMode::DISPLAY_P3:
+ case ColorMode::ADOBE_RGB:
+ case ColorMode::DCI_P3:
+ hasWideColorMode = true;
+ break;
+ default:
+ break;
+ }
+ }
+ ASSERT_EQ(hasWideColorMode, result);
+}
+
+TEST_F(CredentialsTest, IsWideColorDisplayWithPrivileges) {
+ sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
+ std::function<status_t()> condition = [=]() {
+ bool result = false;
+ return SurfaceComposerClient::isWideColorDisplay(display, &result);
+ };
+ ASSERT_NO_FATAL_FAILURE(checkWithPrivileges<status_t>(condition, NO_ERROR, NO_ERROR));
+}
+
} // namespace android