From 24b3dcb40c043f21d0e3fd612a7692e71bc70979 Mon Sep 17 00:00:00 2001 From: Chavi Weingarten Date: Fri, 1 Jul 2022 15:58:52 +0000 Subject: [PATCH] Make UiAutomation#takeScreenshot(Window) public This API is useful when trying to take a screenshot of a window instead of the entire display. It allows the screenshot to ignore anything else on screen, except the specified window. Test: ASurfaceControlTestActivity Fixes: 237681925 Change-Id: Idc08af39645f572ead4fc191d7f26970813241e2 --- core/api/current.txt | 1 + core/api/test-current.txt | 1 - core/java/android/app/UiAutomation.java | 3 --- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 75fcc60080c1e..3575371342381 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -7050,6 +7050,7 @@ package android.app { method public void setRunAsMonkey(boolean); method public void setServiceInfo(android.accessibilityservice.AccessibilityServiceInfo); method public android.graphics.Bitmap takeScreenshot(); + method @Nullable public android.graphics.Bitmap takeScreenshot(@NonNull android.view.Window); method public void waitForIdle(long, long) throws java.util.concurrent.TimeoutException; field public static final int FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES = 1; // 0x1 field public static final int FLAG_DONT_USE_ACCESSIBILITY = 2; // 0x2 diff --git a/core/api/test-current.txt b/core/api/test-current.txt index b1d458cc1746d..7d41bc77ee4bd 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -438,7 +438,6 @@ package android.app { method @Deprecated public boolean revokeRuntimePermission(String, String, android.os.UserHandle); method public void syncInputTransactions(); method public void syncInputTransactions(boolean); - method @Nullable public android.graphics.Bitmap takeScreenshot(@NonNull android.view.Window); field @NonNull public static final java.util.Set ALL_PERMISSIONS; } diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java index ac6759396c8f8..ad7c53b0050d6 100644 --- a/core/java/android/app/UiAutomation.java +++ b/core/java/android/app/UiAutomation.java @@ -1068,10 +1068,7 @@ public final class UiAutomation { * @param window Window to take a screenshot of * * @return The screenshot bitmap on success, null otherwise. - * - * @hide */ - @TestApi @Nullable public Bitmap takeScreenshot(@NonNull Window window) { if (window == null) {