[SurfaceFlinger] Query display capability when display is on the first time.
Some display resource can't be allocated before the display is on, and thus
some capabilities are unknown. Thus move the query of display capability to the
first time that the display is on.
BUG: 69911676
Test: manual
Change-Id: I3488927d9a854a42432b7575d0daa14e61677c3e
diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
index 7c0ecb3..4f8ed1a 100644
--- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
@@ -253,13 +253,16 @@
static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_NORMAL;
static void setupPreconditions(CompositionTest* test) {
- EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _))
- .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::DisplayCapability>({})),
- Return(Error::NONE)));
+ EXPECT_CALL(*test->mComposer,
+ setPowerMode(HWC_DISPLAY,
+ static_cast<Hwc2::IComposerClient::PowerMode>(
+ Derived::INIT_POWER_MODE)))
+ .WillOnce(Return(Error::NONE));
FakeHwcDisplayInjector(DEFAULT_DISPLAY_ID, HWC2::DisplayType::Physical,
true /* isPrimary */)
.setCapabilities(&test->mDefaultCapabilities)
+ .setPowerMode(Derived::INIT_POWER_MODE)
.inject(&test->mFlinger, test->mComposer);
Mock::VerifyAndClear(test->mComposer);
@@ -282,6 +285,13 @@
}
template <typename Case>
+ static void setupPreconditionCallExpectations(CompositionTest* test) {
+ EXPECT_CALL(*test->mComposer, getDisplayCapabilities(HWC_DISPLAY, _))
+ .WillOnce(DoAll(SetArgPointee<1>(std::vector<Hwc2::DisplayCapability>({})),
+ Return(Error::NONE)));
+ }
+
+ template <typename Case>
static void setupCommonCompositionCallExpectations(CompositionTest* test) {
EXPECT_CALL(*test->mComposer,
setColorTransform(HWC_DISPLAY, _, Hwc2::ColorTransform::IDENTITY))
@@ -393,6 +403,9 @@
static constexpr int INIT_POWER_MODE = HWC_POWER_MODE_OFF;
template <typename Case>
+ static void setupPreconditionCallExpectations(CompositionTest*) {}
+
+ template <typename Case>
static void setupCommonCompositionCallExpectations(CompositionTest* test) {
EXPECT_CALL(*test->mRenderEngine, useNativeFenceSync()).WillRepeatedly(Return(true));
@@ -1022,6 +1035,7 @@
using CompositionResult = CompositionResultCase;
static void setupCommon(CompositionTest* test) {
+ Display::template setupPreconditionCallExpectations<ThisCase>(test);
Display::setupPreconditions(test);
auto layer = Layer::createLayer(test);