From f04391896afd01b56864710f869f4a9636d0553a Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Tue, 12 Feb 2019 09:59:15 -0800 Subject: [PATCH] Prevent NPE inside iconloader library Bug: 120439430 Even though there is @NonNull annotation, customers may not respect this annotation. Change-Id: I01679d01f6920c3cc945c4abe757b907f150aa23 --- .../src/com/android/launcher3/icons/BaseIconFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java index af1b3530e7..76abe8d1ba 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java @@ -263,7 +263,9 @@ public class BaseIconFactory implements AutoCloseable { */ public Bitmap createIconBitmap(Drawable icon, float scale, int size) { Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); - + if (icon == null) { + return bitmap; + } mCanvas.setBitmap(bitmap); mOldBounds.set(icon.getBounds());