From 6deba4aebc6fedadb0ae5534c04a0e3386cf7f20 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Thu, 10 Mar 2011 10:53:06 -0800 Subject: [PATCH 1/2] 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 --- src/com/android/launcher2/IconCache.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/com/android/launcher2/IconCache.java b/src/com/android/launcher2/IconCache.java index 2e47adc9e8..0c26bf05ca 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; } From d4de8530b9d77711cae1e9eeba230c48c20e68f7 Mon Sep 17 00:00:00 2001 From: Patrick Dubroy Date: Tue, 15 Mar 2011 10:29:01 -0700 Subject: [PATCH 2/2] Fix 4093841: Launcher crash after downloading app & hitting back The last change to fix the "blue glow gone wild" re-introduced a NPE caused by setting the pressed state of a BubbleTextView which has been detached. Change-Id: I726bace77dd04b6ac8f3e170dd9e1df00a183384 --- src/com/android/launcher2/BubbleTextView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index f18a241972..146485489d 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -264,8 +264,10 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca void setCellLayoutPressedOrFocusedIcon() { CellLayoutChildren parent = (CellLayoutChildren) getParent(); - CellLayout cellLayout = (CellLayout) parent.getParent(); - cellLayout.setPressedOrFocusedIcon((mPressedOrFocusedBackground != null) ? this : null); + if (parent != null) { + CellLayout layout = (CellLayout) parent.getParent(); + layout.setPressedOrFocusedIcon((mPressedOrFocusedBackground != null) ? this : null); + } } Bitmap getPressedOrFocusedBackground() {