Fix region sampling for secure layers
We were swapping a couple of boolean params when requesting
screenshots for region sampling, breaking region sampling for
secure layers in the process. Fix this by passing flags instead of
booleans in a long list of arguments and add a test to verify the
code path.
FLAG: EXEMPT bugfix
Fixes: 348944802
Test: presubmit
Change-Id: I58f12e5cf81cb59115c1b9c500ac1e18a8ec72e5
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5b40acf..13a1464 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -7958,10 +7958,13 @@
GetLayerSnapshotsFunction getLayerSnapshotsFn =
getLayerSnapshotsForScreenshots(layerStack, args.uid, std::move(excludeLayerIds));
+ ftl::Flags<RenderArea::Options> options;
+ if (args.captureSecureLayers) options |= RenderArea::Options::CAPTURE_SECURE_LAYERS;
+ if (args.hintForSeamlessTransition)
+ options |= RenderArea::Options::HINT_FOR_SEAMLESS_TRANSITION;
captureScreenCommon(RenderAreaBuilderVariant(std::in_place_type<DisplayRenderAreaBuilder>,
args.sourceCrop, reqSize, args.dataspace,
- args.hintForSeamlessTransition,
- args.captureSecureLayers, displayWeak),
+ displayWeak, options),
getLayerSnapshotsFn, reqSize, args.pixelFormat, args.allowProtected,
args.grayscale, captureListener);
}
@@ -8012,10 +8015,12 @@
constexpr bool kAllowProtected = false;
constexpr bool kGrayscale = false;
+ ftl::Flags<RenderArea::Options> options;
+ if (args.hintForSeamlessTransition)
+ options |= RenderArea::Options::HINT_FOR_SEAMLESS_TRANSITION;
captureScreenCommon(RenderAreaBuilderVariant(std::in_place_type<DisplayRenderAreaBuilder>,
- Rect(), size, args.dataspace,
- args.hintForSeamlessTransition,
- false /* captureSecureLayers */, displayWeak),
+ Rect(), size, args.dataspace, displayWeak,
+ options),
getLayerSnapshotsFn, size, args.pixelFormat, kAllowProtected, kGrayscale,
captureListener);
}
@@ -8114,10 +8119,13 @@
return;
}
+ ftl::Flags<RenderArea::Options> options;
+ if (args.captureSecureLayers) options |= RenderArea::Options::CAPTURE_SECURE_LAYERS;
+ if (args.hintForSeamlessTransition)
+ options |= RenderArea::Options::HINT_FOR_SEAMLESS_TRANSITION;
captureScreenCommon(RenderAreaBuilderVariant(std::in_place_type<LayerRenderAreaBuilder>, crop,
- reqSize, dataspace, args.captureSecureLayers,
- args.hintForSeamlessTransition, parent,
- args.childrenOnly),
+ reqSize, dataspace, parent, args.childrenOnly,
+ options),
getLayerSnapshotsFn, reqSize, args.pixelFormat, args.allowProtected,
args.grayscale, captureListener);
}