diff options
author | Kenny Root <kroot@google.com> | 2011-03-10 10:53:06 -0800 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2011-03-10 11:37:56 -0800 |
commit | 20b0a5f0fd283cda62ed4f94b72f8ff0833baf75 (patch) | |
tree | d04eba8b7be46e0198248caed510c722001cf4b0 /src/com/android | |
parent | a017c0379c30e0272a88a93d05b6a30e28955b88 (diff) | |
download | android_packages_apps_Trebuchet-20b0a5f0fd283cda62ed4f94b72f8ff0833baf75.tar.gz android_packages_apps_Trebuchet-20b0a5f0fd283cda62ed4f94b72f8ff0833baf75.tar.bz2 android_packages_apps_Trebuchet-20b0a5f0fd283cda62ed4f94b72f8ff0833baf75.zip |
Applications with broken resources get default icon
This will prevent the Launcher from crashing when the icon resource is
not found.
Bug: 4016288
Change-Id: I152574eb62cff66fa863152f84d4bb201f0341af
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher2/IconCache.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java index 2e47adc9e..0c26bf05c 100644 --- a/src/com/android/launcher2/IconCache.java +++ b/src/com/android/launcher2/IconCache.java @@ -68,11 +68,13 @@ public class IconCache { com.android.internal.R.mipmap.sym_def_app_icon); } - public Drawable getFullResIcon(Resources resources, int iconId) { + public Drawable getFullResIcon(Resources resources, int iconId) + throws Resources.NotFoundException { return resources.getDrawableForDensity(iconId, mIconDpi); } - public Drawable getFullResIcon(ResolveInfo info, PackageManager packageManager) { + public Drawable getFullResIcon(ResolveInfo info, PackageManager packageManager) + throws Resources.NotFoundException { Resources resources; try { resources = packageManager.getResourcesForApplication( @@ -174,8 +176,14 @@ public class IconCache { if (entry.title == null) { entry.title = info.activityInfo.name; } - entry.icon = Utilities.createIconBitmap( - getFullResIcon(info, mPackageManager), mContext); + + Drawable icon; + try { + icon = getFullResIcon(info, mPackageManager); + } catch (Resources.NotFoundException e) { + icon = getFullResDefaultActivityIcon(); + } + entry.icon = Utilities.createIconBitmap(icon, mContext); } return entry; } |