Fix no output on second physical display
The RefreshRateConfigs only store the configs of default display
when init. But setAllowedDisplayConfigs would get NPE while getting
these configs from secondary display.
We need to cache the configs of external physical display when hotplug.
Bug: 127868178
Test: build and flash mojave device.
Change-Id: Ie1b598e8f77b28a444097deb0e05dda10d197db5
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 945f6fa..a5f025d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2519,6 +2519,9 @@
state.displayName = info->name;
mCurrentState.displays.add(mPhysicalDisplayTokens[info->id], state);
mInterceptor->saveDisplayCreation(state);
+ // TODO(b/123715322): Removes the per-display state that was added to the scheduler.
+ mRefreshRateConfigs[info->id] = std::make_shared<scheduler::RefreshRateConfigs>(
+ getHwComposer().getConfigs(info->id));
}
} else {
ALOGV("Removing display %s", to_string(info->id).c_str());
@@ -2530,6 +2533,7 @@
mCurrentState.displays.removeItemsAt(index);
}
mPhysicalDisplayTokens.erase(info->id);
+ mRefreshRateConfigs.erase(info->id);
}
processDisplayChangesLocked();