Icon: log when BitmapFactory.decodeStream fails
When an app passes an invalid icon into a BigPictureStyle notification,
we want to know clearly and promptly, so log when we see those icon
loads fail.
Bug: 335878768
Flag: NONE
Test: manual
Change-Id: Ia9e72a64c0070fde71cac1519953210a0125c9bc
diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java
index f359025..ed15258 100644
--- a/graphics/java/android/graphics/drawable/Icon.java
+++ b/graphics/java/android/graphics/drawable/Icon.java
@@ -494,15 +494,22 @@
case TYPE_URI:
InputStream is = getUriInputStream(context);
if (is != null) {
- return new BitmapDrawable(context.getResources(),
- fixMaxBitmapSize(BitmapFactory.decodeStream(is)));
+ final Bitmap bitmap = BitmapFactory.decodeStream(is);
+ if (bitmap == null) {
+ Log.w(TAG, "Unable to decode image from URI: " + getUriString());
+ }
+ return new BitmapDrawable(context.getResources(), fixMaxBitmapSize(bitmap));
}
break;
case TYPE_URI_ADAPTIVE_BITMAP:
is = getUriInputStream(context);
if (is != null) {
+ final Bitmap bitmap = BitmapFactory.decodeStream(is);
+ if (bitmap == null) {
+ Log.w(TAG, "Unable to decode image from URI: " + getUriString());
+ }
return new AdaptiveIconDrawable(null, new BitmapDrawable(context.getResources(),
- fixMaxBitmapSize(BitmapFactory.decodeStream(is))));
+ fixMaxBitmapSize(bitmap)));
}
break;
}