Merge change 1528 into donut

* changes:
  should help fix the Simulator build.
diff --git a/api/4.xml b/api/4.xml
index ab93a47..893301e 100644
--- a/api/4.xml
+++ b/api/4.xml
@@ -31801,97 +31801,6 @@
 >
 </field>
 </class>
-<interface name="IPackageInstallObserver"
- abstract="true"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.os.IInterface">
-</implements>
-<method name="packageInstalled"
- return="void"
- abstract="true"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageName" type="java.lang.String">
-</parameter>
-<parameter name="returnCode" type="int">
-</parameter>
-<exception name="RemoteException" type="android.os.RemoteException">
-</exception>
-</method>
-</interface>
-<class name="IPackageInstallObserver.Stub"
- extends="android.os.Binder"
- abstract="true"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.content.pm.IPackageInstallObserver">
-</implements>
-<constructor name="IPackageInstallObserver.Stub"
- type="android.content.pm.IPackageInstallObserver.Stub"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="asBinder"
- return="android.os.IBinder"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="asInterface"
- return="android.content.pm.IPackageInstallObserver"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="obj" type="android.os.IBinder">
-</parameter>
-</method>
-<method name="onTransact"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="code" type="int">
-</parameter>
-<parameter name="data" type="android.os.Parcel">
-</parameter>
-<parameter name="reply" type="android.os.Parcel">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-<exception name="RemoteException" type="android.os.RemoteException">
-</exception>
-</method>
-</class>
 <class name="InstrumentationInfo"
  extends="android.content.pm.PackageItemInfo"
  abstract="false"
@@ -33041,36 +32950,6 @@
 <parameter name="appInfo" type="android.content.pm.ApplicationInfo">
 </parameter>
 </method>
-<method name="installPackage"
- return="void"
- abstract="true"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageURI" type="android.net.Uri">
-</parameter>
-<parameter name="observer" type="android.content.pm.IPackageInstallObserver">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
-<method name="installPackage"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageURI" type="android.net.Uri">
-</parameter>
-</method>
 <method name="isSafeMode"
  return="boolean"
  abstract="true"
@@ -33344,17 +33223,6 @@
  visibility="public"
 >
 </field>
-<field name="FORWARD_LOCK_PACKAGE"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="GET_ACTIVITIES"
  type="int"
  transient="false"
@@ -33531,270 +33399,6 @@
  visibility="public"
 >
 </field>
-<field name="INSTALL_FAILED_ALREADY_EXISTS"
- type="int"
- transient="false"
- volatile="false"
- value="-1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_CONFLICTING_PROVIDER"
- type="int"
- transient="false"
- volatile="false"
- value="-13"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_DEXOPT"
- type="int"
- transient="false"
- volatile="false"
- value="-11"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_DUPLICATE_PACKAGE"
- type="int"
- transient="false"
- volatile="false"
- value="-5"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_INSUFFICIENT_STORAGE"
- type="int"
- transient="false"
- volatile="false"
- value="-4"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_INVALID_APK"
- type="int"
- transient="false"
- volatile="false"
- value="-2"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_INVALID_URI"
- type="int"
- transient="false"
- volatile="false"
- value="-3"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_MISSING_SHARED_LIBRARY"
- type="int"
- transient="false"
- volatile="false"
- value="-9"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_NO_SHARED_USER"
- type="int"
- transient="false"
- volatile="false"
- value="-6"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_OLDER_SDK"
- type="int"
- transient="false"
- volatile="false"
- value="-12"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_REPLACE_COULDNT_DELETE"
- type="int"
- transient="false"
- volatile="false"
- value="-10"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"
- type="int"
- transient="false"
- volatile="false"
- value="-8"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_UPDATE_INCOMPATIBLE"
- type="int"
- transient="false"
- volatile="false"
- value="-7"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_BAD_MANIFEST"
- type="int"
- transient="false"
- volatile="false"
- value="-101"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"
- type="int"
- transient="false"
- volatile="false"
- value="-106"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"
- type="int"
- transient="false"
- volatile="false"
- value="-107"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"
- type="int"
- transient="false"
- volatile="false"
- value="-105"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"
- type="int"
- transient="false"
- volatile="false"
- value="-104"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_MANIFEST_EMPTY"
- type="int"
- transient="false"
- volatile="false"
- value="-109"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"
- type="int"
- transient="false"
- volatile="false"
- value="-108"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_NOT_APK"
- type="int"
- transient="false"
- volatile="false"
- value="-100"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_NO_CERTIFICATES"
- type="int"
- transient="false"
- volatile="false"
- value="-103"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"
- type="int"
- transient="false"
- volatile="false"
- value="-102"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_SUCCEEDED"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="MATCH_DEFAULT_ONLY"
  type="int"
  transient="false"
@@ -33850,17 +33454,6 @@
  visibility="public"
 >
 </field>
-<field name="REPLACE_EXISTING_PACKAGE"
- type="int"
- transient="false"
- volatile="false"
- value="2"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="SIGNATURE_FIRST_NOT_SIGNED"
  type="int"
  transient="false"
@@ -101178,23 +100771,6 @@
 <parameter name="appInfo" type="android.content.pm.ApplicationInfo">
 </parameter>
 </method>
-<method name="installPackage"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageURI" type="android.net.Uri">
-</parameter>
-<parameter name="observer" type="android.content.pm.IPackageInstallObserver">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
 <method name="isSafeMode"
  return="boolean"
  abstract="false"
diff --git a/api/current.xml b/api/current.xml
index 14faadc..623b986 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -7324,6 +7324,17 @@
  visibility="public"
 >
 </field>
+<field name="testOnly"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843378"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="text"
  type="int"
  transient="false"
@@ -22647,6 +22658,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="java.lang.Comparable">
+</implements>
 <implements name="android.os.Parcelable">
 </implements>
 <constructor name="ComponentName"
@@ -22695,6 +22708,19 @@
 <parameter name="in" type="android.os.Parcel">
 </parameter>
 </constructor>
+<method name="compareTo"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="that" type="android.content.ComponentName">
+</parameter>
+</method>
 <method name="describeContents"
  return="int"
  abstract="false"
@@ -31885,6 +31911,17 @@
  visibility="public"
 >
 </field>
+<field name="FLAG_TEST_ONLY"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="512"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="FLAG_UPDATED_SYSTEM_APP"
  type="int"
  transient="false"
@@ -32300,97 +32337,6 @@
 >
 </field>
 </class>
-<interface name="IPackageInstallObserver"
- abstract="true"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.os.IInterface">
-</implements>
-<method name="packageInstalled"
- return="void"
- abstract="true"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageName" type="java.lang.String">
-</parameter>
-<parameter name="returnCode" type="int">
-</parameter>
-<exception name="RemoteException" type="android.os.RemoteException">
-</exception>
-</method>
-</interface>
-<class name="IPackageInstallObserver.Stub"
- extends="android.os.Binder"
- abstract="true"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.content.pm.IPackageInstallObserver">
-</implements>
-<constructor name="IPackageInstallObserver.Stub"
- type="android.content.pm.IPackageInstallObserver.Stub"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</constructor>
-<method name="asBinder"
- return="android.os.IBinder"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="asInterface"
- return="android.content.pm.IPackageInstallObserver"
- abstract="false"
- native="false"
- synchronized="false"
- static="true"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="obj" type="android.os.IBinder">
-</parameter>
-</method>
-<method name="onTransact"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="code" type="int">
-</parameter>
-<parameter name="data" type="android.os.Parcel">
-</parameter>
-<parameter name="reply" type="android.os.Parcel">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-<exception name="RemoteException" type="android.os.RemoteException">
-</exception>
-</method>
-</class>
 <class name="InstrumentationInfo"
  extends="android.content.pm.PackageItemInfo"
  abstract="false"
@@ -33540,36 +33486,6 @@
 <parameter name="appInfo" type="android.content.pm.ApplicationInfo">
 </parameter>
 </method>
-<method name="installPackage"
- return="void"
- abstract="true"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageURI" type="android.net.Uri">
-</parameter>
-<parameter name="observer" type="android.content.pm.IPackageInstallObserver">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
-<method name="installPackage"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageURI" type="android.net.Uri">
-</parameter>
-</method>
 <method name="isSafeMode"
  return="boolean"
  abstract="true"
@@ -33843,17 +33759,6 @@
  visibility="public"
 >
 </field>
-<field name="FORWARD_LOCK_PACKAGE"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="GET_ACTIVITIES"
  type="int"
  transient="false"
@@ -34041,281 +33946,6 @@
  visibility="public"
 >
 </field>
-<field name="INSTALL_FAILED_ALREADY_EXISTS"
- type="int"
- transient="false"
- volatile="false"
- value="-1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_CONFLICTING_PROVIDER"
- type="int"
- transient="false"
- volatile="false"
- value="-13"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_DEXOPT"
- type="int"
- transient="false"
- volatile="false"
- value="-11"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_DUPLICATE_PACKAGE"
- type="int"
- transient="false"
- volatile="false"
- value="-5"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_INSUFFICIENT_STORAGE"
- type="int"
- transient="false"
- volatile="false"
- value="-4"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_INVALID_APK"
- type="int"
- transient="false"
- volatile="false"
- value="-2"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_INVALID_URI"
- type="int"
- transient="false"
- volatile="false"
- value="-3"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_MISSING_SHARED_LIBRARY"
- type="int"
- transient="false"
- volatile="false"
- value="-9"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_NEWER_SDK"
- type="int"
- transient="false"
- volatile="false"
- value="-14"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_NO_SHARED_USER"
- type="int"
- transient="false"
- volatile="false"
- value="-6"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_OLDER_SDK"
- type="int"
- transient="false"
- volatile="false"
- value="-12"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_REPLACE_COULDNT_DELETE"
- type="int"
- transient="false"
- volatile="false"
- value="-10"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"
- type="int"
- transient="false"
- volatile="false"
- value="-8"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_FAILED_UPDATE_INCOMPATIBLE"
- type="int"
- transient="false"
- volatile="false"
- value="-7"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_BAD_MANIFEST"
- type="int"
- transient="false"
- volatile="false"
- value="-101"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"
- type="int"
- transient="false"
- volatile="false"
- value="-106"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"
- type="int"
- transient="false"
- volatile="false"
- value="-107"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"
- type="int"
- transient="false"
- volatile="false"
- value="-105"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"
- type="int"
- transient="false"
- volatile="false"
- value="-104"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_MANIFEST_EMPTY"
- type="int"
- transient="false"
- volatile="false"
- value="-109"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"
- type="int"
- transient="false"
- volatile="false"
- value="-108"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_NOT_APK"
- type="int"
- transient="false"
- volatile="false"
- value="-100"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_NO_CERTIFICATES"
- type="int"
- transient="false"
- volatile="false"
- value="-103"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"
- type="int"
- transient="false"
- volatile="false"
- value="-102"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
-<field name="INSTALL_SUCCEEDED"
- type="int"
- transient="false"
- volatile="false"
- value="1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="MATCH_DEFAULT_ONLY"
  type="int"
  transient="false"
@@ -34371,17 +34001,6 @@
  visibility="public"
 >
 </field>
-<field name="REPLACE_EXISTING_PACKAGE"
- type="int"
- transient="false"
- volatile="false"
- value="2"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="SIGNATURE_FIRST_NOT_SIGNED"
  type="int"
  transient="false"
@@ -53318,6 +52937,32 @@
 <parameter name="path" type="java.lang.String">
 </parameter>
 </method>
+<method name="createFromFile"
+ return="android.graphics.Typeface"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="path" type="java.io.File">
+</parameter>
+</method>
+<method name="createFromFile"
+ return="android.graphics.Typeface"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="path" type="java.lang.String">
+</parameter>
+</method>
 <method name="defaultFromStyle"
  return="android.graphics.Typeface"
  abstract="false"
@@ -112297,23 +111942,6 @@
 <parameter name="appInfo" type="android.content.pm.ApplicationInfo">
 </parameter>
 </method>
-<method name="installPackage"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageURI" type="android.net.Uri">
-</parameter>
-<parameter name="observer" type="android.content.pm.IPackageInstallObserver">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
 <method name="isSafeMode"
  return="boolean"
  abstract="false"
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 96ee502..f85ea9f8 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -915,24 +915,24 @@
 void CameraService::Client::postAutoFocus(bool focused)
 {
     LOGV("postAutoFocus");
-    mCameraClient->autoFocusCallback(focused);
+    mCameraClient->notifyCallback(CAMERA_MSG_FOCUS, (int32_t)focused, 0);
 }
 
 void CameraService::Client::postShutter()
 {
-    mCameraClient->shutterCallback();
+    mCameraClient->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0);
 }
 
 void CameraService::Client::postRaw(const sp<IMemory>& mem)
 {
     LOGD("postRaw");
-    mCameraClient->rawCallback(mem);
+    mCameraClient->dataCallback(CAMERA_MSG_RAW_IMAGE, mem);
 }
 
 void CameraService::Client::postJpeg(const sp<IMemory>& mem)
 {
     LOGD("postJpeg");
-    mCameraClient->jpegCallback(mem);
+    mCameraClient->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem);
 }
 
 void CameraService::Client::copyFrameAndPostCopiedFrame(sp<IMemoryHeap> heap, size_t offset, size_t size)
@@ -960,7 +960,7 @@
         LOGE("failed to allocate space for frame callback");
         return;
     }
-    mCameraClient->previewCallback(frame);
+    mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME, frame);
 }
 
 void CameraService::Client::postRecordingFrame(const sp<IMemory>& frame)
@@ -970,7 +970,7 @@
         LOGW("frame is a null pointer");
         return;
     }
-    mCameraClient->recordingCallback(frame);
+    mCameraClient->dataCallback(CAMERA_MSG_VIDEO_FRAME, frame);
 }
 
 void CameraService::Client::postPreviewFrame(const sp<IMemory>& mem)
@@ -1004,7 +1004,7 @@
         copyFrameAndPostCopiedFrame(heap, offset, size);
     } else {
         LOGV("frame is directly sent out without copying");
-        mCameraClient->previewCallback(mem);
+        mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME, mem);
     }
 
     // Is this is one-shot only?
@@ -1018,7 +1018,7 @@
 
 void CameraService::Client::postError(status_t error)
 {
-    mCameraClient->errorCallback(error);
+    mCameraClient->notifyCallback(CAMERA_MSG_ERROR, error, 0);
 }
 
 status_t CameraService::dump(int fd, const Vector<String16>& args)
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 04e69e3..8212b92 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -540,6 +540,9 @@
         case PackageManager.INSTALL_FAILED_NEWER_SDK:
             s = "INSTALL_FAILED_NEWER_SDK";
             break;
+        case PackageManager.INSTALL_FAILED_TEST_ONLY:
+            s = "INSTALL_FAILED_TEST_ONLY";
+            break;
         case PackageManager.INSTALL_PARSE_FAILED_NOT_APK:
             s = "INSTALL_PARSE_FAILED_NOT_APK";
             break;
@@ -579,13 +582,23 @@
     
     private void runInstall() {
         int installFlags = 0;
+        String installerPackageName = null;
 
         String opt;
         while ((opt=nextOption()) != null) {
             if (opt.equals("-l")) {
-                installFlags |= PackageManager.FORWARD_LOCK_PACKAGE;
+                installFlags |= PackageManager.INSTALL_FORWARD_LOCK;
             } else if (opt.equals("-r")) {
-                installFlags |= PackageManager.REPLACE_EXISTING_PACKAGE;
+                installFlags |= PackageManager.INSTALL_REPLACE_EXISTING;
+            } else if (opt.equals("-i")) {
+                installerPackageName = nextOptionData();
+                if (installerPackageName == null) {
+                    System.err.println("Error: no value specified for -i");
+                    showUsage();
+                    return;
+                }
+            } else if (opt.equals("-t")) {
+                installFlags |= PackageManager.INSTALL_ALLOW_TEST;
             } else {
                 System.err.println("Error: Unknown option: " + opt);
                 showUsage();
@@ -603,7 +616,8 @@
 
         PackageInstallObserver obs = new PackageInstallObserver();
         try {
-            mPm.installPackage(Uri.fromFile(new File(apkFilePath)), obs, installFlags);
+            mPm.installPackage(Uri.fromFile(new File(apkFilePath)), obs, installFlags,
+                    installerPackageName);
             
             synchronized (obs) {
                 while (!obs.finished) {
@@ -812,37 +826,39 @@
         System.err.println("       pm list permissions [-g] [-f] [-d] [-u] [GROUP]");
         System.err.println("       pm list instrumentation [-f] [TARGET-PACKAGE]");        
         System.err.println("       pm path PACKAGE");
-        System.err.println("       pm install [-l] [-r] PATH");
+        System.err.println("       pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] PATH");
         System.err.println("       pm uninstall [-k] PACKAGE");
         System.err.println("       pm enable PACKAGE_OR_COMPONENT");
         System.err.println("       pm disable PACKAGE_OR_COMPONENT");
         System.err.println("");
-        System.err.println("The list packages command prints all packages.  Use");
-        System.err.println("the -f option to see their associated file.");
+        System.err.println("The list packages command prints all packages.  Options:");
+        System.err.println("  -f: see their associated file.");
         System.err.println("");
         System.err.println("The list permission-groups command prints all known");
         System.err.println("permission groups.");
         System.err.println("");
         System.err.println("The list permissions command prints all known");
-        System.err.println("permissions, optionally only those in GROUP.  Use");
-        System.err.println("the -g option to organize by group.  Use");
-        System.err.println("the -f option to print all information.  Use");
-        System.err.println("the -s option for a short summary.  Use");
-        System.err.println("the -d option to only list dangerous permissions.  Use");
-        System.err.println("the -u option to list only the permissions users will see.");
+        System.err.println("permissions, optionally only those in GROUP.  Options:");
+        System.err.println("  -g: organize by group.");
+        System.err.println("  -f: print all information.");
+        System.err.println("  -s: short summary.");
+        System.err.println("  -d: only list dangerous permissions.");
+        System.err.println("  -u: list only the permissions users will see.");
         System.err.println("");
         System.err.println("The list instrumentation command prints all instrumentations,");
-        System.err.println("or only those that target a specified package.  Use the -f option");
-        System.err.println("to see their associated file.");
+        System.err.println("or only those that target a specified package.  Options:");
+        System.err.println("  -f: see their associated file.");
         System.err.println("");
         System.err.println("The path command prints the path to the .apk of a package.");
         System.err.println("");
-        System.err.println("The install command installs a package to the system.  Use");
-        System.err.println("the -l option to install the package with FORWARD_LOCK. Use");
-        System.err.println("the -r option to reinstall an exisiting app, keeping its data.");
+        System.err.println("The install command installs a package to the system.  Options:");
+        System.err.println("  -l: install the package with FORWARD_LOCK.");
+        System.err.println("  -r: reinstall an exisiting app, keeping its data.");
+        System.err.println("  -t: allow test .apks to be installed.");
+        System.err.println("  -i: specify the installer package name.");
         System.err.println("");
-        System.err.println("The uninstall command removes a package from the system. Use");
-        System.err.println("the -k option to keep the data and cache directories around");
+        System.err.println("The uninstall command removes a package from the system. Options:");
+        System.err.println("  -k: keep the data and cache directories around.");
         System.err.println("after the package removal.");
         System.err.println("");
         System.err.println("The enable and disable commands change the enabled state of");
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 2fc476e..1e15d14 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -191,16 +191,11 @@
                 usePreloaded = false;
                 DisplayMetrics newMetrics = new DisplayMetrics();
                 newMetrics.setTo(metrics);
-                float invertedScale = 1.0f / applicationScale;
-                newMetrics.density *= invertedScale;
-                newMetrics.xdpi *= invertedScale;
-                newMetrics.ydpi *= invertedScale;
-                newMetrics.widthPixels *= invertedScale;
-                newMetrics.heightPixels *= invertedScale;
+                float newDensity = metrics.density / applicationScale;
+                newMetrics.updateDensity(newDensity);
                 metrics = newMetrics;
             }
-            //Log.i(TAG, "Resource:" + appDir + ", density " + newMetrics.density + ", orig density:" +
-            //      metrics.density);
+            //Log.i(TAG, "Resource:" + appDir + ", display metrics=" + metrics);
             r = new Resources(assets, metrics, getConfiguration(), usePreloaded);
             //Log.i(TAG, "Created app resources " + r + ": " + r.getConfiguration());
             // XXX need to remove entries when weak references go away
@@ -3502,8 +3497,10 @@
                     Resources r = v.get();
                     if (r != null) {
                         // keep the original density based on application cale.
-                        appDm.density = r.getDisplayMetrics().density;
+                        appDm.updateDensity(r.getDisplayMetrics().density);
                         r.updateConfiguration(config, appDm);
+                        // reset
+                        appDm.setTo(dm);
                         //Log.i(TAG, "Updated app resources " + v.getKey()
                         //        + " " + r + ": " + r.getConfiguration());
                     } else {
diff --git a/core/java/android/app/ApplicationContext.java b/core/java/android/app/ApplicationContext.java
index a1f5a58..bb17dc3 100644
--- a/core/java/android/app/ApplicationContext.java
+++ b/core/java/android/app/ApplicationContext.java
@@ -2310,15 +2310,26 @@
         }
 
         @Override
-        public void installPackage(Uri packageURI, IPackageInstallObserver observer, int flags) {
+        public void installPackage(Uri packageURI, IPackageInstallObserver observer, int flags,
+                String installerPackageName) {
             try {
-                mPM.installPackage(packageURI, observer, flags);
+                mPM.installPackage(packageURI, observer, flags, installerPackageName);
             } catch (RemoteException e) {
                 // Should never happen!
             }
         }
 
         @Override
+        public String getInstallerPackageName(String packageName) {
+            try {
+                return mPM.getInstallerPackageName(packageName);
+            } catch (RemoteException e) {
+                // Should never happen!
+            }
+            return null;
+        }
+
+        @Override
         public void deletePackage(String packageName, IPackageDeleteObserver observer, int flags) {
             try {
                 mPM.deletePackage(packageName, observer, flags);
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 0aa5975..a174843 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -325,6 +325,14 @@
         
         // show the dialog. this will call onStart().
         if (!isShowing()) {
+            // First make sure the keyboard is showing (if needed), so that we get the right height
+            // for the dropdown to respect the IME.
+            if (getContext().getResources().getConfiguration().hardKeyboardHidden ==
+                Configuration.HARDKEYBOARDHIDDEN_YES) {
+                InputMethodManager inputManager = (InputMethodManager)
+                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+                        inputManager.showSoftInputUnchecked(0, null);
+            }
             show();
         }
 
@@ -528,13 +536,16 @@
         mSearchAutoComplete.setDropDownAnimationStyle(0); // no animation
         mSearchAutoComplete.setThreshold(mSearchable.getSuggestThreshold());
 
-        // TODO: Use different dropdown background resource for in-app search.
         if (mGlobalSearchMode) {
             mSearchAutoComplete.setDropDownAlwaysVisible(true);  // fill space until results come in
             mSearchAutoComplete.setDropDownDismissedOnCompletion(false);
+            mSearchAutoComplete.setDropDownBackgroundResource(
+                    com.android.internal.R.drawable.search_dropdown_background);
         } else {
             mSearchAutoComplete.setDropDownAlwaysVisible(false);
             mSearchAutoComplete.setDropDownDismissedOnCompletion(true);
+            mSearchAutoComplete.setDropDownBackgroundResource(
+                    com.android.internal.R.drawable.search_dropdown_background_apps);
         }
 
         // attach the suggestions adapter, if suggestions are available
diff --git a/core/java/android/content/ComponentName.java b/core/java/android/content/ComponentName.java
index 32c6864..04552021 100644
--- a/core/java/android/content/ComponentName.java
+++ b/core/java/android/content/ComponentName.java
@@ -18,6 +18,7 @@
 
 import android.os.Parcel;
 import android.os.Parcelable;
+import java.lang.Comparable;
 
 /**
  * Identifier for a specific application component
@@ -29,7 +30,7 @@
  * name inside of that package.
  * 
  */
-public final class ComponentName implements Parcelable {
+public final class ComponentName implements Parcelable, Comparable<ComponentName> {
     private final String mPackage;
     private final String mClass;
 
@@ -196,6 +197,15 @@
     public int hashCode() {
         return mPackage.hashCode() + mClass.hashCode();
     }
+
+    public int compareTo(ComponentName that) {
+        int v;
+        v = this.mPackage.compareTo(that.mPackage);
+        if (v != 0) {
+            return v;
+        }
+        return this.mClass.compareTo(that.mClass);
+    }
     
     public int describeContents() {
         return 0;
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 3ebf816..81f72ac 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1940,7 +1940,7 @@
     /**
      * If set, this marks a point in the task's activity stack that should
      * be cleared when the task is reset.  That is, the next time the task
-     * is broad to the foreground with
+     * is brought to the foreground with
      * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
      * the user re-launching it from home), this activity and all on top of
      * it will be finished so that the user does not return to them, but
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index fa9ec6e..88ac04c 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -126,6 +126,12 @@
     public static final int FLAG_TARGETS_SDK = 1<<8;
 
     /**
+     * Value for {@link #flags}: this is set of the application has set
+     * its android:targetSdkVersion to something >= the current SDK version.
+     */
+    public static final int FLAG_TEST_ONLY = 1<<9;
+
+    /**
      * Flags associated with the application.  Any combination of
      * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
      * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
diff --git a/core/java/android/content/pm/IPackageInstallObserver.aidl b/core/java/android/content/pm/IPackageInstallObserver.aidl
index e83bbc6..6133365 100644
--- a/core/java/android/content/pm/IPackageInstallObserver.aidl
+++ b/core/java/android/content/pm/IPackageInstallObserver.aidl
@@ -19,7 +19,7 @@
 
 /**
  * API for installation callbacks from the Package Manager.
- *
+ * @hide
  */
 oneway interface IPackageInstallObserver {
     void packageInstalled(in String packageName, int returnCode);
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index d3f6f3c5..c199619 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -139,8 +139,11 @@
      * @param observer a callback to use to notify when the package installation in finished.
      * @param flags - possible values: {@link #FORWARD_LOCK_PACKAGE},
      * {@link #REPLACE_EXISITING_PACKAGE}
+     * @param installerPackageName Optional package name of the application that is performing the
+     * installation. This identifies which market the package came from.
      */
-    void installPackage(in Uri packageURI, IPackageInstallObserver observer, int flags);
+    void installPackage(in Uri packageURI, IPackageInstallObserver observer, int flags,
+            in String installerPackageName);
 
     /**
      * Delete a package.
@@ -151,6 +154,8 @@
      */
     void deletePackage(in String packageName, IPackageDeleteObserver observer, int flags);
 
+    String getInstallerPackageName(in String packageName);
+
     void addPackageToPreferred(String packageName);
     
     void removePackageFromPreferred(String packageName);
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index d21252b..3a192f7 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -172,6 +172,14 @@
     public static final int GET_SUPPORTS_DENSITIES    = 0x00008000;
 
     /**
+     * Resolution and querying flag: if set, only filters that support the
+     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
+     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
+     * supplied Intent.
+     */
+    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
+
+    /**
      * Permission check result: this is returned by {@link #checkPermission}
      * if the permission has been granted to the given package.
      */
@@ -219,14 +227,6 @@
      */
     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
 
-    /**
-     * Resolution and querying flag: if set, only filters that support the
-     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
-     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
-     * supplied Intent.
-     */
-    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
-
     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
@@ -235,14 +235,24 @@
      * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
      * indicate that this package should be installed as forward locked, i.e. only the app itself
      * should have access to it's code and non-resource assets.
+     * @hide
      */
-    public static final int FORWARD_LOCK_PACKAGE = 0x00000001;
+    public static final int INSTALL_FORWARD_LOCK = 0x00000001;
 
     /**
      * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
-     * installed package, if one exists
+     * installed package, if one exists.
+     * @hide
      */
-    public static final int REPLACE_EXISTING_PACKAGE = 0x00000002;
+    public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
+
+    /**
+     * Flag parameter for {@link #installPackage} to indicate that you want to 
+     * allow test packages (those that have set android:testOnly in their
+     * manifest) to be installed.
+     * @hide
+     */
+    public static final int INSTALL_ALLOW_TEST = 0x00000004;
 
     /**
      * Flag parameter for
@@ -255,6 +265,7 @@
     /**
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
+     * @hide
      */
     public static final int INSTALL_SUCCEEDED = 1;
 
@@ -262,6 +273,7 @@
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
      * already installed.
+     * @hide
      */
     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
 
@@ -269,6 +281,7 @@
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
      * file is invalid.
+     * @hide
      */
     public static final int INSTALL_FAILED_INVALID_APK = -2;
 
@@ -276,13 +289,15 @@
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
      * is invalid.
+     * @hide
      */
     public static final int INSTALL_FAILED_INVALID_URI = -3;
 
     /**
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
-     * service found that the device didn't have enough storage space to install the app
+     * service found that the device didn't have enough storage space to install the app.
+     * @hide
      */
     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
 
@@ -290,6 +305,7 @@
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
      * package is already installed with the same name.
+     * @hide
      */
     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
 
@@ -297,6 +313,7 @@
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the requested shared user does not exist.
+     * @hide
      */
     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
 
@@ -305,6 +322,7 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * a previously installed package of the same name has a different signature
      * than the new package (and the old package's data was not removed).
+     * @hide
      */
     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
 
@@ -313,6 +331,7 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the new package is requested a shared user which is already installed on the
      * device and does not have matching signature.
+     * @hide
      */
     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
 
@@ -320,6 +339,7 @@
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the new package uses a shared library that is not available.
+     * @hide
      */
     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
 
@@ -327,6 +347,7 @@
      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the new package uses a shared library that is not available.
+     * @hide
      */
     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
 
@@ -335,6 +356,7 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the new package failed while optimizing and validating its dex files,
      * either because there was not enough storage or the validation failed.
+     * @hide
      */
     public static final int INSTALL_FAILED_DEXOPT = -11;
 
@@ -343,6 +365,7 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the new package failed because the current SDK version is older than
      * that required by the package.
+     * @hide
      */
     public static final int INSTALL_FAILED_OLDER_SDK = -12;
 
@@ -351,6 +374,7 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the new package failed because it contains a content provider with the
      * same authority as a provider already installed in the system.
+     * @hide
      */
     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
 
@@ -359,14 +383,26 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
      * the new package failed because the current SDK version is newer than
      * that required by the package.
+     * @hide
      */
     public static final int INSTALL_FAILED_NEWER_SDK = -14;
 
     /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
+     * the new package failed because it has specified that it is a test-only
+     * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
+     * flag.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_TEST_ONLY = -15;
+
+    /**
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser was given a path that is not a file, or does not end with the expected
      * '.apk' extension.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
 
@@ -374,6 +410,7 @@
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser was unable to retrieve the AndroidManifest.xml file.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
 
@@ -381,6 +418,7 @@
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser encountered an unexpected exception.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
 
@@ -388,6 +426,7 @@
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser did not find any certificates in the .apk.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
 
@@ -395,6 +434,7 @@
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser found inconsistent certificates on the files in the .apk.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
 
@@ -403,6 +443,7 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser encountered a CertificateEncodingException in one of the
      * files in the .apk.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
 
@@ -410,6 +451,7 @@
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser encountered a bad or missing package name in the manifest.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
 
@@ -417,6 +459,7 @@
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser encountered a bad shared user id name in the manifest.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
 
@@ -424,6 +467,7 @@
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser encountered some structural problem in the manifest.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
 
@@ -432,6 +476,7 @@
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser did not find any actionable tags (instrumentation or application)
      * in the manifest.
+     * @hide
      */
     public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
 
@@ -1338,6 +1383,8 @@
     }
 
     /**
+     * @hide
+     * 
      * Install a package. Since this may take a little while, the result will
      * be posted back to the given observer.  An installation will fail if the calling context
      * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
@@ -1349,13 +1396,14 @@
      * @param observer An observer callback to get notified when the package installation is
      * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
      * called when that happens.  observer may be null to indicate that no callback is desired.
-     * @param flags - possible values: {@link #FORWARD_LOCK_PACKAGE},
-     * {@link #REPLACE_EXISTING_PACKAGE}
-     *
-     * @see #installPackage(android.net.Uri)
+     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
+     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
+     * @param installerPackageName Optional package name of the application that is performing the
+     * installation. This identifies which market the package came from.
      */
     public abstract void installPackage(
-            Uri packageURI, IPackageInstallObserver observer, int flags);
+            Uri packageURI, IPackageInstallObserver observer, int flags,
+            String installerPackageName);
 
     /**
      * Attempts to delete a package.  Since this may take a little while, the result will
@@ -1374,6 +1422,17 @@
      */
     public abstract void deletePackage(
             String packageName, IPackageDeleteObserver observer, int flags);
+
+    /**
+     * Retrieve the package name of the application that installed a package. This identifies
+     * which market the package came from.
+     * 
+     * @param packageName The name of the package to query
+     *
+     * @hide
+     */
+    public abstract String getInstallerPackageName(String packageName);
+    
     /**
      * Attempts to clear the user data directory of an application.
      * Since this may take a little while, the result will
@@ -1479,17 +1538,6 @@
             IPackageStatsObserver observer);
 
     /**
-     * Install a package.
-     *
-     * @param packageURI The location of the package file to install
-     *
-     * @see #installPackage(android.net.Uri, IPackageInstallObserver, int)
-     */
-    public void installPackage(Uri packageURI) {
-        installPackage(packageURI, null, 0);
-    }
-
-    /**
      * Add a new package to the list of preferred packages.  This new package
      * will be added to the front of the list (removed from its current location
      * if already listed), meaning it will now be preferred over all other
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 12df5bd..a1c0f48 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -1187,6 +1187,12 @@
             ai.flags |= ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA;
         }
 
+        if (sa.getBoolean(
+                com.android.internal.R.styleable.AndroidManifestApplication_testOnly,
+                true)) {
+            ai.flags |= ApplicationInfo.FLAG_TEST_ONLY;
+        }
+
         String str;
         str = sa.getNonResourceString(
                 com.android.internal.R.styleable.AndroidManifestApplication_permission);
diff --git a/core/java/android/inputmethodservice/Keyboard.java b/core/java/android/inputmethodservice/Keyboard.java
index 6a560ce..fea63be 100755
--- a/core/java/android/inputmethodservice/Keyboard.java
+++ b/core/java/android/inputmethodservice/Keyboard.java
@@ -27,8 +27,7 @@
 import android.util.Log;
 import android.util.TypedValue;
 import android.util.Xml;
-import android.view.Display;
-import android.view.WindowManager;
+import android.util.DisplayMetrics;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -510,10 +509,11 @@
      * @param modeId keyboard mode identifier
      */
     public Keyboard(Context context, int xmlLayoutResId, int modeId) {
-        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
-        final Display display = wm.getDefaultDisplay();
-        mDisplayWidth = display.getWidth();
-        mDisplayHeight = display.getHeight();
+        DisplayMetrics dm = context.getResources().getDisplayMetrics();
+        mDisplayWidth = dm.widthPixels;
+        mDisplayHeight = dm.heightPixels;
+        //Log.v(TAG, "keyboard's display metrics:" + dm);
+
         mDefaultHorizontalGap = 0;
         mDefaultWidth = mDisplayWidth / 10;
         mDefaultVerticalGap = 0;
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java
index 095f4f4..e4dd020 100644
--- a/core/java/android/util/DisplayMetrics.java
+++ b/core/java/android/util/DisplayMetrics.java
@@ -99,4 +99,24 @@
         xdpi = DEVICE_DENSITY;
         ydpi = DEVICE_DENSITY;
     }
+
+    /**
+     * Set the display metrics' density and update parameters depend on it.
+     * @hide
+     */
+    public void updateDensity(float newDensity) {
+        float ratio = newDensity / density;
+        density = newDensity;
+        scaledDensity = density;
+        widthPixels *= ratio;
+        heightPixels *= ratio;
+        xdpi *= ratio;
+        ydpi *= ratio;
+    }
+
+    public String toString() {
+        return "DisplayMetrics{density=" + density + ", width=" + widthPixels +
+            ", height=" + heightPixels + ", scaledDensity=" + scaledDensity +
+            ", xdpi=" + xdpi + ", ydpi=" + ydpi + "}";
+    }
 }
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 61dca4c..40b03c8 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -256,6 +256,23 @@
     }
 
     @Override
+    public boolean dispatchTouchEvent(MotionEvent event) {
+        // SurfaceView uses pre-scaled size unless fixed size is requested. This hook
+        // scales the event back to the pre-scaled coordinates for such surface.
+        if (mRequestedWidth < 0 && mAppScale != 1.0f) {
+            MotionEvent scaledBack = MotionEvent.obtain(event);
+            scaledBack.scale(mAppScale);
+            try {
+                return super.dispatchTouchEvent(scaledBack);
+            } finally {
+                scaledBack.recycle();
+            }
+        } else {
+            return super.dispatchTouchEvent(event);
+        }
+    }
+
+    @Override
     protected void dispatchDraw(Canvas canvas) {
         // if SKIP_DRAW is cleared, draw() has already punched a hole
         if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
@@ -277,7 +294,13 @@
         if (myWidth <= 0) myWidth = getWidth();
         int myHeight = mRequestedHeight;
         if (myHeight <= 0) myHeight = getHeight();
-        
+
+        // Use original size for surface unless fixed size is requested.
+        if (mRequestedWidth <= 0) {
+            myWidth *= mAppScale;
+            myHeight *= mAppScale;
+        }
+
         getLocationInWindow(mLocation);
         final boolean creating = mWindow == null;
         final boolean formatChanged = mFormat != mRequestedFormat;
@@ -333,7 +356,7 @@
                 mSurfaceLock.lock();
                 mDrawingStopped = !visible;
                 final int relayoutResult = mSession.relayout(
-                    mWindow, mLayout, (int) (mWidth * mAppScale), (int) (mHeight * mAppScale),
+                    mWindow, mLayout, mWidth, mHeight,
                         visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets,
                         mVisibleInsets, mSurface);
 
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index d042f28d..335b43c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -850,6 +850,28 @@
     public static final int HAPTIC_FEEDBACK_ENABLED = 0x10000000;
 
     /**
+     * View flag indicating whether this view was invalidated (fully or partially.)
+     *
+     * @hide
+     */
+    static final int DIRTY = 0x20000000;
+
+    /**
+     * View flag indicating whether this view was invalidated by an opaque
+     * invalidate request.
+     *
+     * @hide
+     */
+    static final int DIRTY_OPAQUE = 0x40000000;
+
+    /**
+     * Mask for {@link #DIRTY} and {@link #DIRTY_OPAQUE}.
+     *
+     * @hide
+     */
+    static final int DIRTY_MASK = 0x60000000;
+
+    /**
      * Use with {@link #focusSearch}. Move focus to the previous selectable
      * item.
      */
@@ -4522,6 +4544,24 @@
     }
 
     /**
+     * Indicates whether this View is opaque. An opaque View guarantees that it will
+     * draw all the pixels overlapping its bounds using a fully opaque color.
+     *
+     * Subclasses of View should override this method whenever possible to indicate
+     * whether an instance is opaque. Opaque Views are treated in a special way by
+     * the View hierarchy, possibly allowing it to perform optimizations during
+     * invalidate/draw passes.
+     * 
+     * @return True if this View is guaranteed to be fully opaque, false otherwise.
+     *
+     * @hide Pending API council approval
+     */
+    @ViewDebug.ExportedProperty
+    public boolean isOpaque() {
+        return mBGDrawable != null && mBGDrawable.getOpacity() == PixelFormat.OPAQUE;
+    }
+
+    /**
      * @return A handler associated with the thread running the View. This
      * handler can be used to pump events in the UI events queue.
      */
@@ -5687,7 +5727,7 @@
             final int restoreCount = canvas.save();
             canvas.translate(-mScrollX, -mScrollY);
 
-            mPrivateFlags |= DRAWN;
+            mPrivateFlags = (mPrivateFlags & ~DIRTY_MASK) | DRAWN; 
 
             // Fast path for layouts with no backgrounds
             if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
@@ -5875,7 +5915,8 @@
             ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
         }
 
-        mPrivateFlags |= DRAWN;                    
+        final boolean dirtyOpaque = (mPrivateFlags & DIRTY_MASK) == DIRTY_OPAQUE;
+        mPrivateFlags = (mPrivateFlags & ~DIRTY_MASK) | DRAWN;
 
         /*
          * Draw traversal performs several drawing steps which must be executed
@@ -5892,22 +5933,24 @@
         // Step 1, draw the background, if needed
         int saveCount;
 
-        final Drawable background = mBGDrawable;
-        if (background != null) {
-            final int scrollX = mScrollX;
-            final int scrollY = mScrollY;
+        if (!dirtyOpaque) {
+            final Drawable background = mBGDrawable;
+            if (background != null) {
+                final int scrollX = mScrollX;
+                final int scrollY = mScrollY;
 
-            if (mBackgroundSizeChanged) {
-                background.setBounds(0, 0,  mRight - mLeft, mBottom - mTop);
-                mBackgroundSizeChanged = false;
-            }
+                if (mBackgroundSizeChanged) {
+                    background.setBounds(0, 0,  mRight - mLeft, mBottom - mTop);
+                    mBackgroundSizeChanged = false;
+                }
 
-            if ((scrollX | scrollY) == 0) {
-                background.draw(canvas);
-            } else {
-                canvas.translate(scrollX, scrollY);
-                background.draw(canvas);
-                canvas.translate(-scrollX, -scrollY);
+                if ((scrollX | scrollY) == 0) {
+                    background.draw(canvas);
+                } else {
+                    canvas.translate(scrollX, scrollY);
+                    background.draw(canvas);
+                    canvas.translate(-scrollX, -scrollY);
+                }
             }
         }
 
@@ -5917,7 +5960,7 @@
         boolean verticalEdges = (viewFlags & FADING_EDGE_VERTICAL) != 0;
         if (!verticalEdges && !horizontalEdges) {
             // Step 3, draw the content
-            onDraw(canvas);
+            if (!dirtyOpaque) onDraw(canvas);
 
             // Step 4, draw the children
             dispatchDraw(canvas);
@@ -6020,7 +6063,7 @@
         }
 
         // Step 3, draw the content
-        onDraw(canvas);
+        if (!dirtyOpaque) onDraw(canvas);
 
         // Step 4, draw the children
         dispatchDraw(canvas);
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index e686d1c..31159d7 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -1796,7 +1796,7 @@
             boolean preventRequestLayout) {
         child.mParent = null;
         addViewInner(child, index, params, preventRequestLayout);
-        child.mPrivateFlags |= DRAWN;
+        child.mPrivateFlags = (child.mPrivateFlags & ~DIRTY_MASK) | DRAWN;
         return true;
     }
 
@@ -2210,7 +2210,7 @@
         addInArray(child, index);
 
         child.mParent = this;
-        child.mPrivateFlags |= DRAWN;
+        child.mPrivateFlags = (child.mPrivateFlags & ~DIRTY_MASK) | DRAWN;
 
         if (child.hasFocus()) {
             requestChildFocus(child, child.findFocus());
@@ -2320,15 +2320,33 @@
             // ourselves and the parent to make sure the invalidate request goes
             // through
             final boolean drawAnimation = (child.mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION;
-    
+
+            // Check whether the child that requests the invalidate is fully opaque
+            final boolean isOpaque = child.isOpaque();
+            // Mark the child as dirty, using the appropriate flag
+            // Make sure we do not set both flags at the same time
+            final int opaqueFlag = isOpaque ? DIRTY_OPAQUE : DIRTY;
+
             do {
+                View view = null;
+                if (parent instanceof View) {
+                    view = (View) parent;
+                }
+
                 if (drawAnimation) {
-                    if (parent instanceof View) {
-                        ((View) parent).mPrivateFlags |= DRAW_ANIMATION;
+                    if (view != null) {
+                        view.mPrivateFlags |= DRAW_ANIMATION;
                     } else if (parent instanceof ViewRoot) {
                         ((ViewRoot) parent).mIsAnimating = true;
                     }
                 }
+
+                // If the parent is dirty opaque or not dirty, mark it dirty with the opaque
+                // flag coming from the child that initiated the invalidate
+                if (view != null && (view.mPrivateFlags & DIRTY_MASK) != DIRTY) {
+                    view.mPrivateFlags = (view.mPrivateFlags & ~DIRTY_MASK) | opaqueFlag;
+                }
+
                 parent = parent.invalidateChildInParent(location, dirty);
             } while (parent != null);
         }
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 0b03626..8494d5e 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -539,6 +539,7 @@
             }
             dirty = mTempRect;
         }
+        // TODO: When doing a union with mDirty != empty, we must cancel all the DIRTY_OPAQUE flags
         mDirty.union(dirty);
         if (!mWillDrawSoon) {
             scheduleTraversals();
@@ -959,11 +960,10 @@
                         mTmpLocation[1] + host.mBottom - host.mTop);
 
                 host.gatherTransparentRegion(mTransparentRegion);
+                if (mAppScale != 1.0f) {
+                    mTransparentRegion.scale(mAppScale);
+                }
 
-                // TODO: scale the region, like:
-                // Region uses native methods. We probabl should have ScalableRegion class.
-
-                // Region does not have equals method ?
                 if (!mTransparentRegion.equals(mPreviousTransparentRegion)) {
                     mPreviousTransparentRegion.set(mTransparentRegion);
                     // reconfigure window manager
@@ -1878,9 +1878,6 @@
         } else {
             didFinish = false;
         }
-        if (event != null) {
-            event.scale(mAppScaleInverted);
-        }
 
         if (DEBUG_TRACKBALL) Log.v(TAG, "Motion event:" + event);
 
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java
index 5f8acc8..17d3f94 100644
--- a/core/java/android/webkit/CallbackProxy.java
+++ b/core/java/android/webkit/CallbackProxy.java
@@ -98,6 +98,7 @@
     private static final int SCALE_CHANGED        = 123;
     private static final int RECEIVED_CERTIFICATE = 124;
     private static final int SWITCH_OUT_HISTORY   = 125;
+    private static final int JS_TIMEOUT           = 126;
 
     // Message triggered by the client to resume execution
     private static final int NOTIFY               = 200;
@@ -530,6 +531,18 @@
                 }
                 break;
 
+            case JS_TIMEOUT:
+                if(mWebChromeClient != null) {
+                    final JsResult res = (JsResult) msg.obj;
+                    if(mWebChromeClient.onJsTimeout()) {
+                        res.confirm();
+                    } else {
+                        res.cancel();
+                    }
+                    res.setReady();
+                }
+                break;
+
             case RECEIVED_CERTIFICATE:
                 mWebView.setCertificate((SslCertificate) msg.obj);
                 break;
@@ -1022,4 +1035,26 @@
         }
         return result.getResult();
     }
+
+    /**
+     * @hide pending API council approval
+     */
+    public boolean onJsTimeout() {
+        //always interrupt timedout JS by default
+        if (mWebChromeClient == null) {
+            return true;
+        }
+        JsResult result = new JsResult(this, true);
+        Message timeout = obtainMessage(JS_TIMEOUT, result);
+        synchronized (this) {
+            sendMessage(timeout);
+            try {
+                wait();
+            } catch (InterruptedException e) {
+                Log.e(LOGTAG, "Caught exception while waiting for jsUnload");
+                Log.e(LOGTAG, Log.getStackTraceString(e));
+            }
+        }
+        return result.getResult();
+    }
 }
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index c0c6775..e8c2279 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -647,8 +647,6 @@
                     // another file in the local web server directory. Still
                     // "localhost" is the best pseudo domain name.
                     ret[0] = "localhost";
-                } else if (!ret[0].equals("localhost")) {
-                    return null;
                 }
             } else if (index == ret[0].lastIndexOf(PERIOD)) {
                 // cookie host must have at least two periods
diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java
index f9400061..9d9763c 100644
--- a/core/java/android/webkit/WebChromeClient.java
+++ b/core/java/android/webkit/WebChromeClient.java
@@ -157,4 +157,19 @@
             JsResult result) {
         return false;
     }
+
+    /**
+     * Tell the client that a JavaScript execution timeout has occured. And the
+     * client may decide whether or not to interrupt the execution. If the
+     * client returns true, the JavaScript will be interrupted. If the client
+     * returns false, the execution will continue. Note that in the case of
+     * continuing execution, the timeout counter will be reset, and the callback
+     * will continue to occur if the script does not finish at the next check
+     * point.
+     * @return boolean Whether the JavaScript execution should be interrupted.
+     * @hide pending API Council approval
+     */
+    public boolean onJsTimeout() {
+        return true;
+    }
 }
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 58d8ae7..e9df453 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -263,6 +263,16 @@
         return mCallbackProxy.onJsBeforeUnload(url, message);
     }
 
+    /**
+     *
+     * Callback to notify that a JavaScript execution timeout has occured.
+     * @return True if the JavaScript execution should be interrupted. False
+     *         will continue the execution.
+     */
+    protected boolean jsInterrupt() {
+        return mCallbackProxy.onJsTimeout();
+    }
+
     //-------------------------------------------------------------------------
     // JNI methods
     //-------------------------------------------------------------------------
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 767c7e7..4f503b4 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -433,7 +433,9 @@
 
     private InputConnection mDefInputConnection;
     private InputConnectionWrapper mPublicInputConnection;
-    
+
+    private Runnable mClearScrollingCache;
+
     /**
      * Interface definition for a callback to be invoked when the list or grid
      * has been scrolled.
@@ -2299,6 +2301,7 @@
             }
 
             if (more) {
+                invalidate();
                 mLastFlingY = y;
                 post(this);
             } else {
@@ -2322,16 +2325,23 @@
     }
 
     private void clearScrollingCache() {
-        if (mCachingStarted) {
-            setChildrenDrawnWithCacheEnabled(false);
-            if ((mPersistentDrawingCache & PERSISTENT_SCROLLING_CACHE) == 0) {
-                setChildrenDrawingCacheEnabled(false);
-            }
-            if (!isAlwaysDrawnWithCacheEnabled()) {
-                invalidate();
-            }
-            mCachingStarted = false;
+        if (mClearScrollingCache == null) {
+            mClearScrollingCache = new Runnable() {
+                public void run() {
+                    if (mCachingStarted) {
+                        mCachingStarted = false;
+                        setChildrenDrawnWithCacheEnabled(false);
+                        if ((mPersistentDrawingCache & PERSISTENT_SCROLLING_CACHE) == 0) {
+                            setChildrenDrawingCacheEnabled(false);
+                        }
+                        if (!isAlwaysDrawnWithCacheEnabled()) {
+                            invalidate();
+                        }
+                    }
+                }
+            };
         }
+        post(mClearScrollingCache);
     }
 
     /**
@@ -2788,7 +2798,7 @@
         int screenHeight = getResources().getDisplayMetrics().heightPixels;
         final int[] xy = new int[2];
         getLocationOnScreen(xy);
-        // TODO: The 20 below should come from the theme and be expressed in dip
+        // TODO: The 20 below should come from the theme
         // TODO: And the gravity should be defined in the theme as well
         final int bottomGap = screenHeight - xy[1] - getHeight() + (int) (mDensityScale * 20);
         if (!mPopup.isShowing()) {
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 66c162e..5472d68 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -20,6 +20,7 @@
 import android.content.res.TypedArray;
 import android.graphics.Canvas;
 import android.graphics.Rect;
+import android.graphics.PixelFormat;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.ColorDrawable;
 import android.os.Parcel;
@@ -113,7 +114,11 @@
 
     Drawable mDivider;
     int mDividerHeight;
+
+    private boolean mIsCacheColorOpaque;
+    private boolean mDividerIsOpaque;
     private boolean mClipDivider;
+
     private boolean mHeaderDividersEnabled;
     private boolean mFooterDividersEnabled;
 
@@ -2776,6 +2781,20 @@
         return mItemsCanFocus;
     }
 
+    /**
+     * @hide Pending API council approval.
+     */
+    @Override
+    public boolean isOpaque() {
+        return (mCachingStarted && mIsCacheColorOpaque && mDividerIsOpaque) || super.isOpaque();
+    }
+
+    @Override
+    public void setCacheColorHint(int color) {
+        mIsCacheColorOpaque = (color >>> 24) == 0xFF;
+        super.setCacheColorHint(color);
+    }
+
     @Override
     protected void dispatchDraw(Canvas canvas) {
         // Draw the dividers
@@ -2897,6 +2916,7 @@
             mClipDivider = false;
         }
         mDivider = divider;
+        mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
         requestLayoutIfNecessary();
     }
 
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index c4f0abd..edbb3db 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -823,7 +823,7 @@
             @ViewDebug.IntToString(from = RIGHT_OF,            to = "rightOf")
         }, mapping = {
             @ViewDebug.IntToString(from = TRUE, to = "true"),
-            @ViewDebug.IntToString(from = 0,    to = "NO_ID")
+            @ViewDebug.IntToString(from = 0,    to = "FALSE/NO_ID")
         })
         private int[] mRules = new int[VERB_COUNT];
 
diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp
index 00d6cd9..1dc0314 100644
--- a/core/jni/android/graphics/Region.cpp
+++ b/core/jni/android/graphics/Region.cpp
@@ -102,6 +102,36 @@
         rgn->translate(x, y);
 }
 
+// Scale the rectangle by given scale and set the reuslt to the dst.
+static void scale_rect(SkIRect* dst, const SkIRect& src, float scale) {
+   dst->fLeft = (int)::roundf(src.fLeft * scale);
+   dst->fTop = (int)::roundf(src.fTop * scale);
+   dst->fRight = (int)::roundf(src.fRight * scale);
+   dst->fBottom = (int)::roundf(src.fBottom * scale);
+}
+
+// Scale the region by given scale and set the reuslt to the dst.
+// dest and src can be the same region instance.
+static void scale_rgn(SkRegion* dst, const SkRegion& src, float scale) {
+   SkRegion tmp;
+   SkRegion::Iterator iter(src);
+
+   for (; !iter.done(); iter.next()) {
+       SkIRect r;
+       scale_rect(&r, iter.rect(), scale);
+       tmp.op(r, SkRegion::kUnion_Op);
+   }
+   dst->swap(tmp);
+}
+
+static void Region_scale(JNIEnv* env, jobject region, jfloat scale, jobject dst) {
+    SkRegion* rgn = GetSkRegion(env, region);
+    if (dst)
+        scale_rgn(GetSkRegion(env, dst), *rgn, scale);
+    else
+        scale_rgn(rgn, *rgn, scale);
+}
+
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 #include "Parcel.h"
@@ -139,6 +169,13 @@
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
+static jboolean Region_equals(JNIEnv* env, jobject clazz, const SkRegion *r1, const SkRegion* r2)
+{
+  return (jboolean) (*r1 == *r2);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 struct RgnIterPair {
     SkRegion            fRgn;   // a copy of the caller's region
     SkRegion::Iterator  fIter;  // an iterator acting upon the copy (fRgn)
@@ -206,10 +243,12 @@
     { "quickContains",          "(IIII)Z",                          (void*)Region_quickContains     },
     { "quickReject",            "(IIII)Z",                          (void*)Region_quickRejectIIII   },
     { "quickReject",            "(Landroid/graphics/Region;)Z",     (void*)Region_quickRejectRgn    },
+    { "scale",                  "(FLandroid/graphics/Region;)V",    (void*)Region_scale             },
     { "translate",              "(IILandroid/graphics/Region;)V",   (void*)Region_translate         },
     // parceling methods
     { "nativeCreateFromParcel", "(Landroid/os/Parcel;)I",           (void*)Region_createFromParcel  },
-    { "nativeWriteToParcel",    "(ILandroid/os/Parcel;)Z",          (void*)Region_writeToParcel     }
+    { "nativeWriteToParcel",    "(ILandroid/os/Parcel;)Z",          (void*)Region_writeToParcel     },
+    { "nativeEquals",           "(II)Z",                            (void*)Region_equals            },
 };
 
 int register_android_graphics_Region(JNIEnv* env);
diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp
index e951431..21dde63 100644
--- a/core/jni/android/graphics/Typeface.cpp
+++ b/core/jni/android/graphics/Typeface.cpp
@@ -133,6 +133,14 @@
     return SkTypeface::CreateFromStream(new AssetStream(asset, true));
 }
 
+static SkTypeface* Typeface_createFromFile(JNIEnv* env, jobject, jstring jpath) {
+    NPE_CHECK_RETURN_ZERO(env, jpath);
+
+    AutoJavaStringToUTF8 str(env, jpath);
+
+    return SkTypeface::CreateFromFile(str.c_str());
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 static JNINativeMethod gTypefaceMethods[] = {
@@ -140,9 +148,10 @@
     { "nativeCreateFromTypeface", "(II)I", (void*)Typeface_createFromTypeface },
     { "nativeUnref",              "(I)V",  (void*)Typeface_unref },
     { "nativeGetStyle",           "(I)I",  (void*)Typeface_getStyle },
-    { "nativeCreateFromAsset",
-                        "(Landroid/content/res/AssetManager;Ljava/lang/String;)I",
-                                            (void*)Typeface_createFromAsset }
+    { "nativeCreateFromAsset",    "(Landroid/content/res/AssetManager;Ljava/lang/String;)I",
+                                           (void*)Typeface_createFromAsset },
+    { "nativeCreateFromFile",     "(Ljava/lang/String;)I",
+                                           (void*)Typeface_createFromFile }
 };
 
 int register_android_graphics_Typeface(JNIEnv* env);
@@ -153,4 +162,3 @@
                                                        gTypefaceMethods,
                                                        SK_ARRAY_COUNT(gTypefaceMethods));
 }
-
diff --git a/core/jni/android_location_GpsLocationProvider.cpp b/core/jni/android_location_GpsLocationProvider.cpp
index 9c63fd2..004b0e3 100644
--- a/core/jni/android_location_GpsLocationProvider.cpp
+++ b/core/jni/android_location_GpsLocationProvider.cpp
@@ -31,31 +31,31 @@
 static jmethodID method_reportLocation;
 static jmethodID method_reportStatus;
 static jmethodID method_reportSvStatus;
-static jmethodID method_reportSuplStatus;
+static jmethodID method_reportAGpsStatus;
 static jmethodID method_xtraDownloadRequest;
 
 static const GpsInterface* sGpsInterface = NULL;
 static const GpsXtraInterface* sGpsXtraInterface = NULL;
-static const GpsSuplInterface* sGpsSuplInterface = NULL;
+static const AGpsInterface* sAGpsInterface = NULL;
 
 // data written to by GPS callbacks
 static GpsLocation  sGpsLocation;
 static GpsStatus    sGpsStatus;
 static GpsSvStatus  sGpsSvStatus;
-static GpsSuplStatus    sGpsSuplStatus;
+static AGpsStatus   sAGpsStatus;
 
 // a copy of the data shared by android_location_GpsLocationProvider_wait_for_event
 // and android_location_GpsLocationProvider_read_status
 static GpsLocation  sGpsLocationCopy;
 static GpsStatus    sGpsStatusCopy;
 static GpsSvStatus  sGpsSvStatusCopy;
-static GpsSuplStatus    sGpsSuplStatusCopy;
+static AGpsStatus   sAGpsStatusCopy;
 
 enum CallbackType {
     kLocation = 1,
     kStatus = 2,
     kSvStatus = 4,
-    kSuplStatus = 8,
+    kAGpsStatus = 8,
     kXtraDownloadRequest = 16,
     kDisableRequest = 32,
 }; 
@@ -96,12 +96,12 @@
     pthread_mutex_unlock(&sEventMutex);
 }
 
-static void supl_status_callback(GpsSuplStatus* supl_status)
+static void agps_status_callback(AGpsStatus* agps_status)
 {
     pthread_mutex_lock(&sEventMutex);
 
-    sPendingCallbacks |= kSuplStatus;
-    memcpy(&sGpsSuplStatus, supl_status, sizeof(GpsSuplStatus));
+    sPendingCallbacks |= kAGpsStatus;
+    memcpy(&sAGpsStatus, agps_status, sizeof(AGpsStatus));
 
     pthread_cond_signal(&sEventCond);
     pthread_mutex_unlock(&sEventMutex);
@@ -126,15 +126,15 @@
     download_request_callback,
 };
 
-GpsSuplCallbacks sGpsSuplCallbacks = {
-    supl_status_callback,
+AGpsCallbacks sAGpsCallbacks = {
+    agps_status_callback,
 };
 
 static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, jclass clazz) {
     method_reportLocation = env->GetMethodID(clazz, "reportLocation", "(IDDDFFFJ)V");
     method_reportStatus = env->GetMethodID(clazz, "reportStatus", "(I)V");
     method_reportSvStatus = env->GetMethodID(clazz, "reportSvStatus", "()V");
-    method_reportSuplStatus = env->GetMethodID(clazz, "reportSuplStatus", "(I)V");
+    method_reportAGpsStatus = env->GetMethodID(clazz, "reportAGpsStatus", "(II)V");
     method_xtraDownloadRequest = env->GetMethodID(clazz, "xtraDownloadRequest", "()V");
 }
 
@@ -151,10 +151,10 @@
     if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
         return false;
 
-    if (!sGpsSuplInterface)
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
-    if (sGpsSuplInterface)
-        sGpsSuplInterface->init(&sGpsSuplCallbacks);
+    if (!sAGpsInterface)
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
+    if (sAGpsInterface)
+        sAGpsInterface->init(&sAGpsCallbacks);
     return true;
 }
 
@@ -187,12 +187,6 @@
     return (sGpsInterface->stop() == 0);
 }
 
-static void android_location_GpsLocationProvider_set_fix_frequency(JNIEnv* env, jobject obj, jint fixFrequency)
-{
-    if (sGpsInterface->set_fix_frequency)
-        sGpsInterface->set_fix_frequency(fixFrequency);
-}
-
 static void android_location_GpsLocationProvider_delete_aiding_data(JNIEnv* env, jobject obj, jint flags)
 {
     sGpsInterface->delete_aiding_data(flags);
@@ -212,7 +206,7 @@
     memcpy(&sGpsLocationCopy, &sGpsLocation, sizeof(sGpsLocationCopy));
     memcpy(&sGpsStatusCopy, &sGpsStatus, sizeof(sGpsStatusCopy));
     memcpy(&sGpsSvStatusCopy, &sGpsSvStatus, sizeof(sGpsSvStatusCopy));
-    memcpy(&sGpsSuplStatusCopy, &sGpsSuplStatus, sizeof(sGpsSuplStatusCopy));
+    memcpy(&sAGpsStatusCopy, &sAGpsStatus, sizeof(sAGpsStatusCopy));
     pthread_mutex_unlock(&sEventMutex);   
 
     if (pendingCallbacks & kLocation) { 
@@ -228,8 +222,8 @@
     if (pendingCallbacks & kSvStatus) {
         env->CallVoidMethod(obj, method_reportSvStatus);
     }
-    if (pendingCallbacks & kSuplStatus) {
-        env->CallVoidMethod(obj, method_reportSuplStatus, sGpsSuplStatusCopy.status);
+    if (pendingCallbacks & kAGpsStatus) {
+        env->CallVoidMethod(obj, method_reportAGpsStatus, sAGpsStatusCopy.type, sAGpsStatusCopy.status);
     }  
     if (pendingCallbacks & kXtraDownloadRequest) {    
         env->CallVoidMethod(obj, method_xtraDownloadRequest);
@@ -299,73 +293,72 @@
     env->ReleaseByteArrayElements(data, bytes, 0);
 }
 
-static void android_location_GpsLocationProvider_supl_data_conn_open(JNIEnv* env, jobject obj, jstring apn)
+static void android_location_GpsLocationProvider_agps_data_conn_open(JNIEnv* env, jobject obj, jstring apn)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
+    if (sAGpsInterface) {
         if (apn == NULL) {
             jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
             return;
         }
         const char *apnStr = env->GetStringUTFChars(apn, NULL);
-        sGpsSuplInterface->data_conn_open(apnStr);
+        sAGpsInterface->data_conn_open(apnStr);
         env->ReleaseStringUTFChars(apn, apnStr);
     }
 }
 
-static void android_location_GpsLocationProvider_supl_data_conn_closed(JNIEnv* env, jobject obj)
+static void android_location_GpsLocationProvider_agps_data_conn_closed(JNIEnv* env, jobject obj)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
-        sGpsSuplInterface->data_conn_closed();
+    if (sAGpsInterface) {
+        sAGpsInterface->data_conn_closed();
     }
 }
 
-static void android_location_GpsLocationProvider_supl_data_conn_failed(JNIEnv* env, jobject obj)
+static void android_location_GpsLocationProvider_agps_data_conn_failed(JNIEnv* env, jobject obj)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
-        sGpsSuplInterface->data_conn_failed();
+    if (sAGpsInterface) {
+        sAGpsInterface->data_conn_failed();
     }
 }
 
-static void android_location_GpsLocationProvider_set_supl_server(JNIEnv* env, jobject obj,
-        jint addr, jint port)
+static void android_location_GpsLocationProvider_set_agps_server(JNIEnv* env, jobject obj,
+        jint type, jint addr, jint port)
 {
-    if (!sGpsSuplInterface) {
-        sGpsSuplInterface = (const GpsSuplInterface*)sGpsInterface->get_extension(GPS_SUPL_INTERFACE);
+    if (!sAGpsInterface) {
+        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
     }
-    if (sGpsSuplInterface) {
-        sGpsSuplInterface->set_server(addr, port);
+    if (sAGpsInterface) {
+        sAGpsInterface->set_server(type, addr, port);
     }
 }
 
 static JNINativeMethod sMethods[] = {
      /* name, signature, funcPtr */
     {"class_init_native", "()V", (void *)android_location_GpsLocationProvider_class_init_native},
-	{"native_is_supported", "()Z", (void*)android_location_GpsLocationProvider_is_supported},
-	{"native_init", "()Z", (void*)android_location_GpsLocationProvider_init},
-	{"native_disable", "()V", (void*)android_location_GpsLocationProvider_disable},
-	{"native_cleanup", "()V", (void*)android_location_GpsLocationProvider_cleanup},
-	{"native_start", "(IZI)Z", (void*)android_location_GpsLocationProvider_start},
-	{"native_stop", "()Z", (void*)android_location_GpsLocationProvider_stop},
-	{"native_set_fix_frequency", "(I)V", (void*)android_location_GpsLocationProvider_set_fix_frequency},
-	{"native_delete_aiding_data", "(I)V", (void*)android_location_GpsLocationProvider_delete_aiding_data},
-	{"native_wait_for_event", "()V", (void*)android_location_GpsLocationProvider_wait_for_event},
-	{"native_read_sv_status", "([I[F[F[F[I)I", (void*)android_location_GpsLocationProvider_read_sv_status},
-	{"native_inject_time", "(JJI)V", (void*)android_location_GpsLocationProvider_inject_time},
-	{"native_supports_xtra", "()Z", (void*)android_location_GpsLocationProvider_supports_xtra},
-	{"native_inject_xtra_data", "([BI)V", (void*)android_location_GpsLocationProvider_inject_xtra_data},
- 	{"native_supl_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_supl_data_conn_open},
- 	{"native_supl_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_supl_data_conn_closed},
- 	{"native_supl_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_supl_data_conn_failed},
- 	{"native_set_supl_server", "(II)V", (void*)android_location_GpsLocationProvider_set_supl_server},
+    {"native_is_supported", "()Z", (void*)android_location_GpsLocationProvider_is_supported},
+    {"native_init", "()Z", (void*)android_location_GpsLocationProvider_init},
+    {"native_disable", "()V", (void*)android_location_GpsLocationProvider_disable},
+    {"native_cleanup", "()V", (void*)android_location_GpsLocationProvider_cleanup},
+    {"native_start", "(IZI)Z", (void*)android_location_GpsLocationProvider_start},
+    {"native_stop", "()Z", (void*)android_location_GpsLocationProvider_stop},
+    {"native_delete_aiding_data", "(I)V", (void*)android_location_GpsLocationProvider_delete_aiding_data},
+    {"native_wait_for_event", "()V", (void*)android_location_GpsLocationProvider_wait_for_event},
+    {"native_read_sv_status", "([I[F[F[F[I)I", (void*)android_location_GpsLocationProvider_read_sv_status},
+    {"native_inject_time", "(JJI)V", (void*)android_location_GpsLocationProvider_inject_time},
+    {"native_supports_xtra", "()Z", (void*)android_location_GpsLocationProvider_supports_xtra},
+    {"native_inject_xtra_data", "([BI)V", (void*)android_location_GpsLocationProvider_inject_xtra_data},
+    {"native_agps_data_conn_open", "(Ljava/lang/String;)V", (void*)android_location_GpsLocationProvider_agps_data_conn_open},
+    {"native_agps_data_conn_closed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_closed},
+    {"native_agps_data_conn_failed", "()V", (void*)android_location_GpsLocationProvider_agps_data_conn_failed},
+    {"native_set_agps_server", "(III)V", (void*)android_location_GpsLocationProvider_set_agps_server},
 };
 
 int register_android_location_GpsLocationProvider(JNIEnv* env)
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index b8d6586..42ada54 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -335,7 +335,7 @@
         jniThrowException(env, "java/lang/IllegalStateException",
             "Unable to retrieve AudioTrack pointer for start()");
     }
-    
+
     lpTrack->start();
 }
 
@@ -433,6 +433,45 @@
 
 
 // ----------------------------------------------------------------------------
+jint writeToTrack(AudioTrack* pTrack, jint audioFormat, jbyte* data,
+                  jint offsetInBytes, jint sizeInBytes) {
+    // give the data to the native AudioTrack object (the data starts at the offset)
+    ssize_t written = 0;
+    // regular write() or copy the data to the AudioTrack's shared memory?
+    if (pTrack->sharedBuffer() == 0) {
+        written = pTrack->write(data + offsetInBytes, sizeInBytes);
+    } else {
+        if (audioFormat == javaAudioTrackFields.PCM16) {
+            // writing to shared memory, check for capacity
+            if ((size_t)sizeInBytes > pTrack->sharedBuffer()->size()) {
+                sizeInBytes = pTrack->sharedBuffer()->size();
+            }
+            memcpy(pTrack->sharedBuffer()->pointer(), data + offsetInBytes, sizeInBytes);
+            written = sizeInBytes;
+        } else if (audioFormat == javaAudioTrackFields.PCM8) {
+            // data contains 8bit data we need to expand to 16bit before copying
+            // to the shared memory
+            // writing to shared memory, check for capacity,
+            // note that input data will occupy 2X the input space due to 8 to 16bit conversion
+            if (((size_t)sizeInBytes)*2 > pTrack->sharedBuffer()->size()) {
+                sizeInBytes = pTrack->sharedBuffer()->size() / 2;
+            }
+            int count = sizeInBytes;
+            int16_t *dst = (int16_t *)pTrack->sharedBuffer()->pointer();
+            const int8_t *src = (const int8_t *)(data + offsetInBytes);
+            while(count--) {
+                *dst++ = (int16_t)(*src++^0x80) << 8;
+            }
+            // even though we wrote 2*sizeInBytes, we only report sizeInBytes as written to hide
+            // the 8bit mixer restriction from the user of this function
+            written = sizeInBytes;
+        }
+    }
+    return written;
+
+}
+
+// ----------------------------------------------------------------------------
 static jint android_media_AudioTrack_native_write(JNIEnv *env,  jobject thiz,
                                                   jbyteArray javaAudioData,
                                                   jint offsetInBytes, jint sizeInBytes,
@@ -461,35 +500,13 @@
         return 0;
     }
 
-    // give the data to the native AudioTrack object (the data starts at the offset)
-    ssize_t written = 0;
-    // regular write() or copy the data to the AudioTrack's shared memory?
-    if (lpTrack->sharedBuffer() == 0) {
-        written = lpTrack->write(cAudioData + offsetInBytes, sizeInBytes);
-    } else {
-        if (javaAudioFormat == javaAudioTrackFields.PCM16) {
-            memcpy(lpTrack->sharedBuffer()->pointer(), cAudioData + offsetInBytes, sizeInBytes);
-            written = sizeInBytes;
-        } else if (javaAudioFormat == javaAudioTrackFields.PCM8) {
-            // cAudioData contains 8bit data we need to expand to 16bit before copying
-            // to the shared memory
-            int count = sizeInBytes;
-            int16_t *dst = (int16_t *)lpTrack->sharedBuffer()->pointer();
-            const int8_t *src = (const int8_t *)(cAudioData + offsetInBytes);            
-            while(count--) {
-                *dst++ = (int16_t)(*src++^0x80) << 8;
-            }
-            // even though we wrote 2*sizeInBytes, we only report sizeInBytes as written to hide
-            // the 8bit mixer restriction from the user of this function
-            written = sizeInBytes;
-        }
-    }
+    jint written = writeToTrack(lpTrack, javaAudioFormat, cAudioData, offsetInBytes, sizeInBytes);
 
     env->ReleasePrimitiveArrayCritical(javaAudioData, cAudioData, 0);
 
     //LOGV("write wrote %d (tried %d) bytes in the native AudioTrack with offset %d",
     //     (int)written, (int)(sizeInBytes), (int)offsetInBytes);
-    return (int)written;
+    return written;
 }
 
 
diff --git a/core/res/res/drawable/divider_horizontal_bright.9.png b/core/res/res/drawable/divider_horizontal_bright.9.png
index 144fc22..30c9b2b 100644
--- a/core/res/res/drawable/divider_horizontal_bright.9.png
+++ b/core/res/res/drawable/divider_horizontal_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_dark.9.png b/core/res/res/drawable/divider_horizontal_dark.9.png
index 08838ca..ce21acd 100644
--- a/core/res/res/drawable/divider_horizontal_dark.9.png
+++ b/core/res/res/drawable/divider_horizontal_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable/search_dropdown_background_apps.9.png b/core/res/res/drawable/search_dropdown_background_apps.9.png
new file mode 100644
index 0000000..56b697d
--- /dev/null
+++ b/core/res/res/drawable/search_dropdown_background_apps.9.png
Binary files differ
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 1319c77..7b48267 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -79,6 +79,13 @@
          by applications. -->
     <attr name="allowClearUserData" format="boolean" />
     
+    <!-- Option to indicate this application is only for testing purposes.
+         For example, it may expose functionality or data outside of itself
+         that would cause a security hole, but is useful for testing.  This
+         kind of application can not be installed without the
+         INSTALL_ALLOW_TEST flag, which means only through adb install.  -->
+    <attr name="testOnly" format="boolean" />
+    
     <!-- A unique name for the given item.  This must use a Java-style naming
          convention to ensure the name is unique, for example
          "com.mycompany.MyName". -->  
@@ -635,6 +642,7 @@
         <!-- Name of activity to be launched for managing the application's space on the device. -->
         <attr name="manageSpaceActivity" />
         <attr name="allowClearUserData" />
+        <attr name="testOnly" />
     </declare-styleable>
     
     <!-- The <code>permission</code> tag declares a security permission that can be
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index df5d879..f90c6b8 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1099,6 +1099,7 @@
    <public type="attr" name="onClick" id="0x0101026f" />
    <public type="attr" name="targetSdkVersion" id="0x01010270" />
    <public type="attr" name="maxSdkVersion" id="0x01010271" />
+   <public type="attr" name="testOnly" id="0x01010272" />
 
    <public type="anim" name="anticipate_interpolator" id="0x010a0007" />
    <public type="anim" name="overshoot_interpolator" id="0x010a0008" />
diff --git a/docs/html/community/index.jd b/docs/html/community/index.jd
index ab1599a..91c54aa 100644
--- a/docs/html/community/index.jd
+++ b/docs/html/community/index.jd
@@ -74,6 +74,14 @@
 </ul>
 </li>
 
+<li><b>Android ndk</b> - A place for discussing the Android NDK and topics related to using native code in Android applications. 
+<ul>
+<li>Subscribe using Google Groups:&nbsp;<a href="http://groups.google.com/group/android-ndk">android-ndk</a></li>
+<li>Subscribe via email:&nbsp;<a href="mailto:android-ndk-subscribe@googlegroups.com">android-ndk-subscribe@googlegroups.com</a><a href="mailto:android-platform-subscribe@googlegroups.com">
+    </a></li>
+</ul>
+</li>
+
 <li><b>Android security discuss</b> - A place for open discussion on secure development, emerging security concerns, and best practices for and by android developers. Please don't disclose vulnerabilities directly on this list, you'd be putting all Android users at risk.
 <ul>
 <li>Subscribe using Google Groups:&nbsp;<a href="http://groups.google.com/group/android-security-discuss">android-security-discuss</a></li>
diff --git a/docs/html/sdk/ndk/1.5-r1/index.jd b/docs/html/sdk/ndk/1.5-r1/index.jd
new file mode 100644
index 0000000..3d3137c
--- /dev/null
+++ b/docs/html/sdk/ndk/1.5-r1/index.jd
@@ -0,0 +1,311 @@
+ndk=true
+ndk.version=1.5
+ndk.rel.id=1
+ndk.date=May 2009
+
+ndk.win_download=android-ndk-1.5_r1-windows.zip
+ndk.win_bytes=22450814
+ndk.win_checksum=7b7836f705ec7e66225794edda34000f
+
+ndk.mac_download=android-ndk-1.5_r1-darwin-x86.zip
+ndk.mac_bytes=17165450
+ndk.mac_checksum=214ccfd704c0307609fbabeb7bf86acc
+
+ndk.linux_download=android-ndk-1.5_r1-linux-x86.zip
+ndk.linux_bytes=15976032
+ndk.linux_checksum=808fd4d6a7e45f76d546ba04ab9ef060
+
+ndk.linux_64_download=android-ndk-1.5_r1-linux-x86_64.zip
+ndk.linux_64_bytes=18112300
+ndk.linux_64_checksum=f8664c187b3ae077bcfe2b44294d0758
+
+page.title=Android 1.5 NDK, Release 1
+@jd:body
+
+<h2>What is the NDK?</h2>
+
+<p>The Android 1.5 NDK provides tools that allow Android application developers
+to embed and deploy native code within their Android applications. It
+provides:</p>
+
+<ul>
+<li>A set of tools and build files used to generate native code libraries from C
+and C++ sources</li>
+<li>A way to embed the corresponding native libraries into application package
+files (.apks) that can be deployed on Android devices</li>
+<li>A set of native system headers and libraries that will be supported in all
+future versions of the Android platform, starting from Android 1.5 </li>
+</ul>
+
+<p>This release of the NDK release supports the ARMv5TE machine instruction set
+and provides stable headers for libc (the C library), libm (the Math library)
+and the JNI interface.</p>
+
+<p>Using the NDK may not be relevant for all Android applications. As a
+developer, you will need to balance its benefits (faster execution) and its
+drawbacks (no portability, JNI overhead, no access to system libraries, and
+difficult debugging). Typical good candidates for the NDK are CPU-intensive
+operations that don't allocate too much memory, such as signal processing,
+physics simulation, custom bytecode/instruction interpreters, and so on.</p>
+
+<p>Please note that the NDK <em>does not</em> enable you to develop native-only
+applications. Android's primary runtime remains the Dalvik virtual machine.</p>
+
+<h2 id="contents">Contents of the NDK</h2>
+
+<h4>Development tools</h4>
+
+<p>The NDK includes a set of cross-toolchains (compilers, linkers, etc..) that
+can generate native ARM binaries on Linux, OS X, and Windows (with Cygwin)
+platforms.</p>
+
+<p>It provides a set of system headers for stable native APIs that are
+guaranteed to be supported in all later releases of the platform:</p>
+
+<ul>
+<li>libc (C library) headers</li>
+<li>libm (Math library) headers</li>
+<li>JNI interface headers</li>
+</ul>
+
+<p>The NDK also provides a build system that lets you work efficiently with your
+sources, without having to handle the toolchain/platform/CPU/ABI details. You
+create very short build files to describe which sources to compile and which
+Android application will use them &mdash; the build system compiles the sources
+and places the shared libraries directly in your application project. </p>
+
+<p class="caution"><strong>Important:</strong> With the exception of the
+libraries listed above, native system libraries in the Android 1.5 platform are
+<em>not</em> stable and may change in future platform versions.
+Your applications should <em>only</em> make use of the stable native system
+libraries provided in this NDK. </p>
+
+<h4>Documentation</h4>
+
+<p>The NDK package includes a set of documentation that describes the
+capabilities of the NDK and how to use it to create shared libraries for your
+Android applications. In this release, the documentation is provided only in the
+downloadable NDK package. You can find the documentation in the
+<code>&lt;ndk&gt;/docs/</code> directory. Included are these files:</p>
+
+<ul>
+<li>INSTALL.TXT &mdash; describes how to install the NDK and configure it for
+your host system</li>
+<li>OVERVIEW.TXT &mdash; provides an overview of the NDK capabilities and
+usage</li>
+<li>ANDROID-MK.TXT &mdash; describes the use of the Android.mk file, which
+defines the native sources you want to compile</li>
+<li>APPLICATION-MK.TXT &mdash; describes the use of the Application.mk file,
+which describes the native sources required by your Android application</li>
+</ul>
+
+<h4>Sample applications</h4>
+
+<p>The NDK includes two sample Android applications that illustrate how to use
+native code in your Android applications:</p>
+
+<ul>
+<li><code>hello-jni</code> &mdash; A simple application that loads a string from
+a native method implemented in a shared library and then displays it in the
+application UI. </li>
+<li><code>two-libs</code> &mdash; A simple application that loads a shared
+library dynamically and calls a native method provided by the library. In this
+case, the method is implemented in a static library that is imported by the 
+shared library. </li>
+</ul>
+
+<p>For more information, see <a href="#samples">Using the Sample
+Applications</a>.</p>
+
+<h2 id="requirements">System and Software Requirements</h2>
+
+<p>The sections below describe the system and software requirements for using
+the Android NDK, as well as platform compatibility considerations that affect
+appplications using libraries produced with the NDK. </p>
+
+<h4>The Android SDK</h4>
+<ul>
+  <li>A complete Android SDK installation (including all dependencies) is
+required.</li>
+  <li>Android 1.5 SDK or later version is required.</li>
+</ul>
+
+<h4>Supported operating systems</h4>
+<ul>
+  <li>Windows XP (32-bit) or Vista (32- or 64-bit)</li>
+  <li>Mac OS X 10.4.8 or later (x86 only)</li>
+  <li>Linux (32- or 64-bit, tested on Linux Ubuntu Dapper Drake)</li>
+</ul>
+
+<h4>Required development tools</h4>
+<ul>
+  <li>For all development platforms, GNU Make 3.81 or later is required. Earlier
+versions of GNU Make might work but have not been tested.</li>
+  <li>For Windows, a recent release of <a
+href="http://www.cygwin.com">Cygwin</a> is required.</li>
+</ul>
+
+<h4>Android platform compatibility</h4>
+<ul>
+  <li>The native libraries created by the Android NDK can only be used on
+devices running the Android 1.5 platform version or later. This is due to subtle
+toolchain and ABI related changes that make the native libraries incompatible
+with 1.0 and 1.1 system images.</li>
+  <li>For this reason, you should use native libraries produced with the NDK in
+applications that are deployable to devices running the Android 1.5 platform
+version or later. To ensure compatibility, an application using a native library
+produced with the NDK must declare a <code>&lt;uses-library&gt;</code> element
+in its manifest file, with the attribute
+<code>android:minSdkVersion="3"</code>.</li>
+</ul>
+
+<h2 id="installing">Installing the NDK</h2>
+
+<p>Installing the NDK on your development computer is straightforward and
+involves extracting the NDK from its download package and running a host-setup
+script. </p>
+
+<p>Before you get started make sure that you have downloaded the latest <a
+href="{@docRoot}sdk/index.html">Android SDK</a> and upgraded your applications
+and environment as needed. The NDK will not work with older versions of the
+Android SDK. Also, take a moment to review the <a href="#requirements">System
+and Software Requirements</a> for the NDK, if you haven't already. </p>
+
+<p>To install the NDK, follow these steps:</p>
+
+<ol>
+<li>From the table at the top of this page, select the NDK package that is
+appropriate for your development computer and download the package.</li>
+<li>Uncompress the NDK download package using tools available on your computer.
+When uncompressed, the NDK files are contained in a directory called
+<code>android-ndk-&lt;version&gt;</code>. You can rename the NDK directory if
+necessary and you can move it to any location on your computer. This
+documentation refers to the NDK directory as <code>&lt;ndk&gt;</code>.  </li>
+<li>Open a terminal, change to the NDK directory, and run the host-setup script.
+The script sets up your environment and generates a host configuration file used
+later, when building your shared libraries. The path to the host-setup script
+is:
+
+<p><code>&lt;ndk&gt;/build/host-setup.sh</code></p>
+
+<p>If the script completes successfully, it prints a "Host setup complete."
+message. If it fails, it prints instructions that you can follow to correct any
+problems. </p>
+</li>
+</ol>
+
+<p>Once you have run the host-setup script, you are ready start working with the
+NDK. </p>
+
+<h2 id="gettingstarted">Getting Started with the NDK</h2>
+
+<p>Once you've installed the NDK successfully, take a few minutes to read the
+documentation included in the NDK. You can find the documentation in the
+<code>&lt;ndk&gt;/docs/</code> directory. In particular, please read the
+OVERVIEW.TXT document completely, so that you understand the intent of the NDK
+and how to use it.</p>
+
+<p>Here's the general outline of how you work with the NDK tools:</p>
+
+<ol>
+<li>Place your native sources under
+<code>&lt;ndk&gt;/sources/&lt;my_src&gt;/...</code>. If you want, you can place
+a symlink to your sources, rather than the sources themselves. The sources you
+reference here are not strictly associated with a specific shared library or
+Android application. Instead, they are accessible to any build configuration and
+can be used to produce any number of shared libraries that can be used by any
+Android application.</li>
+<li>Create <code>&lt;ndk&gt;/sources/&lt;my_src&gt;/Android.mk</code> to
+describe your native sources to the NDK build system</li>
+<li>Create <code>&lt;ndk&gt;/apps/&lt;my_app&gt;/Application.mk</code> to
+describe your Android application and native sources it needs to the NDK build
+system. This file sets up the link between an Android SDK application project
+and any number of shared libraries defined in the
+<code>&lt;ndk&gt;/sources/</code> folder and it specifies the path to the
+application project that will receive the shared library built from the
+sources.</li>
+<li>Build your native code by running this make command from the top-level NDK
+directory:
+
+<p><code>$ make APP=&lt;my_app&gt;</code></p>
+
+<p>The build tools copy the stripped, shared libraries needed by your
+application to the proper location in the application's project directory.</p>
+</li>
+
+<li>Finally, compile your application using the SDK tools in the usual way. The
+SDK build tools will package the shared libraries in the application's
+deployable .apk file. </p></li>
+
+</ol>
+
+<p>For complete information on all of the steps listed above, please see the
+documentation included with the NDK package. </p>
+
+
+<h2 id="samples">Using the Sample Applications</h2>
+
+<p>The NDK includes two sample applications that illustrate how to use native
+code in your Android applications:</p>
+
+<ul>
+<li><code>hello-jni</code> &mdash; A simple application that loads a string from
+a native method implemented in a shared library and then displays it in the
+application UI. </li>
+<li><code>two-libs</code> &mdash; A simple application that loads a shared
+library dynamically and calls a native method provided by the library. In this
+case, the method is implemented in a static library imported by the shared
+library. </li>
+</ul>
+
+<p>For each sample, the NDK includes an Android application project, as well as
+the corresponding C source code and the necessary Android.mk and Application.mk
+files. The application projects are provided in
+<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/</code> and the C source for
+each application is provided in
+<code>&lt;ndk&gt;/sources/samples/&lt;library&gt;/</code>.</p>
+
+<p>Once you have installed the NDK, you can build the shared libraries from the
+NDK by using these commands from the root of the NDK directory:</p>
+<ul>
+<li><code>$ make APP=hello-jni</code> &mdash; compiles
+<code>&lt;ndk&gt;/sources/samples/hello-jni/hello-jni.c</code> and outputs a
+shared library to
+<code>&lt;ndk&gt;/apps/hello-jni/project/libs/armeabi/libhello-jni.so</code>.
+</li>
+<li><code>$ make APP=two-libs</code> &mdash; compiles
+<code>&lt;ndk&gt;/sources/samples/two-libs/second.c</code> and
+<code>first.c</code> and outputs a shared library to
+<code>&lt;ndk&gt;/apps/two-libs/project/libs/armeabi/libtwolib-second.so</code>.
+</li>
+</ul>
+
+<p>Next, build the sample Android applications that use the shared
+libraries:</p>
+
+<ul>
+<li>If you are developing in Eclipse with ADT, use the New Project Wizard to
+create a new Android project for each sample, using the "Import from Existing
+Source" option and importing the source from 
+<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/</code>. Then, set up an AVD, if
+necessary, and build/run the application in the emulator. For more information
+about creating a new Android project in Eclipse, see <a
+href="{@docRoot}guide/developing/eclipse-adt.html">Developing in
+Eclipse</a>.</li>
+<li>If you are developing with Ant, use the <code>android</code> tool to create
+the build file for each of the sample projects at
+<code>&lt;ndk&gt;/apps/&lt;app_name&gt;/project/</code>. Then set up an AVD, if
+necessary, build your project in the usual way, and run it in the emulator. 
+For more information, see <a
+href="{@docRoot}guide/developing/other-ide.html">Developing in Other
+IDEs</a>.</li>
+</ul>
+
+<h2>Discussion Forum and Mailing List</h2>
+
+<p>If you have questions about the NDK or would like to read or contribute to
+discussions about it, please visit the <a
+href="http://groups.google.com/group/android-ndk">android-ndk</a> group and 
+mailing list.</p>
+
+
diff --git a/docs/html/sdk/sdk_toc.cs b/docs/html/sdk/sdk_toc.cs
index 1e5122f..4b55b56 100644
--- a/docs/html/sdk/sdk_toc.cs
+++ b/docs/html/sdk/sdk_toc.cs
@@ -27,6 +27,12 @@
     </ul>
   </li>
   <li>
+    <h2>Native Development Tools</h2>
+    <ul>
+      <li><a href="<?cs var:toroot ?>sdk/ndk/1.5-r1/index.html">Android 1.5 NDK, r1</a></li>
+    </ul>
+  </li>
+  <li>
     <h2>Previous SDK Releases</h2>
     <ul>
       <li><a href="<?cs var:toroot ?>sdk/1.1_r1/index.html">Android 1.1 SDK, r1</a></li>
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 81980d9..862e827 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1084,8 +1084,9 @@
      * not null, return in it the actual width measured.
      *
      * @param text  The text to measure
-     * @param measureForwards If true, measure forwards, starting at index.
-     *                        Otherwise, measure backwards, starting with the
+     * @param measureForwards If true, measure forwards, starting with the
+     *                        first character in the string. Otherwise,
+     *                        measure backwards, starting with the
      *                        last character in the string.
      * @param maxWidth The maximum width to accumulate.
      * @param measuredWidth Optional. If not null, returns the actual width
diff --git a/graphics/java/android/graphics/Region.java b/graphics/java/android/graphics/Region.java
index 544ff4f..2b080aa 100644
--- a/graphics/java/android/graphics/Region.java
+++ b/graphics/java/android/graphics/Region.java
@@ -211,6 +211,26 @@
      */
     public native void translate(int dx, int dy, Region dst);
 
+    /**
+     * Scale the region by the given scale amount. This re-constructs new region by
+     * scaling the rects that this region consists of. New rectis are computed by scaling 
+     * coordinates by float, then rounded by roundf() function to integers. This may results
+     * in less internal rects if 0 < scale < 1. Zero and Negative scale result in
+     * an empty region. If this region is empty, do nothing.
+     *
+     * @hide
+     */
+    public void scale(float scale) {
+        scale(scale, null);
+    }
+
+    /**
+     * Set the dst region to the result of scaling this region by the given scale amount.
+     * If this region is empty, then dst will be set to empty.
+     * @hide
+     */
+    public native void scale(float scale, Region dst);
+
     public final boolean union(Rect r) {
         return op(r, Op.UNION);
     }
@@ -294,7 +314,16 @@
             throw new RuntimeException();
         }
     }
-    
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null || !(obj instanceof Region)) {
+            return false;
+        }
+        Region peer = (Region) obj;
+        return nativeEquals(mNativeRegion, peer.mNativeRegion);
+    }
+
     protected void finalize() throws Throwable {
         nativeDestructor(mNativeRegion);
     }
@@ -340,5 +369,7 @@
     private static native boolean nativeWriteToParcel(int native_region,
                                                       Parcel p);
 
+    private static native boolean nativeEquals(int native_r1, int native_r2);
+
     private final int mNativeRegion;
 }
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index c69c92c..e40e84a 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -18,6 +18,8 @@
 
 import android.content.res.AssetManager;
 
+import java.io.File;
+
 /**
  * The Typeface class specifies the typeface and intrinsic style of a font.
  * This is used in the paint, along with optionally Paint settings like
@@ -118,7 +120,27 @@
     public static Typeface createFromAsset(AssetManager mgr, String path) {
         return new Typeface(nativeCreateFromAsset(mgr, path));
     }
-    
+
+    /**
+     * Create a new typeface from the specified font file.
+     *
+     * @param path The path to the font data. 
+     * @return The new typeface.
+     */
+    public static Typeface createFromFile(File path) {
+        return new Typeface(nativeCreateFromFile(path.getAbsolutePath()));
+    }
+
+    /**
+     * Create a new typeface from the specified font file.
+     *
+     * @param path The full path to the font data. 
+     * @return The new typeface.
+     */
+    public static Typeface createFromFile(String path) {
+        return new Typeface(nativeCreateFromFile(path));
+    }
+
     // don't allow clients to call this directly
     private Typeface(int ni) {
         native_instance = ni;
@@ -140,14 +162,14 @@
     }
 
     protected void finalize() throws Throwable {
+        super.finalize();
         nativeUnref(native_instance);
     }
 
     private static native int  nativeCreate(String familyName, int style);
-    private static native int  nativeCreateFromTypeface(int native_instance,
-                                                        int style);
+    private static native int  nativeCreateFromTypeface(int native_instance, int style); 
     private static native void nativeUnref(int native_instance);
     private static native int  nativeGetStyle(int native_instance);
-    private static native int  nativeCreateFromAsset(AssetManager mgr,
-                                                     String path);
+    private static native int  nativeCreateFromAsset(AssetManager mgr, String path);
+    private static native int nativeCreateFromFile(String path);
 }
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index 29f2a00..f8b88d0 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -181,7 +181,8 @@
 
     @Override
     public int getOpacity() {
-        return mDrawableContainerState.getOpacity();
+        return mCurrDrawable == null || !mCurrDrawable.isVisible() ? PixelFormat.TRANSPARENT :
+                mDrawableContainerState.getOpacity();
     }
 
     public boolean selectDrawable(int idx)
@@ -336,13 +337,11 @@
             return pos;
         }
 
-        public final int getChildCount()
-        {
+        public final int getChildCount() {
             return mNumChildren;
         }
 
-        public final Drawable[] getChildren()
-        {
+        public final Drawable[] getChildren() {
             return mDrawables;
         }
 
@@ -350,13 +349,11 @@
           * all frames in the set (false), or to use the padding value of the frame 
           * being shown (true). Default value is false. 
           */
-        public final void setVariablePadding(boolean variable)
-        {
+        public final void setVariablePadding(boolean variable) {
             mVariablePadding = variable;
         }
 
-        public final Rect getConstantPadding()
-        {
+        public final Rect getConstantPadding() {
             if (mVariablePadding) {
                 return null;
             }
@@ -364,11 +361,12 @@
                 return mConstantPadding;
             }
 
-            Rect r = new Rect(0, 0, 0, 0);
-            Rect t = new Rect();
+            final Rect r = new Rect(0, 0, 0, 0);
+            final Rect t = new Rect();
             final int N = getChildCount();
-            for (int i=0; i<N; i++) {
-                if (mDrawables[i].getPadding(t)) {
+            final Drawable[] drawables = mDrawables;
+            for (int i = 0; i < N; i++) {
+                if (drawables[i].getPadding(t)) {
                     if (t.left > r.left) r.left = t.left;
                     if (t.top > r.top) r.top = t.top;
                     if (t.right > r.right) r.right = t.right;
@@ -378,18 +376,15 @@
             return (mConstantPadding=r);
         }
 
-        public final void setConstantSize(boolean constant)
-        {
+        public final void setConstantSize(boolean constant) {
             mConstantSize = constant;
         }
 
-        public final boolean isConstantSize()
-        {
+        public final boolean isConstantSize() {
             return mConstantSize;
         }
 
-        public final int getConstantWidth()
-        {
+        public final int getConstantWidth() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -397,8 +392,7 @@
             return mConstantWidth;
         }
 
-        public final int getConstantHeight()
-        {
+        public final int getConstantHeight() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -406,8 +400,7 @@
             return mConstantHeight;
         }
 
-        public final int getConstantMinimumWidth()
-        {
+        public final int getConstantMinimumWidth() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -415,8 +408,7 @@
             return mConstantMinimumWidth;
         }
 
-        public final int getConstantMinimumHeight()
-        {
+        public final int getConstantMinimumHeight() {
             if (!mComputedConstantSize) {
                 computeConstantSize();
             }
@@ -424,15 +416,15 @@
             return mConstantMinimumHeight;
         }
 
-        private void computeConstantSize()
-        {
+        private void computeConstantSize() {
             mComputedConstantSize = true;
 
             final int N = getChildCount();
+            final Drawable[] drawables = mDrawables;
             mConstantWidth = mConstantHeight = 0;
             mConstantMinimumWidth = mConstantMinimumHeight = 0;
-            for (int i=0; i<N; i++) {
-                Drawable dr = mDrawables[i];
+            for (int i = 0; i < N; i++) {
+                Drawable dr = drawables[i];
                 int s = dr.getIntrinsicWidth();
                 if (s > mConstantWidth) mConstantWidth = s;
                 s = dr.getIntrinsicHeight();
@@ -444,23 +436,22 @@
             }
         }
 
-        public final int getOpacity()
-        {
+        public final int getOpacity() {
             if (mHaveOpacity) {
                 return mOpacity;
             }
 
             final int N = getChildCount();
-            int op = N > 0
-                ? mDrawables[0].getOpacity() : PixelFormat.TRANSPARENT;
-            for (int i=1; i<N; i++) {
-                op = Drawable.resolveOpacity(op, mDrawables[i].getOpacity());
+            final Drawable[] drawables = mDrawables;
+            int op = N > 0 ? drawables[0].getOpacity() : PixelFormat.TRANSPARENT;
+            for (int i = 1; i < N; i++) {
+                op = Drawable.resolveOpacity(op, drawables[i].getOpacity());
             }
             mOpacity = op;
             mHaveOpacity = true;
             return op;
         }
-        
+
         public final boolean isStateful() {
             if (mHaveStateful) {
                 return mStateful;
@@ -480,8 +471,7 @@
             return stateful;
         }
 
-        public void growArray(int oldSize, int newSize)
-        {
+        public void growArray(int oldSize, int newSize) {
             Drawable[] newDrawables = new Drawable[newSize];
             System.arraycopy(mDrawables, 0, newDrawables, 0, oldSize);
             mDrawables = newDrawables;
diff --git a/include/ui/Camera.h b/include/ui/Camera.h
index 901c7a9..048bdd5 100644
--- a/include/ui/Camera.h
+++ b/include/ui/Camera.h
@@ -63,6 +63,23 @@
 #define FRAME_CALLBACK_FLAG_CAMERA                   0x05
 #define FRAME_CALLBACK_FLAG_BARCODE_SCANNER          0x07
 
+// msgType in notifyCallback function
+enum {
+    CAMERA_MSG_ERROR,
+    CAMERA_MSG_SHUTTER,
+    CAMERA_MSG_FOCUS,
+    CAMERA_MSG_ZOOM
+};
+
+// msgType in dataCallback function
+enum {
+    CAMERA_MSG_PREVIEW_FRAME,
+    CAMERA_MSG_VIDEO_FRAME,
+    CAMERA_MSG_POSTVIEW_FRAME,
+    CAMERA_MSG_RAW_IMAGE,
+    CAMERA_MSG_COMPRESSED_IMAGE
+};
+
 class ICameraService;
 class ICamera;
 class Surface;
@@ -136,15 +153,8 @@
             void        setAutoFocusCallback(autofocus_callback cb, void *cookie);
 
     // ICameraClient interface
-    virtual void        shutterCallback();
-    virtual void        rawCallback(const sp<IMemory>& picture);
-    virtual void        jpegCallback(const sp<IMemory>& picture);
-    virtual void        previewCallback(const sp<IMemory>& frame);
-    virtual void        errorCallback(status_t error);
-    virtual void        autoFocusCallback(bool focused);
-    virtual void        recordingCallback(const sp<IMemory>& frame);
     virtual void        notifyCallback(int32_t msgType, int32_t ext, int32_t ext2);
-    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& frame);
+    virtual void        dataCallback(int32_t msgType, const sp<IMemory>& dataPtr);
 
     sp<ICamera>         remote();
 
diff --git a/include/ui/ICameraClient.h b/include/ui/ICameraClient.h
index 1645ef8..c4bdd07 100644
--- a/include/ui/ICameraClient.h
+++ b/include/ui/ICameraClient.h
@@ -29,30 +29,6 @@
 public:
     DECLARE_META_INTERFACE(CameraClient);
 
-    // msgType in notifyCallback function
-    enum {
-        ERROR,
-        SHUTTER,
-        FOCUSED,
-        ZOOM
-    } notify_callback_message_type;
-
-    // msgType in dataCallback function
-    enum {
-        PREVIEW,
-        RECORD,
-        POSTVIEW,
-        RAW,
-        COMPRESSED
-    } data_callback_message_type;
-
-    virtual void            shutterCallback() = 0;
-    virtual void            rawCallback(const sp<IMemory>& picture) = 0;
-    virtual void            jpegCallback(const sp<IMemory>& picture) = 0;
-    virtual void            previewCallback(const sp<IMemory>& frame) = 0;
-    virtual void            errorCallback(status_t error) = 0;
-    virtual void            autoFocusCallback(bool focused) = 0;
-    virtual void            recordingCallback(const sp<IMemory>& frame) = 0;
     virtual void            notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
     virtual void            dataCallback(int32_t msgType, const sp<IMemory>& data) = 0;
 
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index ed4f3b8..6613700 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -337,76 +337,66 @@
     mErrorCallbackCookie = cookie;
 }
 
-void Camera::autoFocusCallback(bool focused)
-{
-    LOGV("autoFocusCallback");
-    if (mAutoFocusCallback) {
-        mAutoFocusCallback(focused, mAutoFocusCallbackCookie);
-    }
-}
-
-void Camera::shutterCallback()
-{
-    LOGV("shutterCallback");
-    if (mShutterCallback) {
-        mShutterCallback(mShutterCallbackCookie);
-    }
-}
-
-void Camera::rawCallback(const sp<IMemory>& picture)
-{
-    LOGV("rawCallback");
-    if (mRawCallback) {
-        mRawCallback(picture, mRawCallbackCookie);
-    }
-}
-
-// callback from camera service when image is ready
-void Camera::jpegCallback(const sp<IMemory>& picture)
-{
-    LOGV("jpegCallback");
-    if (mJpegCallback) {
-        mJpegCallback(picture, mJpegCallbackCookie);
-    }
-}
-
-// callback from camera service when preview frame is ready
-void Camera::previewCallback(const sp<IMemory>& frame)
-{
-    LOGV("frameCallback");
-    if (mPreviewCallback) {
-        mPreviewCallback(frame, mPreviewCallbackCookie);
-    }
-}
-
-// callback from camera service when a recording frame is ready
-void Camera::recordingCallback(const sp<IMemory>& frame)
-{
-    LOGV("recordingCallback");
-    if (mRecordingCallback) {
-        mRecordingCallback(frame, mRecordingCallbackCookie);
-    }
-}
-
-// callback from camera service when an error occurs in preview or takePicture
-void Camera::errorCallback(status_t error)
-{
-    LOGV("errorCallback");
-    if (mErrorCallback) {
-        mErrorCallback(error, mErrorCallbackCookie);
-    }
-}
-
 // callback from camera service
 void Camera::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
 {
-    LOGV("notifyCallback");
+    switch(msgType) {
+    case CAMERA_MSG_ERROR:
+        LOGV("errorCallback");
+        if (mErrorCallback) {
+            mErrorCallback((status_t)ext1, mErrorCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_FOCUS:
+        LOGV("autoFocusCallback");
+        if (mAutoFocusCallback) {
+            mAutoFocusCallback((bool)ext1, mAutoFocusCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_SHUTTER:
+        LOGV("shutterCallback");
+        if (mShutterCallback) {
+            mShutterCallback(mShutterCallbackCookie);
+        }
+        break;
+    default:
+        LOGV("notifyCallback(%d, %d, %d)", msgType, ext1, ext2);
+        break;
+    }
 }
 
-// callback from camera service when image is ready
-void Camera::dataCallback(int32_t msgType, const sp<IMemory>& frame)
+// callback from camera service when frame or image is ready
+void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr)
 {
-    LOGV("dataCallback");
+    switch(msgType) {
+    case CAMERA_MSG_PREVIEW_FRAME:
+        LOGV("previewCallback");
+        if (mPreviewCallback) {
+            mPreviewCallback(dataPtr, mPreviewCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_VIDEO_FRAME:
+        LOGV("recordingCallback");
+        if (mRecordingCallback) {
+            mRecordingCallback(dataPtr, mRecordingCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_RAW_IMAGE:
+        LOGV("rawCallback");
+        if (mRawCallback) {
+            mRawCallback(dataPtr, mRawCallbackCookie);
+        }
+        break;
+    case CAMERA_MSG_COMPRESSED_IMAGE:
+        LOGV("jpegCallback");
+        if (mJpegCallback) {
+            mJpegCallback(dataPtr, mJpegCallbackCookie);
+        }
+        break;
+    default:
+        LOGV("dataCallback(%d, %p)", msgType, dataPtr.get());
+        break;
+    }
 }
 
 void Camera::binderDied(const wp<IBinder>& who) {
diff --git a/libs/ui/ICameraClient.cpp b/libs/ui/ICameraClient.cpp
index ae07b67..c6cf75c 100644
--- a/libs/ui/ICameraClient.cpp
+++ b/libs/ui/ICameraClient.cpp
@@ -25,14 +25,7 @@
 namespace android {
 
 enum {
-    SHUTTER_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
-    RAW_CALLBACK,
-    JPEG_CALLBACK,
-    PREVIEW_CALLBACK,
-    ERROR_CALLBACK,
-    AUTOFOCUS_CALLBACK,
-    RECORDING_CALLBACK,
-    NOTIFY_CALLBACK,
+    NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
     DATA_CALLBACK,
 };
 
@@ -44,75 +37,6 @@
     {
     }
 
-    // callback to let the app know the shutter has closed, ideal for playing the shutter sound
-    void shutterCallback()
-    {
-        LOGV("shutterCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        remote()->transact(SHUTTER_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with picture data
-    void rawCallback(const sp<IMemory>& picture)
-    {
-        LOGV("rawCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(picture->asBinder());
-        remote()->transact(RAW_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with picture data
-    void jpegCallback(const sp<IMemory>& picture)
-    {
-        LOGV("jpegCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(picture->asBinder());
-        remote()->transact(JPEG_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with preview frame data
-    void previewCallback(const sp<IMemory>& frame)
-    {
-        LOGV("previewCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(frame->asBinder());
-        remote()->transact(PREVIEW_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app with recording frame data
-    void recordingCallback(const sp<IMemory>& frame)
-    {
-        LOGV("recordingCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeStrongBinder(frame->asBinder());
-        remote()->transact(RECORDING_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app to report error
-    void errorCallback(status_t error)
-    {
-        LOGV("errorCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeInt32(error);
-        remote()->transact(ERROR_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // callback from camera service to app to report autofocus completion
-    void autoFocusCallback(bool focused)
-    {
-        LOGV("autoFocusCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
-        data.writeInt32(focused);
-        remote()->transact(AUTOFOCUS_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
     // generic callback from camera service to app
     void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2)
     {
@@ -152,54 +76,6 @@
     uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
 {
     switch(code) {
-        case SHUTTER_CALLBACK: {
-            LOGV("SHUTTER_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            shutterCallback();
-            return NO_ERROR;
-        } break;
-        case RAW_CALLBACK: {
-            LOGV("RAW_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> picture = interface_cast<IMemory>(data.readStrongBinder());
-            rawCallback(picture);
-            return NO_ERROR;
-        } break;
-        case JPEG_CALLBACK: {
-            LOGV("JPEG_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> picture = interface_cast<IMemory>(data.readStrongBinder());
-            jpegCallback(picture);
-            return NO_ERROR;
-        } break;
-        case PREVIEW_CALLBACK: {
-            LOGV("PREVIEW_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder());
-            previewCallback(frame);
-            return NO_ERROR;
-        } break;
-        case RECORDING_CALLBACK: {
-            LOGV("RECORDING_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder());
-            recordingCallback(frame);
-            return NO_ERROR;
-        } break;
-        case ERROR_CALLBACK: {
-            LOGV("ERROR_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            status_t error = data.readInt32();
-            errorCallback(error);
-            return NO_ERROR;
-        } break;
-        case AUTOFOCUS_CALLBACK: {
-            LOGV("AUTOFOCUS_CALLBACK");
-            CHECK_INTERFACE(ICameraClient, data, reply);
-            bool focused = (bool)data.readInt32();
-            autoFocusCallback(focused);
-            return NO_ERROR;
-        } break;
         case NOTIFY_CALLBACK: {
             LOGV("NOTIFY_CALLBACK");
             CHECK_INTERFACE(ICameraClient, data, reply);
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index aef8985..872838c 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -1257,7 +1257,7 @@
     }
 
     /**
-     * Installs a network location provider.
+     * Installs a location provider.
      *
      * @param name of the location provider
      * @param provider Binder interface for the location provider
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index 21c7adb..943d56c 100644
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -109,13 +109,13 @@
     private static final int GPS_STATUS_ENGINE_ON = 3;
     private static final int GPS_STATUS_ENGINE_OFF = 4;
 
-    // these need to match GpsSuplStatusValue defines in gps.h
-    /** SUPL status event values. */
-    private static final int GPS_REQUEST_SUPL_DATA_CONN = 1;
-    private static final int GPS_RELEASE_SUPL_DATA_CONN = 2;
-    private static final int GPS_SUPL_DATA_CONNECTED = 3;
-    private static final int GPS_SUPL_DATA_CONN_DONE = 4;
-    private static final int GPS_SUPL_DATA_CONN_FAILED = 5;
+    // these need to match GpsApgsStatusValue defines in gps.h
+    /** AGPS status event values. */
+    private static final int GPS_REQUEST_AGPS_DATA_CONN = 1;
+    private static final int GPS_RELEASE_AGPS_DATA_CONN = 2;
+    private static final int GPS_AGPS_DATA_CONNECTED = 3;
+    private static final int GPS_AGPS_DATA_CONN_DONE = 4;
+    private static final int GPS_AGPS_DATA_CONN_FAILED = 5;
 
     // these need to match GpsLocationFlags enum in gps.h
     private static final int LOCATION_INVALID = 0;
@@ -124,8 +124,8 @@
     private static final int LOCATION_HAS_SPEED = 4;
     private static final int LOCATION_HAS_BEARING = 8;
     private static final int LOCATION_HAS_ACCURACY = 16;
-    
-// IMPORTANT - the GPS_DELETE_* symbols here must match constants in GpsLocationProvider.java
+
+// IMPORTANT - the GPS_DELETE_* symbols here must match constants in gps.h
     private static final int GPS_DELETE_EPHEMERIS = 0x0001;
     private static final int GPS_DELETE_ALMANAC = 0x0002;
     private static final int GPS_DELETE_POSITION = 0x0004;
@@ -140,10 +140,14 @@
     private static final int GPS_DELETE_CELLDB_INFO = 0x8000;
     private static final int GPS_DELETE_ALL = 0xFFFF;
 
-    // for mSuplDataConnectionState
-    private static final int SUPL_DATA_CONNECTION_CLOSED = 0;
-    private static final int SUPL_DATA_CONNECTION_OPENING = 1;
-    private static final int SUPL_DATA_CONNECTION_OPEN = 2;
+    // these need to match AGpsType enum in gps.h
+    private static final int AGPS_TYPE_SUPL = 1;
+    private static final int AGPS_TYPE_C2K = 2;
+
+    // for mAGpsDataConnectionState
+    private static final int AGPS_DATA_CONNECTION_CLOSED = 0;
+    private static final int AGPS_DATA_CONNECTION_OPENING = 1;
+    private static final int AGPS_DATA_CONNECTION_OPEN = 2;
 
     private static final String PROPERTIES_FILE = "/etc/gps.conf";
 
@@ -203,9 +207,12 @@
 
     private String mSuplHost;
     private int mSuplPort;
+    private String mC2KHost;
+    private int mC2KPort;
     private boolean mSetSuplServer;
-    private String mSuplApn;
-    private int mSuplDataConnectionState;
+    private boolean mSetC2KServer;
+    private String mAGpsApn;
+    private int mAGpsDataConnectionState;
     private final ConnectivityManager mConnMgr;
 
     // Wakelocks
@@ -293,11 +300,12 @@
                 if (Config.LOGD) {
                     Log.d(TAG, "state: " + state +  " apnName: " + apnName + " reason: " + reason);
                 }
+                // FIXME - might not have an APN on CDMA
                 if ("CONNECTED".equals(state) && apnName != null && apnName.length() > 0) {
-                    mSuplApn = apnName;
-                    if (mSuplDataConnectionState == SUPL_DATA_CONNECTION_OPENING) {
-                        native_supl_data_conn_open(mSuplApn);
-                        mSuplDataConnectionState = SUPL_DATA_CONNECTION_OPEN;
+                    mAGpsApn = apnName;
+                    if (mAGpsDataConnectionState == AGPS_DATA_CONNECTION_OPENING) {
+                        native_agps_data_conn_open(mAGpsApn);
+                        mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
                     }
                 }
             }
@@ -336,14 +344,26 @@
             mProperties.load(stream);
             stream.close();
             mNtpServer = mProperties.getProperty("NTP_SERVER", null);
+
             mSuplHost = mProperties.getProperty("SUPL_HOST");
-            String suplPortString = mProperties.getProperty("SUPL_PORT");
-            if (mSuplHost != null && suplPortString != null) {
+            String portString = mProperties.getProperty("SUPL_PORT");
+            if (mSuplHost != null && portString != null) {
                 try {
-                    mSuplPort = Integer.parseInt(suplPortString);
+                    mSuplPort = Integer.parseInt(portString);
                     mSetSuplServer = true;
                 } catch (NumberFormatException e) {
-                    Log.e(TAG, "unable to parse SUPL_PORT: " + suplPortString);
+                    Log.e(TAG, "unable to parse SUPL_PORT: " + portString);
+                }
+            }
+
+            mC2KHost = mProperties.getProperty("C2K_HOST");
+            portString = mProperties.getProperty("C2K_PORT");
+            if (mC2KHost != null && portString != null) {
+                try {
+                    mC2KPort = Integer.parseInt(portString);
+                    mSetC2KServer = true;
+                } catch (NumberFormatException e) {
+                    Log.e(TAG, "unable to parse C2K_PORT: " + portString);
                 }
             }
         } catch (IOException e) {
@@ -358,7 +378,8 @@
     public boolean requiresNetwork() {
         // We want updateNetworkState() to get called when the network state changes
         // for XTRA and NTP time injection support.
-        return (mNtpServer != null || native_supports_xtra() || mSuplHost != null);
+        return (mNtpServer != null || native_supports_xtra() ||
+                mSuplHost != null || mC2KHost != null);
     }
 
     public void updateNetworkState(int state) {
@@ -561,7 +582,6 @@
                 interval = 1;
             }
             mFixInterval = interval;
-            native_set_fix_frequency(mFixInterval);
         }
     }
 
@@ -871,38 +891,38 @@
     }
 
     /**
-     * called from native code to update SUPL status
+     * called from native code to update AGPS status
      */
-    private void reportSuplStatus(int status) {
+    private void reportAGpsStatus(int type, int status) {
         switch (status) {
-            case GPS_REQUEST_SUPL_DATA_CONN:
+            case GPS_REQUEST_AGPS_DATA_CONN:
                  int result = mConnMgr.startUsingNetworkFeature(
                         ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
                 if (result == Phone.APN_ALREADY_ACTIVE) {
-                    native_supl_data_conn_open(mSuplApn);
-                    mSuplDataConnectionState = SUPL_DATA_CONNECTION_OPEN;
+                    native_agps_data_conn_open(mAGpsApn);
+                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
                 } else if (result == Phone.APN_REQUEST_STARTED) {
-                    mSuplDataConnectionState = SUPL_DATA_CONNECTION_OPENING;
+                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
                 } else {
-                    native_supl_data_conn_failed();
+                    native_agps_data_conn_failed();
                 }
                 break;
-            case GPS_RELEASE_SUPL_DATA_CONN:
-                if (mSuplDataConnectionState != SUPL_DATA_CONNECTION_CLOSED) {
+            case GPS_RELEASE_AGPS_DATA_CONN:
+                if (mAGpsDataConnectionState != AGPS_DATA_CONNECTION_CLOSED) {
                     mConnMgr.stopUsingNetworkFeature(
                             ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
-                    native_supl_data_conn_closed();
-                    mSuplDataConnectionState = SUPL_DATA_CONNECTION_CLOSED;
+                    native_agps_data_conn_closed();
+                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
                 }
                 break;
-            case GPS_SUPL_DATA_CONNECTED:
-                // Log.d(TAG, "GPS_SUPL_DATA_CONNECTED");
+            case GPS_AGPS_DATA_CONNECTED:
+                // Log.d(TAG, "GPS_AGPS_DATA_CONNECTED");
                 break;
-            case GPS_SUPL_DATA_CONN_DONE:
-                // Log.d(TAG, "GPS_SUPL_DATA_CONN_DONE");
+            case GPS_AGPS_DATA_CONN_DONE:
+                // Log.d(TAG, "GPS_AGPS_DATA_CONN_DONE");
                 break;
-            case GPS_SUPL_DATA_CONN_FAILED:
-                // Log.d(TAG, "GPS_SUPL_DATA_CONN_FAILED");
+            case GPS_AGPS_DATA_CONN_FAILED:
+                // Log.d(TAG, "GPS_AGPS_DATA_CONN_FAILED");
                 break;
         }
     }
@@ -914,6 +934,29 @@
         }
     }
 
+    private boolean setAGpsServer(int type, String host, int port) {
+        try {
+            InetAddress inetAddress = InetAddress.getByName(host);
+            if (inetAddress != null) {
+                byte[] addrBytes = inetAddress.getAddress();
+                long addr = 0;
+                for (int i = 0; i < addrBytes.length; i++) {
+                    int temp = addrBytes[i];
+                    // signed -> unsigned
+                    if (temp < 0) temp = 256 + temp;
+                    addr = addr * 256 + temp;
+                }
+                // use MS-Based position mode if SUPL support is enabled
+                mPositionMode = GPS_POSITION_MODE_MS_BASED;
+                native_set_agps_server(type, (int)addr, port);
+            }
+        } catch (UnknownHostException e) {
+            Log.e(TAG, "unknown host for server " + host);
+            return false;
+        }
+        return true;
+    }
+
     private class GpsEventThread extends Thread {
 
         public GpsEventThread() {
@@ -985,7 +1028,8 @@
                         }
                     }
                     waitTime = getWaitTime();
-                } while (!mDone && ((!mXtraDownloadRequested && !mSetSuplServer && waitTime > 0)
+                } while (!mDone && ((!mXtraDownloadRequested &&
+                        !mSetSuplServer && !mSetC2KServer && waitTime > 0)
                         || !mNetworkAvailable));
                 if (Config.LOGD) Log.d(TAG, "NetworkThread out of wake loop");
                 
@@ -1012,26 +1056,15 @@
                         }
                     }
 
-                    // Set the SUPL server address if we have not yet
+                    // Set the AGPS server addresses if we have not yet
                     if (mSetSuplServer) {
-                        try {
-                            InetAddress inetAddress = InetAddress.getByName(mSuplHost);
-                            if (inetAddress != null) {
-                                byte[] addrBytes = inetAddress.getAddress();
-                                long addr = 0;
-                                for (int i = 0; i < addrBytes.length; i++) {
-                                    int temp = addrBytes[i];
-                                    // signed -> unsigned
-                                    if (temp < 0) temp = 256 + temp;
-                                    addr = addr * 256 + temp;
-                                }
-                                // use MS-Based position mode if SUPL support is enabled
-                                mPositionMode = GPS_POSITION_MODE_MS_BASED;
-                                native_set_supl_server((int)addr, mSuplPort);
-                                mSetSuplServer = false; 
-                            }
-                        } catch (UnknownHostException e) {
-                            Log.e(TAG, "unknown host for SUPL server " + mSuplHost);
+                        if (setAGpsServer(AGPS_TYPE_SUPL, mSuplHost, mSuplPort)) {
+                            mSetSuplServer = false;
+                        }
+                    }
+                    if (mSetC2KServer) {
+                        if (setAGpsServer(AGPS_TYPE_C2K, mC2KHost, mC2KPort)) {
+                            mSetC2KServer = false;
                         }
                     }
 
@@ -1125,9 +1158,9 @@
     private native boolean native_supports_xtra();
     private native void native_inject_xtra_data(byte[] data, int length);
 
-    // SUPL Support    
-    private native void native_supl_data_conn_open(String apn);
-    private native void native_supl_data_conn_closed();
-    private native void native_supl_data_conn_failed();
-    private native void native_set_supl_server(int addr, int port);
+    // AGPS Support    
+    private native void native_agps_data_conn_open(String apn);
+    private native void native_agps_data_conn_closed();
+    private native void native_agps_data_conn_failed();
+    private native void native_set_agps_server(int type, int addr, int port);
 }
diff --git a/location/java/com/android/internal/location/LocationProviderProxy.java b/location/java/com/android/internal/location/LocationProviderProxy.java
index 80303f4..b40cdca 100644
--- a/location/java/com/android/internal/location/LocationProviderProxy.java
+++ b/location/java/com/android/internal/location/LocationProviderProxy.java
@@ -21,6 +21,7 @@
 import android.location.Location;
 import android.location.LocationManager;
 import android.os.Bundle;
+import android.os.IBinder;
 import android.os.RemoteException;
 import android.util.Log;
 
@@ -31,7 +32,7 @@
  *
  * {@hide}
  */
-public class LocationProviderProxy {
+public class LocationProviderProxy implements IBinder.DeathRecipient {
 
     private static final String TAG = "LocationProviderProxy";
 
@@ -39,16 +40,27 @@
     private final ILocationProvider mProvider;
     private boolean mLocationTracking = false;
     private long mMinTime = 0;
+    private boolean mDead;
 
     public LocationProviderProxy(String name, ILocationProvider provider) {
         mName = name;
         mProvider = provider;
+        try {
+            provider.asBinder().linkToDeath(this, 0);
+        } catch (RemoteException e) {
+            Log.e(TAG, "linkToDeath failed", e);
+            mDead = true;
+        }
     }
 
     public String getName() {
         return mName;
     }
 
+    public boolean isDead() {
+        return mDead;
+    }
+
     public boolean requiresNetwork() {
         try {
             return mProvider.requiresNetwork();
@@ -231,4 +243,9 @@
             Log.e(TAG, "removeListener failed", e);
         }
     }
+
+    public void binderDied() {
+        Log.w(TAG, "Location Provider " + mName + " died");
+        mDead = true;
+    }
 }
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 209b09f..cac65d6 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -150,6 +150,11 @@
 
 static void android_media_MediaRecorder_setCamera(JNIEnv* env, jobject thiz, jobject camera)
 {
+    // we should not pass a null camera to get_native_camera() call.
+    if (camera == NULL) {
+        jniThrowException(env, "java/lang/NullPointerException", "camera object is a NULL pointer");
+        return;
+    }
     sp<Camera> c = get_native_camera(env, camera, NULL);
     sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
     process_media_recorder_call(env, mr->setCamera(c->remote()),
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index e582fb15..db1deae 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -46,6 +46,8 @@
 import java.io.FileNotFoundException;
 import java.io.PrintWriter;
 import java.lang.String;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 
@@ -74,137 +76,16 @@
             fullBackup = isFull;
         }
     }
-    private HashSet<BackupRequest> mPendingBackups = new HashSet<BackupRequest>();
+    // Backups that we haven't started yet.
+    private HashMap<ComponentName,BackupRequest> mPendingBackups = new HashMap();
+    // Backups that we have started.  These are separate to prevent starvation
+    // if an app keeps re-enqueuing itself.
+    private ArrayList<BackupRequest> mBackupQueue;
     private final Object mQueueLock = new Object();
 
     private File mStateDir;
     private File mDataDir;
     
-    // ----- Handler that runs the actual backup process asynchronously -----
-
-    private class BackupHandler extends Handler implements ServiceConnection {
-        private volatile Object mBindSignaller = new Object();
-        private volatile boolean mBinding = false;
-        private IBackupService mTargetService = null;
-
-        public void handleMessage(Message msg) {
-
-            switch (msg.what) {
-            case MSG_RUN_BACKUP:
-            {
-                // snapshot the pending-backup set and work on that
-                HashSet<BackupRequest> queue;
-                synchronized (mQueueLock) {
-                    queue = mPendingBackups;
-                    mPendingBackups = new HashSet<BackupRequest>();
-                    // !!! TODO: start a new backup-queue journal file too
-                }
-                
-                // Walk the set of pending backups, setting up the relevant files and
-                // invoking the backup service in each participant
-                Intent backupIntent = new Intent(BackupService.SERVICE_ACTION);
-                for (BackupRequest request : queue) {
-                    mBinding = true;
-                    mTargetService = null;
-
-                    backupIntent.setClassName(request.service.packageName, request.service.name);
-                    Log.d(TAG, "binding to " + backupIntent);
-                    if (mContext.bindService(backupIntent, this, 0)) {
-                        synchronized (mBindSignaller) {
-                            while (mTargetService == null && mBinding == true) {
-                                try {
-                                    mBindSignaller.wait();
-                                } catch (InterruptedException e) {
-                                }
-                            }
-                        }
-                        if (mTargetService != null) {
-                            try {
-                                Log.d(TAG, "invoking doBackup() on " + backupIntent);
-
-                                // !!! TODO right now these naming schemes limit applications to
-                                // one backup service per package
-                                File savedStateName = new File(mStateDir,
-                                        request.service.packageName);
-                                File backupDataName = new File(mDataDir,
-                                        request.service.packageName + ".data");
-                                File newStateName = new File(mStateDir,
-                                        request.service.packageName + ".new");
-                                
-                                // In a full backup, we pass a null ParcelFileDescriptor as
-                                // the saved-state "file"
-                                ParcelFileDescriptor savedState = (request.fullBackup) ? null
-                                        : ParcelFileDescriptor.open(savedStateName,
-                                            ParcelFileDescriptor.MODE_READ_ONLY |
-                                            ParcelFileDescriptor.MODE_CREATE);
-
-                                backupDataName.delete();
-                                ParcelFileDescriptor backupData =
-                                        ParcelFileDescriptor.open(backupDataName,
-                                                ParcelFileDescriptor.MODE_READ_WRITE |
-                                                ParcelFileDescriptor.MODE_CREATE);
-
-                                newStateName.delete();
-                                ParcelFileDescriptor newState =
-                                        ParcelFileDescriptor.open(newStateName,
-                                                ParcelFileDescriptor.MODE_READ_WRITE |
-                                                ParcelFileDescriptor.MODE_CREATE);
-
-                                // Run the target's backup pass
-                                try {
-                                    mTargetService.doBackup(savedState, backupData, newState);
-                                } finally {
-                                    savedState.close();
-                                    backupData.close();
-                                    newState.close();
-                                }
-
-                                // !!! TODO: Now propagate the newly-backed-up data to the transport
-                                
-                                // !!! TODO: After successful transport, delete the now-stale data
-                                // and juggle the files so that next time the new state is passed
-                                backupDataName.delete();
-                                newStateName.renameTo(savedStateName);
-                                
-                            } catch (FileNotFoundException fnf) {
-                                Log.d(TAG, "File not found on backup: ");
-                                fnf.printStackTrace();
-                            } catch (RemoteException e) {
-                                Log.d(TAG, "Remote target " + backupIntent
-                                        + " threw during backup:");
-                                e.printStackTrace();
-                            } catch (Exception e) {
-                                Log.w(TAG, "Final exception guard in backup: ");
-                                e.printStackTrace();
-                            }
-                            mContext.unbindService(this);
-                        }
-                    } else {
-                        Log.d(TAG, "Unable to bind to " + backupIntent);
-                    }
-                }
-            }
-            break;
-            }
-        }
-        
-        public void onServiceConnected(ComponentName name, IBinder service) {
-            synchronized (mBindSignaller) {
-                mTargetService = IBackupService.Stub.asInterface(service);
-                mBinding = false;
-                mBindSignaller.notifyAll();
-            }
-        }
-
-        public void onServiceDisconnected(ComponentName name) {
-            synchronized (mBindSignaller) {
-                mTargetService = null;
-                mBinding = false;
-                mBindSignaller.notifyAll();
-            }
-        }
-    }
-    
     public BackupManagerService(Context context) {
         mContext = context;
         mPackageManager = context.getPackageManager();
@@ -268,6 +149,140 @@
         }
     };
 
+    // ----- Run the actual backup process asynchronously -----
+
+    private class BackupHandler extends Handler implements ServiceConnection {
+        public void handleMessage(Message msg) {
+
+            switch (msg.what) {
+            case MSG_RUN_BACKUP:
+                // snapshot the pending-backup set and work on that
+                synchronized (mQueueLock) {
+                    mBackupQueue = new ArrayList();
+                    for (BackupRequest b: mPendingBackups.values()) {
+                        mBackupQueue.add(b);
+                    }
+                    mPendingBackups = new HashMap<ComponentName,BackupRequest>();
+                    // !!! TODO: start a new backup-queue journal file too
+                    // WARNING: If we crash after this line, anything in mPendingBackups will
+                    // be lost.  FIX THIS.
+                }
+                startOneService();
+                break;
+            }
+        }
+        
+        public void onServiceConnected(ComponentName name, IBinder service) {
+            Log.d(TAG, "onServiceConnected name=" + name + " service=" + service);
+            IBackupService bs = IBackupService.Stub.asInterface(service);
+            processOneBackup(name, bs);
+        }
+
+        public void onServiceDisconnected(ComponentName name) {
+            // TODO: handle backup being interrupted
+        }
+    }
+
+    void startOneService() {
+        // Loop until we find someone to start or the queue empties out.
+        Intent intent = new Intent(BackupService.SERVICE_ACTION);
+        while (true) {
+            BackupRequest request;
+            synchronized (mQueueLock) {
+                int queueSize = mBackupQueue.size();
+                if (queueSize == 0) {
+                    mBackupQueue = null;
+                    // TODO: Anything else to do here?
+                    return;
+                }
+                request = mBackupQueue.get(0);
+                // Take it off the queue when we're done.
+            }
+            
+            intent.setClassName(request.service.packageName, request.service.name);
+            Log.d(TAG, "binding to " + intent);
+            try {
+                if (mContext.bindService(intent, mBackupHandler, Context.BIND_AUTO_CREATE)) {
+                    Log.d(TAG, "awaiting service object for " + intent);
+                    // success
+                    return;
+                }
+            } catch (SecurityException ex) {
+                // Try for the next one.
+                Log.d(TAG, "error in bind", ex);
+            }
+        }
+    }
+
+    void processOneBackup(ComponentName name, IBackupService bs) {
+        try {
+            Log.d(TAG, "processOneBackup doBackup() on " + name);
+
+            BackupRequest request;
+            synchronized (mQueueLock) {
+                request = mBackupQueue.get(0);
+            }
+
+            // !!! TODO right now these naming schemes limit applications to
+            // one backup service per package
+            File savedStateName = new File(mStateDir, request.service.packageName);
+            File backupDataName = new File(mDataDir, request.service.packageName + ".data");
+            File newStateName = new File(mStateDir, request.service.packageName + ".new");
+            
+            // In a full backup, we pass a null ParcelFileDescriptor as
+            // the saved-state "file"
+            ParcelFileDescriptor savedState = (request.fullBackup) ? null
+                    : ParcelFileDescriptor.open(savedStateName,
+                        ParcelFileDescriptor.MODE_READ_ONLY |
+                        ParcelFileDescriptor.MODE_CREATE);
+
+            backupDataName.delete();
+            ParcelFileDescriptor backupData =
+                    ParcelFileDescriptor.open(backupDataName,
+                            ParcelFileDescriptor.MODE_READ_WRITE |
+                            ParcelFileDescriptor.MODE_CREATE);
+
+            newStateName.delete();
+            ParcelFileDescriptor newState =
+                    ParcelFileDescriptor.open(newStateName,
+                            ParcelFileDescriptor.MODE_READ_WRITE |
+                            ParcelFileDescriptor.MODE_CREATE);
+
+            // Run the target's backup pass
+            try {
+                // TODO: Make this oneway
+                bs.doBackup(savedState, backupData, newState);
+            } finally {
+                if (savedState != null) {
+                    savedState.close();
+                }
+                backupData.close();
+                newState.close();
+            }
+
+            // !!! TODO: Now propagate the newly-backed-up data to the transport
+            
+            // !!! TODO: After successful transport, delete the now-stale data
+            // and juggle the files so that next time the new state is passed
+            backupDataName.delete();
+            newStateName.renameTo(savedStateName);
+            
+        } catch (FileNotFoundException fnf) {
+            Log.d(TAG, "File not found on backup: ");
+            fnf.printStackTrace();
+        } catch (RemoteException e) {
+            Log.d(TAG, "Remote target " + name + " threw during backup:");
+            e.printStackTrace();
+        } catch (Exception e) {
+            Log.w(TAG, "Final exception guard in backup: ");
+            e.printStackTrace();
+        }
+        synchronized (mQueueLock) {
+            mBackupQueue.remove(0);
+        }
+        mContext.unbindService(mBackupHandler);
+    }
+
     // Add the backup services in the given package to our set of known backup participants.
     // If 'packageName' is null, adds all backup services in the system.
     void addPackageParticipantsLocked(String packageName) {
@@ -305,7 +320,8 @@
         removePackageParticipantsLockedInner(packageName, services);
     }
 
-    private void removePackageParticipantsLockedInner(String packageName, List<ResolveInfo> services) {
+    private void removePackageParticipantsLockedInner(String packageName,
+            List<ResolveInfo> services) {
         for (ResolveInfo ri : services) {
             if (packageName == null || ri.serviceInfo.packageName.equals(packageName)) {
                 int uid = ri.serviceInfo.applicationInfo.uid;
@@ -353,10 +369,11 @@
                     // validate the caller-supplied package name against the known set of
                     // packages associated with this uid
                     if (service.packageName.equals(packageName)) {
-                        // add the caller to the set of pending backups
-                        if (mPendingBackups.add(new BackupRequest(service, false))) {
-                            // !!! TODO: write to the pending-backup journal file in case of crash
-                        }
+                        // Add the caller to the set of pending backups.  If there is
+                        // one already there, then overwrite it, but no harm done.
+                        mPendingBackups.put(new ComponentName(service.packageName, service.name),
+                                new BackupRequest(service, true));
+                        // !!! TODO: write to the pending-backup journal file in case of crash
                     }
                 }
 
@@ -381,7 +398,8 @@
                 HashSet<ServiceInfo> servicesAtUid = mBackupParticipants.get(uid);
                 for (ServiceInfo service: servicesAtUid) {
                     if (service.packageName.equals(packageName)) {
-                        mPendingBackups.add(new BackupRequest(service, true));
+                        mPendingBackups.put(new ComponentName(service.packageName, service.name),
+                                new BackupRequest(service, true));
                     }
                 }
             }
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 14c834b..05888e0 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -215,8 +215,7 @@
         public int hashCode() {
             return mKey.hashCode();
         }
-        
-        
+
         @Override
         public String toString() {
             if (mListener != null) {
@@ -611,6 +610,17 @@
         }
 
         synchronized (mLock) {
+            // check to see if we are reinstalling a dead provider
+            LocationProviderProxy oldProvider = mProvidersByName.get(name);
+            if (oldProvider != null) {
+                if (oldProvider.isDead()) {
+                    Log.d(TAG, "replacing dead provider");
+                    removeProvider(oldProvider);
+                } else {
+                    throw new IllegalArgumentException("Provider \"" + name + "\" already exists");
+                }
+            }
+
             LocationProviderProxy proxy = new LocationProviderProxy(name, provider);
             addProvider(proxy);
             updateProvidersLocked();
@@ -1616,6 +1626,7 @@
                                 mCollector.updateLocation(location);
                             } catch (RemoteException e) {
                                 Log.w(TAG, "mCollector.updateLocation failed");
+                                mCollector = null;
                             }
                         }
 
@@ -1750,6 +1761,7 @@
                         variant, appName,  addrs);
             } catch (RemoteException e) {
                 Log.e(TAG, "getFromLocation failed", e);
+                mGeocodeProvider = null;
             }
         }
         return null;
@@ -1768,6 +1780,7 @@
                         maxResults, language, country, variant, appName, addrs);
             } catch (RemoteException e) {
                 Log.e(TAG, "getFromLocationName failed", e);
+                mGeocodeProvider = null;
             }
         }
         return null;
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 237b70d..4ee0c91 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -3231,20 +3231,27 @@
         private final String mRootDir;
         private final boolean mIsRom;
     }
-    
+
     /* Called when a downloaded package installation has been confirmed by the user */
     public void installPackage(
             final Uri packageURI, final IPackageInstallObserver observer, final int flags) {
+        installPackage(packageURI, observer, flags, null);
+    }
+    
+    /* Called when a downloaded package installation has been confirmed by the user */
+    public void installPackage(
+            final Uri packageURI, final IPackageInstallObserver observer, final int flags,
+            final String installerPackageName) {
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.INSTALL_PACKAGES, null);
-
+        
         // Queue up an async operation since the package installation may take a little while.
         mHandler.post(new Runnable() {
             public void run() {
                 mHandler.removeCallbacks(this);
                 PackageInstalledInfo res;
                 synchronized (mInstallLock) {
-                    res = installPackageLI(packageURI, flags, true);
+                    res = installPackageLI(packageURI, flags, true, installerPackageName);
                 }
                 if (observer != null) {
                     try {
@@ -3292,7 +3299,7 @@
             File tmpPackageFile, 
             String destFilePath, File destPackageFile, File destResourceFile,
             PackageParser.Package pkg, boolean forwardLocked, boolean newInstall,
-            PackageInstalledInfo res) {
+            String installerPackageName, PackageInstalledInfo res) {
         // Remember this for later, in case we need to rollback this install
         boolean dataDirExists = (new File(mAppDataDir, pkgName)).exists();
         res.name = pkgName;
@@ -3328,7 +3335,8 @@
                     destResourceFile, pkg, 
                     newPackage,
                     true,
-                    forwardLocked,  
+                    forwardLocked,
+                    installerPackageName,
                     res);
             // delete the partially installed application. the data directory will have to be
             // restored if it was already existing
@@ -3349,7 +3357,8 @@
             File tmpPackageFile, 
             String destFilePath, File destPackageFile, File destResourceFile,
             PackageParser.Package pkg, boolean forwardLocked, boolean newInstall,
-            PackageInstalledInfo res) {
+            String installerPackageName, PackageInstalledInfo res) {
+
         PackageParser.Package oldPackage;
         // First find the old package info and check signatures
         synchronized(mPackages) {
@@ -3364,11 +3373,11 @@
             replaceSystemPackageLI(oldPackage,
                     tmpPackageFile, destFilePath, 
                     destPackageFile, destResourceFile, pkg, forwardLocked,
-                    newInstall, res);
+                    newInstall, installerPackageName, res);
         } else {
             replaceNonSystemPackageLI(oldPackage, tmpPackageFile, destFilePath,
                     destPackageFile, destResourceFile, pkg, forwardLocked,
-                    newInstall, res);
+                    newInstall, installerPackageName, res);
         }
     }
     
@@ -3376,12 +3385,18 @@
             File tmpPackageFile, 
             String destFilePath, File destPackageFile, File destResourceFile,
             PackageParser.Package pkg, boolean forwardLocked, boolean newInstall,
-            PackageInstalledInfo res) {
+            String installerPackageName, PackageInstalledInfo res) {
         PackageParser.Package newPackage = null;
         String pkgName = deletedPackage.packageName;
         boolean deletedPkg = true;
         boolean updatedSettings = false;
-        int parseFlags = PackageManager.REPLACE_EXISTING_PACKAGE;
+        
+        String oldInstallerPackageName = null;
+        synchronized (mPackages) {
+            oldInstallerPackageName = mSettings.getInstallerPackageName(pkgName);
+        }
+        
+        int parseFlags = PackageManager.INSTALL_REPLACE_EXISTING;
         // First delete the existing package while retaining the data directory
         if (!deletePackageLI(pkgName, false, PackageManager.DONT_DELETE_DATA,
                 res.removedInfo)) {
@@ -3409,6 +3424,7 @@
                         newPackage,
                         true,
                         forwardLocked,  
+                        installerPackageName,
                         res);
                 updatedSettings = true;
             }
@@ -3452,8 +3468,8 @@
                 installPackageLI(
                         Uri.fromFile(new File(deletedPackage.mPath)),
                         isForwardLocked(deletedPackage)
-                        ? PackageManager.FORWARD_LOCK_PACKAGE
-                                : 0, false);
+                        ? PackageManager.INSTALL_FORWARD_LOCK
+                                : 0, false, oldInstallerPackageName);
             }
         }
     }
@@ -3462,10 +3478,10 @@
             File tmpPackageFile, 
             String destFilePath, File destPackageFile, File destResourceFile,
             PackageParser.Package pkg, boolean forwardLocked, boolean newInstall,
-            PackageInstalledInfo res) {
+            String installerPackageName, PackageInstalledInfo res) {
         PackageParser.Package newPackage = null;
         boolean updatedSettings = false;
-        int parseFlags = PackageManager.REPLACE_EXISTING_PACKAGE |
+        int parseFlags = PackageManager.INSTALL_REPLACE_EXISTING |
                 PackageParser.PARSE_IS_SYSTEM;
         String packageName = deletedPackage.packageName;
         res.returnCode = PackageManager.INSTALL_FAILED_REPLACE_COULDNT_DELETE;
@@ -3512,7 +3528,8 @@
                     destResourceFile, pkg, 
                     newPackage,
                     true,
-                    forwardLocked,  
+                    forwardLocked,
+                    installerPackageName,
                     res);
             updatedSettings = true;
         }
@@ -3539,6 +3556,8 @@
             synchronized(mPackages) {
                 if(updatedSettings) {
                     mSettings.enableSystemPackageLP(packageName);
+                    mSettings.setInstallerPackageName(packageName,
+                            oldPkgSetting.installerPackageName);
                 }
                 mSettings.writeLP();
             }
@@ -3552,7 +3571,7 @@
             PackageParser.Package newPackage,
             boolean replacingExistingPackage,
             boolean forwardLocked,  
-            PackageInstalledInfo res) {
+            String installerPackageName, PackageInstalledInfo res) {
         synchronized (mPackages) {
             //write settings. the installStatus will be incomplete at this stage.
             //note that the new package setting would have already been
@@ -3599,6 +3618,7 @@
             res.uid = newPackage.applicationInfo.uid;
             res.pkg = newPackage;
             mSettings.setInstallStatus(pkgName, PKG_INSTALL_COMPLETE);
+            mSettings.setInstallerPackageName(pkgName, installerPackageName);
             res.returnCode = PackageManager.INSTALL_SUCCEEDED;
             //to update install status
             mSettings.writeLP();
@@ -3606,7 +3626,7 @@
     }
     
     private PackageInstalledInfo installPackageLI(Uri pPackageURI,
-            int pFlags, boolean newInstall) {
+            int pFlags, boolean newInstall, String installerPackageName) {
         File tmpPackageFile = null;
         String pkgName = null;
         boolean forwardLocked = false;
@@ -3677,13 +3697,13 @@
             res.name = pkgName;
             //initialize some variables before installing pkg
             final String pkgFileName = pkgName + ".apk";
-            final File destDir = ((pFlags&PackageManager.FORWARD_LOCK_PACKAGE) != 0)
+            final File destDir = ((pFlags&PackageManager.INSTALL_FORWARD_LOCK) != 0)
                                  ?  mDrmAppPrivateInstallDir
                                  : mAppInstallDir;
             final File destPackageFile = new File(destDir, pkgFileName);
             final String destFilePath = destPackageFile.getAbsolutePath();
             File destResourceFile;
-            if ((pFlags&PackageManager.FORWARD_LOCK_PACKAGE) != 0) {
+            if ((pFlags&PackageManager.INSTALL_FORWARD_LOCK) != 0) {
                 final String publicZipFileName = pkgName + ".zip";
                 destResourceFile = new File(mAppInstallDir, publicZipFileName);
                 forwardLocked = true;
@@ -3702,6 +3722,12 @@
                 res.returnCode = pp.getParseError();
                 break main_flow;
             }
+            if ((pkg.applicationInfo.flags&ApplicationInfo.FLAG_TEST_ONLY) != 0) {
+                if ((pFlags&PackageManager.INSTALL_ALLOW_TEST) == 0) {
+                    res.returnCode = PackageManager.INSTALL_FAILED_TEST_ONLY;
+                    break main_flow;
+                }
+            }
             if (GET_CERTIFICATES && !pp.collectCertificates(pkg, parseFlags)) {
                 res.returnCode = pp.getParseError();
                 break main_flow;
@@ -3709,7 +3735,7 @@
             
             synchronized (mPackages) {
                 //check if installing already existing package
-                if ((pFlags&PackageManager.REPLACE_EXISTING_PACKAGE) != 0
+                if ((pFlags&PackageManager.INSTALL_REPLACE_EXISTING) != 0
                         && mPackages.containsKey(pkgName)) {
                     replacingExistingPackage = true;
                 }
@@ -3719,13 +3745,13 @@
                 replacePackageLI(pkgName,
                         tmpPackageFile, 
                         destFilePath, destPackageFile, destResourceFile,
-                        pkg, forwardLocked, newInstall,
+                        pkg, forwardLocked, newInstall, installerPackageName,
                         res);
             } else {
                 installNewPackageLI(pkgName,
                         tmpPackageFile, 
                         destFilePath, destPackageFile, destResourceFile,
-                        pkg, forwardLocked, newInstall,
+                        pkg, forwardLocked, newInstall, installerPackageName,
                         res);
             }
         } finally {
@@ -4543,6 +4569,16 @@
         }
     }
 
+    public String getInstallerPackageName(String packageName) {
+        synchronized (mPackages) {
+            PackageSetting pkg = mSettings.mPackages.get(packageName);
+            if (pkg == null) {
+                throw new IllegalArgumentException("Unknown package: " + packageName);
+            }
+            return pkg.installerPackageName;
+        }
+    }
+    
     public int getApplicationEnabledSetting(String appPackageName) {
         synchronized (mPackages) {
             PackageSetting pkg = mSettings.mPackages.get(appPackageName);
@@ -5192,6 +5228,9 @@
         HashSet<String> enabledComponents = new HashSet<String>(0);
         int enabled = COMPONENT_ENABLED_STATE_DEFAULT;
         int installStatus = PKG_INSTALL_COMPLETE;
+        
+        /* package name of the app that installed this package */
+        String installerPackageName;
 
         PackageSettingBase(String name, File codePath, File resourcePath,
                 int pVersionCode, int pkgFlags) {
@@ -5204,6 +5243,14 @@
             this.versionCode = pVersionCode;
         }
 
+        public void setInstallerPackageName(String packageName) {
+            installerPackageName = packageName;
+        }
+        
+        String getInstallerPackageName() {
+            return installerPackageName;
+        }
+        
         public void setInstallStatus(int newStatus) {
             installStatus = newStatus;
         }
@@ -5434,6 +5481,19 @@
             }
         }
         
+        void setInstallerPackageName(String pkgName,
+                String installerPkgName) {
+            PackageSetting p = mPackages.get(pkgName);
+            if(p != null) {
+                p.setInstallerPackageName(installerPkgName);
+            }
+        }
+        
+        String getInstallerPackageName(String pkgName) {
+            PackageSetting p = mPackages.get(pkgName);
+            return (p == null) ? null : p.getInstallerPackageName(); 
+        }
+
         int getInstallStatus(String pkgName) {
             PackageSetting p = mPackages.get(pkgName);
             if(p != null) {
@@ -5909,6 +5969,9 @@
             if(pkg.installStatus == PKG_INSTALL_INCOMPLETE) {
                 serializer.attribute(null, "installStatus", "false");
             }
+            if (pkg.installerPackageName != null) {
+                serializer.attribute(null, "installer", pkg.installerPackageName);
+            }
             pkg.signatures.writeXml(serializer, "sigs", mPastSignatures);
             if ((pkg.pkgFlags&ApplicationInfo.FLAG_SYSTEM) == 0) {
                 serializer.startTag(null, "perms");
@@ -5943,6 +6006,7 @@
                 }
                 serializer.endTag(null, "enabled-components");
             }
+            
             serializer.endTag(null, "package");
         }
         
@@ -6264,6 +6328,7 @@
             String codePathStr = null;
             String resourcePathStr = null;
             String systemStr = null;
+            String installerPackageName = null;
             int pkgFlags = 0;
             String timeStampStr;
             long timeStamp = 0;
@@ -6284,6 +6349,7 @@
                     }
                 }
                 systemStr = parser.getAttributeValue(null, "system");
+                installerPackageName = parser.getAttributeValue(null, "installer");
                 if (systemStr != null) {
                     if ("true".equals(systemStr)) {
                         pkgFlags |= ApplicationInfo.FLAG_SYSTEM;
@@ -6357,6 +6423,7 @@
                         + parser.getPositionDescription());
             }
             if (packageSetting != null) {
+                packageSetting.installerPackageName = installerPackageName;
                 final String enabledStr = parser.getAttributeValue(null, "enabled");
                 if (enabledStr != null) {
                     if (enabledStr.equalsIgnoreCase("true")) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 2be4975..9471eff 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -169,6 +169,10 @@
     static final int LOG_BOOT_PROGRESS_AMS_READY = 3040;
     static final int LOG_BOOT_PROGRESS_ENABLE_SCREEN = 3050;
 
+    // The flags that are set for all calls we make to the package manager.
+    static final int STOCK_PM_FLAGS = PackageManager.GET_SHARED_LIBRARY_FILES
+            | PackageManager.GET_SUPPORTS_DENSITIES;
+    
     private static final String SYSTEM_SECURE = "ro.secure";
 
     // This is the maximum number of application processes we would like
@@ -1058,7 +1062,7 @@
 
             ApplicationInfo info =
                 mSelf.mContext.getPackageManager().getApplicationInfo(
-                        "android", PackageManager.GET_SHARED_LIBRARY_FILES);
+                        "android", STOCK_PM_FLAGS);
             synchronized (mSelf) {
                 ProcessRecord app = mSelf.newProcessRecordLocked(
                         mSystemThread.getApplicationThread(), info,
@@ -2224,7 +2228,7 @@
             }
             ActivityInfo aInfo =
                 intent.resolveActivityInfo(mContext.getPackageManager(),
-                        PackageManager.GET_SHARED_LIBRARY_FILES);
+                        STOCK_PM_FLAGS);
             if (aInfo != null) {
                 intent.setComponent(new ComponentName(
                         aInfo.applicationInfo.packageName, aInfo.name));
@@ -3181,7 +3185,7 @@
                 ActivityThread.getPackageManager().resolveIntent(
                         intent, resolvedType,
                         PackageManager.MATCH_DEFAULT_ONLY
-                        | PackageManager.GET_SHARED_LIBRARY_FILES);
+                        | STOCK_PM_FLAGS);
             aInfo = rInfo != null ? rInfo.activityInfo : null;
         } catch (RemoteException e) {
             aInfo = null;
@@ -3242,8 +3246,7 @@
                 List<ResolveInfo> resolves =
                     ActivityThread.getPackageManager().queryIntentActivities(
                             intent, r.resolvedType,
-                            PackageManager.MATCH_DEFAULT_ONLY
-                            | PackageManager.GET_SHARED_LIBRARY_FILES);
+                            PackageManager.MATCH_DEFAULT_ONLY | STOCK_PM_FLAGS);
 
                 // Look for the original activity in the list...
                 final int N = resolves != null ? resolves.size() : 0;
@@ -3325,8 +3328,7 @@
             ResolveInfo rInfo =
                 ActivityThread.getPackageManager().resolveIntent(
                         intent, resolvedType,
-                        PackageManager.MATCH_DEFAULT_ONLY
-                        | PackageManager.GET_SHARED_LIBRARY_FILES);
+                        PackageManager.MATCH_DEFAULT_ONLY | STOCK_PM_FLAGS);
             aInfo = rInfo != null ? rInfo.activityInfo : null;
         } catch (RemoteException e) {
             aInfo = null;
@@ -4608,7 +4610,8 @@
                     mWaitForDebugger = mOrigWaitForDebugger;
                 }
             }
-            thread.bindApplication(processName, app.info, providers,
+            thread.bindApplication(processName, app.instrumentationInfo != null
+                    ? app.instrumentationInfo : app.info, providers,
                     app.instrumentationClass, app.instrumentationProfileFile,
                     app.instrumentationArguments, app.instrumentationWatcher, testMode, 
                     mConfiguration, getCommonServicesLocked());
@@ -6651,8 +6654,7 @@
         try {
             providers = ActivityThread.getPackageManager().
                 queryContentProviders(app.processName, app.info.uid,
-                        PackageManager.GET_SHARED_LIBRARY_FILES
-                        | PackageManager.GET_URI_PERMISSION_PATTERNS);
+                        STOCK_PM_FLAGS | PackageManager.GET_URI_PERMISSION_PATTERNS);
         } catch (RemoteException ex) {
         }
         if (providers != null) {
@@ -6756,7 +6758,8 @@
             } else {
                 try {
                     cpi = ActivityThread.getPackageManager().
-                        resolveContentProvider(name, PackageManager.GET_URI_PERMISSION_PATTERNS);
+                        resolveContentProvider(name,
+                                STOCK_PM_FLAGS | PackageManager.GET_URI_PERMISSION_PATTERNS);
                 } catch (RemoteException ex) {
                 }
                 if (cpi == null) {
@@ -6777,7 +6780,7 @@
                             ActivityThread.getPackageManager().
                                 getApplicationInfo(
                                         cpi.applicationInfo.packageName,
-                                        PackageManager.GET_SHARED_LIBRARY_FILES);
+                                        STOCK_PM_FLAGS);
                         if (ai == null) {
                             Log.w(TAG, "No package info for content provider "
                                     + cpi.name);
@@ -7513,7 +7516,7 @@
             if (mFactoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL) {
                 ResolveInfo ri = mContext.getPackageManager()
                         .resolveActivity(new Intent(Intent.ACTION_FACTORY_TEST),
-                                0);
+                                STOCK_PM_FLAGS);
                 CharSequence errorMsg = null;
                 if (ri != null) {
                     ActivityInfo ai = ri.activityInfo;
@@ -7549,7 +7552,7 @@
             if (mFactoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
                 try {
                     List apps = ActivityThread.getPackageManager().
-                        getPersistentApplications(PackageManager.GET_SHARED_LIBRARY_FILES);
+                        getPersistentApplications(STOCK_PM_FLAGS);
                     if (apps != null) {
                         int N = apps.size();
                         int i;
@@ -8964,7 +8967,7 @@
             try {
                 ResolveInfo rInfo =
                     ActivityThread.getPackageManager().resolveService(
-                            service, resolvedType, PackageManager.GET_SHARED_LIBRARY_FILES);
+                            service, resolvedType, STOCK_PM_FLAGS);
                 ServiceInfo sInfo =
                     rInfo != null ? rInfo.serviceInfo : null;
                 if (sInfo == null) {
@@ -10182,7 +10185,7 @@
             if (intent.getComponent() != null) {
                 // Broadcast is going to one specific receiver class...
                 ActivityInfo ai = ActivityThread.getPackageManager().
-                    getReceiverInfo(intent.getComponent(), 0);
+                    getReceiverInfo(intent.getComponent(), STOCK_PM_FLAGS);
                 if (ai != null) {
                     receivers = new ArrayList();
                     ResolveInfo ri = new ResolveInfo();
@@ -10195,7 +10198,7 @@
                          == 0) {
                     receivers =
                         ActivityThread.getPackageManager().queryIntentReceivers(
-                                intent, resolvedType, PackageManager.GET_SHARED_LIBRARY_FILES);
+                                intent, resolvedType, STOCK_PM_FLAGS);
                 }
                 registeredReceivers = mReceiverResolver.queryIntent(resolver,
                         intent, resolvedType, false);
@@ -10932,9 +10935,9 @@
             ApplicationInfo ai = null;
             try {
                 ii = mContext.getPackageManager().getInstrumentationInfo(
-                    className, 0);
+                    className, STOCK_PM_FLAGS);
                 ai = mContext.getPackageManager().getApplicationInfo(
-                    ii.targetPackage, PackageManager.GET_SHARED_LIBRARY_FILES);
+                    ii.targetPackage, STOCK_PM_FLAGS);
             } catch (PackageManager.NameNotFoundException e) {
             }
             if (ii == null) {
@@ -10966,6 +10969,7 @@
             uninstallPackageLocked(ii.targetPackage, -1, true);
             ProcessRecord app = addAppLocked(ai);
             app.instrumentationClass = className;
+            app.instrumentationInfo = ai;
             app.instrumentationProfileFile = profileFile;
             app.instrumentationArguments = arguments;
             app.instrumentationWatcher = watcher;
@@ -11013,6 +11017,7 @@
         }
         app.instrumentationWatcher = null;
         app.instrumentationClass = null;
+        app.instrumentationInfo = null;
         app.instrumentationProfileFile = null;
         app.instrumentationArguments = null;
 
diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java
index b76547a..68aebc3 100644
--- a/services/java/com/android/server/am/ProcessRecord.java
+++ b/services/java/com/android/server/am/ProcessRecord.java
@@ -28,6 +28,7 @@
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
+import android.util.PrintWriterPrinter;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -62,6 +63,7 @@
     IBinder forcingToForeground;// Token that is forcing this process to be foreground
     int adjSeq;                 // Sequence id for identifying repeated trav
     ComponentName instrumentationClass;// class installed to instrument app
+    ApplicationInfo instrumentationInfo; // the application being instrumented
     String instrumentationProfileFile; // where to save profiling
     IInstrumentationWatcher instrumentationWatcher; // who is waiting
     Bundle instrumentationArguments;// as given to us
@@ -125,6 +127,11 @@
                     pw.println(instrumentationProfileFile);
             pw.print(prefix); pw.print("instrumentationArguments=");
                     pw.println(instrumentationArguments);
+            pw.print(prefix); pw.print("instrumentationInfo=");
+                    pw.println(instrumentationInfo);
+            if (instrumentationInfo != null) {
+                instrumentationInfo.dump(new PrintWriterPrinter(pw), prefix + "  ");
+            }
         }
         pw.print(prefix); pw.print("thread="); pw.print(thread);
                 pw.print(" curReceiver="); pw.println(curReceiver);
diff --git a/telephony/java/com/android/internal/telephony/CommandsInterface.java b/telephony/java/com/android/internal/telephony/CommandsInterface.java
index aec7238..5a1bb7e 100644
--- a/telephony/java/com/android/internal/telephony/CommandsInterface.java
+++ b/telephony/java/com/android/internal/telephony/CommandsInterface.java
@@ -1023,6 +1023,21 @@
      */
     void setLocationUpdates(boolean enable, Message response);
 
+    /**
+     * Gets the default SMSC address.
+     *
+     * @param result Callback message contains the SMSC address.
+     */
+    void getSmscAddress(Message result);
+
+    /**
+     * Sets the default SMSC address.
+     *
+     * @param address new SMSC address
+     * @param result Callback message is empty on completion
+     */
+    void setSmscAddress(String address, Message result);
+
 
     void invokeOemRilRequestRaw(byte[] data, Message response);
 
diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java
index 3f210ca..03c1c56 100644
--- a/telephony/java/com/android/internal/telephony/Phone.java
+++ b/telephony/java/com/android/internal/telephony/Phone.java
@@ -925,6 +925,21 @@
     void getPreferredNetworkType(Message response);
 
     /**
+     * Gets the default SMSC address.
+     *
+     * @param result Callback message contains the SMSC address.
+     */
+    void getSmscAddress(Message result);
+
+    /**
+     * Sets the default SMSC address.
+     *
+     * @param address new SMSC address
+     * @param result Callback message is empty on completion
+     */
+    void setSmscAddress(String address, Message result);
+
+    /**
      * Query neighboring cell IDs.  <code>response</code> is dispatched when
      * this is complete.  <code>response.obj</code> will be an AsyncResult,
      * and <code>response.obj.exception</code> will be non-null on failure.
diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java
index 1ff0f7e..0314034 100644
--- a/telephony/java/com/android/internal/telephony/PhoneBase.java
+++ b/telephony/java/com/android/internal/telephony/PhoneBase.java
@@ -574,6 +574,14 @@
         mCM.getPreferredNetworkType(response);
     }
 
+    public void getSmscAddress(Message result) {
+        mCM.getSmscAddress(result);
+    }
+
+    public void setSmscAddress(String address, Message result) {
+        mCM.setSmscAddress(address, result);
+    }
+
     public void setTTYModeEnabled(boolean enable, Message onComplete) {
         // This function should be overridden by the class CDMAPhone. Not implemented in GSMPhone.
         Log.e(LOG_TAG, "Error! This function should never be executed, inactive CDMAPhone.");
diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java
index dd36f0b..b76d801 100644
--- a/telephony/java/com/android/internal/telephony/PhoneProxy.java
+++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java
@@ -671,5 +671,13 @@
     public void notifyDataActivity() {
          mActivePhone.notifyDataActivity();
     }
+
+    public void getSmscAddress(Message result) {
+        mActivePhone.getSmscAddress(result);
+    }
+
+    public void setSmscAddress(String address, Message result) {
+        mActivePhone.setSmscAddress(address, result);
+    }
 }
 
diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index 3123111..be18a39 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -1760,6 +1760,32 @@
         send(rr);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public void getSmscAddress(Message result) {
+        RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_SMSC_ADDRESS, result);
+
+        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
+
+        send(rr);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSmscAddress(String address, Message result) {
+        RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_SMSC_ADDRESS, result);
+
+        rr.mp.writeInt(1);
+        rr.mp.writeString(address);
+
+        if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+                + " : " + address);
+
+        send(rr);
+    }
+
     //***** Private Methods
 
     private void sendScreenState(boolean on) {
@@ -2027,6 +2053,8 @@
             case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret =  responseInts(p); break;
             case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret =  responseVoid(p); break;
             case RIL_REQUEST_DEVICE_IDENTITY: ret =  responseStrings(p); break;
+            case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break;
+            case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break;
             default:
                 throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest);
             //break;
@@ -2885,6 +2913,8 @@
             case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM";
             case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM";
             case RIL_REQUEST_DEVICE_IDENTITY: return "RIL_REQUEST_DEVICE_IDENTITY";
+            case RIL_REQUEST_GET_SMSC_ADDRESS: return "RIL_REQUEST_GET_SMSC_ADDRESS";
+            case RIL_REQUEST_SET_SMSC_ADDRESS: return "RIL_REQUEST_SET_SMSC_ADDRESS";
             default: return "<unknown request>";
         }
     }
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index cbbdec6..bcf5141 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -208,6 +208,8 @@
     int RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM = 96;
     int RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM = 97;
     int RIL_REQUEST_DEVICE_IDENTITY = 98;
+    int RIL_REQUEST_GET_SMSC_ADDRESS = 100;
+    int RIL_REQUEST_SET_SMSC_ADDRESS = 101;
     int RIL_UNSOL_RESPONSE_BASE = 1000;
     int RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000;
     int RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED = 1001;
diff --git a/telephony/java/com/android/internal/telephony/test/SimulatedCommands.java b/telephony/java/com/android/internal/telephony/test/SimulatedCommands.java
index cb09cea..5c69017 100644
--- a/telephony/java/com/android/internal/telephony/test/SimulatedCommands.java
+++ b/telephony/java/com/android/internal/telephony/test/SimulatedCommands.java
@@ -1001,6 +1001,14 @@
         unimplemented(response);
     }
 
+    public void getSmscAddress(Message result) {
+        unimplemented(result);
+    }
+
+    public void setSmscAddress(String address, Message result) {
+        unimplemented(result);
+    }
+
     private boolean isSimLocked() {
         if (mSimLockedState != SimLockState.NONE) {
             return true;
diff --git a/test-runner/android/test/mock/MockPackageManager.java b/test-runner/android/test/mock/MockPackageManager.java
index ea190e2..bf1629f 100644
--- a/test-runner/android/test/mock/MockPackageManager.java
+++ b/test-runner/android/test/mock/MockPackageManager.java
@@ -284,9 +284,20 @@
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * @hide - to match hiding in superclass
+     */
     @Override
     public void installPackage(Uri packageURI, IPackageInstallObserver observer,
-            int flags) {
+            int flags, String installerPackageName) {
+        throw new UnsupportedOperationException();
+    }
+    
+    /**
+     * @hide - to match hiding in superclass
+     */
+    @Override
+    public String getInstallerPackageName(String packageName) {
         throw new UnsupportedOperationException();
     }
 
@@ -391,11 +402,6 @@
     }
 
     @Override
-    public void installPackage(Uri packageURI) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public int getPreferredActivities(List<IntentFilter> outFilters,
             List<ComponentName> outActivities, String packageName) {
         throw new UnsupportedOperationException();
diff --git a/tests/CoreTests/android/core/SocketTest.java b/tests/CoreTests/android/core/SocketTest.java
index b64c156..9db6077 100644
--- a/tests/CoreTests/android/core/SocketTest.java
+++ b/tests/CoreTests/android/core/SocketTest.java
@@ -178,29 +178,35 @@
         SocketChannel.open();
     }
 
-    // Regression test for issue 1018016, connecting ignored a set timeout.
-    @LargeTest
-    public void testSocketSetSOTimeout() throws IOException {
-        Socket sock = new Socket();
-        int timeout = 5000;
-        long start = System.currentTimeMillis();
-        try {
-            sock.connect(new InetSocketAddress(NON_EXISTING_ADDRESS, 80), timeout);
-        } catch (SocketTimeoutException e) {
-            // expected
-            long delay = System.currentTimeMillis() - start;
-            if (Math.abs(delay - timeout) > 1000) {
-                fail("timeout was not accurate. expected: " + timeout
-                        + " actual: " + delay + " miliseconds.");
-            }
-        } finally {
-            try {
-                sock.close();
-            } catch (IOException ioe) {
-                // ignore
-            }
-        }
-    }
+// Regression test for issue 1018016, connecting ignored a set timeout.
+//
+// Disabled because test behaves differently depending on networking
+// environment. It works fine in the emulator and one the device with
+// WLAN, but when 3G comes into play, the possible existence of a
+// proxy makes it fail.
+//
+//    @LargeTest
+//    public void testSocketSetSOTimeout() throws IOException {
+//        Socket sock = new Socket();
+//        int timeout = 5000;
+//        long start = System.currentTimeMillis();
+//        try {
+//            sock.connect(new InetSocketAddress(NON_EXISTING_ADDRESS, 80), timeout);
+//        } catch (SocketTimeoutException e) {
+//            // expected
+//            long delay = System.currentTimeMillis() - start;
+//            if (Math.abs(delay - timeout) > 1000) {
+//                fail("timeout was not accurate. expected: " + timeout
+//                        + " actual: " + delay + " miliseconds.");
+//            }
+//        } finally {
+//            try {
+//                sock.close();
+//            } catch (IOException ioe) {
+//                // ignore
+//            }
+//        }
+//    }
     
     /**
      * Regression test for 1062928: Dotted IP addresses (e.g., 192.168.100.1)
diff --git a/tests/DumpRenderTree/AndroidManifest.xml b/tests/DumpRenderTree/AndroidManifest.xml
index 17c44ad..0e33d62 100644
--- a/tests/DumpRenderTree/AndroidManifest.xml
+++ b/tests/DumpRenderTree/AndroidManifest.xml
@@ -31,4 +31,5 @@
         android:targetPackage="com.android.dumprendertree"
         android:label="Layout test automation runner"
     />
+    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
 </manifest>
diff --git a/tests/DumpRenderTree/assets/run_reliability_tests.py b/tests/DumpRenderTree/assets/run_reliability_tests.py
new file mode 100755
index 0000000..a242293
--- /dev/null
+++ b/tests/DumpRenderTree/assets/run_reliability_tests.py
@@ -0,0 +1,214 @@
+#!/usr/bin/python2.4
+
+"""Run reliability tests using Android instrumentation.
+
+  A test file consists of list web sites to test is needed as a parameter
+
+  Usage:
+    run_reliability_tests.py path/to/url/list
+"""
+
+import logging
+import optparse
+import random
+import subprocess
+import sys
+import time
+
+TEST_LIST_FILE = "/sdcard/android/reliability_tests_list.txt"
+TEST_STATUS_FILE = "/sdcard/android/reliability_running_test.txt"
+TEST_TIMEOUT_FILE = "/sdcard/android/reliability_timeout_test.txt"
+HTTP_URL_FILE = "urllist_http"
+HTTPS_URL_FILE = "urllist_https"
+NUM_URLS = 25
+
+
+def DumpRenderTreeFinished(adb_cmd):
+  """Check if DumpRenderTree finished running.
+
+  Args:
+    adb_cmd: adb command string
+
+  Returns:
+    True if DumpRenderTree has finished, False otherwise
+  """
+
+  # pull test status file and look for "#DONE"
+  shell_cmd_str = adb_cmd + " shell cat " + TEST_STATUS_FILE
+  adb_output = subprocess.Popen(shell_cmd_str,
+                                shell=True, stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE).communicate()[0]
+  return adb_output.strip() == "#DONE"
+
+
+def RandomPick(file_name, approx_size, num_needed):
+  """Randomly pick lines from the text file specifed.
+
+  Args:
+    file_name: the text file where lines should be picked from
+    approx_size: an approximate size of the text file
+    num_needed: how many lines are needed from the file
+
+  Returns:
+    an array of string
+  """
+  p = float(num_needed) / approx_size
+  num_picked = 0
+  lines = []
+  random.seed()
+
+  while num_picked < num_needed:
+    file_handle = open(file_name, "r")
+    for line in file_handle:
+      line = line.strip()
+      if float(random.randint(0, approx_size)) / approx_size < p:
+        lines.append(line)
+        num_picked += 1
+        if num_picked == num_needed:
+          break
+    file_handle.close()
+  return lines
+
+
+def main(options, args):
+  """Send the url list to device and start testing, restart if crashed."""
+
+  generate_url = False
+
+  # Set up logging format.
+  log_level = logging.INFO
+  if options.verbose:
+    log_level = logging.DEBUG
+  logging.basicConfig(level=log_level,
+                      format="%(message)s")
+
+  # Include all tests if none are specified.
+  if not args:
+    path = "/tmp/url_list_%d.txt" % time.time()
+    generate_url = True
+    logging.info("A URL list is not provided, will be automatically generated.")
+  else:
+    path = args[0]
+
+  if not options.crash_file:
+    print "missing crash file name, use --crash-file to specify"
+    sys.exit(1)
+  else:
+    crashed_file = options.crash_file
+
+  if not options.timeout_file:
+    print "missing timeout file, use --timeout-file to specify"
+    sys.exit(1)
+  else:
+    timedout_file = options.timeout_file
+
+  http = RandomPick(HTTP_URL_FILE, 500000, NUM_URLS)
+  https = RandomPick(HTTPS_URL_FILE, 45000, NUM_URLS)
+
+  if generate_url:
+    file_handle = open(path, "w")
+    for i in range(0, NUM_URLS):
+      file_handle.write(http[i] + "\n")
+      file_handle.write(https[i] + "\n")
+    file_handle.close()
+
+  adb_cmd = "adb "
+  if options.adb_options:
+    adb_cmd += options.adb_options + " "
+
+  # push url list to device
+  test_cmd = adb_cmd + " push \"" + path + "\" \"" + TEST_LIST_FILE + "\""
+  proc = subprocess.Popen(test_cmd, shell=True,
+                          stdout=subprocess.PIPE,
+                          stderr=subprocess.PIPE)
+  (adb_output, adb_error) = proc.communicate()
+  if proc.returncode != 0:
+    logging.error("failed to push url list to device.")
+    logging.error(adb_output)
+    logging.error(adb_error)
+    sys.exit(1)
+
+  logging.info("Running the test ...")
+
+  # Count crashed tests.
+  crashed_tests = []
+
+  if options.time_out_ms:
+    timeout_ms = options.time_out_ms
+
+  # Run test until it's done
+  test_cmd_prefix = adb_cmd + " shell am instrument"
+  test_cmd_postfix = " -w com.android.dumprendertree/.LayoutTestsAutoRunner"
+
+  # Call ReliabilityTestsAutoTest#startReliabilityTests
+  test_cmd = (test_cmd_prefix + " -e class "
+              "com.android.dumprendertree.ReliabilityTestsAutoTest#"
+              "startReliabilityTests -e timeout " + timeout_ms
+              + test_cmd_postfix)
+
+  time_start = time.time()
+  adb_output = subprocess.Popen(test_cmd, shell=True,
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE).communicate()[0]
+  while not DumpRenderTreeFinished(adb_cmd):
+    logging.error("DumpRenderTree exited before all URLs are visited.")
+    shell_cmd_str = adb_cmd + " shell cat " + TEST_STATUS_FILE
+    crashed_test = subprocess.Popen(shell_cmd_str, shell=True,
+                                    stdout=subprocess.PIPE).communicate()[0]
+    logging.info(crashed_test + " CRASHED")
+    crashed_tests.append(crashed_test)
+    logging.info("Resuming reliability test runner...")
+
+    test_cmd = (test_cmd_prefix + " -e class "
+                "com.android.dumprendertree.ReliabilityTestsAutoTest#"
+                "resumeReliabilityTests -e timeout " + timeout_ms
+                + test_cmd_postfix)
+    adb_output = subprocess.Popen(test_cmd, shell=True, stdout=subprocess.PIPE,
+                                  stderr=subprocess.PIPE).communicate()[0]
+
+  time_end = time.time()
+  fp = open("time_stat", "a")
+  fp.writelines("%.2f\n" % ((time_end - time_start) / NUM_URLS / 2))
+  fp.close()
+  if (adb_output.find("INSTRUMENTATION_FAILED") != -1 or
+      adb_output.find("Process crashed.") != -1):
+    logging.error("Error happened : " + adb_output)
+    sys.exit(1)
+
+  logging.info(adb_output)
+  logging.info("Done\n")
+
+  if crashed_tests:
+    file_handle = open(crashed_file, "w")
+    file_handle.writelines("\n".join(crashed_tests))
+    logging.info("Crashed URL list stored in: " + crashed_file)
+    file_handle.close()
+  else:
+    logging.info("No crash found.")
+
+  test_cmd = (adb_cmd + "pull \"" + TEST_TIMEOUT_FILE + "\" \""
+              + timedout_file +  "\"")
+
+  subprocess.Popen(test_cmd, shell=True, stdout=subprocess.PIPE,
+                   stderr=subprocess.PIPE).communicate()
+
+
+if "__main__" == __name__:
+  option_parser = optparse.OptionParser()
+  option_parser.add_option("", "--time-out-ms",
+                           default=60000,
+                           help="set the timeout for each test")
+  option_parser.add_option("", "--verbose", action="store_true",
+                           default=False,
+                           help="include debug-level logging")
+  option_parser.add_option("", "--adb-options",
+                           default=None,
+                           help="pass options to adb, such as -d -e, etc")
+  option_parser.add_option("", "--crash-file",
+                           default="reliability_crashed_sites.txt",
+                           help="the list of sites that cause browser to crash")
+  option_parser.add_option("", "--timeout-file",
+                           default="reliability_timedout_sites.txt",
+                           help="the list of sites that timedout during test.")
+  opts, arguments = option_parser.parse_args()
+  main(opts, arguments)
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
index 562b1f3..caef861 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
@@ -41,6 +41,7 @@
     private BufferedOutputStream mBufferedOutputPassedStream;
     private BufferedOutputStream mBufferedOutputFailedStream;
     private BufferedOutputStream mBufferedOutputNoresultStream;
+    private BufferedOutputStream mBufferedOutputTimedoutStream;
     
     public void passed(String layout_file) {
         try {
@@ -72,11 +73,22 @@
         }
     }
     
+    public void timedout(String url) {
+        try {
+            mBufferedOutputTimedoutStream.write(url.getBytes());
+            mBufferedOutputTimedoutStream.write('\n');
+            mBufferedOutputTimedoutStream.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
     public MyTestRecorder(boolean resume) {
         try {
             File resultsPassedFile = new File("/sdcard/layout_tests_passed.txt");
             File resultsFailedFile = new File("/sdcard/layout_tests_failed.txt");
             File noExpectedResultFile = new File("/sdcard/layout_tests_nontext.txt");
+            File resultTimedoutFile = new File("/sdcard/layout_tests_timedout.txt");
           
             mBufferedOutputPassedStream =
                 new BufferedOutputStream(new FileOutputStream(resultsPassedFile, resume));
@@ -84,6 +96,8 @@
                 new BufferedOutputStream(new FileOutputStream(resultsFailedFile, resume));
             mBufferedOutputNoresultStream =
                 new BufferedOutputStream(new FileOutputStream(noExpectedResultFile, resume));
+            mBufferedOutputTimedoutStream =
+                new BufferedOutputStream(new FileOutputStream(resultTimedoutFile, resume));
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -94,6 +108,7 @@
             mBufferedOutputPassedStream.close();
             mBufferedOutputFailedStream.close();
             mBufferedOutputNoresultStream.close();
+            mBufferedOutputTimedoutStream.close();
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -281,7 +296,10 @@
                     mFinished = true;
                     LayoutTestsAutoTest.this.notifyAll();
                 }
-            }         
+            }
+            
+            public void timedOut(String url) {
+            }
         });
 
         String resultFile = getResultFile(test);
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
index 5cb5155..81cf3a8 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java
@@ -42,7 +42,7 @@
     private boolean mFinished;
     static final String LOAD_TEST_RUNNER_FILES[] = {
         "run_page_cycler.py"
-  };
+    };
 
     public LoadTestsAutoTest() {
         super("com.android.dumprendertree", TestShellActivity.class);
@@ -134,6 +134,9 @@
                     LoadTestsAutoTest.this.notifyAll();
                 }
             }
+            
+            public void timedOut(String url) {
+            }
         });
 
         mFinished = false;
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestsAutoTest.java
new file mode 100644
index 0000000..347efde
--- /dev/null
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestsAutoTest.java
@@ -0,0 +1,209 @@
+package com.android.dumprendertree;
+
+import com.android.dumprendertree.TestShellActivity.DumpDataType;
+
+import android.content.Intent;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Vector;
+
+public class ReliabilityTestsAutoTest extends ActivityInstrumentationTestCase2<TestShellActivity> {
+
+    private static final String LOGTAG = "ReliabilityTests";
+    private static final String TEST_LIST_FILE = "/sdcard/android/reliability_tests_list.txt";
+    private static final String TEST_STATUS_FILE = "/sdcard/android/reliability_running_test.txt";
+    private static final String TEST_TIMEOUT_FILE = "/sdcard/android/reliability_timeout_test.txt";
+    static final String RELIABILITY_TEST_RUNNER_FILES[] = {
+        "run_reliability_tests.py"
+    };
+
+    private boolean finished;
+    private List<String> testList; 
+
+    public ReliabilityTestsAutoTest() {
+        super("com.android.dumprendertree", TestShellActivity.class);
+    }
+
+    private void getTestList() {
+        // Read test list.
+        testList = new Vector<String>();
+        try {
+            BufferedReader inReader = new BufferedReader(new FileReader(TEST_LIST_FILE));
+            String line;
+            while ((line = inReader.readLine()) != null) {
+                testList.add(line);
+            }
+            inReader.close();
+            Log.v(LOGTAG, "Test list has " + testList.size() + " test(s).");
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Error while reading test list : " + e.getMessage());
+        }
+    }
+
+    private void resumeTestList() {
+        // read out the test name it stopped last time.
+        try {
+            BufferedReader inReader = new BufferedReader(new FileReader(TEST_STATUS_FILE));
+            String line = inReader.readLine();
+            for (int i = 0; i < testList.size(); i++) {
+                if (testList.get(i).equals(line)) {
+                    testList = new Vector<String>(testList.subList(i+1, testList.size()));
+                    break;
+                }
+            }
+            inReader.close();
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Error reading " + TEST_STATUS_FILE);
+        }
+    }
+
+    private void clearTestStatus() {
+        // Delete TEST_STATUS_FILE
+        try {
+            File f = new File(TEST_STATUS_FILE);
+            if (f.delete())
+                Log.v(LOGTAG, "Deleted " + TEST_STATUS_FILE);
+            else
+                Log.e(LOGTAG, "Fail to delete " + TEST_STATUS_FILE);
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Fail to delete " + TEST_STATUS_FILE + " : " + e.getMessage());
+        }
+    }
+
+    private void clearTestTimeout() {
+        // Delete TEST_TIMEOUT_FILE
+        try {
+            File f = new File(TEST_TIMEOUT_FILE);
+            if (f.delete())
+                Log.v(LOGTAG, "Deleted " + TEST_TIMEOUT_FILE);
+            else
+                Log.e(LOGTAG, "Fail to delete " + TEST_TIMEOUT_FILE);
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Fail to delete " + TEST_TIMEOUT_FILE + " : " + e.getMessage());
+        }
+    }
+
+    private void updateTestStatus(String s) {
+        // Write TEST_STATUS_FILE
+        try {
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(TEST_STATUS_FILE));
+            bos.write(s.getBytes());
+            bos.close();
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Cannot update file " + TEST_STATUS_FILE);
+        }
+    }
+
+    private void writeTimeoutFile(String s) {
+        // Write TEST_TIMEOUT_FILE
+        try {
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(TEST_TIMEOUT_FILE, true));
+            bos.write(s.getBytes());
+            bos.write('\n');
+            bos.close();
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Cannot update file " + TEST_TIMEOUT_FILE);
+        }
+    }
+
+    private void runReliabilityTest(boolean resume) {
+        LayoutTestsAutoRunner runner = (LayoutTestsAutoRunner) getInstrumentation();
+
+        getTestList();
+        if(!resume)
+            clearTestStatus();
+        else
+            resumeTestList();
+
+        TestShellActivity activity = getActivity();
+        activity.setDefaultDumpDataType(DumpDataType.NO_OP);
+        // Run tests.
+        for (int i = 0; i < testList.size(); i++) {
+            String s = testList.get(i);
+            updateTestStatus(s);
+            // Run tests
+            runTestAndWaitUntilDone(activity, s, runner.mTimeoutInMillis);
+        }
+
+        updateTestStatus("#DONE");
+
+        activity.finish();
+    }
+
+    private void runTestAndWaitUntilDone(TestShellActivity activity, String url, int timeout) {
+        activity.setCallback(new TestShellCallback() {
+            public void finished() {
+                synchronized (ReliabilityTestsAutoTest.this) {
+                    finished = true;
+                    ReliabilityTestsAutoTest.this.notifyAll();
+                }
+            }
+
+            public void timedOut(String url) {
+                writeTimeoutFile(url);
+            }
+        });
+
+        finished = false;
+        Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setClass(activity, TestShellActivity.class);
+        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+        intent.putExtra(TestShellActivity.TEST_URL, url);
+        intent.putExtra(TestShellActivity.TIMEOUT_IN_MILLIS, timeout);
+        activity.startActivity(intent);
+
+        // Wait until done.
+        synchronized (this) {
+            while(!finished){
+                try {
+                    this.wait();
+                } catch (InterruptedException e) { }
+            }
+        }
+    }
+
+    public void startReliabilityTests() {
+        clearTestTimeout();
+        runReliabilityTest(false);
+    }
+
+    public void resumeReliabilityTests() {
+        runReliabilityTest(true);
+    }
+
+    public void copyRunnerAssetsToCache() {
+        try {
+            String out_dir = getActivity().getApplicationContext()
+            .getCacheDir().getPath() + "/";
+
+            for( int i=0; i< RELIABILITY_TEST_RUNNER_FILES.length; i++) {
+                InputStream in = getActivity().getAssets().open(
+                        RELIABILITY_TEST_RUNNER_FILES[i]);
+                OutputStream out = new FileOutputStream(
+                        out_dir + RELIABILITY_TEST_RUNNER_FILES[i]);
+
+                byte[] buf = new byte[2048];
+                int len;
+
+                while ((len = in.read(buf)) >= 0 ) {
+                    out.write(buf, 0, len);
+                }
+                out.close();
+                in.close();
+            }
+        }catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index 404d101..1ba291c9 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -16,29 +16,40 @@
 
 package com.android.dumprendertree;
 
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.http.SslError;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.ViewGroup;
+import android.webkit.HttpAuthHandler;
+import android.webkit.JsPromptResult;
+import android.webkit.JsResult;
+import android.webkit.SslErrorHandler;
+import android.webkit.WebChromeClient;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.LinearLayout;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Vector;
 
-import android.app.Activity;
-import android.content.Intent;
-import android.util.Log;
-import android.webkit.JsPromptResult;
-import android.webkit.JsResult;
-import android.view.ViewGroup;
-import android.webkit.WebChromeClient;
-import android.webkit.WebSettings;
-import android.webkit.WebView;
-import android.widget.LinearLayout;
-import android.os.*;
-
 public class TestShellActivity extends Activity implements LayoutTestController {
+    
+    static enum DumpDataType {DUMP_AS_TEXT, EXT_REPR, NO_OP}
+    
     public class AsyncHandler extends Handler {
         @Override
         public void handleMessage(Message msg) {
             if (msg.what == MSG_TIMEOUT) {
                 mTimedOut = true;
+                mCallback.timedOut(mWebView.getUrl());
                 requestWebKitData();
                 return;
             } else if (msg.what == MSG_WEBKIT_DATA) {
@@ -57,10 +68,16 @@
             throw new AssertionError("Requested webkit data twice: " + mWebView.getUrl());
         
         mRequestedWebKitData = true;
-        if (mDumpAsText) { 
-            mWebView.documentAsText(callback);
-        } else {
-            mWebView.externalRepresentation(callback);
+        switch (mDumpDataType) {
+            case DUMP_AS_TEXT:
+                mWebView.documentAsText(callback);
+                break;
+            case EXT_REPR:
+                mWebView.externalRepresentation(callback);
+                break;
+            default:
+                finished();
+                break;
         }
     } 
 
@@ -75,6 +92,41 @@
         mWebView = new WebView(this);
         mWebView.getSettings().setJavaScriptEnabled(true);
         mWebView.setWebChromeClient(mChromeClient);
+        mWebView.setWebViewClient(new WebViewClient(){
+
+            @Override
+            public void onPageFinished(WebView view, String url) {
+                Log.v(LOGTAG, "onPageFinished, url=" + url);
+                super.onPageFinished(view, url);
+            }
+
+            @Override
+            public void onPageStarted(WebView view, String url, Bitmap favicon) {
+                Log.v(LOGTAG, "onPageStarted, url=" + url);
+                super.onPageStarted(view, url, favicon);
+            }
+
+            @Override
+            public void onReceivedError(WebView view, int errorCode, String description,
+                    String failingUrl) {
+                Log.v(LOGTAG, "onReceivedError, errorCode=" + errorCode
+                        + ", desc=" + description + ", url=" + failingUrl);
+                super.onReceivedError(view, errorCode, description, failingUrl);
+            }
+
+            @Override
+            public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler,
+                    String host, String realm) {
+                handler.cancel();
+            }
+
+            @Override
+            public void onReceivedSslError(WebView view, SslErrorHandler handler,
+                    SslError error) {
+                handler.proceed();
+            }
+
+        });
         mEventSender = new WebViewEventSender(mWebView);
         mCallbackProxy = new CallbackProxy(mEventSender, this);
 
@@ -186,10 +238,14 @@
         }
     }
    
+    public void setDefaultDumpDataType(DumpDataType defaultDumpDataType) {
+        mDefaultDumpDataType = defaultDumpDataType;
+    }
+
     // .......................................
     // LayoutTestController Functions
     public void dumpAsText() {
-        mDumpAsText = true;
+        mDumpDataType = DumpDataType.DUMP_AS_TEXT;
         if (mWebView != null) {
             String url = mWebView.getUrl();
             Log.v(LOGTAG, "dumpAsText called: "+url);
@@ -382,7 +438,7 @@
     
     private void resetTestStatus() {
         mWaitUntilDone = false;
-        mDumpAsText = false;
+        mDumpDataType = mDefaultDumpDataType;
         mTimedOut = false;
         mDumpTitleChanges = false;
         mRequestedWebKitData = false;
@@ -406,7 +462,8 @@
     private boolean mFinishedRunning;
 
     // Layout test controller variables.
-    private boolean mDumpAsText;
+    private DumpDataType mDumpDataType;
+    private DumpDataType mDefaultDumpDataType = DumpDataType.EXT_REPR;
     private boolean mWaitUntilDone;
     private boolean mDumpTitleChanges;
     private StringBuffer mTitleChanges;
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java
index 759c443..55bf947 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellCallback.java
@@ -18,4 +18,5 @@
 
 public interface TestShellCallback {
     public void finished();
+    public void timedOut(String url);
 }
diff --git a/tests/backup/src/com/android/backuptest/BackupTestService.java b/tests/backup/src/com/android/backuptest/BackupTestService.java
index 99f3e55..c58c98b 100644
--- a/tests/backup/src/com/android/backuptest/BackupTestService.java
+++ b/tests/backup/src/com/android/backuptest/BackupTestService.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.example.android.apis.app;
+package com.android.backuptest;
 
 import android.backup.BackupService;
 import android.os.ParcelFileDescriptor;
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index a09b1a6..ef11a83 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -1225,7 +1225,7 @@
                         // pseudolocalize here
                         block.setPosition(parserPosition);
                         err = parseAndAddEntry(bundle, in, &block, pseudoParams, myPackage, curType,
-                                ident, *curTag, curIsStyled, curFormat, true, false, outTable);
+                                ident, *curTag, curIsStyled, curFormat, true, overwrite, outTable);
                         if (err != NO_ERROR) {
                             hasErrors = localHasErrors = true;
                         }