diff options
| author | 2024-04-23 21:59:11 -0400 | |
|---|---|---|
| committer | 2024-04-23 22:38:06 -0400 | |
| commit | 53a5ae9b61d1c78bd55cbae2cd435aeee24dec48 (patch) | |
| tree | 90c0f1244b1033fa55390ae640a5ecb2effd4162 /graphics/java | |
| parent | ca660ce34f918a18e14a43b26d21d3669d360fac (diff) | |
BitmapDrawable: warn when passed null Bitmap
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: Ic4a009f7d51ed9c40e10bb033ad0e6307a9ed3a9
Diffstat (limited to 'graphics/java')
| -rw-r--r-- | graphics/java/android/graphics/drawable/BitmapDrawable.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java index b291f930da37..579ac60d5a86 100644 --- a/graphics/java/android/graphics/drawable/BitmapDrawable.java +++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java @@ -43,6 +43,7 @@ import android.graphics.Xfermode; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.LayoutDirection; +import android.util.Log; import android.util.TypedValue; import android.view.Gravity; @@ -138,6 +139,9 @@ public class BitmapDrawable extends Drawable { */ @Deprecated public BitmapDrawable(Bitmap bitmap) { + if (bitmap == null) { + Log.w(TAG, "BitmapDrawable created with null Bitmap"); + } init(new BitmapState(bitmap), null); } @@ -146,6 +150,9 @@ public class BitmapDrawable extends Drawable { * the display metrics of the resources. */ public BitmapDrawable(Resources res, Bitmap bitmap) { + if (bitmap == null) { + Log.w(TAG, "BitmapDrawable created with null Bitmap"); + } init(new BitmapState(bitmap), res); } @@ -177,7 +184,7 @@ public class BitmapDrawable extends Drawable { } finally { init(new BitmapState(bitmap), res); if (mBitmapState.mBitmap == null) { - android.util.Log.w("BitmapDrawable", "BitmapDrawable cannot decode " + filepath); + Log.w(TAG, "BitmapDrawable cannot decode " + filepath); } } } @@ -210,7 +217,7 @@ public class BitmapDrawable extends Drawable { } finally { init(new BitmapState(bitmap), res); if (mBitmapState.mBitmap == null) { - android.util.Log.w("BitmapDrawable", "BitmapDrawable cannot decode " + is); + Log.w(TAG, "BitmapDrawable cannot decode " + is); } } } @@ -1073,4 +1080,6 @@ public class BitmapDrawable extends Drawable { mBitmapState.mBlendMode); computeBitmapSize(); } + + private static final String TAG = "BitmapDrawable"; } |