Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85fffa5a authored by Jon Eckenrode's avatar Jon Eckenrode Committed by Automerger Merge Worker
Browse files

Merge "Revised the API documentation for the getMediaProjection() method."...

Merge "Revised the API documentation for the getMediaProjection() method." into tm-dev am: 0cfcaa28

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18635346



Change-Id: I21ef9605f9f1ca61264997593bfaafa9ba1071dd
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c342eb60 0cfcaa28
Loading
Loading
Loading
Loading
+38 −23
Original line number Original line Diff line number Diff line
@@ -80,33 +80,48 @@ public final class MediaProjectionManager {
    }
    }


    /**
    /**
     * Retrieve the MediaProjection obtained from a succesful screen
     * Retrieves the {@link MediaProjection} obtained from a successful screen
     * capture request. Will be null if the result from the
     * capture request. The result code and data from the request are provided
     * startActivityForResult() is anything other than RESULT_OK.
     * by overriding {@link Activity#onActivityResult(int, int, Intent)
     * onActivityResult(int, int, Intent)}, which is called after starting an
     * activity using {@link #createScreenCaptureIntent()}.
     *
     *
     * Starting from Android {@link android.os.Build.VERSION_CODES#R}, if your application requests
     * <p>Starting from Android {@link android.os.Build.VERSION_CODES#R}, if
     * the {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission, and the
     * your application requests the
     * user has not explicitly denied it, the permission will be automatically granted until the
     * {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW
     * projection is stopped. This allows for user controls to be displayed on top of the screen
     * SYSTEM_ALERT_WINDOW} permission, and the user has not explicitly denied
     * being captured.
     * it, the permission will be automatically granted until the projection is
     * stopped. The permission allows your app to display user controls on top
     * of the screen being captured.
     *
     *
     * <p>
     * <p>Apps targeting SDK version {@link android.os.Build.VERSION_CODES#Q} or
     * Apps targeting SDK version {@link android.os.Build.VERSION_CODES#Q} or later should specify
     * later must set the
     * the foreground service type using the attribute {@link android.R.attr#foregroundServiceType}
     * {@link android.R.attr#foregroundServiceType foregroundServiceType}
     * in the service element of the app's manifest file.
     * attribute to {@code mediaProjection} in the
     * The {@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION} attribute
     * <a href="/guide/topics/manifest/service-element">
     * should be specified.
     * <code>&lt;service&gt;</code></a> element of the app's manifest file;
     * </p>
     * {@code mediaProjection} is equivalent to
     * {@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
     * FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION}.
     *
     *
     * @see <a href="https://developer.android.com/preview/privacy/foreground-service-types">
     * @see <a href="/guide/components/foreground-services">
     * Foregroud Service Types</a>
     *      Foreground services developer guide</a>
     * @see <a href="/guide/topics/large-screens/media-projection">
     *      Media projection developer guide</a>
     *
     *
     * @param resultCode The result code from {@link android.app.Activity#onActivityResult(int,
     * @param resultCode The result code from
     * int, android.content.Intent)}
     *      {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)
     * @param resultData The resulting data from {@link android.app.Activity#onActivityResult(int,
     *      onActivityResult(int, int, Intent)}.
     * int, android.content.Intent)}
     * @param resultData The result data from
     * @throws IllegalStateException on pre-Q devices if a previously gotten MediaProjection
     *      {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)
     * from the same {@code resultData} has not yet been stopped
     *      onActivityResult(int, int, Intent)}.
     * @return The media projection obtained from a successful screen capture
     *      request, or null if the result of the screen capture request is not
     *      {@link Activity#RESULT_OK RESULT_OK}.
     * @throws IllegalStateException On
     *      pre-{@link android.os.Build.VERSION_CODES#Q Q} devices if a
     *      previously obtained {@code MediaProjection} from the same
     *      {@code resultData} has not yet been stopped.
     */
     */
    public MediaProjection getMediaProjection(int resultCode, @NonNull Intent resultData) {
    public MediaProjection getMediaProjection(int resultCode, @NonNull Intent resultData) {
        if (resultCode != Activity.RESULT_OK || resultData == null) {
        if (resultCode != Activity.RESULT_OK || resultData == null) {