Loading services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h +1 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ public: MOCK_METHOD2(onHotplug, std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection)); MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool()); MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t)); MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync)); MOCK_CONST_METHOD1(getRefreshTimestamp, nsecs_t(PhysicalDisplayId)); Loading services/surfaceflinger/DisplayHardware/HWComposer.cpp +21 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "HWComposer.h" #include <android-base/properties.h> #include <compositionengine/Output.h> #include <compositionengine/OutputLayer.h> #include <compositionengine/impl/OutputLayerCompositionState.h> Loading @@ -38,6 +39,7 @@ #include "../Layer.h" // needed only for debugging #include "../Promise.h" #include "../SurfaceFlinger.h" #include "../SurfaceFlingerProperties.h" #include "ComposerHal.h" #include "HWC2.h" Loading Loading @@ -143,12 +145,13 @@ HWComposer::~HWComposer() = default; namespace impl { HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer) : mComposer(std::move(composer)) { } HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer) : mComposer(std::move(composer)), mUpdateDeviceProductInfoOnHotplugReconnect( android::sysprop::update_device_product_info_on_hotplug_reconnect(false)) {} HWComposer::HWComposer(const std::string& composerServiceName) : mComposer(std::make_unique<Hwc2::impl::Composer>(composerServiceName)) { } : HWComposer(std::make_unique<Hwc2::impl::Composer>(composerServiceName)) {} HWComposer::~HWComposer() { mDisplayData.clear(); Loading Loading @@ -204,6 +207,10 @@ std::optional<DisplayIdentificationInfo> HWComposer::onHotplug(hal::HWDisplayId } } bool HWComposer::updatesDeviceProductInfoOnHotplugReconnect() const { return mUpdateDeviceProductInfoOnHotplugReconnect; } bool HWComposer::onVsync(hal::HWDisplayId hwcDisplayId, int64_t timestamp) { const auto displayId = toPhysicalDisplayId(hwcDisplayId); if (!displayId) { Loading Loading @@ -888,6 +895,16 @@ std::optional<DisplayIdentificationInfo> HWComposer::onHotplugConnect( info = DisplayIdentificationInfo{.id = *displayId, .name = std::string(), .deviceProductInfo = std::nullopt}; if (mUpdateDeviceProductInfoOnHotplugReconnect) { uint8_t port; DisplayIdentificationData data; getDisplayIdentificationData(hwcDisplayId, &port, &data); if (auto newInfo = parseDisplayIdentificationData(port, data)) { info->deviceProductInfo = std::move(newInfo->deviceProductInfo); } else { ALOGE("Failed to parse identification data for display %" PRIu64, hwcDisplayId); } } } else { uint8_t port; DisplayIdentificationData data; Loading services/surfaceflinger/DisplayHardware/HWComposer.h +9 −1 Original line number Diff line number Diff line Loading @@ -173,6 +173,10 @@ public: virtual std::optional<DisplayIdentificationInfo> onHotplug(hal::HWDisplayId, hal::Connection) = 0; // If true we'll update the DeviceProductInfo on subsequent hotplug connected events. // TODO(b/157555476): Remove when the framework has proper support for headless mode virtual bool updatesDeviceProductInfoOnHotplugReconnect() const = 0; virtual bool onVsync(hal::HWDisplayId, int64_t timestamp) = 0; virtual void setVsyncEnabled(PhysicalDisplayId, hal::Vsync enabled) = 0; Loading Loading @@ -303,10 +307,12 @@ public: // Events handling --------------------------------------------------------- // Returns stable display ID (and display name on connection of new or previously disconnected // Returns PhysicalDisplayId (and display name on connection of new or previously disconnected // display), or std::nullopt if hotplug event was ignored. std::optional<DisplayIdentificationInfo> onHotplug(hal::HWDisplayId, hal::Connection) override; bool updatesDeviceProductInfoOnHotplugReconnect() const override; bool onVsync(hal::HWDisplayId, int64_t timestamp) override; void setVsyncEnabled(PhysicalDisplayId, hal::Vsync enabled) override; Loading Loading @@ -400,6 +406,8 @@ private: bool mHasMultiDisplaySupport = false; RandomDisplayIdGenerator<HalVirtualDisplayId> mVirtualIdGenerator{getMaxVirtualDisplayCount()}; const bool mUpdateDeviceProductInfoOnHotplugReconnect; }; } // namespace impl Loading services/surfaceflinger/SurfaceFlinger.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -2313,7 +2313,7 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags) void SurfaceFlinger::processDisplayHotplugEventsLocked() { for (const auto& event : mPendingHotplugEvents) { const std::optional<DisplayIdentificationInfo> info = std::optional<DisplayIdentificationInfo> info = getHwComposer().onHotplug(event.hwcDisplayId, event.connection); if (!info) { Loading @@ -2335,9 +2335,9 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { state.physical = {.id = displayId, .type = getHwComposer().getDisplayConnectionType(displayId), .hwcDisplayId = event.hwcDisplayId, .deviceProductInfo = info->deviceProductInfo}; .deviceProductInfo = std::move(info->deviceProductInfo)}; state.isSecure = true; // All physical displays are currently considered secure. state.displayName = info->name; state.displayName = std::move(info->name); sp<IBinder> token = new BBinder(); mCurrentState.displays.add(token, state); Loading @@ -2349,7 +2349,10 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { const auto token = it->second; auto& state = mCurrentState.displays.editValueFor(token); state.sequenceId = DisplayDeviceState{}.sequenceId; state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId if (getHwComposer().updatesDeviceProductInfoOnHotplugReconnect()) { state.physical->deviceProductInfo = std::move(info->deviceProductInfo); } } } else { ALOGV("Removing display %s", to_string(displayId).c_str()); Loading services/surfaceflinger/SurfaceFlingerProperties.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -371,5 +371,10 @@ DisplayPrimaries getDisplayNativePrimaries() { return primaries; } bool update_device_product_info_on_hotplug_reconnect(bool defaultValue) { return SurfaceFlingerProperties::update_device_product_info_on_hotplug_reconnect().value_or( defaultValue); } } // namespace sysprop } // namespace android Loading
services/surfaceflinger/CompositionEngine/tests/MockHWComposer.h +1 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ public: MOCK_METHOD2(onHotplug, std::optional<DisplayIdentificationInfo>(hal::HWDisplayId, hal::Connection)); MOCK_CONST_METHOD0(updatesDeviceProductInfoOnHotplugReconnect, bool()); MOCK_METHOD2(onVsync, bool(hal::HWDisplayId, int64_t)); MOCK_METHOD2(setVsyncEnabled, void(PhysicalDisplayId, hal::Vsync)); MOCK_CONST_METHOD1(getRefreshTimestamp, nsecs_t(PhysicalDisplayId)); Loading
services/surfaceflinger/DisplayHardware/HWComposer.cpp +21 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "HWComposer.h" #include <android-base/properties.h> #include <compositionengine/Output.h> #include <compositionengine/OutputLayer.h> #include <compositionengine/impl/OutputLayerCompositionState.h> Loading @@ -38,6 +39,7 @@ #include "../Layer.h" // needed only for debugging #include "../Promise.h" #include "../SurfaceFlinger.h" #include "../SurfaceFlingerProperties.h" #include "ComposerHal.h" #include "HWC2.h" Loading Loading @@ -143,12 +145,13 @@ HWComposer::~HWComposer() = default; namespace impl { HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer) : mComposer(std::move(composer)) { } HWComposer::HWComposer(std::unique_ptr<Hwc2::Composer> composer) : mComposer(std::move(composer)), mUpdateDeviceProductInfoOnHotplugReconnect( android::sysprop::update_device_product_info_on_hotplug_reconnect(false)) {} HWComposer::HWComposer(const std::string& composerServiceName) : mComposer(std::make_unique<Hwc2::impl::Composer>(composerServiceName)) { } : HWComposer(std::make_unique<Hwc2::impl::Composer>(composerServiceName)) {} HWComposer::~HWComposer() { mDisplayData.clear(); Loading Loading @@ -204,6 +207,10 @@ std::optional<DisplayIdentificationInfo> HWComposer::onHotplug(hal::HWDisplayId } } bool HWComposer::updatesDeviceProductInfoOnHotplugReconnect() const { return mUpdateDeviceProductInfoOnHotplugReconnect; } bool HWComposer::onVsync(hal::HWDisplayId hwcDisplayId, int64_t timestamp) { const auto displayId = toPhysicalDisplayId(hwcDisplayId); if (!displayId) { Loading Loading @@ -888,6 +895,16 @@ std::optional<DisplayIdentificationInfo> HWComposer::onHotplugConnect( info = DisplayIdentificationInfo{.id = *displayId, .name = std::string(), .deviceProductInfo = std::nullopt}; if (mUpdateDeviceProductInfoOnHotplugReconnect) { uint8_t port; DisplayIdentificationData data; getDisplayIdentificationData(hwcDisplayId, &port, &data); if (auto newInfo = parseDisplayIdentificationData(port, data)) { info->deviceProductInfo = std::move(newInfo->deviceProductInfo); } else { ALOGE("Failed to parse identification data for display %" PRIu64, hwcDisplayId); } } } else { uint8_t port; DisplayIdentificationData data; Loading
services/surfaceflinger/DisplayHardware/HWComposer.h +9 −1 Original line number Diff line number Diff line Loading @@ -173,6 +173,10 @@ public: virtual std::optional<DisplayIdentificationInfo> onHotplug(hal::HWDisplayId, hal::Connection) = 0; // If true we'll update the DeviceProductInfo on subsequent hotplug connected events. // TODO(b/157555476): Remove when the framework has proper support for headless mode virtual bool updatesDeviceProductInfoOnHotplugReconnect() const = 0; virtual bool onVsync(hal::HWDisplayId, int64_t timestamp) = 0; virtual void setVsyncEnabled(PhysicalDisplayId, hal::Vsync enabled) = 0; Loading Loading @@ -303,10 +307,12 @@ public: // Events handling --------------------------------------------------------- // Returns stable display ID (and display name on connection of new or previously disconnected // Returns PhysicalDisplayId (and display name on connection of new or previously disconnected // display), or std::nullopt if hotplug event was ignored. std::optional<DisplayIdentificationInfo> onHotplug(hal::HWDisplayId, hal::Connection) override; bool updatesDeviceProductInfoOnHotplugReconnect() const override; bool onVsync(hal::HWDisplayId, int64_t timestamp) override; void setVsyncEnabled(PhysicalDisplayId, hal::Vsync enabled) override; Loading Loading @@ -400,6 +406,8 @@ private: bool mHasMultiDisplaySupport = false; RandomDisplayIdGenerator<HalVirtualDisplayId> mVirtualIdGenerator{getMaxVirtualDisplayCount()}; const bool mUpdateDeviceProductInfoOnHotplugReconnect; }; } // namespace impl Loading
services/surfaceflinger/SurfaceFlinger.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -2313,7 +2313,7 @@ void SurfaceFlinger::handleTransaction(uint32_t transactionFlags) void SurfaceFlinger::processDisplayHotplugEventsLocked() { for (const auto& event : mPendingHotplugEvents) { const std::optional<DisplayIdentificationInfo> info = std::optional<DisplayIdentificationInfo> info = getHwComposer().onHotplug(event.hwcDisplayId, event.connection); if (!info) { Loading @@ -2335,9 +2335,9 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { state.physical = {.id = displayId, .type = getHwComposer().getDisplayConnectionType(displayId), .hwcDisplayId = event.hwcDisplayId, .deviceProductInfo = info->deviceProductInfo}; .deviceProductInfo = std::move(info->deviceProductInfo)}; state.isSecure = true; // All physical displays are currently considered secure. state.displayName = info->name; state.displayName = std::move(info->name); sp<IBinder> token = new BBinder(); mCurrentState.displays.add(token, state); Loading @@ -2349,7 +2349,10 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() { const auto token = it->second; auto& state = mCurrentState.displays.editValueFor(token); state.sequenceId = DisplayDeviceState{}.sequenceId; state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId if (getHwComposer().updatesDeviceProductInfoOnHotplugReconnect()) { state.physical->deviceProductInfo = std::move(info->deviceProductInfo); } } } else { ALOGV("Removing display %s", to_string(displayId).c_str()); Loading
services/surfaceflinger/SurfaceFlingerProperties.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -371,5 +371,10 @@ DisplayPrimaries getDisplayNativePrimaries() { return primaries; } bool update_device_product_info_on_hotplug_reconnect(bool defaultValue) { return SurfaceFlingerProperties::update_device_product_info_on_hotplug_reconnect().value_or( defaultValue); } } // namespace sysprop } // namespace android