diff options
| author | Jacky Kao <jackykao@google.com> | 2020-03-23 16:30:04 +0800 |
|---|---|---|
| committer | Jacky Kao <jackykao@google.com> | 2020-03-25 13:46:11 +0800 |
| commit | 316477c3995f020e036f53feebc6ce26b1fde9f0 (patch) | |
| tree | eac334a116db54aae9ac2bd81e7a24e1e3a83451 /core/java | |
| parent | 5c36c9551b28503a406390449426c896e653bcc8 (diff) | |
Supporting multi-display for takeScreenshot()
Creating a new API, screenshotWithoutSecureLayer(), to get the
graphic buffer of screenshot for all displays including non-default
display and virtual one. We can use it to support multi-display
of takeScreenshot() API.
Bug: 145893483
Test: a11y CTS & unit tests
Test: manual testing to take screenshot of second display which is a
monitor with chrome cast
Change-Id: I474c71f7e01d57b5a318b2a5bfb690a2e01c128c
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/accessibilityservice/AccessibilityService.java | 10 | ||||
| -rw-r--r-- | core/java/android/hardware/display/DisplayManagerInternal.java | 9 |
2 files changed, 9 insertions, 10 deletions
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java index f3759fd611df..d4f511280553 100644 --- a/core/java/android/accessibilityservice/AccessibilityService.java +++ b/core/java/android/accessibilityservice/AccessibilityService.java @@ -47,7 +47,6 @@ import android.util.Slog; import android.util.SparseArray; import android.view.Display; import android.view.KeyEvent; -import android.view.SurfaceControl; import android.view.SurfaceView; import android.view.WindowManager; import android.view.WindowManagerImpl; @@ -1981,8 +1980,6 @@ public abstract class AccessibilityService extends Service { * to declare the capability to take screenshot by setting the * {@link android.R.styleable#AccessibilityService_canTakeScreenshot} * property in its meta-data. For details refer to {@link #SERVICE_META_DATA}. - * This API only will support {@link Display#DEFAULT_DISPLAY} until {@link SurfaceControl} - * supports non-default displays. * </p> * * @param displayId The logic display id, must be {@link Display#DEFAULT_DISPLAY} for @@ -1990,18 +1987,11 @@ public abstract class AccessibilityService extends Service { * @param executor Executor on which to run the callback. * @param callback The callback invoked when taking screenshot has succeeded or failed. * See {@link TakeScreenshotCallback} for details. - * - * @throws IllegalArgumentException if displayId is not {@link Display#DEFAULT_DISPLAY}. */ public void takeScreenshot(int displayId, @NonNull @CallbackExecutor Executor executor, @NonNull TakeScreenshotCallback callback) { Preconditions.checkNotNull(executor, "executor cannot be null"); Preconditions.checkNotNull(callback, "callback cannot be null"); - - if (displayId != Display.DEFAULT_DISPLAY) { - throw new IllegalArgumentException("DisplayId isn't the default display"); - } - final IAccessibilityServiceConnection connection = AccessibilityInteractionClient.getInstance().getConnection( mConnectionId); diff --git a/core/java/android/hardware/display/DisplayManagerInternal.java b/core/java/android/hardware/display/DisplayManagerInternal.java index ea2b9e79d99c..571537c3cc22 100644 --- a/core/java/android/hardware/display/DisplayManagerInternal.java +++ b/core/java/android/hardware/display/DisplayManagerInternal.java @@ -72,6 +72,15 @@ public abstract class DisplayManagerInternal { public abstract SurfaceControl.ScreenshotGraphicBuffer screenshot(int displayId); /** + * Take a screenshot without secure layer of the specified display and return a buffer. + * + * @param displayId The display id to take the screenshot of. + * @return The buffer or null if we have failed. + */ + public abstract SurfaceControl.ScreenshotGraphicBuffer screenshotWithoutSecureLayer( + int displayId); + + /** * Returns information about the specified logical display. * * @param displayId The logical display id. |
