Merge "[MediaProjection] Clarify createVirtualDisplay exception javadoc" into udc-dev am: 057c1e7c20
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23727947 Change-Id: I977cbce7d4db66f331307f1eb5462a1c60f303cf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -171,25 +171,30 @@ public final class MediaProjection {
|
|||||||
* @param handler The {@link android.os.Handler} on which the callback should be invoked, or
|
* @param handler The {@link android.os.Handler} on which the callback should be invoked, or
|
||||||
* null if the callback should be invoked on the calling thread's main
|
* null if the callback should be invoked on the calling thread's main
|
||||||
* {@link android.os.Looper}.
|
* {@link android.os.Looper}.
|
||||||
* @throws IllegalStateException In the following scenarios, if the target SDK is {@link
|
* @throws IllegalStateException If the target SDK is {@link
|
||||||
* android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE U} and up:
|
* android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE U} and up, and
|
||||||
|
* if no {@link Callback} is registered.
|
||||||
|
* @throws SecurityException In any of the following scenarios:
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>If no {@link Callback} is registered.</li>
|
* <li>If attempting to create a new virtual display
|
||||||
* <li>If {@link MediaProjectionManager#getMediaProjection}
|
* associated with this MediaProjection instance after it has
|
||||||
|
* been stopped by invoking {@link #stop()}.
|
||||||
|
* <li>If the target SDK is {@link
|
||||||
|
* android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE U} and up,
|
||||||
|
* and if this instance has already taken a recording through
|
||||||
|
* {@code #createVirtualDisplay}, but {@link #stop()} wasn't
|
||||||
|
* invoked to end the recording.
|
||||||
|
* <li>If the target SDK is {@link
|
||||||
|
* android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE U} and up,
|
||||||
|
* and if {@link MediaProjectionManager#getMediaProjection}
|
||||||
* was invoked more than once to get this
|
* was invoked more than once to get this
|
||||||
* {@code MediaProjection} instance.
|
* {@code MediaProjection} instance.
|
||||||
* <li>If this instance has already taken a recording through
|
|
||||||
* {@code #createVirtualDisplay}.
|
|
||||||
* </ol>
|
* </ol>
|
||||||
* However, if the target SDK is less than
|
* In cases 2 & 3, no exception is thrown if the target SDK is
|
||||||
* {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE U}, no
|
* less than
|
||||||
* exception is thrown. In case 1, recording begins even without
|
* {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE U}.
|
||||||
* the callback. In case 2 & 3, recording doesn't begin
|
* Instead, recording doesn't begin until the user re-grants
|
||||||
* until the user re-grants consent in the dialog.
|
* consent in the dialog.
|
||||||
* @throws SecurityException If attempting to create a new virtual display associated with this
|
|
||||||
* MediaProjection instance after it has been stopped by invoking
|
|
||||||
* {@link #stop()}.
|
|
||||||
*
|
|
||||||
* @see VirtualDisplay
|
* @see VirtualDisplay
|
||||||
* @see VirtualDisplay.Callback
|
* @see VirtualDisplay.Callback
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1078,7 +1078,7 @@ public final class MediaProjectionManagerService extends SystemService
|
|||||||
// Tear down projection here; necessary to ensure (among other reasons) that
|
// Tear down projection here; necessary to ensure (among other reasons) that
|
||||||
// stop is dispatched to client and cast icon disappears from status bar.
|
// stop is dispatched to client and cast icon disappears from status bar.
|
||||||
mProjectionGrant.stop();
|
mProjectionGrant.stop();
|
||||||
throw new IllegalStateException("Don't re-use the resultData to retrieve "
|
throw new SecurityException("Don't re-use the resultData to retrieve "
|
||||||
+ "the same projection instance, and don't use a token that has "
|
+ "the same projection instance, and don't use a token that has "
|
||||||
+ "timed out. Don't take multiple captures by invoking "
|
+ "timed out. Don't take multiple captures by invoking "
|
||||||
+ "MediaProjection#createVirtualDisplay multiple times on the "
|
+ "MediaProjection#createVirtualDisplay multiple times on the "
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ public class MediaProjectionManagerServiceTest {
|
|||||||
// Second start - so not valid.
|
// Second start - so not valid.
|
||||||
projection.start(mIMediaProjectionCallback);
|
projection.start(mIMediaProjectionCallback);
|
||||||
|
|
||||||
assertThrows(IllegalStateException.class, projection::isValid);
|
assertThrows(SecurityException.class, projection::isValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(269273190): Test flag using compat annotations instead.
|
// TODO(269273190): Test flag using compat annotations instead.
|
||||||
|
|||||||
Reference in New Issue
Block a user