Switch from allowed display configs to refresh rate range
This completes the recent work to switch from a list of allowed display
configs to a default config + min/max frame rate.
Bug: 142507213
Test: Ran on a device with refresh rate switching, confirmed expected
60/90 switching behavior when touching the screen.
Test: Launched Google Maps on a device with 60/90 switching, confirmed
the device stays at 60fps.
Test: Checked dumpsys output, confirmed new display config specs
formatting looks good.
Test: Ran on a device with refresh rate switching disallowed via the
ro.surface_flinger.refresh_rate_switching sysprop, and confirmed
we don't do refresh rate switching.
Test: Ran on a device that doesn't support refresh rate switching, and
confirmed normal behavior.
Test: Tested surface flinger's display config back door, confirmed it
still works.
Test: Inspected log output, made sure there's nothing weird.
Test: Ran unit tests for DisplayModeDirector, LocalDisplayAdapter, and
RefreshRateConfigs.
Test: atest FrameworksServicesTests
Test: atest FrameworksMockingServicesTests
Test: adb shell /data/nativetest64/libgui_test/libgui_test
Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest
Change-Id: I53743a437bce1e3df79539caece0c423051c80a6
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index 546757b..3ce7a4a 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -852,61 +852,8 @@
return error;
}
- virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- const std::vector<int32_t>& allowedConfigs) {
- Parcel data, reply;
- status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
- if (result != NO_ERROR) {
- ALOGE("setAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
- return result;
- }
- result = data.writeStrongBinder(displayToken);
- if (result != NO_ERROR) {
- ALOGE("setAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
- return result;
- }
- result = data.writeInt32Vector(allowedConfigs);
- if (result != NO_ERROR) {
- ALOGE("setAllowedDisplayConfigs failed to writeInt32Vector: %d", result);
- return result;
- }
- result = remote()->transact(BnSurfaceComposer::SET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("setAllowedDisplayConfigs failed to transact: %d", result);
- return result;
- }
- return reply.readInt32();
- }
-
- virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- std::vector<int32_t>* outAllowedConfigs) {
- if (!outAllowedConfigs) return BAD_VALUE;
- Parcel data, reply;
- status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
- if (result != NO_ERROR) {
- ALOGE("getAllowedDisplayConfigs failed to writeInterfaceToken: %d", result);
- return result;
- }
- result = data.writeStrongBinder(displayToken);
- if (result != NO_ERROR) {
- ALOGE("getAllowedDisplayConfigs failed to writeStrongBinder: %d", result);
- return result;
- }
- result = remote()->transact(BnSurfaceComposer::GET_ALLOWED_DISPLAY_CONFIGS, data, &reply);
- if (result != NO_ERROR) {
- ALOGE("getAllowedDisplayConfigs failed to transact: %d", result);
- return result;
- }
- result = reply.readInt32Vector(outAllowedConfigs);
- if (result != NO_ERROR) {
- ALOGE("getAllowedDisplayConfigs failed to readInt32Vector: %d", result);
- return result;
- }
- return reply.readInt32();
- }
-
virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t defaultModeId, float minRefreshRate,
+ int32_t defaultConfig, float minRefreshRate,
float maxRefreshRate) {
Parcel data, reply;
status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
@@ -919,9 +866,9 @@
ALOGE("setDesiredDisplayConfigSpecs: failed to write display token: %d", result);
return result;
}
- result = data.writeInt32(defaultModeId);
+ result = data.writeInt32(defaultConfig);
if (result != NO_ERROR) {
- ALOGE("setDesiredDisplayConfigSpecs failed to write defaultModeId: %d", result);
+ ALOGE("setDesiredDisplayConfigSpecs failed to write defaultConfig: %d", result);
return result;
}
result = data.writeFloat(minRefreshRate);
@@ -945,10 +892,10 @@
}
virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t* outDefaultModeId,
+ int32_t* outDefaultConfig,
float* outMinRefreshRate,
float* outMaxRefreshRate) {
- if (!outDefaultModeId || !outMinRefreshRate || !outMaxRefreshRate) return BAD_VALUE;
+ if (!outDefaultConfig || !outMinRefreshRate || !outMaxRefreshRate) return BAD_VALUE;
Parcel data, reply;
status_t result = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
if (result != NO_ERROR) {
@@ -966,9 +913,9 @@
ALOGE("getDesiredDisplayConfigSpecs failed to transact: %d", result);
return result;
}
- result = reply.readInt32(outDefaultModeId);
+ result = reply.readInt32(outDefaultConfig);
if (result != NO_ERROR) {
- ALOGE("getDesiredDisplayConfigSpecs failed to read defaultModeId: %d", result);
+ ALOGE("getDesiredDisplayConfigSpecs failed to read defaultConfig: %d", result);
return result;
}
result = reply.readFloat(outMinRefreshRate);
@@ -1644,31 +1591,13 @@
}
return removeRegionSamplingListener(listener);
}
- case SET_ALLOWED_DISPLAY_CONFIGS: {
- CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<IBinder> displayToken = data.readStrongBinder();
- std::vector<int32_t> allowedConfigs;
- data.readInt32Vector(&allowedConfigs);
- status_t result = setAllowedDisplayConfigs(displayToken, allowedConfigs);
- reply->writeInt32(result);
- return result;
- }
- case GET_ALLOWED_DISPLAY_CONFIGS: {
- CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<IBinder> displayToken = data.readStrongBinder();
- std::vector<int32_t> allowedConfigs;
- status_t result = getAllowedDisplayConfigs(displayToken, &allowedConfigs);
- reply->writeInt32Vector(allowedConfigs);
- reply->writeInt32(result);
- return result;
- }
case SET_DESIRED_DISPLAY_CONFIG_SPECS: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
sp<IBinder> displayToken = data.readStrongBinder();
- int32_t defaultModeId;
- status_t result = data.readInt32(&defaultModeId);
+ int32_t defaultConfig;
+ status_t result = data.readInt32(&defaultConfig);
if (result != NO_ERROR) {
- ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultModeId: %d", result);
+ ALOGE("setDesiredDisplayConfigSpecs: failed to read defaultConfig: %d", result);
return result;
}
float minRefreshRate;
@@ -1683,7 +1612,7 @@
ALOGE("setDesiredDisplayConfigSpecs: failed to read maxRefreshRate: %d", result);
return result;
}
- result = setDesiredDisplayConfigSpecs(displayToken, defaultModeId, minRefreshRate,
+ result = setDesiredDisplayConfigSpecs(displayToken, defaultConfig, minRefreshRate,
maxRefreshRate);
if (result != NO_ERROR) {
ALOGE("setDesiredDisplayConfigSpecs: failed to call setDesiredDisplayConfigSpecs: "
@@ -1697,11 +1626,11 @@
case GET_DESIRED_DISPLAY_CONFIG_SPECS: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
sp<IBinder> displayToken = data.readStrongBinder();
- int32_t defaultModeId;
+ int32_t defaultConfig;
float minRefreshRate;
float maxRefreshRate;
- status_t result = getDesiredDisplayConfigSpecs(displayToken, &defaultModeId,
+ status_t result = getDesiredDisplayConfigSpecs(displayToken, &defaultConfig,
&minRefreshRate, &maxRefreshRate);
if (result != NO_ERROR) {
ALOGE("getDesiredDisplayConfigSpecs: failed to get getDesiredDisplayConfigSpecs: "
@@ -1710,9 +1639,9 @@
return result;
}
- result = reply->writeInt32(defaultModeId);
+ result = reply->writeInt32(defaultConfig);
if (result != NO_ERROR) {
- ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultModeId: %d", result);
+ ALOGE("getDesiredDisplayConfigSpecs: failed to write defaultConfig: %d", result);
return result;
}
result = reply->writeFloat(minRefreshRate);
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 9d7d7d0..d10bc81 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1605,34 +1605,22 @@
return ComposerService::getComposerService()->setActiveConfig(display, id);
}
-status_t SurfaceComposerClient::setAllowedDisplayConfigs(
- const sp<IBinder>& displayToken, const std::vector<int32_t>& allowedConfigs) {
- return ComposerService::getComposerService()->setAllowedDisplayConfigs(displayToken,
- allowedConfigs);
-}
-
-status_t SurfaceComposerClient::getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- std::vector<int32_t>* outAllowedConfigs) {
- return ComposerService::getComposerService()->getAllowedDisplayConfigs(displayToken,
- outAllowedConfigs);
-}
-
status_t SurfaceComposerClient::setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t defaultModeId,
+ int32_t defaultConfig,
float minRefreshRate,
float maxRefreshRate) {
return ComposerService::getComposerService()->setDesiredDisplayConfigSpecs(displayToken,
- defaultModeId,
+ defaultConfig,
minRefreshRate,
maxRefreshRate);
}
status_t SurfaceComposerClient::getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t* outDefaultModeId,
+ int32_t* outDefaultConfig,
float* outMinRefreshRate,
float* outMaxRefreshRate) {
return ComposerService::getComposerService()->getDesiredDisplayConfigSpecs(displayToken,
- outDefaultModeId,
+ outDefaultConfig,
outMinRefreshRate,
outMaxRefreshRate);
}
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 345425d..024f2d6 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -386,31 +386,16 @@
virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) = 0;
/*
- * Sets the allowed display configurations to be used.
- * The allowedConfigs in a vector of indexes corresponding to the configurations
- * returned from getDisplayConfigs().
- */
- virtual status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- const std::vector<int32_t>& allowedConfigs) = 0;
-
- /*
- * Returns the allowed display configurations currently set.
- * The allowedConfigs in a vector of indexes corresponding to the configurations
- * returned from getDisplayConfigs().
- */
- virtual status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- std::vector<int32_t>* outAllowedConfigs) = 0;
- /*
* Sets the refresh rate boundaries for display configuration.
* For all other parameters, default configuration is used. The index for the default is
* corresponding to the configs returned from getDisplayConfigs().
*/
virtual status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t defaultModeId, float minRefreshRate,
+ int32_t defaultConfig, float minRefreshRate,
float maxRefreshRate) = 0;
virtual status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t* outDefaultModeId,
+ int32_t* outDefaultConfig,
float* outMinRefreshRate,
float* outMaxRefreshRate) = 0;
/*
@@ -523,8 +508,6 @@
GET_PHYSICAL_DISPLAY_IDS,
ADD_REGION_SAMPLING_LISTENER,
REMOVE_REGION_SAMPLING_LISTENER,
- SET_ALLOWED_DISPLAY_CONFIGS,
- GET_ALLOWED_DISPLAY_CONFIGS,
SET_DESIRED_DISPLAY_CONFIG_SPECS,
GET_DESIRED_DISPLAY_CONFIG_SPECS,
GET_DISPLAY_BRIGHTNESS_SUPPORT,
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 2c0b143..873fac0 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -117,23 +117,11 @@
// returned by getDisplayInfo
static status_t setActiveConfig(const sp<IBinder>& display, int id);
- // Sets the allowed display configurations to be used.
- // The allowedConfigs in a vector of indexes corresponding to the configurations
- // returned from getDisplayConfigs().
- static status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- const std::vector<int32_t>& allowedConfigs);
-
- // Returns the allowed display configurations currently set.
- // The allowedConfigs in a vector of indexes corresponding to the configurations
- // returned from getDisplayConfigs().
- static status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- std::vector<int32_t>* outAllowedConfigs);
-
// Sets the refresh rate boundaries for display configuration.
// For all other parameters, default configuration is used. The index for the default is
// corresponting to the configs returned from getDisplayConfigs().
static status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t defaultModeId, float minRefreshRate,
+ int32_t defaultConfig, float minRefreshRate,
float maxRefreshRate);
// Gets the refresh rate boundaries for display configuration.
// For all other parameters, default configuration is used. The index for the default is
@@ -141,7 +129,7 @@
// The reason is passed in for telemetry tracking, and it corresponds to the list of all
// the policy rules that were used.
static status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t* outDefaultModeId,
+ int32_t* outDefaultConfig,
float* outMinRefreshRate,
float* outMaxRefreshRate);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 3d90369..eaffc10 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -823,21 +823,13 @@
const sp<IRegionSamplingListener>& /*listener*/) override {
return NO_ERROR;
}
- status_t setAllowedDisplayConfigs(const sp<IBinder>& /*displayToken*/,
- const std::vector<int32_t>& /*allowedConfigs*/) override {
- return NO_ERROR;
- }
- status_t getAllowedDisplayConfigs(const sp<IBinder>& /*displayToken*/,
- std::vector<int32_t>* /*outAllowedConfigs*/) override {
- return NO_ERROR;
- }
status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& /*displayToken*/,
- int32_t /*defaultModeId*/, float /*minRefreshRate*/,
- float /*maxRefreshRate*/) override {
+ int32_t /*defaultConfig*/, float /*minRefreshRate*/,
+ float /*maxRefreshRate*/) {
return NO_ERROR;
}
status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& /*displayToken*/,
- int32_t* /*outDefaultModeId*/,
+ int32_t* /*outDefaultConfig*/,
float* /*outMinRefreshRate*/,
float* /*outMaxRefreshRate*/) override {
return NO_ERROR;
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
index 23fb96a..847e20c 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp
@@ -110,13 +110,48 @@
init(inputConfigs, currentConfigId);
}
-void RefreshRateConfigs::setPolicy(HwcConfigIndexType defaultConfigId, float minRefreshRate,
- float maxRefreshRate) {
+status_t RefreshRateConfigs::setPolicy(HwcConfigIndexType defaultConfigId, float minRefreshRate,
+ float maxRefreshRate, bool* outPolicyChanged) {
std::lock_guard lock(mLock);
- mCurrentGroupId = mRefreshRates.at(defaultConfigId).configGroup;
+ bool policyChanged = defaultConfigId != mDefaultConfig ||
+ minRefreshRate != mMinRefreshRateFps || maxRefreshRate != mMaxRefreshRateFps;
+ if (outPolicyChanged) {
+ *outPolicyChanged = policyChanged;
+ }
+ if (!policyChanged) {
+ return NO_ERROR;
+ }
+ // defaultConfigId must be a valid config ID, and within the given refresh rate range.
+ if (mRefreshRates.count(defaultConfigId) == 0) {
+ return BAD_VALUE;
+ }
+ const RefreshRate& refreshRate = mRefreshRates.at(defaultConfigId);
+ if (refreshRate.fps < minRefreshRate || refreshRate.fps > maxRefreshRate) {
+ return BAD_VALUE;
+ }
+ mDefaultConfig = defaultConfigId;
mMinRefreshRateFps = minRefreshRate;
mMaxRefreshRateFps = maxRefreshRate;
constructAvailableRefreshRates();
+ return NO_ERROR;
+}
+
+void RefreshRateConfigs::getPolicy(HwcConfigIndexType* defaultConfigId, float* minRefreshRate,
+ float* maxRefreshRate) const {
+ std::lock_guard lock(mLock);
+ *defaultConfigId = mDefaultConfig;
+ *minRefreshRate = mMinRefreshRateFps;
+ *maxRefreshRate = mMaxRefreshRateFps;
+}
+
+bool RefreshRateConfigs::isConfigAllowed(HwcConfigIndexType config) const {
+ std::lock_guard lock(mLock);
+ for (const RefreshRate* refreshRate : mAvailableRefreshRates) {
+ if (refreshRate->configId == config) {
+ return true;
+ }
+ }
+ return false;
}
void RefreshRateConfigs::getSortedRefreshRateList(
@@ -140,15 +175,18 @@
void RefreshRateConfigs::constructAvailableRefreshRates() {
// Filter configs based on current policy and sort based on vsync period
- ALOGV("constructRefreshRateMap: group %d min %.2f max %.2f", mCurrentGroupId.value(),
- mMinRefreshRateFps, mMaxRefreshRateFps);
+ HwcConfigGroupType group = mRefreshRates.at(mDefaultConfig).configGroup;
+ ALOGV("constructRefreshRateMap: default %d group %d min %.2f max %.2f", mDefaultConfig.value(),
+ group.value(), mMinRefreshRateFps, mMaxRefreshRateFps);
getSortedRefreshRateList(
- [this](const RefreshRate& refreshRate) REQUIRES(mLock) {
- return refreshRate.configGroup == mCurrentGroupId &&
- refreshRate.fps >= mMinRefreshRateFps &&
+ [&](const RefreshRate& refreshRate) REQUIRES(mLock) {
+ return refreshRate.configGroup == group && refreshRate.fps >= mMinRefreshRateFps &&
refreshRate.fps <= mMaxRefreshRateFps;
},
&mAvailableRefreshRates);
+ LOG_ALWAYS_FATAL_IF(mAvailableRefreshRates.empty(),
+ "No compatible display configs for default=%d min=%.0f max=%.0f",
+ mDefaultConfig.value(), mMinRefreshRateFps, mMaxRefreshRateFps);
}
// NO_THREAD_SAFETY_ANALYSIS since this is called from the constructor
@@ -167,12 +205,12 @@
mRefreshRates.emplace(config.configId, buildRefreshRate(config));
if (config.configId == currentHwcConfig) {
mCurrentRefreshRate = &mRefreshRates.at(config.configId);
- mCurrentGroupId = config.configGroup;
}
}
std::vector<const RefreshRate*> sortedConfigs;
getSortedRefreshRateList([](const RefreshRate&) { return true; }, &sortedConfigs);
+ mDefaultConfig = currentHwcConfig;
mMinSupportedRefreshRate = sortedConfigs.front();
mMaxSupportedRefreshRate = sortedConfigs.back();
constructAvailableRefreshRates();
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
index fb14dc7..1e740ca 100644
--- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
+++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.h
@@ -73,9 +73,17 @@
using AllRefreshRatesMapType = std::unordered_map<HwcConfigIndexType, const RefreshRate>;
- // Sets the current policy to choose refresh rates.
- void setPolicy(HwcConfigIndexType defaultConfigId, float minRefreshRate, float maxRefreshRate)
- EXCLUDES(mLock);
+ // Sets the current policy to choose refresh rates. Returns NO_ERROR if the requested policy is
+ // valid, or a negative error value otherwise. policyChanged, if non-null, will be set to true
+ // if the new policy is different from the old policy.
+ status_t setPolicy(HwcConfigIndexType defaultConfigId, float minRefreshRate,
+ float maxRefreshRate, bool* policyChanged) EXCLUDES(mLock);
+ // Gets the current policy.
+ void getPolicy(HwcConfigIndexType* defaultConfigId, float* minRefreshRate,
+ float* maxRefreshRate) const EXCLUDES(mLock);
+
+ // Returns true if config is allowed by the current policy.
+ bool isConfigAllowed(HwcConfigIndexType config) const EXCLUDES(mLock);
// Returns true if this device is doing refresh rate switching. This won't change at runtime.
bool refreshRateSwitchingSupported() const { return mRefreshRateSwitching; }
@@ -143,9 +151,9 @@
// the main thread, and read by the Scheduler (and other objects) on other threads.
const RefreshRate* mCurrentRefreshRate GUARDED_BY(mLock);
- // The current config group. This will change at runtime. This is set by SurfaceFlinger on
+ // The default config. This will change at runtime. This is set by SurfaceFlinger on
// the main thread, and read by the Scheduler (and other objects) on other threads.
- HwcConfigGroupType mCurrentGroupId GUARDED_BY(mLock);
+ HwcConfigIndexType mDefaultConfig GUARDED_BY(mLock);
// The min and max FPS allowed by the policy. This will change at runtime and set by
// SurfaceFlinger on the main thread.
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9d5081c..857cb70 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -910,10 +910,30 @@
status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& displayToken, int mode) {
ATRACE_CALL();
- std::vector<int32_t> allowedConfig;
- allowedConfig.push_back(mode);
+ if (!displayToken) {
+ return BAD_VALUE;
+ }
- return setAllowedDisplayConfigs(displayToken, allowedConfig);
+ status_t result = NO_ERROR;
+
+ postMessageSync(new LambdaMessage([&]() {
+ const auto display = getDisplayDeviceLocked(displayToken);
+ if (!display) {
+ ALOGE("Attempt to set allowed display configs for invalid display token %p",
+ displayToken.get());
+ result = BAD_VALUE;
+ } else if (display->isVirtual()) {
+ ALOGW("Attempt to set allowed display configs for virtual display");
+ result = BAD_VALUE;
+ } else {
+ HwcConfigIndexType config(mode);
+ const auto& refreshRate = mRefreshRateConfigs->getRefreshRateFromConfigId(config);
+ result = setDesiredDisplayConfigSpecsInternal(display, config, refreshRate.fps,
+ refreshRate.fps);
+ }
+ }));
+
+ return result;
}
void SurfaceFlinger::setActiveConfigInternal() {
@@ -1413,7 +1433,7 @@
}
bool SurfaceFlinger::isDisplayConfigAllowed(HwcConfigIndexType configId) const {
- return mAllowedDisplayConfigs.empty() || mAllowedDisplayConfigs.count(configId);
+ return mRefreshRateConfigs->isConfigAllowed(configId);
}
void SurfaceFlinger::changeRefreshRateLocked(const RefreshRate& refreshRate,
@@ -3995,18 +4015,13 @@
" present offset: %9" PRId64 " ns\t VSYNC period: %9" PRId64 " ns\n\n",
dispSyncPresentTimeOffset, getVsyncPeriod());
- StringAppendF(&result, "Allowed Display Configs: ");
- for (auto configId : mAllowedDisplayConfigs) {
- StringAppendF(&result, "%" PRIu32 " Hz, ",
- static_cast<int32_t>(
- mRefreshRateConfigs->getRefreshRateFromConfigId(configId).fps));
- }
+ HwcConfigIndexType defaultConfig;
+ float minFps, maxFps;
+ mRefreshRateConfigs->getPolicy(&defaultConfig, &minFps, &maxFps);
StringAppendF(&result,
- "DesiredDisplayConfigSpecs: default config ID: %" PRIu32
+ "DesiredDisplayConfigSpecs: default config ID: %d"
", min: %.2f Hz, max: %.2f Hz",
- mDesiredDisplayConfigSpecs.defaultModeId,
- mDesiredDisplayConfigSpecs.minRefreshRate,
- mDesiredDisplayConfigSpecs.maxRefreshRate);
+ defaultConfig.value(), minFps, maxFps);
StringAppendF(&result, "(config override by backdoor: %s)\n\n",
mDebugDisplayConfigSetByBackdoor ? "yes" : "no");
@@ -4434,8 +4449,6 @@
case GET_ANIMATION_FRAME_STATS:
case GET_HDR_CAPABILITIES:
case SET_ACTIVE_CONFIG:
- case SET_ALLOWED_DISPLAY_CONFIGS:
- case GET_ALLOWED_DISPLAY_CONFIGS:
case SET_DESIRED_DISPLAY_CONFIG_SPECS:
case GET_DESIRED_DISPLAY_CONFIG_SPECS:
case SET_ACTIVE_COLOR_MODE:
@@ -4861,7 +4874,7 @@
mDebugDisplayConfigSetByBackdoor = false;
if (n >= 0) {
const auto displayToken = getInternalDisplayToken();
- status_t result = setAllowedDisplayConfigs(displayToken, {n});
+ status_t result = setActiveConfig(displayToken, n);
if (result != NO_ERROR) {
return result;
}
@@ -5457,8 +5470,12 @@
}
}
-void SurfaceFlinger::setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display,
- const std::vector<int32_t>& allowedConfigs) {
+status_t SurfaceFlinger::setDesiredDisplayConfigSpecsInternal(const sp<DisplayDevice>& display,
+ HwcConfigIndexType defaultConfig,
+ float minRefreshRate,
+ float maxRefreshRate) {
+ Mutex::Autolock lock(mStateLock);
+
if (!display->isPrimary()) {
// TODO(b/144711714): For non-primary displays we should be able to set an active config
// as well. For now, just call directly to setActiveConfigWithConstraints but ideally
@@ -5472,26 +5489,36 @@
constraints.seamlessRequired = false;
HWC2::VsyncPeriodChangeTimeline timeline = {0, 0, 0};
- getHwComposer().setActiveConfigWithConstraints(*displayId, allowedConfigs[0], constraints,
- &timeline);
+ if (getHwComposer().setActiveConfigWithConstraints(*displayId, defaultConfig.value(),
+ constraints, &timeline) < 0) {
+ return BAD_VALUE;
+ }
if (timeline.refreshRequired) {
repaintEverythingForHWC();
}
- auto configId = HwcConfigIndexType(allowedConfigs[0]);
+ auto configId = HwcConfigIndexType(defaultConfig);
display->setActiveConfig(configId);
mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value, configId);
- return;
+ return NO_ERROR;
}
- const auto allowedDisplayConfigs = DisplayConfigs(allowedConfigs.begin(),
- allowedConfigs.end());
- if (allowedDisplayConfigs == mAllowedDisplayConfigs) {
- return;
+ if (mDebugDisplayConfigSetByBackdoor) {
+ // ignore this request as config is overridden by backdoor
+ return NO_ERROR;
}
- ALOGV("Updating allowed configs");
- mAllowedDisplayConfigs = std::move(allowedDisplayConfigs);
+ bool policyChanged;
+ if (mRefreshRateConfigs->setPolicy(defaultConfig, minRefreshRate, maxRefreshRate,
+ &policyChanged) < 0) {
+ return BAD_VALUE;
+ }
+ if (!policyChanged) {
+ return NO_ERROR;
+ }
+
+ ALOGV("Setting desired display config specs: defaultConfig: %d min: %.f max: %.f",
+ defaultConfig.value(), minRefreshRate, maxRefreshRate);
// TODO(b/140204874): This hack triggers a notification that something has changed, so
// that listeners that care about a change in allowed configs can get the notification.
@@ -5499,25 +5526,6 @@
mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value,
display->getActiveConfig());
- // Prepare the parameters needed for RefreshRateConfigs::setPolicy. This will change to just
- // passthrough once DisplayManager provide these parameters directly.
- const auto refreshRate =
- mRefreshRateConfigs->getRefreshRateFromConfigId(HwcConfigIndexType(allowedConfigs[0]));
- const auto defaultModeId = refreshRate.configId;
- auto minRefreshRateFps = refreshRate.fps;
- auto maxRefreshRateFps = minRefreshRateFps;
-
- for (auto config : allowedConfigs) {
- const auto configRefreshRate =
- mRefreshRateConfigs->getRefreshRateFromConfigId(HwcConfigIndexType(config));
- if (configRefreshRate.fps < minRefreshRateFps) {
- minRefreshRateFps = configRefreshRate.fps;
- } else if (configRefreshRate.fps > maxRefreshRateFps) {
- maxRefreshRateFps = configRefreshRate.fps;
- }
- }
- mRefreshRateConfigs->setPolicy(defaultModeId, minRefreshRateFps, maxRefreshRateFps);
-
if (mRefreshRateConfigs->refreshRateSwitchingSupported()) {
auto configId = mScheduler->getPreferredConfigId();
auto preferredRefreshRate = configId
@@ -5536,70 +5544,15 @@
Scheduler::ConfigEvent::Changed});
}
} else {
- if (!allowedConfigs.empty()) {
- ALOGV("switching to config %d", allowedConfigs[0]);
- auto configId = HwcConfigIndexType(allowedConfigs[0]);
- setDesiredActiveConfig({configId, Scheduler::ConfigEvent::Changed});
- }
- }
-}
-
-status_t SurfaceFlinger::setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- const std::vector<int32_t>& allowedConfigs) {
- ATRACE_CALL();
-
- if (!displayToken || allowedConfigs.empty()) {
- return BAD_VALUE;
- }
-
- if (mDebugDisplayConfigSetByBackdoor) {
- // ignore this request as config is overridden by backdoor
- return NO_ERROR;
- }
-
- postMessageSync(new LambdaMessage([&]() {
- const auto display = getDisplayDeviceLocked(displayToken);
- if (!display) {
- ALOGE("Attempt to set allowed display configs for invalid display token %p",
- displayToken.get());
- } else if (display->isVirtual()) {
- ALOGW("Attempt to set allowed display configs for virtual display");
- } else {
- Mutex::Autolock lock(mStateLock);
- setAllowedDisplayConfigsInternal(display, allowedConfigs);
- }
- }));
-
- return NO_ERROR;
-}
-
-status_t SurfaceFlinger::getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- std::vector<int32_t>* outAllowedConfigs) {
- ATRACE_CALL();
-
- if (!displayToken || !outAllowedConfigs) {
- return BAD_VALUE;
- }
-
- Mutex::Autolock lock(mStateLock);
-
- const auto display = getDisplayDeviceLocked(displayToken);
- if (!display) {
- return NAME_NOT_FOUND;
- }
-
- if (display->isPrimary()) {
- outAllowedConfigs->reserve(mAllowedDisplayConfigs.size());
- for (auto configId : mAllowedDisplayConfigs) {
- outAllowedConfigs->push_back(configId.value());
- }
+ ALOGV("switching to config %d", defaultConfig.value());
+ setDesiredActiveConfig({defaultConfig, Scheduler::ConfigEvent::Changed});
}
return NO_ERROR;
}
status_t SurfaceFlinger::setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t defaultModeId, float minRefreshRate,
+ int32_t defaultConfig, float minRefreshRate,
float maxRefreshRate) {
ATRACE_CALL();
@@ -5607,39 +5560,34 @@
return BAD_VALUE;
}
+ status_t result = NO_ERROR;
+
postMessageSync(new LambdaMessage([&]() {
const auto display = getDisplayDeviceLocked(displayToken);
if (!display) {
+ result = BAD_VALUE;
ALOGE("Attempt to set desired display configs for invalid display token %p",
displayToken.get());
} else if (display->isVirtual()) {
+ result = BAD_VALUE;
ALOGW("Attempt to set desired display configs for virtual display");
} else {
- // TODO(b/142507213): Plug through to HWC once the interface is ready.
- Mutex::Autolock lock(mStateLock);
- const DesiredDisplayConfigSpecs desiredDisplayConfigSpecs = {defaultModeId,
- minRefreshRate,
- maxRefreshRate};
- if (desiredDisplayConfigSpecs == mDesiredDisplayConfigSpecs) {
- return;
- }
- ALOGV("Updating desired display configs");
- ALOGD("desiredDisplayConfigSpecs: defaultId: %d min: %.f max: %.f decisions: ",
- desiredDisplayConfigSpecs.defaultModeId, desiredDisplayConfigSpecs.minRefreshRate,
- desiredDisplayConfigSpecs.maxRefreshRate);
- mDesiredDisplayConfigSpecs = desiredDisplayConfigSpecs;
+ result =
+ setDesiredDisplayConfigSpecsInternal(display, HwcConfigIndexType(defaultConfig),
+ minRefreshRate, maxRefreshRate);
}
}));
- return NO_ERROR;
+
+ return result;
}
status_t SurfaceFlinger::getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t* outDefaultModeId,
+ int32_t* outDefaultConfig,
float* outMinRefreshRate,
float* outMaxRefreshRate) {
ATRACE_CALL();
- if (!displayToken || !outDefaultModeId || !outMinRefreshRate || !outMaxRefreshRate) {
+ if (!displayToken || !outDefaultConfig || !outMinRefreshRate || !outMaxRefreshRate) {
return BAD_VALUE;
}
@@ -5650,12 +5598,23 @@
}
if (display->isPrimary()) {
- *outDefaultModeId = mDesiredDisplayConfigSpecs.defaultModeId;
- *outMinRefreshRate = mDesiredDisplayConfigSpecs.minRefreshRate;
- *outMaxRefreshRate = mDesiredDisplayConfigSpecs.maxRefreshRate;
+ HwcConfigIndexType defaultConfig;
+ mRefreshRateConfigs->getPolicy(&defaultConfig, outMinRefreshRate, outMaxRefreshRate);
+ *outDefaultConfig = defaultConfig.value();
+ return NO_ERROR;
+ } else if (display->isVirtual()) {
+ return BAD_VALUE;
+ } else {
+ const auto displayId = display->getId();
+ if (!displayId) {
+ return BAD_VALUE;
+ }
+ *outDefaultConfig = getHwComposer().getActiveConfigIndex(*displayId);
+ auto vsyncPeriod = getHwComposer().getActiveConfig(*displayId)->getVsyncPeriod();
+ *outMinRefreshRate = 1e9f / vsyncPeriod;
+ *outMaxRefreshRate = 1e9f / vsyncPeriod;
+ return NO_ERROR;
}
-
- return NO_ERROR;
}
void SurfaceFlinger::SetInputWindowsListener::onSetInputWindowsFinished() {
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 53b8908..81000c6 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -384,17 +384,6 @@
void traverseInReverseZOrder(const LayerVector::Visitor& visitor) const;
};
- struct DesiredDisplayConfigSpecs {
- int32_t defaultModeId;
- float minRefreshRate;
- float maxRefreshRate;
-
- bool operator==(const DesiredDisplayConfigSpecs& other) const {
- return defaultModeId == other.defaultModeId && minRefreshRate == other.minRefreshRate &&
- maxRefreshRate == other.maxRefreshRate;
- }
- };
-
/* ------------------------------------------------------------------------
* IBinder interface
*/
@@ -478,14 +467,10 @@
status_t addRegionSamplingListener(const Rect& samplingArea, const sp<IBinder>& stopLayerHandle,
const sp<IRegionSamplingListener>& listener) override;
status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) override;
- status_t setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- const std::vector<int32_t>& allowedConfigs) override;
- status_t getAllowedDisplayConfigs(const sp<IBinder>& displayToken,
- std::vector<int32_t>* outAllowedConfigs) override;
status_t setDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken, int32_t displayModeId,
float minRefreshRate, float maxRefreshRate) override;
status_t getDesiredDisplayConfigSpecs(const sp<IBinder>& displayToken,
- int32_t* outDefaultModeId, float* outMinRefreshRate,
+ int32_t* outDefaultConfig, float* outMinRefreshRate,
float* outMaxRefreshRate) override;
status_t getDisplayBrightnessSupport(const sp<IBinder>& displayToken,
bool* outSupport) const override;
@@ -559,10 +544,11 @@
// called on the main thread in response to setPowerMode()
void setPowerModeInternal(const sp<DisplayDevice>& display, int mode) REQUIRES(mStateLock);
- // called on the main thread in response to setAllowedDisplayConfigs()
- void setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display,
- const std::vector<int32_t>& allowedConfigs)
- REQUIRES(mStateLock);
+ // Sets the desired display configs.
+ status_t setDesiredDisplayConfigSpecsInternal(const sp<DisplayDevice>& display,
+ HwcConfigIndexType defaultConfig,
+ float minRefreshRate, float maxRefreshRate)
+ EXCLUDES(mStateLock);
// Returns whether the transaction actually modified any state
bool handleMessageTransaction();
@@ -1140,11 +1126,6 @@
std::atomic<nsecs_t> mExpectedPresentTime = 0;
- // All configs are allowed if the set is empty.
- using DisplayConfigs = std::set<HwcConfigIndexType>;
- DisplayConfigs mAllowedDisplayConfigs GUARDED_BY(mStateLock);
- DesiredDisplayConfigSpecs mDesiredDisplayConfigSpecs GUARDED_BY(mStateLock);
-
std::mutex mActiveConfigLock;
// This bit is set once we start setting the config. We read from this bit during the
// process. If at the end, this bit is different than mDesiredActiveConfig, we restart
diff --git a/services/surfaceflinger/tests/Android.bp b/services/surfaceflinger/tests/Android.bp
index ca7e18d..dcfc077 100644
--- a/services/surfaceflinger/tests/Android.bp
+++ b/services/surfaceflinger/tests/Android.bp
@@ -21,7 +21,6 @@
"CommonTypes_test.cpp",
"Credentials_test.cpp",
"DereferenceSurfaceControl_test.cpp",
- "DisplayActiveConfig_test.cpp",
"DisplayConfigs_test.cpp",
"InvalidHandles_test.cpp",
"LayerCallback_test.cpp",
diff --git a/services/surfaceflinger/tests/DisplayActiveConfig_test.cpp b/services/surfaceflinger/tests/DisplayActiveConfig_test.cpp
deleted file mode 100644
index 2e3b760..0000000
--- a/services/surfaceflinger/tests/DisplayActiveConfig_test.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <thread>
-#include "LayerTransactionTest.h"
-namespace android {
-
-using android::hardware::graphics::common::V1_1::BufferUsage;
-
-::testing::Environment* const binderEnv =
- ::testing::AddGlobalTestEnvironment(new BinderEnvironment());
-
-class DisplayActiveConfigTest : public ::testing::Test {
-protected:
- void SetUp() override {
- mDisplayToken = SurfaceComposerClient::getInternalDisplayToken();
- SurfaceComposerClient::getDisplayConfigs(mDisplayToken, &mDisplayconfigs);
- EXPECT_GT(mDisplayconfigs.size(), 0);
-
- // set display power to on to make sure config can be changed
- SurfaceComposerClient::setDisplayPowerMode(mDisplayToken, HWC_POWER_MODE_NORMAL);
- }
-
- sp<IBinder> mDisplayToken;
- Vector<DisplayInfo> mDisplayconfigs;
-};
-
-TEST_F(DisplayActiveConfigTest, allConfigsAllowed) {
- std::vector<int32_t> allowedConfigs;
-
- // Add all configs to the allowed configs
- for (int i = 0; i < mDisplayconfigs.size(); i++) {
- allowedConfigs.push_back(i);
- }
-
- status_t res = SurfaceComposerClient::setAllowedDisplayConfigs(mDisplayToken, allowedConfigs);
- EXPECT_EQ(res, NO_ERROR);
-
- std::vector<int32_t> outConfigs;
- res = SurfaceComposerClient::getAllowedDisplayConfigs(mDisplayToken, &outConfigs);
- EXPECT_EQ(res, NO_ERROR);
- EXPECT_EQ(allowedConfigs, outConfigs);
-}
-
-TEST_F(DisplayActiveConfigTest, changeAllowedConfig) {
- // we need at least 2 configs available for this test
- if (mDisplayconfigs.size() <= 1) return;
-
- int activeConfig = SurfaceComposerClient::getActiveConfig(mDisplayToken);
-
- // We want to set the allowed config to everything but the active config
- std::vector<int32_t> allowedConfigs;
- for (int i = 0; i < mDisplayconfigs.size(); i++) {
- if (i != activeConfig) {
- allowedConfigs.push_back(i);
- }
- }
-
- status_t res = SurfaceComposerClient::setAllowedDisplayConfigs(mDisplayToken, allowedConfigs);
- EXPECT_EQ(res, NO_ERROR);
-
- // Allow some time for the config change
- std::this_thread::sleep_for(200ms);
-
- int newActiveConfig = SurfaceComposerClient::getActiveConfig(mDisplayToken);
- EXPECT_NE(activeConfig, newActiveConfig);
-
- // Make sure the new config is part of allowed config
- EXPECT_TRUE(std::find(allowedConfigs.begin(), allowedConfigs.end(), newActiveConfig) !=
- allowedConfigs.end());
-}
-} // namespace android
diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
index 546e65c..ed620ef 100644
--- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
+++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp
@@ -79,6 +79,16 @@
ASSERT_FALSE(refreshRateConfigs->refreshRateSwitchingSupported());
}
+TEST_F(RefreshRateConfigsTest, invalidPolicy) {
+ std::vector<RefreshRateConfigs::InputConfig> configs{
+ {{HWC_CONFIG_ID_60, HWC_GROUP_ID_0, VSYNC_60}}};
+ auto refreshRateConfigs =
+ std::make_unique<RefreshRateConfigs>(/*refreshRateSwitching=*/true, configs,
+ /*currentConfigId=*/HWC_CONFIG_ID_60);
+ ASSERT_LT(refreshRateConfigs->setPolicy(HwcConfigIndexType(10), 60, 60, nullptr), 0);
+ ASSERT_LT(refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 20, 40, nullptr), 0);
+}
+
TEST_F(RefreshRateConfigsTest, twoDeviceConfigs_storesFullRefreshRateMap) {
std::vector<RefreshRateConfigs::InputConfig> configs{
{{HWC_CONFIG_ID_60, HWC_GROUP_ID_0, VSYNC_60},
@@ -123,7 +133,7 @@
ASSERT_EQ(expectedDefaultConfig, minRate60);
ASSERT_EQ(expectedDefaultConfig, performanceRate60);
- refreshRateConfigs->setPolicy(HWC_CONFIG_ID_90, 60, 90);
+ ASSERT_GE(refreshRateConfigs->setPolicy(HWC_CONFIG_ID_90, 60, 90, nullptr), 0);
refreshRateConfigs->setCurrentConfigId(HWC_CONFIG_ID_90);
ASSERT_TRUE(refreshRateConfigs->refreshRateSwitchingSupported());
@@ -154,7 +164,7 @@
90};
ASSERT_EQ(expectedPerformanceConfig, performanceRate);
- refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 60, 60);
+ ASSERT_GE(refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 60, 60, nullptr), 0);
ASSERT_TRUE(refreshRateConfigs->refreshRateSwitchingSupported());
auto minRate60 = refreshRateConfigs->getMinRefreshRateByPolicy();
@@ -181,7 +191,7 @@
EXPECT_EQ(current.configId, HWC_CONFIG_ID_90);
}
- refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 90, 90);
+ ASSERT_GE(refreshRateConfigs->setPolicy(HWC_CONFIG_ID_90, 90, 90, nullptr), 0);
{
auto current = refreshRateConfigs->getCurrentRefreshRate();
EXPECT_EQ(current.configId, HWC_CONFIG_ID_90);
@@ -207,20 +217,20 @@
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(30.0f));
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(24.0f));
- refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 60, 60);
+ ASSERT_GE(refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 60, 60, nullptr), 0);
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(90.0f));
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(60.0f));
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(45.0f));
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(30.0f));
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(24.0f));
- refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 90, 90);
+ ASSERT_GE(refreshRateConfigs->setPolicy(HWC_CONFIG_ID_90, 90, 90, nullptr), 0);
ASSERT_EQ(expected90Config, refreshRateConfigs->getRefreshRateForContent(90.0f));
ASSERT_EQ(expected90Config, refreshRateConfigs->getRefreshRateForContent(60.0f));
ASSERT_EQ(expected90Config, refreshRateConfigs->getRefreshRateForContent(45.0f));
ASSERT_EQ(expected90Config, refreshRateConfigs->getRefreshRateForContent(30.0f));
ASSERT_EQ(expected90Config, refreshRateConfigs->getRefreshRateForContent(24.0f));
- refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 0, 120);
+ ASSERT_GE(refreshRateConfigs->setPolicy(HWC_CONFIG_ID_60, 0, 120, nullptr), 0);
ASSERT_EQ(expected90Config, refreshRateConfigs->getRefreshRateForContent(90.0f));
ASSERT_EQ(expected60Config, refreshRateConfigs->getRefreshRateForContent(60.0f));
ASSERT_EQ(expected90Config, refreshRateConfigs->getRefreshRateForContent(45.0f));