Added captureScreen function for displayId or layerStack
Previously, screencap shell command could accept a display id as an argument.
It would use the id to look up information about the display (displayToken,
orientation, colorMode) by making requests into SurfaceFlinger. Since those
requests only worked for physical display ids, screencap didn't work to capture
virtual displays.
Instead of adding new methods to look up display information for a virtual
display, this change just adds a new captureScreen function in SurfaceFlinger
that accepts a displayId or layerStack and handles getting the default info
for the requested display. This works for both physical and virtual displays.
Test: adb shell screencap -d <layerStack for virt display>
Fixes: 130974213
Change-Id: I24b7558c973a057414c6b4f81ab1d60152fff38d
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 437cdd7..5d4367d 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -1572,6 +1572,13 @@
useIdentityTransform, rotation, false, outBuffer, ignored);
}
+status_t ScreenshotClient::capture(uint64_t displayOrLayerStack, ui::Dataspace* outDataspace,
+ sp<GraphicBuffer>* outBuffer) {
+ sp<ISurfaceComposer> s(ComposerService::getComposerService());
+ if (s == nullptr) return NO_INIT;
+ return s->captureScreen(displayOrLayerStack, outDataspace, outBuffer);
+}
+
status_t ScreenshotClient::captureLayers(const sp<IBinder>& layerHandle,
const ui::Dataspace reqDataSpace,
const ui::PixelFormat reqPixelFormat, Rect sourceCrop,