diff options
12 files changed, 200 insertions, 22 deletions
diff --git a/services/surfaceflinger/Display/DisplaySnapshot.cpp b/services/surfaceflinger/Display/DisplaySnapshot.cpp index 0c7a58ee71..39607400d6 100644 --- a/services/surfaceflinger/Display/DisplaySnapshot.cpp +++ b/services/surfaceflinger/Display/DisplaySnapshot.cpp @@ -26,11 +26,12 @@ namespace android::display { -DisplaySnapshot::DisplaySnapshot(PhysicalDisplayId displayId, +DisplaySnapshot::DisplaySnapshot(PhysicalDisplayId displayId, uint8_t port, ui::DisplayConnectionType connectionType, DisplayModes&& displayModes, ui::ColorModes&& colorModes, std::optional<DeviceProductInfo>&& deviceProductInfo) : mDisplayId(displayId), + mPort(port), mConnectionType(connectionType), mDisplayModes(std::move(displayModes)), mColorModes(std::move(colorModes)), @@ -62,6 +63,8 @@ ui::ColorModes DisplaySnapshot::filterColorModes(bool supportsWideColor) const { void DisplaySnapshot::dump(utils::Dumper& dumper) const { using namespace std::string_view_literals; + dumper.dump("port"sv, mPort); + dumper.dump("connectionType"sv, ftl::enum_string(mConnectionType)); dumper.dump("colorModes"sv); diff --git a/services/surfaceflinger/Display/DisplaySnapshot.h b/services/surfaceflinger/Display/DisplaySnapshot.h index 23471f5d8e..0030aad91e 100644 --- a/services/surfaceflinger/Display/DisplaySnapshot.h +++ b/services/surfaceflinger/Display/DisplaySnapshot.h @@ -16,6 +16,7 @@ #pragma once +#include <cstdint> #include <optional> #include <ui/ColorMode.h> @@ -30,13 +31,14 @@ namespace android::display { // Immutable state of a physical display, captured on hotplug. class DisplaySnapshot { public: - DisplaySnapshot(PhysicalDisplayId, ui::DisplayConnectionType, DisplayModes&&, ui::ColorModes&&, - std::optional<DeviceProductInfo>&&); + DisplaySnapshot(PhysicalDisplayId, uint8_t, ui::DisplayConnectionType, DisplayModes&&, + ui::ColorModes&&, std::optional<DeviceProductInfo>&&); DisplaySnapshot(const DisplaySnapshot&) = delete; DisplaySnapshot(DisplaySnapshot&&) = default; PhysicalDisplayId displayId() const { return mDisplayId; } + uint8_t port() const { return mPort; } ui::DisplayConnectionType connectionType() const { return mConnectionType; } std::optional<DisplayModeId> translateModeId(hal::HWConfigId) const; @@ -51,6 +53,7 @@ public: private: const PhysicalDisplayId mDisplayId; + const uint8_t mPort; const ui::DisplayConnectionType mConnectionType; // Effectively const except in move constructor. diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 8f411121bc..0e241d7037 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3631,10 +3631,13 @@ std::optional<DisplayModeId> SurfaceFlinger::processHotplugConnect(PhysicalDispl deviceProductInfo = snapshot.deviceProductInfo(); } + // Use the cached port via snapshot because we are updating an existing + // display on reconnect. const auto it = mPhysicalDisplays.try_replace(displayId, display.token(), displayId, - snapshot.connectionType(), std::move(displayModes), - std::move(colorModes), std::move(deviceProductInfo)); + snapshot.port(), snapshot.connectionType(), + std::move(displayModes), std::move(colorModes), + std::move(deviceProductInfo)); auto& state = mCurrentState.displays.editValueFor(it->second.token()); state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId. @@ -3647,7 +3650,7 @@ std::optional<DisplayModeId> SurfaceFlinger::processHotplugConnect(PhysicalDispl const ui::DisplayConnectionType connectionType = getHwComposer().getDisplayConnectionType(displayId); - mPhysicalDisplays.try_emplace(displayId, token, displayId, connectionType, + mPhysicalDisplays.try_emplace(displayId, token, displayId, info.port, connectionType, std::move(displayModes), std::move(colorModes), std::move(info.deviceProductInfo)); diff --git a/services/surfaceflinger/tests/unittests/CommitAndCompositeTest.h b/services/surfaceflinger/tests/unittests/CommitAndCompositeTest.h index b517ff02ad..c858d9a477 100644 --- a/services/surfaceflinger/tests/unittests/CommitAndCompositeTest.h +++ b/services/surfaceflinger/tests/unittests/CommitAndCompositeTest.h @@ -54,8 +54,8 @@ struct CommitAndCompositeTest : testing::Test { compositionengine::impl::createDisplay(mFlinger.getCompositionEngine(), std::move(compostionEngineDisplayArgs)); mDisplay = FakeDisplayDeviceInjector(mFlinger, compositionDisplay, - ui::DisplayConnectionType::Internal, HWC_DISPLAY, - kIsPrimary) + ui::DisplayConnectionType::Internal, + DEFAULT_DISPLAY_PORT, HWC_DISPLAY, kIsPrimary) .setDisplaySurface(mDisplaySurface) .setNativeWindow(mNativeWindow) .setPowerMode(hal::PowerMode::ON) @@ -68,7 +68,9 @@ struct CommitAndCompositeTest : testing::Test { using FakeDisplayDeviceInjector = TestableSurfaceFlinger::FakeDisplayDeviceInjector; static constexpr hal::HWDisplayId HWC_DISPLAY = FakeHwcDisplayInjector::DEFAULT_HWC_DISPLAY_ID; - static constexpr PhysicalDisplayId DEFAULT_DISPLAY_ID = PhysicalDisplayId::fromPort(42u); + static constexpr uint8_t DEFAULT_DISPLAY_PORT = 42u; + static constexpr PhysicalDisplayId DEFAULT_DISPLAY_ID = + PhysicalDisplayId::fromPort(DEFAULT_DISPLAY_PORT); static constexpr int DEFAULT_DISPLAY_WIDTH = 1920; static constexpr int DEFAULT_DISPLAY_HEIGHT = 1024; diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp index 860ad2e013..71cafbfd64 100644 --- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp +++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp @@ -76,7 +76,8 @@ constexpr hal::HWDisplayId HWC_DISPLAY = FakeHwcDisplayInjector::DEFAULT_HWC_DIS constexpr hal::HWLayerId HWC_LAYER = 5000; constexpr Transform DEFAULT_TRANSFORM = static_cast<Transform>(0); -constexpr PhysicalDisplayId DEFAULT_DISPLAY_ID = PhysicalDisplayId::fromPort(42u); +constexpr uint8_t DEFAULT_DISPLAY_PORT = 42u; +constexpr PhysicalDisplayId DEFAULT_DISPLAY_ID = PhysicalDisplayId::fromPort(DEFAULT_DISPLAY_PORT); constexpr int DEFAULT_DISPLAY_WIDTH = 1920; constexpr int DEFAULT_DISPLAY_HEIGHT = 1024; @@ -276,7 +277,8 @@ struct BaseDisplayVariant { test->mDisplay = FakeDisplayDeviceInjector(test->mFlinger, compositionDisplay, - kDisplayConnectionType, HWC_DISPLAY, kIsPrimary) + kDisplayConnectionType, DEFAULT_DISPLAY_PORT, HWC_DISPLAY, + kIsPrimary) .setDisplaySurface(test->mDisplaySurface) .setNativeWindow(test->mNativeWindow) .setSecure(Derived::IS_SECURE) diff --git a/services/surfaceflinger/tests/unittests/DisplayModeControllerTest.cpp b/services/surfaceflinger/tests/unittests/DisplayModeControllerTest.cpp index 29a1fab5ff..c6cbe52c4a 100644 --- a/services/surfaceflinger/tests/unittests/DisplayModeControllerTest.cpp +++ b/services/surfaceflinger/tests/unittests/DisplayModeControllerTest.cpp @@ -71,7 +71,7 @@ public: ASSERT_TRUE(infoOpt); mDisplayId = infoOpt->id; - mDisplaySnapshotOpt.emplace(mDisplayId, ui::DisplayConnectionType::Internal, + mDisplaySnapshotOpt.emplace(mDisplayId, infoOpt->port, ui::DisplayConnectionType::Internal, makeModes(kMode60, kMode90, kMode120), ui::ColorModes{}, std::nullopt); diff --git a/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h b/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h index fa976c8091..6e231aa7f4 100644 --- a/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h +++ b/services/surfaceflinger/tests/unittests/DisplayTransactionTestHelpers.h @@ -231,6 +231,16 @@ struct HwcDisplayIdGetter<PhysicalDisplayIdType<PhysicalDisplay>> { static constexpr std::optional<HWDisplayId> value = PhysicalDisplay::HWC_DISPLAY_ID; }; +template <typename> +struct PortGetter { + static constexpr std::optional<uint8_t> value; +}; + +template <typename PhysicalDisplay> +struct PortGetter<PhysicalDisplayIdType<PhysicalDisplay>> { + static constexpr std::optional<uint8_t> value = PhysicalDisplay::PORT; +}; + // DisplayIdType can be: // 1) PhysicalDisplayIdType<...> for generated ID of physical display backed by HWC. // 2) HalVirtualDisplayIdType<...> for hard-coded ID of virtual display backed by HWC. @@ -241,6 +251,7 @@ struct DisplayVariant { using DISPLAY_ID = DisplayIdGetter<DisplayIdType>; using CONNECTION_TYPE = DisplayConnectionTypeGetter<DisplayIdType>; using HWC_DISPLAY_ID_OPT = HwcDisplayIdGetter<DisplayIdType>; + using PORT = PortGetter<DisplayIdType>; static constexpr int WIDTH = width; static constexpr int HEIGHT = height; @@ -277,6 +288,7 @@ struct DisplayVariant { TestableSurfaceFlinger::FakeDisplayDeviceInjector(test->mFlinger, compositionDisplay, CONNECTION_TYPE::value, + PORT::value, HWC_DISPLAY_ID_OPT::value, static_cast<bool>(PRIMARY)); @@ -558,6 +570,10 @@ using OuterDisplayNonSecureVariant = /*hasIdentificationData=*/true, kNonSecure>, 1080, 2092>; +using ExternalDisplayWithIdentificationVariant = + PhysicalDisplayVariant<SecondaryDisplay<ui::DisplayConnectionType::External, + /*hasIdentificationData=*/true, kNonSecure>, + 1920, 1280>; using ExternalDisplayVariant = PhysicalDisplayVariant<SecondaryDisplay<ui::DisplayConnectionType::External, /*hasIdentificationData=*/false, kSecure>, diff --git a/services/surfaceflinger/tests/unittests/FakeDisplayInjector.h b/services/surfaceflinger/tests/unittests/FakeDisplayInjector.h index 744c53637a..5f7a9f2422 100644 --- a/services/surfaceflinger/tests/unittests/FakeDisplayInjector.h +++ b/services/surfaceflinger/tests/unittests/FakeDisplayInjector.h @@ -24,12 +24,15 @@ namespace android { +static constexpr uint8_t kDefaultPort = 255u; + using FakeDisplayDeviceInjector = TestableSurfaceFlinger::FakeDisplayDeviceInjector; using android::adpf::mock::PowerAdvisor; using android::hardware::graphics::composer::hal::HWDisplayId; struct FakeDisplayInjectorArgs { - PhysicalDisplayId displayId = PhysicalDisplayId::fromPort(255u); + PhysicalDisplayId displayId = PhysicalDisplayId::fromPort(kDefaultPort); + uint8_t port = kDefaultPort; HWDisplayId hwcDisplayId = 0; bool isPrimary = true; }; @@ -73,7 +76,7 @@ public: .build()); auto injector = FakeDisplayDeviceInjector(mFlinger, compositionDisplay, - ui::DisplayConnectionType::Internal, + ui::DisplayConnectionType::Internal, args.port, args.hwcDisplayId, args.isPrimary); injector.setNativeWindow(mNativeWindow); diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp index b0dd5c21f8..a506873d4c 100644 --- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp +++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_DisplayModeSwitching.cpp @@ -126,8 +126,9 @@ public: static constexpr HWDisplayId kInnerDisplayHwcId = PrimaryDisplayVariant::HWC_DISPLAY_ID; static constexpr HWDisplayId kOuterDisplayHwcId = kInnerDisplayHwcId + 1; - - static constexpr PhysicalDisplayId kOuterDisplayId = PhysicalDisplayId::fromPort(254u); + static constexpr uint8_t kOuterDisplayPort = 254u; + static constexpr PhysicalDisplayId kOuterDisplayId = + PhysicalDisplayId::fromPort(kOuterDisplayPort); auto injectOuterDisplay() { // For the inner display, this is handled by setupHwcHotplugCallExpectations. @@ -149,6 +150,7 @@ public: kModeId120); }, {.displayId = kOuterDisplayId, + .port = kOuterDisplayPort, .hwcDisplayId = kOuterDisplayHwcId, .isPrimary = kIsPrimary}); diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_HotplugTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_HotplugTest.cpp index aef467ab9d..4e7a1742fd 100644 --- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_HotplugTest.cpp +++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_HotplugTest.cpp @@ -59,6 +59,137 @@ TEST_F(HotplugTest, schedulesFrameToCommitDisplayTransaction) { EXPECT_TRUE(hasTransactionFlagSet(eDisplayTransactionNeeded)); } +TEST_F(HotplugTest, createsDisplaySnapshotsForDisplaysWithIdentificationData) { + // Configure a primary display with identification data. + using PrimaryDisplay = InnerDisplayVariant; + PrimaryDisplay::setupHwcHotplugCallExpectations(this); + PrimaryDisplay::setupHwcGetActiveConfigCallExpectations(this); + PrimaryDisplay::injectPendingHotplugEvent(this, Connection::CONNECTED); + + // TODO(b/241286146): Remove this unnecessary call. + EXPECT_CALL(*mComposer, + setVsyncEnabled(PrimaryDisplay::HWC_DISPLAY_ID, IComposerClient::Vsync::DISABLE)) + .WillOnce(Return(Error::NONE)); + + // A single commit should be scheduled. + EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame(_)).Times(1); + + mFlinger.configure(); + + // Configure an external display with identification info. + using ExternalDisplay = ExternalDisplayWithIdentificationVariant; + ExternalDisplay::setupHwcHotplugCallExpectations(this); + ExternalDisplay::setupHwcGetActiveConfigCallExpectations(this); + ExternalDisplay::injectPendingHotplugEvent(this, Connection::CONNECTED); + + // TODO(b/241286146): Remove this unnecessary call. + EXPECT_CALL(*mComposer, + setVsyncEnabled(ExternalDisplay::HWC_DISPLAY_ID, IComposerClient::Vsync::DISABLE)) + .WillOnce(Return(Error::NONE)); + + mFlinger.configure(); + + EXPECT_TRUE(hasPhysicalHwcDisplay(PrimaryDisplay::HWC_DISPLAY_ID)); + EXPECT_TRUE(mFlinger.getHwComposer().isConnected(PrimaryDisplay::DISPLAY_ID::get())); + const auto primaryDisplayIdOpt = + mFlinger.getHwComposer().toPhysicalDisplayId(PrimaryDisplay::HWC_DISPLAY_ID); + ASSERT_TRUE(primaryDisplayIdOpt.has_value()); + const auto primaryPhysicalDisplayOpt = + mFlinger.physicalDisplays().get(primaryDisplayIdOpt.value()); + ASSERT_TRUE(primaryPhysicalDisplayOpt.has_value()); + const auto primaryDisplaySnapshotRef = primaryPhysicalDisplayOpt->get().snapshotRef(); + EXPECT_EQ(PrimaryDisplay::DISPLAY_ID::get(), primaryDisplaySnapshotRef.get().displayId()); + EXPECT_EQ(PrimaryDisplay::PORT::value, primaryDisplaySnapshotRef.get().port()); + EXPECT_EQ(PrimaryDisplay::CONNECTION_TYPE::value, + primaryDisplaySnapshotRef.get().connectionType()); + + EXPECT_TRUE(hasPhysicalHwcDisplay(ExternalDisplay::HWC_DISPLAY_ID)); + EXPECT_TRUE(mFlinger.getHwComposer().isConnected(ExternalDisplay::DISPLAY_ID::get())); + const auto externalDisplayIdOpt = + mFlinger.getHwComposer().toPhysicalDisplayId(ExternalDisplay::HWC_DISPLAY_ID); + ASSERT_TRUE(externalDisplayIdOpt.has_value()); + const auto externalPhysicalDisplayOpt = + mFlinger.physicalDisplays().get(externalDisplayIdOpt.value()); + ASSERT_TRUE(externalPhysicalDisplayOpt.has_value()); + const auto externalDisplaySnapshotRef = externalPhysicalDisplayOpt->get().snapshotRef(); + EXPECT_EQ(ExternalDisplay::DISPLAY_ID::get(), externalDisplaySnapshotRef.get().displayId()); + EXPECT_EQ(ExternalDisplay::PORT::value, externalDisplaySnapshotRef.get().port()); + EXPECT_EQ(ExternalDisplay::CONNECTION_TYPE::value, + externalDisplaySnapshotRef.get().connectionType()); +} + +TEST_F(HotplugTest, createsDisplaySnapshotsForDisplaysWithoutIdentificationData) { + // Configure a primary display without identification data. + using PrimaryDisplay = PrimaryDisplayVariant; + PrimaryDisplay::setupHwcHotplugCallExpectations(this); + PrimaryDisplay::setupHwcGetActiveConfigCallExpectations(this); + PrimaryDisplay::injectPendingHotplugEvent(this, Connection::CONNECTED); + + // TODO(b/241286146): Remove this unnecessary call. + EXPECT_CALL(*mComposer, + setVsyncEnabled(PrimaryDisplay::HWC_DISPLAY_ID, IComposerClient::Vsync::DISABLE)) + .WillOnce(Return(Error::NONE)); + + // A single commit should be scheduled. + EXPECT_CALL(*mFlinger.scheduler(), scheduleFrame(_)).Times(1); + + mFlinger.configure(); + + // Configure an external display with identification info. + using ExternalDisplay = ExternalDisplayWithIdentificationVariant; + ExternalDisplay::setupHwcHotplugCallExpectations(this); + ExternalDisplay::setupHwcGetActiveConfigCallExpectations(this); + ExternalDisplay::injectPendingHotplugEvent(this, Connection::CONNECTED); + + // TODO(b/241286146): Remove this unnecessary call. + EXPECT_CALL(*mComposer, + setVsyncEnabled(ExternalDisplay::HWC_DISPLAY_ID, IComposerClient::Vsync::DISABLE)) + .WillOnce(Return(Error::NONE)); + + mFlinger.configure(); + + // Both ID and port are expected to be equal to 0 for primary internal display due to no + // identification data. + constexpr uint8_t primaryInternalDisplayPort = 0u; + constexpr PhysicalDisplayId primaryInternalDisplayId = + PhysicalDisplayId::fromPort(primaryInternalDisplayPort); + EXPECT_TRUE(hasPhysicalHwcDisplay(PrimaryDisplay::HWC_DISPLAY_ID)); + ASSERT_EQ(primaryInternalDisplayId, PrimaryDisplay::DISPLAY_ID::get()); + EXPECT_TRUE(mFlinger.getHwComposer().isConnected(PrimaryDisplay::DISPLAY_ID::get())); + const auto primaryDisplayIdOpt = + mFlinger.getHwComposer().toPhysicalDisplayId(PrimaryDisplay::HWC_DISPLAY_ID); + ASSERT_TRUE(primaryDisplayIdOpt.has_value()); + const auto primaryPhysicalDisplayOpt = + mFlinger.physicalDisplays().get(primaryDisplayIdOpt.value()); + ASSERT_TRUE(primaryPhysicalDisplayOpt.has_value()); + const auto primaryDisplaySnapshotRef = primaryPhysicalDisplayOpt->get().snapshotRef(); + EXPECT_EQ(primaryInternalDisplayId, primaryDisplaySnapshotRef.get().displayId()); + EXPECT_EQ(primaryInternalDisplayPort, primaryDisplaySnapshotRef.get().port()); + EXPECT_EQ(PrimaryDisplay::CONNECTION_TYPE::value, + primaryDisplaySnapshotRef.get().connectionType()); + + // Even though the external display has identification data available, the lack of data for the + // internal display has set of the legacy multi-display mode in SF and therefore the external + // display's identification data will be ignored. + // Both ID and port are expected to be equal to 1 for external internal display. + constexpr uint8_t externalDisplayPort = 1u; + constexpr PhysicalDisplayId externalDisplayId = + PhysicalDisplayId::fromPort(externalDisplayPort); + EXPECT_TRUE(hasPhysicalHwcDisplay(ExternalDisplay::HWC_DISPLAY_ID)); + EXPECT_TRUE(mFlinger.getHwComposer().isConnected(externalDisplayId)); + const auto externalDisplayIdOpt = + mFlinger.getHwComposer().toPhysicalDisplayId(ExternalDisplay::HWC_DISPLAY_ID); + ASSERT_TRUE(externalDisplayIdOpt.has_value()); + const auto externalPhysicalDisplayOpt = + mFlinger.physicalDisplays().get(externalDisplayIdOpt.value()); + ASSERT_TRUE(externalPhysicalDisplayOpt.has_value()); + const auto externalDisplaySnapshotRef = externalPhysicalDisplayOpt->get().snapshotRef(); + EXPECT_EQ(externalDisplayId, externalDisplaySnapshotRef.get().displayId()); + EXPECT_EQ(externalDisplayPort, externalDisplaySnapshotRef.get().port()); + EXPECT_EQ(ExternalDisplay::CONNECTION_TYPE::value, + externalDisplaySnapshotRef.get().connectionType()); +} + TEST_F(HotplugTest, ignoresDuplicateDisconnection) { // Inject a primary display. PrimaryDisplayVariant::injectHwcDisplay(this); diff --git a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp index 352000ef9a..6951eaf093 100644 --- a/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp +++ b/services/surfaceflinger/tests/unittests/SurfaceFlinger_SetupNewDisplayDeviceInternalTest.cpp @@ -239,6 +239,8 @@ void SetupNewDisplayDeviceInternalTest::setupNewDisplayDeviceInternalTest() { ASSERT_TRUE(displayId); const auto hwcDisplayId = Case::Display::HWC_DISPLAY_ID_OPT::value; ASSERT_TRUE(hwcDisplayId); + const auto port = Case::Display::PORT::value; + ASSERT_TRUE(port); mFlinger.getHwComposer().allocatePhysicalDisplay(*hwcDisplayId, *displayId, std::nullopt); DisplayModePtr activeMode = DisplayMode::Builder(Case::Display::HWC_ACTIVE_CONFIG_ID) .setResolution(Case::Display::RESOLUTION) @@ -258,7 +260,7 @@ void SetupNewDisplayDeviceInternalTest::setupNewDisplayDeviceInternalTest() { } const auto it = mFlinger.mutablePhysicalDisplays() - .emplace_or_replace(*displayId, displayToken, *displayId, + .emplace_or_replace(*displayId, displayToken, *displayId, *port, *kConnectionTypeOpt, makeModes(activeMode), std::move(colorModes), std::nullopt) .first; @@ -299,6 +301,13 @@ void SetupNewDisplayDeviceInternalTest::setupNewDisplayDeviceInternalTest() { mFlinger.mutableDisplayModeController() .getActiveMode(device->getPhysicalId()) .modePtr->getHwcId()); + + EXPECT_EQ(Case::Display::PORT::value, + mFlinger.physicalDisplays() + .get(device->getPhysicalId()) + .transform([](const display::PhysicalDisplay& display) { + return display.snapshot().port(); + })); } } diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h index 7f0b7a6585..bd1382e851 100644 --- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h +++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h @@ -947,11 +947,13 @@ public: FakeDisplayDeviceInjector(TestableSurfaceFlinger& flinger, std::shared_ptr<compositionengine::Display> display, std::optional<ui::DisplayConnectionType> connectionType, + std::optional<uint8_t> port, std::optional<hal::HWDisplayId> hwcDisplayId, bool isPrimary) : mFlinger(flinger), mCreationArgs(flinger.mFlinger, flinger.mFlinger->getHwComposer(), mDisplayToken, display), mConnectionType(connectionType), + mPort(port), mHwcDisplayId(hwcDisplayId) { mCreationArgs.isPrimary = isPrimary; mCreationArgs.initialPowerMode = hal::PowerMode::ON; @@ -1100,11 +1102,12 @@ public: .hwcDisplayId = *mHwcDisplayId, .activeMode = activeModeOpt->get()}; - const auto it = mFlinger.mutablePhysicalDisplays() - .emplace_or_replace(*physicalId, mDisplayToken, *physicalId, - *mConnectionType, std::move(modes), - ui::ColorModes(), std::nullopt) - .first; + const auto it = + mFlinger.mutablePhysicalDisplays() + .emplace_or_replace(*physicalId, mDisplayToken, *physicalId, *mPort, + *mConnectionType, std::move(modes), + ui::ColorModes(), std::nullopt) + .first; mFlinger.mutableDisplayModeController() .registerDisplay(*physicalId, it->second.snapshot(), @@ -1138,6 +1141,7 @@ public: DisplayModeId mActiveModeId; bool mSchedulerRegistration = true; const std::optional<ui::DisplayConnectionType> mConnectionType; + const std::optional<uint8_t> mPort; const std::optional<hal::HWDisplayId> mHwcDisplayId; }; |