Fixing NPE in Workspace.removeItemsByPackageName() (Bug 8942242)

Change-Id: I1f63e548caa4b00b7166db4a53307c80650d8907
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index ac4c3dd..c725296 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -3659,21 +3659,21 @@
                 if (tag instanceof ShortcutInfo) {
                     ShortcutInfo info = (ShortcutInfo) tag;
                     ComponentName cn = info.intent.getComponent();
-                    if (packageNames.contains(cn.getPackageName())) {
+                    if ((cn != null) && packageNames.contains(cn.getPackageName())) {
                         cns.add(cn);
                     }
                 } else if (tag instanceof FolderInfo) {
                     FolderInfo info = (FolderInfo) tag;
                     for (ShortcutInfo s : info.contents) {
                         ComponentName cn = s.intent.getComponent();
-                        if (packageNames.contains(cn.getPackageName())) {
+                        if ((cn != null) && packageNames.contains(cn.getPackageName())) {
                             cns.add(cn);
                         }
                     }
                 } else if (tag instanceof LauncherAppWidgetInfo) {
                     LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) tag;
                     ComponentName cn = info.providerName;
-                    if (packageNames.contains(cn.getPackageName())) {
+                    if ((cn != null) && packageNames.contains(cn.getPackageName())) {
                         cns.add(cn);
                     }
                 }