From adf5e468d1c26f063eaac79edf864cc3333acd90 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Fri, 18 Jun 2021 16:56:30 -0400 Subject: [PATCH] Don't crash the notification bind if the icon fails to resolve. Bug: 189924598 Test: reproduce the bug and notice that instead of an empty collapsed state, you get everything except the icon. Change-Id: Ibc4bebf0bbf42192ce70b748f98725e312fa54b8 --- core/java/com/android/internal/widget/CachingIconView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/java/com/android/internal/widget/CachingIconView.java b/core/java/com/android/internal/widget/CachingIconView.java index 4a70f74160756..299cbe12b4d13 100644 --- a/core/java/com/android/internal/widget/CachingIconView.java +++ b/core/java/com/android/internal/widget/CachingIconView.java @@ -257,7 +257,7 @@ public class CachingIconView extends ImageView { boolean hasColor = color != ColoredIconHelper.COLOR_INVALID; if (background == null) { // This is the pre-S style -- colored icon with no background. - if (hasColor) { + if (hasColor && icon != null) { icon.mutate().setColorFilter(color, PorterDuff.Mode.SRC_ATOP); } } else { @@ -265,7 +265,9 @@ public class CachingIconView extends ImageView { // colorize the icon itself with the background color, creating an inverted effect. if (hasColor) { background.mutate().setColorFilter(color, PorterDuff.Mode.SRC_ATOP); - icon.mutate().setColorFilter(mBackgroundColor, PorterDuff.Mode.SRC_ATOP); + if (icon != null) { + icon.mutate().setColorFilter(mBackgroundColor, PorterDuff.Mode.SRC_ATOP); + } } else { background.mutate().setColorFilter(mBackgroundColor, PorterDuff.Mode.SRC_ATOP); }