(list.size());
int listSize = list.size();
for (int i = 0; i < listSize; i++) {
ResolveInfo resolveInfo = list.get(i);
- result.add(new ListItem(mPackageManager, resolveInfo, resizer));
+ result.add(new ListItem(mPackageManager, resolveInfo, null));
}
return result;
diff --git a/core/java/android/app/WallpaperInfo.aidl b/core/java/android/app/WallpaperInfo.aidl
new file mode 100644
index 0000000000000..7bbdcae71c563
--- /dev/null
+++ b/core/java/android/app/WallpaperInfo.aidl
@@ -0,0 +1,19 @@
+/*
+** Copyright 2009, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+package android.app;
+
+parcelable WallpaperInfo;
diff --git a/core/java/android/app/WallpaperInfo.java b/core/java/android/app/WallpaperInfo.java
new file mode 100644
index 0000000000000..5e44bc78064ea
--- /dev/null
+++ b/core/java/android/app/WallpaperInfo.java
@@ -0,0 +1,200 @@
+package android.app;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+import android.content.res.TypedArray;
+import android.content.res.XmlResourceParser;
+import android.graphics.drawable.Drawable;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.service.wallpaper.WallpaperService;
+import android.util.AttributeSet;
+import android.util.Printer;
+import android.util.Xml;
+
+import java.io.IOException;
+
+/**
+ * This class is used to specify meta information of a wallpaper service.
+ * @hide Live Wallpaper
+ */
+public final class WallpaperInfo implements Parcelable {
+ static final String TAG = "WallpaperInfo";
+
+ /**
+ * The Service that implements this wallpaper component.
+ */
+ final ResolveInfo mService;
+
+ /**
+ * The wallpaper setting activity's name, to
+ * launch the setting activity of this wallpaper.
+ */
+ final String mSettingsActivityName;
+
+ /**
+ * Constructor.
+ *
+ * @param context The Context in which we are parsing the wallpaper.
+ * @param service The ResolveInfo returned from the package manager about
+ * this wallpaper's component.
+ */
+ public WallpaperInfo(Context context, ResolveInfo service)
+ throws XmlPullParserException, IOException {
+ mService = service;
+ ServiceInfo si = service.serviceInfo;
+
+ PackageManager pm = context.getPackageManager();
+ String settingsActivityComponent = null;
+
+ XmlResourceParser parser = null;
+ try {
+ parser = si.loadXmlMetaData(pm, WallpaperService.SERVICE_META_DATA);
+ if (parser == null) {
+ throw new XmlPullParserException("No "
+ + WallpaperService.SERVICE_META_DATA + " meta-data");
+ }
+
+ AttributeSet attrs = Xml.asAttributeSet(parser);
+
+ int type;
+ while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+ && type != XmlPullParser.START_TAG) {
+ }
+
+ String nodeName = parser.getName();
+ if (!"wallpaper".equals(nodeName)) {
+ throw new XmlPullParserException(
+ "Meta-data does not start with wallpaper tag");
+ }
+
+ TypedArray sa = context.getResources().obtainAttributes(attrs,
+ com.android.internal.R.styleable.Wallpaper);
+ settingsActivityComponent = sa.getString(
+ com.android.internal.R.styleable.Wallpaper_settingsActivity);
+ sa.recycle();
+ } finally {
+ if (parser != null) parser.close();
+ }
+
+ mSettingsActivityName = settingsActivityComponent;
+ }
+
+ WallpaperInfo(Parcel source) {
+ mSettingsActivityName = source.readString();
+ mService = ResolveInfo.CREATOR.createFromParcel(source);
+ }
+
+ /**
+ * Return the .apk package that implements this wallpaper.
+ */
+ public String getPackageName() {
+ return mService.serviceInfo.packageName;
+ }
+
+ /**
+ * Return the class name of the service component that implements
+ * this wallpaper.
+ */
+ public String getServiceName() {
+ return mService.serviceInfo.name;
+ }
+
+ /**
+ * Return the raw information about the Service implementing this
+ * wallpaper. Do not modify the returned object.
+ */
+ public ServiceInfo getServiceInfo() {
+ return mService.serviceInfo;
+ }
+
+ /**
+ * Return the component of the service that implements this wallpaper.
+ */
+ public ComponentName getComponent() {
+ return new ComponentName(mService.serviceInfo.packageName,
+ mService.serviceInfo.name);
+ }
+
+ /**
+ * Load the user-displayed label for this wallpaper.
+ *
+ * @param pm Supply a PackageManager used to load the wallpaper's
+ * resources.
+ */
+ public CharSequence loadLabel(PackageManager pm) {
+ return mService.loadLabel(pm);
+ }
+
+ /**
+ * Load the user-displayed icon for this wallpaper.
+ *
+ * @param pm Supply a PackageManager used to load the wallpaper's
+ * resources.
+ */
+ public Drawable loadIcon(PackageManager pm) {
+ return mService.loadIcon(pm);
+ }
+
+ /**
+ * Return the class name of an activity that provides a settings UI for
+ * the wallpaper. You can launch this activity be starting it with
+ * an {@link android.content.Intent} whose action is MAIN and with an
+ * explicit {@link android.content.ComponentName}
+ * composed of {@link #getPackageName} and the class name returned here.
+ *
+ * A null will be returned if there is no settings activity associated
+ * with the wallpaper.
+ */
+ public String getSettingsActivity() {
+ return mSettingsActivityName;
+ }
+
+ public void dump(Printer pw, String prefix) {
+ pw.println(prefix + "Service:");
+ mService.dump(pw, prefix + " ");
+ pw.println(prefix + "mSettingsActivityName=" + mSettingsActivityName);
+ }
+
+ @Override
+ public String toString() {
+ return "WallpaperInfo{" + mService.serviceInfo.name
+ + ", settings: "
+ + mSettingsActivityName + "}";
+ }
+
+ /**
+ * Used to package this object into a {@link Parcel}.
+ *
+ * @param dest The {@link Parcel} to be written.
+ * @param flags The flags used for parceling.
+ */
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mSettingsActivityName);
+ mService.writeToParcel(dest, flags);
+ }
+
+ /**
+ * Used to make this class parcelable.
+ */
+ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
+ public WallpaperInfo createFromParcel(Parcel source) {
+ return new WallpaperInfo(source);
+ }
+
+ public WallpaperInfo[] newArray(int size) {
+ return new WallpaperInfo[size];
+ }
+ };
+
+ public int describeContents() {
+ return 0;
+ }
+}
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index dbe080b60b18c..da40c8a2fa5af 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -49,7 +49,7 @@ public class WallpaperManager {
/**
* Launch an activity for the user to pick the current global live
* wallpaper.
- * @hide
+ * @hide Live Wallpaper
*/
public static final String ACTION_LIVE_WALLPAPER_CHOOSER
= "android.service.wallpaper.LIVE_WALLPAPER_CHOOSER";
@@ -238,6 +238,20 @@ public class WallpaperManager {
return bm != null ? new BitmapDrawable(mContext.getResources(), bm) : null;
}
+ /**
+ * If the current wallpaper is a live wallpaper component, return the
+ * information about that wallpaper. Otherwise, if it is a static image,
+ * simply return null.
+ * @hide Live Wallpaper
+ */
+ public WallpaperInfo getWallpaperInfo() {
+ try {
+ return sGlobals.mService.getWallpaperInfo();
+ } catch (RemoteException e) {
+ return null;
+ }
+ }
+
/**
* Change the current system wallpaper to the bitmap in the given resource.
* The resource is opened as a raw data stream and copied into the
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index e8b2984ba2e3f..c053ace7e1baa 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1928,6 +1928,15 @@ public class Intent implements Parcelable {
*/
public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
+ /**
+ * A Parcelable[] of {@link Intent} or
+ * {@link android.content.pm.LabeledIntent} objects as set with
+ * {@link #putExtra(String, Parcelable[])} of additional activities to place
+ * a the front of the list of choices, when shown to the user with a
+ * {@link #ACTION_CHOOSER}.
+ */
+ public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
+
/**
* A {@link android.view.KeyEvent} object containing the event that
* triggered the creation of the Intent it is in.
@@ -5067,7 +5076,8 @@ public class Intent implements Parcelable {
}
};
- private Intent(Parcel in) {
+ /** @hide */
+ protected Intent(Parcel in) {
readFromParcel(in);
}
diff --git a/core/java/android/content/pm/LabeledIntent.java b/core/java/android/content/pm/LabeledIntent.java
new file mode 100644
index 0000000000000..d70a698d3b810
--- /dev/null
+++ b/core/java/android/content/pm/LabeledIntent.java
@@ -0,0 +1,177 @@
+package android.content.pm;
+
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.os.Parcel;
+import android.text.TextUtils;
+
+/**
+ * A special subclass of Intent that can have a custom label/icon
+ * associated with it. Primarily for use with {@link Intent#ACTION_CHOOSER}.
+ */
+public class LabeledIntent extends Intent {
+ private String mSourcePackage;
+ private int mLabelRes;
+ private CharSequence mNonLocalizedLabel;
+ private int mIcon;
+
+ /**
+ * Create a labeled intent from the given intent, supplying the label
+ * and icon resources for it.
+ *
+ * @param origIntent The original Intent to copy.
+ * @param sourcePackage The package in which the label and icon live.
+ * @param labelRes Resource containing the label, or 0 if none.
+ * @param icon Resource containing the icon, or 0 if none.
+ */
+ public LabeledIntent(Intent origIntent, String sourcePackage,
+ int labelRes, int icon) {
+ super(origIntent);
+ mSourcePackage = sourcePackage;
+ mLabelRes = labelRes;
+ mNonLocalizedLabel = null;
+ mIcon = icon;
+ }
+
+ /**
+ * Create a labeled intent from the given intent, supplying a textual
+ * label and icon resource for it.
+ *
+ * @param origIntent The original Intent to copy.
+ * @param sourcePackage The package in which the label and icon live.
+ * @param nonLocalizedLabel Concrete text to use for the label.
+ * @param icon Resource containing the icon, or 0 if none.
+ */
+ public LabeledIntent(Intent origIntent, String sourcePackage,
+ CharSequence nonLocalizedLabel, int icon) {
+ super(origIntent);
+ mSourcePackage = sourcePackage;
+ mLabelRes = 0;
+ mNonLocalizedLabel = nonLocalizedLabel;
+ mIcon = icon;
+ }
+
+ /**
+ * Create a labeled intent with no intent data but supplying the label
+ * and icon resources for it.
+ *
+ * @param sourcePackage The package in which the label and icon live.
+ * @param labelRes Resource containing the label, or 0 if none.
+ * @param icon Resource containing the icon, or 0 if none.
+ */
+ public LabeledIntent(String sourcePackage, int labelRes, int icon) {
+ mSourcePackage = sourcePackage;
+ mLabelRes = labelRes;
+ mNonLocalizedLabel = null;
+ mIcon = icon;
+ }
+
+ /**
+ * Create a labeled intent with no intent data but supplying a textual
+ * label and icon resource for it.
+ *
+ * @param sourcePackage The package in which the label and icon live.
+ * @param nonLocalizedLabel Concrete text to use for the label.
+ * @param icon Resource containing the icon, or 0 if none.
+ */
+ public LabeledIntent(String sourcePackage,
+ CharSequence nonLocalizedLabel, int icon) {
+ mSourcePackage = sourcePackage;
+ mLabelRes = 0;
+ mNonLocalizedLabel = nonLocalizedLabel;
+ mIcon = icon;
+ }
+
+ /**
+ * Return the name of the package holding label and icon resources.
+ */
+ public String getSourcePackage() {
+ return mSourcePackage;
+ }
+
+ /**
+ * Return any resource identifier that has been given for the label text.
+ */
+ public int getLabelResource() {
+ return mLabelRes;
+ }
+
+ /**
+ * Return any concrete text that has been given for the label text.
+ */
+ public CharSequence getNonLocalizedLabel() {
+ return mNonLocalizedLabel;
+ }
+
+ /**
+ * Return any resource identifier that has been given for the label icon.
+ */
+ public int getIconResource() {
+ return mIcon;
+ }
+
+ /**
+ * Retrieve the label associated with this object. If the object does
+ * not have a label, null will be returned, in which case you will probably
+ * want to load the label from the underlying resolved info for the Intent.
+ */
+ public CharSequence loadLabel(PackageManager pm) {
+ if (mNonLocalizedLabel != null) {
+ return mNonLocalizedLabel;
+ }
+ if (mLabelRes != 0 && mSourcePackage != null) {
+ CharSequence label = pm.getText(mSourcePackage, mLabelRes, null);
+ if (label != null) {
+ return label;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve the icon associated with this object. If the object does
+ * not have a icon, null will be returned, in which case you will probably
+ * want to load the icon from the underlying resolved info for the Intent.
+ */
+ public Drawable loadIcon(PackageManager pm) {
+ if (mIcon != 0 && mSourcePackage != null) {
+ Drawable icon = pm.getDrawable(mSourcePackage, mIcon, null);
+ if (icon != null) {
+ return icon;
+ }
+ }
+ return null;
+ }
+
+ public void writeToParcel(Parcel dest, int parcelableFlags) {
+ super.writeToParcel(dest, parcelableFlags);
+ dest.writeString(mSourcePackage);
+ dest.writeInt(mLabelRes);
+ TextUtils.writeToParcel(mNonLocalizedLabel, dest, parcelableFlags);
+ dest.writeInt(mIcon);
+ }
+
+ /** @hide */
+ protected LabeledIntent(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public void readFromParcel(Parcel in) {
+ super.readFromParcel(in);
+ mSourcePackage = in.readString();
+ mLabelRes = in.readInt();
+ mNonLocalizedLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+ mIcon = in.readInt();
+ }
+
+ public static final Creator CREATOR
+ = new Creator() {
+ public LabeledIntent createFromParcel(Parcel source) {
+ return new LabeledIntent(source);
+ }
+ public LabeledIntent[] newArray(int size) {
+ return new LabeledIntent[size];
+ }
+ };
+
+}
diff --git a/core/java/android/content/pm/ResolveInfo.java b/core/java/android/content/pm/ResolveInfo.java
index ee49c02223865..380db65129875 100644
--- a/core/java/android/content/pm/ResolveInfo.java
+++ b/core/java/android/content/pm/ResolveInfo.java
@@ -91,6 +91,13 @@ public class ResolveInfo implements Parcelable {
*/
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
@@ -106,9 +113,15 @@ public class ResolveInfo implements Parcelable {
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 @@ public class ResolveInfo implements Parcelable {
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 @@ public class ResolveInfo implements Parcelable {
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 @@ public class ResolveInfo implements Parcelable {
dest.writeInt(labelRes);
TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
dest.writeInt(icon);
+ dest.writeString(resolvePackageName);
}
public static final Creator CREATOR
@@ -257,6 +279,7 @@ public class ResolveInfo implements Parcelable {
nonLocalizedLabel
= TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
icon = source.readInt();
+ resolvePackageName = source.readString();
}
public static class DisplayNameComparator
diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java
index b60650c01bfe0..51d2a4decf8c1 100644
--- a/core/java/android/content/pm/ServiceInfo.java
+++ b/core/java/android/content/pm/ServiceInfo.java
@@ -2,6 +2,7 @@ package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.Printer;
/**
* Information you can retrieve about a particular application
@@ -24,6 +25,11 @@ public class ServiceInfo extends ComponentInfo
permission = orig.permission;
}
+ public void dump(Printer pw, String prefix) {
+ super.dumpFront(pw, prefix);
+ pw.println(prefix + "permission=" + permission);
+ }
+
public String toString() {
return "ServiceInfo{"
+ Integer.toHexString(System.identityHashCode(this))
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 2e4f1d2fb7510..95b5730c0fecd 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -50,6 +50,14 @@ public abstract class WallpaperService extends Service {
public static final String SERVICE_INTERFACE =
"android.service.wallpaper.WallpaperService";
+ /**
+ * Name under which a WallpaperService component publishes information
+ * about itself. This meta-data must reference an XML resource containing
+ * a <{@link android.R.styleable#Wallpaper wallpaper}>
+ * tag.
+ */
+ public static final String SERVICE_META_DATA = "android.service.wallpaper";
+
static final String TAG = "WallpaperService";
static final boolean DEBUG = false;
diff --git a/core/java/android/view/inputmethod/InputMethodInfo.java b/core/java/android/view/inputmethod/InputMethodInfo.java
index b4c5b72f33eb5..316bcd614c46f 100644
--- a/core/java/android/view/inputmethod/InputMethodInfo.java
+++ b/core/java/android/view/inputmethod/InputMethodInfo.java
@@ -40,7 +40,7 @@ import java.io.IOException;
* This class is used to specify meta information of an input method.
*/
public final class InputMethodInfo implements Parcelable {
- static final String TAG = "InputMethodMetaInfo";
+ static final String TAG = "InputMethodInfo";
/**
* The Service that implements this input method component.
@@ -244,7 +244,7 @@ public final class InputMethodInfo implements Parcelable {
@Override
public String toString() {
- return "InputMethodMetaInfo{" + mId
+ return "InputMethodInfo{" + mId
+ ", settings: "
+ mSettingsActivityName + "}";
}
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 1697df279b859..9ed4dd826bd6f 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -17,17 +17,40 @@
package com.android.internal.app;
import android.content.Intent;
+import android.content.pm.ResolveInfo;
import android.os.Bundle;
+import android.os.Parcelable;
+import android.util.Log;
public class ChooserActivity extends ResolverActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
- Intent target = (Intent)intent.getParcelableExtra(Intent.EXTRA_INTENT);
+ Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
+ if (!(targetParcelable instanceof Intent)) {
+ Log.w("ChooseActivity", "Target is not an intent: " + targetParcelable);
+ finish();
+ return;
+ }
+ Intent target = (Intent)targetParcelable;
CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE);
if (title == null) {
title = getResources().getText(com.android.internal.R.string.chooseActivity);
}
- super.onCreate(savedInstanceState, target, title, false);
+ Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS);
+ Intent[] initialIntents = null;
+ if (pa != null) {
+ initialIntents = new Intent[pa.length];
+ for (int i=0; i 1) {
ap.mAdapter = mAdapter;
} else if (mAdapter.getCount() == 1) {
@@ -185,12 +187,16 @@ public class ResolverActivity extends AlertActivity implements
private final class DisplayResolveInfo {
ResolveInfo ri;
CharSequence displayLabel;
+ Drawable displayIcon;
CharSequence extendedInfo;
+ Intent origIntent;
- DisplayResolveInfo(ResolveInfo pri, CharSequence pLabel, CharSequence pInfo) {
+ DisplayResolveInfo(ResolveInfo pri, CharSequence pLabel,
+ CharSequence pInfo, Intent pOrigIntent) {
ri = pri;
displayLabel = pLabel;
extendedInfo = pInfo;
+ origIntent = pOrigIntent;
}
}
@@ -200,7 +206,8 @@ public class ResolverActivity extends AlertActivity implements
private List mList;
- public ResolveListAdapter(Context context, Intent intent) {
+ public ResolveListAdapter(Context context, Intent intent,
+ Intent[] initialIntents) {
mIntent = new Intent(intent);
mIntent.setComponent(null);
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -234,9 +241,39 @@ public class ResolverActivity extends AlertActivity implements
new ResolveInfo.DisplayNameComparator(mPm);
Collections.sort(rList, rComparator);
}
+
+ mList = new ArrayList();
+
+ // First put the initial items at the top.
+ if (initialIntents != null) {
+ for (int i=0; i();
r0 = rList.get(0);
int start = 0;
CharSequence r0Label = r0.loadLabel(mPm);
@@ -268,7 +305,7 @@ public class ResolverActivity extends AlertActivity implements
int num = end - start+1;
if (num == 1) {
// No duplicate labels. Use label for entry at start
- mList.add(new DisplayResolveInfo(ro, roLabel, null));
+ mList.add(new DisplayResolveInfo(ro, roLabel, null, null));
} else {
boolean usePkg = false;
CharSequence startApp = ro.activityInfo.applicationInfo.loadLabel(mPm);
@@ -298,11 +335,11 @@ public class ResolverActivity extends AlertActivity implements
if (usePkg) {
// Use application name for all entries from start to end-1
mList.add(new DisplayResolveInfo(add, roLabel,
- add.activityInfo.packageName));
+ add.activityInfo.packageName, null));
} else {
// Use package name for all entries from start to end-1
mList.add(new DisplayResolveInfo(add, roLabel,
- add.activityInfo.applicationInfo.loadLabel(mPm)));
+ add.activityInfo.applicationInfo.loadLabel(mPm), null));
}
}
}
@@ -321,10 +358,13 @@ public class ResolverActivity extends AlertActivity implements
return null;
}
- Intent intent = new Intent(mIntent);
+ DisplayResolveInfo dri = mList.get(position);
+
+ Intent intent = new Intent(dri.origIntent != null
+ ? dri.origIntent : mIntent);
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
|Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
- ActivityInfo ai = mList.get(position).ri.activityInfo;
+ ActivityInfo ai = dri.ri.activityInfo;
intent.setComponent(new ComponentName(
ai.applicationInfo.packageName, ai.name));
return intent;
@@ -365,7 +405,10 @@ public class ResolverActivity extends AlertActivity implements
} else {
text2.setVisibility(View.GONE);
}
- icon.setImageDrawable(info.ri.loadIcon(mPm));
+ if (info.displayIcon == null) {
+ info.displayIcon = info.ri.loadIcon(mPm);
+ }
+ icon.setImageDrawable(info.displayIcon);
}
}
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 1e71a99f19c70..b394f017c997c 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3406,6 +3406,23 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 1057c09582526..560796a3bd2bc 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -24,6 +24,7 @@
#ff000000
#ff000000
#60000000
+ #80000000
#80ffffff
#ffffffff
#ff000000
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 3be3ef8b8b43f..8541c739bd1bc 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1166,4 +1166,10 @@
+
+
+
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3333915ecdd7a..250612f4b780e 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1972,5 +1972,7 @@
Accessibility
Wallpaper
+
+ Change wallpaper
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index cc977b09808e6..4b6049f03e1cf 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -22,6 +22,7 @@ import static android.os.ParcelFileDescriptor.*;
import android.app.IWallpaperManager;
import android.app.IWallpaperManagerCallback;
import android.app.PendingIntent;
+import android.app.WallpaperInfo;
import android.backup.BackupManager;
import android.content.ComponentName;
import android.content.Context;
@@ -41,7 +42,6 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteCallbackList;
import android.os.ServiceManager;
import android.os.SystemClock;
-import android.provider.Settings;
import android.service.wallpaper.IWallpaperConnection;
import android.service.wallpaper.IWallpaperEngine;
import android.service.wallpaper.IWallpaperService;
@@ -51,12 +51,14 @@ import android.util.Xml;
import android.view.IWindowManager;
import android.view.WindowManager;
+import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.PrintWriter;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
@@ -130,15 +132,25 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
class WallpaperConnection extends IWallpaperConnection.Stub
implements ServiceConnection {
+ final WallpaperInfo mInfo;
final Binder mToken = new Binder();
IWallpaperService mService;
IWallpaperEngine mEngine;
+ public WallpaperConnection(WallpaperInfo info) {
+ mInfo = info;
+ }
+
public void onServiceConnected(ComponentName name, IBinder service) {
synchronized (mLock) {
if (mWallpaperConnection == this) {
mService = IWallpaperService.Stub.asInterface(service);
attachServiceLocked(this);
+ // XXX should probably do saveSettingsLocked() later
+ // when we have an engine, but I'm not sure about
+ // locking there and anyway we always need to be able to
+ // recover if there is something wrong.
+ saveSettingsLocked();
}
}
}
@@ -165,11 +177,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
public ParcelFileDescriptor setWallpaper(String name) {
synchronized (mLock) {
if (mWallpaperConnection == this) {
- ParcelFileDescriptor pfd = updateWallpaperBitmapLocked(name);
- if (pfd != null) {
- saveSettingsLocked();
- }
- return pfd;
+ return updateWallpaperBitmapLocked(name);
}
return null;
}
@@ -283,6 +291,15 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
}
}
+ public WallpaperInfo getWallpaperInfo() {
+ synchronized (mLock) {
+ if (mWallpaperConnection != null) {
+ return mWallpaperConnection.mInfo;
+ }
+ return null;
+ }
+ }
+
public ParcelFileDescriptor setWallpaper(String name) {
checkPermission(android.Manifest.permission.SET_WALLPAPER);
synchronized (mLock) {
@@ -356,32 +373,43 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
+ ": " + realName);
}
+ WallpaperInfo wi = null;
+
Intent intent = new Intent(WallpaperService.SERVICE_INTERFACE);
if (name != null) {
// Make sure the selected service is actually a wallpaper service.
List ris = mContext.getPackageManager()
- .queryIntentServices(intent, 0);
+ .queryIntentServices(intent, PackageManager.GET_META_DATA);
for (int i=0; i