SF: Remove per-display state in scheduler
This CL removes per-display RefreshRateConfigs and AllowedDisplayConfigs
to avoid bugs in the untested multi-display code path of the scheduler,
adds checks to prevent crashes if the internal display is removed, and
cleans up related code by:
1) Replacing AllowedDisplayConfigs with a simple set.
2) Making setAllowedDisplayConfigs consistent with setPowerMode.
3) Removing unnecessary locking and allocation.
Bug: 129433906
Test: Boot with single/multiple display(s)
Change-Id: I3f59e9bdeaceb2cf48b4b9b71cd27f1d6a574680
(cherry picked from commit 645365116b7c77204aaffbb88f9407549445396c)
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
index 1aa6ade..5874066 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
@@ -51,13 +51,7 @@
// TODO(b/122916473): Get this information from configs prepared by vendors, instead of
// baking them in.
- explicit RefreshRateConfigs(
- const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) {
- init(configs);
- }
- ~RefreshRateConfigs() = default;
-
- const std::map<RefreshRateType, std::shared_ptr<RefreshRate>>& getRefreshRates() {
+ const std::map<RefreshRateType, std::shared_ptr<RefreshRate>>& getRefreshRates() const {
return mRefreshRates;
}
std::shared_ptr<RefreshRate> getRefreshRate(RefreshRateType type) {
@@ -68,8 +62,9 @@
return nullptr;
}
-private:
- void init(const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) {
+ void populate(const std::vector<std::shared_ptr<const HWC2::Display::Config>>& configs) {
+ mRefreshRates.clear();
+
// This is the rate that HWC encapsulates right now when the device is in DOZE mode.
mRefreshRates.emplace(RefreshRateType::POWER_SAVING,
std::make_shared<RefreshRate>(
@@ -120,6 +115,7 @@
}
}
+private:
std::map<RefreshRateType, std::shared_ptr<RefreshRate>> mRefreshRates;
};