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

Commit 8d018fce authored by Julia Tuttle's avatar Julia Tuttle
Browse files

BigPictureStyle: log when Icon.loadDrawable returns empty BitmapDrawable

Right now, if Icon.loadDrawable fails to decode the image file at the
end of an Icon URI, it returns a non-null BitmapDrawable with a null
Bitmap. I'm fixing this elsewhere, but in the meantime, log this as an
error.

Bug: 335878768
Flag: NONE only adds log messages
Test: manual
Change-Id: I69a75994dea55f4df88557bd693d7d14f1125c9d
parent 1e5e9b7b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
import android.annotation.StyleRes;
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri;
@@ -119,6 +120,17 @@ public class BigPictureNotificationImageView extends ImageView implements
        return () -> setImageDrawable(drawable);
    }

    @Override
    public void setImageDrawable(@Nullable Drawable drawable) {
        if (drawable instanceof BitmapDrawable bitmapDrawable) {
            if (bitmapDrawable.getBitmap() == null) {
                Log.e(TAG, "setting BitmapDrawable with null Bitmap (invalid image file?)");
            }
        }

        super.setImageDrawable(drawable);
    }

    private Drawable loadImage(Uri uri) {
        if (uri == null) return null;
        return LocalImageResolver.resolveImage(uri, mContext, mMaximumDrawableWidth,