Merge change 24097 into eclair

* changes:
  Fix small bugs in VCardComposer.java.
diff --git a/api/current.xml b/api/current.xml
index a122bd9d..ce2ac27 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -10615,6 +10615,17 @@
  visibility="public"
 >
 </field>
+<field name="screen_background_dark_transparent"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17301673"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="screen_background_light"
  type="int"
  transient="false"
@@ -18115,6 +18126,16 @@
  visibility="public"
 >
 </field>
+<field name="uid"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <class name="ActivityManager.RunningServiceInfo"
  extends="java.lang.Object"
@@ -34398,6 +34419,17 @@
  visibility="public"
 >
 </field>
+<field name="EXTRA_INITIAL_INTENTS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.extra.INITIAL_INTENTS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="EXTRA_INTENT"
  type="java.lang.String"
  transient="false"
@@ -38233,6 +38265,155 @@
 >
 </field>
 </class>
+<class name="LabeledIntent"
+ extends="android.content.Intent"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="LabeledIntent"
+ type="android.content.pm.LabeledIntent"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="origIntent" type="android.content.Intent">
+</parameter>
+<parameter name="sourcePackage" type="java.lang.String">
+</parameter>
+<parameter name="labelRes" type="int">
+</parameter>
+<parameter name="icon" type="int">
+</parameter>
+</constructor>
+<constructor name="LabeledIntent"
+ type="android.content.pm.LabeledIntent"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="origIntent" type="android.content.Intent">
+</parameter>
+<parameter name="sourcePackage" type="java.lang.String">
+</parameter>
+<parameter name="nonLocalizedLabel" type="java.lang.CharSequence">
+</parameter>
+<parameter name="icon" type="int">
+</parameter>
+</constructor>
+<constructor name="LabeledIntent"
+ type="android.content.pm.LabeledIntent"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="sourcePackage" type="java.lang.String">
+</parameter>
+<parameter name="labelRes" type="int">
+</parameter>
+<parameter name="icon" type="int">
+</parameter>
+</constructor>
+<constructor name="LabeledIntent"
+ type="android.content.pm.LabeledIntent"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="sourcePackage" type="java.lang.String">
+</parameter>
+<parameter name="nonLocalizedLabel" type="java.lang.CharSequence">
+</parameter>
+<parameter name="icon" type="int">
+</parameter>
+</constructor>
+<method name="getIconResource"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getLabelResource"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getNonLocalizedLabel"
+ return="java.lang.CharSequence"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSourcePackage"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="loadIcon"
+ return="android.graphics.drawable.Drawable"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pm" type="android.content.pm.PackageManager">
+</parameter>
+</method>
+<method name="loadLabel"
+ return="java.lang.CharSequence"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pm" type="android.content.pm.PackageManager">
+</parameter>
+</method>
+<field name="CREATOR"
+ type="android.os.Parcelable.Creator"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
 <class name="PackageInfo"
  extends="java.lang.Object"
  abstract="false"
@@ -40670,6 +40851,16 @@
  visibility="public"
 >
 </field>
+<field name="resolvePackageName"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="serviceInfo"
  type="android.content.pm.ServiceInfo"
  transient="false"
@@ -40766,6 +40957,21 @@
  visibility="public"
 >
 </method>
+<method name="dump"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pw" type="android.util.Printer">
+</parameter>
+<parameter name="prefix" type="java.lang.String">
+</parameter>
+</method>
 <field name="CREATOR"
  type="android.os.Parcelable.Creator"
  transient="false"
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index af73112..e96de07 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -684,6 +684,11 @@
          */
         public int pid;
         
+        /**
+         * The user id of this process.
+         */
+        public int uid;
+        
         public String pkgList[];
         
         /**
@@ -797,6 +802,7 @@
         public void writeToParcel(Parcel dest, int flags) {
             dest.writeString(processName);
             dest.writeInt(pid);
+            dest.writeInt(uid);
             dest.writeStringArray(pkgList);
             dest.writeInt(importance);
             dest.writeInt(lru);
@@ -808,6 +814,7 @@
         public void readFromParcel(Parcel source) {
             processName = source.readString();
             pid = source.readInt();
+            uid = source.readInt();
             pkgList = source.readStringArray();
             importance = source.readInt();
             lru = source.readInt();
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl
index 4d1e254..69f64a1 100644
--- a/core/java/android/app/IWallpaperManager.aidl
+++ b/core/java/android/app/IWallpaperManager.aidl
@@ -19,6 +19,7 @@
 import android.os.Bundle;
 import android.os.ParcelFileDescriptor;
 import android.app.IWallpaperManagerCallback;
+import android.app.WallpaperInfo;
 import android.content.ComponentName;
 
 /** @hide */
@@ -41,6 +42,11 @@
             out Bundle outParams);
     
     /**
+     * Get information about a live wallpaper.
+     */
+    WallpaperInfo getWallpaperInfo();
+    
+    /**
      * Clear the wallpaper.
      */
     void clearWallpaper();
diff --git a/core/java/android/app/LauncherActivity.java b/core/java/android/app/LauncherActivity.java
index a83f4e8..0ece2fc 100644
--- a/core/java/android/app/LauncherActivity.java
+++ b/core/java/android/app/LauncherActivity.java
@@ -53,9 +53,9 @@
  *
  */
 public abstract class LauncherActivity extends ListActivity {
-
     Intent mIntent;
     PackageManager mPackageManager;
+    IconResizer mIconResizer;
     
     /**
      * An item in the list
@@ -77,7 +77,9 @@
                 label = resolveInfo.activityInfo.name;
             }
             
-            icon = resizer.createIconThumbnail(resolveInfo.loadIcon(pm));
+            if (resizer != null) {
+                icon = resizer.createIconThumbnail(resolveInfo.loadIcon(pm));
+            }
             packageName = ci.applicationInfo.packageName;
             className = ci.name;
         }
@@ -93,13 +95,15 @@
         private final Object lock = new Object();
         private ArrayList<ListItem> mOriginalValues;
 
+        protected final IconResizer mIconResizer;
         protected final LayoutInflater mInflater;
 
         protected List<ListItem> mActivitiesList;
 
         private Filter mFilter;
         
-        public ActivityAdapter() {
+        public ActivityAdapter(IconResizer resizer) {
+            mIconResizer = resizer;
             mInflater = (LayoutInflater) LauncherActivity.this.getSystemService(
                     Context.LAYOUT_INFLATER_SERVICE);
             mActivitiesList = makeListItems();
@@ -154,6 +158,10 @@
         private void bindView(View view, ListItem item) {
             TextView text = (TextView) view;
             text.setText(item.label);
+            if (item.icon == null) {
+                item.icon = mIconResizer.createIconThumbnail(
+                        item.resolveInfo.loadIcon(getPackageManager()));
+            }
             text.setCompoundDrawablesWithIntrinsicBounds(item.icon, null, null, null);
         }
         
@@ -330,9 +338,11 @@
         setProgressBarIndeterminateVisibility(true);
         onSetContentView();
             
+        mIconResizer = new IconResizer();
+        
         mIntent = new Intent(getTargetIntent());
         mIntent.setComponent(null);
-        mAdapter = new ActivityAdapter();
+        mAdapter = new ActivityAdapter(mIconResizer);
         
         setListAdapter(mAdapter);
         getListView().setTextFilterEnabled(true);
@@ -398,13 +408,11 @@
         List<ResolveInfo> list = onQueryPackageManager(mIntent);
         Collections.sort(list, new ResolveInfo.DisplayNameComparator(mPackageManager));
         
-        IconResizer resizer = new IconResizer();
-        
         ArrayList<ListItem> result = new ArrayList<ListItem>(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 0000000..7bbdcae
--- /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 0000000..5e44bc7
--- /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.
+     * 
+     * <p>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<WallpaperInfo> CREATOR = new Parcelable.Creator<WallpaperInfo>() {
+        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 dbe080b..da40c8a 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -49,7 +49,7 @@
     /**
      * 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";
@@ -239,6 +239,20 @@
     }
 
     /**
+     * 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
      * wallpaper; it must be a valid PNG or JPEG image.  On success, the intent
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index e8b2984..c053ace 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1929,6 +1929,15 @@
     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 @@
         }
     };
 
-    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 0000000..d70a698
--- /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<LabeledIntent> CREATOR
+            = new Creator<LabeledIntent>() {
+        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 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
diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java
index b60650c..51d2a4d 100644
--- a/core/java/android/content/pm/ServiceInfo.java
+++ b/core/java/android/content/pm/ServiceInfo.java
@@ -2,6 +2,7 @@
 
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.util.Printer;
 
 /**
  * Information you can retrieve about a particular application
@@ -24,6 +25,11 @@
         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/provider/Settings.java b/core/java/android/provider/Settings.java
index 5bc5855..97955ae 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3485,6 +3485,93 @@
                 "google_calendar_sync_window_update_days";
 
         /**
+         * The number of promoted sources in GlobalSearch.
+         */
+        public static final String SEARCH_NUM_PROMOTED_SOURCES = "search_num_promoted_sources";
+        /**
+         * The maximum number of suggestions returned by GlobalSearch.
+         */
+        public static final String SEARCH_MAX_RESULTS_TO_DISPLAY = "search_max_results_to_display";
+        /**
+         * The number of suggestions GlobalSearch will ask each non-web search source for.
+         */
+        public static final String SEARCH_MAX_RESULTS_PER_SOURCE = "search_max_results_per_source";
+        /**
+         * The number of suggestions the GlobalSearch will ask the web search source for.
+         */
+        public static final String SEARCH_WEB_RESULTS_OVERRIDE_LIMIT =
+                "search_web_results_override_limit";
+        /**
+         * The number of milliseconds that GlobalSearch will wait for suggestions from
+         * promoted sources before continuing with all other sources.
+         */
+        public static final String SEARCH_PROMOTED_SOURCE_DEADLINE_MILLIS =
+                "search_promoted_source_deadline_millis";
+        /**
+         * The number of milliseconds before GlobalSearch aborts search suggesiton queries.
+         */
+        public static final String SEARCH_SOURCE_TIMEOUT_MILLIS = "search_source_timeout_millis";
+        /**
+         * The maximum number of milliseconds that GlobalSearch shows the previous results
+         * after receiving a new query.
+         */
+        public static final String SEARCH_PREFILL_MILLIS = "search_prefill_millis";
+        /**
+         * The maximum age of log data used for shortcuts in GlobalSearch.
+         */
+        public static final String SEARCH_MAX_STAT_AGE_MILLIS = "search_max_stat_age_millis";
+        /**
+         * The maximum age of log data used for source ranking in GlobalSearch.
+         */
+        public static final String SEARCH_MAX_SOURCE_EVENT_AGE_MILLIS =
+                "search_max_source_event_age_millis";
+        /**
+         * The minimum number of impressions needed to rank a source in GlobalSearch.
+         */
+        public static final String SEARCH_MIN_IMPRESSIONS_FOR_SOURCE_RANKING =
+                "search_min_impressions_for_source_ranking";
+        /**
+         * The minimum number of clicks needed to rank a source in GlobalSearch.
+         */
+        public static final String SEARCH_MIN_CLICKS_FOR_SOURCE_RANKING =
+                "search_min_clicks_for_source_ranking";
+        /**
+         * The maximum number of shortcuts shown by GlobalSearch.
+         */
+        public static final String SEARCH_MAX_SHORTCUTS_RETURNED = "search_max_shortcuts_returned";
+        /**
+         * The size of the core thread pool for suggestion queries in GlobalSearch.
+         */
+        public static final String SEARCH_QUERY_THREAD_CORE_POOL_SIZE =
+                "search_query_thread_core_pool_size";
+        /**
+         * The maximum size of the thread pool for suggestion queries in GlobalSearch.
+         */
+        public static final String SEARCH_QUERY_THREAD_MAX_POOL_SIZE =
+                "search_query_thread_max_pool_size";
+        /**
+         * The size of the core thread pool for shortcut refreshing in GlobalSearch.
+         */
+        public static final String SEARCH_SHORTCUT_REFRESH_CORE_POOL_SIZE =
+                "search_shortcut_refresh_core_pool_size";
+        /**
+         * The maximum size of the thread pool for shortcut refreshing in GlobalSearch.
+         */
+        public static final String SEARCH_SHORTCUT_REFRESH_MAX_POOL_SIZE =
+                "search_shortcut_refresh_max_pool_size";
+        /**
+         * The maximun time that excess threads in the GlobalSeach thread pools will
+         * wait before terminating.
+         */
+        public static final String SEARCH_THREAD_KEEPALIVE_SECONDS =
+                "search_thread_keepalive_seconds";
+        /**
+         * The maximum number of concurrent suggestion queries to each source.
+         */
+        public static final String SEARCH_PER_SOURCE_CONCURRENT_QUERY_LIMIT =
+                "search_per_source_concurrent_query_limit";
+
+        /**
          * @deprecated
          * @hide
          */
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 2cdfc66..95b5730 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -50,6 +50,14 @@
     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 <code>&lt;{@link android.R.styleable#Wallpaper wallpaper}&gt;</code>
+     * tag.
+     */
+    public static final String SERVICE_META_DATA = "android.service.wallpaper";
+    
     static final String TAG = "WallpaperService";
     static final boolean DEBUG = false;
     
@@ -377,6 +385,7 @@
                     if (!mCreated) {
                         mLayout.type = mIWallpaperEngine.mWindowType;
                         mLayout.gravity = Gravity.LEFT|Gravity.TOP;
+                        mLayout.setTitle(WallpaperService.this.getClass().getName());
                         mLayout.windowAnimations =
                                 com.android.internal.R.style.Animation_Wallpaper;
                         mSession.add(mWindow, mLayout, View.VISIBLE, mContentInsets);
@@ -558,7 +567,7 @@
                     mSession.remove(mWindow);
                 } catch (RemoteException e) {
                 }
-                mSurfaceHolder.mSurface.clear();
+                mSurfaceHolder.mSurface.release();
                 mCreated = false;
             }
         }
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 5cecac3..b85667b 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -181,7 +181,7 @@
     public Surface(SurfaceSession s,
             int pid, int display, int w, int h, int format, int flags)
         throws OutOfResourcesException {
-        mCanvas = new Canvas();
+        mCanvas = new CompatibleCanvas();
         init(s,pid,display,w,h,format,flags);
     }
 
@@ -271,8 +271,12 @@
      */
     public native   boolean isValid();
     
-    /** Call this free the surface up. {@hide} */
-    public native   void clear();
+    /** Free all server-side state associated with this surface and
+     * release this object's reference. {@hide} */
+    public native void destroy();
+    
+    /** Release the local reference to the server-side surface. @hide */
+    public native void release();
     
     /** draw into a surface */
     public Canvas lockCanvas(Rect dirty) throws OutOfResourcesException, IllegalArgumentException
@@ -400,6 +404,4 @@
             throws OutOfResourcesException;
 
     private native void init(Parcel source);
-    
-    private native void release();
 }
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index fafe00f..b61465a 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1575,7 +1575,7 @@
         if (mUseGL) {
             destroyGL();
         }
-        mSurface.clear();
+        mSurface.release();
 
         try {
             sWindowSession.remove(mWindow);
@@ -2532,7 +2532,7 @@
                     }
                 }
 
-                mSurface.clear();
+                mSurface.release();
             }
             if (mAdded) {
                 mAdded = false;
diff --git a/core/java/android/view/inputmethod/InputMethodInfo.java b/core/java/android/view/inputmethod/InputMethodInfo.java
index b4c5b72..316bcd6 100644
--- a/core/java/android/view/inputmethod/InputMethodInfo.java
+++ b/core/java/android/view/inputmethod/InputMethodInfo.java
@@ -40,7 +40,7 @@
  * 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 @@
     
     @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 1697df2..9ed4dd8 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<pa.length; i++) {
+                if (!(pa[i] instanceof Intent)) {
+                    Log.w("ChooseActivity", "Initial intent #" + i
+                            + " not an Intent: " + pa[i]);
+                    finish();
+                    return;
+                }
+                initialIntents[i] = (Intent)pa[i];
+            }
+        }
+        super.onCreate(savedInstanceState, target, title, initialIntents, false);
     }
 }
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index e907a04..7466cc46 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -23,8 +23,10 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
+import android.content.pm.LabeledIntent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.PatternMatcher;
@@ -61,11 +63,11 @@
     protected void onCreate(Bundle savedInstanceState) {
         onCreate(savedInstanceState, new Intent(getIntent()),
                 getResources().getText(com.android.internal.R.string.whichApplication),
-                true);
+                null, true);
     }
 
     protected void onCreate(Bundle savedInstanceState, Intent intent,
-            CharSequence title, boolean alwaysUseOption) {
+            CharSequence title, Intent[] initialIntents, boolean alwaysUseOption) {
         super.onCreate(savedInstanceState);
         mPm = getPackageManager();
         intent.setComponent(null);
@@ -86,7 +88,7 @@
                                                         com.android.internal.R.id.clearDefaultHint);
             mClearDefaultHint.setVisibility(View.GONE);
         }
-        mAdapter = new ResolveListAdapter(this, intent);
+        mAdapter = new ResolveListAdapter(this, intent, initialIntents);
         if (mAdapter.getCount() > 1) {
             ap.mAdapter = mAdapter;
         } else if (mAdapter.getCount() == 1) {
@@ -185,12 +187,16 @@
     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 @@
 
         private List<DisplayResolveInfo> 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 @@
                             new ResolveInfo.DisplayNameComparator(mPm);
                     Collections.sort(rList, rComparator);
                 }
+                
+                mList = new ArrayList<DisplayResolveInfo>();
+                
+                // First put the initial items at the top.
+                if (initialIntents != null) {
+                    for (int i=0; i<initialIntents.length; i++) {
+                        Intent ii = initialIntents[i];
+                        if (ii == null) {
+                            continue;
+                        }
+                        ActivityInfo ai = ii.resolveActivityInfo(
+                                getPackageManager(), 0);
+                        if (ai == null) {
+                            Log.w("ResolverActivity", "No activity found for "
+                                    + ii);
+                            continue;
+                        }
+                        ResolveInfo ri = new ResolveInfo();
+                        ri.activityInfo = ai;
+                        if (ii instanceof LabeledIntent) {
+                            LabeledIntent li = (LabeledIntent)ii;
+                            ri.resolvePackageName = li.getSourcePackage();
+                            ri.labelRes = li.getLabelResource();
+                            ri.nonLocalizedLabel = li.getNonLocalizedLabel();
+                            ri.icon = li.getIconResource();
+                        }
+                        mList.add(new DisplayResolveInfo(ri,
+                                ri.loadLabel(getPackageManager()), null, ii));
+                    }
+                }
+                
                 // Check for applications with same name and use application name or
                 // package name if necessary
-                mList = new ArrayList<DisplayResolveInfo>();
                 r0 = rList.get(0);
                 int start = 0;
                 CharSequence r0Label =  r0.loadLabel(mPm);
@@ -268,7 +305,7 @@
             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 @@
                     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 @@
                 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 @@
             } 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/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 02677f4..40c8aa0 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -214,7 +214,7 @@
     setSurface(env, clazz, rhs);
 }
 
-static void Surface_clear(JNIEnv* env, jobject clazz, uintptr_t *ostack)
+static void Surface_destroy(JNIEnv* env, jobject clazz, uintptr_t *ostack)
 {
     const sp<SurfaceControl>& surface(getSurfaceControl(env, clazz));
     if (SurfaceControl::isValid(surface)) {
@@ -622,7 +622,7 @@
     {"nativeClassInit",     "()V",  (void*)nativeClassInit },
     {"init",                "(Landroid/view/SurfaceSession;IIIIII)V",  (void*)Surface_init },
     {"init",                "(Landroid/os/Parcel;)V",  (void*)Surface_initParcel },
-    {"clear",               "()V",  (void*)Surface_clear },
+    {"destroy",             "()V",  (void*)Surface_destroy },
     {"release",             "()V",  (void*)Surface_release },
 	{"copyFrom",            "(Landroid/view/Surface;)V",  (void*)Surface_copyFrom },
 	{"isValid",             "()Z",  (void*)Surface_isValid },
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 1e71a99..1fcfe63d 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3407,6 +3407,24 @@
     </declare-styleable>
 
     <!-- =============================== -->
+    <!-- App package class attributes -->
+    <!-- =============================== -->
+
+    <!-- Use <code>wallpaper</code> as the root tag of the XML resource that
+         describes an
+         {@link android.service.wallpaper.WallpaperService}, which is
+         referenced from its
+         {@link android.service.wallpaper.WallpaperService#SERVICE_META_DATA}
+         meta-data entry.  Described here are the attributes that can be
+         included in that tag.
+         @hide Live Wallpaper -->
+    <declare-styleable name="Wallpaper">
+        <!-- Component name of an activity that allows the user to modify
+             the current settings for this wallpaper. -->
+        <attr name="settingsActivity" />
+    </declare-styleable>
+
+    <!-- =============================== -->
     <!-- Accounts package class attributes -->
     <!-- =============================== -->
 
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 1057c09..560796a 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -24,6 +24,7 @@
     <drawable name="status_bar_opened_default_background">#ff000000</drawable>
     <drawable name="search_bar_default_color">#ff000000</drawable>
     <drawable name="safe_mode_background">#60000000</drawable>
+    <drawable name="screen_background_dark_transparent">#80000000</drawable>
     <color name="safe_mode_text">#80ffffff</color>
     <color name="white">#ffffffff</color>
     <color name="black">#ff000000</color>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 3be3ef8..8541c73 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1166,4 +1166,10 @@
   <public type="style" name="Theme.Wallpaper" />
   <public type="style" name="Theme.Wallpaper.NoTitleBar" />
   <public type="style" name="Theme.Wallpaper.NoTitleBar.Fullscreen" />
+  
+  <!-- Semi-transparent background that can be used when placing a dark
+       themed UI on top of some arbitrary background (such as the
+       wallpaper).  This darkens the background sufficiently that the UI
+       can be seen. -->
+  <public type="drawable" name="screen_background_dark_transparent" />
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3333915..250612f 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1972,5 +1972,7 @@
     <string name="accessibility_binding_label">Accessibility</string>
     <!-- Label to show for a service that is running because it is a wallpaper. -->
     <string name="wallpaper_binding_label">Wallpaper</string>
+    <!-- Dialog title for user to select a different wallpaper from service list -->
+    <string name="chooser_wallpaper">Change wallpaper</string>
     
 </resources>
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index cc977b0..4b6049f 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -22,6 +22,7 @@
 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.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.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 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 @@
         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 @@
         }
     }
 
+    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 @@
                         + ": " + 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<ResolveInfo> ris = mContext.getPackageManager()
-                        .queryIntentServices(intent, 0);
+                        .queryIntentServices(intent, PackageManager.GET_META_DATA);
                 for (int i=0; i<ris.size(); i++) {
                     ServiceInfo rsi = ris.get(i).serviceInfo;
                     if (rsi.name.equals(si.name) &&
                             rsi.packageName.equals(si.packageName)) {
-                        ris = null;
+                        try {
+                            wi = new WallpaperInfo(mContext, ris.get(i));
+                        } catch (XmlPullParserException e) {
+                            throw new IllegalArgumentException(e);
+                        } catch (IOException e) {
+                            throw new IllegalArgumentException(e);
+                        }
                         break;
                     }
                 }
-                if (ris != null) {
+                if (wi == null) {
                     throw new SecurityException("Selected service is not a wallpaper: "
                             + realName);
                 }
             }
             
             // Bind the service!
-            WallpaperConnection newConn = new WallpaperConnection();
+            WallpaperConnection newConn = new WallpaperConnection(wi);
             intent.setComponent(realName);
             intent.putExtra(Intent.EXTRA_CLIENT_LABEL,
                     com.android.internal.R.string.wallpaper_binding_label);
             intent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
-                    mContext, 0, new Intent(Intent.ACTION_SET_WALLPAPER), 0));
+                    mContext, 0,
+                    Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER),
+                            mContext.getText(com.android.internal.R.string.chooser_wallpaper)),
+                            0));
             if (!mContext.bindService(intent, newConn,
                     Context.BIND_AUTO_CREATE)) {
                 throw new IllegalArgumentException("Unable to bind service: "
@@ -640,4 +668,35 @@
         }
         return false;
     }
+    
+    @Override
+    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
+                != PackageManager.PERMISSION_GRANTED) {
+            
+            pw.println("Permission Denial: can't dump wallpaper service from from pid="
+                    + Binder.getCallingPid()
+                    + ", uid=" + Binder.getCallingUid());
+            return;
+        }
+
+        synchronized (mLock) {
+            pw.println("Current Wallpaper Service state:");
+            pw.print("  mWidth="); pw.print(mWidth);
+                    pw.print(" mHeight="); pw.println(mHeight);
+            pw.print("  mName="); pw.println(mName);
+            pw.print("  mWallpaperComponent="); pw.println(mWallpaperComponent);
+            if (mWallpaperConnection != null) {
+                WallpaperConnection conn = mWallpaperConnection;
+                pw.print("  Wallpaper connection ");
+                        pw.print(conn); pw.println(":");
+                pw.print("    mInfo.component="); pw.println(conn.mInfo.getComponent());
+                pw.print("    mToken="); pw.println(conn.mToken);
+                pw.print("    mService="); pw.println(conn.mService);
+                pw.print("    mEngine="); pw.println(conn.mEngine);
+                pw.print("    mLastDiedTime=");
+                        pw.println(mLastDiedTime - SystemClock.uptimeMillis());
+            }
+        }
+    }
 }
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index b4f4768..c8ff6cb 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -1207,8 +1207,11 @@
                 || mLowerWallpaperTarget != null;
     }
     
-    boolean adjustWallpaperWindowsLocked() {
-        boolean changed = false;
+    static final int ADJUST_WALLPAPER_LAYERS_CHANGED = 1<<1;
+    static final int ADJUST_WALLPAPER_VISIBILITY_CHANGED = 1<<2;
+    
+    int adjustWallpaperWindowsLocked() {
+        int changed = 0;
         
         final int dw = mDisplay.getWidth();
         final int dh = mDisplay.getHeight();
@@ -1274,12 +1277,12 @@
             if (mWallpaperTarget != null && mWallpaperTarget.mAppToken != null) {
                 if (DEBUG_WALLPAPER) Log.v(TAG,
                         "Wallpaper not changing: waiting for app anim in current target");
-                return false;
+                return 0;
             }
             if (foundW != null && foundW.mAppToken != null) {
                 if (DEBUG_WALLPAPER) Log.v(TAG,
                         "Wallpaper not changing: waiting for app anim in found target");
-                return false;
+                return 0;
             }
         }
         
@@ -1410,7 +1413,13 @@
         while (curTokenIndex > 0) {
             curTokenIndex--;
             WindowToken token = mWallpaperTokens.get(curTokenIndex);
-            token.hidden = !visible;
+            if (token.hidden == visible) {
+                changed |= ADJUST_WALLPAPER_VISIBILITY_CHANGED;
+                token.hidden = !visible;
+                // Need to do a layout to ensure the wallpaper now has the
+                // correct size.
+                mLayoutNeeded = true;
+            }
             
             int curWallpaperIndex = token.windows.size();
             while (curWallpaperIndex > 0) {
@@ -1463,7 +1472,7 @@
                         + " from " + oldIndex + " to " + foundI);
                 
                 localmWindows.add(foundI, wallpaper);
-                changed = true;
+                changed |= ADJUST_WALLPAPER_LAYERS_CHANGED;
             }
         }
         
@@ -1574,7 +1583,12 @@
         while (curTokenIndex > 0) {
             curTokenIndex--;
             WindowToken token = mWallpaperTokens.get(curTokenIndex);
-            token.hidden = !visible;
+            if (token.hidden == visible) {
+                token.hidden = !visible;
+                // Need to do a layout to ensure the wallpaper now has the
+                // correct size.
+                mLayoutNeeded = true;
+            }
             
             int curWallpaperIndex = token.windows.size();
             while (curWallpaperIndex > 0) {
@@ -1999,10 +2013,15 @@
             synchronized (mWindowMap) {
                 WindowState w = windowForClientLocked(session, client);
                 if ((w != null) && (w.mSurface != null)) {
+                    if (SHOW_TRANSACTIONS) Log.i(TAG, ">>> OPEN TRANSACTION");
                     Surface.openTransaction();
                     try {
+                        if (SHOW_TRANSACTIONS) Log.i(
+                                TAG, "  SURFACE " + w.mSurface
+                                + ": transparentRegionHint=" + region);
                         w.mSurface.setTransparentRegionHint(region);
                     } finally {
+                        if (SHOW_TRANSACTIONS) Log.i(TAG, "<<< CLOSE TRANSACTION");
                         Surface.closeTransaction();
                     }
                 }
@@ -2149,13 +2168,17 @@
                     Surface surface = win.createSurfaceLocked();
                     if (surface != null) {
                         outSurface.copyFrom(surface);
+                        if (SHOW_TRANSACTIONS) Log.i(TAG,
+                                "  OUT SURFACE " + outSurface + ": copied");
                     } else {
-                        outSurface.clear();
+                        // For some reason there isn't a surface.  Clear the
+                        // caller's object so they see the same state.
+                        outSurface.release();
                     }
                 } catch (Exception e) {
                     Log.w(TAG, "Exception thrown when creating surface for client "
-                         + client + " (" + win.mAttrs.getTitle() + ")",
-                         e);
+                             + client + " (" + win.mAttrs.getTitle() + ")",
+                             e);
                     Binder.restoreCallingIdentity(origId);
                     return 0;
                 }
@@ -2196,7 +2219,11 @@
                         }
                     }
                 }
-                outSurface.clear();
+                // We are being called from a local process, which
+                // means outSurface holds its current surface.  Ensure the
+                // surface object is cleared, but we don't want it actually
+                // destroyed at this point.
+                outSurface.release();
             }
 
             if (focusMayChange) {
@@ -2217,7 +2244,7 @@
                 }
             }
             if (wallpaperMayMove) {
-                if (adjustWallpaperWindowsLocked()) {
+                if ((adjustWallpaperWindowsLocked()&ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
                     assignLayers = true;
                 }
             }
@@ -6281,6 +6308,8 @@
                 if (localLOGV) Log.v(
                     TAG, "First window added to " + this + ", creating SurfaceSession");
                 mSurfaceSession = new SurfaceSession();
+                if (SHOW_TRANSACTIONS) Log.i(
+                        TAG, "  NEW SURFACE SESSION " + mSurfaceSession);
                 mSessions.add(this);
             }
             mNumWindow++;
@@ -6298,6 +6327,8 @@
                     if (localLOGV) Log.v(
                         TAG, "Last window removed from " + this
                         + ", destroying " + mSurfaceSession);
+                    if (SHOW_TRANSACTIONS) Log.i(
+                            TAG, "  KILL SURFACE SESSION " + mSurfaceSession);
                     try {
                         mSurfaceSession.kill();
                     } catch (Exception e) {
@@ -6794,6 +6825,12 @@
                     mSurface = new Surface(
                             mSession.mSurfaceSession, mSession.mPid,
                             0, w, h, mAttrs.format, flags);
+                    if (SHOW_TRANSACTIONS) Log.i(TAG, "  CREATE SURFACE "
+                            + mSurface + " IN SESSION "
+                            + mSession.mSurfaceSession
+                            + ": pid=" + mSession.mPid + " format="
+                            + mAttrs.format + " flags=0x"
+                            + Integer.toHexString(flags));
                 } catch (Surface.OutOfResourcesException e) {
                     Log.w(TAG, "OutOfResourcesException creating surface");
                     reclaimSomeSurfaceMemoryLocked(this, "create");
@@ -6823,6 +6860,8 @@
                         mSurface.setLayer(mAnimLayer);
                         mSurface.hide();
                         if ((mAttrs.flags&WindowManager.LayoutParams.FLAG_DITHER) != 0) {
+                            if (SHOW_TRANSACTIONS) Log.i(TAG, "  SURFACE "
+                                    + mSurface + ": DITHER");
                             mSurface.setFlags(Surface.SURFACE_DITHER,
                                     Surface.SURFACE_DITHER);
                         }
@@ -6868,7 +6907,7 @@
                         Log.i(TAG, "  SURFACE " + mSurface + ": DESTROY ("
                                 + mAttrs.getTitle() + ")", ex);
                     }
-                    mSurface.clear();
+                    mSurface.destroy();
                 } catch (RuntimeException e) {
                     Log.w(TAG, "Exception thrown when destroying Window " + this
                         + " surface " + mSurface + " session " + mSession
@@ -8840,6 +8879,8 @@
                         if (w.commitFinishDrawingLocked(currentTime)) {
                             if ((w.mAttrs.flags
                                     & WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER) != 0) {
+                                if (DEBUG_WALLPAPER) Log.v(TAG,
+                                        "First draw done in potential wallpaper target " + w);
                                 wallpaperMayChange = true;
                             }
                         }
@@ -9134,10 +9175,23 @@
                 }
                 
                 if (wallpaperMayChange) {
-                    if (adjustWallpaperWindowsLocked()) {
+                    if (DEBUG_WALLPAPER) Log.v(TAG,
+                            "Wallpaper may change!  Adjusting");
+                    int adjResult = adjustWallpaperWindowsLocked();
+                    if ((adjResult&ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
+                        if (DEBUG_WALLPAPER) Log.v(TAG,
+                                "Wallpaper layer changed: assigning layers + relayout");
+                        restart = true;
+                        mLayoutNeeded = true;
                         assignLayersLocked();
+                    } else if ((adjResult&ADJUST_WALLPAPER_VISIBILITY_CHANGED) != 0) {
+                        if (DEBUG_WALLPAPER) Log.v(TAG,
+                                "Wallpaper visibility changed: relayout");
+                        restart = true;
+                        mLayoutNeeded = true;
                     }
                     if (mLayoutNeeded) {
+                        restart = true;
                         performLayoutLockedInner();
                     }
                 }
@@ -9184,6 +9238,10 @@
                         w.mLastRequestedHeight = height;
                         w.mLastShownFrame.set(w.mShownFrame);
                         try {
+                            if (SHOW_TRANSACTIONS) Log.i(
+                                    TAG, "  SURFACE " + w.mSurface
+                                    + ": POS " + w.mShownFrame.left
+                                    + ", " + w.mShownFrame.top);
                             w.mSurface.setPosition(w.mShownFrame.left, w.mShownFrame.top);
                         } catch (RuntimeException e) {
                             Log.w(TAG, "Error positioning surface in " + w, e);
@@ -9196,14 +9254,6 @@
                         width = w.mShownFrame.width();
                         height = w.mShownFrame.height();
                         w.mLastShownFrame.set(w.mShownFrame);
-                        if (resize) {
-                            if (SHOW_TRANSACTIONS) Log.i(
-                                    TAG, "  SURFACE " + w.mSurface + ": ("
-                                    + w.mShownFrame.left + ","
-                                    + w.mShownFrame.top + ") ("
-                                    + w.mShownFrame.width() + "x"
-                                    + w.mShownFrame.height() + ")");
-                        }
                     }
 
                     if (resize) {
@@ -9211,6 +9261,12 @@
                         if (height < 1) height = 1;
                         if (w.mSurface != null) {
                             try {
+                                if (SHOW_TRANSACTIONS) Log.i(
+                                        TAG, "  SURFACE " + w.mSurface + ": POS "
+                                        + w.mShownFrame.left + ","
+                                        + w.mShownFrame.top + " SIZE "
+                                        + w.mShownFrame.width() + "x"
+                                        + w.mShownFrame.height());
                                 w.mSurface.setSize(width, height);
                                 w.mSurface.setPosition(w.mShownFrame.left,
                                         w.mShownFrame.top);
@@ -9239,6 +9295,22 @@
                             w.mLastFrame.set(w.mFrame);
                             w.mLastContentInsets.set(w.mContentInsets);
                             w.mLastVisibleInsets.set(w.mVisibleInsets);
+                            // If the screen is currently frozen, then keep
+                            // it frozen until this window draws at its new
+                            // orientation.
+                            if (mDisplayFrozen) {
+                                if (DEBUG_ORIENTATION) Log.v(TAG,
+                                        "Resizing while display frozen: " + w);
+                                w.mOrientationChanging = true;
+                                if (mWindowsFreezingScreen) {
+                                    mWindowsFreezingScreen = true;
+                                    // XXX should probably keep timeout from
+                                    // when we first froze the display.
+                                    mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
+                                    mH.sendMessageDelayed(mH.obtainMessage(
+                                            H.WINDOW_FREEZE_TIMEOUT), 2000);
+                                }
+                            }
                             // If the orientation is changing, then we need to
                             // hold off on unfreezing the display until this
                             // window has been redrawn; to do that, we need
@@ -9340,7 +9412,11 @@
                         w.mLastVScale = w.mVScale;
                         if (SHOW_TRANSACTIONS) Log.i(
                                 TAG, "  SURFACE " + w.mSurface + ": alpha="
-                                + w.mShownAlpha + " layer=" + w.mAnimLayer);
+                                + w.mShownAlpha + " layer=" + w.mAnimLayer
+                                + " matrix=[" + (w.mDsDx*w.mHScale)
+                                + "," + (w.mDtDx*w.mVScale)
+                                + "][" + (w.mDsDy*w.mHScale)
+                                + "," + (w.mDtDy*w.mVScale) + "]");
                         if (w.mSurface != null) {
                             try {
                                 w.mSurface.setAlpha(w.mShownAlpha);
@@ -9571,6 +9647,8 @@
                 i--;
                 WindowState win = mResizingWindows.get(i);
                 try {
+                    if (DEBUG_ORIENTATION) Log.v(TAG, "Reporting new frame to "
+                            + win + ": " + win.mFrame);
                     win.mClient.resized(win.mFrame.width(),
                             win.mFrame.height(), win.mLastContentInsets,
                             win.mLastVisibleInsets, win.mDrawPending);
@@ -9642,7 +9720,7 @@
             mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS);
         }
         if (wallpaperDestroyed) {
-            needRelayout = adjustWallpaperWindowsLocked();            
+            needRelayout = adjustWallpaperWindowsLocked() != 0;
         }
         if (needRelayout) {
             requestAnimationLocked(0);
@@ -9720,7 +9798,7 @@
                                 + " token=" + win.mToken
                                 + " pid=" + ws.mSession.mPid
                                 + " uid=" + ws.mSession.mUid);
-                        ws.mSurface.clear();
+                        ws.mSurface.destroy();
                         ws.mSurface = null;
                         mForceRemoves.add(ws);
                         i--;
@@ -9730,7 +9808,7 @@
                         Log.w(TAG, "LEAKED SURFACE (app token hidden): "
                                 + ws + " surface=" + ws.mSurface
                                 + " token=" + win.mAppToken);
-                        ws.mSurface.clear();
+                        ws.mSurface.destroy();
                         ws.mSurface = null;
                         leakedSurface = true;
                     }
@@ -9766,7 +9844,7 @@
                 // surface and ask the app to request another one.
                 Log.w(TAG, "Looks like we have reclaimed some memory, clearing surface for retry.");
                 if (surface != null) {
-                    surface.clear();
+                    surface.destroy();
                     win.mSurface = null;
                 }
 
@@ -10025,6 +10103,16 @@
                     w.dump(pw, "    ");
                 }
             }
+            if (mResizingWindows.size() > 0) {
+                pw.println(" ");
+                pw.println("  Windows waiting to resize:");
+                for (int i=mResizingWindows.size()-1; i>=0; i--) {
+                    WindowState w = mResizingWindows.get(i);
+                    pw.print("  Resizing #"); pw.print(i); pw.print(' ');
+                            pw.print(w); pw.println(":");
+                    w.dump(pw, "    ");
+                }
+            }
             if (mSessions.size() > 0) {
                 pw.println(" ");
                 pw.println("  All active sessions:");
@@ -10227,7 +10315,8 @@
             mDimSurface.setLayer(w.mAnimLayer-1);
 
             final float target = w.mExiting ? 0 : w.mAttrs.dimAmount;
-            if (SHOW_TRANSACTIONS) Log.i(TAG, "layer=" + (w.mAnimLayer-1) + ", target=" + target);
+            if (SHOW_TRANSACTIONS) Log.i(TAG, "  DIM " + mDimSurface
+                    + ": layer=" + (w.mAnimLayer-1) + " target=" + target);
             if (mDimTargetAlpha != target) {
                 // If the desired dim level has changed, then
                 // start an animation to it.
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9554a22..0b86fc0 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -136,6 +136,7 @@
     static final boolean DEBUG_SERVICE = localLOGV || false;
     static final boolean DEBUG_VISBILITY = localLOGV || false;
     static final boolean DEBUG_PROCESSES = localLOGV || false;
+    static final boolean DEBUG_PROVIDER = localLOGV || false;
     static final boolean DEBUG_USER_LEAVING = localLOGV || false;
     static final boolean DEBUG_RESULTS = localLOGV || false;
     static final boolean DEBUG_BACKUP = localLOGV || true;
@@ -7411,9 +7412,13 @@
 
                 final long origId = Binder.clearCallingIdentity();
 
-                // In this case the provider is a single instance, so we can
+                // In this case the provider instance already exists, so we can
                 // return it right away.
                 if (r != null) {
+                    if (DEBUG_PROVIDER) Log.v(TAG,
+                            "Adding provider requested by "
+                            + r.processName + " from process "
+                            + cpr.info.processName);                    
                     r.conProviders.add(cpr);
                     cpr.clients.add(r);
                 } else {
@@ -7471,10 +7476,10 @@
                     return cpr;
                 }
 
-                if (false) {
-                    RuntimeException e = new RuntimeException("foo");
-                    //Log.w(TAG, "LAUNCHING REMOTE PROVIDER (myuid " + r.info.uid
-                    //      + " pruid " + ai.uid + "): " + cpi.className, e);
+                if (DEBUG_PROVIDER) {
+                    RuntimeException e = new RuntimeException("here");
+                    Log.w(TAG, "LAUNCHING REMOTE PROVIDER (myuid " + r.info.uid
+                          + " pruid " + cpr.appInfo.uid + "): " + cpr.info.name, e);
                 }
 
                 // This is single process, and our app is now connecting to it.
@@ -7486,14 +7491,6 @@
                     if (mLaunchingProviders.get(i) == cpr) {
                         break;
                     }
-                    if (false) {
-                        final ContentProviderRecord rec =
-                            (ContentProviderRecord)mLaunchingProviders.get(i);
-                        if (rec.info.name.equals(cpr.info.name)) {
-                            cpr = rec;
-                            break;
-                        }
-                    }
                 }
 
                 // If the provider is not already being launched, then get it
@@ -7524,6 +7521,10 @@
                 mProvidersByName.put(name, cpr);
 
                 if (r != null) {
+                    if (DEBUG_PROVIDER) Log.v(TAG,
+                            "Adding provider requested by "
+                            + r.processName + " from process "
+                            + cpr.info.processName);                    
                     r.conProviders.add(cpr);
                     cpr.clients.add(r);
                 } else {
@@ -7578,8 +7579,9 @@
         synchronized (this) {
             ContentProviderRecord cpr = (ContentProviderRecord)mProvidersByName.get(name);
             if(cpr == null) {
-                //remove from mProvidersByClass
-                if(localLOGV) Log.v(TAG, name+" content provider not found in providers list");
+                // remove from mProvidersByClass
+                if (DEBUG_PROVIDER) Log.v(TAG, name +
+                        " provider not found in providers list");
                 return;
             }
             final ProcessRecord r = getRecordForAppLocked(caller);
@@ -7589,12 +7591,15 @@
                         " when removing content provider " + name);
             }
             //update content provider record entry info
-            ContentProviderRecord localCpr = (ContentProviderRecord) mProvidersByClass.get(cpr.info.name);
-            if(localLOGV) Log.v(TAG, "Removing content provider requested by "+
-                    r.info.processName+" from process "+localCpr.appInfo.processName);
-            if(localCpr.appInfo.processName ==  r.info.processName) {
+            ContentProviderRecord localCpr = (ContentProviderRecord)
+                    mProvidersByClass.get(cpr.info.name);
+            if (DEBUG_PROVIDER) Log.v(TAG, "Removing provider requested by "
+                    + r.info.processName + " from process "
+                    + localCpr.appInfo.processName);
+            if (localCpr.app == r) {
                 //should not happen. taken care of as a local provider
-                if(localLOGV) Log.v(TAG, "local provider doing nothing Ignoring other names");
+                Log.w(TAG, "removeContentProvider called on local provider: "
+                        + cpr.info.name + " in process " + r.processName);
                 return;
             } else {
                 localCpr.clients.remove(r);
@@ -8850,6 +8855,7 @@
                     ActivityManager.RunningAppProcessInfo currApp = 
                         new ActivityManager.RunningAppProcessInfo(app.processName,
                                 app.pid, app.getPackageList());
+                    currApp.uid = app.info.uid;
                     int adj = app.curAdj;
                     if (adj >= CONTENT_PROVIDER_ADJ) {
                         currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY;
@@ -10511,7 +10517,8 @@
             r.app.services.remove(r);
             if (r.app.thread != null) {
                 try {
-                    Log.i(TAG, "Stopping service: " + r.shortName);
+                    if (DEBUG_SERVICE) Log.v(TAG,
+                            "Stopping service: " + r.shortName);
                     bumpServiceExecutingLocked(r);
                     mStoppingServices.add(r);
                     updateOomAdjLocked(r.app);
diff --git a/tests/AndroidTests/src/com/android/unit_tests/SMSTest.java b/tests/AndroidTests/src/com/android/unit_tests/GsmSmsTest.java
similarity index 99%
rename from tests/AndroidTests/src/com/android/unit_tests/SMSTest.java
rename to tests/AndroidTests/src/com/android/unit_tests/GsmSmsTest.java
index 9d44fd9..24698fb 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/SMSTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/GsmSmsTest.java
@@ -25,7 +25,7 @@
 
 import java.util.Iterator;
 
-public class SMSTest extends AndroidTestCase {
+public class GsmSmsTest extends AndroidTestCase {
 
     @SmallTest
     public void testOne() throws Exception {
diff --git a/tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java
index 6f25fd9..db38ede 100644
--- a/tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java
+++ b/tests/CoreTests/com/android/internal/telephony/SimUtilsTest.java
@@ -59,7 +59,7 @@
         assertEquals(89, IccUtils.cdmaBcdByteToInt((byte) 0x89));
 
         // Out of range is treated as 0
-        assertEquals(80, IccUtils.gsmBcdByteToInt((byte) 0x8c));
+        assertEquals(80, IccUtils.cdmaBcdByteToInt((byte) 0x8c));
 
         /*
          * adnStringFieldToString()