Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a23b4d37 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

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
parent 4960efea
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -494,15 +494,22 @@ public final class Icon implements Parcelable {
            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;
        }