Implement all of the infrastructure for configuring wallpapers.

Actually being able to configure a wallpaper relies on additional
work in the launcher and wallpapers that will be in another change.
Also note that this breaks all existing wallpapers, since they now
need to include a meta-data item about themselves.  This also
will be fixed in another change.

Change-Id: I97d2c2bd07237abc32f92b9147c32530a2f73c71
diff --git a/core/java/android/content/pm/ResolveInfo.java b/core/java/android/content/pm/ResolveInfo.java
index ee49c02..380db65 100644
--- a/core/java/android/content/pm/ResolveInfo.java
+++ b/core/java/android/content/pm/ResolveInfo.java
@@ -92,6 +92,13 @@
     public int icon;
 
     /**
+     * Optional -- if non-null, the {@link #labelRes} and {@link #icon}
+     * resources will be loaded from this package, rather than the one
+     * containing the resolved component.
+     */
+    public String resolvePackageName;
+    
+    /**
      * Retrieve the current textual label associated with this resolution.  This
      * will call back on the given PackageManager to load the label from
      * the application.
@@ -106,9 +113,15 @@
         if (nonLocalizedLabel != null) {
             return nonLocalizedLabel;
         }
+        CharSequence label;
+        if (resolvePackageName != null && labelRes != 0) {
+            label = pm.getText(resolvePackageName, labelRes, null);
+            if (label != null) {
+                return label;
+            }
+        }
         ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo;
         ApplicationInfo ai = ci.applicationInfo;
-        CharSequence label;
         if (labelRes != 0) {
             label = pm.getText(ci.packageName, labelRes, ai);
             if (label != null) {
@@ -133,6 +146,12 @@
         ComponentInfo ci = activityInfo != null ? activityInfo : serviceInfo;
         ApplicationInfo ai = ci.applicationInfo;
         Drawable dr;
+        if (resolvePackageName != null && icon != 0) {
+            dr = pm.getDrawable(resolvePackageName, icon, null);
+            if (dr != null) {
+                return dr;
+            }
+        }
         if (icon != 0) {
             dr = pm.getDrawable(ci.packageName, icon, ai);
             if (dr != null) {
@@ -160,24 +179,26 @@
         if (filter != null) {
             pw.println(prefix + "Filter:");
             filter.dump(pw, prefix + "  ");
-        } else {
-            pw.println(prefix + "Filter: null");
         }
         pw.println(prefix + "priority=" + priority
                 + " preferredOrder=" + preferredOrder
                 + " match=0x" + Integer.toHexString(match)
                 + " specificIndex=" + specificIndex
                 + " isDefault=" + isDefault);
-        pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
-                + " nonLocalizedLabel=" + nonLocalizedLabel
-                + " icon=0x" + Integer.toHexString(icon));
+        if (resolvePackageName != null) {
+            pw.println(prefix + "resolvePackageName=" + resolvePackageName);
+        }
+        if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
+            pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
+                    + " nonLocalizedLabel=" + nonLocalizedLabel
+                    + " icon=0x" + Integer.toHexString(icon));
+        }
         if (activityInfo != null) {
             pw.println(prefix + "ActivityInfo:");
             activityInfo.dump(pw, prefix + "  ");
         } else if (serviceInfo != null) {
             pw.println(prefix + "ServiceInfo:");
-            // TODO
-            //serviceInfo.dump(pw, prefix + "  ");
+            serviceInfo.dump(pw, prefix + "  ");
         }
     }
     
@@ -219,6 +240,7 @@
         dest.writeInt(labelRes);
         TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
         dest.writeInt(icon);
+        dest.writeString(resolvePackageName);
     }
 
     public static final Creator<ResolveInfo> CREATOR
@@ -257,6 +279,7 @@
         nonLocalizedLabel
                 = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
         icon = source.readInt();
+        resolvePackageName = source.readString();
     }
     
     public static class DisplayNameComparator