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

Commit 9c7d70ef authored by Julia Tuttle's avatar Julia Tuttle
Browse files

ImageLoader: log when Icon.loadDrawable 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
Test: manual
Flag: NONE
Change-Id: Ib16356b29bdf2f288ef738bc24433db422b28782
parent ca660ce3
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -339,7 +339,7 @@ constructor(
                }
                // Fallback to non-ImageDecoder load if the attempt failed (e.g. the resource
                // is a Vector drawable which ImageDecoder doesn't support.)
                ?: icon.loadDrawable(context)
                ?: loadIconDrawable(icon, context)
            }
            Icon.TYPE_BITMAP -> {
                BitmapDrawable(context.resources, icon.bitmap)
@@ -357,7 +357,7 @@ constructor(
            }
            else -> {
                // We don't recognize this icon, just fallback.
                icon.loadDrawable(context)
                loadIconDrawable(icon, context)
            }
        }?.let { drawable ->
            // Icons carry tint which we need to propagate down to a Drawable.
@@ -366,6 +366,14 @@ constructor(
        }
    }

    @WorkerThread
    fun loadIconDrawable(icon: Icon, context: Context): Drawable? {
        icon.loadDrawable(context)?.let { return it }

        Log.w(TAG, "Failed to load drawable for $icon")
        return null
    }

    /**
     * Obtains the image size from the image header, without decoding the full image.
     *