Fix two crashes

- NPE: bug #4984219
- IllegalStateException: bug #4969695

Change-Id: Iaf02e669b26f9277388e0e7bffd532220ebf9bb1
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index af8d986..e318960 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2593,14 +2593,18 @@
         ImageView button = (ImageView) findViewById(buttonId);
         Drawable toolbarIcon = getExternalPackageToolbarIcon(activityName);
 
-        // If we were unable to find the icon via the meta-data, use a generic one
-        if (toolbarIcon == null) {
-            button.setImageResource(fallbackDrawableId);
-            return null;
-        } else {
-            button.setImageDrawable(toolbarIcon);
-            return toolbarIcon.getConstantState();
+        if (button != null) {
+            // If we were unable to find the icon via the meta-data, use a
+            // generic one
+            if (toolbarIcon == null) {
+                button.setImageResource(fallbackDrawableId);
+            } else {
+                button.setImageDrawable(toolbarIcon);
+            }
         }
+
+        return toolbarIcon != null ? toolbarIcon.getConstantState() : null;
+
     }
 
     private void updateTextButtonWithDrawable(int buttonId, Drawable.ConstantState d) {