From 5167ede2afc57b6114b09d4a854c8103b5161cd0 Mon Sep 17 00:00:00 2001 From: Hassan Shojania Date: Wed, 19 Apr 2017 12:27:05 -0700 Subject: [PATCH] MediaPlayer/ModularDrm API review: Document/runtime exception update Bug: 36790220 Bug: 37514763 Test: GTS tests Change-Id: I264f6cf66dd09e94720edcf22110240be61e9702 --- api/current.txt | 2 +- api/system-current.txt | 2 +- api/test-current.txt | 2 +- media/java/android/media/MediaPlayer.java | 24 ++++++++++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index 1098b781b3565..2e3507a4c6129 100644 --- a/api/current.txt +++ b/api/current.txt @@ -22803,7 +22803,7 @@ package android.media { method public deprecated void setAudioStreamType(int); method public void setAuxEffectSendLevel(float); method public void setDataSource(android.content.Context, android.net.Uri) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; - method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map, java.util.List) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; + method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map, java.util.List) throws java.io.IOException; method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(java.lang.String) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(android.content.res.AssetFileDescriptor) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException; diff --git a/api/system-current.txt b/api/system-current.txt index 5277ef083d4b3..584500bb59a99 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -24636,7 +24636,7 @@ package android.media { method public deprecated void setAudioStreamType(int); method public void setAuxEffectSendLevel(float); method public void setDataSource(android.content.Context, android.net.Uri) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; - method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map, java.util.List) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; + method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map, java.util.List) throws java.io.IOException; method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(java.lang.String) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(android.content.res.AssetFileDescriptor) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException; diff --git a/api/test-current.txt b/api/test-current.txt index 0d3de3824492d..01eea3241a050 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -22910,7 +22910,7 @@ package android.media { method public deprecated void setAudioStreamType(int); method public void setAuxEffectSendLevel(float); method public void setDataSource(android.content.Context, android.net.Uri) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; - method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map, java.util.List) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; + method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map, java.util.List) throws java.io.IOException; method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(java.lang.String) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(android.content.res.AssetFileDescriptor) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException; diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index d5efc971d1fd5..293ceea79523c 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -1010,6 +1010,8 @@ public class MediaPlayer extends PlayerBase * The headers must not include cookies. Instead, use the cookies param. * @param cookies the cookies to be sent together with the request * @throws IllegalStateException if it is called in an invalid state + * @throws NullPointerException if context or uri is null + * @throws IOException if uri has a file scheme and an I/O error occurs * *

Note that the cross domain redirection is allowed by default, * but that can be changed with key/value pairs through the headers parameter with @@ -1018,7 +1020,15 @@ public class MediaPlayer extends PlayerBase */ public void setDataSource(@NonNull Context context, @NonNull Uri uri, @Nullable Map headers, @Nullable List cookies) - throws IOException, IllegalArgumentException, SecurityException, IllegalStateException { + throws IOException { + if (context == null) { + throw new NullPointerException("context param can not be null."); + } + + if (uri == null) { + throw new NullPointerException("uri param can not be null."); + } + // The context and URI usually belong to the calling user. Get a resolver for that user // and strip out the userId from the URI if present. final ContentResolver resolver = context.getContentResolver(); @@ -4624,13 +4634,25 @@ public class MediaPlayer extends PlayerBase } // synchronized } + /** + * Encapsulates the DRM properties of the source. + */ public static final class DrmInfo { private Map mapPssh; private UUID[] supportedSchemes; + /** + * Returns the PSSH info of the data source for each supported DRM scheme. + */ public Map getPssh() { return mapPssh; } + + /** + * Returns the intersection of the data source and the device DRM schemes. + * It effectively identifies the subset of the source's DRM schemes which + * are supported by the device too. + */ public UUID[] getSupportedSchemes() { return supportedSchemes; }