Loading core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -25464,6 +25464,7 @@ package android.media.projection { public abstract static class MediaProjection.Callback { ctor public MediaProjection.Callback(); method public void onCapturedContentResize(int, int); method public void onStop(); } data/etc/services.core.protolog.json +12 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,12 @@ "group": "WM_ERROR", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, "-1944652783": { "message": "Unable to tell MediaProjectionManagerService to stop the active projection: %s", "level": "ERROR", "group": "WM_DEBUG_CONTENT_RECORDING", "at": "com\/android\/server\/wm\/ContentRecorder.java" }, "-1941440781": { "message": "Creating Pending Move-to-back: %s", "level": "VERBOSE", Loading Loading @@ -715,6 +721,12 @@ "group": "WM_DEBUG_ADD_REMOVE", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, "-1423223548": { "message": "Unable to tell MediaProjectionManagerService about resizing the active projection: %s", "level": "ERROR", "group": "WM_DEBUG_CONTENT_RECORDING", "at": "com\/android\/server\/wm\/ContentRecorder.java" }, "-1421296808": { "message": "Moving to RESUMED: %s (in existing)", "level": "VERBOSE", Loading media/java/android/media/projection/IMediaProjectionCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -19,4 +19,5 @@ package android.media.projection; /** {@hide} */ oneway interface IMediaProjectionCallback { void onStop(); void onCapturedContentResize(int width, int height); } media/java/android/media/projection/IMediaProjectionManager.aidl +20 −0 Original line number Diff line number Diff line Loading @@ -27,12 +27,32 @@ import android.view.ContentRecordingSession; interface IMediaProjectionManager { @UnsupportedAppUsage boolean hasProjectionPermission(int uid, String packageName); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") IMediaProjection createProjection(int uid, String packageName, int type, boolean permanentGrant); boolean isValidMediaProjection(IMediaProjection projection); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") MediaProjectionInfo getActiveProjectionInfo(); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void stopActiveProjection(); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void notifyActiveProjectionCapturedContentResized(int width, int height); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void addCallback(IMediaProjectionWatcherCallback callback); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void removeCallback(IMediaProjectionWatcherCallback callback); /** Loading media/java/android/media/projection/MediaProjection.java +52 −1 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ public final class MediaProjection { /** * Callbacks for the projection session. */ public static abstract class Callback { public abstract static class Callback { /** * Called when the MediaProjection session is no longer valid. * <p> Loading @@ -243,6 +243,46 @@ public final class MediaProjection { * </p> */ public void onStop() { } /** * Indicates the width and height of the captured region in pixels. Called immediately after * capture begins to provide the app with accurate sizing for the stream. Also called * when the region captured in this MediaProjection session is resized. * <p> * The given width and height, in pixels, corresponds to the same width and height that * would be returned from {@link android.view.WindowMetrics#getBounds()} * </p> * <p> * Without the application resizing the {@link VirtualDisplay} (returned from * {@code MediaProjection#createVirtualDisplay}) and output {@link Surface} (provided * to {@code MediaProjection#createVirtualDisplay}), the captured stream will have * letterboxing (black bars) around the recorded content to make up for the * difference in aspect ratio. * </p> * <p> * The application can prevent the letterboxing by overriding this method, and * updating the size of both the {@link VirtualDisplay} and output {@link Surface}: * </p> * * <pre> * @Override * public String onCapturedContentResize(int width, int height) { * // VirtualDisplay instance from MediaProjection#createVirtualDisplay * virtualDisplay.resize(width, height, dpi); * * // Create a new Surface with the updated size (depending on the application's use * // case, this may be through different APIs - see Surface documentation for * // options). * int texName; // the OpenGL texture object name * SurfaceTexture surfaceTexture = new SurfaceTexture(texName); * surfaceTexture.setDefaultBufferSize(width, height); * Surface surface = new Surface(surfaceTexture); * * // Ensure the VirtualDisplay has the updated Surface to send the capture to. * virtualDisplay.setSurface(surface); * }</pre> */ public void onCapturedContentResize(int width, int height) { } } private final class MediaProjectionCallback extends IMediaProjectionCallback.Stub { Loading @@ -252,6 +292,13 @@ public final class MediaProjection { cbr.onStop(); } } @Override public void onCapturedContentResize(int width, int height) { for (CallbackRecord cbr : mCallbacks.values()) { cbr.onCapturedContentResize(width, height); } } } private final static class CallbackRecord { Loading @@ -271,5 +318,9 @@ public final class MediaProjection { } }); } public void onCapturedContentResize(int width, int height) { mHandler.post(() -> mCallback.onCapturedContentResize(width, height)); } } } Loading
core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -25464,6 +25464,7 @@ package android.media.projection { public abstract static class MediaProjection.Callback { ctor public MediaProjection.Callback(); method public void onCapturedContentResize(int, int); method public void onStop(); }
data/etc/services.core.protolog.json +12 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,12 @@ "group": "WM_ERROR", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, "-1944652783": { "message": "Unable to tell MediaProjectionManagerService to stop the active projection: %s", "level": "ERROR", "group": "WM_DEBUG_CONTENT_RECORDING", "at": "com\/android\/server\/wm\/ContentRecorder.java" }, "-1941440781": { "message": "Creating Pending Move-to-back: %s", "level": "VERBOSE", Loading Loading @@ -715,6 +721,12 @@ "group": "WM_DEBUG_ADD_REMOVE", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, "-1423223548": { "message": "Unable to tell MediaProjectionManagerService about resizing the active projection: %s", "level": "ERROR", "group": "WM_DEBUG_CONTENT_RECORDING", "at": "com\/android\/server\/wm\/ContentRecorder.java" }, "-1421296808": { "message": "Moving to RESUMED: %s (in existing)", "level": "VERBOSE", Loading
media/java/android/media/projection/IMediaProjectionCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -19,4 +19,5 @@ package android.media.projection; /** {@hide} */ oneway interface IMediaProjectionCallback { void onStop(); void onCapturedContentResize(int width, int height); }
media/java/android/media/projection/IMediaProjectionManager.aidl +20 −0 Original line number Diff line number Diff line Loading @@ -27,12 +27,32 @@ import android.view.ContentRecordingSession; interface IMediaProjectionManager { @UnsupportedAppUsage boolean hasProjectionPermission(int uid, String packageName); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") IMediaProjection createProjection(int uid, String packageName, int type, boolean permanentGrant); boolean isValidMediaProjection(IMediaProjection projection); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") MediaProjectionInfo getActiveProjectionInfo(); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void stopActiveProjection(); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void notifyActiveProjectionCapturedContentResized(int width, int height); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void addCallback(IMediaProjectionWatcherCallback callback); @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" + ".permission.MANAGE_MEDIA_PROJECTION)") void removeCallback(IMediaProjectionWatcherCallback callback); /** Loading
media/java/android/media/projection/MediaProjection.java +52 −1 Original line number Diff line number Diff line Loading @@ -234,7 +234,7 @@ public final class MediaProjection { /** * Callbacks for the projection session. */ public static abstract class Callback { public abstract static class Callback { /** * Called when the MediaProjection session is no longer valid. * <p> Loading @@ -243,6 +243,46 @@ public final class MediaProjection { * </p> */ public void onStop() { } /** * Indicates the width and height of the captured region in pixels. Called immediately after * capture begins to provide the app with accurate sizing for the stream. Also called * when the region captured in this MediaProjection session is resized. * <p> * The given width and height, in pixels, corresponds to the same width and height that * would be returned from {@link android.view.WindowMetrics#getBounds()} * </p> * <p> * Without the application resizing the {@link VirtualDisplay} (returned from * {@code MediaProjection#createVirtualDisplay}) and output {@link Surface} (provided * to {@code MediaProjection#createVirtualDisplay}), the captured stream will have * letterboxing (black bars) around the recorded content to make up for the * difference in aspect ratio. * </p> * <p> * The application can prevent the letterboxing by overriding this method, and * updating the size of both the {@link VirtualDisplay} and output {@link Surface}: * </p> * * <pre> * @Override * public String onCapturedContentResize(int width, int height) { * // VirtualDisplay instance from MediaProjection#createVirtualDisplay * virtualDisplay.resize(width, height, dpi); * * // Create a new Surface with the updated size (depending on the application's use * // case, this may be through different APIs - see Surface documentation for * // options). * int texName; // the OpenGL texture object name * SurfaceTexture surfaceTexture = new SurfaceTexture(texName); * surfaceTexture.setDefaultBufferSize(width, height); * Surface surface = new Surface(surfaceTexture); * * // Ensure the VirtualDisplay has the updated Surface to send the capture to. * virtualDisplay.setSurface(surface); * }</pre> */ public void onCapturedContentResize(int width, int height) { } } private final class MediaProjectionCallback extends IMediaProjectionCallback.Stub { Loading @@ -252,6 +292,13 @@ public final class MediaProjection { cbr.onStop(); } } @Override public void onCapturedContentResize(int width, int height) { for (CallbackRecord cbr : mCallbacks.values()) { cbr.onCapturedContentResize(width, height); } } } private final static class CallbackRecord { Loading @@ -271,5 +318,9 @@ public final class MediaProjection { } }); } public void onCapturedContentResize(int width, int height) { mHandler.post(() -> mCallback.onCapturedContentResize(width, height)); } } }