diff options
author | 2023-11-03 12:14:26 -0700 | |
---|---|---|
committer | 2023-11-03 19:17:35 +0000 | |
commit | b6041f6af5ae8bb24514d1c4ad0ec459d1a7ae7e (patch) | |
tree | 4d5c12febbe36790d0923a563034f441ee9618d3 | |
parent | 2891b69e4423e85e613b03db87237a4f0e85aa83 (diff) |
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
-rw-r--r-- | services/surfaceflinger/FlagManager.cpp | 52 | ||||
-rw-r--r-- | services/surfaceflinger/FlagManager.h | 11 |
2 files changed, 41 insertions, 22 deletions
diff --git a/services/surfaceflinger/FlagManager.cpp b/services/surfaceflinger/FlagManager.cpp index 1f8a3f5ca6..6d0dbc7978 100644 --- a/services/surfaceflinger/FlagManager.cpp +++ b/services/surfaceflinger/FlagManager.cpp @@ -60,10 +60,6 @@ bool getFlagValue(std::function<bool()> getter, std::optional<bool> overrideValu 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 @@ void FlagManager::setUnitTestMode() { 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 10784a7c0a..cefce9bcda 100644 --- a/services/surfaceflinger/FlagManager.h +++ b/services/surfaceflinger/FlagManager.h @@ -46,6 +46,10 @@ public: 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 @@ public: 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 @@ private: 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; |