SF: Sequential display mode IDs
If the supported display modes differ after a hotplug
assing the new modes new IDs. This way the old IDs will
self invalidate.
This breaks the assumption that the modes IDs are
equivalent to indices in the array of supported modes.
Bug: 159590486
Test: manually 0. device boots in 60hz mode
1. switch to 50hz from app
2. disconnect display
3. reconnect display
dumpsys SurfaceFlinger after each step to
verify mode IDs change as expected
Change-Id: I44c90e8151f31e998b43649dad73c51d6948195d
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
index de11c16..91e8043 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
@@ -610,15 +610,16 @@
void RefreshRateConfigs::updateDisplayModes(const DisplayModes& modes,
DisplayModeId currentModeId) {
std::lock_guard lock(mLock);
- LOG_ALWAYS_FATAL_IF(modes.empty());
- LOG_ALWAYS_FATAL_IF(currentModeId.value() >= modes.size());
+ // The current mode should be supported
+ LOG_ALWAYS_FATAL_IF(std::none_of(modes.begin(), modes.end(), [&](DisplayModePtr mode) {
+ return mode->getId() == currentModeId;
+ }));
mRefreshRates.clear();
for (const auto& mode : modes) {
const auto modeId = mode->getId();
- const auto fps = Fps::fromPeriodNsecs(mode->getVsyncPeriod());
mRefreshRates.emplace(modeId,
- std::make_unique<RefreshRate>(modeId, mode, fps,
+ std::make_unique<RefreshRate>(modeId, mode, mode->getFps(),
RefreshRate::ConstructorTag(0)));
if (modeId == currentModeId) {
mCurrentRefreshRate = mRefreshRates.at(modeId).get();