diff options
| author | chaviw <chaviw@google.com> | 2020-04-21 12:55:37 -0700 |
|---|---|---|
| committer | Chavi Weingarten <chaviw@google.com> | 2020-04-27 16:45:27 +0000 |
| commit | 5ef1e9367110001abf55d54caabaea4eb7f7be43 (patch) | |
| tree | 356fd6d662528f51063b65e27c3ff0bff86b9652 /core/java/android/window/WindowOrganizer.java | |
| parent | 9d07e62689bef121e9648178700224f04c8399e4 (diff) | |
Added takeScreenshot API to WindowOrganizer
Added requests to take screenshot of a Window that's organized
by the client. The resulting screenshot will be attached to a
SurfaceControl and reparented to the requested window's parent. The
client will be responsible for showing, setting z order, etc. They can
also re-parent to another place in the hierarchy. The default is to
parent to the window's parent since that's usually where a screenshot is
placed.
Test: Builds
Bug: 152114574
Change-Id: I5c829e029f3528fdb382842e9f0474097e01cb2e
Merged-In: I5c829e029f3528fdb382842e9f0474097e01cb2e
Diffstat (limited to 'core/java/android/window/WindowOrganizer.java')
| -rw-r--r-- | core/java/android/window/WindowOrganizer.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/window/WindowOrganizer.java b/core/java/android/window/WindowOrganizer.java index 457827117f86..ff40ddac134e 100644 --- a/core/java/android/window/WindowOrganizer.java +++ b/core/java/android/window/WindowOrganizer.java @@ -17,11 +17,13 @@ package android.window; import android.annotation.NonNull; +import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.TestApi; import android.app.ActivityTaskManager; import android.os.RemoteException; import android.util.Singleton; +import android.view.SurfaceControl; /** * Base class for organizing specific types of windows like Tasks and DisplayAreas @@ -63,6 +65,28 @@ public class WindowOrganizer { } } + /** + * Take a screenshot for a specified Window + * @param token The token for the WindowContainer that should get a screenshot taken. + * @return A SurfaceControl where the screenshot will be attached, or null if failed. + * + * @hide + */ + @Nullable + @RequiresPermission(android.Manifest.permission.READ_FRAME_BUFFER) + public static SurfaceControl takeScreenshot(@NonNull WindowContainerToken token) { + try { + SurfaceControl surfaceControl = new SurfaceControl(); + if (getWindowOrganizerController().takeScreenshot(token, surfaceControl)) { + return surfaceControl; + } else { + return null; + } + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) static IWindowOrganizerController getWindowOrganizerController() { return IWindowOrganizerControllerSingleton.get(); |
