Merge "[SF] Don't crash if HWC returns an unknown config" into rvc-dev am: 9b89dd7a12 am: 200ccf7d15 am: cb30bb5f66 am: 94ea676e92
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/11789968
Change-Id: I42e0b5b09b720c8b96259b2890b74d979781d668
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index af76b81..8ac0561 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -208,13 +208,17 @@
*outVsyncPeriod = static_cast<nsecs_t>(vsyncPeriodNanos);
} else {
// Get the default vsync period
- HWConfigId configId = 0;
- auto intError_2_1 = mComposer.getActiveConfig(mId, &configId);
- error = static_cast<Error>(intError_2_1);
- if (error == Error::NONE) {
- auto config = mConfigs.at(configId);
- *outVsyncPeriod = config->getVsyncPeriod();
+ std::shared_ptr<const Display::Config> config;
+ error = getActiveConfig(&config);
+ if (error != Error::NONE) {
+ return error;
}
+ if (!config) {
+ // HWC has updated the display modes and hasn't notified us yet.
+ return Error::BAD_CONFIG;
+ }
+
+ *outVsyncPeriod = config->getVsyncPeriod();
}
return error;