Merge "Guard against the NPE in setPreferenceIcon()" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-05-18 13:47:47 +00:00
committed by Android (Google) Code Review

View File

@@ -422,6 +422,11 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
private void setPreferenceIcon(Preference preference, Tile tile, boolean forceRoundedIcon, private void setPreferenceIcon(Preference preference, Tile tile, boolean forceRoundedIcon,
String iconPackage, Icon icon) { String iconPackage, Icon icon) {
Drawable iconDrawable = icon.loadDrawable(preference.getContext()); Drawable iconDrawable = icon.loadDrawable(preference.getContext());
if (iconDrawable == null) {
Log.w(TAG, "Set null preference icon for: " + iconPackage);
preference.setIcon(null);
return;
}
if (TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) { if (TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
iconDrawable.setTint(Utils.getHomepageIconColor(preference.getContext())); iconDrawable.setTint(Utils.getHomepageIconColor(preference.getContext()));
} else if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) { } else if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) {