SF: fix a crash in FlagManager
When dumping the flag, don't dump the server flags if boot
is still in progress.
Test: adb shell dumpsys SurfaceFlinger while booting
Bug: 309017367
Change-Id: I44d12351c55366ff8dae6decb15beebd87db99e1
diff --git a/services/surfaceflinger/FlagManager.cpp b/services/surfaceflinger/FlagManager.cpp
index 1f8a3f5..6d0dbc7 100644
--- a/services/surfaceflinger/FlagManager.cpp
+++ b/services/surfaceflinger/FlagManager.cpp
@@ -60,10 +60,6 @@
return getter();
}
-void dumpFlag(std::string& result, const char* name, std::function<bool()> getter) {
- base::StringAppendF(&result, "%s: %s\n", name, getter() ? "true" : "false");
-}
-
} // namespace
const FlagManager& FlagManager::getInstance() {
@@ -90,23 +86,43 @@
mBootCompleted = true;
}
+void FlagManager::dumpFlag(std::string& result, bool readonly, const char* name,
+ std::function<bool()> getter) const {
+ if (readonly || mBootCompleted) {
+ base::StringAppendF(&result, "%s: %s\n", name, getter() ? "true" : "false");
+ } else {
+ base::StringAppendF(&result, "%s: in progress (still booting)\n", name);
+ }
+}
+
void FlagManager::dump(std::string& result) const {
-#define DUMP_FLAG(name) dumpFlag(result, #name, std::bind(&FlagManager::name, this))
+#define DUMP_FLAG_INTERVAL(name, readonly) \
+ dumpFlag(result, (readonly), #name, std::bind(&FlagManager::name, this))
+#define DUMP_SERVER_FLAG(name) DUMP_FLAG_INTERVAL(name, false)
+#define DUMP_READ_ONLY_FLAG(name) DUMP_FLAG_INTERVAL(name, true)
base::StringAppendF(&result, "FlagManager values: \n");
- DUMP_FLAG(use_adpf_cpu_hint);
- DUMP_FLAG(use_skia_tracing);
- DUMP_FLAG(connected_display);
- DUMP_FLAG(dont_skip_on_early);
- DUMP_FLAG(enable_small_area_detection);
- DUMP_FLAG(misc1);
- DUMP_FLAG(late_boot_misc2);
- DUMP_FLAG(vrr_config);
- DUMP_FLAG(hotplug2);
- DUMP_FLAG(hdcp_level_hal);
- DUMP_FLAG(multithreaded_present);
-#undef DUMP_FLAG
+ /// Legacy server flags ///
+ DUMP_SERVER_FLAG(use_adpf_cpu_hint);
+ DUMP_SERVER_FLAG(use_skia_tracing);
+
+ /// Trunk stable server flags ///
+ DUMP_SERVER_FLAG(late_boot_misc2);
+ DUMP_SERVER_FLAG(dont_skip_on_early);
+
+ /// Trunk stable readonly flags ///
+ DUMP_READ_ONLY_FLAG(connected_display);
+ DUMP_READ_ONLY_FLAG(enable_small_area_detection);
+ DUMP_READ_ONLY_FLAG(misc1);
+ DUMP_READ_ONLY_FLAG(vrr_config);
+ DUMP_READ_ONLY_FLAG(hotplug2);
+ DUMP_READ_ONLY_FLAG(hdcp_level_hal);
+ DUMP_READ_ONLY_FLAG(multithreaded_present);
+
+#undef DUMP_READ_ONLY_FLAG
+#undef DUMP_SERVER_FLAG
+#undef DUMP_FLAG_INTERVAL
}
std::optional<bool> FlagManager::getBoolProperty(const char* property) const {
diff --git a/services/surfaceflinger/FlagManager.h b/services/surfaceflinger/FlagManager.h
index 10784a7..cefce9b 100644
--- a/services/surfaceflinger/FlagManager.h
+++ b/services/surfaceflinger/FlagManager.h
@@ -46,6 +46,10 @@
bool use_adpf_cpu_hint() const;
bool use_skia_tracing() const;
+ /// Trunk stable server flags ///
+ bool late_boot_misc2() const;
+ bool dont_skip_on_early() const;
+
/// Trunk stable readonly flags ///
bool connected_display() const;
bool enable_small_area_detection() const;
@@ -55,10 +59,6 @@
bool hdcp_level_hal() const;
bool multithreaded_present() const;
- /// Trunk stable server flags ///
- bool late_boot_misc2() const;
- bool dont_skip_on_early() const;
-
protected:
// overridden for unit tests
virtual std::optional<bool> getBoolProperty(const char*) const;
@@ -69,6 +69,9 @@
FlagManager(const FlagManager&) = delete;
+ void dumpFlag(std::string& result, bool readonly, const char* name,
+ std::function<bool()> getter) const;
+
std::atomic_bool mBootCompleted = false;
std::atomic_bool mUnitTestMode = false;