Merge "composer: vts: Init display dimension using active config"

This commit is contained in:
Treehugger Robot 2023-01-09 04:51:54 +00:00 committed by Gerrit Code Review
commit 12c9d664aa
2 changed files with 36 additions and 4 deletions

View file

@ -393,14 +393,31 @@ std::pair<ScopedAStatus, std::vector<VtsDisplay>> VtsComposerClient::getDisplays
return {std::move(configs.first), vtsDisplays}; return {std::move(configs.first), vtsDisplays};
} }
for (int config : configs.second) { for (int config : configs.second) {
auto status = updateDisplayProperties(&vtsDisplay, config); auto status = addDisplayConfig(&vtsDisplay, config);
if (!status.isOk()) { if (!status.isOk()) {
ALOGE("Unable to get the displays for test, failed to update the properties " ALOGE("Unable to get the displays for test, failed to add config "
"for display %" PRId64, "for display %" PRId64,
display); display);
return {std::move(status), vtsDisplays}; return {std::move(status), vtsDisplays};
} }
} }
auto config = getActiveConfig(display);
if (!config.first.isOk()) {
ALOGE("Unable to get the displays for test, failed to get active config "
"for display %" PRId64, display);
return {std::move(config.first), vtsDisplays};
}
auto status = updateDisplayProperties(&vtsDisplay, config.second);
if (!status.isOk()) {
ALOGE("Unable to get the displays for test, "
"failed to update the properties "
"for display %" PRId64,
display);
return {std::move(status), vtsDisplays};
}
vtsDisplays.emplace_back(vtsDisplay); vtsDisplays.emplace_back(vtsDisplay);
addDisplayToDisplayResources(display, /*isVirtual*/ false); addDisplayToDisplayResources(display, /*isVirtual*/ false);
} }
@ -409,7 +426,7 @@ std::pair<ScopedAStatus, std::vector<VtsDisplay>> VtsComposerClient::getDisplays
} }
} }
ScopedAStatus VtsComposerClient::updateDisplayProperties(VtsDisplay* vtsDisplay, int32_t config) { ScopedAStatus VtsComposerClient::addDisplayConfig(VtsDisplay* vtsDisplay, int32_t config) {
const auto width = const auto width =
getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::WIDTH); getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::WIDTH);
const auto height = const auto height =
@ -420,7 +437,6 @@ ScopedAStatus VtsComposerClient::updateDisplayProperties(VtsDisplay* vtsDisplay,
getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::CONFIG_GROUP); getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::CONFIG_GROUP);
if (width.first.isOk() && height.first.isOk() && vsyncPeriod.first.isOk() && if (width.first.isOk() && height.first.isOk() && vsyncPeriod.first.isOk() &&
configGroup.first.isOk()) { configGroup.first.isOk()) {
vtsDisplay->setDimensions(width.second, height.second);
vtsDisplay->addDisplayConfig(config, {vsyncPeriod.second, configGroup.second}); vtsDisplay->addDisplayConfig(config, {vsyncPeriod.second, configGroup.second});
return ScopedAStatus::ok(); return ScopedAStatus::ok();
} }
@ -431,6 +447,21 @@ ScopedAStatus VtsComposerClient::updateDisplayProperties(VtsDisplay* vtsDisplay,
return ScopedAStatus::fromServiceSpecificError(IComposerClient::EX_BAD_CONFIG); return ScopedAStatus::fromServiceSpecificError(IComposerClient::EX_BAD_CONFIG);
} }
ScopedAStatus VtsComposerClient::updateDisplayProperties(VtsDisplay* vtsDisplay, int32_t config) {
const auto width =
getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::WIDTH);
const auto height =
getDisplayAttribute(vtsDisplay->getDisplayId(), config, DisplayAttribute::HEIGHT);
if (width.first.isOk() && height.first.isOk()) {
vtsDisplay->setDimensions(width.second, height.second);
return ScopedAStatus::ok();
}
LOG(ERROR) << "Failed to update display property for width: " << width.first.isOk()
<< ", height: " << height.first.isOk();
return ScopedAStatus::fromServiceSpecificError(IComposerClient::EX_BAD_CONFIG);
}
ScopedAStatus VtsComposerClient::addDisplayToDisplayResources(int64_t display, bool isVirtual) { ScopedAStatus VtsComposerClient::addDisplayToDisplayResources(int64_t display, bool isVirtual) {
if (mDisplayResources.insert({display, DisplayResource(isVirtual)}).second) { if (mDisplayResources.insert({display, DisplayResource(isVirtual)}).second) {
return ScopedAStatus::ok(); return ScopedAStatus::ok();

View file

@ -173,6 +173,7 @@ class VtsComposerClient {
std::pair<ScopedAStatus, std::vector<VtsDisplay>> getDisplays(); std::pair<ScopedAStatus, std::vector<VtsDisplay>> getDisplays();
private: private:
ScopedAStatus addDisplayConfig(VtsDisplay* vtsDisplay, int32_t config);
ScopedAStatus updateDisplayProperties(VtsDisplay* vtsDisplay, int32_t config); ScopedAStatus updateDisplayProperties(VtsDisplay* vtsDisplay, int32_t config);
ScopedAStatus addDisplayToDisplayResources(int64_t display, bool isVirtual); ScopedAStatus addDisplayToDisplayResources(int64_t display, bool isVirtual);