Merge changes 1591,1596 into donut

* changes:
  Add a new feature to android.os.Debug to add the ability to inject only specific fields when calling setFieldsOn().
  Fixes #1836075. Adds consistency checks for the View hierarchy. To enable them, you need a debug build and ViewDebug.sConsistencyCheckEnabled set to true in debug.prop. This change also lets you easily enable drawing and layout profiling in ViewRoot by setting ViewRoot.sProfileDrawing, ViewRoot.sProfileLayout and ViewRoot.sShowFps in debug.prop with a debug build.
diff --git a/api/1.xml b/api/1.xml
index b196ac7..02e8eac 100644
--- a/api/1.xml
+++ b/api/1.xml
@@ -88531,7 +88531,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="predicates" type="com.android.internal.util.Predicate...">
+<parameter name="predicates" type="com.android.internal.util.Predicate&lt;android.test.suitebuilder.TestMethod&gt;...">
 </parameter>
 </method>
 <method name="build"
@@ -169208,7 +169208,7 @@
 >
 <parameter name="loader" type="java.lang.ClassLoader">
 </parameter>
-<parameter name="interfaces" type="java.lang.Class...">
+<parameter name="interfaces" type="java.lang.Class&lt;?&gt;...">
 </parameter>
 <exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
 </exception>
diff --git a/api/2.xml b/api/2.xml
index b9736fe..65e7cec 100644
--- a/api/2.xml
+++ b/api/2.xml
@@ -88575,7 +88575,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="predicates" type="com.android.internal.util.Predicate...">
+<parameter name="predicates" type="com.android.internal.util.Predicate&lt;android.test.suitebuilder.TestMethod&gt;...">
 </parameter>
 </method>
 <method name="build"
@@ -169353,7 +169353,7 @@
 >
 <parameter name="loader" type="java.lang.ClassLoader">
 </parameter>
-<parameter name="interfaces" type="java.lang.Class...">
+<parameter name="interfaces" type="java.lang.Class&lt;?&gt;...">
 </parameter>
 <exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
 </exception>
diff --git a/api/current.xml b/api/current.xml
index 623b986..56e2309 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -21839,219 +21839,6 @@
 </field>
 </class>
 </package>
-<package name="android.backup"
->
-<class name="BackupDataOutput"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<constructor name="BackupDataOutput"
- type="android.backup.BackupDataOutput"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="fd" type="java.io.FileDescriptor">
-</parameter>
-</constructor>
-<method name="close"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="flush"
- return="void"
- abstract="false"
- native="true"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="write"
- return="void"
- abstract="false"
- native="true"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="buffer" type="byte[]">
-</parameter>
-</method>
-<method name="write"
- return="void"
- abstract="false"
- native="true"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="oneByte" type="int">
-</parameter>
-</method>
-<method name="write"
- return="void"
- abstract="false"
- native="true"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="buffer" type="byte[]">
-</parameter>
-<parameter name="offset" type="int">
-</parameter>
-<parameter name="count" type="int">
-</parameter>
-</method>
-<method name="writeKey"
- return="void"
- abstract="false"
- native="true"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="key" type="java.lang.String">
-</parameter>
-</method>
-<method name="writeOperation"
- return="void"
- abstract="false"
- native="true"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="op" type="int">
-</parameter>
-</method>
-<field name="OP_DELETE"
- type="int"
- transient="false"
- volatile="false"
- value="2"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="OP_UPDATE"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-</class>
-<class name="FileBackupHelper"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<constructor name="FileBackupHelper"
- type="android.backup.FileBackupHelper"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="performBackup"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="oldSnapshot" type="android.os.ParcelFileDescriptor">
-</parameter>
-<parameter name="newSnapshot" type="android.os.ParcelFileDescriptor">
-</parameter>
-<parameter name="data" type="android.backup.BackupDataOutput">
-</parameter>
-<parameter name="files" type="java.lang.String[]">
-</parameter>
-</method>
-</class>
-<class name="SharedPreferencesBackupHelper"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<constructor name="SharedPreferencesBackupHelper"
- type="android.backup.SharedPreferencesBackupHelper"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="performBackup"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="context" type="android.content.Context">
-</parameter>
-<parameter name="oldSnapshot" type="android.os.ParcelFileDescriptor">
-</parameter>
-<parameter name="newSnapshot" type="android.os.ParcelFileDescriptor">
-</parameter>
-<parameter name="data" type="android.backup.BackupDataOutput">
-</parameter>
-<parameter name="prefGroups" type="java.lang.String[]">
-</parameter>
-</method>
-</class>
-</package>
 <package name="android.content"
 >
 <class name="ActivityNotFoundException"
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index a174843..3e12fe6 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -309,11 +309,23 @@
                     + appSearchData + ", " + globalSearch + ")");
         }
         
+        // Try to get the searchable info for the provided component (or for global search,
+        // if globalSearch == true).
         mSearchable = SearchManager.getSearchableInfo(componentName, globalSearch);
-        if (mSearchable == null) {
-            // unfortunately, we can't log here.  it would be logspam every time the user
-            // clicks the "search" key on a non-search app
-            return false;
+        
+        // If we got back nothing, and it wasn't a request for global search, then try again
+        // for global search, as we'll try to launch that in lieu of any component-specific search.
+        if (!globalSearch && mSearchable == null) {
+            globalSearch = true;
+            mSearchable = SearchManager.getSearchableInfo(componentName, globalSearch);
+            
+            // If we still get back null (i.e., there's not even a searchable info available
+            // for global search), then really give up.
+            if (mSearchable == null) {
+                // Unfortunately, we can't log here.  it would be logspam every time the user
+                // clicks the "search" key on a non-search app.
+                return false;
+            }
         }
         
         mLaunchComponent = componentName;
diff --git a/core/java/android/appwidget/AppWidgetProvider.java b/core/java/android/appwidget/AppWidgetProvider.java
index 7871fb6..26712a1 100755
--- a/core/java/android/appwidget/AppWidgetProvider.java
+++ b/core/java/android/appwidget/AppWidgetProvider.java
@@ -22,7 +22,7 @@
 import android.os.Bundle;
 
 /**
- * A conveience class to aid in implementing an AppWidget provider.
+ * A convenience class to aid in implementing an AppWidget provider.
  * Everything you can do with AppWidgetProvider, you can do with a regular {@link BroadcastReceiver}.
  * AppWidgetProvider merely parses the relevant fields out of the Intent that is received in
  * {@link #onReceive(Context,Intent) onReceive(Context,Intent)}, and calls hook methods
diff --git a/core/java/android/backup/BackupDataOutput.java b/core/java/android/backup/BackupDataOutput.java
index 6c47f7e..555494e 100644
--- a/core/java/android/backup/BackupDataOutput.java
+++ b/core/java/android/backup/BackupDataOutput.java
@@ -20,6 +20,7 @@
 
 import java.io.FileDescriptor;
 
+/** @hide */
 public class BackupDataOutput {
     /* package */ FileDescriptor fd;
 
diff --git a/core/java/android/backup/BackupService.java b/core/java/android/backup/BackupService.java
index 6ac703a..50a5921 100644
--- a/core/java/android/backup/BackupService.java
+++ b/core/java/android/backup/BackupService.java
@@ -75,9 +75,8 @@
      *                 file.  The application should record the final backup state
      *                 here after writing the requested data to dataFd.
      */
-    public abstract void onBackup(ParcelFileDescriptor oldState,
-            ParcelFileDescriptor data,
-            ParcelFileDescriptor newState);
+    public abstract void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+             ParcelFileDescriptor newState);
     
     /**
      * The application is being restored from backup, and should replace any
@@ -92,7 +91,7 @@
      *                 file.  The application should record the final backup state
      *                 here after restoring its data from dataFd.
      */
-    public abstract void onRestore(ParcelFileDescriptor data, ParcelFileDescriptor newState);
+    public abstract void onRestore(ParcelFileDescriptor /* TODO: BackupDataInput */ data, ParcelFileDescriptor newState);
 
 
     // ----- Core implementation -----
@@ -117,7 +116,15 @@
                 ParcelFileDescriptor newState) throws RemoteException {
             // !!! TODO - real implementation; for now just invoke the callbacks directly
             Log.v("BackupServiceBinder", "doBackup() invoked");
-            BackupService.this.onBackup(oldState, data, newState);
+            BackupDataOutput output = new BackupDataOutput(BackupService.this,
+                    data.getFileDescriptor());
+            try {
+                BackupService.this.onBackup(oldState, output, newState);
+            } catch (RuntimeException ex) {
+                Log.d("BackupService", "onBackup ("
+                        + BackupService.this.getClass().getName() + ") threw", ex);
+                throw ex;
+            }
         }
 
         public void doRestore(ParcelFileDescriptor data,
diff --git a/core/java/android/backup/FileBackupHelper.java b/core/java/android/backup/FileBackupHelper.java
index 3b2122c..2762f22 100644
--- a/core/java/android/backup/FileBackupHelper.java
+++ b/core/java/android/backup/FileBackupHelper.java
@@ -18,20 +18,24 @@
 
 import android.content.Context;
 import android.os.ParcelFileDescriptor;
+import android.util.Log;
 
 import java.io.FileDescriptor;
 
+/** @hide */
 public class FileBackupHelper {
+    private static final String TAG = "FileBackupHelper";
+
     /**
-     * Based on oldSnapshot, determine which of the files from the application's data directory
-     * need to be backed up, write them to the data stream, and fill in newSnapshot with the
+     * Based on oldState, determine which of the files from the application's data directory
+     * need to be backed up, write them to the data stream, and fill in newState with the
      * state as it exists now.
      */
     public static void performBackup(Context context,
-            ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot,
-            BackupDataOutput data, String[] files) {
+            ParcelFileDescriptor oldState, BackupDataOutput data,
+            ParcelFileDescriptor newState, String[] files) {
         String basePath = context.getFilesDir().getAbsolutePath();
-        performBackup_checked(basePath, oldSnapshot, newSnapshot, data, files);
+        performBackup_checked(basePath, oldState, data, newState, files);
     }
 
     /**
@@ -39,30 +43,34 @@
      * since it's easier to do that from java.
      */
     static void performBackup_checked(String basePath,
-            ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot,
-            BackupDataOutput data, String[] files) {
-        if (newSnapshot == null) {
-            throw new NullPointerException("newSnapshot==null");
+            ParcelFileDescriptor oldState, BackupDataOutput data,
+            ParcelFileDescriptor newState, String[] files) {
+        if (files.length == 0) {
+            return;
         }
-        if (data == null) {
-            throw new NullPointerException("data==null");
+        if (basePath == null) {
+            throw new NullPointerException();
         }
+        // oldStateFd can be null
+        FileDescriptor oldStateFd = oldState != null ? oldState.getFileDescriptor() : null;
         if (data.fd == null) {
-            throw new NullPointerException("data.fd==null");
+            throw new NullPointerException();
+        }
+        FileDescriptor newStateFd = newState.getFileDescriptor();
+        if (newStateFd == null) {
+            throw new NullPointerException();
         }
         if (files == null) {
-            throw new NullPointerException("files==null");
+            throw new NullPointerException();
         }
 
-        int err = performBackup_native(basePath, oldSnapshot.getFileDescriptor(),
-                newSnapshot.getFileDescriptor(), data.fd, files);
+        int err = performBackup_native(basePath, oldStateFd, data.fd, newStateFd, files);
 
         if (err != 0) {
             throw new RuntimeException("Backup failed"); // TODO: more here
         }
     }
 
-    native private static int performBackup_native(String basePath,
-            FileDescriptor oldSnapshot, FileDescriptor newSnapshot,
-            FileDescriptor data, String[] files);
+    native private static int performBackup_native(String basePath, FileDescriptor oldState,
+            FileDescriptor data, FileDescriptor newState, String[] files);
 }
diff --git a/core/java/android/backup/SharedPreferencesBackupHelper.java b/core/java/android/backup/SharedPreferencesBackupHelper.java
index e839bb4..8627f08 100644
--- a/core/java/android/backup/SharedPreferencesBackupHelper.java
+++ b/core/java/android/backup/SharedPreferencesBackupHelper.java
@@ -21,6 +21,7 @@
 
 import java.io.FileDescriptor;
 
+/** @hide */
 public class SharedPreferencesBackupHelper {
     public static void performBackup(Context context,
             ParcelFileDescriptor oldSnapshot, ParcelFileDescriptor newSnapshot,
@@ -34,7 +35,7 @@
             files[i] = prefGroups[i] + ".xml";
         }
 
-        FileBackupHelper.performBackup_checked(basePath, oldSnapshot, newSnapshot, data, files);
+        FileBackupHelper.performBackup_checked(basePath, oldSnapshot, data, newSnapshot, files);
     }
 }
 
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 81f72ac..24262f5 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1048,6 +1048,17 @@
     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
 
+    /**
+     * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
+     * This intent is delivered to the package which installed the application, usually
+     * the Market.
+     * <p>Input: No data is specified. The bug report is passed in using
+     * an {@link #EXTRA_BUG_REPORT} field.
+     * <p>Output: Nothing.
+     * @hide
+     */
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+    public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
     // ---------------------------------------------------------------------
     // ---------------------------------------------------------------------
     // Standard intent broadcast actions (see action variable).
@@ -1780,6 +1791,24 @@
      * delivered.
      */
     public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
+    
+    /**
+     * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
+     * the bug report.
+     * 
+     * @hide
+     */
+    public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
+
+    /**
+     * Used as a string extra field when sending an intent to PackageInstaller to install a 
+     * package. Specifies the installer package name; this package will receive the
+     * {@link #ACTION_APP_ERROR} intent.
+     * 
+     * @hide
+     */
+    public static final String EXTRA_INSTALLER_PACKAGE_NAME 
+            = "android.intent.extra.INSTALLER_PACKAGE_NAME";
 
     // ---------------------------------------------------------------------
     // ---------------------------------------------------------------------
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java
index 3827849..9c25e73 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -387,8 +387,7 @@
                 while (i > 0) {
                     i--;
                     AuthorityInfo authority = mAuthorities.get(i);
-                    if (authority.account.equals(account)
-                            && authority.authority.equals(providerName)) {
+                    if (authority.authority.equals(providerName)) {
                         authority.enabled = sync;
                     }
                 }
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index a1c0f48..88907c1 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -1189,7 +1189,7 @@
 
         if (sa.getBoolean(
                 com.android.internal.R.styleable.AndroidManifestApplication_testOnly,
-                true)) {
+                false)) {
             ai.flags |= ApplicationInfo.FLAG_TEST_ONLY;
         }
 
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index a926355..563d819 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -21,6 +21,7 @@
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.DialogInterface.OnCancelListener;
+import android.database.DataSetObserver;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
 import android.graphics.Color;
@@ -60,6 +61,7 @@
 import android.webkit.TextDialog.AutoCompleteAdapter;
 import android.webkit.WebViewCore.EventHub;
 import android.widget.AbsoluteLayout;
+import android.widget.Adapter;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.FrameLayout;
@@ -4809,7 +4811,10 @@
 
             @Override
             public boolean hasStableIds() {
-                return true;
+                // AdapterView's onChanged method uses this to determine whether
+                // to restore the old state.  Return false so that the old (out
+                // of date) state does not replace the new, valid state.
+                return false;
             }
 
             private Container item(int position) {
@@ -4873,6 +4878,51 @@
             }
         }
 
+        /*
+         * Whenever the data set changes due to filtering, this class ensures
+         * that the checked item remains checked.
+         */
+        private class SingleDataSetObserver extends DataSetObserver {
+            private long        mCheckedId;
+            private ListView    mListView;
+            private Adapter     mAdapter;
+
+            /*
+             * Create a new observer.
+             * @param id The ID of the item to keep checked.
+             * @param l ListView for getting and clearing the checked states
+             * @param a Adapter for getting the IDs
+             */
+            public SingleDataSetObserver(long id, ListView l, Adapter a) {
+                mCheckedId = id;
+                mListView = l;
+                mAdapter = a;
+            }
+
+            public void onChanged() {
+                // The filter may have changed which item is checked.  Find the
+                // item that the ListView thinks is checked.
+                int position = mListView.getCheckedItemPosition();
+                long id = mAdapter.getItemId(position);
+                if (mCheckedId != id) {
+                    // Clear the ListView's idea of the checked item, since
+                    // it is incorrect
+                    mListView.clearChoices();
+                    // Search for mCheckedId.  If it is in the filtered list,
+                    // mark it as checked
+                    int count = mAdapter.getCount();
+                    for (int i = 0; i < count; i++) {
+                        if (mAdapter.getItemId(i) == mCheckedId) {
+                            mListView.setItemChecked(i, true);
+                            break;
+                        }
+                    }
+                }
+            }
+
+            public void onInvalidate() {}
+        }
+
         public void run() {
             final ListView listView = (ListView) LayoutInflater.from(mContext)
                     .inflate(com.android.internal.R.layout.select_dialog, null);
@@ -4901,8 +4951,7 @@
             // filtered.  Do not allow filtering on multiple lists until
             // that bug is fixed.
             
-            // Disable filter altogether
-            // listView.setTextFilterEnabled(!mMultiple);
+            listView.setTextFilterEnabled(!mMultiple);
             if (mMultiple) {
                 listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
                 int length = mSelectedArray.length;
@@ -4922,6 +4971,9 @@
                     listView.setSelection(mSelection);
                     listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
                     listView.setItemChecked(mSelection, true);
+                    DataSetObserver observer = new SingleDataSetObserver(
+                            adapter.getItemId(mSelection), listView, adapter);
+                    adapter.registerDataSetObserver(observer);
                 }
             }
             dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
diff --git a/core/jni/android_backup_FileBackupHelper.cpp b/core/jni/android_backup_FileBackupHelper.cpp
index e8d60a0..c6de3a5 100644
--- a/core/jni/android_backup_FileBackupHelper.cpp
+++ b/core/jni/android_backup_FileBackupHelper.cpp
@@ -14,6 +14,9 @@
  * limitations under the License.
  */
 
+#define LOG_TAG "FileBackupHelper_native"
+#include <utils/Log.h>
+
 #include "JNIHelp.h"
 #include <android_runtime/AndroidRuntime.h>
 
@@ -22,29 +25,29 @@
 namespace android
 {
 
-static jfieldID s_descriptorField;
+static jfieldID s_descriptorField = 0;
 
 static int
-performBackup_native(JNIEnv* env, jstring basePath,
-            jobject oldSnapshot, jobject newSnapshot,
-            jobject data, jobjectArray files)
+performBackup_native(JNIEnv* env, jobject clazz, jstring basePath, jobject oldState, jobject data,
+        jobject newState, jobjectArray files)
 {
     int err;
 
     // all parameters have already been checked against null
-
-    int oldSnapshotFD = env->GetIntField(oldSnapshot, s_descriptorField);
-    int newSnapshotFD = env->GetIntField(newSnapshot, s_descriptorField);
+    LOGD("oldState=%p newState=%p data=%p\n", oldState, newState, data);
+    int oldStateFD = oldState != NULL ? env->GetIntField(oldState, s_descriptorField) : -1;
+    int newStateFD = env->GetIntField(newState, s_descriptorField);
     int dataFD = env->GetIntField(data, s_descriptorField);
 
     char const* basePathUTF = env->GetStringUTFChars(basePath, NULL);
+    LOGD("basePathUTF=\"%s\"\n", basePathUTF);
     const int fileCount = env->GetArrayLength(files);
     char const** filesUTF = (char const**)malloc(sizeof(char*)*fileCount);
     for (int i=0; i<fileCount; i++) {
         filesUTF[i] = env->GetStringUTFChars((jstring)env->GetObjectArrayElement(files, i), NULL);
     }
 
-    err = back_up_files(oldSnapshotFD, newSnapshotFD, dataFD, basePathUTF, filesUTF, fileCount);
+    err = back_up_files(oldStateFD, dataFD, newStateFD, basePathUTF, filesUTF, fileCount);
 
     for (int i=0; i<fileCount; i++) {
         env->ReleaseStringUTFChars((jstring)env->GetObjectArrayElement(files, i), filesUTF[i]);
@@ -64,6 +67,8 @@
 
 int register_android_backup_FileBackupHelper(JNIEnv* env)
 {
+    LOGD("register_android_backup_FileBackupHelper");
+
     jclass clazz;
 
     clazz = env->FindClass("java/io/FileDescriptor");
diff --git a/core/res/res/drawable/btn_search_dialog_default.9.png b/core/res/res/drawable/btn_search_dialog_default.9.png
index ec39178..7275231 100644
--- a/core/res/res/drawable/btn_search_dialog_default.9.png
+++ b/core/res/res/drawable/btn_search_dialog_default.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_search_dialog_pressed.9.png b/core/res/res/drawable/btn_search_dialog_pressed.9.png
index 5f52fef..50a9209 100644
--- a/core/res/res/drawable/btn_search_dialog_pressed.9.png
+++ b/core/res/res/drawable/btn_search_dialog_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_search_dialog_selected.9.png b/core/res/res/drawable/btn_search_dialog_selected.9.png
index 9fc2fde..14b774a 100644
--- a/core/res/res/drawable/btn_search_dialog_selected.9.png
+++ b/core/res/res/drawable/btn_search_dialog_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_search_dialog_voice_default.9.png b/core/res/res/drawable/btn_search_dialog_voice_default.9.png
index 2a3366c..febf222 100644
--- a/core/res/res/drawable/btn_search_dialog_voice_default.9.png
+++ b/core/res/res/drawable/btn_search_dialog_voice_default.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_search_dialog_voice_pressed.9.png b/core/res/res/drawable/btn_search_dialog_voice_pressed.9.png
index 57d7a74..70a200b 100644
--- a/core/res/res/drawable/btn_search_dialog_voice_pressed.9.png
+++ b/core/res/res/drawable/btn_search_dialog_voice_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_search_dialog_voice_selected.9.png b/core/res/res/drawable/btn_search_dialog_voice_selected.9.png
index db3187e..6f2989f 100644
--- a/core/res/res/drawable/btn_search_dialog_voice_selected.9.png
+++ b/core/res/res/drawable/btn_search_dialog_voice_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_bright.9.png b/core/res/res/drawable/divider_horizontal_bright.9.png
index 30c9b2b..144fc22 100644
--- a/core/res/res/drawable/divider_horizontal_bright.9.png
+++ b/core/res/res/drawable/divider_horizontal_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_bright_opaque.9.png b/core/res/res/drawable/divider_horizontal_bright_opaque.9.png
new file mode 100644
index 0000000..30c9b2b
--- /dev/null
+++ b/core/res/res/drawable/divider_horizontal_bright_opaque.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_dark.9.png b/core/res/res/drawable/divider_horizontal_dark.9.png
index ce21acd..08838ca 100644
--- a/core/res/res/drawable/divider_horizontal_dark.9.png
+++ b/core/res/res/drawable/divider_horizontal_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_dark_opaque.9.png b/core/res/res/drawable/divider_horizontal_dark_opaque.9.png
new file mode 100644
index 0000000..ce21acd
--- /dev/null
+++ b/core/res/res/drawable/divider_horizontal_dark_opaque.9.png
Binary files differ
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index a436f61..8160c9c 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -330,7 +330,7 @@
         <item name="android:groupIndicator">@android:drawable/expander_group</item>
         <item name="android:indicatorLeft">?android:attr/expandableListPreferredItemIndicatorLeft</item>
         <item name="android:indicatorRight">?android:attr/expandableListPreferredItemIndicatorRight</item>
-        <item name="android:childDivider">@android:drawable/divider_horizontal_dark</item>
+        <item name="android:childDivider">@android:drawable/divider_horizontal_dark_opaque</item>
     </style>
 
     <style name="Widget.ImageWell">
@@ -398,18 +398,18 @@
     <style name="Widget.ListView" parent="Widget.AbsListView">
         <item name="android:listSelector">@android:drawable/list_selector_background</item>
         <item name="android:cacheColorHint">?android:attr/colorBackground</item>
-        <item name="android:divider">@android:drawable/divider_horizontal_dark</item>
+        <item name="android:divider">@android:drawable/divider_horizontal_dark_opaque</item>
     </style>
     
     <style name="Widget.ListView.White" parent="Widget.AbsListView">
         <item name="android:listSelector">@android:drawable/list_selector_background</item>
         <item name="android:background">@android:color/white</item>
-        <item name="android:divider">@android:drawable/divider_horizontal_bright</item>
+        <item name="android:divider">@android:drawable/divider_horizontal_bright_opaque</item>
     </style>    
 
     <style name="Widget.ListView.DropDown">
     	<item name="android:cacheColorHint">@null</item>
-        <item name="android:divider">@android:drawable/divider_horizontal_bright</item>
+        <item name="android:divider">@android:drawable/divider_horizontal_bright_opaque</item>
     </style>
 
     <style name="Widget.ListView.Menu">
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 5367cb2..a044cea 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -95,7 +95,7 @@
           </ul>
       </li> -->
 <!--  <li><a style="color:gray;">Localization</a></li>  -->
-      <li><a href="<?cs var:toroot ?>guide/topics/appwidgets/index.html">AppWidgets</a></li>
+      <li><a href="<?cs var:toroot ?>guide/topics/appwidgets/index.html">App Widgets</a></li>
     </ul>
 </li>
 
@@ -146,7 +146,7 @@
       <li class="toggle-list">
         <div><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/index.html">UI Guidelines</a></div>
           <ul>
-            <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/widget_design.html">Widget Design</a></li>
+            <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/widget_design.html">App Widget Design</a></li>
           </ul>
       </li>
       <li><a href="<?cs var:toroot ?>guide/practices/design/performance.html">Designing for Performance</a></li>
diff --git a/docs/html/guide/topics/appwidgets/index.jd b/docs/html/guide/topics/appwidgets/index.jd
index f9db356..01a9648 100644
--- a/docs/html/guide/topics/appwidgets/index.jd
+++ b/docs/html/guide/topics/appwidgets/index.jd
@@ -1,4 +1,4 @@
-page.title=AppWidgets
+page.title=App Widgets
 @jd:body
 
 <div id="qv-wrapper">
@@ -6,131 +6,338 @@
     <h2>Key classes</h2>
     <ol>
       <li>{@link android.appwidget.AppWidgetProvider}</li>
-      <li>{@link android.appwidget.AppWidgetHost}</li>
+      <li>{@link android.appwidget.AppWidgetProviderInfo}</li>
+      <li>{@link android.appwidget.AppWidgetManager}</li>
     </ol>
     <h2>In this document</h2>
     <ol>
-      <li><a href="#Providers">AppWidget Providers</a>
+      <li><a href="#Basics">The Basics</a></li>
+      <li><a href="#Manifest">Declaring an App Widget in the Manifest</a></li>
+      <li><a href="#MetaData">Adding the AppWidgetProviderInfo Metadata</a></li>
+      <li><a href="#CreatingLayout">Creating the App Widget Layout</a></li>
+      <li><a href="#AppWidgetProvider">Using the AppWidgetProvider Class</a>
         <ol>
-          <li><a href="#provider_manifest">Declaring a widget in the AndroidManifest</a></li>
-          <li><a href="#provider_meta_data">Adding the AppWidgetProviderInfo meta-data</a></li>
-          <li><a href="#provider_AppWidgetProvider">Using the AppWidgetProvider class</a></li>
-          <li><a href="#provider_configuration">AppWidget Configuration UI</a></li>
-          <li><a href="#provider_broadcasts">AppWidget Broadcast Intents</a></li>
+          <li><a href="#ProviderBroadcasts">Receiving App Widget broadcast Intents</a></li>
         </ol>
       </li>
-      <li><a href="#Hosts">AppWidget Hosts</a></li>
+      <li><a href="#Configuring">Creating an App Widget Configuration Activity</a>
+        <ol>
+          <li><a href="#UpdatingFromTheConfiguration">Updating the App Widget from 
+            the configuration Activity</a></li>
+        </ol>
+      </li>
     </ol>
 
     <h2>See also</h2>
     <ol>
+      <li><a href="{@docRoot}guide/practices/ui_guidelines/widget_design.html">App Widget Design 
+        Guidelines</a></li>
       <li><a href="http://android-developers.blogspot.com/2009/04/introducing-home-screen-widgets-and.html">Introducing
-      home screen widgets and the AppWidget framework &raquo;</a></li>
+        home screen widgets and the AppWidget framework &raquo;</a></li>
     </ol>
   </div>
 </div>
 
-<p>AppWidgets are miniature application views that can be embedded in other applications
-(e.g., the Home). These views are called "widgets" and you can publish one with
-an "AppWidget provider." An application component that is able to hold other widgets is 
-called an "AppWidget host."</p>
+
+<p>App Widgets are miniature application views that can be embedded in other applications
+(such as the Home screen) and receive periodic updates. These views are referred 
+to as Widgets in the user interface,
+and you can publish one with an App Widget provider. An application component that is 
+able to hold other App Widgets is called an App Widget host. The screenshot below shows
+the Music App Widget.</p>
+
+<img src="{@docRoot}images/appwidget.png" alt="" />
+
+<p>This document describes how to publish an App Widget using an App Widget provider.</p>
 
 
+<h2 id="Basics">The Basics</h2>
+
+<p>To create an App Widget, you need the following:</p>
+
+<dl>
+  <dt>{@link android.appwidget.AppWidgetProviderInfo} object</dt>
+  <dd>Describes the metadata for an App Widget, such as the App Widget's layout, update frequency,
+    and the AppWidgetProvider class. This should be defined in XML.</dd>
+  <dt>{@link android.appwidget.AppWidgetProvider} class implementation</dt>
+  <dd>Defines the basic methods that allow you to programmatically interface with the App Widget,
+    based on broadcast events. Through it, you will receive broadcasts when the App Widget is updated, 
+    enabled, disabled and deleted.</dd>
+  <dt>View layout</dt>
+  <dd>Defines the initial layout for the App Widget, defined in XML.</dd>
+</dl>
+
+<p>Additionally, you can implement an App Widget configuration Activity. This is an optional 
+{@link android.app.Activity} that launches when the user adds your App Widget and allows him or her
+to modify App Widget settings at create-time.</p>
+
+<p>The following sections describe how to setup each of these components.</p>
 
 
-<h2 id="Providers">AppWidget Providers</h2>
-<p>Any application can publish widgets.  All an application needs to do to publish a widget is
-to have a {@link android.content.BroadcastReceiver} that receives the {@link
-android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE AppWidgetManager.ACTION_APPWIDGET_UPDATE} intent,
-and provide some meta-data about the widget.  Android provides the
-{@link android.appwidget.AppWidgetProvider} class, which extends BroadcastReceiver, as a convenience
-class to aid in handling the broadcasts.
+<h2 id="Manifest">Declaring an App Widget in the Manifest</h2>
 
+<p>First, declare the {@link android.appwidget.AppWidgetProvider} class in your application's
+<code>AndroidManifest.xml</code> file. For example:</p>
 
-<h3 id="provider_manifest">Declaring a widget in the AndroidManifest</h3>
+<pre>
+&lt;receiver android:name="ExampleAppWidgetProvider" >
+    &lt;intent-filter>
+        &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+    &lt;/intent-filter>
+    &lt;meta-data android:name="android.appwidget.provider"
+               android:resource="@xml/example_appwidget_info" />
+&lt;/receiver>
+</pre>
 
-<p>First, declare the {@link android.content.BroadcastReceiver} in your application's
-<code>AndroidManifest.xml</code> file.
+<p>The <code>&lt;receiver&gt;</code> element requires the <code>android:name</code> 
+attribute, which specifies the {@link android.appwidget.AppWidgetProvider} used
+by the App Widget.</p>
 
-{@sample frameworks/base/tests/appwidgets/AppWidgetHostTest/AndroidManifest.xml AppWidgetProvider}
+<p>The <code>&lt;intent-filter&gt;</code> element must include an <code>&lt;action></code>
+element with the <code>android:name</code> attribute. This attribute specifies
+that the {@link android.appwidget.AppWidgetProvider} accepts the {@link
+android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE ACTION_APPWIDGET_UPDATE} broadcast.
+This is the only broadcast that you must explicitly declare. The {@link android.appwidget.AppWidgetManager}
+automatically sends all other App Widget broadcasts to the AppWidgetProvider as necessary.</p>
 
-<p>
-The <code>&lt;receiver&gt;</code> element has the following attributes:
+<p>The <code>&lt;meta-data&gt;</code> element specifies the
+{@link android.appwidget.AppWidgetProviderInfo} resource and requires the 
+following attributes:</p>
 <ul>
-  <li><code>android:name</code> - specifies the
-        {@link android.content.BroadcastReceiver} or {@link android.appwidget.AppWidgetProvider}
-        class.</li>
-  <li><code>android:label</code> - specifies the string resource that
-        will be shown by the widget picker as the label.</li>
-  <li><code>android:icon</code> - specifies the drawable resource that
-        will be shown by the widget picker as the icon.</li>
-</ul>
-
-<p>
-The <code>&lt;intent-filter&gt;</code> element tells the {@link android.content.pm.PackageManager}
-that this {@link android.content.BroadcastReceiver} receives the {@link
-android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE AppWidgetManager.ACTION_APPWIDGET_UPDATE} broadcast.
-The widget manager will send other broadcasts directly to your widget provider as required.
-It is only necessary to explicitly declare that you accept the {@link
-android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE AppWidgetManager.ACTION_APPWIDGET_UPDATE} broadcast.
-
-<p>
-The <code>&lt;meta-data&gt;</code> element tells the widget manager which xml resource to
-read to find the {@link android.appwidget.AppWidgetProviderInfo} for your widget provider.  It has the following
-attributes:
-<ul>
-  <li><code>android:name="android.appwidget.provider"</code> - identifies this meta-data
-        as the {@link android.appwidget.AppWidgetProviderInfo} descriptor.</li>
-  <li><code>android:resource</code> - is the xml resource to use as that descriptor.</li>
+  <li><code>android:name</code> - Specifies the metadata name. Use <code>android.appwidget.provider</code>
+    to identify the data as the {@link android.appwidget.AppWidgetProviderInfo} descriptor.</li>
+  <li><code>android:resource</code> - Specifies the {@link android.appwidget.AppWidgetProviderInfo} 
+    resource location.</li>
 </ul>
 
 
-<h3 id="provider_meta_data">Adding the AppWidgetProviderInfo meta-data</h3>
+<h2 id="MetaData">Adding the AppWidgetProviderInfo Metadata</h2>
 
-<p>For a widget, the values in the {@link android.appwidget.AppWidgetProviderInfo} structure are supplied
-in an XML resource.  In the example above, the xml resource is referenced with
-<code>android:resource="@xml/appwidget_info"</code>.  That XML file would go in your application's
-directory at <code>res/xml/appwidget_info.xml</code>.  Here is a simple example.
+<p>The {@link android.appwidget.AppWidgetProviderInfo} defines the essential 
+qualities of an App Widget, such as its minimum layout dimensions, its initial layout resource,
+how often to update the App Widget, and (optionally) a configuration Activity to launch at create-time.
+Define the AppWidgetProviderInfo object in an XML resource using a single
+<code>&lt;appwidget-provider></code> element and save it in the project's <code>res/xml/</code> 
+folder.</p>
 
-{@sample frameworks/base/tests/appwidgets/AppWidgetHostTest/res/xml/appwidget_info.xml AppWidgetProviderInfo}
+<p>For example:</p>
 
-<p>The attributes are as documented in the 
-{@link android.appwidget.AppWidgetProviderInfo} class.
+<pre>
+&lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+    android:minWidth="294dp" &lt;!-- density-independent pixels --&gt;
+    android:minHeight="72dp"
+    android:updatePeriodMillis="86400000" &lt;!-- once per day --&gt;
+    android:initialLayout="@layout/example_appwidget"
+    android:configure="com.example.android.ExampleAppWidgetConfigure" >
+&lt;/appwidget-provider>
+</pre>
+
+<p>Here's a summary of the <code>&lt;appwidget-provider></code> attributes:</p>
+<ul>
+  <li>The values for the <code>minWidth</code> and <code>minHeight</code> attributes specify the minimum
+    area required by the App Widget's layout.
+    <p>The default Home screen positions App Widgets in its window based on a grid of
+    cells that have a defined height and width. If the values for an App Widget's minimum width 
+    or height don't match the dimensions of the cells,
+    then the App Widget dimensions round <em>up</em> to the nearest cell size.
+    (See the <a href="{@docRoot}guide/practices/ui_guidelines/widget_design.html">App Widget Design 
+    Guidelines</a> for more information on the Home screen cell sizes.)</p>
+    <p>Because the Home screen's layout orientation (and thus, the cell sizes) can change,
+    as a rule of thumb, you should assume the worst-case cell size of 74 pixels for the height
+    <em>and</em> width of a cell. However, you must subtract 2 from the final dimension to account
+    for any integer rounding errors that occur in the pixel count. To find your minimum width
+    and height in density-independent pixels (dp), use this formula:<br/>
+      <code>(number of cells * 74) - 2</code><br/>
+    Following this formula, you should use 72 dp for a height of one cell, 294 dp and for a width of four cells.</p>
+  </li>
+  <li>The <code>updatePerdiodMillis</code> attribute defines how often the App Widget framework should
+    request an update from the {@link android.appwidget.AppWidgetProvider} by calling the
+    {@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
+    onUpdate()} method. The actual update is not guaranteed to occur exactly on time with this value
+    and we suggest updating as infrequently as possible&mdash;perhaps no more than once an hour to 
+    conserve the battery. You might also allow the user to adjust the frequency in a 
+    configuration&mdash;some people might want a stock ticker to update every 15 minutes, or maybe 
+    only four times a day.</li>
+  <li>The <code>initialLayout</code> attribute points to the layout resource that defines the
+    App Widget layout.</li>
+  <li>The <code>configure</code> attribute defines the {@link android.app.Activity} to launch when
+    the user adds the App Widget, in order for him or her to configure App Widget properties. This is optional
+    (read <a href="#Configuring">Creating an App Widget Configuration Activity</a> below).</li>
+</ul>
+
+<p>See the {@link android.appwidget.AppWidgetProviderInfo} class for more information on the
+attributes accepted by the <code>&lt;appwidget-provider></code> element.</p>
 
 
-<h3 id="provider_AppWidgetProvider">Using the AppWidgetProvider class</h3>
+<h2 id="CreatingLayout">Creating the App Widget Layout</h2>
 
-<p>The AppWidgetProvider class is the easiest way to handle the widget provider intent broadcasts.
-See the <code>src/com/example/android/apis/appwidget/ExampleAppWidgetProvider.java</code>
-sample class in ApiDemos for an example.
+<p>You must define an initial layout for your App Widget in XML and save it in the project's
+<code>res/layout/</code> directory. You can design your App Widget using the View objects listed
+below, but before you begin designing your App Widget, please read and understand the
+<a href="{@docRoot}guide/practices/ui_guidelines/widget_design.html">App Widget Design 
+Guidelines</a>.</p>
 
-<p class="note">Keep in mind that since the the AppWidgetProvider is a BroadcastReceiver,
-your process is not guaranteed to keep running after the callback methods return.  See
-<a href="../../../guide/topics/fundamentals.html#broadlife">Application Fundamentals &gt;
-Broadcast Receiver Lifecycle</a> for more information.
+<p>Creating the App Widget layout is simple if you're
+familiar with <a href="{@docRoot}guide/topics/ui/declaring-layout.html">Declaring Layout in XML</a>.
+However, you must be aware that App Widget layouts are based on {@link android.widget.RemoteViews},
+which do not support every kind of layout or view widget.</p>
+
+<p>A RemoteViews object (and, consequently, an App Widget) can support the 
+following layout classes:</p>
+
+<ul class="nolist">
+  <li>{@link android.widget.FrameLayout}</li>
+  <li>{@link android.widget.LinearLayout}</li>
+  <li>{@link android.widget.RelativeLayout}</li>
+</ul>
+
+<p>And the following widget classes:</p>
+<ul class="nolist">
+  <li>{@link android.widget.AnalogClock}</li>
+  <li>{@link android.widget.Button}</li>
+  <li>{@link android.widget.Chronometer}</li>
+  <li>{@link android.widget.ImageButton}</li>
+  <li>{@link android.widget.ImageView}</li>
+  <li>{@link android.widget.ProgressBar}</li>
+  <li>{@link android.widget.TextView}</li>
+</ul>
+
+<p>Descendants of these classes are not supported.</p>
 
 
+<h2 id="AppWidgetProvider">Using the AppWidgetProvider Class</h2>
 
-<h3 id="provider_configuration">AppWidget Configuration UI</h3>
+<div class="sidebox-wrapper">
+  <div class="sidebox-inner">
+    <p>You must declare your AppWidgetProvider class implementation as a broadcast receiver 
+    using the <code>&lt;receiver></code> element in the AndroidManifest (see
+    <a href="#Manifest">Declaring an App Widget in the Manifest</a> above).</p>
+  </div>
+</div>
 
-<p>
-Widget hosts have the ability to start a configuration activity when a widget is instantiated.
-The activity should be declared as normal in AndroidManifest.xml, and it should be listed in
-the AppWidgetProviderInfo XML file in the <code>android:configure</code> attribute.
+<p>The {@link android.appwidget.AppWidgetProvider} class extends BroadcastReceiver as a convenience
+class to handle the App Widget broadcasts. The AppWidgetProvider receives only the event broadcasts that
+are relevant to the App Widget, such as when the App Widget is updated, deleted, enabled, and disabled.
+When these broadcast events occur, the AppWidgetProvider receives the following method calls:</p>
 
-<p>The activity you specified will be launched with the {@link
-android.appwidget.AppWidgetManager#ACTION_APPWIDGET_CONFIGURE} action.  See the documentation for that
-action for more info.
+<dl>
+  <dt>{@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])}</dt>
+    <dd>This is called to update the App Widget at intervals defined by the <code>updatePeriodMillis</code>
+    attribute in the AppWidgetProviderInfo (see <a href="#MetaData">Adding the 
+    AppWidgetProviderInfo Metadata</a> above). This method is also called
+    when the user adds the App Widget, so it should perform the essential setup,
+    such as define event handlers for Views and start a temporary
+    {@link android.app.Service}, if necessary. However, if you have declared a configuration
+    Activity, <strong>this method is not called</strong> when the user adds the App Widget,
+    but is called for the subsequent updates. It is the responsibility of the 
+    configuration Activity to perform the first update when configuration is done.
+    (See <a href="#Configuring">Creating an App Widget Configuration Activity</a> below.)</dd> 
+  <dt>{@link android.appwidget.AppWidgetProvider#onDeleted(Context,int[])}</dt>
+    <dd>This is called every time an App Widget is deleted from the App Widget host.</dd>
+  <dt>{@link android.appwidget.AppWidgetProvider#onEnabled(Context)}</dt>
+    <dd>This is called when an instance the App Widget is created for the first time. For example, if the user 
+    adds two instances of your App Widget, this is only called the first time.
+    If you need to open a new database or perform other setup that only needs to occur once 
+    for all App Widget instances, then this is a good place to do it.</dd> 
+  <dt>{@link android.appwidget.AppWidgetProvider#onDisabled(Context)}</dt>
+    <dd>This is called when the last instance of your App Widget is deleted from the App Widget host. 
+    This is where you should clean up any work done in 
+    {@link android.appwidget.AppWidgetProvider#onEnabled(Context)}, 
+    such as delete a temporary database.</dd> 
+  <dt>{@link android.appwidget.AppWidgetProvider#onReceive(Context,Intent)}</dt>
+    <dd>This is called for every broadcast and before each of the above callback methods.
+    You normally don't need to implement this method because the default AppWidgetProvider 
+    implementation filters all App Widget broadcasts and calls the above 
+    methods as appropriate.</dd> 
+</dl>
 
-<p>See the <code>src/com/example/android/apis/appwidget/ExampleAppWidgetConfigure.java</code>
-sample class in ApiDemos for an example.
+<p class="warning"><strong>Note:</strong> In Android 1.5, there is a known issue in which the
+<code>onDeleted()</code> method will not be called when it should be. To work around this issue, 
+you can implement {@link android.appwidget.AppWidgetProvider#onReceive(Context,Intent)
+onReceive()} as described in this 
+<a href="http://groups.google.com/group/android-developers/msg/e405ca19df2170e2">Group post</a>
+to receive the <code>onDeleted()</code> callback.
+</p>
+
+<p>The most important AppWidgetProvider callback is 
+{@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
+onUpdated()} because it is called when each App Widget is added to a host (unless you use
+a configuration Activity). If your App Widget accepts any
+user interaction events, then you need to register the event handlers in this callback.
+If your App Widget doesn't create temporary
+files or databases, or perform other work that requires clean-up, then
+{@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
+onUpdated()} may be the only callback method you need to define. For example, if you want an App Widget
+with a button that launches an Activity when clicked, you could use the following
+implementation of AppWidgetProvider:</p>
+
+<pre>
+public class ExampleAppWidgetProvider extends AppWidgetProvider {
+
+    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
+        final int N = appWidgetIds.length;
+
+        // Perform this loop procedure for each App Widget that belongs to this provider
+        for (int i=0; i&lt;N; i++) {
+            int appWidgetId = appWidgetIds[i];
+
+            // Create an Intent to launch ExampleActivity
+            Intent intent = new Intent(context, ExampleActivity.class);
+            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
+
+            // Get the layout for the App Widget and attach an on-click listener to the button
+            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout);
+            views.setOnClickPendingIntent(R.id.button, pendingIntent);
+
+            // Tell the AppWidgetManager to perform an update on the current App Widget
+            appWidgetManager.updateAppWidget(appWidgetId, views);
+        }
+    }
+}
+</pre>
+
+<p>This AppWidgetProvider defines only the 
+{@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
+onUpdated()} method for the purpose
+of defining a {@link android.app.PendingIntent} that launches an {@link android.app.Activity}
+and attaching it to the App Widget's button
+with {@link android.widget.RemoteViews#setOnClickPendingIntent(int,PendingIntent)}.
+Notice that it includes a loop that iterates through each entry in <code>appWidgetIds</code>, which
+is an array of IDs that identify each App Widget created by this provider.
+In this way, if the user creates more than one instance of the App Widget, then they are
+all updated simultaneously. However, only one <code>updatePeriodMillis</code> schedule will be 
+managed for all instances of the App Widget. For example, if the update schedule is defined 
+to be every two hours, and a second instance 
+of the App Widget is added one hour after the first one, then they will both be updated 
+on the period defined by the first one and the second update period will be ignored 
+(they'll both be updated every two hours, not every hour).</p>
+
+<p class="note"><strong>Note:</strong> Because the AppWidgetProvider is a BroadcastReceiver,
+your process is not guaranteed to keep running after the callback methods return (see
+<a href="{@docRoot}guide/topics/fundamentals.html#broadlife">Application Fundamentals &gt;
+Broadcast Receiver Lifecycle</a> for more information). If your App Widget setup process can take several
+seconds (perhaps while performing web requests) and you require that your process continues, 
+consider starting a {@link android.app.Service} 
+in the {@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
+onUpdated()} method. From within the Service, you can perform your own updates to the App Widget
+without worrying about the AppWidgetProvider closing down due to an 
+<a href="{@docRoot}guide/practices/design/responsiveness.html">Application Not Responding</a> 
+(ANR) error. See the
+<a href="http://code.google.com/p/wiktionary-android/source/browse/trunk/Wiktionary/src/com/example/android/wiktionary/WordWidget.java">Wiktionary
+sample's AppWidgetProvider</a> for an example of an App Widget running a {@link android.app.Service}.</p>
+
+<p>Also see the <a 
+href="{@docRoot}guide/samples/ApiDemos/src/com/example/android/apis/appwidget/ExampleAppWidgetProvider.html">
+ExampleAppWidgetProvider.java</a> sample class.</p>
 
 
-
-<h3 id="provider_broadcasts">AppWidget Broadcast Intents</h3>
+<h3 id="ProviderBroadcasts">Receiving App Widget broadcast Intents</h3>
 
 <p>{@link android.appwidget.AppWidgetProvider} is just a convenience class.  If you would like
-to receive the widget broadcasts directly, you can.  The four intents you need to care about are:
+to receive the App Widget broadcasts directly, you can implement your own 
+{@link android.content.BroadcastReceiver} or override the 
+{@link android.appwidget.AppWidgetProvider#onReceive(Context,Intent)} callback. 
+The four Intents you need to care about are:</p>
 <ul>
   <li>{@link android.appwidget.AppWidgetManager#ACTION_APPWIDGET_UPDATE}</li>
   <li>{@link android.appwidget.AppWidgetManager#ACTION_APPWIDGET_DELETED}</li>
@@ -138,17 +345,119 @@
   <li>{@link android.appwidget.AppWidgetManager#ACTION_APPWIDGET_DISABLED}</li>
 </ul>
 
-<p>By way of example, the implementation of
-{@link android.appwidget.AppWidgetProvider#onReceive} is quite simple:</p>
-
-{@sample frameworks/base/core/java/android/appwidget/AppWidgetProvider.java onReceive}
 
 
-<h2 id="Hosts">AppWidget Hosts</h2>
+<h2 id="Configuring">Creating an App Widget Configuration Activity</h2>
 
-<p>Widget hosts are the containers in which widgets can be placed.  Most of the look and feel
-details are left up to the widget hosts.  For example, the home screen has one way of viewing
-widgets, but the lock screen could also contain widgets, and it would have a different way of
-adding, removing and otherwise managing widgets.</p>
-<p>For more information on implementing your own widget host, see the
-{@link android.appwidget.AppWidgetHost AppWidgetHost} class.</p>
+<p>If you would like the user to configure settings when he or she adds a new App Widget,
+you can create an App Widget configuration Activity. This {@link android.app.Activity} 
+will be automatically launched by the App Widget host and allows the user to configure
+available settings for the App Widget at create-time, such as the App Widget color, size, 
+update period or other functionality settings.</p>
+
+<p>The configuration Activity should be declared as a normal Activity in the Android manifest file.
+However, it will be launched by the App Widget host with the {@link
+android.appwidget.AppWidgetManager#ACTION_APPWIDGET_CONFIGURE ACTION_APPWIDGET_CONFIGURE} action,
+so the Activity needs to accept this Intent. For example:</p>
+
+<pre>
+&lt;activity android:name=".ExampleAppWidgetConfigure">
+    &lt;intent-filter>
+        &lt;action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
+    &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+<p>Also, the Activity must be declared in the AppWidgetProviderInfo XML file, with the 
+<code>android:configure</code> attribute (see <a href="#MetaData">Adding 
+the AppWidgetProvierInfo Metadata</a> above). For example, the configuration Activity
+can be declared like this:</p>
+
+<pre>
+&lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+    ...
+    android:configure="com.example.android.ExampleAppWidgetConfigure" 
+    ... >
+&lt;/appwidget-provider>
+</pre>
+
+<p>Notice that the Activity is declared with a fully-qualified namespace, because 
+it will be referenced from outside your package scope.</p>
+
+<p>That's all you need to get started with a configuration Activity. Now all you need is the actual
+Activity. There are, however, two important things to remember when you implement the Activity:</p>
+<ul>
+  <li>The App Widget host calls the configuration Activity and the configuration Activity should always 
+    return a result. The result should include the App Widget ID
+    passed by the Intent that launched the Activity (saved in the Intent extras as
+    {@link android.appwidget.AppWidgetManager#EXTRA_APPWIDGET_ID}).</li>
+  <li>The {@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
+    onUpdate()} method <strong>will not be called</strong> when the App Widget is created
+    (the system will not send the ACTION_APPWIDGET_UPDATE broadcast when a configuration Activity
+    is launched). It is the responsibility of the configuration Activity to request an update from the 
+    AppWidgetManager when the App Widget is first created. However, 
+    {@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
+    onUpdate()} will be called for subsequent updates&mdash;it is only skipped the first time.</li>
+</ul>
+
+<p>See the code snippets in the following section for an example of how to return a result
+from the configuration and update the App Widget.</p>
+
+
+<h3 id="UpdatingFromTheConfiguration">Updating the App Widget from the configuration Activity</h3>
+
+<p>When an App Widget uses a configuration Activity, it is the responsibility of the Activity
+to update the App Widget when configuration is complete. 
+You can do so by requesting an update directly from the 
+{@link android.appwidget.AppWidgetManager}.</p>
+
+<p>Here's a summary of the procedure to properly update the App Widget and close
+the configuration Activity:</p>
+
+<ol>
+  <li>First, get the App Widget ID from the Intent that launched the Activity:
+<pre>
+Intent intent = getIntent();
+Bundle extras = intent.getExtras();
+if (extras != null) {
+    mAppWidgetId = extras.getInt(
+            AppWidgetManager.EXTRA_APPWIDGET_ID, 
+            AppWidgetManager.INVALID_APPWIDGET_ID);
+}
+</pre>
+  </li>
+  <li>Perform your App Widget configuration.</li>
+  <li>When the configuration is complete, get an instance of the AppWidgetManager by calling
+    {@link android.appwidget.AppWidgetManager#getInstance(Context)}:
+<pre>
+AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
+</pre>
+  </li>
+  <li>Update the App Widget with a {@link android.widget.RemoteViews} layout by calling
+    {@link android.appwidget.AppWidgetManager#updateAppWidget(int,RemoteViews)}:
+<pre>
+RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.example_appwidget);
+appWidgetManager.updateAppWidget(mAppWidgetId, views);
+</pre>
+  </li>
+  <li>Finally, create the return Intent, set it with the Activity result, and finish the Activity:</li>
+<pre>
+Intent resultValue = new Intent();
+resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
+setResult(RESULT_OK, resultValue);
+finish();
+</pre>
+  </li>
+</ol>
+
+<p class="note"><strong>Tip:</strong> When your configuration Activity first opens, set
+the Activity result to RESULT_CANCELED. This way, if the user backs-out of the Activity before
+reaching the end, the App Widget host is notified that the configuration was cancelled and the
+App Widget will not be added.</p>
+
+<p>See the <a 
+href="{@docRoot}guide/samples/ApiDemos/src/com/example/android/apis/appwidget/ExampleAppWidgetConfigure.html">
+ExampleAppWidgetConfigure.java</a> sample class in ApiDemos for an example.</p>
+
+
+
diff --git a/docs/html/images/appwidget.png b/docs/html/images/appwidget.png
new file mode 100644
index 0000000..b72b80b
--- /dev/null
+++ b/docs/html/images/appwidget.png
Binary files differ
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 0b398bc..fda584d 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -400,7 +400,7 @@
      * @param y        The y coordinate of the first pixel in source
      * @param width    The number of pixels in each row
      * @param height   The number of rows
-     * @param m        Option matrix to be applied to the pixels
+     * @param m        Optional matrix to be applied to the pixels
      * @param filter   true if the source should be filtered.
      *                   Only applies if the matrix contains more than just
      *                   translation.
diff --git a/include/utils/backup_helpers.h b/include/utils/backup_helpers.h
index 61bee340..137c5f1 100644
--- a/include/utils/backup_helpers.h
+++ b/include/utils/backup_helpers.h
@@ -1,7 +1,7 @@
 #ifndef _UTILS_BACKUP_HELPERS_H
 #define _UTILS_BACKUP_HELPERS_H
 
-int back_up_files(int oldSnapshotFD, int newSnapshotFD, int oldDataStream,
+int back_up_files(int oldSnapshotFD, int oldDataStream, int newSnapshotFD,
         char const* fileBase, char const* const* files, int fileCount);
 
 #define TEST_BACKUP_HELPERS 0
diff --git a/libs/utils/file_backup_helper.cpp b/libs/utils/file_backup_helper.cpp
index 111f88d..453084a 100644
--- a/libs/utils/file_backup_helper.cpp
+++ b/libs/utils/file_backup_helper.cpp
@@ -24,6 +24,9 @@
 #define MAGIC0 0x70616e53 // Snap
 #define MAGIC1 0x656c6946 // File
 
+#define LOGP(x...) LOGD(x)
+//#define LOGP(x...) printf(x)
+
 struct SnapshotHeader {
     int magic0;
     int fileCount;
@@ -159,14 +162,14 @@
 static int
 write_delete_file(const String8& key)
 {
-    printf("write_delete_file %s\n", key.string());
+    LOGP("write_delete_file %s\n", key.string());
     return 0;
 }
 
 static int
 write_update_file(const String8& realFilename, const String8& key)
 {
-    printf("write_update_file %s (%s)\n", realFilename.string(), key.string());
+    LOGP("write_update_file %s (%s)\n", realFilename.string(), key.string());
     return 0;
 }
 
@@ -195,7 +198,7 @@
 }
 
 int
-back_up_files(int oldSnapshotFD, int newSnapshotFD, int oldDataStream,
+back_up_files(int oldSnapshotFD, int oldDataStream, int newSnapshotFD,
         char const* fileBase, char const* const* files, int fileCount)
 {
     int err;
@@ -260,10 +263,10 @@
             const FileState& f = oldSnapshot.valueAt(n);
             const FileState& g = newSnapshot.valueAt(m);
 
-            printf("%s\n", q.string());
-            printf("  new: modTime=%d,%d size=%-3d crc32=0x%08x\n",
+            LOGP("%s\n", q.string());
+            LOGP("  new: modTime=%d,%d size=%-3d crc32=0x%08x\n",
                     f.modTime_sec, f.modTime_nsec, f.size, f.crc32);
-            printf("  old: modTime=%d,%d size=%-3d crc32=0x%08x\n",
+            LOGP("  old: modTime=%d,%d size=%-3d crc32=0x%08x\n",
                     g.modTime_sec, g.modTime_nsec, g.size, g.crc32);
             if (f.modTime_sec != g.modTime_sec || f.modTime_nsec != g.modTime_nsec
                     || f.size != g.size || f.crc32 != g.crc32) {
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index db1deae..983329b 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -220,6 +220,9 @@
 
             BackupRequest request;
             synchronized (mQueueLock) {
+                if (mBackupQueue == null) {
+                    Log.d(TAG, "mBackupQueue is null.  WHY?");
+                }
                 request = mBackupQueue.get(0);
             }
 
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 4ee0c91..079f363 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -5644,6 +5644,7 @@
                 }
                 p = new PackageSetting(name, codePath, resourcePath, vc, pkgFlags);
                 p.setTimeStamp(codePath.lastModified());
+                p.sharedUser = sharedUser;
                 if (sharedUser != null) {
                     p.userId = sharedUser.userId;
                 } else if (MULTIPLE_APPLICATION_UIDS) {
diff --git a/tests/backup/src/com/android/backuptest/BackupTestActivity.java b/tests/backup/src/com/android/backuptest/BackupTestActivity.java
index de68cb7..af7dfd4 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestActivity.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestActivity.java
@@ -83,6 +83,27 @@
                 bm.dataChanged();
             }
         },
+        new Test("Clear File") {
+            void run() {
+                PrintStream output = null;
+                try {
+                    output = new PrintStream(openFileOutput(FILE_NAME, MODE_PRIVATE));
+                    output.close();
+                } catch (IOException ex) {
+                    if (output != null) {
+                        output.close();
+                    }
+                }
+                BackupManager bm = new BackupManager(BackupTestActivity.this);
+                bm.dataChanged();
+            }
+        },
+        new Test("Poke") {
+            void run() {
+                BackupManager bm = new BackupManager(BackupTestActivity.this);
+                bm.dataChanged();
+            }
+        },
         new Test("Show Shared Pref") {
             void run() {
                 SharedPreferences prefs = getSharedPreferences(PREF_GROUP_SETTINGS, MODE_PRIVATE);
diff --git a/tests/backup/src/com/android/backuptest/BackupTestService.java b/tests/backup/src/com/android/backuptest/BackupTestService.java
index c58c98b..00eb86e 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestService.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestService.java
@@ -17,6 +17,8 @@
 package com.android.backuptest;
 
 import android.backup.BackupService;
+import android.backup.BackupDataOutput;
+import android.backup.FileBackupHelper;
 import android.os.ParcelFileDescriptor;
 import android.util.Log;
 
@@ -25,10 +27,12 @@
     static final String TAG = "BackupTestService";
 
     @Override
-    public void onBackup(ParcelFileDescriptor oldState,
-            ParcelFileDescriptor data,
-            ParcelFileDescriptor newState) {
+    public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
+             ParcelFileDescriptor newState) {
         Log.d(TAG, "onBackup");
+        FileBackupHelper.performBackup(this, oldState, data, newState, new String[] {
+                    BackupTestActivity.FILE_NAME
+                });
     }
 
     @Override