From 0686afa15a0c2f3666246977ebd1db37e640ebad Mon Sep 17 00:00:00 2001 From: Peiyong Lin Date: Mon, 29 Apr 2019 16:04:41 -0700 Subject: [PATCH] Return display capability if getDisplayBrightnessSupport is not registered. If getDisplayBrightnessSupport is not registered, there are two possibilities, one is it's not supported at all, the other is that the support is returned in getDisplayCapabilities. And thus we need to check getDisplayCapabilities, and we return UNSUPPORTED always in this case. This patch also allows getPerFrameMetadataKeys to return UNSUPPORTED on non-HDR capable devices. BUG: 131595097 Test: Build, boot. Change-Id: Ied302b1ac702dd94e039f1081d5420395c1bfbf4 --- .../VtsHalGraphicsComposerV2_2TargetTest.cpp | 14 +++++++++++++- .../include/composer-hal/2.3/ComposerClient.h | 2 +- .../hal/include/composer-hal/2.3/ComposerHal.h | 2 +- .../include/composer-passthrough/2.3/HwcHal.h | 18 ++++++++++++++++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp index 7834b9460f..9c80f4da5e 100644 --- a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp +++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp @@ -246,7 +246,19 @@ TEST_F(GraphicsComposerHidlCommandTest, SET_LAYER_PER_FRAME_METADATA) { * Test IComposerClient::getPerFrameMetadataKeys. */ TEST_F(GraphicsComposerHidlTest, GetPerFrameMetadataKeys) { - mComposerClient->getPerFrameMetadataKeys(mPrimaryDisplay); + std::vector keys; + Error error = Error::NONE; + mComposerClient->getRaw()->getPerFrameMetadataKeys( + mPrimaryDisplay, [&](const auto& tmpError, const auto& tmpKeys) { + error = tmpError; + keys = tmpKeys; + }); + if (error == Error::UNSUPPORTED) { + GTEST_SUCCEED() << "getPerFrameMetadataKeys is not supported"; + return; + } + ASSERT_EQ(Error::NONE, error); + ASSERT_TRUE(keys.size() >= 0); } /** diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h index 3792c2e4a0..b289b6a0f9 100644 --- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h +++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerClient.h @@ -95,7 +95,7 @@ class ComposerClientImpl : public V2_2::hal::detail::ComposerClientImpl getDisplayCapabilities( Display display, IComposerClient::getDisplayCapabilities_cb hidl_cb) override { - hidl_vec capabilities; + std::vector capabilities; Error error = mHal->getDisplayCapabilities(display, &capabilities); hidl_cb(error, capabilities); return Void(); diff --git a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h index 186b004810..c3c488746d 100644 --- a/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h +++ b/graphics/composer/2.3/utils/hal/include/composer-hal/2.3/ComposerHal.h @@ -115,7 +115,7 @@ class ComposerHal : public V2_2::hal::ComposerHal { hidl_vec& sampleComponent2, hidl_vec& sampleComponent3) = 0; virtual Error getDisplayCapabilities( - Display display, hidl_vec* outCapabilities) = 0; + Display display, std::vector* outCapabilities) = 0; virtual Error setLayerPerFrameMetadataBlobs( Display display, Layer layer, std::vector& blobs) = 0; diff --git a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h index 4829e24daa..d3b29bb803 100644 --- a/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h +++ b/graphics/composer/2.3/utils/passthrough/include/composer-passthrough/2.3/HwcHal.h @@ -220,7 +220,8 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl { } Error getDisplayCapabilities( - Display display, hidl_vec* outCapabilities) override { + Display display, + std::vector* outCapabilities) override { uint32_t count = 0; int32_t error = mDispatch.getDisplayCapabilities(mDevice, display, &count, nullptr); if (error != HWC2_ERROR_NONE) { @@ -232,7 +233,7 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl { reinterpret_cast::type*>( outCapabilities->data())); if (error != HWC2_ERROR_NONE) { - *outCapabilities = hidl_vec(); + *outCapabilities = std::vector(); return static_cast(error); } return Error::NONE; @@ -267,6 +268,19 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl { Error getDisplayBrightnessSupport(Display display, bool* outSupport) { if (!mDispatch.getDisplayBrightnessSupport) { + // Preemptively set to false. + *outSupport = false; + // Try to query from getDisplayCapabilities. + std::vector capabilities; + Error error = getDisplayCapabilities(display, &capabilities); + if (error != Error::NONE) { + // This function is not registered, always return UNSUPPORTED. + return Error::UNSUPPORTED; + } + *outSupport = + std::find(capabilities.begin(), capabilities.end(), + IComposerClient::DisplayCapability::BRIGHTNESS) != capabilities.end(); + // This function is not registered, always return UNSUPPORTED. return Error::UNSUPPORTED; } bool support = false;