Make OreoDecoder nullsafe
@@ -14,11 +14,13 @@ import android.os.Build;
import androidx.core.util.Pools.SynchronizedPool;
import com.facebook.imagepipeline.memory.BitmapPool;
import com.facebook.imageutils.BitmapUtil;
+import com.facebook.infer.annotation.Nullsafe;
import javax.annotation.concurrent.ThreadSafe;
/** Bitmap decoder for ART VM (Android O and up). */
@TargetApi(Build.VERSION_CODES.O)
@ThreadSafe
+@Nullsafe(Nullsafe.Mode.LOCAL)
public class OreoDecoder extends DefaultDecoder {
public OreoDecoder(BitmapPool bitmapPool, int maxNumThreads, SynchronizedPool decodeBuffers) {
@@ -32,7 +34,12 @@ public class OreoDecoder extends DefaultDecoder {
// needs to be computed manually to get the correct size.
return hasColorGamutMismatch(options)
? width * height * 8
- : BitmapUtil.getSizeInByteForBitmap(width, height, options.inPreferredConfig);
+ : BitmapUtil.getSizeInByteForBitmap(
+ width,
+ height,
+ options.inPreferredConfig != null
+ ? options.inPreferredConfig
+ : Bitmap.Config.ARGB_8888);
}
/** Check if the color space has a wide color gamut and is consistent with the Bitmap config */
