Try and resolve the package name from the intent directly falling back to the resolved component name if it fails. (Bug 6452306)
Change-Id: Ifb2187fb845f807f30df966bf298ffde1b779b46
diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/android/launcher2/ItemInfo.java
index 11a6c0d..d34b87e 100644
--- a/src/com/android/launcher2/ItemInfo.java
+++ b/src/com/android/launcher2/ItemInfo.java
@@ -16,13 +16,14 @@
package com.android.launcher2;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
import android.content.ContentValues;
+import android.content.Intent;
import android.graphics.Bitmap;
import android.util.Log;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
/**
* Represents an item in the launcher.
*/
@@ -109,6 +110,21 @@
container = info.container;
}
+ /** Returns the package name that the intent will resolve to, or an empty string if
+ * none exists. */
+ static String getPackageName(Intent intent) {
+ if (intent != null) {
+ String packageName = intent.getPackage();
+ if (packageName == null) {
+ packageName = intent.getComponent().getPackageName();
+ }
+ if (packageName != null) {
+ return packageName;
+ }
+ }
+ return "";
+ }
+
/**
* Write the fields of this item to the DB
*