SF FlagManager: ignore debug override during tests
Tests use SET_FLAG_FOR_TEST, which specifies the value of the flag that
the test is expecting. But if the debug override is set, the test will
test under the wrong conditions.
In addition, there is no need to modify the static value in unit test
mode. Simply return the value returned by the flag system.
Bug: 241285491
Test: libsurfaceflinger_unittest:FlagManagerTest
Test: libcompositionengine_test after
Ie2836e07e900c0269d60112ec0ebfa82ee4b82d7 with different values
set for debug.sf.multithreaded_present
Change-Id: Ide557e06ed7511b47033c2cb7016ad81bac40dad
diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp
index adb4974..b3041a1 100644
--- a/services/surfaceflinger/common/FlagManager.cpp
+++ b/services/surfaceflinger/common/FlagManager.cpp
@@ -160,15 +160,13 @@
"Can't read %s before boot completed as it is server writable", \
__func__); \
} \
- static std::optional<bool> debugOverride = getBoolProperty(syspropOverride); \
- static bool value = getFlagValue([] { return flags::name(); }, debugOverride); \
+ static const std::optional<bool> debugOverride = getBoolProperty(syspropOverride); \
+ static const bool value = getFlagValue([] { return flags::name(); }, debugOverride); \
if (mUnitTestMode) { \
/* \
- * When testing, we don't want to rely on the cached values stored in the static \
- * variables. \
+ * When testing, we don't want to rely on the cached `value` or the debugOverride. \
*/ \
- debugOverride = getBoolProperty(syspropOverride); \
- value = getFlagValue([] { return flags::name(); }, debugOverride); \
+ return flags::name(); \
} \
return value; \
}