From f54df24a2522d5db6c7036d8018cf86f91bfb045 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Mon, 23 Mar 2020 14:18:25 -0400 Subject: [PATCH] BRD: Correct @NonNull annotation Bug: 140600285 Test: Ifd9e9abe3f2c89f724a0b918d99ec4e9db65ad56 After adding some tests, I confirmed that newInstance(InputStream) (and the deprecated version that includes boolean isShareable) can return null if the InputStream is null. Update the annotations for both - the old one that has always been wrong, and the new one added in I0bf8c4c72cc118d2799a59e8eb6c2cede546fceb. Change-Id: Ib820edd1ad62665092c272a7b89b0a29b0e1bb32 --- api/current.txt | 4 ++-- graphics/java/android/graphics/BitmapRegionDecoder.java | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index f6a0d02aaea90..298c27c7cd7e5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -14190,8 +14190,8 @@ package android.graphics { method @NonNull public static android.graphics.BitmapRegionDecoder newInstance(@NonNull byte[], int, int) throws java.io.IOException; method @Deprecated @NonNull public static android.graphics.BitmapRegionDecoder newInstance(@NonNull java.io.FileDescriptor, boolean) throws java.io.IOException; method @NonNull public static android.graphics.BitmapRegionDecoder newInstance(@NonNull android.os.ParcelFileDescriptor) throws java.io.IOException; - method @Deprecated @NonNull public static android.graphics.BitmapRegionDecoder newInstance(@NonNull java.io.InputStream, boolean) throws java.io.IOException; - method @NonNull public static android.graphics.BitmapRegionDecoder newInstance(@NonNull java.io.InputStream) throws java.io.IOException; + method @Deprecated @Nullable public static android.graphics.BitmapRegionDecoder newInstance(@NonNull java.io.InputStream, boolean) throws java.io.IOException; + method @Nullable public static android.graphics.BitmapRegionDecoder newInstance(@NonNull java.io.InputStream) throws java.io.IOException; method @Deprecated @NonNull public static android.graphics.BitmapRegionDecoder newInstance(@NonNull String, boolean) throws java.io.IOException; method @NonNull public static android.graphics.BitmapRegionDecoder newInstance(@NonNull String) throws java.io.IOException; method public void recycle(); diff --git a/graphics/java/android/graphics/BitmapRegionDecoder.java b/graphics/java/android/graphics/BitmapRegionDecoder.java index 4e1c5b0efea29..29112af9516b4 100644 --- a/graphics/java/android/graphics/BitmapRegionDecoder.java +++ b/graphics/java/android/graphics/BitmapRegionDecoder.java @@ -16,6 +16,7 @@ package android.graphics; import android.annotation.NonNull; +import android.annotation.Nullable; import android.compat.annotation.UnsupportedAppUsage; import android.content.res.AssetManager; import android.os.Build; @@ -125,6 +126,7 @@ public final class BitmapRegionDecoder { * @param is The input stream that holds the raw data to be decoded into a * BitmapRegionDecoder. * @param isShareable This field has always been ignored. + * @return A new BitmapRegionDecoder, or {@code null} if {@code is} is {@code null}. * @throws IOException if the image format is not supported or can not be decoded. * @deprecated In favor of {@link #newInstance(InputStream)} * @@ -134,7 +136,7 @@ public final class BitmapRegionDecoder { * {@link Build.VERSION_CODES#KITKAT}, this is no longer the case.

*/ @Deprecated - @NonNull + @Nullable public static BitmapRegionDecoder newInstance(@NonNull InputStream is, boolean isShareable) throws IOException { return newInstance(is); @@ -148,9 +150,10 @@ public final class BitmapRegionDecoder { * * @param is The input stream that holds the raw data to be decoded into a * BitmapRegionDecoder. + * @return A new BitmapRegionDecoder, or {@code null} if {@code is} is {@code null}. * @throws IOException if the image format is not supported or can not be decoded. */ - @NonNull + @Nullable public static BitmapRegionDecoder newInstance(@NonNull InputStream is) throws IOException { if (is instanceof AssetManager.AssetInputStream) { return nativeNewInstance(