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;