Ensure sub-hierarchy screenshots inherit secure from parent.
If a sub-hierarchy is screenshot that doesn't include the parent layer
that had the secure flag, the screenshot request would not respect the
secure flag. This is incorrect because we want to ensure secure flag
remains on all children regardless of where in the hierarchy the
screenshot is taken.
Test: CaptureChildRespectsParentSecureFlag
Test: CaptureOffscreenChildRespectsParentSecureFlag
Test: LayerSnapshotTest#setSecureRootSnapshot
Bug: 308662081
Change-Id: I13f19a7fa4b9e51da0aa097314f015fe1340fc54
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 644b6ef..da2a6e0 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -8958,6 +8958,7 @@
.genericLayerMetadataKeyMap = getGenericLayerMetadataKeyMap(),
.skipRoundCornersWhenProtected =
!getRenderEngine().supportsProtectedContent()};
+ args.rootSnapshot.isSecure = mLayerLifecycleManager.isLayerSecure(rootLayerId);
mLayerSnapshotBuilder.update(args);
auto getLayerSnapshotsFn =