diff options
author | 2025-01-21 12:00:15 -0800 | |
---|---|---|
committer | 2025-03-21 13:02:29 -0700 | |
commit | 9b2db4b7f20aff5de2c2454678010d3e0dafa163 (patch) | |
tree | f758df85f6659be7dea0745926600872d5de1c99 /services/surfaceflinger/SurfaceFlinger.cpp | |
parent | 73416e163b7611c2880add437d139129bd0cf79d (diff) |
Detect secure layers and start lazy HDCP activation
Layer snapshots are traversed to check for secure layers,
then trigger HWC to start HDCP activation when a secure
layer is detected.
Flag: com.android.graphics.surfaceflinger.flags.hdcp_negotiation
Bug: 372902990
Bug: 375340594
Test: manual
Change-Id: Ie52159043f94d7cdb079d7c48c47764017a979f5
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e89ef1874d..ffe70f547e 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2958,7 +2958,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite( for (const auto& [token, display] : FTL_FAKE_GUARD(mStateLock, mDisplays)) { auto compositionDisplay = display->getCompositionDisplay(); if (!compositionDisplay->getState().isEnabled) continue; - for (auto outputLayer : compositionDisplay->getOutputLayersOrderedByZ()) { + for (const auto* outputLayer : compositionDisplay->getOutputLayersOrderedByZ()) { if (outputLayer->getLayerFE().getCompositionState() == nullptr) { // This is unexpected but instead of crashing, capture traces to disk // and recover gracefully by forcing CE to rebuild layer stack. @@ -3084,11 +3084,23 @@ CompositeResultsPerDisplay SurfaceFlinger::composite( .c_str()); mPowerAdvisor->setCompositedWorkload(compositedWorkload); - moveSnapshotsFromCompositionArgs(refreshArgs, layers); SFTRACE_ASYNC_FOR_TRACK_END(WorkloadTracer::TRACK_NAME, WorkloadTracer::COMPOSITION_TRACE_COOKIE); SFTRACE_NAME_FOR_TRACK(WorkloadTracer::TRACK_NAME, "Post Composition"); SFTRACE_NAME("postComposition"); + + if (mDisplayModeController.supportsHdcp()) { + for (const auto& [id, _] : frameTargeters) { + ftl::FakeGuard guard(mStateLock); + if (const auto display = getCompositionDisplayLocked(id)) { + if (!display->isSecure() && display->hasSecureLayers()) { + mDisplayModeController.startHdcpNegotiation(id); + } + } + } + } + + moveSnapshotsFromCompositionArgs(refreshArgs, layers); mTimeStats->recordFrameDuration(pacesetterTarget.frameBeginTime().ns(), systemTime()); // Send a power hint after presentation is finished. @@ -3793,9 +3805,9 @@ std::optional<DisplayModeId> SurfaceFlinger::processHotplugConnect(PhysicalDispl .hwcDisplayId = hwcDisplayId, .port = info.port, .activeMode = std::move(activeMode)}; - - // TODO: b/349703362 - Remove this when HDCP aidl APIs are enforced - state.isSecure = true; // All physical displays are currently considered secure. + // TODO: b/349703362 - Remove first condition when HDCP aidl APIs are enforced + state.isSecure = !mDisplayModeController.supportsHdcp() || + connectionType == ui::DisplayConnectionType::Internal; state.isProtected = true; state.displayName = std::move(info.name); state.maxLayerPictureProfiles = getHwComposer().getMaxLayerPictureProfiles(displayId); @@ -8481,10 +8493,12 @@ void SurfaceFlinger::updateHdcpLevels(hal::HWDisplayId hwcDisplayId, int32_t con } static_cast<void>(mScheduler->schedule([this, displayId = *idOpt, connectedLevel, maxLevel]() { + const bool secure = connectedLevel >= 2 /* HDCP_V1 */; if (const auto display = FTL_FAKE_GUARD(mStateLock, getDisplayDeviceLocked(displayId))) { Mutex::Autolock lock(mStateLock); - display->setSecure(connectedLevel >= 2 /* HDCP_V1 */); + display->setSecure(secure); } + FTL_FAKE_GUARD(kMainThreadContext, mDisplayModeController.setSecure(displayId, secure)); mScheduler->onHdcpLevelsChanged(scheduler::Cycle::Render, displayId, connectedLevel, maxLevel); })); |