From 3328535d0dd5c45a9cb86e56d0757d106dfb2771 Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Wed, 16 Oct 2019 10:11:09 -0700 Subject: [PATCH] Add @Nullable to MediaMetadataRetriever methods Add @Nullable to methods that could return null. bug: 142785055 Change-Id: Ia1694f71b7fd782dc919671cce2c7f709bbe790c --- api/current.txt | 28 +++++++++---------- .../android/media/MediaMetadataRetriever.java | 28 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/api/current.txt b/api/current.txt index b17667531b043..a3b72e1cf7942 100644 --- a/api/current.txt +++ b/api/current.txt @@ -25419,22 +25419,22 @@ package android.media { public class MediaMetadataRetriever implements java.lang.AutoCloseable { ctor public MediaMetadataRetriever(); method public void close(); - method public String extractMetadata(int); - method public byte[] getEmbeddedPicture(); - method public android.graphics.Bitmap getFrameAtIndex(int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); - method public android.graphics.Bitmap getFrameAtIndex(int); - method public android.graphics.Bitmap getFrameAtTime(long, int); - method public android.graphics.Bitmap getFrameAtTime(long, int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); - method public android.graphics.Bitmap getFrameAtTime(long); - method public android.graphics.Bitmap getFrameAtTime(); + method @Nullable public String extractMetadata(int); + method @Nullable public byte[] getEmbeddedPicture(); + method @Nullable public android.graphics.Bitmap getFrameAtIndex(int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); + method @Nullable public android.graphics.Bitmap getFrameAtIndex(int); + method @Nullable public android.graphics.Bitmap getFrameAtTime(long, int); + method @Nullable public android.graphics.Bitmap getFrameAtTime(long, int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); + method @Nullable public android.graphics.Bitmap getFrameAtTime(long); + method @Nullable public android.graphics.Bitmap getFrameAtTime(); method @NonNull public java.util.List getFramesAtIndex(int, int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); method @NonNull public java.util.List getFramesAtIndex(int, int); - method public android.graphics.Bitmap getImageAtIndex(int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); - method public android.graphics.Bitmap getImageAtIndex(int); - method public android.graphics.Bitmap getPrimaryImage(@NonNull android.media.MediaMetadataRetriever.BitmapParams); - method public android.graphics.Bitmap getPrimaryImage(); - method public android.graphics.Bitmap getScaledFrameAtTime(long, int, int, int); - method public android.graphics.Bitmap getScaledFrameAtTime(long, int, int, int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); + method @Nullable public android.graphics.Bitmap getImageAtIndex(int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); + method @Nullable public android.graphics.Bitmap getImageAtIndex(int); + method @Nullable public android.graphics.Bitmap getPrimaryImage(@NonNull android.media.MediaMetadataRetriever.BitmapParams); + method @Nullable public android.graphics.Bitmap getPrimaryImage(); + method @Nullable public android.graphics.Bitmap getScaledFrameAtTime(long, int, int, int); + method @Nullable public android.graphics.Bitmap getScaledFrameAtTime(long, int, int, int, @NonNull android.media.MediaMetadataRetriever.BitmapParams); method public void release(); method public void setDataSource(String) throws java.lang.IllegalArgumentException; method public void setDataSource(String, java.util.Map) throws java.lang.IllegalArgumentException; diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index 7ed431d4660d3..cc5ddeb49813d 100644 --- a/media/java/android/media/MediaMetadataRetriever.java +++ b/media/java/android/media/MediaMetadataRetriever.java @@ -224,7 +224,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @return The meta data value associate with the given keyCode on success; * null on failure. */ - public native String extractMetadata(int keyCode); + public native @Nullable String extractMetadata(int keyCode); /** * This method is similar to {@link #getFrameAtTime(long, int, BitmapParams)} @@ -255,7 +255,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * * @see {@link #getFrameAtTime(long, int, BitmapParams)} */ - public Bitmap getFrameAtTime(long timeUs, @Option int option) { + public @Nullable Bitmap getFrameAtTime(long timeUs, @Option int option) { if (option < OPTION_PREVIOUS_SYNC || option > OPTION_CLOSEST) { throw new IllegalArgumentException("Unsupported option: " + option); @@ -301,7 +301,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * * @see {@link #getFrameAtTime(long, int)} */ - public Bitmap getFrameAtTime( + public @Nullable Bitmap getFrameAtTime( long timeUs, @Option int option, @NonNull BitmapParams params) { if (option < OPTION_PREVIOUS_SYNC || option > OPTION_CLOSEST) { @@ -343,7 +343,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * is less than or equal to 0. * @see {@link #getScaledFrameAtTime(long, int, int, int, BitmapParams)} */ - public Bitmap getScaledFrameAtTime( + public @Nullable Bitmap getScaledFrameAtTime( long timeUs, @Option int option, int dstWidth, int dstHeight) { validate(option, dstWidth, dstHeight); return _getFrameAtTime(timeUs, option, dstWidth, dstHeight, null); @@ -388,7 +388,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * is less than or equal to 0. * @see {@link #getScaledFrameAtTime(long, int, int, int)} */ - public Bitmap getScaledFrameAtTime(long timeUs, @Option int option, + public @Nullable Bitmap getScaledFrameAtTime(long timeUs, @Option int option, int dstWidth, int dstHeight, @NonNull BitmapParams params) { validate(option, dstWidth, dstHeight); return _getFrameAtTime(timeUs, option, dstWidth, dstHeight, params); @@ -430,7 +430,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * * @see #getFrameAtTime(long, int) */ - public Bitmap getFrameAtTime(long timeUs) { + public @Nullable Bitmap getFrameAtTime(long timeUs) { return getFrameAtTime(timeUs, OPTION_CLOSEST_SYNC); } @@ -452,7 +452,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @see #getFrameAtTime(long) * @see #getFrameAtTime(long, int) */ - public Bitmap getFrameAtTime() { + public @Nullable Bitmap getFrameAtTime() { return _getFrameAtTime( -1, OPTION_CLOSEST_SYNC, -1 /*dst_width*/, -1 /*dst_height*/, null); } @@ -528,7 +528,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @see #getFramesAtIndex(int, int, BitmapParams) * @see #getFramesAtIndex(int, int) */ - public Bitmap getFrameAtIndex(int frameIndex, @NonNull BitmapParams params) { + public @Nullable Bitmap getFrameAtIndex(int frameIndex, @NonNull BitmapParams params) { List bitmaps = getFramesAtIndex(frameIndex, 1, params); return bitmaps.get(0); } @@ -550,7 +550,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @see #getFramesAtIndex(int, int, BitmapParams) * @see #getFramesAtIndex(int, int) */ - public Bitmap getFrameAtIndex(int frameIndex) { + public @Nullable Bitmap getFrameAtIndex(int frameIndex) { List bitmaps = getFramesAtIndex(frameIndex, 1); return bitmaps.get(0); } @@ -653,7 +653,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @see #getPrimaryImage(BitmapParams) * @see #getPrimaryImage() */ - public Bitmap getImageAtIndex(int imageIndex, @NonNull BitmapParams params) { + public @Nullable Bitmap getImageAtIndex(int imageIndex, @NonNull BitmapParams params) { return getImageAtIndexInternal(imageIndex, params); } @@ -691,7 +691,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @see #getPrimaryImage(BitmapParams) * @see #getPrimaryImage() */ - public Bitmap getImageAtIndex(int imageIndex) { + public @Nullable Bitmap getImageAtIndex(int imageIndex) { return getImageAtIndexInternal(imageIndex, null); } @@ -713,7 +713,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @see #getImageAtIndex(int) * @see #getPrimaryImage() */ - public Bitmap getPrimaryImage(@NonNull BitmapParams params) { + public @Nullable Bitmap getPrimaryImage(@NonNull BitmapParams params) { return getImageAtIndexInternal(-1, params); } @@ -729,7 +729,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * @see #getImageAtIndex(int) * @see #getPrimaryImage(BitmapParams) */ - public Bitmap getPrimaryImage() { + public @Nullable Bitmap getPrimaryImage() { return getImageAtIndexInternal(-1, null); } @@ -755,7 +755,7 @@ public class MediaMetadataRetriever implements AutoCloseable { * * @return null if no such graphic is found. */ - public byte[] getEmbeddedPicture() { + public @Nullable byte[] getEmbeddedPicture() { return getEmbeddedPicture(EMBEDDED_PICTURE_TYPE_ANY); }