From 80bb00b977643e8f7c7f0b30d671d3a30e9e99ff Mon Sep 17 00:00:00 2001 From: chaviw Date: Tue, 4 May 2021 14:32:48 -0500 Subject: [PATCH] Capture layer and children when calling takeSurfaceControlScreenshot When calling UiAutomationConnection.takeSurfaceControlScreenshot, it should capture the requested SurfaceControl and its children. The current code only captures the children. Therefore, call setChildrenOnly with false to ensure it captures the parent, as well. Test: ASurfaceControlTest Bug: 185390632 Change-Id: I62707f808934177c8db05485ac28559982b8c607 --- core/java/android/app/UiAutomationConnection.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java index e693c5ea6c935..e016027329ac9 100644 --- a/core/java/android/app/UiAutomationConnection.java +++ b/core/java/android/app/UiAutomationConnection.java @@ -220,7 +220,9 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub { final long identity = Binder.clearCallingIdentity(); try { captureBuffer = SurfaceControl.captureLayers( - new SurfaceControl.LayerCaptureArgs.Builder(surfaceControl).build()); + new SurfaceControl.LayerCaptureArgs.Builder(surfaceControl) + .setChildrenOnly(false) + .build()); } finally { Binder.restoreCallingIdentity(identity); }