Merge change 9097

* changes:
  Wifi: Add support for enabling Wifi while in airplane mode.
diff --git a/api/4.xml b/api/4.xml
index c8a2e83..cac3ae8 100644
--- a/api/4.xml
+++ b/api/4.xml
@@ -256713,7 +256713,7 @@
  extends="java.lang.Enum"
  abstract="false"
  static="false"
- final="true"
+ final="false"
  deprecated="not deprecated"
  visibility="public"
 >
@@ -258766,7 +258766,7 @@
 <package name="java.util.concurrent.locks"
 >
 <class name="AbstractQueuedSynchronizer"
- extends="java.lang.Object"
+ extends="java.util.concurrent.locks.AbstractOwnableSynchronizer"
  abstract="true"
  static="false"
  final="false"
diff --git a/api/current.xml b/api/current.xml
index 3c79b90..fef6b76 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -35725,39 +35725,6 @@
  visibility="public"
 >
 </field>
-<field name="ACTION_TTS_CHECK_TTS_DATA"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;android.intent.action.CHECK_TTS_DATA&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_TTS_INSTALL_TTS_DATA"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;android.intent.action.INSTALL_TTS_DATA&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="ACTION_TTS_QUEUE_PROCESSING_COMPLETED"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;android.intent.action.TTS_QUEUE_PROCESSING_COMPLETED&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="ACTION_UID_REMOVED"
  type="java.lang.String"
  transient="false"
@@ -116289,7 +116256,18 @@
 <parameter name="filename" type="java.lang.String">
 </parameter>
 </method>
-<field name="TTS_ERROR"
+<field name="ACTION_TTS_QUEUE_PROCESSING_COMPLETED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.tts.TTS_QUEUE_PROCESSING_COMPLETED&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ERROR"
  type="int"
  transient="false"
  volatile="false"
@@ -116300,7 +116278,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_LANG_AVAILABLE"
+<field name="LANG_AVAILABLE"
  type="int"
  transient="false"
  volatile="false"
@@ -116311,7 +116289,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_LANG_COUNTRY_AVAILABLE"
+<field name="LANG_COUNTRY_AVAILABLE"
  type="int"
  transient="false"
  volatile="false"
@@ -116322,7 +116300,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_LANG_COUNTRY_VAR_AVAILABLE"
+<field name="LANG_COUNTRY_VAR_AVAILABLE"
  type="int"
  transient="false"
  volatile="false"
@@ -116333,7 +116311,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_LANG_MISSING_DATA"
+<field name="LANG_MISSING_DATA"
  type="int"
  transient="false"
  volatile="false"
@@ -116344,7 +116322,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_LANG_NOT_SUPPORTED"
+<field name="LANG_NOT_SUPPORTED"
  type="int"
  transient="false"
  volatile="false"
@@ -116355,7 +116333,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_QUEUE_ADD"
+<field name="QUEUE_ADD"
  type="int"
  transient="false"
  volatile="false"
@@ -116366,7 +116344,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_QUEUE_FLUSH"
+<field name="QUEUE_FLUSH"
  type="int"
  transient="false"
  volatile="false"
@@ -116377,7 +116355,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_SUCCESS"
+<field name="SUCCESS"
  type="int"
  transient="false"
  volatile="false"
@@ -116405,6 +116383,28 @@
  visibility="public"
 >
 </constructor>
+<field name="ACTION_CHECK_TTS_DATA"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.tts.engine.CHECK_TTS_DATA&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_INSTALL_TTS_DATA"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.tts.engine.INSTALL_TTS_DATA&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="CHECK_VOICE_DATA_BAD_DATA"
  type="int"
  transient="false"
@@ -116460,7 +116460,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_DEFAULT_STREAM"
+<field name="DEFAULT_STREAM"
  type="int"
  transient="false"
  volatile="false"
@@ -116471,29 +116471,7 @@
  visibility="public"
 >
 </field>
-<field name="TTS_KEY_PARAM_STREAM"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;streamType&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="TTS_KEY_PARAM_UTTERANCE_ID"
- type="java.lang.String"
- transient="false"
- volatile="false"
- value="&quot;utteranceId&quot;"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="VOICE_DATA_FILES"
+<field name="EXTRA_VOICE_DATA_FILES"
  type="java.lang.String"
  transient="false"
  volatile="false"
@@ -116504,7 +116482,7 @@
  visibility="public"
 >
 </field>
-<field name="VOICE_DATA_FILES_INFO"
+<field name="EXTRA_VOICE_DATA_FILES_INFO"
  type="java.lang.String"
  transient="false"
  volatile="false"
@@ -116515,7 +116493,7 @@
  visibility="public"
 >
 </field>
-<field name="VOICE_DATA_ROOT_DIRECTORY"
+<field name="EXTRA_VOICE_DATA_ROOT_DIRECTORY"
  type="java.lang.String"
  transient="false"
  volatile="false"
@@ -116526,6 +116504,28 @@
  visibility="public"
 >
 </field>
+<field name="KEY_PARAM_STREAM"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;streamType&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="KEY_PARAM_UTTERANCE_ID"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;utteranceId&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <interface name="TextToSpeech.OnInitListener"
  abstract="true"
@@ -146779,7 +146779,7 @@
  value="2"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -146805,6 +146805,17 @@
  visibility="public"
 >
 </field>
+<field name="SURFACE_FROZEN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="SURFACE_HIDDEN"
  type="int"
  transient="false"
@@ -277754,7 +277765,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="offer"
@@ -277767,7 +277778,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <parameter name="timeout" type="long">
 </parameter>
@@ -277825,7 +277836,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <exception name="InterruptedException" type="java.lang.InterruptedException">
 </exception>
@@ -277885,7 +277896,20 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
+</parameter>
+</method>
+<method name="contains"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="o" type="java.lang.Object">
 </parameter>
 </method>
 <method name="drainTo"
@@ -277926,7 +277950,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="offer"
@@ -277939,7 +277963,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <parameter name="timeout" type="long">
 </parameter>
@@ -277975,7 +277999,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <exception name="InterruptedException" type="java.lang.InterruptedException">
 </exception>
@@ -277991,6 +278015,19 @@
  visibility="public"
 >
 </method>
+<method name="remove"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="o" type="java.lang.Object">
+</parameter>
+</method>
 <method name="take"
  return="E"
  abstract="true"
@@ -278208,7 +278245,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="t" type="java.util.Map&lt;? extends K, ? extends V&gt;">
+<parameter name="m" type="java.util.Map&lt;? extends K, ? extends V&gt;">
 </parameter>
 </constructor>
 <method name="contains"
@@ -278371,7 +278408,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="peek"
@@ -278521,7 +278558,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="array" type="E[]">
+<parameter name="toCopyIn" type="E[]">
 </parameter>
 </constructor>
 <method name="add"
@@ -278549,7 +278586,7 @@
 >
 <parameter name="index" type="int">
 </parameter>
-<parameter name="e" type="E">
+<parameter name="element" type="E">
 </parameter>
 </method>
 <method name="addAll"
@@ -278677,9 +278714,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="e" type="E">
-</parameter>
-<parameter name="index" type="int">
+<parameter name="o" type="java.lang.Object">
 </parameter>
 </method>
 <method name="indexOf"
@@ -278692,7 +278727,9 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="java.lang.Object">
+<parameter name="e" type="E">
+</parameter>
+<parameter name="index" type="int">
 </parameter>
 </method>
 <method name="isEmpty"
@@ -278727,9 +278764,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="e" type="E">
-</parameter>
-<parameter name="index" type="int">
+<parameter name="o" type="java.lang.Object">
 </parameter>
 </method>
 <method name="lastIndexOf"
@@ -278742,7 +278777,9 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="java.lang.Object">
+<parameter name="e" type="E">
+</parameter>
+<parameter name="index" type="int">
 </parameter>
 </method>
 <method name="listIterator"
@@ -278833,7 +278870,7 @@
 >
 <parameter name="index" type="int">
 </parameter>
-<parameter name="e" type="E">
+<parameter name="element" type="E">
 </parameter>
 </method>
 <method name="size"
@@ -279197,7 +279234,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="offer"
@@ -279210,7 +279247,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <parameter name="timeout" type="long">
 </parameter>
@@ -279238,12 +279275,6 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="time" type="long">
-</parameter>
-<parameter name="unit" type="java.util.concurrent.TimeUnit">
-</parameter>
-<exception name="InterruptedException" type="java.lang.InterruptedException">
-</exception>
 </method>
 <method name="poll"
  return="E"
@@ -279255,6 +279286,12 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="timeout" type="long">
+</parameter>
+<parameter name="unit" type="java.util.concurrent.TimeUnit">
+</parameter>
+<exception name="InterruptedException" type="java.lang.InterruptedException">
+</exception>
 </method>
 <method name="put"
  return="void"
@@ -279266,7 +279303,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="remainingCapacity"
@@ -280337,7 +280374,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <parameter name="timeout" type="long">
 </parameter>
@@ -280356,7 +280393,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="peek"
@@ -280408,7 +280445,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <exception name="InterruptedException" type="java.lang.InterruptedException">
 </exception>
@@ -280561,7 +280598,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="offer"
@@ -280574,7 +280611,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 <parameter name="timeout" type="long">
 </parameter>
@@ -280630,7 +280667,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="remainingCapacity"
@@ -281360,7 +281397,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="o" type="E">
+<parameter name="e" type="E">
 </parameter>
 </method>
 <method name="peek"
@@ -282065,7 +282102,7 @@
  extends="java.lang.Enum"
  abstract="false"
  static="false"
- final="true"
+ final="false"
  deprecated="not deprecated"
  visibility="public"
 >
@@ -282079,9 +282116,9 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="duration" type="long">
+<parameter name="sourceDuration" type="long">
 </parameter>
-<parameter name="unit" type="java.util.concurrent.TimeUnit">
+<parameter name="sourceUnit" type="java.util.concurrent.TimeUnit">
 </parameter>
 </method>
 <method name="sleep"
@@ -284117,12 +284154,55 @@
 </package>
 <package name="java.util.concurrent.locks"
 >
-<class name="AbstractQueuedSynchronizer"
+<class name="AbstractOwnableSynchronizer"
  extends="java.lang.Object"
  abstract="true"
  static="false"
  final="false"
  deprecated="not deprecated"
+ visibility=""
+>
+<implements name="java.io.Serializable">
+</implements>
+<constructor name="AbstractOwnableSynchronizer"
+ type="java.util.concurrent.locks.AbstractOwnableSynchronizer"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</constructor>
+<method name="getExclusiveOwnerThread"
+ return="java.lang.Thread"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</method>
+<method name="setExclusiveOwnerThread"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="t" type="java.lang.Thread">
+</parameter>
+</method>
+</class>
+<class name="AbstractQueuedSynchronizer"
+ extends="java.util.concurrent.locks.AbstractOwnableSynchronizer"
+ abstract="true"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
  visibility="public"
 >
 <implements name="java.io.Serializable">
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 3aeac53..447512a 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1085,6 +1085,7 @@
             reply.writeInt(result);
             return true;
         }
+        
         case KILL_APPLICATION_WITH_UID_TRANSACTION: {
             data.enforceInterface(IActivityManager.descriptor);
             String pkg = data.readString();
@@ -1093,6 +1094,14 @@
             reply.writeNoException();
             return true;
         }
+        
+        case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
+            data.enforceInterface(IActivityManager.descriptor);
+            String reason = data.readString();
+            closeSystemDialogs(reason);
+            reply.writeNoException();
+            return true;
+        }
         }
         
         return super.onTransact(code, data, reply, flags);
@@ -2376,6 +2385,7 @@
         data.recycle();
         return result;
     }
+    
     public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
         Parcel data = Parcel.obtain();
         Parcel reply = Parcel.obtain();
@@ -2387,6 +2397,17 @@
         data.recycle();
         reply.recycle();
     }
+    
+    public void closeSystemDialogs(String reason) throws RemoteException {
+        Parcel data = Parcel.obtain();
+        Parcel reply = Parcel.obtain();
+        data.writeInterfaceToken(IActivityManager.descriptor);
+        data.writeString(reason);
+        mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
+        reply.readException();
+        data.recycle();
+        reply.recycle();
+    }
         
     private IBinder mRemote;
 }
diff --git a/core/java/android/app/ApplicationContext.java b/core/java/android/app/ApplicationContext.java
index 1e4ab68..b095e30 100644
--- a/core/java/android/app/ApplicationContext.java
+++ b/core/java/android/app/ApplicationContext.java
@@ -578,7 +578,7 @@
     @Override
     public void setWallpaper(Bitmap bitmap) throws IOException  {
         try {
-            ParcelFileDescriptor fd = getWallpaperService().setWallpaper();
+            ParcelFileDescriptor fd = getWallpaperService().setWallpaper(null);
             if (fd == null) {
                 return;
             }
@@ -598,7 +598,7 @@
     @Override
     public void setWallpaper(InputStream data) throws IOException {
         try {
-            ParcelFileDescriptor fd = getWallpaperService().setWallpaper();
+            ParcelFileDescriptor fd = getWallpaperService().setWallpaper(null);
             if (fd == null) {
                 return;
             }
@@ -627,13 +627,16 @@
     @Override
     public void clearWallpaper() throws IOException {
         try {
+            Resources resources = getResources();
             /* Set the wallpaper to the default values */
-            ParcelFileDescriptor fd = getWallpaperService().setWallpaper();
+            ParcelFileDescriptor fd = getWallpaperService().setWallpaper(
+                    "res:" + resources.getResourceName(
+                        com.android.internal.R.drawable.default_wallpaper));
             if (fd != null) {
                 FileOutputStream fos = null;
                 try {
                     fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
-                    setWallpaper(getResources().openRawResource(
+                    setWallpaper(resources.openRawResource(
                             com.android.internal.R.drawable.default_wallpaper),
                             fos);
                 } finally {
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index b1b5282..f6ef549 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -268,7 +268,9 @@
             throws RemoteException;
 
     public void killApplicationWithUid(String pkg, int uid) throws RemoteException;
-        
+    
+    public void closeSystemDialogs(String reason) throws RemoteException;
+    
     /*
      * Private non-Binder interfaces
      */
@@ -424,4 +426,5 @@
     int UNREGISTER_ACTIVITY_WATCHER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+93;
     int START_ACTIVITY_IN_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+94;
     int KILL_APPLICATION_WITH_UID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+95;
+    int CLOSE_SYSTEM_DIALOGS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+96;
 }
diff --git a/core/java/android/app/IActivityWatcher.aidl b/core/java/android/app/IActivityWatcher.aidl
index 5d36e3f..6737545 100644
--- a/core/java/android/app/IActivityWatcher.aidl
+++ b/core/java/android/app/IActivityWatcher.aidl
@@ -23,4 +23,5 @@
  */
 oneway interface IActivityWatcher {
     void activityResuming(int activityId);
+    void closingSystemDialogs(String reason);
 }
diff --git a/core/java/android/app/IWallpaperService.aidl b/core/java/android/app/IWallpaperService.aidl
index a332b1a..281a060 100644
--- a/core/java/android/app/IWallpaperService.aidl
+++ b/core/java/android/app/IWallpaperService.aidl
@@ -25,7 +25,7 @@
     /**
      * Set the wallpaper.
      */
-    ParcelFileDescriptor setWallpaper();
+    ParcelFileDescriptor setWallpaper(String name);
     
     /**
      * Get the wallpaper.
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index e991bc6..fcfbd17 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -1297,6 +1297,9 @@
             if (mGlobalSearchMode) {
                 launchGlobalSearchIntent(intent);
             } else {
+                // If the intent was created from a suggestion, it will always have an explicit
+                // component here.
+                Log.i(LOG_TAG, "Starting (as ourselves) " + intent.toURI());
                 getContext().startActivity(intent);
                 // If the search switches to a different activity,
                 // SearchDialogWrapper#performActivityResuming
@@ -1338,7 +1341,6 @@
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         setBrowserApplicationId(intent);
 
-        if (DBG) Log.d(LOG_TAG, "Launching intent " + intent.toURI() + " as " + packageName);
         startActivityInPackage(intent, packageName);
     }
 
@@ -1379,6 +1381,7 @@
             String resultWho = null;
             int requestCode = -1;
             boolean onlyIfNeeded = false;
+            Log.i(LOG_TAG, "Starting (uid " + uid + ", " + packageName + ") " + intent.toURI());
             int result = ActivityManagerNative.getDefault().startActivityInPackage(
                     uid, intent, resolvedType, resultTo, resultWho, requestCode, onlyIfNeeded);
             checkStartActivityResult(result, intent);
diff --git a/core/java/android/backup/BackupDataInput.java b/core/java/android/backup/BackupDataInput.java
index 69c206c..e67b0be 100644
--- a/core/java/android/backup/BackupDataInput.java
+++ b/core/java/android/backup/BackupDataInput.java
@@ -97,12 +97,7 @@
 
     public void skipEntityData() throws IOException {
         if (mHeaderReady) {
-            int result = skipEntityData_native(mBackupReader);
-            if (result >= 0) {
-                return;
-            } else {
-                throw new IOException("result=0x" + Integer.toHexString(result));
-            }
+            skipEntityData_native(mBackupReader);
         } else {
             throw new IllegalStateException("mHeaderReady=false");
         }
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 64ee60e..5c75e2d 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1684,53 +1684,7 @@
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_REBOOT =
             "android.intent.action.REBOOT";
-    /**
-     * Broadcast Action: Triggers the platform Text-To-Speech engine to
-     * start the activity that installs the resource files on the device
-     * that are required for TTS to be operational. Since the installation
-     * of the data can be interrupted or declined by the user, the application
-     * shouldn't expect successful installation upon return from that intent,
-     * and if need be, should check installation status with 
-     * {@link #ACTION_TTS_CHECK_TTS_DATA}.
-     */
-    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String ACTION_TTS_INSTALL_TTS_DATA =
-            "android.intent.action.INSTALL_TTS_DATA";
 
-    /**
-     * Broadcast Action: Starts the activity from the platform Text-To-Speech
-     * engine to verify the proper installation and availability of the
-     * resource files on the system. Upon completion, the activity will
-     * return one of the following codes: 
-     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_PASS},
-     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_FAIL},
-     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_BAD_DATA},
-     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_MISSING_DATA}, or
-     * {@link android.speech.tts.TextToSpeech.Engine#CHECK_VOICE_DATA_MISSING_VOLUME}.
-     * <p> Moreover, the data received in the activity result will contain the following
-     * fields:
-     * <ul>
-     *   <li>{@link android.speech.tts.TextToSpeech.Engine#VOICE_DATA_ROOT_DIRECTORY} which
-     *       indicates the path to the location of the resource files</li>,
-     *   <li>{@link android.speech.tts.TextToSpeech.Engine#VOICE_DATA_FILES} which contains
-     *       the list of all the resource files</li>,
-     *   <li>and {@link android.speech.tts.TextToSpeech.Engine#VOICE_DATA_FILES_INFO} which
-     *       contains, for each resource file, the description of the language covered by
-     *       the file in the xxx-YYY format, where xxx is the 3-letter ISO language code,
-     *       and YYY is the 3-letter ISO country code.</li>
-     * </ul>
-     */
-    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String ACTION_TTS_CHECK_TTS_DATA =
-            "android.intent.action.CHECK_TTS_DATA";
-
-    /**
-     * Broadcast Action: The TextToSpeech synthesizer has completed processing 
-     * all of the text in the speech queue.
-     */
-    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String ACTION_TTS_QUEUE_PROCESSING_COMPLETED =
-            "android.intent.action.TTS_QUEUE_PROCESSING_COMPLETED";
 
     /**
      * Broadcast Action: a remote intent is to be broadcasted.
diff --git a/core/java/android/os/FileObserver.java b/core/java/android/os/FileObserver.java
index d9804ea..38d252e 100644
--- a/core/java/android/os/FileObserver.java
+++ b/core/java/android/os/FileObserver.java
@@ -25,22 +25,35 @@
 import java.util.HashMap;
 
 public abstract class FileObserver {
-    public static final int ACCESS = 0x00000001; /* File was accessed */
-    public static final int MODIFY = 0x00000002; /* File was modified */
-    public static final int ATTRIB = 0x00000004; /* Metadata changed */
-    public static final int CLOSE_WRITE = 0x00000008; /*  Writtable file was  closed */
-    public static final int CLOSE_NOWRITE = 0x00000010; /* Unwrittable file closed */
-    public static final int OPEN = 0x00000020; /* File was opened */
-    public static final int MOVED_FROM = 0x00000040; /* File was moved from X */
-    public static final int MOVED_TO = 0x00000080; /* File was moved to Y */
-    public static final int CREATE = 0x00000100; /* Subfile was created */
-    public static final int DELETE = 0x00000200; /* Subfile was deleted */
-    public static final int DELETE_SELF = 0x00000400; /* Self was deleted */
-    public static final int MOVE_SELF = 0x00000800; /* Self was moved */
+    /** File was accessed */
+    public static final int ACCESS = 0x00000001;
+    /** File was modified */
+    public static final int MODIFY = 0x00000002;
+    /** Metadata changed */
+    public static final int ATTRIB = 0x00000004;
+    /** Writable file was closed */
+    public static final int CLOSE_WRITE = 0x00000008;
+    /** Unwrittable file closed */
+    public static final int CLOSE_NOWRITE = 0x00000010;
+    /** File was opened */
+    public static final int OPEN = 0x00000020;
+    /** File was moved from X */
+    public static final int MOVED_FROM = 0x00000040;
+    /** File was moved to Y */
+    public static final int MOVED_TO = 0x00000080;
+    /** Subfile was created */
+    public static final int CREATE = 0x00000100;
+    /** Subfile was deleted */
+    public static final int DELETE = 0x00000200;
+    /** Self was deleted */
+    public static final int DELETE_SELF = 0x00000400;
+    /** Self was moved */
+    public static final int MOVE_SELF = 0x00000800;
+
     public static final int ALL_EVENTS = ACCESS | MODIFY | ATTRIB | CLOSE_WRITE 
             | CLOSE_NOWRITE | OPEN | MOVED_FROM | MOVED_TO | DELETE | CREATE
 	    | DELETE_SELF | MOVE_SELF;
-    
+
     private static final String LOG_TAG = "FileObserver";
 
     private static class ObserverThread extends Thread {
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index fb436e5..fb6ae28 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -188,10 +188,12 @@
     private boolean isSinkDevice(String address) {
         String uuids[] = mBluetoothService.getRemoteUuids(address);
         UUID uuid;
-        for (String deviceUuid: uuids) {
-            uuid = UUID.fromString(deviceUuid);
-            if (BluetoothUuid.isAudioSink(uuid)) {
-                return true;
+        if (uuids != null) {
+            for (String deviceUuid: uuids) {
+                uuid = UUID.fromString(deviceUuid);
+                if (BluetoothUuid.isAudioSink(uuid)) {
+                    return true;
+                }
             }
         }
         return false;
diff --git a/core/java/android/server/search/SearchDialogWrapper.java b/core/java/android/server/search/SearchDialogWrapper.java
index b8a9875..49718cb 100644
--- a/core/java/android/server/search/SearchDialogWrapper.java
+++ b/core/java/android/server/search/SearchDialogWrapper.java
@@ -63,6 +63,8 @@
     private static final int MSG_STOP_SEARCH = 2;
     // arg1 is activity id
     private static final int MSG_ACTIVITY_RESUMING = 3;
+    // obj is the reason
+    private static final int MSG_CLOSING_SYSTEM_DIALOGS = 4;
 
     private static final String KEY_INITIAL_QUERY = "q";
     private static final String KEY_LAUNCH_ACTIVITY = "a";
@@ -127,8 +129,7 @@
     private void registerBroadcastReceiver() {
         if (!mReceiverRegistered) {
             IntentFilter filter = new IntentFilter(
-                    Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
-            filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
+                    Intent.ACTION_CONFIGURATION_CHANGED);
             mContext.registerReceiver(mBroadcastReceiver, filter, null,
                     mSearchUiThread);
             mReceiverRegistered = true;
@@ -149,12 +150,7 @@
         @Override
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
-            if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
-                if (!"search".equals(intent.getStringExtra("reason"))) {
-                    if (DBG) debug(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
-                    performStopSearch();
-                }
-            } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
+            if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
                 if (DBG) debug(Intent.ACTION_CONFIGURATION_CHANGED);
                 performOnConfigurationChanged();
             }
@@ -219,6 +215,18 @@
         mSearchUiThread.sendMessage(msg);
     }
 
+    /**
+     * Handles closing of system windows/dialogs
+     * Can be called from any thread.
+     */
+    public void closingSystemDialogs(String reason) {
+        if (DBG) debug("closingSystemDialogs(reason=" + reason + ")");
+        Message msg = Message.obtain();
+        msg.what = MSG_CLOSING_SYSTEM_DIALOGS;
+        msg.obj = reason;
+        mSearchUiThread.sendMessage(msg);
+    }
+
     //
     // Implementation methods that run on the search UI thread
     //
@@ -244,6 +252,9 @@
                 case MSG_ACTIVITY_RESUMING:
                     performActivityResuming(msg.arg1);
                     break;
+                case MSG_CLOSING_SYSTEM_DIALOGS:
+                    performClosingSystemDialogs((String)msg.obj);
+                    break;
             }
         }
 
@@ -330,6 +341,19 @@
     }
 
     /**
+     * Updates due to system dialogs being closed
+     * This must be called on the search UI thread.
+     */
+    void performClosingSystemDialogs(String reason) {
+        if (DBG) debug("performClosingSystemDialogs(): mStartedIdent="
+                + mStartedIdent + ", reason: " + reason);
+        if (!"search".equals(reason)) {
+            if (DBG) debug(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+            performStopSearch();
+        }
+    }
+
+    /**
      * Must be called from the search UI thread.
      */
     void performOnConfigurationChanged() {
diff --git a/core/java/android/server/search/SearchManagerService.java b/core/java/android/server/search/SearchManagerService.java
index fdeb8f9..afed4a4 100644
--- a/core/java/android/server/search/SearchManagerService.java
+++ b/core/java/android/server/search/SearchManagerService.java
@@ -138,6 +138,11 @@
             if (mSearchDialog == null) return;
             mSearchDialog.activityResuming(activityId);
         }
+        public void closingSystemDialogs(String reason) {
+            if (DBG) Log.i("foo", "********************** closing dialogs: " + reason);
+            if (mSearchDialog == null) return;
+            mSearchDialog.closingSystemDialogs(reason);
+        }
     };
     
     /**
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java
index 8f8d976..b033c6a 100755
--- a/core/java/android/speech/tts/TextToSpeech.java
+++ b/core/java/android/speech/tts/TextToSpeech.java
@@ -18,6 +18,8 @@
 import android.speech.tts.ITts;
 import android.speech.tts.ITtsCallback;
 
+import android.annotation.SdkConstant;
+import android.annotation.SdkConstant.SdkConstantType;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -41,51 +43,60 @@
     /**
      * Denotes a successful operation.
      */
-    public static final int TTS_SUCCESS                = 0;
+    public static final int SUCCESS                = 0;
     /**
      * Denotes a generic operation failure.
      */
-    public static final int TTS_ERROR                  = -1;
+    public static final int ERROR                  = -1;
 
     /**
      * Queue mode where all entries in the playback queue (media to be played
      * and text to be synthesized) are dropped and replaced by the new entry.
      */
-    public static final int TTS_QUEUE_FLUSH = 0;
+    public static final int QUEUE_FLUSH = 0;
     /**
      * Queue mode where the new entry is added at the end of the playback queue.
      */
-    public static final int TTS_QUEUE_ADD = 1;
+    public static final int QUEUE_ADD = 1;
 
 
     /**
      * Denotes the language is available exactly as specified by the locale
      */
-    public static final int TTS_LANG_COUNTRY_VAR_AVAILABLE = 2;
+    public static final int LANG_COUNTRY_VAR_AVAILABLE = 2;
 
 
     /**
      * Denotes the language is available for the language and country specified 
      * by the locale, but not the variant.
      */
-    public static final int TTS_LANG_COUNTRY_AVAILABLE = 1;
+    public static final int LANG_COUNTRY_AVAILABLE = 1;
 
 
     /**
      * Denotes the language is available for the language by the locale, 
      * but not the country and variant.
      */
-    public static final int TTS_LANG_AVAILABLE = 0;
+    public static final int LANG_AVAILABLE = 0;
 
     /**
      * Denotes the language data is missing.
      */
-    public static final int TTS_LANG_MISSING_DATA = -1;
+    public static final int LANG_MISSING_DATA = -1;
 
     /**
      * Denotes the language is not supported by the current TTS engine.
      */
-    public static final int TTS_LANG_NOT_SUPPORTED = -2;
+    public static final int LANG_NOT_SUPPORTED = -2;
+
+
+    /**
+     * Broadcast Action: The TextToSpeech synthesizer has completed processing
+     * of all the text in the speech queue.
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_TTS_QUEUE_PROCESSING_COMPLETED =
+            "android.speech.tts.TTS_QUEUE_PROCESSING_COMPLETED";
 
 
     /**
@@ -119,126 +130,167 @@
         /**
          * {@hide}
          */
-        public static final int FALLBACK_TTS_DEFAULT_RATE = 100; // 1x
+        public static final int DEFAULT_RATE = 100; // 1x
         /**
          * {@hide}
          */
-        public static final int FALLBACK_TTS_DEFAULT_PITCH = 100;// 1x
+        public static final int DEFAULT_PITCH = 100;// 1x
         /**
          * {@hide}
          */
-        public static final int FALLBACK_TTS_USE_DEFAULTS = 0; // false
+        public static final int USE_DEFAULTS = 0; // false
         /**
          * {@hide}
          */
-        public static final String FALLBACK_TTS_DEFAULT_SYNTH = "com.svox.pico";
+        public static final String DEFAULT_SYNTH = "com.svox.pico";
 
         // default values for rendering
-        public static final int TTS_DEFAULT_STREAM = AudioManager.STREAM_MUSIC;
+        public static final int DEFAULT_STREAM = AudioManager.STREAM_MUSIC;
 
         // return codes for a TTS engine's check data activity
         /**
          * Indicates success when checking the installation status of the resources used by the
-         * text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent.
+         * text-to-speech engine with the {@link #ACTION_CHECK_TTS_DATA} intent.
          */
         public static final int CHECK_VOICE_DATA_PASS = 1;
         /**
          * Indicates failure when checking the installation status of the resources used by the
-         * text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent.
+         * text-to-speech engine with the {@link #ACTION_CHECK_TTS_DATA} intent.
          */
         public static final int CHECK_VOICE_DATA_FAIL = 0;
         /**
          * Indicates erroneous data when checking the installation status of the resources used by
-         * the text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent.
+         * the text-to-speech engine with the {@link #ACTION_CHECK_TTS_DATA} intent.
          */
         public static final int CHECK_VOICE_DATA_BAD_DATA = -1;
         /**
          * Indicates missing resources when checking the installation status of the resources used
-         * by the text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent.
+         * by the text-to-speech engine with the {@link #ACTION_CHECK_TTS_DATA} intent.
          */
         public static final int CHECK_VOICE_DATA_MISSING_DATA = -2;
         /**
          * Indicates missing storage volume when checking the installation status of the resources
-         * used by the text-to-speech engine with the android.intent.action.CHECK_TTS_DATA intent.
+         * used by the text-to-speech engine with the {@link #ACTION_CHECK_TTS_DATA} intent.
          */
         public static final int CHECK_VOICE_DATA_MISSING_VOLUME = -3;
 
-        // return codes for a TTS engine's check data activity
+        // intents to ask engine to install data or check its data
         /**
-         * Extra information received with the android.intent.action.CHECK_TTS_DATA intent where
+         * Broadcast Action: Triggers the platform Text-To-Speech engine to
+         * start the activity that installs the resource files on the device
+         * that are required for TTS to be operational. Since the installation
+         * of the data can be interrupted or declined by the user, the application
+         * shouldn't expect successful installation upon return from that intent,
+         * and if need be, should check installation status with
+         * {@link #ACTION_CHECK_TTS_DATA}.
+         */
+        @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+        public static final String ACTION_INSTALL_TTS_DATA =
+                "android.speech.tts.engine.INSTALL_TTS_DATA";
+
+        /**
+         * Broadcast Action: Starts the activity from the platform Text-To-Speech
+         * engine to verify the proper installation and availability of the
+         * resource files on the system. Upon completion, the activity will
+         * return one of the following codes:
+         * {@link #CHECK_VOICE_DATA_PASS},
+         * {@link #CHECK_VOICE_DATA_FAIL},
+         * {@link #CHECK_VOICE_DATA_BAD_DATA},
+         * {@link #CHECK_VOICE_DATA_MISSING_DATA}, or
+         * {@link #CHECK_VOICE_DATA_MISSING_VOLUME}.
+         * <p> Moreover, the data received in the activity result will contain the following
+         * fields:
+         * <ul>
+         *   <li>{@link #EXTRA_VOICE_DATA_ROOT_DIRECTORY} which
+         *       indicates the path to the location of the resource files</li>,
+         *   <li>{@link #EXTRA_VOICE_DATA_FILES} which contains
+         *       the list of all the resource files</li>,
+         *   <li>and {@link #EXTRA_VOICE_DATA_FILES_INFO} which
+         *       contains, for each resource file, the description of the language covered by
+         *       the file in the xxx-YYY format, where xxx is the 3-letter ISO language code,
+         *       and YYY is the 3-letter ISO country code.</li>
+         * </ul>
+         */
+        @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+        public static final String ACTION_CHECK_TTS_DATA =
+                "android.speech.tts.engine.CHECK_TTS_DATA";
+
+        // extras for a TTS engine's check data activity
+        /**
+         * Extra information received with the {@link #ACTION_CHECK_TTS_DATA} intent where
          * the text-to-speech engine specifies the path to its resources.
          */
-        public static final String VOICE_DATA_ROOT_DIRECTORY = "dataRoot";
+        public static final String EXTRA_VOICE_DATA_ROOT_DIRECTORY = "dataRoot";
         /**
-         * Extra information received with the android.intent.action.CHECK_TTS_DATA intent where
+         * Extra information received with the {@link #ACTION_CHECK_TTS_DATA} intent where
          * the text-to-speech engine specifies the file names of its resources under the
          * resource path.
          */
-        public static final String VOICE_DATA_FILES = "dataFiles";
+        public static final String EXTRA_VOICE_DATA_FILES = "dataFiles";
         /**
-         * Extra information received with the android.intent.action.CHECK_TTS_DATA intent where
+         * Extra information received with the {@link #ACTION_CHECK_TTS_DATA} intent where
          * the text-to-speech engine specifies the locale associated with each resource file.
          */
-        public static final String VOICE_DATA_FILES_INFO = "dataFilesInfo";
+        public static final String EXTRA_VOICE_DATA_FILES_INFO = "dataFilesInfo";
 
         // keys for the parameters passed with speak commands. Hidden keys are used internally
         // to maintain engine state for each TextToSpeech instance.
         /**
          * {@hide}
          */
-        public static final String TTS_KEY_PARAM_RATE = "rate";
+        public static final String KEY_PARAM_RATE = "rate";
         /**
          * {@hide}
          */
-        public static final String TTS_KEY_PARAM_LANGUAGE = "language";
+        public static final String KEY_PARAM_LANGUAGE = "language";
         /**
          * {@hide}
          */
-        public static final String TTS_KEY_PARAM_COUNTRY = "country";
+        public static final String KEY_PARAM_COUNTRY = "country";
         /**
          * {@hide}
          */
-        public static final String TTS_KEY_PARAM_VARIANT = "variant";
+        public static final String KEY_PARAM_VARIANT = "variant";
         /**
          * Parameter key to specify the audio stream type to be used when speaking text
          * or playing back a file.
          */
-        public static final String TTS_KEY_PARAM_STREAM = "streamType";
+        public static final String KEY_PARAM_STREAM = "streamType";
         /**
          * Parameter key to identify an utterance in the completion listener after text has been
          * spoken, a file has been played back or a silence duration has elapsed.
          */
-        public static final String TTS_KEY_PARAM_UTTERANCE_ID = "utteranceId";
+        public static final String KEY_PARAM_UTTERANCE_ID = "utteranceId";
 
         // key positions in the array of cached parameters
         /**
          * {@hide}
          */
-        protected static final int TTS_PARAM_POSITION_RATE = 0;
+        protected static final int PARAM_POSITION_RATE = 0;
         /**
          * {@hide}
          */
-        protected static final int TTS_PARAM_POSITION_LANGUAGE = 2;
+        protected static final int PARAM_POSITION_LANGUAGE = 2;
         /**
          * {@hide}
          */
-        protected static final int TTS_PARAM_POSITION_COUNTRY = 4;
+        protected static final int PARAM_POSITION_COUNTRY = 4;
         /**
          * {@hide}
          */
-        protected static final int TTS_PARAM_POSITION_VARIANT = 6;
+        protected static final int PARAM_POSITION_VARIANT = 6;
         /**
          * {@hide}
          */
-        protected static final int TTS_PARAM_POSITION_STREAM = 8;
+        protected static final int PARAM_POSITION_STREAM = 8;
         /**
          * {@hide}
          */
-        protected static final int TTS_PARAM_POSITION_UTTERANCE_ID = 10;
+        protected static final int PARAM_POSITION_UTTERANCE_ID = 10;
         /**
          * {@hide}
          */
-        protected static final int TTS_NB_CACHED_PARAMS = 6;
+        protected static final int NB_CACHED_PARAMS = 6;
     }
 
     /**
@@ -273,25 +325,25 @@
         mPackageName = mContext.getPackageName();
         mInitListener = listener;
 
-        mCachedParams = new String[2*Engine.TTS_NB_CACHED_PARAMS]; // store key and value
-        mCachedParams[Engine.TTS_PARAM_POSITION_RATE] = Engine.TTS_KEY_PARAM_RATE;
-        mCachedParams[Engine.TTS_PARAM_POSITION_LANGUAGE] = Engine.TTS_KEY_PARAM_LANGUAGE;
-        mCachedParams[Engine.TTS_PARAM_POSITION_COUNTRY] = Engine.TTS_KEY_PARAM_COUNTRY;
-        mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT] = Engine.TTS_KEY_PARAM_VARIANT;
-        mCachedParams[Engine.TTS_PARAM_POSITION_STREAM] = Engine.TTS_KEY_PARAM_STREAM;
-        mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = Engine.TTS_KEY_PARAM_UTTERANCE_ID;
+        mCachedParams = new String[2*Engine.NB_CACHED_PARAMS]; // store key and value
+        mCachedParams[Engine.PARAM_POSITION_RATE] = Engine.KEY_PARAM_RATE;
+        mCachedParams[Engine.PARAM_POSITION_LANGUAGE] = Engine.KEY_PARAM_LANGUAGE;
+        mCachedParams[Engine.PARAM_POSITION_COUNTRY] = Engine.KEY_PARAM_COUNTRY;
+        mCachedParams[Engine.PARAM_POSITION_VARIANT] = Engine.KEY_PARAM_VARIANT;
+        mCachedParams[Engine.PARAM_POSITION_STREAM] = Engine.KEY_PARAM_STREAM;
+        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID] = Engine.KEY_PARAM_UTTERANCE_ID;
 
-        mCachedParams[Engine.TTS_PARAM_POSITION_RATE + 1] =
-                String.valueOf(Engine.FALLBACK_TTS_DEFAULT_RATE);
+        mCachedParams[Engine.PARAM_POSITION_RATE + 1] =
+                String.valueOf(Engine.DEFAULT_RATE);
         // initialize the language cached parameters with the current Locale
         Locale defaultLoc = Locale.getDefault();
-        mCachedParams[Engine.TTS_PARAM_POSITION_LANGUAGE + 1] = defaultLoc.getISO3Language();
-        mCachedParams[Engine.TTS_PARAM_POSITION_COUNTRY + 1] = defaultLoc.getISO3Country();
-        mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] = defaultLoc.getVariant();
+        mCachedParams[Engine.PARAM_POSITION_LANGUAGE + 1] = defaultLoc.getISO3Language();
+        mCachedParams[Engine.PARAM_POSITION_COUNTRY + 1] = defaultLoc.getISO3Country();
+        mCachedParams[Engine.PARAM_POSITION_VARIANT + 1] = defaultLoc.getVariant();
 
-        mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] =
-                String.valueOf(Engine.TTS_DEFAULT_STREAM);
-        mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = "";
+        mCachedParams[Engine.PARAM_POSITION_STREAM + 1] =
+                String.valueOf(Engine.DEFAULT_STREAM);
+        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID + 1] = "";
 
         initTts();
     }
@@ -308,7 +360,7 @@
                     mStarted = true;
                     if (mInitListener != null) {
                         // TODO manage failures and missing resources
-                        mInitListener.onInit(TTS_SUCCESS);
+                        mInitListener.onInit(SUCCESS);
                     }
                 }
             }
@@ -349,8 +401,7 @@
     /**
      * Adds a mapping between a string of text and a sound resource in a
      * package.
-     *
-     * @see #TTS.speak(String text, int queueMode, String[] params)
+     * @see #speak(String, int, HashMap)
      *
      * @param text
      *            Example: <b><code>"south_south_east"</code></b><br/>
@@ -371,16 +422,16 @@
      * @param resourceId
      *            Example: <b><code>R.raw.south_south_east</code></b>
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int addSpeech(String text, String packagename, int resourceId) {
         synchronized(mStartLock) {
             if (!mStarted) {
-                return TTS_ERROR;
+                return ERROR;
             }
             try {
                 mITts.addSpeech(mPackageName, text, packagename, resourceId);
-                return TTS_SUCCESS;
+                return SUCCESS;
             } catch (RemoteException e) {
                 // TTS died; restart it.
                 Log.e("TextToSpeech.java - addSpeech", "RemoteException");
@@ -400,7 +451,7 @@
                 mStarted = false;
                 initTts();
             }
-            return TTS_ERROR;
+            return ERROR;
         }
     }
 
@@ -415,16 +466,16 @@
      *            The full path to the sound file (for example:
      *            "/sdcard/mysounds/hello.wav")
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int addSpeech(String text, String filename) {
         synchronized (mStartLock) {
             if (!mStarted) {
-                return TTS_ERROR;
+                return ERROR;
             }
             try {
                 mITts.addSpeechFile(mPackageName, text, filename);
-                return TTS_SUCCESS;
+                return SUCCESS;
             } catch (RemoteException e) {
                 // TTS died; restart it.
                 Log.e("TextToSpeech.java - addSpeech", "RemoteException");
@@ -444,7 +495,7 @@
                 mStarted = false;
                 initTts();
             }
-            return TTS_ERROR;
+            return ERROR;
         }
     }
 
@@ -453,7 +504,7 @@
      * Adds a mapping between a string of text and a sound resource in a
      * package.
      *
-     * @see #TTS.playEarcon(String earcon, int queueMode, String[] params)
+     * @see #playEarcon(String, int, HashMap)
      *
      * @param earcon The name of the earcon
      *            Example: <b><code>"[tick]"</code></b><br/>
@@ -474,16 +525,16 @@
      * @param resourceId
      *            Example: <b><code>R.raw.tick_snd</code></b>
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int addEarcon(String earcon, String packagename, int resourceId) {
         synchronized(mStartLock) {
             if (!mStarted) {
-                return TTS_ERROR;
+                return ERROR;
             }
             try {
                 mITts.addEarcon(mPackageName, earcon, packagename, resourceId);
-                return TTS_SUCCESS;
+                return SUCCESS;
             } catch (RemoteException e) {
                 // TTS died; restart it.
                 Log.e("TextToSpeech.java - addEarcon", "RemoteException");
@@ -503,7 +554,7 @@
                 mStarted = false;
                 initTts();
             }
-            return TTS_ERROR;
+            return ERROR;
         }
     }
 
@@ -518,16 +569,16 @@
      *            The full path to the sound file (for example:
      *            "/sdcard/mysounds/tick.wav")
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int addEarcon(String earcon, String filename) {
         synchronized (mStartLock) {
             if (!mStarted) {
-                return TTS_ERROR;
+                return ERROR;
             }
             try {
                 mITts.addEarconFile(mPackageName, earcon, filename);
-                return TTS_SUCCESS;
+                return SUCCESS;
             } catch (RemoteException e) {
                 // TTS died; restart it.
                 Log.e("TextToSpeech.java - addEarcon", "RemoteException");
@@ -547,7 +598,7 @@
                 mStarted = false;
                 initTts();
             }
-            return TTS_ERROR;
+            return ERROR;
         }
     }
 
@@ -563,29 +614,29 @@
      *            The string of text to be spoken.
      * @param queueMode
      *            The queuing strategy to use.
-     *            See TTS_QUEUE_ADD and TTS_QUEUE_FLUSH.
+     *            See QUEUE_ADD and QUEUE_FLUSH.
      * @param params
      *            The hashmap of speech parameters to be used.
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int speak(String text, int queueMode, HashMap<String,String> params)
     {
         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             Log.i("TTS received: ", text);
             if (!mStarted) {
                 return result;
             }
             try {
                 if ((params != null) && (!params.isEmpty())) {
-                    String extra = params.get(Engine.TTS_KEY_PARAM_STREAM);
+                    String extra = params.get(Engine.KEY_PARAM_STREAM);
                     if (extra != null) {
-                        mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra;
+                        mCachedParams[Engine.PARAM_POSITION_STREAM + 1] = extra;
                     }
-                    extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
+                    extra = params.get(Engine.KEY_PARAM_UTTERANCE_ID);
                     if (extra != null) {
-                        mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra;
+                        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID + 1] = extra;
                     }
                 }
                 result = mITts.speak(mPackageName, text, queueMode, mCachedParams);
@@ -621,28 +672,28 @@
      * @param earcon
      *            The earcon that should be played
      * @param queueMode
-     *            See TTS_QUEUE_ADD and TTS_QUEUE_FLUSH.
+     *            See QUEUE_ADD and QUEUE_FLUSH.
      * @param params
      *            The hashmap of parameters to be used.
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int playEarcon(String earcon, int queueMode,
             HashMap<String,String> params) {
         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             if (!mStarted) {
                 return result;
             }
             try {
                 if ((params != null) && (!params.isEmpty())) {
-                    String extra = params.get(Engine.TTS_KEY_PARAM_STREAM);
+                    String extra = params.get(Engine.KEY_PARAM_STREAM);
                     if (extra != null) {
-                        mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra;
+                        mCachedParams[Engine.PARAM_POSITION_STREAM + 1] = extra;
                     }
-                    extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
+                    extra = params.get(Engine.KEY_PARAM_UTTERANCE_ID);
                     if (extra != null) {
-                        mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra;
+                        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID + 1] = extra;
                     }
                 }
                 result = mITts.playEarcon(mPackageName, earcon, queueMode, null);
@@ -678,21 +729,21 @@
      * @param durationInMs
      *            A long that indicates how long the silence should last.
      * @param queueMode
-     *            See TTS_QUEUE_ADD and TTS_QUEUE_FLUSH.
+     *            See QUEUE_ADD and QUEUE_FLUSH.
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int playSilence(long durationInMs, int queueMode, HashMap<String,String> params) {
         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             if (!mStarted) {
                 return result;
             }
             try {
                 if ((params != null) && (!params.isEmpty())) {
-                    String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
+                    String extra = params.get(Engine.KEY_PARAM_UTTERANCE_ID);
                     if (extra != null) {
-                        mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra;
+                        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID + 1] = extra;
                     }
                 }
                 result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams);
@@ -760,11 +811,11 @@
     /**
      * Stops speech from the TTS.
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int stop() {
         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             if (!mStarted) {
                 return result;
             }
@@ -808,24 +859,24 @@
      *            lower values slow down the speech (0.5 is half the normal speech rate),
      *            greater values accelerate it (2 is twice the normal speech rate).
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int setSpeechRate(float speechRate) {
         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             if (!mStarted) {
                 return result;
             }
             try {
                 if (speechRate > 0) {
                     int rate = (int)(speechRate*100);
-                    mCachedParams[Engine.TTS_PARAM_POSITION_RATE + 1] = String.valueOf(rate);
+                    mCachedParams[Engine.PARAM_POSITION_RATE + 1] = String.valueOf(rate);
                     // the rate is not set here, instead it is cached so it will be associated
                     // with all upcoming utterances.
                     if (speechRate > 0.0f) {
-                        result = TTS_SUCCESS;
+                        result = SUCCESS;
                     } else {
-                        result = TTS_ERROR;
+                        result = ERROR;
                     }
                 }
             } catch (NullPointerException e) {
@@ -860,11 +911,11 @@
      *            lower values lower the tone of the synthesized voice,
      *            greater values increase it.
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int setPitch(float pitch) {
         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             if (!mStarted) {
                 return result;
             }
@@ -907,27 +958,27 @@
      * @param loc
      *            The locale describing the language to be used.
      *
-     * @return code indicating the support status for the locale. See {@link #TTS_LANG_AVAILABLE},
-     *         {@link #TTS_LANG_COUNTRY_AVAILABLE}, {@link #TTS_LANG_COUNTRY_VAR_AVAILABLE},
-     *         {@link #TTS_LANG_MISSING_DATA} and {@link #TTS_LANG_NOT_SUPPORTED}.
+     * @return code indicating the support status for the locale. See {@link #LANG_AVAILABLE},
+     *         {@link #LANG_COUNTRY_AVAILABLE}, {@link #LANG_COUNTRY_VAR_AVAILABLE},
+     *         {@link #LANG_MISSING_DATA} and {@link #LANG_NOT_SUPPORTED}.
      */
     public int setLanguage(Locale loc) {
         synchronized (mStartLock) {
-            int result = TTS_LANG_NOT_SUPPORTED;
+            int result = LANG_NOT_SUPPORTED;
             if (!mStarted) {
                 return result;
             }
             try {
-                mCachedParams[Engine.TTS_PARAM_POSITION_LANGUAGE + 1] = loc.getISO3Language();
-                mCachedParams[Engine.TTS_PARAM_POSITION_COUNTRY + 1] = loc.getISO3Country();
-                mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] = loc.getVariant();
+                mCachedParams[Engine.PARAM_POSITION_LANGUAGE + 1] = loc.getISO3Language();
+                mCachedParams[Engine.PARAM_POSITION_COUNTRY + 1] = loc.getISO3Country();
+                mCachedParams[Engine.PARAM_POSITION_VARIANT + 1] = loc.getVariant();
                 // the language is not set here, instead it is cached so it will be associated
                 // with all upcoming utterances. But we still need to report the language support,
                 // which is achieved by calling isLanguageAvailable()
                 result = mITts.isLanguageAvailable(
-                        mCachedParams[Engine.TTS_PARAM_POSITION_LANGUAGE + 1],
-                        mCachedParams[Engine.TTS_PARAM_POSITION_COUNTRY + 1],
-                        mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] );
+                        mCachedParams[Engine.PARAM_POSITION_LANGUAGE + 1],
+                        mCachedParams[Engine.PARAM_POSITION_COUNTRY + 1],
+                        mCachedParams[Engine.PARAM_POSITION_VARIANT + 1] );
             } catch (RemoteException e) {
                 // TTS died; restart it.
                 Log.e("TextToSpeech.java - setLanguage", "RemoteException");
@@ -999,13 +1050,13 @@
      * @param loc
      *            The Locale describing the language to be used.
      *
-     * @return code indicating the support status for the locale. See {@link #TTS_LANG_AVAILABLE},
-     *         {@link #TTS_LANG_COUNTRY_AVAILABLE}, {@link #TTS_LANG_COUNTRY_VAR_AVAILABLE},
-     *         {@link #TTS_LANG_MISSING_DATA} and {@link #TTS_LANG_NOT_SUPPORTED}.
+     * @return code indicating the support status for the locale. See {@link #LANG_AVAILABLE},
+     *         {@link #LANG_COUNTRY_AVAILABLE}, {@link #LANG_COUNTRY_VAR_AVAILABLE},
+     *         {@link #LANG_MISSING_DATA} and {@link #LANG_NOT_SUPPORTED}.
      */
     public int isLanguageAvailable(Locale loc) {
         synchronized (mStartLock) {
-            int result = TTS_LANG_NOT_SUPPORTED;
+            int result = LANG_NOT_SUPPORTED;
             if (!mStarted) {
                 return result;
             }
@@ -1048,25 +1099,25 @@
      *            The string that gives the full output filename; it should be
      *            something like "/sdcard/myappsounds/mysound.wav".
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int synthesizeToFile(String text, HashMap<String,String> params,
             String filename) {
         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             if (!mStarted) {
                 return result;
             }
             try {
                 if ((params != null) && (!params.isEmpty())) {
                     // no need to read the stream type here
-                    String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID);
+                    String extra = params.get(Engine.KEY_PARAM_UTTERANCE_ID);
                     if (extra != null) {
-                        mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID + 1] = extra;
+                        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID + 1] = extra;
                     }
                 }
                 if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){
-                    result = TTS_SUCCESS;
+                    result = SUCCESS;
                 }
             } catch (RemoteException e) {
                 // TTS died; restart it.
@@ -1099,9 +1150,9 @@
      * if they are not persistent between calls to the service.
      */
     private void resetCachedParams() {
-        mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] =
-                String.valueOf(Engine.TTS_DEFAULT_STREAM);
-        mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID+ 1] = "";
+        mCachedParams[Engine.PARAM_POSITION_STREAM + 1] =
+                String.valueOf(Engine.DEFAULT_STREAM);
+        mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID+ 1] = "";
     }
 
     /**
@@ -1110,12 +1161,12 @@
      * @param listener
      *            The OnUtteranceCompletedListener
      *
-     * @return Code indicating success or failure. See TTS_ERROR and TTS_SUCCESS.
+     * @return Code indicating success or failure. See {@link #ERROR} and {@link #SUCCESS}.
      */
     public int setOnUtteranceCompletedListener(

             final OnUtteranceCompletedListener listener) {

         synchronized (mStartLock) {
-            int result = TTS_ERROR;
+            int result = ERROR;
             if (!mStarted) {
                 return result;
             }
diff --git a/core/java/android/util/EventLog.java b/core/java/android/util/EventLog.java
index 0f0be79..81dd96e 100644
--- a/core/java/android/util/EventLog.java
+++ b/core/java/android/util/EventLog.java
@@ -124,10 +124,6 @@
                         "A List must have fewer than "
                         + Byte.MAX_VALUE + " items in it.");
             }
-            if (items.length < 1) {
-                throw new IllegalArgumentException(
-                        "A List must have at least one item in it.");
-            }
             for (int i = 0; i < items.length; i++) {
                 final Object item = items[i];
                 if (item == null) {
@@ -223,7 +219,7 @@
             case LIST:
                 if (mBuffer.remaining() < 1) return null;
                 int length = mBuffer.get();
-                if (length <= 0) return null;
+                if (length < 0) return null;
                 Object[] array = new Object[length];
                 for (int i = 0; i < length; ++i) {
                     array[i] = decodeObject();
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index d46660c..ae84e1e 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -516,14 +516,14 @@
         }
         
         final int NS = (ev.mNumPointers=o.mNumPointers) * NT;
-        if (ev.mStateSamples.length < NS) {
+        if (ev.mStateSamples.length >= NS) {
             System.arraycopy(o.mStateSamples, 0, ev.mStateSamples, 0, NS);
         } else {
             ev.mStateSamples = (int[])o.mStateSamples.clone();
         }
         
         final int ND = NS * NUM_SAMPLE_DATA;
-        if (ev.mDataSamples.length < ND) {
+        if (ev.mDataSamples.length >= ND) {
             System.arraycopy(o.mDataSamples, 0, ev.mDataSamples, 0, ND);
         } else {
             ev.mDataSamples = (float[])o.mDataSamples.clone();
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 9178131..c4bf642 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -107,8 +107,14 @@
     public static final int SURFACE_HIDDEN    = 0x01;
     
     /** Freeze the surface. Equivalent to calling freeze() */ 
+    public static final int SURFACE_FROZEN     = 0x02;
+
+    /**
+     * @deprecated use {@link #SURFACE_FROZEN} instead.
+     */
+    @Deprecated
     public static final int SURACE_FROZEN     = 0x02;
-    
+
     /** Enable dithering when compositing this surface */
     public static final int SURFACE_DITHER    = 0x04;
 
diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java
index 3da5a3c..50436d8 100644
--- a/core/java/android/webkit/LoadListener.java
+++ b/core/java/android/webkit/LoadListener.java
@@ -74,6 +74,7 @@
     static {
         sCertificateMimeTypeMap = new HashSet<String>();
         sCertificateMimeTypeMap.add("application/x-x509-ca-cert");
+        sCertificateMimeTypeMap.add("application/x-x509-user-cert");
         sCertificateMimeTypeMap.add("application/x-pkcs12");
     }
 
diff --git a/core/java/android/webkit/MimeTypeMap.java b/core/java/android/webkit/MimeTypeMap.java
index b2aa524..a55dbc8 100644
--- a/core/java/android/webkit/MimeTypeMap.java
+++ b/core/java/android/webkit/MimeTypeMap.java
@@ -330,6 +330,7 @@
             sMimeTypeMap.loadEntry("application/x-wingz", "wz");
             sMimeTypeMap.loadEntry("application/x-webarchive", "webarchive");
             sMimeTypeMap.loadEntry("application/x-x509-ca-cert", "crt");
+            sMimeTypeMap.loadEntry("application/x-x509-user-cert", "crt");
             sMimeTypeMap.loadEntry("application/x-xcf", "xcf");
             sMimeTypeMap.loadEntry("application/x-xfig", "fig");
             sMimeTypeMap.loadEntry("application/xhtml+xml", "xhtml");
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index a26bfa2..47f5c6c 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -277,7 +277,7 @@
         if (child.getLayoutParams() == null) {
             final LinearLayout.LayoutParams lp = new LayoutParams(
                     0,
-                    ViewGroup.LayoutParams.WRAP_CONTENT, 1);
+                    ViewGroup.LayoutParams.FILL_PARENT, 1.0f);
             lp.setMargins(0, 0, 0, 0);
             child.setLayoutParams(lp);
         }
@@ -289,10 +289,10 @@
         // If we have dividers between the tabs and we already have at least one
         // tab, then add a divider before adding the next tab.
         if (mDividerDrawable != null && getTabCount() > 0) {
-            View divider = new View(mContext);
+            ImageView divider = new ImageView(mContext);
             final LinearLayout.LayoutParams lp = new LayoutParams(
                     mDividerDrawable.getIntrinsicWidth(),
-                    mDividerDrawable.getIntrinsicHeight());
+                    LayoutParams.FILL_PARENT);
             lp.setMargins(0, 0, 0, 0);
             divider.setLayoutParams(lp);
             divider.setBackgroundDrawable(mDividerDrawable);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 0421612..591f9bb 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6916,6 +6916,17 @@
             }
         }
 
+        boolean hasLetter = false;
+        for (int i = start; i < end; i++) {
+            if (Character.isLetter(mTransformed.charAt(i))) {
+                hasLetter = true;
+                break;
+            }
+        }
+        if (!hasLetter) {
+            return null;
+        }
+
         if (start == end) {
             return null;
         }
diff --git a/core/java/com/android/internal/backup/SystemBackupAgent.java b/core/java/com/android/internal/backup/SystemBackupAgent.java
deleted file mode 100644
index 6b396d7..0000000
--- a/core/java/com/android/internal/backup/SystemBackupAgent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 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 com.android.internal.backup;
-
-import android.backup.AbsoluteFileBackupHelper;
-import android.backup.BackupHelperAgent;
-
-/**
- * Backup agent for various system-managed data
- */
-public class SystemBackupAgent extends BackupHelperAgent {
-    // the set of files that we back up whole, as absolute paths
-    String[] mFiles = {
-            /* WallpaperService.WALLPAPER_FILE */
-            "/data/data/com.android.settings/files/wallpaper",
-            };
-
-    public void onCreate() {
-        addHelper("system_files", new AbsoluteFileBackupHelper(this, mFiles));
-    }
-}
diff --git a/core/java/com/google/android/gdata/client/QueryParamsImpl.java b/core/java/com/google/android/gdata/client/QueryParamsImpl.java
index e27b36f..fbe0d22 100644
--- a/core/java/com/google/android/gdata/client/QueryParamsImpl.java
+++ b/core/java/com/google/android/gdata/client/QueryParamsImpl.java
@@ -60,6 +60,8 @@
             sb.append('?');
         }
         for (String param : params) {
+            String value = mParams.get(param);
+            if (value == null) continue;
             if (first) {
                 first = false;
             } else {
@@ -67,7 +69,7 @@
             }
             sb.append(param);
             sb.append('=');
-            String value = mParams.get(param);
+
             String encodedValue = null;
 
             try {
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 6ad2441..1cd04f1 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1087,7 +1087,7 @@
                  android:hasCode="false"
                  android:label="@string/android_system_label"
                  android:allowClearUserData="false"
-                 android:backupAgent="com.android.internal.backup.SystemBackupAgent"
+                 android:backupAgent="com.android.server.SystemBackupAgent"
                  android:icon="@drawable/ic_launcher_android">
         <activity android:name="com.android.internal.app.ChooserActivity"
                 android:theme="@style/Theme.Dialog.Alert"
diff --git a/keystore/java/android/security/CertTool.java b/keystore/java/android/security/CertTool.java
index 1de007d..b1b78ea 100644
--- a/keystore/java/android/security/CertTool.java
+++ b/keystore/java/android/security/CertTool.java
@@ -140,7 +140,7 @@
 
     private void addExtraIntentInfo(Intent intent, String namespace,
             String data) {
-        intent.putExtra(KEY_ITEM + "1", data);
+        intent.putExtra(KEY_ITEM + "1", data.getBytes());
         intent.putExtra(KEY_NAMESPACE + "1", namespace);
     }
 
diff --git a/keystore/jni/cert.c b/keystore/jni/cert.c
index ea21b7d..006a0a3 100644
--- a/keystore/jni/cert.c
+++ b/keystore/jni/cert.c
@@ -46,7 +46,7 @@
     RSA *rsa = EVP_PKEY_get1_RSA(pkey);
     EVP_PKEY_set1_RSA(newpkey, rsa);
     PKEY_STORE_free(pkey_store[store_index]);
-    pkey_store[store_index].key_len = i2d_RSAPublicKey(rsa, &pkey_store[store_index].public_key);
+    pkey_store[store_index].key_len = i2d_RSA_PUBKEY(rsa, &pkey_store[store_index].public_key);
     pkey_store[store_index++].pkey = newpkey;
     store_index %= KEYGEN_STORE_SIZE;
     RSA_free(rsa);
diff --git a/libs/audioflinger/Android.mk b/libs/audioflinger/Android.mk
index c10e02b..f5c03bb 100644
--- a/libs/audioflinger/Android.mk
+++ b/libs/audioflinger/Android.mk
@@ -107,6 +107,7 @@
 
 ifeq ($(BOARD_HAVE_BLUETOOTH),true)
   LOCAL_CFLAGS += -DWITH_BLUETOOTH -DWITH_A2DP
+  LOCAL_SHARED_LIBRARIES += liba2dp
 endif
 
 ifeq ($(AUDIO_POLICY_TEST),true)
diff --git a/libs/rs/java/Film/res/drawable/p01.png b/libs/rs/java/Film/res/drawable/p01.png
new file mode 100644
index 0000000..a9b9bdb
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p01.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p02.png b/libs/rs/java/Film/res/drawable/p02.png
new file mode 100644
index 0000000..8162c82
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p02.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p03.png b/libs/rs/java/Film/res/drawable/p03.png
new file mode 100644
index 0000000..e3e26c0
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p03.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p04.png b/libs/rs/java/Film/res/drawable/p04.png
new file mode 100644
index 0000000..daee603
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p04.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p05.png b/libs/rs/java/Film/res/drawable/p05.png
new file mode 100644
index 0000000..fac5248
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p05.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p06.png b/libs/rs/java/Film/res/drawable/p06.png
new file mode 100644
index 0000000..3b51261
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p06.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p07.png b/libs/rs/java/Film/res/drawable/p07.png
new file mode 100644
index 0000000..d8bd938
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p07.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p08.png b/libs/rs/java/Film/res/drawable/p08.png
new file mode 100644
index 0000000..ef175e8
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p08.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p09.png b/libs/rs/java/Film/res/drawable/p09.png
new file mode 100644
index 0000000..7bf3874
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p09.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p10.png b/libs/rs/java/Film/res/drawable/p10.png
new file mode 100644
index 0000000..908827d
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p10.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p11.png b/libs/rs/java/Film/res/drawable/p11.png
new file mode 100644
index 0000000..1289f71
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p11.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p12.png b/libs/rs/java/Film/res/drawable/p12.png
new file mode 100644
index 0000000..e1af16a
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p12.png
Binary files differ
diff --git a/libs/rs/java/Film/res/drawable/p13.png b/libs/rs/java/Film/res/drawable/p13.png
new file mode 100644
index 0000000..d08bcbe
--- /dev/null
+++ b/libs/rs/java/Film/res/drawable/p13.png
Binary files differ
diff --git a/libs/rs/java/Film/res/raw/filmstrip.c b/libs/rs/java/Film/res/raw/filmstrip.c
index 495fe55..ac694ab 100644
--- a/libs/rs/java/Film/res/raw/filmstrip.c
+++ b/libs/rs/java/Film/res/raw/filmstrip.c
@@ -47,8 +47,8 @@
 
 
     // Start of images.
-    bindProgramFragmentStore(NAMED_PFImages);
-    bindProgramFragment(NAMED_PFSImages);
+    bindProgramFragmentStore(NAMED_PFSImages);
+    bindProgramFragment(NAMED_PFImages);
     bindProgramVertex(NAMED_PVImages);
 
     float focusPos = loadF(1, POS_FOCUS);
@@ -87,7 +87,16 @@
 
         offset = offset + triangleOffsetsCount / 2;
 
-        if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
+    int drawit = 1;
+    if (offset < 0) {
+        drawit = 0;
+    }
+    if (offset >= triangleOffsetsCount) {
+        drawit = 0;
+    }
+
+        //if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
+        if (drawit) {
             int start = offset -2;
             int end = offset + 2;
 
@@ -99,11 +108,9 @@
             }
 
             bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1));
-    /*
-            matrixLoadTranslate(con, &m, -pos - env->triangleOffsetsTex[env->triangleOffsetsCount / 2], 0, 0);
-            storeEnvMatrix(con, 3, RS_PROGRAM_VERTEX_TEXTURE_OFFSET, &m);
-            renderTriangleMeshRange(con, env->mesh, env->triangleOffsets[start], env->triangleOffsets[end] - env->triangleOffsets[start]);
-    */
+            matrixLoadTranslate(&f16, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
+            vpLoadTextureMatrix(&f16);
+            drawTriangleMeshRange(NAMED_mesh, loadI32(4, start), loadI32(4, end) - loadI32(4, start));
         }
     }
     return 0;
diff --git a/libs/rs/java/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java
index 395bd35..a639c55 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -18,10 +18,6 @@
 
 import java.io.Writer;
 
-import android.renderscript.RenderScript;
-import android.renderscript.ProgramVertexAlloc;
-import android.renderscript.Matrix;
-
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
@@ -30,13 +26,17 @@
 import android.graphics.drawable.Drawable;
 import android.os.Handler;
 import android.os.Message;
+import android.renderscript.Matrix;
+import android.renderscript.ProgramVertexAlloc;
+import android.renderscript.RenderScript;
+import android.renderscript.RenderScript.ElementPredefined;
 import android.util.AttributeSet;
 import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
 import android.view.Surface;
 import android.view.SurfaceHolder;
 import android.view.SurfaceView;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
 
 public class FilmRS {
     private final int POS_TRANSLATE = 0;
@@ -67,7 +67,7 @@
         float anim = ((float)x-50) / 270.f;
         mBufferPos[POS_TRANSLATE] = 2f * anim + 0.5f;   // translation
         mBufferPos[POS_ROTATE] = (anim * 40);  // rotation
-        mBufferPos[POS_FOCUS] = ((float)y) / 16.f - 8;  // focusPos
+        mBufferPos[POS_FOCUS] = ((float)y) / 16.f - 10.f;  // focusPos
         mAllocPos.data(mBufferPos);
     }
 
@@ -92,6 +92,9 @@
     private RenderScript.Allocation mAllocPos;
     private RenderScript.Allocation mAllocState;
     private RenderScript.Allocation mAllocPV;
+    private RenderScript.Allocation mAllocOffsetsTex;
+    private RenderScript.Allocation mAllocOffsets;
+
     private RenderScript.TriangleMesh mMesh;
     private RenderScript.Light mLight;
 
@@ -101,21 +104,11 @@
     private float[] mBufferPos = new float[3];
     private int[] mBufferState;
 
-    private void initSamplers() {
-        mRS.samplerBegin();
-        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
-                       RenderScript.SamplerValue.LINEAR_MIP_LINEAR);
-        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_S,
-                       RenderScript.SamplerValue.CLAMP);
-        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_T,
-                       RenderScript.SamplerValue.CLAMP);
-        mSampler = mRS.samplerCreate();
-    }
-
     private void initPFS() {
         mRS.programFragmentStoreBegin(null, null);
         mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.LESS);
         mRS.programFragmentStoreDitherEnable(true);
+        mRS.programFragmentStoreDepthMask(true);
         mPFSBackground = mRS.programFragmentStoreCreate();
         mPFSBackground.setName("PFSBackground");
 
@@ -130,15 +123,27 @@
     }
 
     private void initPF() {
+        mRS.samplerBegin();
+        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN,
+                       RenderScript.SamplerValue.LINEAR);//_MIP_LINEAR);
+        mRS.samplerSet(RenderScript.SamplerParam.FILTER_MAG,
+                       RenderScript.SamplerValue.LINEAR);
+        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_S,
+                       RenderScript.SamplerValue.CLAMP);
+        mRS.samplerSet(RenderScript.SamplerParam.WRAP_MODE_T,
+                       RenderScript.SamplerValue.WRAP);
+        mSampler = mRS.samplerCreate();
+
+
         mRS.programFragmentBegin(null, null);
         mPFBackground = mRS.programFragmentCreate();
         mPFBackground.setName("PFBackground");
 
         mRS.programFragmentBegin(null, null);
         mRS.programFragmentSetTexEnable(0, true);
-        //mRS.programFragmentSetEnvMode(0, RS_TEX_ENV_MODE_REPLACE);
-        //rsProgramFragmentSetType(0, gEnv.tex[0]->getType());
+        mRS.programFragmentSetTexEnvMode(0, RenderScript.EnvMode.REPLACE);
         mPFImages = mRS.programFragmentCreate();
+        mPFImages.bindSampler(mSampler, 0);
         mPFImages.setName("PFImages");
     }
 
@@ -148,12 +153,12 @@
         mLight.setPosition(0, -0.5f, -1.0f);
 
         mRS.programVertexBegin(null, null);
-        mRS.programVertexSetTextureMatrixEnable(true);
         mRS.programVertexAddLight(mLight);
         mPVBackground = mRS.programVertexCreate();
         mPVBackground.setName("PVBackground");
 
         mRS.programVertexBegin(null, null);
+        mRS.programVertexSetTextureMatrixEnable(true);
         mPVImages = mRS.programVertexCreate();
         mPVImages.setName("PVImages");
     }
@@ -170,44 +175,47 @@
         BitmapFactory.Options opts = new BitmapFactory.Options();
         opts.inScaled = false;
 
+        RenderScript.ElementPredefined ie = 
+            RenderScript.ElementPredefined.RGB_565;
+
         b = BitmapFactory.decodeResource(mRes, R.drawable.p01, opts);
-        mImages[0] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[0] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p02, opts);
-        mImages[1] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[1] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p03, opts);
-        mImages[2] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[2] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p04, opts);
-        mImages[3] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[3] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p05, opts);
-        mImages[4] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[4] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p06, opts);
-        mImages[5] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[5] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p07, opts);
-        mImages[6] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[6] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p08, opts);
-        mImages[7] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[7] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p09, opts);
-        mImages[8] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[8] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p10, opts);
-        mImages[9] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[9] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p11, opts);
-        mImages[10] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[10] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p12, opts);
-        mImages[11] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[11] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         b = BitmapFactory.decodeResource(mRes, R.drawable.p13, opts);
-        mImages[12] = mRS.allocationCreateFromBitmapBoxed(b, RenderScript.ElementPredefined.RGB_565, true);
+        mImages[12] = mRS.allocationCreateFromBitmapBoxed(b, ie, true);
 
         for(int ct=0; ct < mImages.length; ct++) {
             mImages[ct].uploadToTexture(1);
@@ -242,10 +250,8 @@
         mMesh.setName("mesh");
 
         initPFS();
-        initSamplers();
         initPF();
         initPV();
-        mPFImages.bindSampler(mSampler, 0);
 
         Log.e("rs", "Done loading named");
 
@@ -274,28 +280,19 @@
         mScriptStrip.bindAllocation(mPVA.mAlloc, 3);
 
 
-/*
-        {
-            Resources res = getResources();
-            Drawable d = res.getDrawable(R.drawable.gadgets_clock_mp3);
-            BitmapDrawable bd = (BitmapDrawable)d;
-            Bitmap b = bd.getBitmap();
-            mTexture = mRS.allocationCreateFromBitmap(b,
-                                                      RenderScript.ElementPredefined.RGB_565,
-                                                      true);
-            mTexture.uploadToTexture(0);
-        }
+        mAllocOffsets = mRS.allocationCreatePredefSized(
+            RenderScript.ElementPredefined.USER_I32,
+            mFSM.mTriangleOffsets.length);
+        mAllocOffsets.data(mFSM.mTriangleOffsets);
+        mScriptStrip.bindAllocation(mAllocOffsets, 4);
 
-        mRS.programFragmentStoreBegin(null, null);
-        mRS.programFragmentStoreBlendFunc(RenderScript.BlendSrcFunc.SRC_ALPHA, RenderScript.BlendDstFunc.ONE);
-        mRS.programFragmentStoreDepthFunc(RenderScript.DepthFunc.ALWAYS);
-        mPFS = mRS.programFragmentStoreCreate();
-        mPFS.setName("MyBlend");
-        mRS.contextBindProgramFragmentStore(mPFS);
-        */
+        mAllocOffsetsTex = mRS.allocationCreatePredefSized(
+            RenderScript.ElementPredefined.USER_FLOAT,
+            mFSM.mTriangleOffsetsTex.length);
+        mAllocOffsetsTex.data(mFSM.mTriangleOffsetsTex);
+        mScriptStrip.bindAllocation(mAllocOffsetsTex, 5);
 
         setFilmStripPosition(0, 0);
-
         mRS.contextBindRootScript(mScriptStrip);
     }
 }
diff --git a/libs/rs/java/Film/src/com/android/film/FilmView.java b/libs/rs/java/Film/src/com/android/film/FilmView.java
index a743b1b..73b7414 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmView.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmView.java
@@ -74,7 +74,7 @@
         if (act == ev.ACTION_UP) {
             ret = false;
         }
-        mRender.setFilmStripPosition((int)ev.getX(), (int)ev.getY());
+        mRender.setFilmStripPosition((int)ev.getX(), (int)ev.getY() / 5);
         return ret;
     }
 }
diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c
index 9e03a44..8763a34 100644
--- a/libs/rs/java/Rollo/res/raw/rollo.c
+++ b/libs/rs/java/Rollo/res/raw/rollo.c
@@ -80,15 +80,15 @@
         float tmpCos = cosf(rot);
             //debugF("rot", rot);
 
-        float tx1 = tmpSin * diam - (tmpCos * scale);
-        float tx2 = tx1 + (tmpCos * scale * 2.f);
-        float tz1 = tmpCos * diam + (tmpSin * scale);
-        float tz2 = tz1 - (tmpSin * scale * 2.f);
+        float tx1 = tmpSin * diam - (tmpCos * scale * 0.9f);
+        float tx2 = tx1 + (tmpCos * scale * 1.8f);
+        float tz1 = tmpCos * diam + (tmpSin * scale * 0.9f);
+        float tz2 = tz1 - (tmpSin * scale * 1.8f);
 
         int y;
         for (y = rowCount -1; (y >= 0) && iconCount; y--) {
             float ty1 = ((y * 3.1f) - 5.f) * scale;
-            float ty2 = ty1 + scale * 2.f;
+            float ty2 = ty1 + scale * 1.8f;
             bindTexture(NAMED_PF, 0, loadI32(1, index));
             //if (done && (index != selectedID)) {
                 //color(0.4f, 0.4f, 0.4f, 1.0f);
diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
index 520e3e4..c080176 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -200,9 +200,6 @@
         mRS.contextBindProgramVertex(mPV);
 
         mAllocScratchBuf = new int[32];
-        for(int ct=0; ct < mAllocScratchBuf.length; ct++) {
-            mAllocScratchBuf[ct] = 0;
-        }
         mAllocScratch = mRS.allocationCreatePredefSized(
             RenderScript.ElementPredefined.USER_I32, mAllocScratchBuf.length);
         mAllocScratch.data(mAllocScratchBuf);
@@ -249,63 +246,63 @@
             mLabels[3] = makeTextBitmap("settings");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.calendar, opts);
-            mIcons[4] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[4] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[4] = makeTextBitmap("creed");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.g1155, opts);
-            mIcons[5] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[5] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[5] = makeTextBitmap("BOA");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.g2140, opts);
-            mIcons[6] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[6] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[6] = makeTextBitmap("chess");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.maps, opts);
-            mIcons[7] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[7] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[7] = makeTextBitmap("Dictionary");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path431, opts);
-            mIcons[8] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[8] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[8] = makeTextBitmap("facebook");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path676, opts);
-            mIcons[9] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[9] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[9] = makeTextBitmap("Flash Light");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path754, opts);
-            mIcons[10] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[10] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[10] = makeTextBitmap("Flight Control");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path815, opts);
-            mIcons[11] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[11] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[11] = makeTextBitmap("google earth");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path1920, opts);
-            mIcons[12] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[12] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[12] = makeTextBitmap("Harry Potter");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path1927, opts);
-            mIcons[13] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[13] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[13] = makeTextBitmap("Movies");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path3099, opts);
-            mIcons[14] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[14] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[14] = makeTextBitmap("NY Times");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path3950, opts);
-            mIcons[15] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[15] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[15] = makeTextBitmap("Pandora");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path4481, opts);
-            mIcons[16] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[16] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[16] = makeTextBitmap("Public Radio");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.path5168, opts);
-            mIcons[17] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[17] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[17] = makeTextBitmap("Public Radio");
 
             b = BitmapFactory.decodeResource(mRes, R.raw.polygon2408, opts);
-            mIcons[18] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGB_565, true);
+            mIcons[18] = mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
             mLabels[18] = makeTextBitmap("Public Radio");
 
             /*
@@ -405,7 +402,6 @@
                 tmp[ct * 32 + 31] = 0;
             }
             mIconPlate.data(tmp);
-            Log.e("xx", "plate");
             mIconPlate.uploadToTexture(0);
             mIconPlate.setName("Plate");
             mPFImages.bindTexture(mIconPlate, 0);
@@ -418,9 +414,9 @@
         Canvas c = new Canvas(b);
         Paint p = new Paint();
         p.setTypeface(Typeface.DEFAULT_BOLD);
-        p.setTextSize(16);
+        p.setTextSize(20);
         p.setColor(0xffffffff);
-        c.drawText(t, 2, 20, p);
+        c.drawText(t, 2, 26, p);
         return mRS.allocationCreateFromBitmap(b, RenderScript.ElementPredefined.RGBA_8888, true);
     }
 
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index c6a9149..ca277ef 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -377,9 +377,9 @@
 
     const uint8_t * src = static_cast<const uint8_t *>(data);
     for (uint32_t y = 0; y < h; y++) {
-        uint8_t * ydst = &tmp[y + ((h2 - h) >> 1)];
+        uint8_t * ydst = &tmp[(y + ((h2 - h) >> 1)) * w2 * bpp];
         memcpy(&ydst[(w2 - w) >> 1], src, w * bpp);
-        src += h * bpp;
+        src += w * bpp;
     }
 
     RsAllocation ret = rsi_AllocationCreateFromBitmap(rsc, w2, h2, dstFmt, srcFmt, genMips, tmp);
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index 41219064..7db3619 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -497,9 +497,9 @@
         "void", "(int, int, int)" },
 
     // vp
-    { "vpLoadModelMatrix", (void *)&SC_bindProgramFragment,
+    { "vpLoadModelMatrix", (void *)&SC_vpLoadModelMatrix,
         "void", "(void *)" },
-    { "vpLoadTextureMatrix", (void *)&SC_bindProgramFragmentStore,
+    { "vpLoadTextureMatrix", (void *)&SC_vpLoadTextureMatrix,
         "void", "(void *)" },
 
 
diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index 21f87e37..f0615f0b 100644
--- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -231,6 +231,9 @@
             LOGW("ro.sf.lcd_density not defined, using 160 dpi by default.");
             strcpy(property, "160");
         }
+    } else {
+        /* for the emulator case, reset the dpi values too */
+        mDpiX = mDpiY = atoi(property);
     }
     mDensity = atoi(property) * (1.0f/160.0f);
 
diff --git a/libs/utils/BackupData.cpp b/libs/utils/BackupData.cpp
index c51d989..0cef35a 100644
--- a/libs/utils/BackupData.cpp
+++ b/libs/utils/BackupData.cpp
@@ -193,6 +193,7 @@
         if ((actual) != (expected)) { \
             if ((actual) == 0) { \
                 m_status = EIO; \
+                m_done = true; \
             } else { \
                 m_status = errno; \
             } \
@@ -222,7 +223,7 @@
 
     amt = skip_padding();
     if (amt == EIO) {
-        *done = true;
+        *done = m_done = true;
         return NO_ERROR;
     }
     else if (amt != NO_ERROR) {
@@ -338,6 +339,10 @@
         m_status = errno;
         return -1;
     }
+    if (amt == 0) {
+        m_status = EIO;
+        m_done = true;
+    }
     m_pos += amt;
     return amt;
 }
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index 7f3f114..445e681 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -149,7 +149,7 @@
             hnd = new driver_t(dso);
         } else {
             // Always load EGL first
-            snprintf(path, PATH_MAX, "lib%s_%s.so", "EGL", tag);
+            snprintf(path, PATH_MAX, format, "EGL", tag);
             dso = load_driver(path, hooks, EGL);
             if (dso) {
                 hnd = new driver_t(dso);
diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java
index 6832862..1b99d32 100755
--- a/packages/TtsService/src/android/tts/TtsService.java
+++ b/packages/TtsService/src/android/tts/TtsService.java
@@ -194,7 +194,7 @@
     private boolean isDefaultEnforced() {
         return (android.provider.Settings.Secure.getInt(mResolver,
                     android.provider.Settings.Secure.TTS_USE_DEFAULTS,
-                    TextToSpeech.Engine.FALLBACK_TTS_USE_DEFAULTS)
+                    TextToSpeech.Engine.USE_DEFAULTS)
                 == 1 );
     }
 
@@ -202,7 +202,7 @@
     private int getDefaultRate() {
         return android.provider.Settings.Secure.getInt(mResolver,
                 android.provider.Settings.Secure.TTS_DEFAULT_RATE,
-                TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_RATE);
+                TextToSpeech.Engine.DEFAULT_RATE);
     }
 
 
@@ -346,7 +346,7 @@
      */
     private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) {
         Log.v("TtsService", "TTS service received " + text);
-        if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
+        if (queueMode == TextToSpeech.QUEUE_FLUSH) {
             stop(callingApp);
         } else if (queueMode == 2) {
             stopAll(callingApp);
@@ -355,7 +355,7 @@
         if (!mIsSpeaking) {
             processSpeechQueue();
         }
-        return TextToSpeech.TTS_SUCCESS;
+        return TextToSpeech.SUCCESS;
     }
 
     /**
@@ -372,7 +372,7 @@
      */
     private int playEarcon(String callingApp, String earcon, int queueMode,
             ArrayList<String> params) {
-        if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
+        if (queueMode == TextToSpeech.QUEUE_FLUSH) {
             stop(callingApp);
         } else if (queueMode == 2) {
             stopAll(callingApp);
@@ -381,14 +381,14 @@
         if (!mIsSpeaking) {
             processSpeechQueue();
         }
-        return TextToSpeech.TTS_SUCCESS;
+        return TextToSpeech.SUCCESS;
     }
 
     /**
      * Stops all speech output and removes any utterances still in the queue for the calling app.
      */
     private int stop(String callingApp) {
-        int result = TextToSpeech.TTS_ERROR;
+        int result = TextToSpeech.ERROR;
         boolean speechQueueAvailable = false;
         try{
             speechQueueAvailable =
@@ -414,7 +414,7 @@
                     mIsSpeaking = false;
                     mCurrentSpeechItem = null;
                 } else {
-                    result = TextToSpeech.TTS_SUCCESS;
+                    result = TextToSpeech.SUCCESS;
                 }
                 Log.i("TtsService", "Stopped");
             }
@@ -437,7 +437,7 @@
      * Stops all speech output and removes any utterances still in the queue globally.
      */
     private int stopAll(String callingApp) {
-        int result = TextToSpeech.TTS_ERROR;
+        int result = TextToSpeech.ERROR;
         boolean speechQueueAvailable = false;
         try{
             speechQueueAvailable =
@@ -463,7 +463,7 @@
                     mIsSpeaking = false;
                     mCurrentSpeechItem = null;
                 } else {
-                    result = TextToSpeech.TTS_SUCCESS;
+                    result = TextToSpeech.SUCCESS;
                 }
                 Log.i("TtsService", "Stopped all");
             }
@@ -487,7 +487,7 @@
         if (params != null){
             for (int i = 0; i < params.size() - 1; i = i + 2){
             String param = params.get(i);
-                if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
+                if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                     utteranceId = params.get(i+1);
                 }
             }
@@ -500,14 +500,14 @@
 
     private int playSilence(String callingApp, long duration, int queueMode,
             ArrayList<String> params) {
-        if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) {
+        if (queueMode == TextToSpeech.QUEUE_FLUSH) {
             stop(callingApp);
         }
         mSpeechQueue.add(new SpeechItem(callingApp, duration, params));
         if (!mIsSpeaking) {
             processSpeechQueue();
         }
-        return TextToSpeech.TTS_SUCCESS;
+        return TextToSpeech.SUCCESS;
     }
 
     private void silence(final SpeechItem speechItem) {
@@ -517,7 +517,7 @@
                 if (speechItem.mParams != null){
                     for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){
                         String param = speechItem.mParams.get(i);
-                        if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
+                        if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                             utteranceId = speechItem.mParams.get(i+1);
                         }
                     }
@@ -562,17 +562,17 @@
                         for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){
                             String param = speechItem.mParams.get(i);
                             if (param != null) {
-                                if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)) {
+                                if (param.equals(TextToSpeech.Engine.KEY_PARAM_RATE)) {
                                     speechRate = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_LANGUAGE)){
                                     language = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_COUNTRY)){
                                     country = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_VARIANT)){
                                     variant = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                                     utteranceId = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_STREAM)) {
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_STREAM)) {
                                     try {
                                         streamType
                                                 = Integer.parseInt(speechItem.mParams.get(i + 1));
@@ -638,15 +638,15 @@
                         for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){
                             String param = speechItem.mParams.get(i);
                             if (param != null) {
-                                if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)) {
+                                if (param.equals(TextToSpeech.Engine.KEY_PARAM_RATE)) {
                                     speechRate = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_LANGUAGE)){
                                     language = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_COUNTRY)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_COUNTRY)){
                                     country = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_VARIANT)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_VARIANT)){
                                     variant = speechItem.mParams.get(i+1);
-                                } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)){
+                                } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID)){
                                     utteranceId = speechItem.mParams.get(i+1);
                                 }
                             }
@@ -698,7 +698,7 @@
     }
 
     private void broadcastTtsQueueProcessingCompleted(){
-        Intent i = new Intent(Intent.ACTION_TTS_QUEUE_PROCESSING_COMPLETED);
+        Intent i = new Intent(TextToSpeech.ACTION_TTS_QUEUE_PROCESSING_COMPLETED);
         sendBroadcast(i);
     }
 
@@ -843,7 +843,7 @@
         }
         for (int i = 0; i < paramList.size() - 1; i = i + 2) {
             String param = paramList.get(i);
-            if ((param != null) && (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_STREAM))) {
+            if ((param != null) && (param.equals(TextToSpeech.Engine.KEY_PARAM_STREAM))) {
                 try {
                     streamType = Integer.parseInt(paramList.get(i + 1));
                 } catch (NumberFormatException e) {
@@ -910,18 +910,18 @@
             if (cb != null) {
                 mCallbacks.register(cb);
                 mCallbacksMap.put(packageName, cb);
-                return TextToSpeech.TTS_SUCCESS;
+                return TextToSpeech.SUCCESS;
             }
-            return TextToSpeech.TTS_ERROR;
+            return TextToSpeech.ERROR;
         }
 
         public int unregisterCallback(String packageName, ITtsCallback cb) {
             if (cb != null) {
                 mCallbacksMap.remove(packageName);
                 mCallbacks.unregister(cb);
-                return TextToSpeech.TTS_SUCCESS;
+                return TextToSpeech.SUCCESS;
             }
-            return TextToSpeech.TTS_ERROR;
+            return TextToSpeech.ERROR;
         }
 
         /**
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index a8e5f8b..67f3816 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -803,7 +803,7 @@
 
     class ClearDataObserver extends IPackageDataObserver.Stub {
         public void onRemoveCompleted(String packageName, boolean succeeded)
-                throws android.os.RemoteException {
+                throws RemoteException {
             synchronized(mClearDataLock) {
                 mClearingData = false;
                 mClearDataLock.notifyAll();
@@ -1666,58 +1666,66 @@
         }
 
         // --- Binder interface ---
-        public RestoreSet[] getAvailableRestoreSets() throws android.os.RemoteException {
+        public synchronized RestoreSet[] getAvailableRestoreSets() {
             mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
                     "getAvailableRestoreSets");
 
             try {
-            synchronized(this) {
                 if (mRestoreTransport == null) {
                     Log.w(TAG, "Null transport getting restore sets");
-                } else if (mRestoreSets == null) { // valid transport; do the one-time fetch
+                    return null;
+                }
+                if (mRestoreSets == null) { // valid transport; do the one-time fetch
                     mRestoreSets = mRestoreTransport.getAvailableRestoreSets();
                     if (mRestoreSets == null) EventLog.writeEvent(RESTORE_TRANSPORT_FAILURE_EVENT);
                 }
                 return mRestoreSets;
-            }
-            } catch (RuntimeException e) {
-                Log.d(TAG, "getAvailableRestoreSets exception");
-                e.printStackTrace();
-                throw e;
+            } catch (Exception e) {
+                Log.e(TAG, "Error in getAvailableRestoreSets", e);
+                return null;
             }
         }
 
-        public int performRestore(long token, IRestoreObserver observer)
-                throws android.os.RemoteException {
-            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP, "performRestore");
+        public synchronized int performRestore(long token, IRestoreObserver observer) {
+            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
+                    "performRestore");
 
-            Log.d(TAG, "performRestore token=" + token + " observer=" + observer);
+            if (DEBUG) Log.d(TAG, "performRestore token=" + token + " observer=" + observer);
 
-            if (mRestoreSets != null) {
-                for (int i = 0; i < mRestoreSets.length; i++) {
-                    if (token == mRestoreSets[i].token) {
-                        mWakelock.acquire();
-                        Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
-                        msg.obj = new RestoreParams(mRestoreTransport, observer, token);
-                        mBackupHandler.sendMessage(msg);
-                        return 0;
-                    }
+            if (mRestoreTransport == null || mRestoreSets == null) {
+                Log.e(TAG, "Ignoring performRestore() with no restore set");
+                return -1;
+            }
+
+            for (int i = 0; i < mRestoreSets.length; i++) {
+                if (token == mRestoreSets[i].token) {
+                    mWakelock.acquire();
+                    Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
+                    msg.obj = new RestoreParams(mRestoreTransport, observer, token);
+                    mBackupHandler.sendMessage(msg);
+                    return 0;
                 }
-            } else {
-                if (DEBUG) Log.v(TAG, "No current restore set, not doing restore");
             }
             return -1;
         }
 
-        public void endRestoreSession() throws android.os.RemoteException {
+        public synchronized void endRestoreSession() {
             mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
                     "endRestoreSession");
 
-            Log.d(TAG, "endRestoreSession");
+            if (DEBUG) Log.d(TAG, "endRestoreSession");
 
-            mRestoreTransport.finishRestore();
-            mRestoreTransport = null;
-            synchronized(BackupManagerService.this) {
+            synchronized (this) {
+                try {
+                    if (mRestoreTransport != null) mRestoreTransport.finishRestore();
+                } catch (Exception e) {
+                    Log.e(TAG, "Error in finishRestore", e);
+                } finally {
+                    mRestoreTransport = null;
+                }
+            }
+
+            synchronized (BackupManagerService.this) {
                 if (BackupManagerService.this.mActiveRestoreSession == this) {
                     BackupManagerService.this.mActiveRestoreSession = null;
                 } else {
diff --git a/services/java/com/android/server/JournaledFile.java b/services/java/com/android/server/JournaledFile.java
new file mode 100644
index 0000000..3d1f52d
--- /dev/null
+++ b/services/java/com/android/server/JournaledFile.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 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 com.android.server;
+
+import java.io.File;
+import java.io.IOException;
+
+public class JournaledFile {
+    File mReal;
+    File mTemp;
+    boolean mWriting;
+
+    public JournaledFile(File real, File temp) {
+        mReal = real;
+        mTemp = temp;
+    }
+
+    /** Returns the file for you to read.
+     * @more
+     * Prefers the real file.  If it doesn't exist, uses the temp one, and then copies
+     * it to the real one.  If there is both a real file and a temp one, assumes that the
+     * temp one isn't fully written and deletes it.
+     */
+    public File chooseForRead() {
+        File result;
+        if (mReal.exists()) {
+            result = mReal;
+            if (mTemp.exists()) {
+                mTemp.delete();
+            }
+        } else if (mTemp.exists()) {
+            result = mTemp;
+            mTemp.renameTo(mReal);
+        } else {
+            return mReal;
+        }
+        return result;
+    }
+
+    /**
+     * Returns a file for you to write.
+     * @more
+     * If a write is already happening, throws.  In other words, you must provide your
+     * own locking.
+     * <p>
+     * Call {@link #commit} to commit the changes, or {@link #rollback} to forget the changes.
+     */
+    public File chooseForWrite() {
+        if (mWriting) {
+            throw new IllegalStateException("uncommitted write already in progress");
+        }
+        if (!mReal.exists()) {
+            // If the real one doesn't exist, it's either because this is the first time
+            // or because something went wrong while copying them.  In this case, we can't
+            // trust anything that's in temp.  In order to have the chooseForRead code not
+            // use the temporary one until it's fully written, create an empty file
+            // for real, which will we'll shortly delete.
+            try {
+                mReal.createNewFile();
+            } catch (IOException e) {
+                // Ignore
+            }
+        }
+
+        if (mTemp.exists()) {
+            mTemp.delete();
+        }
+        mWriting = true;
+        return mTemp;
+    }
+
+    /**
+     * Commit changes.
+     */
+    public void commit() {
+        if (!mWriting) {
+            throw new IllegalStateException("no file to commit");
+        }
+        mWriting = false;
+        mTemp.renameTo(mReal);
+    }
+
+    /**
+     * Roll back changes.
+     */
+    public void rollback() {
+        if (!mWriting) {
+            throw new IllegalStateException("no file to roll back");
+        }
+        mWriting = false;
+        mTemp.delete();
+    }
+}
diff --git a/services/java/com/android/server/SystemBackupAgent.java b/services/java/com/android/server/SystemBackupAgent.java
new file mode 100644
index 0000000..b681961
--- /dev/null
+++ b/services/java/com/android/server/SystemBackupAgent.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 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 com.android.server;
+
+import android.backup.AbsoluteFileBackupHelper;
+import android.backup.BackupDataInput;
+import android.backup.BackupDataInputStream;
+import android.backup.BackupDataOutput;
+import android.backup.BackupHelper;
+import android.backup.BackupHelperAgent;
+import android.content.Context;
+import android.os.ParcelFileDescriptor;
+import android.os.ServiceManager;
+import android.os.SystemService;
+import android.util.Log;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Backup agent for various system-managed data
+ */
+public class SystemBackupAgent extends BackupHelperAgent {
+    private static final String TAG = "SystemBackupAgent";
+
+    private static final String WALLPAPER_IMAGE = "/data/data/com.android.settings/files/wallpaper";
+    private static final String WALLPAPER_INFO = "/data/system/wallpaper_info.xml";
+
+    @Override
+    public void onCreate() {
+        addHelper("wallpaper", new AbsoluteFileBackupHelper(SystemBackupAgent.this,
+                new String[] { WALLPAPER_IMAGE, WALLPAPER_INFO }));
+    }
+
+    @Override
+    public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
+            throws IOException {
+        boolean success = false;
+        try {
+            super.onRestore(data, appVersionCode, newState);
+
+            WallpaperService wallpaper = (WallpaperService)ServiceManager.getService(
+                    Context.WALLPAPER_SERVICE);
+            wallpaper.settingsRestored();
+        } catch (IOException ex) {
+            // If there was a failure, delete everything for the wallpaper, this is too aggresive,
+            // but this is hopefully a rare failure.
+            Log.d(TAG, "restore failed", ex);
+            (new File(WALLPAPER_IMAGE)).delete();
+            (new File(WALLPAPER_INFO)).delete();
+        }
+    }
+}
diff --git a/services/java/com/android/server/WallpaperService.java b/services/java/com/android/server/WallpaperService.java
index d921baf..67b60a6 100644
--- a/services/java/com/android/server/WallpaperService.java
+++ b/services/java/com/android/server/WallpaperService.java
@@ -24,8 +24,9 @@
 import android.backup.BackupManager;
 import android.content.Context;
 import android.content.Intent;
-import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
 import android.os.Binder;
 import android.os.RemoteException;
 import android.os.FileObserver;
@@ -33,30 +34,38 @@
 import android.os.RemoteCallbackList;
 import android.util.Config;
 import android.util.Log;
+import android.util.Xml;
 
+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 org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
+
+import com.android.internal.util.FastXmlSerializer;
 
 class WallpaperService extends IWallpaperService.Stub {
-    private static final String TAG = WallpaperService.class.getSimpleName();     
+    private static final String TAG = "WallpaperService";
+
+    private Object mLock = new Object();
 
     private static final File WALLPAPER_DIR = new File(
             "/data/data/com.android.settings/files");
     private static final String WALLPAPER = "wallpaper";
     private static final File WALLPAPER_FILE = new File(WALLPAPER_DIR, WALLPAPER);
 
-    private static final String PREFERENCES = "wallpaper-hints";
-
-    private static final String HINT_WIDTH = "hintWidth";
-    private static final String HINT_HEIGHT = "hintHeight";
-
     /**
      * List of callbacks registered they should each be notified
      * when the wallpaper is changed.
      */
     private final RemoteCallbackList<IWallpaperServiceCallback> mCallbacks
             = new RemoteCallbackList<IWallpaperServiceCallback>();
-    
+
     /**
      * Observes the wallpaper for changes and notifies all IWallpaperServiceCallbacks
      * that the wallpaper has changed. The CREATE is triggered when there is no
@@ -64,16 +73,23 @@
      * everytime the wallpaper is changed.
      */
     private final FileObserver mWallpaperObserver = new FileObserver(
-            WALLPAPER_DIR.getAbsolutePath(), CREATE | CLOSE_WRITE) {
+            WALLPAPER_DIR.getAbsolutePath(), CREATE | CLOSE_WRITE | DELETE | DELETE_SELF) {
                 @Override
                 public void onEvent(int event, String path) {
                     if (path == null) {
                         return;
                     }
+                    synchronized (mLock) {
+                        // changing the wallpaper means we'll need to back up the new one
+                        long origId = Binder.clearCallingIdentity();
+                        BackupManager bm = new BackupManager(mContext);
+                        bm.dataChanged();
+                        Binder.restoreCallingIdentity(origId);
 
-                    File changedFile = new File(WALLPAPER_DIR, path);
-                    if (WALLPAPER_FILE.equals(changedFile)) {
-                        notifyCallbacks();
+                        File changedFile = new File(WALLPAPER_DIR, path);
+                        if (WALLPAPER_FILE.equals(changedFile)) {
+                            notifyCallbacksLocked();
+                        }
                     }
                 }
             };
@@ -82,17 +98,14 @@
 
     private int mWidth = -1;
     private int mHeight = -1;
+    private String mName = "";
 
     public WallpaperService(Context context) {
         if (Config.LOGD) Log.d(TAG, "WallpaperService startup");
         mContext = context;
-        createFilesDir();
+        WALLPAPER_DIR.mkdirs();
+        loadSettingsLocked();
         mWallpaperObserver.startWatching();
-
-        SharedPreferences preferences = mContext.getSharedPreferences(PREFERENCES,
-                    Context.MODE_PRIVATE);
-        mWidth = preferences.getInt(HINT_WIDTH, -1);
-        mHeight = preferences.getInt(HINT_HEIGHT, -1);
     }
     
     @Override
@@ -102,9 +115,11 @@
     }
     
     public void clearWallpaper() {
-        File f = WALLPAPER_FILE;
-        if (f.exists()) {
-            f.delete();
+        synchronized (mLock) {
+            File f = WALLPAPER_FILE;
+            if (f.exists()) {
+                f.delete();
+            }
         }
     }
 
@@ -115,70 +130,62 @@
             throw new IllegalArgumentException("width and height must be > 0");
         }
 
-        if (width != mWidth || height != mHeight) {
-            mWidth = width;
-            mHeight = height;
-
-            SharedPreferences preferences = mContext.getSharedPreferences(PREFERENCES,
-                    Context.MODE_PRIVATE);
-
-            final SharedPreferences.Editor editor = preferences.edit();
-            editor.putInt(HINT_WIDTH, width);
-            editor.putInt(HINT_HEIGHT, height);
-            editor.commit();
+        synchronized (mLock) {
+            if (width != mWidth || height != mHeight) {
+                mWidth = width;
+                mHeight = height;
+                saveSettingsLocked();
+            }
         }
     }
 
     public int getWidthHint() throws RemoteException {
-        return mWidth;
+        synchronized (mLock) {
+            return mWidth;
+        }
     }
 
     public int getHeightHint() throws RemoteException {
-        return mHeight;
+        synchronized (mLock) {
+            return mHeight;
+        }
     }
 
     public ParcelFileDescriptor getWallpaper(IWallpaperServiceCallback cb) {
-        try {
-            mCallbacks.register(cb);
-            File f = WALLPAPER_FILE;
-            if (!f.exists()) {
-                return null;
+        synchronized (mLock) {
+            try {
+                mCallbacks.register(cb);
+                File f = WALLPAPER_FILE;
+                if (!f.exists()) {
+                    return null;
+                }
+                return ParcelFileDescriptor.open(f, MODE_READ_ONLY);
+            } catch (FileNotFoundException e) {
+                /* Shouldn't happen as we check to see if the file exists */
+                if (Config.LOGD) Log.d(TAG, "Error getting wallpaper", e);
             }
-            return ParcelFileDescriptor.open(f, MODE_READ_ONLY);
-        } catch (FileNotFoundException e) {
-            
-            /* Shouldn't happen as we check to see if the file exists */
-            if (Config.LOGD) Log.d(TAG, "Error getting wallpaper", e);
+            return null;
         }
-        return null;
     }
 
-    public ParcelFileDescriptor setWallpaper() {
+    public ParcelFileDescriptor setWallpaper(String name) {
         checkPermission(android.Manifest.permission.SET_WALLPAPER);
-        try {
-            ParcelFileDescriptor fd = ParcelFileDescriptor.open(WALLPAPER_FILE,
-                    MODE_CREATE|MODE_READ_WRITE);
-
-            // changing the wallpaper means we'll need to back up the new one
-            long origId = Binder.clearCallingIdentity();
-            BackupManager bm = new BackupManager(mContext);
-            bm.dataChanged();
-            Binder.restoreCallingIdentity(origId);
-
-            return fd;
-        } catch (FileNotFoundException e) {
-            if (Config.LOGD) Log.d(TAG, "Error setting wallpaper", e);
-        }
-        return null;
-    }
-
-    private void createFilesDir() {
-        if (!WALLPAPER_DIR.exists()) {
-            WALLPAPER_DIR.mkdirs();
+        synchronized (mLock) {
+            if (name == null) name = "";
+            mName = name;
+            saveSettingsLocked();
+            try {
+                ParcelFileDescriptor fd = ParcelFileDescriptor.open(WALLPAPER_FILE,
+                        MODE_CREATE|MODE_READ_WRITE);
+                return fd;
+            } catch (FileNotFoundException e) {
+                if (Config.LOGD) Log.d(TAG, "Error setting wallpaper", e);
+            }
+            return null;
         }
     }
 
-    private void notifyCallbacks() {
+    private void notifyCallbacksLocked() {
         final int n = mCallbacks.beginBroadcast();
         for (int i = 0; i < n; i++) {
             try {
@@ -195,9 +202,185 @@
     }
 
     private void checkPermission(String permission) {
-        if (PackageManager.PERMISSION_GRANTED != mContext.checkCallingOrSelfPermission(permission)) {
+        if (PackageManager.PERMISSION_GRANTED!= mContext.checkCallingOrSelfPermission(permission)) {
             throw new SecurityException("Access denied to process: " + Binder.getCallingPid()
                     + ", must have permission " + permission);
         }
     }
+
+    private static JournaledFile makeJournaledFile() {
+        final String base = "/data/system/wallpaper_info.xml";
+        return new JournaledFile(new File(base), new File(base + ".tmp"));
+    }
+
+    private void saveSettingsLocked() {
+        JournaledFile journal = makeJournaledFile();
+        FileOutputStream stream = null;
+        try {
+            stream = new FileOutputStream(journal.chooseForWrite(), false);
+            XmlSerializer out = new FastXmlSerializer();
+            out.setOutput(stream, "utf-8");
+            out.startDocument(null, true);
+
+            out.startTag(null, "wp");
+            out.attribute(null, "width", Integer.toString(mWidth));
+            out.attribute(null, "height", Integer.toString(mHeight));
+            out.attribute(null, "name", mName);
+            out.endTag(null, "wp");
+
+            out.endDocument();
+            stream.close();
+            journal.commit();
+        } catch (IOException e) {
+            try {
+                if (stream != null) {
+                    stream.close();
+                }
+            } catch (IOException ex) {
+                // Ignore
+            }
+            journal.rollback();
+        }
+    }
+
+    private void loadSettingsLocked() {
+        JournaledFile journal = makeJournaledFile();
+        FileInputStream stream = null;
+        File file = journal.chooseForRead();
+        boolean success = false;
+        try {
+            stream = new FileInputStream(file);
+            XmlPullParser parser = Xml.newPullParser();
+            parser.setInput(stream, null);
+
+            int type;
+            int providerIndex = 0;
+            do {
+                type = parser.next();
+                if (type == XmlPullParser.START_TAG) {
+                    String tag = parser.getName();
+                    if ("wp".equals(tag)) {
+                        mWidth = Integer.parseInt(parser.getAttributeValue(null, "width"));
+                        mHeight = Integer.parseInt(parser.getAttributeValue(null, "height"));
+                        mName = parser.getAttributeValue(null, "name");
+                    }
+                }
+            } while (type != XmlPullParser.END_DOCUMENT);
+            success = true;
+        } catch (NullPointerException e) {
+            Log.w(TAG, "failed parsing " + file + " " + e);
+        } catch (NumberFormatException e) {
+            Log.w(TAG, "failed parsing " + file + " " + e);
+        } catch (XmlPullParserException e) {
+            Log.w(TAG, "failed parsing " + file + " " + e);
+        } catch (IOException e) {
+            Log.w(TAG, "failed parsing " + file + " " + e);
+        } catch (IndexOutOfBoundsException e) {
+            Log.w(TAG, "failed parsing " + file + " " + e);
+        }
+        try {
+            if (stream != null) {
+                stream.close();
+            }
+        } catch (IOException e) {
+            // Ignore
+        }
+
+        if (!success) {
+            mWidth = -1;
+            mHeight = -1;
+            mName = "";
+        }
+    }
+
+    void settingsRestored() {
+        boolean success = false;
+        synchronized (mLock) {
+            loadSettingsLocked();
+            // If there's a wallpaper name, we use that.  If that can't be loaded, then we
+            // use the default.
+            if ("".equals(mName)) {
+                success = true;
+            } else {
+                success = restoreNamedResourceLocked();
+            }
+        }
+
+        if (!success) {
+            Log.e(TAG, "Failed to restore wallpaper: '" + mName + "'");
+            mName = "";
+            WALLPAPER_FILE.delete();
+        }
+        saveSettingsLocked();
+    }
+
+    boolean restoreNamedResourceLocked() {
+        if (mName.length() > 4 && "res:".equals(mName.substring(0, 4))) {
+            String resName = mName.substring(4);
+
+            String pkg = null;
+            int colon = resName.indexOf(':');
+            if (colon > 0) {
+                pkg = resName.substring(0, colon);
+            }
+
+            String ident = null;
+            int slash = resName.lastIndexOf('/');
+            if (slash > 0) {
+                ident = resName.substring(slash+1);
+            }
+
+            String type = null;
+            if (colon > 0 && slash > 0 && (slash-colon) > 1) {
+                type = resName.substring(colon+1, slash);
+            }
+
+            if (pkg != null && ident != null && type != null) {
+                int resId = -1;
+                InputStream res = null;
+                FileOutputStream fos = null;
+                try {
+                    Context c = mContext.createPackageContext(pkg, Context.CONTEXT_RESTRICTED);
+                    Resources r = c.getResources();
+                    resId = r.getIdentifier(resName, null, null);
+                    if (resId == 0) {
+                        Log.e(TAG, "couldn't resolve identifier pkg=" + pkg + " type=" + type
+                                + " ident=" + ident);
+                        return false;
+                    }
+
+                    res = r.openRawResource(resId);
+                    fos = new FileOutputStream(WALLPAPER_FILE);
+
+                    byte[] buffer = new byte[32768];
+                    int amt;
+                    while ((amt=res.read(buffer)) > 0) {
+                        fos.write(buffer, 0, amt);
+                    }
+                    // mWallpaperObserver will notice the close and send the change broadcast
+
+                    Log.d(TAG, "Restored wallpaper: " + resName);
+                    return true;
+                } catch (NameNotFoundException e) {
+                    Log.e(TAG, "Package name " + pkg + " not found");
+                } catch (Resources.NotFoundException e) {
+                    Log.e(TAG, "Resource not found: " + resId);
+                } catch (IOException e) {
+                    Log.e(TAG, "IOException while restoring wallpaper ", e);
+                } finally {
+                    if (res != null) {
+                        try {
+                            res.close();
+                        } catch (IOException ex) {}
+                    }
+                    if (fos != null) {
+                        try {
+                            fos.close();
+                        } catch (IOException ex) {}
+                    }
+                }
+            }
+        }
+        return false;
+    }
 }
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 7bd2532..552d5be 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -4766,6 +4766,34 @@
         }
     }
 
+    public void closeSystemDialogs(String reason) {
+        Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+        if (reason != null) {
+            intent.putExtra("reason", reason);
+        }
+        
+        final int uid = Binder.getCallingUid();
+        final long origId = Binder.clearCallingIdentity();
+        synchronized (this) {
+            int i = mWatchers.beginBroadcast();
+            while (i > 0) {
+                i--;
+                IActivityWatcher w = mWatchers.getBroadcastItem(i);
+                if (w != null) {
+                    try {
+                        w.closingSystemDialogs(reason);
+                    } catch (RemoteException e) {
+                    }
+                }
+            }
+            mWatchers.finishBroadcast();
+            
+            broadcastIntentLocked(null, null, intent, null,
+                    null, 0, null, null, null, false, false, -1, uid);
+        }
+        Binder.restoreCallingIdentity(origId);
+    }
+    
     private void restartPackageLocked(final String packageName, int uid) {
         uninstallPackageLocked(packageName, uid, false);
         Intent intent = new Intent(Intent.ACTION_PACKAGE_RESTARTED,
diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java
index 33e793b..5aed396 100644
--- a/services/java/com/android/server/status/StatusBarPolicy.java
+++ b/services/java/com/android/server/status/StatusBarPolicy.java
@@ -926,17 +926,16 @@
             // Use Evdo icon
             evdoIconList = this.sSignalImages_evdo;
 
-            int evdoEcio = mSignalStrength.getEvdoEcio();
+            int evdoDbm = mSignalStrength.getEvdoDbm();
             int evdoSnr = mSignalStrength.getEvdoSnr();
-            int levelEvdoEcio = 0;
+            int levelEvdoDbm = 0;
             int levelEvdoSnr = 0;
 
-            // Ec/Io are in dB*10
-            if (evdoEcio >= -650) levelEvdoEcio = 4;
-            else if (evdoEcio >= -750) levelEvdoEcio = 3;
-            else if (evdoEcio >= -900) levelEvdoEcio = 2;
-            else if (evdoEcio >= -1050) levelEvdoEcio = 1;
-            else levelEvdoEcio = 0;
+            if (evdoDbm >= -65) levelEvdoDbm = 4;
+            else if (evdoDbm >= -75) levelEvdoDbm = 3;
+            else if (evdoDbm >= -90) levelEvdoDbm = 2;
+            else if (evdoDbm >= -105) levelEvdoDbm = 1;
+            else levelEvdoDbm = 0;
 
             if (evdoSnr > 7) levelEvdoSnr = 4;
             else if (evdoSnr > 5) levelEvdoSnr = 3;
@@ -944,7 +943,7 @@
             else if (evdoSnr > 1) levelEvdoSnr = 1;
             else levelEvdoSnr = 0;
 
-            evdoIconLevel = (levelEvdoEcio < levelEvdoSnr) ? levelEvdoEcio : levelEvdoSnr;
+            evdoIconLevel = (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr;
 
             mPhoneEvdoData.iconId = evdoIconList[evdoIconLevel];
             mService.updateIcon(mPhoneEvdoIcon, mPhoneEvdoData, null);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index ba5c6e7..ed9af66 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -256,7 +256,7 @@
      * No phone module
      *
      */
-    public static final int PHONE_TYPE_NONE = 0;
+    public static final int PHONE_TYPE_NONE = RILConstants.NO_PHONE;
 
     /**
      * GSM phone
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 7834018..1f4ce3d 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -68,8 +68,9 @@
     int CDMA_CELL_BROADCAST_SMS_DISABLED = 1;
     int CDMA_CELL_BROADCAST_SMS_ENABLED  = 0;
 
-    int CDMA_PHONE = 0;
+    int NO_PHONE = 0;
     int GSM_PHONE = 1;
+    int CDMA_PHONE = 2;
 
     int CDM_TTY_MODE_DISABLED = 0;
     int CDM_TTY_MODE_ENABLED = 1;
diff --git a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
index 8e76cd2..46b39a5 100644
--- a/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/ServiceStateTracker.java
@@ -77,7 +77,6 @@
     // waiting period before recheck gprs and voice registration
     public static final int DEFAULT_GPRS_CHECK_PERIOD_MILLIS = 60 * 1000;
 
-    public static final int MAX_NUM_DATA_STATE_READS = 15;
     public static final int DATA_STATE_POLL_SLEEP_MS = 100;
 
     //*****GSM events
diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
index dda0187..28ce6a5 100755
--- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -777,6 +777,9 @@
             Intent intent = new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS);
             ActivityManagerNative.broadcastStickyIntent(intent, null);
             return false;
+        } else if ((mCT.state == Phone.State.OFFHOOK) && mCT.isInEmergencyCall()) {
+            // Do not allow data call to be enabled when emergency call is going on
+            return false;
         } else {
             return mDataConnection.setDataEnabled(true);
         }
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
index 7788c75..84d6b3d 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaCallTracker.java
@@ -80,6 +80,7 @@
     int pendingCallClirMode;
     Phone.State state = Phone.State.IDLE;
 
+    private boolean mIsInEmergencyCall = false;
 
 //    boolean needsPoll;
 
@@ -210,6 +211,9 @@
             // Always unmute when initiating a new call
             setMute(false);
 
+            // Check data call
+            disableDataCallInEmergencyCall(dialString);
+
             String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false");
             if(inEcm.equals("false")) {
                 cm.dial(pendingMO.address, clirMode, obtainCompleteMessage());
@@ -236,6 +240,9 @@
     private Connection
     dialThreeWay (String dialString) {
         if (!foregroundCall.isIdle()) {
+            // Check data call
+            disableDataCallInEmergencyCall(dialString);
+
             // Attach the new connection to foregroundCall
             pendingMO = new CdmaConnection(phone.getContext(),
                                 dialString, this, foregroundCall);
@@ -529,6 +536,9 @@
                     }
                 }
                 foregroundCall.setGeneric(false);
+
+                mIsInEmergencyCall = false;
+
                 // Dropped connections are removed from the CallTracker
                 // list but kept in the Call list
                 connections[i] = null;
@@ -967,6 +977,26 @@
         }
     }
 
+    /**
+     * Disable data call when emergency call is connected
+     */
+    private void disableDataCallInEmergencyCall(String dialString) {
+        if (PhoneNumberUtils.isEmergencyNumber(dialString)) {
+            phone.disableDataConnectivity();
+            mIsInEmergencyCall = true;
+        }
+    }
+
+    /**
+     * Check if current call is in emergency call
+     *
+     * @return true if it is in emergency call
+     *         false if it is not in emergency call
+     */
+    boolean isInEmergencyCall() {
+        return mIsInEmergencyCall;
+    }
+
     protected void log(String msg) {
         Log.d(LOG_TAG, "[CdmaCallTracker] " + msg);
     }
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
index c4db609..3ab1f77 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
@@ -88,7 +88,7 @@
         int teleService = sms.getTeleService();
         boolean handled = false;
 
-        if (sms.getUserData() == null) {
+        if ((sms.getUserData() == null) && (SmsEnvelope.TELESERVICE_MWI != teleService)) {
             if (Config.LOGD) {
                 Log.d(TAG, "Received SMS without user data");
             }
@@ -99,10 +99,11 @@
             return Intents.RESULT_SMS_HANDLED;
         }
 
-        if (SmsEnvelope.TELESERVICE_WAP == teleService){
+        if (SmsEnvelope.TELESERVICE_WAP == teleService) {
             return processCdmaWapPdu(sms.getUserData(), sms.messageRef,
                     sms.getOriginatingAddress());
-        } else if (SmsEnvelope.TELESERVICE_VMN == teleService) {
+        } else if ((SmsEnvelope.TELESERVICE_VMN == teleService) ||
+                   (SmsEnvelope.TELESERVICE_MWI == teleService)) {
             // handling Voicemail
             int voicemailCount = sms.getNumOfVoicemails();
             Log.d(TAG, "Voicemail count=" + voicemailCount);
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
index d5da666..6356473 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
@@ -504,9 +504,10 @@
             msg.obj = CDMAPhone.REASON_RADIO_TURNED_OFF;
             dcTracker.sendMessage(msg);
 
-            // Poll data state up to 15 times, with a 100ms delay
-            // totaling 1.5 sec. Normal data disable action will finish in 100ms.
-            for (int i = 0; i < MAX_NUM_DATA_STATE_READS; i++) {
+            // Poll data state up to 50 times, with a 100ms delay
+            // totaling 5 sec.
+            // TODO: change the 5 seconds wait from blocking to non-blocking.
+            for (int i = 0; i < 50; i++) {
                 DataConnectionTracker.State currentState = dcTracker.getState();
                 if (currentState != DataConnectionTracker.State.CONNECTED
                         && currentState != DataConnectionTracker.State.DISCONNECTING) {
@@ -1073,7 +1074,7 @@
 
     /**
      *  send signal-strength-changed notification if changed
-     *  Called both for solicited and unsolicited signal stength updates
+     *  Called both for solicited and unsolicited signal strength updates
      */
     private void
     onSignalStrengthResult(AsyncResult ar) {
@@ -1086,15 +1087,15 @@
             int[] ints = (int[])ar.result;
             int offset = 2;
 
-            int cdmaDbm = (ints[offset] > 0) ? -ints[offset] : -1;
-            int cdmaEcio = (ints[offset+1] > 0) ? -ints[offset+1] : -1;
+            int cdmaDbm = (ints[offset] > 0) ? -ints[offset] : -120;
+            int cdmaEcio = (ints[offset+1] > 0) ? -ints[offset+1] : -160;
 
             int evdoRssi = -1;
             int evdoEcio = -1;
             int evdoSnr = -1;
             if ((networkType == ServiceState.RADIO_TECHNOLOGY_EVDO_0)
                     || (networkType == ServiceState.RADIO_TECHNOLOGY_EVDO_A)) {
-                evdoRssi = (ints[offset+2] > 0) ? -ints[offset+2] : -1;
+                evdoRssi = (ints[offset+2] > 0) ? -ints[offset+2] : -120;
                 evdoEcio = (ints[offset+3] > 0) ? -ints[offset+3] : -1;
                 evdoSnr  = ((ints[offset+4] > 0) && (ints[offset+4] <= 8)) ? ints[offset+4] : -1;
             }
diff --git a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
index 30adc52..9c04305 100755
--- a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
+++ b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java
@@ -527,6 +527,19 @@
      * Parses a SMS message from its BearerData stream. (mobile-terminated only)
      */
     protected void parseSms() {
+        // Message Waiting Info Record defined in 3GPP2 C.S-0005, 3.7.5.6
+        // It contains only an 8-bit number with the number of messages waiting
+        if (mEnvelope.teleService == SmsEnvelope.TELESERVICE_MWI) {
+            mBearerData = new BearerData();
+            if (mEnvelope.bearerData != null) {
+                mBearerData.numberOfMessages = 0x000000FF & mEnvelope.bearerData[0];
+            }
+            if (Config.DEBUG) {
+                Log.d(LOG_TAG, "parseSms: get MWI " +
+                      Integer.toString(mBearerData.numberOfMessages));
+            }
+            return;
+        }
         mBearerData = BearerData.decode(mEnvelope.bearerData);
         messageRef = mBearerData.messageId;
         if (mBearerData.userData != null) {
diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java b/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java
index f80e8c0..0dcacc1 100644
--- a/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java
+++ b/telephony/java/com/android/internal/telephony/cdma/sms/SmsEnvelope.java
@@ -36,6 +36,14 @@
     static public final int TELESERVICE_WAP               = 0x1004;
     static public final int TELESERVICE_WEMT              = 0x1005;
 
+    /**
+     * The following are defined as extensions to the standard teleservices
+     */
+    // Voice mail notification through Message Waiting Indication in CDMA mode or Analog mode.
+    // Defined in 3GPP2 C.S-0005, 3.7.5.6, an Info Record containing an 8-bit number with the
+    // number of messages waiting, it's used by some CDMA carriers for a voice mail count.
+    static public final int TELESERVICE_MWI               = 0x40000;
+
     // ServiceCategories for Cell Broadcast, see 3GPP2 C.R1001 table 9.3.1-1
     //static public final int SERVICECATEGORY_EMERGENCY      = 0x0010;
     //...
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
index b3b4345..4178115 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
@@ -151,6 +151,8 @@
     static final int PS_NOTIFICATION = 888; //id to update and cancel PS restricted
     static final int CS_NOTIFICATION = 999; //id to update and cancel CS restricted
 
+    static final int MAX_NUM_DATA_STATE_READS = 15;
+
     private ContentObserver mAutoTimeObserver = new ContentObserver(new Handler()) {
         @Override
         public void onChange(boolean selfChange) {
diff --git a/tests/CoreTests/android/core/CryptoTest.java b/tests/CoreTests/android/core/CryptoTest.java
index f00d49f..e6e50ec 100644
--- a/tests/CoreTests/android/core/CryptoTest.java
+++ b/tests/CoreTests/android/core/CryptoTest.java
@@ -22,7 +22,6 @@
 import org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigest;
 import org.bouncycastle.crypto.Digest;
 import org.bouncycastle.crypto.ExtendedDigest;
-import org.bouncycastle.crypto.digests.MD2Digest;
 import org.bouncycastle.crypto.digests.MD4Digest;
 import org.bouncycastle.crypto.digests.MD5Digest;
 import org.bouncycastle.crypto.digests.SHA1Digest;
@@ -93,16 +92,6 @@
         
         // Assert.assertTrue("New hash should be faster", newTime < oldTime);
     }
-
-    /**
-     * Tests the MD2 implementation.
-     */
-    @LargeTest
-    public void testMD2() {
-        Digest oldDigest = new MD2Digest();
-        Digest newDigest = OpenSSLMessageDigest.getInstance("MD2");
-        doTestMessageDigest(oldDigest, newDigest);
-    }
     
     /**
      * Tests the MD4 implementation.