summaryrefslogtreecommitdiffstats
path: root/iconloaderlib
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2019-07-17 17:04:40 -0700
committerHyunyoung Song <hyunyoungs@google.com>2019-07-18 00:06:04 +0000
commitae86d22dfb6d365b52bd1465a1b3f2811d721882 (patch)
treeaf95395eedd503e61b3bbbe357e4dab4cf41e4c7 /iconloaderlib
parentbf0042107c433de499e10b91a412b6c3e4a3bcbc (diff)
downloadandroid_packages_apps_Trebuchet-ae86d22dfb6d365b52bd1465a1b3f2811d721882.tar.gz
android_packages_apps_Trebuchet-ae86d22dfb6d365b52bd1465a1b3f2811d721882.tar.bz2
android_packages_apps_Trebuchet-ae86d22dfb6d365b52bd1465a1b3f2811d721882.zip
Guard against NPE inside BaseIconFactory
Bug: 137253043 This is a bandage fix. Ideally, we should really figure out why TaskIconCache will be sending null icon drawable to BaseIconFactory. Change-Id: Ie005006baeddc9a3379283fe7139e590daad9a57
Diffstat (limited to 'iconloaderlib')
-rw-r--r--iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
index db5515b74..fc7d6b329 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
+import androidx.annotation.NonNull;
/**
* This class will be moved to androidx library. There shouldn't be any dependency outside
@@ -154,7 +155,7 @@ public class BaseIconFactory implements AutoCloseable {
* @param scale returns the scale result from normalization
* @return a bitmap suitable for disaplaying as an icon at various system UIs.
*/
- public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
+ public BitmapInfo createBadgedIconBitmap(@NonNull Drawable icon, UserHandle user,
boolean shrinkNonAdaptiveIcons, boolean isInstantApp, float[] scale) {
if (scale == null) {
scale = new float[1];
@@ -207,8 +208,11 @@ public class BaseIconFactory implements AutoCloseable {
mDisableColorExtractor = true;
}
- private Drawable normalizeAndWrapToAdaptiveIcon(Drawable icon, boolean shrinkNonAdaptiveIcons,
- RectF outIconBounds, float[] outScale) {
+ private Drawable normalizeAndWrapToAdaptiveIcon(@NonNull Drawable icon,
+ boolean shrinkNonAdaptiveIcons, RectF outIconBounds, float[] outScale) {
+ if (icon == null) {
+ return null;
+ }
float scale = 1f;
if (shrinkNonAdaptiveIcons && ATLEAST_OREO) {
@@ -264,7 +268,7 @@ public class BaseIconFactory implements AutoCloseable {
* @param icon drawable that should be flattened to a bitmap
* @param scale the scale to apply before drawing {@param icon} on the canvas
*/
- public Bitmap createIconBitmap(Drawable icon, float scale, int size) {
+ public Bitmap createIconBitmap(@NonNull Drawable icon, float scale, int size) {
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
if (icon == null) {
return bitmap;