auto import from //branches/cupcake/...@130745
diff --git a/Android.mk b/Android.mk
index d67a21e..764e88b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -97,7 +97,9 @@
 	core/java/android/view/IWindowManager.aidl \
 	core/java/android/view/IWindowSession.aidl \
 	core/java/com/android/internal/app/IBatteryStats.aidl \
+	core/java/com/android/internal/app/IUsageStats.aidl \
 	core/java/com/android/internal/gadget/IGadgetService.aidl \
+	core/java/com/android/internal/gadget/IGadgetHost.aidl \
 	core/java/com/android/internal/view/IInputContext.aidl \
 	core/java/com/android/internal/view/IInputContextCallback.aidl \
 	core/java/com/android/internal/view/IInputMethod.aidl \
@@ -173,6 +175,7 @@
 	frameworks/base/core/java/android/view/MotionEvent.aidl \
 	frameworks/base/core/java/android/view/Surface.aidl \
 	frameworks/base/core/java/android/view/WindowManager.aidl \
+	frameworks/base/core/java/android/widget/RemoteViews.aidl \
 	frameworks/base/core/java/com/android/internal/view/IInputContext.aidl \
 	frameworks/base/core/java/com/android/internal/view/IInputMethod.aidl \
 	frameworks/base/core/java/com/android/internal/view/IInputMethodCallback.aidl \
diff --git a/api/3.xml b/api/3.xml
index 9d9ce98..66cdbe8 100644
--- a/api/3.xml
+++ b/api/3.xml
@@ -79027,7 +79027,7 @@
  type="java.lang.String"
  transient="false"
  volatile="false"
- value=""name ASC""
+ value=""bucket_display_name""
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -79385,7 +79385,7 @@
  type="java.lang.String"
  transient="false"
  volatile="false"
- value=""name ASC""
+ value=""_display_name""
  static="true"
  final="true"
  deprecated="not deprecated"
diff --git a/api/current.xml b/api/current.xml
index 935454a..55994fb 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -144,6 +144,17 @@
  visibility="public"
 >
 </field>
+<field name="BIND_GADGET"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.permission.BIND_GADGET&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="BIND_INPUT_METHOD"
  type="java.lang.String"
  transient="false"
@@ -595,6 +606,17 @@
  visibility="public"
 >
 </field>
+<field name="MOUNT_FORMAT_FILESYSTEMS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.permission.MOUNT_FORMAT_FILESYSTEMS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="MOUNT_UNMOUNT_FILESYSTEMS"
  type="java.lang.String"
  transient="false"
@@ -606,6 +628,17 @@
  visibility="public"
 >
 </field>
+<field name="PACKAGE_USAGE_STATS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.permission.PACKAGE_USAGE_STATS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="PERSISTENT_ACTIVITY"
  type="java.lang.String"
  transient="false"
@@ -1013,6 +1046,17 @@
  visibility="public"
 >
 </field>
+<field name="UPDATE_DEVICE_STATS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.permission.UPDATE_DEVICE_STATS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="VIBRATE"
  type="java.lang.String"
  transient="false"
@@ -1571,6 +1615,17 @@
  visibility="public"
 >
 </field>
+<field name="allowSingleTap"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843353"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="allowTaskReparenting"
  type="int"
  transient="false"
@@ -1626,6 +1681,17 @@
  visibility="public"
 >
 </field>
+<field name="animateOnClick"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843356"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="animation"
  type="int"
  transient="false"
@@ -1857,6 +1923,17 @@
  visibility="public"
 >
 </field>
+<field name="bottomOffset"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843351"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="bottomRightRadius"
  type="int"
  transient="false"
@@ -2224,7 +2301,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843336"
+ value="16843330"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -2352,6 +2429,17 @@
  visibility="public"
 >
 </field>
+<field name="configure"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843357"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="constantSize"
  type="int"
  transient="false"
@@ -2363,6 +2451,17 @@
  visibility="public"
 >
 </field>
+<field name="content"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843355"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="cropToPadding"
  type="int"
  transient="false"
@@ -3104,7 +3203,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843349"
+ value="16843343"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3441,6 +3540,17 @@
  visibility="public"
 >
 </field>
+<field name="handle"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843354"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="handleProfiling"
  type="int"
  transient="false"
@@ -3522,7 +3632,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843333"
+ value="16843327"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3566,7 +3676,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843343"
+ value="16843337"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3742,7 +3852,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843351"
+ value="16843345"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3863,7 +3973,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843340"
+ value="16843334"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3874,7 +3984,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843342"
+ value="16843336"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3885,7 +3995,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843348"
+ value="16843342"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3896,7 +4006,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843341"
+ value="16843335"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3973,7 +4083,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843339"
+ value="16843333"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3984,7 +4094,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843332"
+ value="16843326"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -3995,7 +4105,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843346"
+ value="16843340"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -4006,7 +4116,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843345"
+ value="16843339"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -4017,7 +4127,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843344"
+ value="16843338"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -4083,7 +4193,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843331"
+ value="16843325"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -4094,7 +4204,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843347"
+ value="16843341"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -5359,7 +5469,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843338"
+ value="16843332"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -5370,7 +5480,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843337"
+ value="16843331"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -5381,7 +5491,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843329"
+ value="16843323"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -5821,7 +5931,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843335"
+ value="16843329"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -6330,7 +6440,7 @@
  value="16843101"
  static="true"
  final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </field>
@@ -6602,7 +6712,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843330"
+ value="16843324"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -7511,6 +7621,17 @@
  visibility="public"
 >
 </field>
+<field name="topOffset"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843352"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="topRightRadius"
  type="int"
  transient="false"
@@ -7570,7 +7691,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843350"
+ value="16843344"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -7636,7 +7757,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843328"
+ value="16843322"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -7658,7 +7779,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="16843334"
+ value="16843328"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -7698,6 +7819,61 @@
  visibility="public"
 >
 </field>
+<field name="voiceLanguage"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843349"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="voiceLanguageModel"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843347"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="voiceMaxResults"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843350"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="voicePromptText"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843348"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="voiceSearchMode"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843346"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="webViewStyle"
  type="int"
  transient="false"
@@ -7863,6 +8039,17 @@
  visibility="public"
 >
 </field>
+<field name="windowNoDisplay"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843294"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="windowNoTitle"
  type="int"
  transient="false"
@@ -7985,6 +8172,23 @@
 >
 </field>
 </class>
+<class name="R.bool"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="R.bool"
+ type="android.R.bool"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+</class>
 <class name="R.color"
  extends="java.lang.Object"
  abstract="false"
@@ -8475,6 +8679,17 @@
  visibility="public"
 >
 </field>
+<field name="dark_header"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17301686"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="dialog_frame"
  type="int"
  transient="false"
@@ -8783,6 +8998,17 @@
  visibility="public"
 >
 </field>
+<field name="ic_btn_speak_now"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17301685"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="ic_delete"
  type="int"
  transient="false"
@@ -10169,6 +10395,17 @@
  visibility="public"
 >
 </field>
+<field name="title_bar_tall"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17301687"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="toast_frame"
  type="int"
  transient="false"
@@ -10208,6 +10445,17 @@
  visibility="public"
 >
 </constructor>
+<field name="addToDictionary"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16908330"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="background"
  type="int"
  transient="false"
@@ -10439,17 +10687,6 @@
  visibility="public"
 >
 </field>
-<field name="inputMethod"
- type="int"
- transient="false"
- volatile="false"
- value="16908324"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="keyboardView"
  type="int"
  transient="false"
@@ -10549,6 +10786,28 @@
  visibility="public"
 >
 </field>
+<field name="startSelectingText"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16908328"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="stopSelectingText"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16908329"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="summary"
  type="int"
  transient="false"
@@ -10560,6 +10819,17 @@
  visibility="public"
 >
 </field>
+<field name="switchInputMethod"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16908324"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="tabcontent"
  type="int"
  transient="false"
@@ -11035,6 +11305,17 @@
  visibility="public"
 >
 </field>
+<field name="dialog_alert_title"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="17039380"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="emptyPhoneNumber"
  type="int"
  transient="false"
@@ -13234,7 +13515,18 @@
 <parameter name="event" type="android.view.MotionEvent">
 </parameter>
 </method>
-<method name="onUserLeaving"
+<method name="onUserInteraction"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="onUserLeaveHint"
  return="void"
  abstract="false"
  native="false"
@@ -13632,6 +13924,19 @@
 <parameter name="textColor" type="int">
 </parameter>
 </method>
+<method name="setVisible"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="visible" type="boolean">
+</parameter>
+</method>
 <method name="setVolumeControlStream"
  return="void"
  abstract="false"
@@ -13946,6 +14251,17 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<method name="getDeviceConfigurationInfo"
+ return="android.content.pm.ConfigurationInfo"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getMemoryInfo"
  return="void"
  abstract="false"
@@ -14028,6 +14344,19 @@
 <exception name="SecurityException" type="java.lang.SecurityException">
 </exception>
 </method>
+<method name="restartPackage"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="packageName" type="java.lang.String">
+</parameter>
+</method>
 <field name="RECENT_WITH_EXCLUDED"
  type="int"
  transient="false"
@@ -14499,6 +14828,81 @@
  visibility="public"
 >
 </field>
+<field name="IMPORTANCE_BACKGROUND"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="400"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="IMPORTANCE_EMPTY"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="500"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="IMPORTANCE_FOREGROUND"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="100"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="IMPORTANCE_SERVICE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="300"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="IMPORTANCE_VISIBLE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="200"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="importance"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="lru"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="pid"
  type="int"
  transient="false"
@@ -18219,7 +18623,7 @@
 </constructor>
 <method name="getTargetIntent"
  return="android.content.Intent"
- abstract="true"
+ abstract="false"
  native="false"
  synchronized="false"
  static="false"
@@ -18228,6 +18632,117 @@
  visibility="protected"
 >
 </method>
+<method name="intentForPosition"
+ return="android.content.Intent"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="position" type="int">
+</parameter>
+</method>
+<method name="makeListItems"
+ return="java.util.List&lt;android.app.LauncherActivity.ListItem&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</class>
+<class name="LauncherActivity.IconResizer"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="LauncherActivity.IconResizer"
+ type="android.app.LauncherActivity.IconResizer"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="createIconThumbnail"
+ return="android.graphics.drawable.Drawable"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="icon" type="android.graphics.drawable.Drawable">
+</parameter>
+</method>
+</class>
+<class name="LauncherActivity.ListItem"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="LauncherActivity.ListItem"
+ type="android.app.LauncherActivity.ListItem"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<field name="className"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="icon"
+ type="android.graphics.drawable.Drawable"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="label"
+ type="java.lang.CharSequence"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="packageName"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <class name="ListActivity"
  extends="android.app.Activity"
@@ -20766,6 +21281,21 @@
 <parameter name="intent" type="android.content.Intent">
 </parameter>
 </method>
+<method name="peekService"
+ return="android.os.IBinder"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="myContext" type="android.content.Context">
+</parameter>
+<parameter name="service" type="android.content.Intent">
+</parameter>
+</method>
 <method name="setDebugUnregister"
  return="void"
  abstract="false"
@@ -26629,6 +27159,17 @@
  visibility="public"
 >
 </field>
+<field name="ACTION_MEDIA_CHECKING"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.action.MEDIA_CHECKING&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="ACTION_MEDIA_EJECT"
  type="java.lang.String"
  transient="false"
@@ -26651,6 +27192,17 @@
  visibility="public"
 >
 </field>
+<field name="ACTION_MEDIA_NOFS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.action.MEDIA_NOFS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="ACTION_MEDIA_REMOVED"
  type="java.lang.String"
  transient="false"
@@ -26761,6 +27313,17 @@
  visibility="public"
 >
 </field>
+<field name="ACTION_PACKAGE_DATA_CLEARED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.action.PACKAGE_DATA_CLEARED&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="ACTION_PACKAGE_INSTALL"
  type="java.lang.String"
  transient="false"
@@ -27266,6 +27829,17 @@
  visibility="public"
 >
 </field>
+<field name="EXTRA_DATA_REMOVED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.extra.DATA_REMOVED&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="EXTRA_DONT_KILL_APP"
  type="java.lang.String"
  transient="false"
@@ -27321,6 +27895,17 @@
  visibility="public"
 >
 </field>
+<field name="EXTRA_REPLACING"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.extra.REPLACING&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="EXTRA_SHORTCUT_ICON"
  type="java.lang.String"
  transient="false"
@@ -27596,6 +28181,17 @@
  visibility="public"
 >
 </field>
+<field name="FLAG_ACTIVITY_REORDER_TO_FRONT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="131072"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="FLAG_ACTIVITY_RESET_TASK_IF_NEEDED"
  type="int"
  transient="false"
@@ -31453,6 +32049,17 @@
 <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
 </exception>
 </method>
+<method name="getSystemSharedLibraryNames"
+ return="java.lang.String[]"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getText"
  return="java.lang.CharSequence"
  abstract="true"
@@ -31517,6 +32124,17 @@
 <parameter name="packageURI" type="android.net.Uri">
 </parameter>
 </method>
+<method name="isSafeMode"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="queryBroadcastReceivers"
  return="java.util.List&lt;android.content.pm.ResolveInfo&gt;"
  abstract="true"
@@ -34550,6 +35168,23 @@
 <exception name="Resources.NotFoundException" type="android.content.res.Resources.NotFoundException">
 </exception>
 </method>
+<method name="getFraction"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+<parameter name="base" type="int">
+</parameter>
+<parameter name="pbase" type="int">
+</parameter>
+</method>
 <method name="getIdentifier"
  return="int"
  abstract="false"
@@ -42713,6 +43348,35 @@
 </parameter>
 <parameter name="stride" type="int">
 </parameter>
+<parameter name="x" type="float">
+</parameter>
+<parameter name="y" type="float">
+</parameter>
+<parameter name="width" type="int">
+</parameter>
+<parameter name="height" type="int">
+</parameter>
+<parameter name="hasAlpha" type="boolean">
+</parameter>
+<parameter name="paint" type="android.graphics.Paint">
+</parameter>
+</method>
+<method name="drawBitmap"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="colors" type="int[]">
+</parameter>
+<parameter name="offset" type="int">
+</parameter>
+<parameter name="stride" type="int">
+</parameter>
 <parameter name="x" type="int">
 </parameter>
 <parameter name="y" type="int">
@@ -52106,6 +52770,17 @@
  visibility="public"
 >
 </method>
+<method name="mutate"
+ return="android.graphics.drawable.Drawable"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onBoundsChange"
  return="void"
  abstract="false"
@@ -54520,6 +55195,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="java.lang.Cloneable">
+</implements>
 <constructor name="Shape"
  type="android.graphics.drawable.shapes.Shape"
  static="false"
@@ -54528,6 +55205,19 @@
  visibility="public"
 >
 </constructor>
+<method name="clone"
+ return="android.graphics.drawable.shapes.Shape"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<exception name="CloneNotSupportedException" type="java.lang.CloneNotSupportedException">
+</exception>
+</method>
 <method name="draw"
  return="void"
  abstract="true"
@@ -55171,6 +55861,108 @@
 >
 </field>
 </class>
+<class name="GeomagneticField"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="GeomagneticField"
+ type="android.hardware.GeomagneticField"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="gdLatitudeDeg" type="float">
+</parameter>
+<parameter name="gdLongitudeDeg" type="float">
+</parameter>
+<parameter name="altitudeMeters" type="float">
+</parameter>
+<parameter name="timeMillis" type="long">
+</parameter>
+</constructor>
+<method name="getDeclination"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getFieldStrength"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getHorizontalStrength"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getInclination"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getX"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getY"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getZ"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</class>
 <class name="Sensor"
  extends="java.lang.Object"
  abstract="false"
@@ -56605,6 +57397,28 @@
 <parameter name="defStyle" type="int">
 </parameter>
 </constructor>
+<method name="finishInternalChanges"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="startInternalChanges"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 </class>
 <class name="InputMethodService"
  extends="android.inputmethodservice.AbstractInputMethodService"
@@ -56635,6 +57449,17 @@
 <parameter name="flags" type="int">
 </parameter>
 </method>
+<method name="getCandidatesHiddenVisibility"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getCurrentInputBinding"
  return="android.view.inputmethod.InputBinding"
  abstract="false"
@@ -56745,6 +57570,17 @@
  visibility="public"
 >
 </method>
+<method name="isShowInputRequested"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onAppPrivateCommand"
  return="void"
  abstract="false"
@@ -56902,6 +57738,58 @@
  visibility="public"
 >
 </method>
+<method name="onExtractTextContextMenuItem"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+</method>
+<method name="onExtractedSelectionChanged"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="start" type="int">
+</parameter>
+<parameter name="end" type="int">
+</parameter>
+</method>
+<method name="onExtractedTextClicked"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="onFinishCandidatesView"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="finishingInput" type="boolean">
+</parameter>
+</method>
 <method name="onFinishInput"
  return="void"
  abstract="false"
@@ -56913,6 +57801,30 @@
  visibility="public"
 >
 </method>
+<method name="onFinishInputView"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="finishingInput" type="boolean">
+</parameter>
+</method>
+<method name="onInitializeInterface"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onKeyDown"
  return="boolean"
  abstract="false"
@@ -56973,6 +57885,21 @@
 <parameter name="flags" type="int">
 </parameter>
 </method>
+<method name="onStartCandidatesView"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="info" type="android.view.inputmethod.EditorInfo">
+</parameter>
+<parameter name="restarting" type="boolean">
+</parameter>
+</method>
 <method name="onStartInput"
  return="void"
  abstract="false"
@@ -57242,6 +58169,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="ic" type="android.view.inputmethod.InputConnection">
+</parameter>
 <parameter name="attribute" type="android.view.inputmethod.EditorInfo">
 </parameter>
 </method>
@@ -57268,6 +58197,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="ic" type="android.view.inputmethod.InputConnection">
+</parameter>
 <parameter name="attribute" type="android.view.inputmethod.EditorInfo">
 </parameter>
 </method>
@@ -60857,6 +61788,111 @@
 >
 </method>
 </class>
+<class name="AudioFormat"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="AudioFormat"
+ type="android.media.AudioFormat"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<field name="CHANNEL_CONFIGURATION_DEFAULT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CHANNEL_CONFIGURATION_INVALID"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CHANNEL_CONFIGURATION_MONO"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CHANNEL_CONFIGURATION_STEREO"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ENCODING_DEFAULT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ENCODING_INVALID"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ENCODING_PCM_16BIT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ENCODING_PCM_8BIT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
 <class name="AudioManager"
  extends="java.lang.Object"
  abstract="false"
@@ -61248,6 +62284,17 @@
  visibility="public"
 >
 </method>
+<field name="ACTION_AUDIO_BECOMING_NOISY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.media.AUDIO_BECOMING_NOISY&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="ADJUST_LOWER"
  type="int"
  transient="false"
@@ -61755,6 +62802,990 @@
 >
 </field>
 </class>
+<class name="AudioRecord"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="AudioRecord"
+ type="android.media.AudioRecord"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="audioSource" type="int">
+</parameter>
+<parameter name="sampleRateInHz" type="int">
+</parameter>
+<parameter name="channelConfig" type="int">
+</parameter>
+<parameter name="audioFormat" type="int">
+</parameter>
+<parameter name="bufferSizeInBytes" type="int">
+</parameter>
+<exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
+</exception>
+</constructor>
+<method name="getAudioFormat"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getAudioSource"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getChannelConfiguration"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getChannelCount"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getNotificationMarkerPosition"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getPositionNotificationPeriod"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getRecordingState"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSampleRate"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getState"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="read"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="audioData" type="byte[]">
+</parameter>
+<parameter name="offsetInBytes" type="int">
+</parameter>
+<parameter name="sizeInBytes" type="int">
+</parameter>
+</method>
+<method name="read"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="audioData" type="short[]">
+</parameter>
+<parameter name="offsetInShorts" type="int">
+</parameter>
+<parameter name="sizeInShorts" type="int">
+</parameter>
+</method>
+<method name="read"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="audioBuffer" type="java.nio.ByteBuffer">
+</parameter>
+<parameter name="sizeInBytes" type="int">
+</parameter>
+</method>
+<method name="release"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="setMarkerReachedListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.media.AudioRecord.OnMarkerReachedListener">
+</parameter>
+</method>
+<method name="setNotificationMarkerPosition"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="markerInFrames" type="int">
+</parameter>
+</method>
+<method name="setPeriodicNotificationListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.media.AudioRecord.OnPeriodicNotificationListener">
+</parameter>
+</method>
+<method name="setPositionNotificationPeriod"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="periodInFrames" type="int">
+</parameter>
+</method>
+<method name="startRecording"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<exception name="IllegalStateException" type="java.lang.IllegalStateException">
+</exception>
+</method>
+<method name="stop"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<exception name="IllegalStateException" type="java.lang.IllegalStateException">
+</exception>
+</method>
+<field name="ERROR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ERROR_BAD_VALUE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ERROR_INVALID_OPERATION"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RECORDSTATE_RECORDING"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RECORDSTATE_STOPPED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="STATE_INITIALIZED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="STATE_UNINITIALIZED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SUCCESS"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<interface name="AudioRecord.OnMarkerReachedListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onMarkerReached"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="recorder" type="android.media.AudioRecord">
+</parameter>
+</method>
+</interface>
+<interface name="AudioRecord.OnPeriodicNotificationListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onPeriodicNotification"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="recorder" type="android.media.AudioRecord">
+</parameter>
+</method>
+</interface>
+<class name="AudioTrack"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="AudioTrack"
+ type="android.media.AudioTrack"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="streamType" type="int">
+</parameter>
+<parameter name="sampleRateInHz" type="int">
+</parameter>
+<parameter name="channelConfig" type="int">
+</parameter>
+<parameter name="audioFormat" type="int">
+</parameter>
+<parameter name="bufferSizeInBytes" type="int">
+</parameter>
+<parameter name="mode" type="int">
+</parameter>
+<exception name="IllegalArgumentException" type="java.lang.IllegalArgumentException">
+</exception>
+</constructor>
+<method name="flush"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getAudioFormat"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getChannelConfiguration"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getChannelCount"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getMaxVolume"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getMinVolume"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getNativeFrameCount"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</method>
+<method name="getNativeOutputSampleRate"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getNotificationMarkerPosition"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getPlayState"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getPlaybackHeadPosition"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getPositionNotificationPeriod"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSampleRate"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getState"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getStreamType"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="pause"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<exception name="IllegalStateException" type="java.lang.IllegalStateException">
+</exception>
+</method>
+<method name="play"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<exception name="IllegalStateException" type="java.lang.IllegalStateException">
+</exception>
+</method>
+<method name="release"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="reloadStaticData"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="setLoopPoints"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="startInFrames" type="int">
+</parameter>
+<parameter name="endInFrames" type="int">
+</parameter>
+<parameter name="loopCount" type="int">
+</parameter>
+</method>
+<method name="setMarkerReachedListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.media.AudioTrack.OnMarkerReachedListener">
+</parameter>
+</method>
+<method name="setNotificationMarkerPosition"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="markerInFrames" type="int">
+</parameter>
+</method>
+<method name="setPeriodicNotificationListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.media.AudioTrack.OnPeriodicNotificationListener">
+</parameter>
+</method>
+<method name="setPlaybackHeadPosition"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="positionInFrames" type="int">
+</parameter>
+</method>
+<method name="setPlaybackRate"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="sampleRateInHz" type="int">
+</parameter>
+</method>
+<method name="setPositionNotificationPeriod"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="periodInFrames" type="int">
+</parameter>
+</method>
+<method name="setState"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="state" type="int">
+</parameter>
+</method>
+<method name="setStereoVolume"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="leftVolume" type="float">
+</parameter>
+<parameter name="rightVolume" type="float">
+</parameter>
+</method>
+<method name="stop"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<exception name="IllegalStateException" type="java.lang.IllegalStateException">
+</exception>
+</method>
+<method name="write"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="audioData" type="byte[]">
+</parameter>
+<parameter name="offsetInBytes" type="int">
+</parameter>
+<parameter name="sizeInBytes" type="int">
+</parameter>
+</method>
+<method name="write"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="audioData" type="short[]">
+</parameter>
+<parameter name="offsetInShorts" type="int">
+</parameter>
+<parameter name="sizeInShorts" type="int">
+</parameter>
+</method>
+<field name="ERROR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ERROR_BAD_VALUE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ERROR_INVALID_OPERATION"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MODE_STATIC"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="MODE_STREAM"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="PLAYSTATE_PAUSED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="PLAYSTATE_PLAYING"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="PLAYSTATE_STOPPED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="STATE_INITIALIZED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="STATE_NO_STATIC_DATA"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="STATE_UNINITIALIZED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SUCCESS"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<interface name="AudioTrack.OnMarkerReachedListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onMarkerReached"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="track" type="android.media.AudioTrack">
+</parameter>
+</method>
+</interface>
+<interface name="AudioTrack.OnPeriodicNotificationListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onPeriodicNotification"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="track" type="android.media.AudioTrack">
+</parameter>
+</method>
+</interface>
 <class name="FaceDetector"
  extends="java.lang.Object"
  abstract="false"
@@ -61894,6 +63925,349 @@
 >
 </field>
 </class>
+<class name="JetPlayer"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="clearQueue"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="clone"
+ return="java.lang.Object"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<exception name="CloneNotSupportedException" type="java.lang.CloneNotSupportedException">
+</exception>
+</method>
+<method name="closeJetFile"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getJetPlayer"
+ return="android.media.JetPlayer"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getMaxTracks"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="loadJetFile"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="path" type="java.lang.String">
+</parameter>
+</method>
+<method name="loadJetFile"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="afd" type="android.content.res.AssetFileDescriptor">
+</parameter>
+</method>
+<method name="pause"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="play"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="queueJetSegment"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="segmentNum" type="int">
+</parameter>
+<parameter name="libNum" type="int">
+</parameter>
+<parameter name="repeatCount" type="int">
+</parameter>
+<parameter name="transpose" type="int">
+</parameter>
+<parameter name="muteFlags" type="int">
+</parameter>
+<parameter name="userID" type="byte">
+</parameter>
+</method>
+<method name="queueJetSegmentMuteArray"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="segmentNum" type="int">
+</parameter>
+<parameter name="libNum" type="int">
+</parameter>
+<parameter name="repeatCount" type="int">
+</parameter>
+<parameter name="transpose" type="int">
+</parameter>
+<parameter name="muteArray" type="boolean[]">
+</parameter>
+<parameter name="userID" type="byte">
+</parameter>
+</method>
+<method name="release"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="setEventListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.media.JetPlayer.JetEventListener">
+</parameter>
+</method>
+<method name="setMuteArray"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="muteArray" type="boolean[]">
+</parameter>
+<parameter name="sync" type="boolean">
+</parameter>
+</method>
+<method name="setMuteFlag"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="trackId" type="int">
+</parameter>
+<parameter name="muteFlag" type="boolean">
+</parameter>
+<parameter name="sync" type="boolean">
+</parameter>
+</method>
+<method name="setMuteFlags"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="muteFlags" type="int">
+</parameter>
+<parameter name="sync" type="boolean">
+</parameter>
+</method>
+<method name="setStatusUpdateListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="listener" type="android.media.JetPlayer.JetStatusUpdateListener">
+</parameter>
+</method>
+<method name="triggerClip"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="clipId" type="int">
+</parameter>
+</method>
+</class>
+<interface name="JetPlayer.JetEventListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onJetEvent"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="player" type="android.media.JetPlayer">
+</parameter>
+<parameter name="segment" type="short">
+</parameter>
+<parameter name="track" type="byte">
+</parameter>
+<parameter name="channel" type="byte">
+</parameter>
+<parameter name="controller" type="byte">
+</parameter>
+<parameter name="value" type="byte">
+</parameter>
+</method>
+</interface>
+<interface name="JetPlayer.JetStatusUpdateListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onJetNumQueuedSegmentUpdate"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="player" type="android.media.JetPlayer">
+</parameter>
+<parameter name="nbSegments" type="int">
+</parameter>
+</method>
+<method name="onJetPauseUpdate"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="player" type="android.media.JetPlayer">
+</parameter>
+<parameter name="paused" type="int">
+</parameter>
+</method>
+<method name="onJetUserIdUpdate"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="player" type="android.media.JetPlayer">
+</parameter>
+<parameter name="userId" type="int">
+</parameter>
+<parameter name="repeatCount" type="int">
+</parameter>
+</method>
+</interface>
 <class name="MediaPlayer"
  extends="java.lang.Object"
  abstract="false"
@@ -64078,6 +66452,17 @@
  visibility="public"
 >
 </method>
+<method name="getBackgroundDataSetting"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getNetworkInfo"
  return="android.net.NetworkInfo"
  abstract="false"
@@ -64173,6 +66558,17 @@
 <parameter name="feature" type="java.lang.String">
 </parameter>
 </method>
+<field name="ACTION_BACKGROUND_DATA_SETTING_CHANGED"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.net.conn.BACKGROUND_DATA_SETTING_CHANGED&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="CONNECTIVITY_ACTION"
  type="java.lang.String"
  transient="false"
@@ -70693,6 +73089,21 @@
  static="false"
  final="false"
  deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fd" type="java.io.FileDescriptor">
+</parameter>
+<parameter name="args" type="java.lang.String[]">
+</parameter>
+</method>
+<method name="dump"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
  visibility="protected"
 >
 <parameter name="fd" type="java.io.FileDescriptor">
@@ -70924,6 +73335,16 @@
  visibility="public"
 >
 </field>
+<field name="DISPLAY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="FINGERPRINT"
  type="java.lang.String"
  transient="false"
@@ -72357,6 +74778,21 @@
 <parameter name="port" type="int">
 </parameter>
 </method>
+<method name="dumpHprofData"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fileName" type="java.lang.String">
+</parameter>
+<exception name="IOException" type="java.io.IOException">
+</exception>
+</method>
 <method name="enableEmulatorTraceOutput"
  return="void"
  abstract="false"
@@ -73288,6 +75724,17 @@
  visibility="public"
 >
 </field>
+<field name="MEDIA_CHECKING"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;checking&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="MEDIA_MOUNTED"
  type="java.lang.String"
  transient="false"
@@ -73310,6 +75757,17 @@
  visibility="public"
 >
 </field>
+<field name="MEDIA_NOFS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;nofs&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="MEDIA_REMOVED"
  type="java.lang.String"
  transient="false"
@@ -74103,6 +76561,23 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<method name="dump"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fd" type="java.io.FileDescriptor">
+</parameter>
+<parameter name="args" type="java.lang.String[]">
+</parameter>
+<exception name="RemoteException" type="android.os.RemoteException">
+</exception>
+</method>
 <method name="getInterfaceDescriptor"
  return="java.lang.String"
  abstract="true"
@@ -84042,6 +86517,28 @@
  visibility="public"
 >
 </method>
+<field name="ACTION_IMAGE_CAPTURE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.media.action.IMAGE_CAPTURE&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_VIDEO_CAPTURE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.media.action.VIDEO_CAPTURE&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="AUTHORITY"
  type="java.lang.String"
  transient="false"
@@ -84108,6 +86605,17 @@
  visibility="public"
 >
 </field>
+<field name="EXTRA_OUTPUT"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;output&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="EXTRA_SCREEN_ORIENTATION"
  type="java.lang.String"
  transient="false"
@@ -84119,6 +86627,17 @@
  visibility="public"
 >
 </field>
+<field name="EXTRA_VIDEO_QUALITY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.intent.extra.videoQuality&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="INTENT_ACTION_MEDIA_SEARCH"
  type="java.lang.String"
  transient="false"
@@ -85571,7 +88090,7 @@
  type="java.lang.String"
  transient="false"
  volatile="false"
- value="&quot;name ASC&quot;"
+ value="&quot;bucket_display_name&quot;"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -85929,7 +88448,7 @@
  type="java.lang.String"
  transient="false"
  volatile="false"
- value="&quot;name ASC&quot;"
+ value="&quot;_display_name&quot;"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -86042,6 +88561,17 @@
  visibility="public"
 >
 </field>
+<field name="BOOKMARK"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;bookmark&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="BUCKET_DISPLAY_NAME"
  type="java.lang.String"
  transient="false"
@@ -86450,6 +88980,17 @@
  visibility="public"
 >
 </field>
+<field name="ACTION_INPUT_METHOD_SETTINGS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.settings.INPUT_METHOD_SETTINGS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="ACTION_INTERNAL_STORAGE_SETTINGS"
  type="java.lang.String"
  transient="false"
@@ -86571,6 +89112,17 @@
  visibility="public"
 >
 </field>
+<field name="ACTION_USER_DICTIONARY_SETTINGS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.settings.USER_DICTIONARY_SETTINGS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="ACTION_WIFI_IP_SETTINGS"
  type="java.lang.String"
  transient="false"
@@ -88613,6 +91165,202 @@
 >
 </field>
 </class>
+<class name="UserDictionary"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="UserDictionary"
+ type="android.provider.UserDictionary"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<field name="AUTHORITY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;user_dictionary&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CONTENT_URI"
+ type="android.net.Uri"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<class name="UserDictionary.Words"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.provider.BaseColumns">
+</implements>
+<constructor name="UserDictionary.Words"
+ type="android.provider.UserDictionary.Words"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+<method name="addWord"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="word" type="java.lang.String">
+</parameter>
+<parameter name="frequency" type="int">
+</parameter>
+<parameter name="localeType" type="int">
+</parameter>
+</method>
+<field name="APP_ID"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;appid&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CONTENT_ITEM_TYPE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;vnd.android.cursor.item/vnd.google.userword&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CONTENT_TYPE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;vnd.android.cursor.dir/vnd.google.userword&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="CONTENT_URI"
+ type="android.net.Uri"
+ transient="false"
+ volatile="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="DEFAULT_SORT_ORDER"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;frequency DESC&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="FREQUENCY"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;frequency&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="LOCALE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;locale&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="LOCALE_TYPE_ALL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="LOCALE_TYPE_CURRENT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="WORD"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;word&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="_ID"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;_id&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
 </package>
 <package name="android.sax"
 >
@@ -88874,6 +91622,194 @@
 </implements>
 </interface>
 </package>
+<package name="android.speech"
+>
+<class name="RecognizerIntent"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<field name="ACTION_RECOGNIZE_SPEECH"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.action.RECOGNIZE_SPEECH&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ACTION_WEB_SEARCH"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.action.WEB_SEARCH&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_LANGUAGE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extra.LANGUAGE&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_LANGUAGE_MODEL"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extra.LANGUAGE_MODEL&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_MAX_RESULTS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extra.MAX_RESULTS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_PROMPT"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extra.PROMPT&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_RESULTS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extra.RESULTS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_RESULTS_PENDINGINTENT"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extra.RESULTS_PENDINGINTENT&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_RESULTS_PENDINGINTENT_BUNDLE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="LANGUAGE_MODEL_FREE_FORM"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;free_form&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="LANGUAGE_MODEL_WEB_SEARCH"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;web_search&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RESULT_AUDIO_ERROR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="5"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RESULT_CLIENT_ERROR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RESULT_NETWORK_ERROR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RESULT_NO_MATCH"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="RESULT_SERVER_ERROR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="3"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+</package>
 <package name="android.speech.srec"
 >
 <class name="MicrophoneInputStream"
@@ -96542,6 +99478,17 @@
 <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException">
 </exception>
 </method>
+<method name="getSystemSharedLibraryNames"
+ return="java.lang.String[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getText"
  return="java.lang.CharSequence"
  abstract="false"
@@ -96593,6 +99540,17 @@
 <parameter name="flags" type="int">
 </parameter>
 </method>
+<method name="isSafeMode"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="queryBroadcastReceivers"
  return="java.util.List&lt;android.content.pm.ResolveInfo&gt;"
  abstract="false"
@@ -97320,6 +100278,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="Annotation"
  type="android.text.Annotation"
  static="false"
@@ -97332,6 +100292,27 @@
 <parameter name="value" type="java.lang.String">
 </parameter>
 </constructor>
+<constructor name="Annotation"
+ type="android.text.Annotation"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getKey"
  return="java.lang.String"
  abstract="false"
@@ -97343,6 +100324,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getValue"
  return="java.lang.String"
  abstract="false"
@@ -97354,6 +100346,21 @@
  visibility="public"
 >
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="AutoText"
  extends="java.lang.Object"
@@ -98721,6 +101728,17 @@
  visibility="public"
 >
 </field>
+<field name="TYPE_TEXT_FLAG_IME_MULTI_LINE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="262144"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="TYPE_TEXT_FLAG_MULTI_LINE"
  type="int"
  transient="false"
@@ -98736,7 +101754,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="262144"
+ value="524288"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -98754,22 +101772,22 @@
  visibility="public"
 >
 </field>
-<field name="TYPE_TEXT_VARIATION_EMAIL_CONTENT"
+<field name="TYPE_TEXT_VARIATION_EMAIL_SUBJECT"
  type="int"
  transient="false"
  volatile="false"
- value="64"
+ value="48"
  static="true"
  final="true"
  deprecated="not deprecated"
  visibility="public"
 >
 </field>
-<field name="TYPE_TEXT_VARIATION_EMAIL_SUBJECT"
+<field name="TYPE_TEXT_VARIATION_LONG_MESSAGE"
  type="int"
  transient="false"
  volatile="false"
- value="48"
+ value="80"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -98791,7 +101809,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="112"
+ value="128"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -98802,7 +101820,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="80"
+ value="96"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -98813,18 +101831,18 @@
  type="int"
  transient="false"
  volatile="false"
- value="96"
+ value="112"
  static="true"
  final="true"
  deprecated="not deprecated"
  visibility="public"
 >
 </field>
-<field name="TYPE_TEXT_VARIATION_SEARCH_STRING"
+<field name="TYPE_TEXT_VARIATION_SHORT_MESSAGE"
  type="int"
  transient="false"
  volatile="false"
- value="128"
+ value="64"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -99762,6 +102780,54 @@
 </parameter>
 </method>
 </class>
+<interface name="NoCopySpan"
+ abstract="true"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</interface>
+<class name="NoCopySpan.Concrete"
+ extends="java.lang.Object"
+ abstract="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.text.NoCopySpan">
+</implements>
+<constructor name="NoCopySpan.Concrete"
+ type="android.text.NoCopySpan.Concrete"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</constructor>
+</class>
+<interface name="ParcelableSpan"
+ abstract="true"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<implements name="android.os.Parcelable">
+</implements>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</interface>
 <class name="Selection"
  extends="java.lang.Object"
  abstract="false"
@@ -100077,6 +103143,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.NoCopySpan">
+</implements>
 <method name="onSpanAdded"
  return="void"
  abstract="true"
@@ -100983,6 +104051,17 @@
  visibility="public"
 >
 </field>
+<field name="SPAN_INTERMEDIATE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="512"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="SPAN_MARK_MARK"
  type="int"
  transient="false"
@@ -102287,6 +105366,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.NoCopySpan">
+</implements>
 <method name="afterTextChanged"
  return="void"
  abstract="true"
@@ -104127,6 +107208,23 @@
 <parameter name="event" type="android.view.KeyEvent">
 </parameter>
 </method>
+<method name="onKeyOther"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="view" type="android.widget.TextView">
+</parameter>
+<parameter name="text" type="android.text.Spannable">
+</parameter>
+<parameter name="event" type="android.view.KeyEvent">
+</parameter>
+</method>
 <method name="onKeyUp"
  return="boolean"
  abstract="false"
@@ -104235,6 +107333,23 @@
 <parameter name="event" type="android.view.KeyEvent">
 </parameter>
 </method>
+<method name="onKeyOther"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="view" type="android.view.View">
+</parameter>
+<parameter name="content" type="android.text.Editable">
+</parameter>
+<parameter name="event" type="android.view.KeyEvent">
+</parameter>
+</method>
 </class>
 <class name="CharacterPickerDialog"
  extends="android.app.Dialog"
@@ -104676,6 +107791,23 @@
 <parameter name="event" type="android.view.KeyEvent">
 </parameter>
 </method>
+<method name="onKeyOther"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="view" type="android.view.View">
+</parameter>
+<parameter name="text" type="android.text.Editable">
+</parameter>
+<parameter name="event" type="android.view.KeyEvent">
+</parameter>
+</method>
 <method name="onKeyUp"
  return="boolean"
  abstract="true"
@@ -104784,6 +107916,21 @@
 </parameter>
 </method>
 <method name="clearMetaKeyState"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="content" type="android.text.Editable">
+</parameter>
+<parameter name="states" type="int">
+</parameter>
+</method>
+<method name="clearMetaKeyState"
  return="long"
  abstract="false"
  native="false"
@@ -105099,6 +108246,23 @@
 <parameter name="event" type="android.view.KeyEvent">
 </parameter>
 </method>
+<method name="onKeyOther"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="view" type="android.widget.TextView">
+</parameter>
+<parameter name="text" type="android.text.Spannable">
+</parameter>
+<parameter name="event" type="android.view.KeyEvent">
+</parameter>
+</method>
 <method name="onKeyUp"
  return="boolean"
  abstract="true"
@@ -105729,6 +108893,23 @@
 <parameter name="event" type="android.view.KeyEvent">
 </parameter>
 </method>
+<method name="onKeyOther"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="view" type="android.widget.TextView">
+</parameter>
+<parameter name="text" type="android.text.Spannable">
+</parameter>
+<parameter name="event" type="android.view.KeyEvent">
+</parameter>
+</method>
 <method name="onKeyUp"
  return="boolean"
  abstract="false"
@@ -106236,6 +109417,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="AbsoluteSizeSpan"
  type="android.text.style.AbsoluteSizeSpan"
  static="false"
@@ -106246,6 +109429,27 @@
 <parameter name="size" type="int">
 </parameter>
 </constructor>
+<constructor name="AbsoluteSizeSpan"
+ type="android.text.style.AbsoluteSizeSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getSize"
  return="int"
  abstract="false"
@@ -106257,6 +109461,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -106283,6 +109498,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <interface name="AlignmentSpan"
  abstract="true"
@@ -106315,6 +109545,8 @@
 >
 <implements name="android.text.style.AlignmentSpan">
 </implements>
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="AlignmentSpan.Standard"
  type="android.text.style.AlignmentSpan.Standard"
  static="false"
@@ -106325,6 +109557,27 @@
 <parameter name="align" type="android.text.Layout.Alignment">
 </parameter>
 </constructor>
+<constructor name="AlignmentSpan.Standard"
+ type="android.text.style.AlignmentSpan.Standard"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getAlignment"
  return="android.text.Layout.Alignment"
  abstract="false"
@@ -106336,6 +109589,32 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="BackgroundColorSpan"
  extends="android.text.style.CharacterStyle"
@@ -106345,6 +109624,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <implements name="android.text.style.UpdateAppearance">
 </implements>
 <constructor name="BackgroundColorSpan"
@@ -106357,6 +109638,27 @@
 <parameter name="color" type="int">
 </parameter>
 </constructor>
+<constructor name="BackgroundColorSpan"
+ type="android.text.style.BackgroundColorSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getBackgroundColor"
  return="int"
  abstract="false"
@@ -106368,6 +109670,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -106381,6 +109694,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="BulletSpan"
  extends="java.lang.Object"
@@ -106392,6 +109720,8 @@
 >
 <implements name="android.text.style.LeadingMarginSpan">
 </implements>
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="BulletSpan"
  type="android.text.style.BulletSpan"
  static="false"
@@ -106422,6 +109752,27 @@
 <parameter name="color" type="int">
 </parameter>
 </constructor>
+<constructor name="BulletSpan"
+ type="android.text.style.BulletSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="drawLeadingMargin"
  return="void"
  abstract="false"
@@ -106470,6 +109821,32 @@
 <parameter name="first" type="boolean">
 </parameter>
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 <field name="STANDARD_GAP_WIDTH"
  type="int"
  transient="false"
@@ -106826,6 +110203,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <implements name="android.text.style.UpdateAppearance">
 </implements>
 <constructor name="ForegroundColorSpan"
@@ -106838,6 +110217,27 @@
 <parameter name="color" type="int">
 </parameter>
 </constructor>
+<constructor name="ForegroundColorSpan"
+ type="android.text.style.ForegroundColorSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getForegroundColor"
  return="int"
  abstract="false"
@@ -106849,6 +110249,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -106862,6 +110273,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="IconMarginSpan"
  extends="java.lang.Object"
@@ -107190,6 +110616,8 @@
 >
 <implements name="android.text.style.LeadingMarginSpan">
 </implements>
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="LeadingMarginSpan.Standard"
  type="android.text.style.LeadingMarginSpan.Standard"
  static="false"
@@ -107212,6 +110640,27 @@
 <parameter name="every" type="int">
 </parameter>
 </constructor>
+<constructor name="LeadingMarginSpan.Standard"
+ type="android.text.style.LeadingMarginSpan.Standard"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="drawLeadingMargin"
  return="void"
  abstract="false"
@@ -107260,6 +110709,32 @@
 <parameter name="first" type="boolean">
 </parameter>
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <interface name="LineBackgroundSpan"
  abstract="true"
@@ -107434,6 +110909,8 @@
 >
 <implements name="android.text.style.LeadingMarginSpan">
 </implements>
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="QuoteSpan"
  type="android.text.style.QuoteSpan"
  static="false"
@@ -107452,6 +110929,27 @@
 <parameter name="color" type="int">
 </parameter>
 </constructor>
+<constructor name="QuoteSpan"
+ type="android.text.style.QuoteSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="drawLeadingMargin"
  return="void"
  abstract="false"
@@ -107511,6 +111009,32 @@
 <parameter name="first" type="boolean">
 </parameter>
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="RasterizerSpan"
  extends="android.text.style.CharacterStyle"
@@ -107565,6 +111089,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="RelativeSizeSpan"
  type="android.text.style.RelativeSizeSpan"
  static="false"
@@ -107575,6 +111101,27 @@
 <parameter name="proportion" type="float">
 </parameter>
 </constructor>
+<constructor name="RelativeSizeSpan"
+ type="android.text.style.RelativeSizeSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getSizeChange"
  return="float"
  abstract="false"
@@ -107586,6 +111133,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -107612,6 +111170,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="ReplacementSpan"
  extends="android.text.style.MetricAffectingSpan"
@@ -107714,6 +111287,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="ScaleXSpan"
  type="android.text.style.ScaleXSpan"
  static="false"
@@ -107724,6 +111299,27 @@
 <parameter name="proportion" type="float">
 </parameter>
 </constructor>
+<constructor name="ScaleXSpan"
+ type="android.text.style.ScaleXSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getScaleX"
  return="float"
  abstract="false"
@@ -107735,6 +111331,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -107761,6 +111368,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="StrikethroughSpan"
  extends="android.text.style.CharacterStyle"
@@ -107770,6 +111392,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <implements name="android.text.style.UpdateAppearance">
 </implements>
 <constructor name="StrikethroughSpan"
@@ -107780,6 +111404,38 @@
  visibility="public"
 >
 </constructor>
+<constructor name="StrikethroughSpan"
+ type="android.text.style.StrikethroughSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -107793,6 +111449,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="StyleSpan"
  extends="android.text.style.MetricAffectingSpan"
@@ -107802,6 +111473,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="StyleSpan"
  type="android.text.style.StyleSpan"
  static="false"
@@ -107812,6 +111485,38 @@
 <parameter name="style" type="int">
 </parameter>
 </constructor>
+<constructor name="StyleSpan"
+ type="android.text.style.StyleSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getStyle"
  return="int"
  abstract="false"
@@ -107849,6 +111554,21 @@
 <parameter name="paint" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="SubscriptSpan"
  extends="android.text.style.MetricAffectingSpan"
@@ -107858,6 +111578,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="SubscriptSpan"
  type="android.text.style.SubscriptSpan"
  static="false"
@@ -107866,6 +111588,38 @@
  visibility="public"
 >
 </constructor>
+<constructor name="SubscriptSpan"
+ type="android.text.style.SubscriptSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -107892,6 +111646,21 @@
 <parameter name="tp" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="SuperscriptSpan"
  extends="android.text.style.MetricAffectingSpan"
@@ -107901,6 +111670,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="SuperscriptSpan"
  type="android.text.style.SuperscriptSpan"
  static="false"
@@ -107909,6 +111680,38 @@
  visibility="public"
 >
 </constructor>
+<constructor name="SuperscriptSpan"
+ type="android.text.style.SuperscriptSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -107935,6 +111738,21 @@
 <parameter name="tp" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <interface name="TabStopSpan"
  abstract="true"
@@ -107997,6 +111815,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="TextAppearanceSpan"
  type="android.text.style.TextAppearanceSpan"
  static="false"
@@ -108041,6 +111861,27 @@
 <parameter name="linkColor" type="android.content.res.ColorStateList">
 </parameter>
 </constructor>
+<constructor name="TextAppearanceSpan"
+ type="android.text.style.TextAppearanceSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getFamily"
  return="java.lang.String"
  abstract="false"
@@ -108063,6 +111904,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getTextColor"
  return="android.content.res.ColorStateList"
  abstract="false"
@@ -108122,6 +111974,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="TypefaceSpan"
  extends="android.text.style.MetricAffectingSpan"
@@ -108131,6 +111998,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="TypefaceSpan"
  type="android.text.style.TypefaceSpan"
  static="false"
@@ -108141,6 +112010,27 @@
 <parameter name="family" type="java.lang.String">
 </parameter>
 </constructor>
+<constructor name="TypefaceSpan"
+ type="android.text.style.TypefaceSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getFamily"
  return="java.lang.String"
  abstract="false"
@@ -108152,6 +112042,17 @@
  visibility="public"
 >
 </method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -108178,6 +112079,21 @@
 <parameter name="paint" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="URLSpan"
  extends="android.text.style.ClickableSpan"
@@ -108187,6 +112103,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <constructor name="URLSpan"
  type="android.text.style.URLSpan"
  static="false"
@@ -108197,6 +112115,38 @@
 <parameter name="url" type="java.lang.String">
 </parameter>
 </constructor>
+<constructor name="URLSpan"
+ type="android.text.style.URLSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getURL"
  return="java.lang.String"
  abstract="false"
@@ -108221,6 +112171,21 @@
 <parameter name="widget" type="android.view.View">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <class name="UnderlineSpan"
  extends="android.text.style.CharacterStyle"
@@ -108230,6 +112195,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="android.text.ParcelableSpan">
+</implements>
 <implements name="android.text.style.UpdateAppearance">
 </implements>
 <constructor name="UnderlineSpan"
@@ -108240,6 +112207,38 @@
  visibility="public"
 >
 </constructor>
+<constructor name="UnderlineSpan"
+ type="android.text.style.UnderlineSpan"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="src" type="android.os.Parcel">
+</parameter>
+</constructor>
+<method name="describeContents"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getSpanTypeId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="updateDrawState"
  return="void"
  abstract="false"
@@ -108253,6 +112252,21 @@
 <parameter name="ds" type="android.text.TextPaint">
 </parameter>
 </method>
+<method name="writeToParcel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dest" type="android.os.Parcel">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 </class>
 <interface name="UpdateAppearance"
  abstract="true"
@@ -112174,7 +116188,7 @@
  type="android.view.GestureDetector"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="listener" type="android.view.GestureDetector.OnGestureListener">
@@ -112186,12 +116200,38 @@
  type="android.view.GestureDetector"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="listener" type="android.view.GestureDetector.OnGestureListener">
 </parameter>
 </constructor>
+<constructor name="GestureDetector"
+ type="android.view.GestureDetector"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="listener" type="android.view.GestureDetector.OnGestureListener">
+</parameter>
+</constructor>
+<constructor name="GestureDetector"
+ type="android.view.GestureDetector"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="listener" type="android.view.GestureDetector.OnGestureListener">
+</parameter>
+<parameter name="handler" type="android.os.Handler">
+</parameter>
+</constructor>
 <method name="isLongpressEnabled"
  return="boolean"
  abstract="false"
@@ -112853,6 +116893,32 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<method name="deviceHasKey"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="keyCode" type="int">
+</parameter>
+</method>
+<method name="deviceHasKeys"
+ return="boolean[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="keyCodes" type="int[]">
+</parameter>
+</method>
 <method name="get"
  return="int"
  abstract="false"
@@ -113271,6 +117337,22 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="time" type="long">
+</parameter>
+<parameter name="characters" type="java.lang.String">
+</parameter>
+<parameter name="device" type="int">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</constructor>
+<constructor name="KeyEvent"
+ type="android.view.KeyEvent"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
 <parameter name="origEvent" type="android.view.KeyEvent">
 </parameter>
 <parameter name="eventTime" type="long">
@@ -113325,6 +117407,17 @@
  visibility="public"
 >
 </method>
+<method name="getCharacters"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getDeadChar"
  return="int"
  abstract="false"
@@ -121867,10 +125960,23 @@
  type="android.view.ViewConfiguration"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </constructor>
+<method name="get"
+ return="android.view.ViewConfiguration"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+</method>
 <method name="getEdgeSlop"
  return="int"
  abstract="false"
@@ -121878,7 +125984,7 @@
  synchronized="false"
  static="true"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -121889,7 +125995,7 @@
  synchronized="false"
  static="true"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -121933,7 +126039,7 @@
  synchronized="false"
  static="true"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -121944,7 +126050,7 @@
  synchronized="false"
  static="true"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -121959,6 +126065,83 @@
  visibility="public"
 >
 </method>
+<method name="getScaledEdgeSlop"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getScaledFadingEdgeLength"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getScaledMaximumDrawingCacheSize"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getScaledMinimumFlingVelocity"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getScaledScrollBarSize"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getScaledTouchSlop"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getScaledWindowTouchSlop"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getScrollBarSize"
  return="int"
  abstract="false"
@@ -121966,7 +126149,7 @@
  synchronized="false"
  static="true"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -121999,7 +126182,7 @@
  synchronized="false"
  static="true"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -122010,7 +126193,7 @@
  synchronized="false"
  static="true"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 </method>
@@ -125315,6 +129498,19 @@
 <parameter name="streamType" type="int">
 </parameter>
 </method>
+<method name="setWindowAnimations"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="resId" type="int">
+</parameter>
+</method>
 <method name="setWindowManager"
  return="void"
  abstract="false"
@@ -126432,6 +130628,17 @@
  visibility="public"
 >
 </field>
+<field name="SCREEN_ORIENTATION_CHANGED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1024"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="SOFT_INPUT_ADJUST_PAN"
  type="int"
  transient="false"
@@ -126907,6 +131114,16 @@
  visibility="public"
 >
 </field>
+<field name="screenOrientation"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="softInputMode"
  type="int"
  transient="false"
@@ -127130,6 +131347,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<implements name="java.lang.Cloneable">
+</implements>
 <constructor name="Animation"
  type="android.view.animation.Animation"
  static="false"
@@ -129207,7 +133426,7 @@
 >
 <class name="BaseInputConnection"
  extends="java.lang.Object"
- abstract="true"
+ abstract="false"
  static="false"
  final="false"
  deprecated="not deprecated"
@@ -129224,7 +133443,193 @@
 >
 <parameter name="targetView" type="android.view.View">
 </parameter>
+<parameter name="dummyMode" type="boolean">
+</parameter>
 </constructor>
+<method name="beginBatchEdit"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="clearMetaKeyStates"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="states" type="int">
+</parameter>
+</method>
+<method name="commitCompletion"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="text" type="android.view.inputmethod.CompletionInfo">
+</parameter>
+</method>
+<method name="commitText"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="text" type="java.lang.CharSequence">
+</parameter>
+<parameter name="newCursorPosition" type="int">
+</parameter>
+</method>
+<method name="deleteSurroundingText"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="leftLength" type="int">
+</parameter>
+<parameter name="rightLength" type="int">
+</parameter>
+</method>
+<method name="endBatchEdit"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="finishComposingText"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getComposingSpanEnd"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="text" type="android.text.Spannable">
+</parameter>
+</method>
+<method name="getComposingSpanStart"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="text" type="android.text.Spannable">
+</parameter>
+</method>
+<method name="getCursorCapsMode"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="reqModes" type="int">
+</parameter>
+</method>
+<method name="getEditable"
+ return="android.text.Editable"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getExtractedText"
+ return="android.view.inputmethod.ExtractedText"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="request" type="android.view.inputmethod.ExtractedTextRequest">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<method name="getTextAfterCursor"
+ return="java.lang.CharSequence"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="length" type="int">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
+<method name="getTextBeforeCursor"
+ return="java.lang.CharSequence"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="length" type="int">
+</parameter>
+<parameter name="flags" type="int">
+</parameter>
+</method>
 <method name="hideStatusIcon"
  return="boolean"
  abstract="false"
@@ -129236,6 +133641,47 @@
  visibility="public"
 >
 </method>
+<method name="performContextMenuAction"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+</method>
+<method name="performPrivateCommand"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="action" type="java.lang.String">
+</parameter>
+<parameter name="data" type="android.os.Bundle">
+</parameter>
+</method>
+<method name="removeComposingSpans"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="text" type="android.text.Spannable">
+</parameter>
+</method>
 <method name="sendKeyEvent"
  return="boolean"
  abstract="false"
@@ -129249,6 +133695,49 @@
 <parameter name="event" type="android.view.KeyEvent">
 </parameter>
 </method>
+<method name="setComposingSpans"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="text" type="android.text.Spannable">
+</parameter>
+</method>
+<method name="setComposingText"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="text" type="java.lang.CharSequence">
+</parameter>
+<parameter name="newCursorPosition" type="int">
+</parameter>
+</method>
+<method name="setSelection"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="start" type="int">
+</parameter>
+<parameter name="end" type="int">
+</parameter>
+</method>
 <method name="showStatusIcon"
  return="boolean"
  abstract="false"
@@ -129417,6 +133906,21 @@
  visibility="public"
 >
 </method>
+<method name="dump"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="pw" type="android.util.Printer">
+</parameter>
+<parameter name="prefix" type="java.lang.String">
+</parameter>
+</method>
 <method name="writeToParcel"
  return="void"
  abstract="false"
@@ -129452,6 +133956,26 @@
  visibility="public"
 >
 </field>
+<field name="fieldId"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="fieldName"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="hintText"
  type="java.lang.CharSequence"
  transient="false"
@@ -129512,6 +134036,16 @@
  visibility="public"
 >
 </field>
+<field name="packageName"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="privateContentType"
  type="java.lang.String"
  transient="false"
@@ -129598,6 +134132,26 @@
  visibility="public"
 >
 </field>
+<field name="partialEndOffset"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="partialStartOffset"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="selectionEnd"
  type="int"
  transient="false"
@@ -129693,6 +134247,16 @@
  visibility="public"
 >
 </field>
+<field name="flags"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="hintMaxChars"
  type="int"
  transient="false"
@@ -129979,6 +134543,8 @@
 >
 <parameter name="n" type="int">
 </parameter>
+<parameter name="flags" type="int">
+</parameter>
 </method>
 <method name="getTextBeforeCursor"
  return="java.lang.CharSequence"
@@ -129992,6 +134558,8 @@
 >
 <parameter name="n" type="int">
 </parameter>
+<parameter name="flags" type="int">
+</parameter>
 </method>
 <method name="hideStatusIcon"
  return="boolean"
@@ -130004,6 +134572,19 @@
  visibility="public"
 >
 </method>
+<method name="performContextMenuAction"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+</method>
 <method name="performPrivateCommand"
  return="boolean"
  abstract="true"
@@ -130047,6 +134628,21 @@
 <parameter name="newCursorPosition" type="int">
 </parameter>
 </method>
+<method name="setSelection"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="start" type="int">
+</parameter>
+<parameter name="end" type="int">
+</parameter>
+</method>
 <method name="showStatusIcon"
  return="boolean"
  abstract="true"
@@ -130062,7 +134658,18 @@
 <parameter name="resId" type="int">
 </parameter>
 </method>
-<field name="EXTRACTED_TEXT_MONITOR"
+<field name="GET_EXTRACTED_TEXT_MONITOR"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="GET_TEXT_WITH_STYLES"
  type="int"
  transient="false"
  volatile="false"
@@ -130074,239 +134681,6 @@
 >
 </field>
 </interface>
-<class name="InputConnectionWrapper"
- extends="java.lang.Object"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<implements name="android.view.inputmethod.InputConnection">
-</implements>
-<constructor name="InputConnectionWrapper"
- type="android.view.inputmethod.InputConnectionWrapper"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="base" type="android.view.inputmethod.InputConnection">
-</parameter>
-</constructor>
-<method name="beginBatchEdit"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="clearMetaKeyStates"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="states" type="int">
-</parameter>
-</method>
-<method name="commitCompletion"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="text" type="android.view.inputmethod.CompletionInfo">
-</parameter>
-</method>
-<method name="commitText"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="text" type="java.lang.CharSequence">
-</parameter>
-<parameter name="newCursorPosition" type="int">
-</parameter>
-</method>
-<method name="deleteSurroundingText"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="leftLength" type="int">
-</parameter>
-<parameter name="rightLength" type="int">
-</parameter>
-</method>
-<method name="endBatchEdit"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="finishComposingText"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="getCursorCapsMode"
- return="int"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="reqModes" type="int">
-</parameter>
-</method>
-<method name="getExtractedText"
- return="android.view.inputmethod.ExtractedText"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="request" type="android.view.inputmethod.ExtractedTextRequest">
-</parameter>
-<parameter name="flags" type="int">
-</parameter>
-</method>
-<method name="getTextAfterCursor"
- return="java.lang.CharSequence"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="n" type="int">
-</parameter>
-</method>
-<method name="getTextBeforeCursor"
- return="java.lang.CharSequence"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="n" type="int">
-</parameter>
-</method>
-<method name="hideStatusIcon"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-</method>
-<method name="performPrivateCommand"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="action" type="java.lang.String">
-</parameter>
-<parameter name="data" type="android.os.Bundle">
-</parameter>
-</method>
-<method name="sendKeyEvent"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="event" type="android.view.KeyEvent">
-</parameter>
-</method>
-<method name="setComposingText"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="text" type="java.lang.CharSequence">
-</parameter>
-<parameter name="newCursorPosition" type="int">
-</parameter>
-</method>
-<method name="showStatusIcon"
- return="boolean"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="packageName" type="java.lang.String">
-</parameter>
-<parameter name="resId" type="int">
-</parameter>
-</method>
-</class>
 <interface name="InputMethod"
  abstract="true"
  static="false"
@@ -130374,6 +134748,8 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="inputConnection" type="android.view.inputmethod.InputConnection">
+</parameter>
 <parameter name="attribute" type="android.view.inputmethod.EditorInfo">
 </parameter>
 </method>
@@ -130428,7 +134804,9 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="attribute" type="android.view.inputmethod.EditorInfo">
+<parameter name="inputConnection" type="android.view.inputmethod.InputConnection">
+</parameter>
+<parameter name="info" type="android.view.inputmethod.EditorInfo">
 </parameter>
 </method>
 <method name="unbindInput"
@@ -130475,6 +134853,17 @@
  visibility="public"
 >
 </field>
+<field name="SHOW_FORCED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </interface>
 <interface name="InputMethod.SessionCallback"
  abstract="true"
@@ -130830,6 +135219,23 @@
 <parameter name="view" type="android.view.View">
 </parameter>
 </method>
+<method name="sendAppPrivateCommand"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="view" type="android.view.View">
+</parameter>
+<parameter name="action" type="java.lang.String">
+</parameter>
+<parameter name="data" type="android.os.Bundle">
+</parameter>
+</method>
 <method name="setInputMethod"
  return="void"
  abstract="false"
@@ -130956,6 +135362,28 @@
  visibility="public"
 >
 </field>
+<field name="HIDE_NOT_ALWAYS"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="SHOW_FORCED"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="2"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="SHOW_IMPLICIT"
  type="int"
  transient="false"
@@ -131123,38 +135551,6 @@
 </parameter>
 </method>
 </interface>
-<class name="MutableInputConnectionWrapper"
- extends="android.view.inputmethod.InputConnectionWrapper"
- abstract="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<constructor name="MutableInputConnectionWrapper"
- type="android.view.inputmethod.MutableInputConnectionWrapper"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="base" type="android.view.inputmethod.InputConnection">
-</parameter>
-</constructor>
-<method name="setBaseInputConnection"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="base" type="android.view.inputmethod.InputConnection">
-</parameter>
-</method>
-</class>
 </package>
 <package name="android.webkit"
 >
@@ -134994,7 +139390,7 @@
  synchronized="false"
  static="false"
  final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
  visibility="public"
 >
 <parameter name="oldFocus" type="android.view.View">
@@ -138293,6 +142689,17 @@
  visibility="public"
 >
 </method>
+<method name="isPerformingCompletion"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="isPopupShowing"
  return="boolean"
  abstract="false"
@@ -142403,6 +146810,218 @@
 </parameter>
 </method>
 </class>
+<class name="HorizontalScrollView"
+ extends="android.widget.FrameLayout"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="HorizontalScrollView"
+ type="android.widget.HorizontalScrollView"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+</constructor>
+<constructor name="HorizontalScrollView"
+ type="android.widget.HorizontalScrollView"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="attrs" type="android.util.AttributeSet">
+</parameter>
+</constructor>
+<constructor name="HorizontalScrollView"
+ type="android.widget.HorizontalScrollView"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="attrs" type="android.util.AttributeSet">
+</parameter>
+<parameter name="defStyle" type="int">
+</parameter>
+</constructor>
+<method name="arrowScroll"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="direction" type="int">
+</parameter>
+</method>
+<method name="computeScrollDeltaToGetChildRectOnScreen"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="rect" type="android.graphics.Rect">
+</parameter>
+</method>
+<method name="executeKeyEvent"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="event" type="android.view.KeyEvent">
+</parameter>
+</method>
+<method name="fling"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="velocityX" type="int">
+</parameter>
+</method>
+<method name="fullScroll"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="direction" type="int">
+</parameter>
+</method>
+<method name="getMaxScrollAmount"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="isFillViewport"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="isSmoothScrollingEnabled"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="pageScroll"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="direction" type="int">
+</parameter>
+</method>
+<method name="setFillViewport"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fillViewport" type="boolean">
+</parameter>
+</method>
+<method name="setSmoothScrollingEnabled"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="smoothScrollingEnabled" type="boolean">
+</parameter>
+</method>
+<method name="smoothScrollBy"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="dx" type="int">
+</parameter>
+<parameter name="dy" type="int">
+</parameter>
+</method>
+<method name="smoothScrollTo"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="x" type="int">
+</parameter>
+<parameter name="y" type="int">
+</parameter>
+</method>
+</class>
 <class name="ImageButton"
  extends="android.widget.ImageView"
  abstract="false"
@@ -144318,6 +148937,21 @@
 <parameter name="anchor" type="android.view.View">
 </parameter>
 </method>
+<method name="getMaxAvailableHeight"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="anchor" type="android.view.View">
+</parameter>
+<parameter name="yOffset" type="int">
+</parameter>
+</method>
 <method name="getWidth"
  return="int"
  abstract="false"
@@ -144329,6 +148963,17 @@
  visibility="public"
 >
 </method>
+<method name="isAboveAnchor"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="isClippingEnabled"
  return="boolean"
  abstract="false"
@@ -145967,6 +150612,29 @@
 <parameter name="running" type="boolean">
 </parameter>
 </method>
+<method name="setDrawableParameters"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="viewId" type="int">
+</parameter>
+<parameter name="targetBackground" type="boolean">
+</parameter>
+<parameter name="alpha" type="int">
+</parameter>
+<parameter name="colorFilter" type="int">
+</parameter>
+<parameter name="mode" type="android.graphics.PorterDuff.Mode">
+</parameter>
+<parameter name="level" type="int">
+</parameter>
+</method>
 <method name="setImageViewBitmap"
  return="void"
  abstract="false"
@@ -146046,6 +150714,21 @@
 <parameter name="indeterminate" type="boolean">
 </parameter>
 </method>
+<method name="setTextColor"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="viewId" type="int">
+</parameter>
+<parameter name="color" type="int">
+</parameter>
+</method>
 <method name="setTextViewText"
  return="void"
  abstract="false"
@@ -147733,6 +152416,323 @@
 </parameter>
 </method>
 </class>
+<class name="SlidingDrawer"
+ extends="android.view.ViewGroup"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<constructor name="SlidingDrawer"
+ type="android.widget.SlidingDrawer"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="attrs" type="android.util.AttributeSet">
+</parameter>
+</constructor>
+<constructor name="SlidingDrawer"
+ type="android.widget.SlidingDrawer"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="context" type="android.content.Context">
+</parameter>
+<parameter name="attrs" type="android.util.AttributeSet">
+</parameter>
+<parameter name="defStyle" type="int">
+</parameter>
+</constructor>
+<method name="animateClose"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="animateOpen"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="animateToggle"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="close"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getContent"
+ return="android.view.View"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getHandle"
+ return="android.view.View"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="isMoving"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="isOpened"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="lock"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="onLayout"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="changed" type="boolean">
+</parameter>
+<parameter name="l" type="int">
+</parameter>
+<parameter name="t" type="int">
+</parameter>
+<parameter name="r" type="int">
+</parameter>
+<parameter name="b" type="int">
+</parameter>
+</method>
+<method name="open"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="setOnDrawerCloseListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="onDrawerCloseListener" type="android.widget.SlidingDrawer.OnDrawerCloseListener">
+</parameter>
+</method>
+<method name="setOnDrawerOpenListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="onDrawerOpenListener" type="android.widget.SlidingDrawer.OnDrawerOpenListener">
+</parameter>
+</method>
+<method name="setOnDrawerScrollListener"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="onDrawerScrollListener" type="android.widget.SlidingDrawer.OnDrawerScrollListener">
+</parameter>
+</method>
+<method name="toggle"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="unlock"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<field name="ORIENTATION_HORIZONTAL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="0"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="ORIENTATION_VERTICAL"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
+<interface name="SlidingDrawer.OnDrawerCloseListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onDrawerClosed"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</interface>
+<interface name="SlidingDrawer.OnDrawerOpenListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onDrawerOpened"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</interface>
+<interface name="SlidingDrawer.OnDrawerScrollListener"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onScrollEnded"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="onScrollStarted"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+</interface>
 <class name="Spinner"
  extends="android.widget.AbsSpinner"
  abstract="false"
@@ -148834,6 +153834,30 @@
 <parameter name="end" type="int">
 </parameter>
 </method>
+<method name="beginBatchEdit"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="bringPointIntoView"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="offset" type="int">
+</parameter>
+</method>
 <method name="debug"
  return="void"
  abstract="false"
@@ -148847,6 +153871,17 @@
 <parameter name="depth" type="int">
 </parameter>
 </method>
+<method name="endBatchEdit"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="extractText"
  return="boolean"
  abstract="false"
@@ -149428,6 +154463,17 @@
  visibility="public"
 >
 </method>
+<method name="isInputMethodTarget"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="length"
  return="int"
  abstract="false"
@@ -149524,6 +154570,21 @@
  visibility="public"
 >
 </method>
+<method name="onSelectionChanged"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="selStart" type="int">
+</parameter>
+<parameter name="selEnd" type="int">
+</parameter>
+</method>
 <method name="onTextChanged"
  return="void"
  abstract="false"
@@ -149543,6 +154604,19 @@
 <parameter name="after" type="int">
 </parameter>
 </method>
+<method name="onTextContextMenuItem"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="id" type="int">
+</parameter>
+</method>
 <method name="removeTextChangedListener"
  return="void"
  abstract="false"
@@ -155136,6 +160210,21 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<method name="dumpHprofData"
+ return="void"
+ abstract="false"
+ native="true"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="fileName" type="java.lang.String">
+</parameter>
+<exception name="IOException" type="java.io.IOException">
+</exception>
+</method>
 <method name="getAllocCount"
  return="int"
  abstract="false"
diff --git a/camera/libcameraservice/CameraHardwareStub.cpp b/camera/libcameraservice/CameraHardwareStub.cpp
index 3d6b0b1..9a47705 100644
--- a/camera/libcameraservice/CameraHardwareStub.cpp
+++ b/camera/libcameraservice/CameraHardwareStub.cpp
@@ -187,6 +187,24 @@
     return mPreviewThread != 0;
 }
 
+status_t CameraHardwareStub::startRecording(recording_callback cb, void* user)
+{
+    return UNKNOWN_ERROR;
+}
+
+void CameraHardwareStub::stopRecording()
+{
+}
+
+bool CameraHardwareStub::recordingEnabled()
+{
+    return false;
+}
+
+void CameraHardwareStub::releaseRecordingFrame(const sp<IMemory>& mem)
+{
+}
+
 // ---------------------------------------------------------------------------
 
 int CameraHardwareStub::beginAutoFocusThread(void *cookie)
diff --git a/camera/libcameraservice/CameraHardwareStub.h b/camera/libcameraservice/CameraHardwareStub.h
index 9f5ddf1..cdd6011 100644
--- a/camera/libcameraservice/CameraHardwareStub.h
+++ b/camera/libcameraservice/CameraHardwareStub.h
@@ -34,6 +34,12 @@
     virtual status_t    startPreview(preview_callback cb, void* user);
     virtual void        stopPreview();
     virtual bool        previewEnabled();
+
+    virtual status_t    startRecording(recording_callback cb, void* user);
+    virtual void        stopRecording();
+    virtual bool        recordingEnabled();
+    virtual void        releaseRecordingFrame(const sp<IMemory>& mem);
+
     virtual status_t    autoFocus(autofocus_callback, void *user);
     virtual status_t    takePicture(shutter_callback,
                                     raw_callback,
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index 36c5ada..e5d4220 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -86,18 +86,19 @@
     LOGD("Connect E from ICameraClient %p", cameraClient->asBinder().get());
 
     Mutex::Autolock lock(mLock);
+    sp<Client> client;
     if (mClient != 0) {
         sp<Client> currentClient = mClient.promote();
         if (currentClient != 0) {
             sp<ICameraClient> currentCameraClient(currentClient->getCameraClient());
             if (cameraClient->asBinder() == currentCameraClient->asBinder()) {
                 // this is the same client reconnecting...
-                LOGD("Connect X same client is reconnecting...");
+                LOGD("Connect X same client (%p) is reconnecting...", cameraClient->asBinder().get());
                 return currentClient;
             } else {
-                // it's another client... boot the previous one...
-                LOGD("new client connecting, booting the old one...");
-                mClient.clear();
+                // it's another client... reject it
+                LOGD("new client (%p) attempting to connect - rejected", cameraClient->asBinder().get());
+                return client;
             }
         } else {
             // can't promote, the previous client has died...
@@ -107,7 +108,7 @@
     }
 
     // create a new Client object
-    sp<Client> client = new Client(this, cameraClient, IPCThreadState::self()->getCallingPid());
+    client = new Client(this, cameraClient, IPCThreadState::self()->getCallingPid());
     mClient = client;
 #if DEBUG_CLIENT_REFERENCES
     // Enable tracking for this object, and track increments and decrements of
@@ -158,21 +159,23 @@
     mCameraClient = cameraClient;
     mClientPid = clientPid;
     mHardware = openCameraHardware();
+    mUseOverlay = mHardware->useOverlay();
 
     // Callback is disabled by default
-    mFrameCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
+    mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
     LOGD("Client X constructor");
 }
 
 status_t CameraService::Client::checkPid()
 {
     if (mClientPid == IPCThreadState::self()->getCallingPid()) return NO_ERROR;
-    LOGW("Attempt to use locked camera from different process");
+    LOGW("Attempt to use locked camera (%p) from different process", getCameraClient()->asBinder().get());
     return -EBUSY;
 }
 
 status_t CameraService::Client::lock()
 {
+    Mutex::Autolock _l(mLock);
     // lock camera to this client if the the camera is unlocked
     if (mClientPid == 0) {
         mClientPid = IPCThreadState::self()->getCallingPid();
@@ -184,8 +187,9 @@
 
 status_t CameraService::Client::unlock()
 {
+    Mutex::Autolock _l(mLock);
     // allow anyone to use camera
-    LOGV("unlock");
+    LOGV("unlock (%p)", getCameraClient()->asBinder().get());
     status_t result = checkPid();
     if (result == NO_ERROR) mClientPid = 0;
     return result;
@@ -194,27 +198,40 @@
 status_t CameraService::Client::connect(const sp<ICameraClient>& client)
 {
     // connect a new process to the camera
-    LOGV("connect");
+    LOGV("connect (%p)", client->asBinder().get());
 
-    // hold a reference to the old client or we will deadlock if the client is
-    // in the same process and we hold the lock when we remove the reference
-    sp<ICameraClient> oldClient;
+    // I hate this hack, but things get really ugly when the media recorder
+    // service is handing back the camera to the app. The ICameraClient
+    // destructor will be called during the same IPC, making it look like
+    // the remote client is trying to disconnect. This hack temporarily
+    // sets the mClientPid to an invalid pid to prevent the hardware from
+    //  being torn down.
     {
-        Mutex::Autolock _l(mLock);
-        if (mClientPid != 0) {
-            LOGW("Tried to connect to locked camera");
-            return -EBUSY;
+
+        // hold a reference to the old client or we will deadlock if the client is
+        // in the same process and we hold the lock when we remove the reference
+        sp<ICameraClient> oldClient;
+        {
+            Mutex::Autolock _l(mLock);
+            if (mClientPid != 0) {
+                LOGW("Tried to connect to locked camera");
+                return -EBUSY;
+            }
+            oldClient = mCameraClient;
+
+            // did the client actually change?
+            if (client->asBinder() == mCameraClient->asBinder()) return NO_ERROR;
+
+            mCameraClient = client;
+            mClientPid = -1;
+            mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
+            LOGV("connect new process (%d) to existing camera client", mClientPid);
         }
-        oldClient = mCameraClient;
 
-        // did the client actually change?
-        if (client->asBinder() == mCameraClient->asBinder()) return NO_ERROR;
-
-        LOGV("connect new process to existing camera client");
-        mCameraClient = client;
-        mClientPid = IPCThreadState::self()->getCallingPid();
-        mFrameCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
     }
+    // the old client destructor is called when oldClient goes out of scope
+    // now we set the new PID to lock the interface again
+    mClientPid = IPCThreadState::self()->getCallingPid();
 
     return NO_ERROR;
 }
@@ -232,8 +249,8 @@
 CameraService::Client::~Client()
 {
     // tear down client
-    LOGD("Client E destructor");
-    if (mSurface != 0) {
+    LOGD("Client (%p)  E destructor", getCameraClient()->asBinder().get());
+    if (mSurface != 0 && !mUseOverlay) {
 #if HAVE_ANDROID_OS
         pthread_t thr;
         // We unregister the buffers in a different thread because binder does
@@ -244,7 +261,7 @@
                        mSurface.get());
         pthread_join(thr, NULL);
 #else
-    	mSurface->unregisterBuffers();
+        mSurface->unregisterBuffers();
 #endif
     }
 
@@ -256,16 +273,22 @@
 
 void CameraService::Client::disconnect()
 {
-    LOGD("Client E disconnect");
+    LOGD("Client (%p) E disconnect from (%d)",
+            getCameraClient()->asBinder().get(),
+            IPCThreadState::self()->getCallingPid());
     Mutex::Autolock lock(mLock);
-    if (mClientPid == 0) {
+    if (mClientPid <= 0) {
         LOGV("camera is unlocked, don't tear down hardware");
         return;
     }
-    if (checkPid() != NO_ERROR) return;
+    if (checkPid() != NO_ERROR) {
+        LOGV("Different client - don't disconnect");
+        return;
+    }
 
     mCameraService->removeClient(mCameraClient);
     if (mHardware != 0) {
+        LOGV("hardware teardown");
         // Before destroying mHardware, we must make sure it's in the
         // idle state.
         mHardware->stopPreview();
@@ -288,7 +311,7 @@
     Mutex::Autolock surfaceLock(mSurfaceLock);
     // asBinder() is safe on NULL (returns NULL)
     if (surface->asBinder() != mSurface->asBinder()) {
-        if (mSurface != 0) {
+        if (mSurface != 0 && !mUseOverlay) {
             LOGD("clearing old preview surface %p", mSurface.get());
             mSurface->unregisterBuffers();
         }
@@ -297,19 +320,20 @@
     return NO_ERROR;
 }
 
-// set the frame callback flag to affect how the received frames from
+// set the preview callback flag to affect how the received frames from
 // preview are handled.
-void CameraService::Client::setFrameCallbackFlag(int frame_callback_flag)
+void CameraService::Client::setPreviewCallbackFlag(int callback_flag)
 {
+    LOGV("setPreviewCallbackFlag");
     Mutex::Autolock lock(mLock);
     if (checkPid() != NO_ERROR) return;
-    mFrameCallbackFlag = frame_callback_flag;
+    mPreviewCallbackFlag = callback_flag;
 }
 
 // start preview mode, must call setPreviewDisplay first
-status_t CameraService::Client::startPreview()
+status_t CameraService::Client::startCameraMode(camera_mode mode)
 {
-    LOGD("startPreview()");
+    LOGD("startCameraMode(%d)", mode);
 
     /* we cannot call into mHardware with mLock held because
      * mHardware has callbacks onto us which acquire this lock
@@ -325,37 +349,124 @@
     }
 
     if (mSurface == 0) {
-        LOGE("setPreviewDisplay must be called before startPreview!");
+        LOGE("setPreviewDisplay must be called before startCameraMode!");
         return INVALID_OPERATION;
     }
 
-    // do nothing if preview is already started
-    if (mHardware->previewEnabled()) return NO_ERROR;
+    switch(mode) {
+    case CAMERA_RECORDING_MODE:
+        return startRecordingMode();
 
-    // XXX: This needs to be improved. remove all hardcoded stuff
+    default: // CAMERA_PREVIEW_MODE
+        return startPreviewMode();
+    }
+}
 
+status_t CameraService::Client::startRecordingMode()
+{
+    LOGV("startRecordingMode");
+
+    status_t ret = UNKNOWN_ERROR;
+
+    // if preview has not been started, start preview first
+    if (!mHardware->previewEnabled()) {
+        ret = startPreviewMode();
+        if (ret != NO_ERROR) {
+            return ret;
+        }
+    }
+
+    // if recording has been enabled, nothing needs to be done
+    if (mHardware->recordingEnabled()) {
+        return NO_ERROR;
+    }
+
+    // start recording mode
+    ret = mHardware->startRecording(recordingCallback,
+                                    mCameraService.get());
+    if (ret != NO_ERROR) {
+        LOGE("mHardware->startRecording() failed with status %d", ret);
+    }
+    return ret;
+}
+
+status_t CameraService::Client::startPreviewMode()
+{
+    LOGV("startPreviewMode");
+
+    // if preview has been enabled, nothing needs to be done
+    if (mHardware->previewEnabled()) {
+        return NO_ERROR;
+    }
+
+    // start preview mode
+#if DEBUG_DUMP_PREVIEW_FRAME_TO_FILE
+    debug_frame_cnt = 0;
+#endif
+    status_t ret = UNKNOWN_ERROR;
     int w, h;
     CameraParameters params(mHardware->getParameters());
     params.getPreviewSize(&w, &h);
 
-#if DEBUG_DUMP_PREVIEW_FRAME_TO_FILE
-    debug_frame_cnt = 0;
-#endif
+    if (mUseOverlay) {
+        const char *format = params.getPreviewFormat();
+        int fmt;
+        LOGD("Use Overlays");
+        if (!strcmp(format, "yuv422i"))
+            fmt = OVERLAY_FORMAT_YCbCr_422_I;
+        else if (!strcmp(format, "rgb565"))
+            fmt = OVERLAY_FORMAT_RGB_565;
+        else {
+            LOGE("Invalid preview format for overlays");
+            return -EINVAL;
+        }
+        sp<OverlayRef> ref = mSurface->createOverlay(w, h, fmt);
+        ret = mHardware->setOverlay(new Overlay(ref));
+        if (ret != NO_ERROR) {
+            LOGE("mHardware->setOverlay() failed with status %d\n", ret);
+            return ret;
+        }
+        ret = mHardware->startPreview(NULL, mCameraService.get());
+        if (ret != NO_ERROR)
+            LOGE("mHardware->startPreview() failed with status %d\n", ret);
+ 
+    } else {
+        ret = mHardware->startPreview(previewCallback,
+                                      mCameraService.get());
+        if (ret == NO_ERROR) {
 
-    status_t ret = mHardware->startPreview(previewCallback,
-                                           mCameraService.get());
-    if (ret == NO_ERROR) {
-        mSurface->unregisterBuffers();
-        mSurface->registerBuffers(w,h,w,h,
-                                  PIXEL_FORMAT_YCbCr_420_SP,
-                                  mHardware->getPreviewHeap());
+            mSurface->unregisterBuffers();
+
+            uint32_t transform = 0;
+            if (params.getOrientation() ==
+                CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
+              LOGV("portrait mode");
+              transform = ISurface::BufferHeap::ROT_90;
+            }
+            ISurface::BufferHeap buffers(w, h, w, h,
+                                         PIXEL_FORMAT_YCbCr_420_SP,
+                                         transform,
+                                         0,
+                                         mHardware->getPreviewHeap());
+
+            mSurface->registerBuffers(buffers);
+        } else {
+          LOGE("mHardware->startPreview() failed with status %d", ret);
+        }
     }
-    else LOGE("mHardware->startPreview() failed with status %d\n",
-              ret);
-
     return ret;
 }
 
+status_t CameraService::Client::startPreview()
+{
+    return startCameraMode(CAMERA_PREVIEW_MODE);
+}
+
+status_t CameraService::Client::startRecording()
+{
+    return startCameraMode(CAMERA_RECORDING_MODE);
+}
+
 // stop preview mode
 void CameraService::Client::stopPreview()
 {
@@ -372,12 +483,46 @@
     mHardware->stopPreview();
     LOGD("stopPreview(), hardware stopped OK");
 
-    if (mSurface != 0) {
+    if (mSurface != 0 && !mUseOverlay) {
         mSurface->unregisterBuffers();
     }
     mPreviewBuffer.clear();
 }
 
+// stop recording mode
+void CameraService::Client::stopRecording()
+{
+    LOGV("stopRecording()");
+
+    Mutex::Autolock lock(mLock);
+    if (checkPid() != NO_ERROR) return;
+
+    if (mHardware == 0) {
+        LOGE("mHardware is NULL, returning.");
+        return;
+    }
+
+    mHardware->stopRecording();
+    LOGV("stopRecording(), hardware stopped OK");
+    mPreviewBuffer.clear();
+}
+
+// release a recording frame
+void CameraService::Client::releaseRecordingFrame(const sp<IMemory>& mem)
+{
+    LOGV("releaseRecordingFrame()");
+
+    Mutex::Autolock lock(mLock);
+    if (checkPid() != NO_ERROR) return;
+
+    if (mHardware == 0) {
+        LOGE("mHardware is NULL, returning.");
+        return;
+    }
+
+    mHardware->releaseRecordingFrame(mem);
+}
+
 bool CameraService::Client::previewEnabled()
 {
     Mutex::Autolock lock(mLock);
@@ -385,6 +530,13 @@
     return mHardware->previewEnabled();
 }
 
+bool CameraService::Client::recordingEnabled()
+{
+    Mutex::Autolock lock(mLock);
+    if (mHardware == 0) return false;
+    return mHardware->recordingEnabled();
+}
+
 // Safely retrieves a strong pointer to the client during a hardware callback.
 sp<CameraService::Client> CameraService::Client::getClientFromCookie(void* user)
 {
@@ -476,7 +628,7 @@
 #endif
 
     // The strong pointer guarantees the client will exist, but no lock is held.
-    client->postFrame(mem);
+    client->postPreviewFrame(mem);
 
 #if DEBUG_CLIENT_REFERENCES
     //**** if the client's refcount is 1, then we are about to destroy it here,
@@ -488,6 +640,18 @@
 #endif
 }
 
+// recording callback
+void CameraService::Client::recordingCallback(const sp<IMemory>& mem, void* user)
+{
+    LOGV("recordingCallback");
+    sp<Client> client = getClientFromCookie(user);
+    if (client == 0) {
+        return;
+    }
+    // The strong pointer guarantees the client will exist, but no lock is held.
+    client->postRecordingFrame(mem);
+}
+
 // take a picture - image is returned in callback
 status_t CameraService::Client::autoFocus()
 {
@@ -520,7 +684,7 @@
         return INVALID_OPERATION;
     }
 
-    if (mSurface != NULL)
+    if (mSurface != NULL && !mUseOverlay)
         mSurface->unregisterBuffers();
 
     return mHardware->takePicture(shutterCallback,
@@ -573,10 +737,18 @@
     params.getPictureSize(&w, &h);
 
 //  Mutex::Autolock clientLock(client->mLock);
-    if (client->mSurface != 0) {
+    if (client->mSurface != 0 && !client->mUseOverlay) {
         client->mSurface->unregisterBuffers();
-        client->mSurface->registerBuffers(w,h,w,h,
-                                          PIXEL_FORMAT_YCbCr_420_SP, heap);
+        
+        uint32_t transform = 0;
+        if (params.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
+            LOGV("portrait mode");
+            transform = ISurface::BufferHeap::ROT_90;
+        }
+        ISurface::BufferHeap buffers(w, h, w, h,
+                PIXEL_FORMAT_YCbCr_420_SP, transform, 0, heap);
+        
+        client->mSurface->registerBuffers(buffers);
         client->mSurface->postBuffer(offset);
     }
 
@@ -730,12 +902,22 @@
         LOGE("failed to allocate space for frame callback");
         return;
     }
-    mCameraClient->frameCallback(frame);
+    mCameraClient->previewCallback(frame);
 }
 
-void CameraService::Client::postFrame(const sp<IMemory>& mem)
+void CameraService::Client::postRecordingFrame(const sp<IMemory>& frame)
 {
-    LOGV("postFrame");
+    LOGV("postRecordingFrame");
+    if (frame == 0) {
+        LOGW("frame is a null pointer");
+        return;
+    }
+    mCameraClient->recordingCallback(frame);
+}
+
+void CameraService::Client::postPreviewFrame(const sp<IMemory>& mem)
+{
+    LOGV("postPreviewFrame");
     if (mem == 0) {
         LOGW("mem is a null pointer");
         return;
@@ -752,31 +934,32 @@
     }
 
     // Is the callback enabled or not?
-    if (!(mFrameCallbackFlag & FRAME_CALLBACK_FLAG_ENABLE_MASK)) {
+    if (!(mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_ENABLE_MASK)) {
         // If the enable bit is off, the copy-out and one-shot bits are ignored
         LOGV("frame callback is diabled");
         return;
     }
 
     // Is the received frame copied out or not?
-    if (mFrameCallbackFlag & FRAME_CALLBACK_FLAG_COPY_OUT_MASK) {
+    if (mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_COPY_OUT_MASK) {
         LOGV("frame is copied out");
         copyFrameAndPostCopiedFrame(heap, offset, size);
     } else {
         LOGV("frame is directly sent out without copying");
-        mCameraClient->frameCallback(mem);
+        mCameraClient->previewCallback(mem);
     }
 
     // Is this is one-shot only?
-    if (mFrameCallbackFlag & FRAME_CALLBACK_FLAG_ONE_SHOT_MASK) {
+    if (mPreviewCallbackFlag & FRAME_CALLBACK_FLAG_ONE_SHOT_MASK) {
         LOGV("One-shot only, thus clear the bits and disable frame callback");
-        mFrameCallbackFlag &= ~(FRAME_CALLBACK_FLAG_ONE_SHOT_MASK |
+        mPreviewCallbackFlag &= ~(FRAME_CALLBACK_FLAG_ONE_SHOT_MASK |
                                 FRAME_CALLBACK_FLAG_COPY_OUT_MASK |
                                 FRAME_CALLBACK_FLAG_ENABLE_MASK);
     }
 }
 
-void CameraService::Client::postError(status_t error) {
+void CameraService::Client::postError(status_t error)
+{
     mCameraClient->errorCallback(error);
 }
 
@@ -796,6 +979,11 @@
         AutoMutex lock(&mLock);
         if (mClient != 0) {
             sp<Client> currentClient = mClient.promote();
+            sprintf(buffer, "Client (%p) PID: %d",
+                    currentClient->getCameraClient()->asBinder().get(),
+                    currentClient->mClientPid);
+            result.append(buffer);
+            write(fd, result.string(), result.size());
             currentClient->mHardware->dump(fd, args);
         } else {
             result.append("No camera client yet.\n");
@@ -880,5 +1068,3 @@
 #endif // DEBUG_HEAP_LEAKS
 
 }; // namespace android
-
-
diff --git a/camera/libcameraservice/CameraService.h b/camera/libcameraservice/CameraService.h
index cd8c1e9..d9b7927 100644
--- a/camera/libcameraservice/CameraService.h
+++ b/camera/libcameraservice/CameraService.h
@@ -82,9 +82,9 @@
         // pass the buffered ISurface to the camera service
         virtual status_t        setPreviewDisplay(const sp<ISurface>& surface);
 
-        // set the frame callback flag to affect how the received frames from
+        // set the preview callback flag to affect how the received frames from
         // preview are handled.
-        virtual void            setFrameCallbackFlag(int frame_callback_flag);
+        virtual void            setPreviewCallbackFlag(int callback_flag);
 
         // start preview mode, must call setPreviewDisplay first
         virtual status_t        startPreview();
@@ -95,6 +95,18 @@
         // get preview state
         virtual bool            previewEnabled();
 
+        // start recording mode
+        virtual status_t        startRecording();
+
+        // stop recording mode
+        virtual void            stopRecording();
+
+        // get recording state
+        virtual bool            recordingEnabled();
+
+        // release a recording frame
+        virtual void            releaseRecordingFrame(const sp<IMemory>& mem);
+
         // auto focus
         virtual status_t        autoFocus();
 
@@ -120,6 +132,7 @@
 
                     status_t    checkPid();
 
+        static      void        recordingCallback(const sp<IMemory>& mem, void* user);
         static      void        previewCallback(const sp<IMemory>& mem, void* user);
         static      void        shutterCallback(void *user);
         static      void        yuvPictureCallback(const sp<IMemory>& mem, void* user);
@@ -130,17 +143,28 @@
                     void        postShutter();
                     void        postRaw(const sp<IMemory>& mem);
                     void        postJpeg(const sp<IMemory>& mem);
-                    void        postFrame(const sp<IMemory>& mem);
+                    void        postPreviewFrame(const sp<IMemory>& mem);
+                    void        postRecordingFrame(const sp<IMemory>& frame);
                     void        copyFrameAndPostCopiedFrame(sp<IMemoryHeap> heap, size_t offset, size_t size);
                     void        postError(status_t error);
                     void        postAutoFocus(bool focused);
 
-                    // Ensures atomicity among the public methods
+        // camera operation mode
+        enum camera_mode {
+            CAMERA_PREVIEW_MODE   = 0,  // frame automatically released
+            CAMERA_RECORDING_MODE = 1,  // frame has to be explicitly released by releaseRecordingFrame()
+        };
+        status_t                startCameraMode(camera_mode mode);
+        status_t                startPreviewMode();
+        status_t                startRecordingMode();
+
+        // Ensures atomicity among the public methods
         mutable     Mutex                       mLock;
+
         // mSurfaceLock synchronizes access to mSurface between
-        // setPreviewSurface() and postFrame().  Note that among
+        // setPreviewSurface() and postPreviewFrame().  Note that among
         // the public methods, all accesses to mSurface are
-        // syncrhonized by mLock.  However, postFrame() is called
+        // syncrhonized by mLock.  However, postPreviewFrame() is called
         // by the CameraHardwareInterface callback, and needs to
         // access mSurface.  It cannot hold mLock, however, because
         // stopPreview() may be holding that lock while attempting
@@ -152,13 +176,14 @@
                     sp<CameraService>           mCameraService;
                     sp<ISurface>                mSurface;
                     sp<MemoryHeapBase>          mPreviewBuffer;
-                    int                         mFrameCallbackFlag;
+                    int                         mPreviewCallbackFlag;
 
                     // these are immutable once the object is created,
                     // they don't need to be protected by a lock
                     sp<ICameraClient>           mCameraClient;
                     sp<CameraHardwareInterface> mHardware;
                     pid_t                       mClientPid;
+                    bool                        mUseOverlay;
     };
 
 // ----------------------------------------------------------------------------
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index dea269dc..4621f57 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -224,6 +224,8 @@
         }
         if (compress)
             strcat(path, ".gz");
+        else
+            strcat(path, ".txt");
 
         /* ensure that all directories in the path exist */ 
         create_directories(path);
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index a3651b2..70a1206 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -413,7 +413,8 @@
     return 0;
 }
 
-static void run_dexopt(int zip_fd, int odex_fd, const char* input_file_name)
+static void run_dexopt(int zip_fd, int odex_fd, const char* input_file_name,
+    const char* dexopt_flags)
 {
     static const char* DEX_OPT_BIN = "/system/bin/dexopt";
     static const int MAX_INT_LEN = 12;      // '-'+10dig+'\0' -OR- 0x+8dig
@@ -424,7 +425,7 @@
     sprintf(odex_num, "%d", odex_fd);
 
     execl(DEX_OPT_BIN, DEX_OPT_BIN, "--zip", zip_num, odex_num, input_file_name,
-        (char*) NULL);
+        dexopt_flags, (char*) NULL);
     LOGE("execl(%s) failed: %s\n", DEX_OPT_BIN, strerror(errno));
 }
 
@@ -465,6 +466,7 @@
     struct utimbuf ut;
     struct stat apk_stat, dex_stat;
     char dex_path[PKG_PATH_MAX];
+    char dexopt_flags[PROPERTY_VALUE_MAX];
     char *end;
     int res, zip_fd=-1, odex_fd=-1;
 
@@ -475,6 +477,9 @@
         return -1;
     }
 
+    /* platform-specific flags affecting optimization and verification */
+    property_get("dalvik.vm.dexopt-flags", dexopt_flags, "");
+
     strcpy(dex_path, apk_path);
     end = strrchr(dex_path, '.');
     if (end != NULL) {
@@ -533,8 +538,8 @@
             exit(66);
         }
 
-        run_dexopt(zip_fd, odex_fd, apk_path);      /* does not return */
-        exit(67);
+        run_dexopt(zip_fd, odex_fd, apk_path, dexopt_flags);
+        exit(67);   /* only get here on exec failure */
     } else {
         res = wait_dexopt(pid, apk_path);
         if (res != 0) {
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 4dc4b6a..8236943 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -53,6 +53,7 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewManager;
 import android.view.Window;
 import android.view.WindowManager;
 import android.view.ContextMenu.ContextMenuInfo;
@@ -93,11 +94,11 @@
  * {@link android.R.styleable#AndroidManifestActivity &lt;activity&gt;}
  * declaration in their package's <code>AndroidManifest.xml</code>.</p>
  * 
- * <p>The Activity class is an important part of an
- * <a href="{@docRoot}intro/lifecycle.html">application's overall lifecycle</a>,
+ * <p>The Activity class is an important part of an application's overall lifecycle,
  * and the way activities are launched and put together is a fundamental
- * part of the platform's
- * <a href="{@docRoot}intro/appmodel.html">application model</a>.</p>
+ * part of the platform's application model. For a detailed perspective on the structure of
+ * Android applications and lifecycles, please read the <em>Dev Guide</em> document on 
+ * <a href="{@docRoot}guide/topics/fundamentals.html">Application Fundamentals</a>.</p>
  * 
  * <p>Topics covered here:
  * <ol>
@@ -527,7 +528,7 @@
  * {@link android.R.styleable#AndroidManifestUsesPermission &lt;uses-permission&gt;}
  * element in their own manifest to be able to start that activity.
  * 
- * <p>See the <a href="{@docRoot}devel/security.html">Security Model</a>
+ * <p>See the <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
  * document for more information on permissions and security in general.
  * 
  * <a name="ProcessLifecycle"></a>
@@ -629,6 +630,9 @@
 
     private WindowManager mWindowManager;
     /*package*/ View mDecor = null;
+    /*package*/ boolean mWindowAdded = false;
+    /*package*/ boolean mVisibleFromServer = false;
+    /*package*/ boolean mVisibleFromClient = true;
 
     private CharSequence mTitle;
     private int mTitleColor = 0;
@@ -779,6 +783,8 @@
      * @see #onPostCreate
      */
     protected void onCreate(Bundle savedInstanceState) {
+        mVisibleFromClient = mWindow.getWindowStyle().getBoolean(
+                com.android.internal.R.styleable.Window_windowNoDisplay, true);
         mCalled = true;
     }
 
@@ -1134,12 +1140,19 @@
     /**
      * Called as part of the activity lifecycle when an activity is about to go
      * into the background as the result of user choice.  For example, when the
-     * user presses the Home key, {@link #onUserLeaving} will be called, but
+     * user presses the Home key, {@link #onUserLeaveHint} will be called, but
      * when an incoming phone call causes the in-call Activity to be automatically
-     * brought to the foreground, {@link #onUserLeaving} will not be called on
-     * the activity being interrupted.
+     * brought to the foreground, {@link #onUserLeaveHint} will not be called on
+     * the activity being interrupted.  In cases when it is invoked, this method
+     * is called right before the activity's {@link #onPause} callback.
+     * 
+     * <p>This callback and {@link #onUserInteraction} are intended to help
+     * activities manage status bar notifications intelligently; specifically,
+     * for helping activities determine the proper time to cancel a notfication.
+     * 
+     * @see #onUserInteraction()
      */
-    protected void onUserLeaving() {
+    protected void onUserLeaveHint() {
     }
     
     /**
@@ -1443,7 +1456,6 @@
      * @return The Cursor that was returned by query().
      * 
      * @see ContentResolver#query(android.net.Uri , String[], String, String[], String)
-     * @see #managedCommitUpdates
      * @see #startManagingCursor
      * @hide
      */
@@ -1475,7 +1487,6 @@
      * @return The Cursor that was returned by query().
      * 
      * @see ContentResolver#query(android.net.Uri , String[], String, String[], String)
-     * @see #managedCommitUpdates
      * @see #startManagingCursor
      */
     public final Cursor managedQuery(Uri uri,
@@ -1863,6 +1874,28 @@
         return false;
     }
     
+    /**
+     * Called whenever a key, touch, or trackball event is dispatched to the
+     * activity.  Implement this method if you wish to know that the user has
+     * interacted with the device in some way while your activity is running.
+     * This callback and {@link #onUserLeaveHint} are intended to help
+     * activities manage status bar notifications intelligently; specifically,
+     * for helping activities determine the proper time to cancel a notfication.
+     * 
+     * <p>All calls to your activity's {@link #onUserLeaveHint} callback will
+     * be accompanied by calls to {@link #onUserInteraction}.  This
+     * ensures that your activity will be told of relevant user activity such
+     * as pulling down the notification pane and touching an item there.
+     * 
+     * <p>Note that this callback will be invoked for the touch down action
+     * that begins a touch gesture, but may not be invoked for the touch-moved
+     * and touch-up actions that follow.
+     * 
+     * @see #onUserLeaveHint()
+     */
+    public void onUserInteraction() {
+    }
+    
     public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
         // Update window manager if: we have a view, that view is
         // attached to its parent (which will be a RootView), and
@@ -1935,6 +1968,7 @@
      * @return boolean Return true if this event was consumed.
      */
     public boolean dispatchKeyEvent(KeyEvent event) {
+        onUserInteraction();
         if (getWindow().superDispatchKeyEvent(event)) {
             return true;
         }
@@ -1952,6 +1986,9 @@
      * @return boolean Return true if this event was consumed.
      */
     public boolean dispatchTouchEvent(MotionEvent ev) {
+        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+            onUserInteraction();
+        }
         if (getWindow().superDispatchTouchEvent(ev)) {
             return true;
         }
@@ -1969,6 +2006,7 @@
      * @return boolean Return true if this event was consumed.
      */
     public boolean dispatchTrackballEvent(MotionEvent ev) {
+        onUserInteraction();
         if (getWindow().superDispatchTrackballEvent(ev)) {
             return true;
         }
@@ -2865,6 +2903,35 @@
     }
 
     /**
+     * Control whether this activity's main window is visible.  This is intended
+     * only for the special case of an activity that is not going to show a
+     * UI itself, but can't just finish prior to onResume() because it needs
+     * to wait for a service binding or such.  Setting this to false allows
+     * you to prevent your UI from being shown during that time.
+     * 
+     * <p>The default value for this is taken from the
+     * {@link android.R.attr#windowNoDisplay} attribute of the activity's theme.
+     */
+    public void setVisible(boolean visible) {
+        if (mVisibleFromClient != visible) {
+            mVisibleFromClient = visible;
+            if (mVisibleFromServer) {
+                if (visible) makeVisible();
+                else mDecor.setVisibility(View.INVISIBLE);
+            }
+        }
+    }
+    
+    void makeVisible() {
+        if (!mWindowAdded) {
+            ViewManager wm = getWindowManager();
+            wm.addView(mDecor, getWindow().getAttributes());
+            mWindowAdded = true;
+        }
+        mDecor.setVisibility(View.VISIBLE);
+    }
+    
+    /**
      * Check to see whether this activity is in the process of finishing,
      * either because you called {@link #finish} on it or someone else
      * has requested that it finished.  This is often used in
@@ -3482,7 +3549,8 @@
     }
     
     final void performUserLeaving() {
-        onUserLeaving();
+        onUserInteraction();
+        onUserLeaveHint();
     }
     
     final void performStop() {
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index f9b9221..07520c9d 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -19,16 +19,14 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ConfigurationInfo;
 import android.content.pm.IPackageDataObserver;
 import android.graphics.Bitmap;
 import android.os.RemoteException;
 import android.os.Handler;
-import android.os.IBinder;
 import android.os.Parcel;
 import android.os.Parcelable;
-import android.os.Parcelable.Creator;
 import android.text.TextUtils;
-import android.util.Log;
 import java.util.List;
 
 /**
@@ -617,7 +615,59 @@
         
         public String pkgList[];
         
+        /**
+         * Constant for {@link #importance}: this process is running the
+         * foreground UI.
+         */
+        public static final int IMPORTANCE_FOREGROUND = 100;
+        
+        /**
+         * Constant for {@link #importance}: this process is running something
+         * that is considered to be actively visible to the user.
+         */
+        public static final int IMPORTANCE_VISIBLE = 200;
+        
+        /**
+         * Constant for {@link #importance}: this process is contains services
+         * that should remain running.
+         */
+        public static final int IMPORTANCE_SERVICE = 300;
+        
+        /**
+         * Constant for {@link #importance}: this process process contains
+         * background code that is expendable.
+         */
+        public static final int IMPORTANCE_BACKGROUND = 400;
+        
+        /**
+         * Constant for {@link #importance}: this process is empty of any
+         * actively running code.
+         */
+        public static final int IMPORTANCE_EMPTY = 500;
+        
+        /**
+         * The relative importance level that the system places on this
+         * process.  May be one of {@link #IMPORTANCE_FOREGROUND},
+         * {@link #IMPORTANCE_VISIBLE}, {@link #IMPORTANCE_SERVICE},
+         * {@link #IMPORTANCE_BACKGROUND}, or {@link #IMPORTANCE_EMPTY}.  These
+         * constants are numbered so that "more important" values are always
+         * smaller than "less important" values.
+         */
+        public int importance;
+        
+        /**
+         * An additional ordering within a particular {@link #importance}
+         * category, providing finer-grained information about the relative
+         * utility of processes within a category.  This number means nothing
+         * except that a smaller values are more recently used (and thus
+         * more important).  Currently an LRU value is only maintained for
+         * the {@link #IMPORTANCE_BACKGROUND} category, though others may
+         * be maintained in the future.
+         */
+        public int lru;
+        
         public RunningAppProcessInfo() {
+            importance = IMPORTANCE_FOREGROUND;
         }
         
         public RunningAppProcessInfo(String pProcessName, int pPid, String pArr[]) {
@@ -634,12 +684,16 @@
             dest.writeString(processName);
             dest.writeInt(pid);
             dest.writeStringArray(pkgList);
+            dest.writeInt(importance);
+            dest.writeInt(lru);
         }
 
         public void readFromParcel(Parcel source) {
             processName = source.readString();
             pid = source.readInt();
             pkgList = source.readStringArray();
+            importance = source.readInt();
+            lru = source.readInt();
         }
 
         public static final Creator<RunningAppProcessInfo> CREATOR = 
@@ -671,4 +725,37 @@
             return null;
         }
     }
+    
+    /**
+     * Have the system perform a force stop of everything associated with
+     * the given application package.  All processes that share its uid
+     * will be killed, all services it has running stopped, all activities
+     * removed, etc.  In addition, a {@link Intent#ACTION_PACKAGE_RESTARTED}
+     * broadcast will be sent, so that any of its registered alarms can
+     * be stopped, notifications removed, etc.
+     * 
+     * <p>You must hold the permission
+     * {@link android.Manifest.permission#RESTART_PACKAGES} to be able to
+     * call this method.
+     * 
+     * @param packageName The name of the package to be stopped.
+     */
+    public void restartPackage(String packageName) {
+        try {
+            ActivityManagerNative.getDefault().restartPackage(packageName);
+        } catch (RemoteException e) {
+        }
+    }
+    
+    /**
+     * Get the device configuration attributes.
+     */
+    public ConfigurationInfo getDeviceConfigurationInfo() {
+        try {
+            return ActivityManagerNative.getDefault().getDeviceConfigurationInfo();
+        } catch (RemoteException e) {
+        }
+        return null;
+    }
+    
 }
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index ae9f3bf..f11dbec 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -20,6 +20,7 @@
 import android.content.ContentResolver;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.ConfigurationInfo;
 import android.content.pm.IPackageDataObserver;
 import android.content.res.Configuration;
 import android.graphics.Bitmap;
@@ -83,6 +84,17 @@
     }
 
     /**
+     * Convenience for checking whether the system is ready.  For internal use only.
+     */
+    static public boolean isSystemReady() {
+        if (!sSystemReady) {
+            sSystemReady = getDefault().testIsSystemReady();
+        }
+        return sSystemReady;
+    }
+    static boolean sSystemReady = false;
+    
+    /**
      * Convenience for sending a sticky broadcast.  For internal use only.
      * If you don't care about permission, use null.
      */
@@ -959,6 +971,23 @@
             return true;
         }
         
+        case GET_DEVICE_CONFIGURATION_TRANSACTION: {
+            data.enforceInterface(IActivityManager.descriptor);
+            ConfigurationInfo config = getDeviceConfigurationInfo();
+            reply.writeNoException();
+            config.writeToParcel(reply, 0);
+            return true;
+        }
+        
+        case PEEK_SERVICE_TRANSACTION: {
+            data.enforceInterface(IActivityManager.descriptor);
+            Intent service = Intent.CREATOR.createFromParcel(data);
+            String resolvedType = data.readString();
+            IBinder binder = peekService(service, resolvedType);
+            reply.writeNoException();
+            reply.writeStrongBinder(binder);
+            return true;
+        }
         }
         
         return super.onTransact(code, data, reply, flags);
@@ -1604,6 +1633,20 @@
         data.recycle();
         reply.recycle();
     }
+    
+    public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
+        Parcel data = Parcel.obtain();
+        Parcel reply = Parcel.obtain();
+        data.writeInterfaceToken(IActivityManager.descriptor);
+        service.writeToParcel(data, 0);
+        data.writeString(resolvedType);
+        mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
+        reply.readException();
+        IBinder binder = reply.readStrongBinder();
+        reply.recycle();
+        data.recycle();
+        return binder;
+    }
 
     public boolean startInstrumentation(ComponentName className, String profileFile,
             int flags, Bundle arguments, IInstrumentationWatcher watcher)
@@ -2028,6 +2071,11 @@
         data.recycle();
         reply.recycle();
     }
+    public boolean testIsSystemReady()
+    {
+        /* this base class version is never called */
+        return true;
+    }
     public int handleApplicationError(IBinder app, int flags,
             String tag, String shortMsg, String longMsg,
             byte[] crashData) throws RemoteException
@@ -2071,5 +2119,17 @@
         reply.recycle();
     }
     
+    public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
+    {
+        Parcel data = Parcel.obtain();
+        Parcel reply = Parcel.obtain();
+        data.writeInterfaceToken(IActivityManager.descriptor);
+        mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
+        reply.readException();
+        ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
+        reply.recycle();
+        data.recycle();
+        return res;
+    }
     private IBinder mRemote;
 }
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index e4c1057..bf5616e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -144,13 +144,19 @@
         return sPackageManager;
     }
 
-    DisplayMetrics getDisplayMetricsLocked() {
+    DisplayMetrics getDisplayMetricsLocked(boolean forceUpdate) {
+        if (mDisplayMetrics != null && !forceUpdate) {
+            return mDisplayMetrics;
+        }
         if (mDisplay == null) {
             WindowManager wm = WindowManagerImpl.getDefault();
             mDisplay = wm.getDefaultDisplay();
         }
-        DisplayMetrics metrics = new DisplayMetrics();
+        DisplayMetrics metrics = mDisplayMetrics = new DisplayMetrics();
         mDisplay.getMetrics(metrics);
+        //Log.i("foo", "New metrics: w=" + metrics.widthPixels + " h="
+        //        + metrics.heightPixels + " den=" + metrics.density
+        //        + " xdpi=" + metrics.xdpi + " ydpi=" + metrics.ydpi);
         return metrics;
     }
 
@@ -173,7 +179,7 @@
             if (assets.addAssetPath(appDir) == 0) {
                 return null;
             }
-            DisplayMetrics metrics = getDisplayMetricsLocked();
+            DisplayMetrics metrics = getDisplayMetricsLocked(false);
             r = new Resources(assets, metrics, getConfiguration());
             //Log.i(TAG, "Created app resources " + r + ": " + r.getConfiguration());
             // XXX need to remove entries when weak references go away
@@ -235,7 +241,7 @@
                         ApplicationContext.createSystemContext(mainThread);
                     mSystemContext.getResources().updateConfiguration(
                             mainThread.getConfiguration(),
-                            mainThread.getDisplayMetricsLocked());
+                            mainThread.getDisplayMetricsLocked(false));
                     //Log.i(TAG, "Created system resources "
                     //        + mSystemContext.getResources() + ": "
                     //        + mSystemContext.getResources().getConfiguration());
@@ -1205,7 +1211,10 @@
         private static final String HEAP_COLUMN = "%17s %8s %8s %8s %8s";
         private static final String ONE_COUNT_COLUMN = "%17s %8d";
         private static final String TWO_COUNT_COLUMNS = "%17s %8d %17s %8d";
-
+        
+        // Formatting for checkin service - update version if row format changes
+        private static final int ACTIVITY_THREAD_CHECKIN_VERSION = 1;
+       
         public final void schedulePauseActivity(IBinder token, boolean finished,
                 boolean userLeaving, int configChanges) {
             queueOrSendMessage(
@@ -1462,7 +1471,101 @@
             long dalvikMax = runtime.totalMemory() / 1024;
             long dalvikFree = runtime.freeMemory() / 1024;
             long dalvikAllocated = dalvikMax - dalvikFree;
-
+            long viewInstanceCount = ViewDebug.getViewInstanceCount();
+            long viewRootInstanceCount = ViewDebug.getViewRootInstanceCount();
+            long appContextInstanceCount = ApplicationContext.getInstanceCount();
+            long activityInstanceCount = Activity.getInstanceCount();
+            int globalAssetCount = AssetManager.getGlobalAssetCount();
+            int globalAssetManagerCount = AssetManager.getGlobalAssetManagerCount();
+            int binderLocalObjectCount = Debug.getBinderLocalObjectCount();
+            int binderProxyObjectCount = Debug.getBinderProxyObjectCount();
+            int binderDeathObjectCount = Debug.getBinderDeathObjectCount();
+            int openSslSocketCount = OpenSSLSocketImpl.getInstanceCount();
+            long sqliteAllocated = SQLiteDebug.getHeapAllocatedSize() / 1024;
+            SQLiteDebug.PagerStats stats = new SQLiteDebug.PagerStats();
+            SQLiteDebug.getPagerStats(stats);
+            
+            // Check to see if we were called by checkin server. If so, print terse format.
+            boolean doCheckinFormat = false;
+            if (args != null) {
+                for (String arg : args) {
+                    if ("-c".equals(arg)) doCheckinFormat = true;
+                }
+            }
+            
+            // For checkin, we print one long comma-separated list of values
+            if (doCheckinFormat) {
+                // NOTE: if you change anything significant below, also consider changing
+                // ACTIVITY_THREAD_CHECKIN_VERSION.
+                String processName = (mBoundApplication != null) 
+                        ? mBoundApplication.processName : "unknown";
+                
+                // Header
+                pw.print(ACTIVITY_THREAD_CHECKIN_VERSION); pw.print(',');
+                pw.print(Process.myPid()); pw.print(',');
+                pw.print(processName); pw.print(',');
+                
+                // Heap info - max
+                pw.print(nativeMax); pw.print(',');
+                pw.print(dalvikMax); pw.print(',');
+                pw.print("N/A,");
+                pw.print(nativeMax + dalvikMax); pw.print(',');
+                
+                // Heap info - allocated
+                pw.print(nativeAllocated); pw.print(',');
+                pw.print(dalvikAllocated); pw.print(',');
+                pw.print("N/A,");
+                pw.print(nativeAllocated + dalvikAllocated); pw.print(',');
+                
+                // Heap info - free
+                pw.print(nativeFree); pw.print(',');
+                pw.print(dalvikFree); pw.print(',');
+                pw.print("N/A,");
+                pw.print(nativeFree + dalvikFree); pw.print(',');
+                
+                // Heap info - proportional set size
+                pw.print(memInfo.nativePss); pw.print(',');
+                pw.print(memInfo.dalvikPss); pw.print(',');
+                pw.print(memInfo.otherPss); pw.print(',');
+                pw.print(memInfo.nativePss + memInfo.dalvikPss + memInfo.otherPss); pw.print(',');
+                
+                // Heap info - shared
+                pw.print(nativeShared); pw.print(','); 
+                pw.print(dalvikShared); pw.print(','); 
+                pw.print(otherShared); pw.print(','); 
+                pw.print(nativeShared + dalvikShared + otherShared); pw.print(',');
+                
+                // Heap info - private
+                pw.print(nativePrivate); pw.print(','); 
+                pw.print(dalvikPrivate); pw.print(',');
+                pw.print(otherPrivate); pw.print(',');
+                pw.print(nativePrivate + dalvikPrivate + otherPrivate); pw.print(',');
+                
+                // Object counts
+                pw.print(viewInstanceCount); pw.print(',');
+                pw.print(viewRootInstanceCount); pw.print(',');
+                pw.print(appContextInstanceCount); pw.print(',');
+                pw.print(activityInstanceCount); pw.print(',');
+                
+                pw.print(globalAssetCount); pw.print(',');
+                pw.print(globalAssetManagerCount); pw.print(',');
+                pw.print(binderLocalObjectCount); pw.print(',');
+                pw.print(binderProxyObjectCount); pw.print(',');
+                
+                pw.print(binderDeathObjectCount); pw.print(',');
+                pw.print(openSslSocketCount); pw.print(',');
+                
+                // SQL
+                pw.print(sqliteAllocated); pw.print(',');
+                pw.print(stats.databaseBytes / 1024); pw.print(','); 
+                pw.print(stats.numPagers); pw.print(',');
+                pw.print((stats.totalBytes - stats.referencedBytes) / 1024); pw.print(',');
+                pw.print(stats.referencedBytes / 1024); pw.print('\n');
+                
+                return;
+            }
+            
+            // otherwise, show human-readable format
             printRow(pw, HEAP_COLUMN, "", "native", "dalvik", "other", "total");
             printRow(pw, HEAP_COLUMN, "size:", nativeMax, dalvikMax, "N/A", nativeMax + dalvikMax);
             printRow(pw, HEAP_COLUMN, "allocated:", nativeAllocated, dalvikAllocated, "N/A",
@@ -1480,26 +1583,22 @@
 
             pw.println(" ");
             pw.println(" Objects");
-            printRow(pw, TWO_COUNT_COLUMNS, "Views:", ViewDebug.getViewInstanceCount(), "ViewRoots:",
-                    ViewDebug.getViewRootInstanceCount());
+            printRow(pw, TWO_COUNT_COLUMNS, "Views:", viewInstanceCount, "ViewRoots:",
+                    viewRootInstanceCount);
 
-            printRow(pw, TWO_COUNT_COLUMNS, "AppContexts:", ApplicationContext.getInstanceCount(),
-                    "Activities:", Activity.getInstanceCount());
+            printRow(pw, TWO_COUNT_COLUMNS, "AppContexts:", appContextInstanceCount,
+                    "Activities:", activityInstanceCount);
 
-            printRow(pw, TWO_COUNT_COLUMNS, "Assets:", AssetManager.getGlobalAssetCount(),
-                    "AssetManagers:", AssetManager.getGlobalAssetManagerCount());
+            printRow(pw, TWO_COUNT_COLUMNS, "Assets:", globalAssetCount,
+                    "AssetManagers:", globalAssetManagerCount);
 
-            printRow(pw, TWO_COUNT_COLUMNS, "Local Binders:", Debug.getBinderLocalObjectCount(),
-                    "Proxy Binders:", Debug.getBinderProxyObjectCount());
-            printRow(pw, ONE_COUNT_COLUMN, "Death Recipients:", Debug.getBinderDeathObjectCount());
+            printRow(pw, TWO_COUNT_COLUMNS, "Local Binders:", binderLocalObjectCount,
+                    "Proxy Binders:", binderProxyObjectCount);
+            printRow(pw, ONE_COUNT_COLUMN, "Death Recipients:", binderDeathObjectCount);
 
-            printRow(pw, ONE_COUNT_COLUMN, "OpenSSL Sockets:", OpenSSLSocketImpl.getInstanceCount());
-
+            printRow(pw, ONE_COUNT_COLUMN, "OpenSSL Sockets:", openSslSocketCount);
+            
             // SQLite mem info
-            long sqliteAllocated = SQLiteDebug.getHeapAllocatedSize() / 1024;
-            SQLiteDebug.PagerStats stats = new SQLiteDebug.PagerStats();
-            SQLiteDebug.getPagerStats(stats);
-
             pw.println(" ");
             pw.println(" SQL");
             printRow(pw, TWO_COUNT_COLUMNS, "heap:", sqliteAllocated, "dbFiles:",
@@ -1751,6 +1850,7 @@
     final HashMap<String, WeakReference<PackageInfo>> mResourcePackages
         = new HashMap<String, WeakReference<PackageInfo>>();
     Display mDisplay = null;
+    DisplayMetrics mDisplayMetrics = null;
     HashMap<String, WeakReference<Resources> > mActiveResources
         = new HashMap<String, WeakReference<Resources> >();
 
@@ -1918,7 +2018,7 @@
                 PackageInfo info = new PackageInfo(this, "android", context);
                 context.init(info, null, this);
                 context.getResources().updateConfiguration(
-                        getConfiguration(), getDisplayMetricsLocked());
+                        getConfiguration(), getDisplayMetricsLocked(false));
                 mSystemContext = context;
                 //Log.i(TAG, "Created system resources " + context.getResources()
                 //        + ": " + context.getResources().getConfiguration());
@@ -2557,7 +2657,10 @@
                 a.mDecor = decor;
                 l.type = WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
                 l.softInputMode |= forwardBit;
-                wm.addView(decor, l);
+                if (a.mVisibleFromClient) {
+                    a.mWindowAdded = true;
+                    wm.addView(decor, l);
+                }
 
             // If the window has already been added, but during resume
             // we started another activity, then don't yet make the
@@ -2576,7 +2679,8 @@
                     performConfigurationChanged(r.activity, r.newConfig);
                     r.newConfig = null;
                 }
-                Log.v(TAG, "Resuming " + r + " with isForward=" + isForward);
+                if (localLOGV) Log.v(TAG, "Resuming " + r + " with isForward="
+                        + isForward);
                 WindowManager.LayoutParams l = r.window.getAttributes();
                 if ((l.softInputMode
                         & WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION)
@@ -2588,8 +2692,11 @@
                     View decor = r.window.getDecorView();
                     wm.updateViewLayout(decor, l);
                 }
-                r.activity.mDecor.setVisibility(View.VISIBLE);
+                r.activity.mVisibleFromServer = true;
                 mNumVisibleActivities++;
+                if (r.activity.mVisibleFromClient) {
+                    r.activity.makeVisible();
+                }
             }
 
             r.nextIdle = mNewActivities;
@@ -2800,18 +2907,22 @@
         View v = r.activity.mDecor;
         if (v != null) {
             if (show) {
-                if (v.getVisibility() != View.VISIBLE) {
-                    v.setVisibility(View.VISIBLE);
+                if (!r.activity.mVisibleFromServer) {
+                    r.activity.mVisibleFromServer = true;
                     mNumVisibleActivities++;
+                    if (r.activity.mVisibleFromClient) {
+                        r.activity.makeVisible();
+                    }
                 }
                 if (r.newConfig != null) {
                     performConfigurationChanged(r.activity, r.newConfig);
                     r.newConfig = null;
                 }
             } else {
-                if (v.getVisibility() == View.VISIBLE) {
-                    v.setVisibility(View.INVISIBLE);
+                if (r.activity.mVisibleFromServer) {
+                    r.activity.mVisibleFromServer = false;
                     mNumVisibleActivities--;
+                    v.setVisibility(View.INVISIBLE);
                 }
             }
         }
@@ -3037,11 +3148,13 @@
             WindowManager wm = r.activity.getWindowManager();
             View v = r.activity.mDecor;
             if (v != null) {
-                if (v.getVisibility() == View.VISIBLE) {
+                if (r.activity.mVisibleFromServer) {
                     mNumVisibleActivities--;
                 }
                 IBinder wtoken = v.getWindowToken();
-                wm.removeViewImmediate(v);
+                if (r.activity.mWindowAdded) {
+                    wm.removeViewImmediate(v);
+                }
                 if (wtoken != null) {
                     WindowManagerImpl.getDefault().closeAll(wtoken,
                             r.activity.getClass().getName(), "Activity");
@@ -3271,6 +3384,7 @@
                 mConfiguration = new Configuration();
             }
             mConfiguration.updateFrom(config);
+            DisplayMetrics dm = getDisplayMetricsLocked(true);
 
             // set it for java, this also affects newly created Resources
             if (config.locale != null) {
@@ -3290,7 +3404,7 @@
                     WeakReference<Resources> v = it.next();
                     Resources r = v.get();
                     if (r != null) {
-                        r.updateConfiguration(config, null);
+                        r.updateConfiguration(config, 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 4236a00..394b8e3 100644
--- a/core/java/android/app/ApplicationContext.java
+++ b/core/java/android/app/ApplicationContext.java
@@ -1630,6 +1630,15 @@
         }
 
         @Override
+        public String[] getSystemSharedLibraryNames() {
+             try {
+                 return mPM.getSystemSharedLibraryNames();
+             } catch (RemoteException e) {
+                 throw new RuntimeException("Package manager has died", e);
+             }
+        }
+
+        @Override
         public int checkPermission(String permName, String pkgName) {
             try {
                 return mPM.checkPermission(permName, pkgName);
@@ -1974,6 +1983,18 @@
                 getApplicationInfo(appPackageName, 0));
         }
 
+        int mCachedSafeMode = -1;
+        @Override public boolean isSafeMode() {
+            try {
+                if (mCachedSafeMode < 0) {
+                    mCachedSafeMode = mPM.isSafeMode() ? 1 : 0;
+                }
+                return mCachedSafeMode != 0;
+            } catch (RemoteException e) {
+                throw new RuntimeException("Package manager has died", e);
+            }
+        }
+
         static void configurationChanged() {
             synchronized (sSync) {
                 sIconCache.clear();
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 951b48d..b09a57f 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -122,7 +122,7 @@
      *                uses the window manager and theme from this context to
      *                present its UI.
      * @param theme A style resource describing the theme to use for the 
-     * window. See <a href="{@docRoot}reference/available-resources.html#stylesandthemes">Style 
+     * window. See <a href="{@docRoot}guide/topics/resources/available-resources.html#stylesandthemes">Style 
      * and Theme Resources</a> for more information about defining and using 
      * styles.  This theme is applied on top of the current theme in 
      * <var>context</var>.  If 0, the default dialog theme will be used.
@@ -518,7 +518,7 @@
     private boolean isOutOfBounds(MotionEvent event) {
         final int x = (int) event.getX();
         final int y = (int) event.getY();
-        final int slop = ViewConfiguration.getWindowTouchSlop();
+        final int slop = ViewConfiguration.get(mContext).getScaledWindowTouchSlop();
         final View decorView = getWindow().getDecorView();
         return (x < -slop) || (y < -slop)
                 || (x > (decorView.getWidth()+slop))
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 353500e9..cd3701f 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -22,6 +22,7 @@
 import android.content.IContentProvider;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.ConfigurationInfo;
 import android.content.pm.IPackageDataObserver;
 import android.content.pm.ProviderInfo;
 import android.content.res.Configuration;
@@ -127,7 +128,8 @@
             boolean doRebind) throws RemoteException;
     /* oneway */
     public void serviceDoneExecuting(IBinder token) throws RemoteException;
-
+    public IBinder peekService(Intent service, String resolvedType) throws RemoteException;
+    
     public boolean startInstrumentation(ComponentName className, String profileFile,
             int flags, Bundle arguments, IInstrumentationWatcher watcher)
             throws RemoteException;
@@ -216,6 +218,13 @@
     // Retrieve running application processes in the system
     public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
             throws RemoteException;
+    // Get device configuration
+    public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException;
+    
+    /*
+     * Private non-Binder interfaces
+     */
+    /* package */ boolean testIsSystemReady();
     
     /** Information you can retrieve about a particular application. */
     public static class ContentProviderHolder implements Parcelable {
@@ -354,4 +363,6 @@
     int GET_SERVICES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+80;
     int REPORT_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+81;
     int GET_RUNNING_APP_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+82;
+    int GET_DEVICE_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+83;
+    int PEEK_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+84;
 }
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index f96d787..f6a28b2 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1267,7 +1267,7 @@
     }
     
     /**
-     * Perform calling of an activity's {@link Activity#onUserLeaving} method.
+     * Perform calling of an activity's {@link Activity#onUserLeaveHint} method.
      * The default implementation simply calls through to that method.
      * 
      * @param activity The activity being notified that the user has navigated away
diff --git a/core/java/android/app/LauncherActivity.java b/core/java/android/app/LauncherActivity.java
index 8f0a4f5..c363f04 100644
--- a/core/java/android/app/LauncherActivity.java
+++ b/core/java/android/app/LauncherActivity.java
@@ -21,11 +21,23 @@
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.PaintFlagsDrawFilter;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.PaintDrawable;
+import android.os.AsyncTask;
 import android.os.Bundle;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.Window;
 import android.widget.BaseAdapter;
 import android.widget.Filter;
 import android.widget.Filterable;
@@ -43,33 +55,59 @@
  *
  */
 public abstract class LauncherActivity extends ListActivity {
+
+    Intent mIntent;
+    PackageManager mPackageManager;
     
     /**
+     * An item in the list
+     */
+    public static class ListItem {
+        public CharSequence label;
+        //public CharSequence description;
+        public Drawable icon;
+        public String packageName;
+        public String className;
+        
+        ListItem(PackageManager pm, ResolveInfo resolveInfo, IconResizer resizer) {
+            label = resolveInfo.loadLabel(pm);
+            if (label == null && resolveInfo.activityInfo != null) {
+                label = resolveInfo.activityInfo.name;
+            }
+            
+            /*
+            if (resolveInfo.activityInfo != null &&
+                    resolveInfo.activityInfo.applicationInfo != null) {
+                description = resolveInfo.activityInfo.applicationInfo.loadDescription(pm);
+            }
+            */
+            
+            icon = resizer.createIconThumbnail(resolveInfo.loadIcon(pm));
+            packageName = resolveInfo.activityInfo.applicationInfo.packageName;
+            className = resolveInfo.activityInfo.name;
+        }
+
+        public ListItem() {
+        }
+    }
+
+    /**
      * Adapter which shows the set of activities that can be performed for a given intent.
      */
     private class ActivityAdapter extends BaseAdapter implements Filterable {
         private final Object lock = new Object();
-        private ArrayList<ResolveInfo> mOriginalValues;
+        private ArrayList<ListItem> mOriginalValues;
 
-        protected final Context mContext;
-        protected final Intent mIntent;
         protected final LayoutInflater mInflater;
 
-        protected List<ResolveInfo> mActivitiesList;
+        protected List<ListItem> mActivitiesList;
 
         private Filter mFilter;
-
-        public ActivityAdapter(Context context, Intent intent) {
-            mContext = context;
-            mIntent = new Intent(intent);
-            mIntent.setComponent(null);
-            mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
-            PackageManager pm = context.getPackageManager();
-            mActivitiesList = pm.queryIntentActivities(intent, 0);
-            if (mActivitiesList != null) {
-                Collections.sort(mActivitiesList, new ResolveInfo.DisplayNameComparator(pm));
-            }
+        
+        public ActivityAdapter() {
+            mInflater = (LayoutInflater) LauncherActivity.this.getSystemService(
+                    Context.LAYOUT_INFLATER_SERVICE);
+            mActivitiesList = makeListItems();
         }
 
         public Intent intentForPosition(int position) {
@@ -78,8 +116,8 @@
             }
 
             Intent intent = new Intent(mIntent);
-            ActivityInfo ai = mActivitiesList.get(position).activityInfo;
-            intent.setClassName(ai.applicationInfo.packageName, ai.name);
+            ListItem item = mActivitiesList.get(position);
+            intent.setClassName(item.packageName, item.className);
             return intent;
         }
 
@@ -99,7 +137,7 @@
             View view;
             if (convertView == null) {
                 view = mInflater.inflate(
-                        com.android.internal.R.layout.simple_list_item_1, parent, false);
+                        com.android.internal.R.layout.activity_list_item_2, parent, false);
             } else {
                 view = convertView;
             }
@@ -108,7 +146,7 @@
         }
 
         private char getCandidateLetter(ResolveInfo info) {
-            PackageManager pm = mContext.getPackageManager();
+            PackageManager pm = LauncherActivity.this.getPackageManager();
             CharSequence label = info.loadLabel(pm);
 
             if (label == null) {
@@ -118,24 +156,22 @@
             return Character.toLowerCase(label.charAt(0));
         }
 
-        private void bindView(View view, ResolveInfo info) {
-            TextView text = (TextView) view.findViewById(com.android.internal.R.id.text1);
-
-            PackageManager pm = mContext.getPackageManager();
-            CharSequence label = info.loadLabel(pm);
-            text.setText(label != null ? label : info.activityInfo.name);
+        private void bindView(View view, ListItem item) {
+            TextView text = (TextView) view;
+            text.setText(item.label);
+            text.setCompoundDrawablesWithIntrinsicBounds(item.icon, null, null, null);
         }
-
+        
         public Filter getFilter() {
             if (mFilter == null) {
                 mFilter = new ArrayFilter();
             }
             return mFilter;
         }
-
+        
         /**
-         * <p>An array filters constrains the content of the array adapter with a prefix. Each item that
-         * does not start with the supplied prefix is removed from the list.</p>
+         * An array filters constrains the content of the array adapter with a prefix. Each
+         * item that does not start with the supplied prefix is removed from the list.
          */
         private class ArrayFilter extends Filter {
             @Override
@@ -144,39 +180,36 @@
 
                 if (mOriginalValues == null) {
                     synchronized (lock) {
-                        mOriginalValues = new ArrayList<ResolveInfo>(mActivitiesList);
+                        mOriginalValues = new ArrayList<ListItem>(mActivitiesList);
                     }
                 }
 
                 if (prefix == null || prefix.length() == 0) {
                     synchronized (lock) {
-                        ArrayList<ResolveInfo> list = new ArrayList<ResolveInfo>(mOriginalValues);
+                        ArrayList<ListItem> list = new ArrayList<ListItem>(mOriginalValues);
                         results.values = list;
                         results.count = list.size();
                     }
                 } else {
-                    final PackageManager pm = mContext.getPackageManager();
+                    final PackageManager pm = LauncherActivity.this.getPackageManager();
                     final String prefixString = prefix.toString().toLowerCase();
 
-                    ArrayList<ResolveInfo> values = mOriginalValues;
+                    ArrayList<ListItem> values = mOriginalValues;
                     int count = values.size();
 
-                    ArrayList<ResolveInfo> newValues = new ArrayList<ResolveInfo>(count);
+                    ArrayList<ListItem> newValues = new ArrayList<ListItem>(count);
 
                     for (int i = 0; i < count; i++) {
-                        ResolveInfo value = values.get(i);
+                        ListItem item = values.get(i);
 
-                        final CharSequence label = value.loadLabel(pm);
-                        final CharSequence name = label != null ? label : value.activityInfo.name;
-
-                        String[] words = name.toString().toLowerCase().split(" ");
+                        String[] words = item.label.toString().toLowerCase().split(" ");
                         int wordCount = words.length;
 
                         for (int k = 0; k < wordCount; k++) {
                             final String word = words[k];
 
                             if (word.startsWith(prefixString)) {
-                                newValues.add(value);
+                                newValues.add(item);
                                 break;
                             }
                         }
@@ -192,7 +225,7 @@
             @Override
             protected void publishResults(CharSequence constraint, FilterResults results) {
                 //noinspection unchecked
-                mActivitiesList = (List<ResolveInfo>) results.values;
+                mActivitiesList = (List<ListItem>) results.values;
                 if (results.count > 0) {
                     notifyDataSetChanged();
                 } else {
@@ -201,19 +234,121 @@
             }
         }
     }
-    
-    
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
         
-        mAdapter = new ActivityAdapter(this, getTargetIntent());
+    /**
+     * Utility class to resize icons to match default icon size.  
+     */
+    public class IconResizer {
+        // Code is borrowed from com.android.launcher.Utilities. 
+        private int mIconWidth = -1;
+        private int mIconHeight = -1;
+
+        private final Paint mPaint = new Paint();
+        private final Rect mBounds = new Rect();
+        private final Rect mOldBounds = new Rect();
+        private Canvas mCanvas = new Canvas();
+        
+        public IconResizer() {
+            mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
+                    Paint.FILTER_BITMAP_FLAG));
+            
+            final Resources resources = LauncherActivity.this.getResources();
+            mIconWidth = mIconHeight = (int) resources.getDimension(
+                    android.R.dimen.app_icon_size);
+        }
+
+        /**
+         * Returns a Drawable representing the thumbnail of the specified Drawable.
+         * The size of the thumbnail is defined by the dimension
+         * android.R.dimen.launcher_application_icon_size.
+         *
+         * This method is not thread-safe and should be invoked on the UI thread only.
+         *
+         * @param icon The icon to get a thumbnail of.
+         *
+         * @return A thumbnail for the specified icon or the icon itself if the
+         *         thumbnail could not be created. 
+         */
+        public Drawable createIconThumbnail(Drawable icon) {
+            int width = mIconWidth;
+            int height = mIconHeight;
+
+            final int iconWidth = icon.getIntrinsicWidth();
+            final int iconHeight = icon.getIntrinsicHeight();
+
+            if (icon instanceof PaintDrawable) {
+                PaintDrawable painter = (PaintDrawable) icon;
+                painter.setIntrinsicWidth(width);
+                painter.setIntrinsicHeight(height);
+            }
+
+            if (width > 0 && height > 0) {
+                if (width < iconWidth || height < iconHeight) {
+                    final float ratio = (float) iconWidth / iconHeight;
+
+                    if (iconWidth > iconHeight) {
+                        height = (int) (width / ratio);
+                    } else if (iconHeight > iconWidth) {
+                        width = (int) (height * ratio);
+                    }
+
+                    final Bitmap.Config c = icon.getOpacity() != PixelFormat.OPAQUE ?
+                                Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
+                    final Bitmap thumb = Bitmap.createBitmap(mIconWidth, mIconHeight, c);
+                    final Canvas canvas = mCanvas;
+                    canvas.setBitmap(thumb);
+                    // Copy the old bounds to restore them later
+                    // If we were to do oldBounds = icon.getBounds(),
+                    // the call to setBounds() that follows would
+                    // change the same instance and we would lose the
+                    // old bounds
+                    mOldBounds.set(icon.getBounds());
+                    final int x = (mIconWidth - width) / 2;
+                    final int y = (mIconHeight - height) / 2;
+                    icon.setBounds(x, y, x + width, y + height);
+                    icon.draw(canvas);
+                    icon.setBounds(mOldBounds);
+                    icon = new BitmapDrawable(thumb);
+                } else if (iconWidth < width && iconHeight < height) {
+                    final Bitmap.Config c = Bitmap.Config.ARGB_8888;
+                    final Bitmap thumb = Bitmap.createBitmap(mIconWidth, mIconHeight, c);
+                    final Canvas canvas = mCanvas;
+                    canvas.setBitmap(thumb);
+                    mOldBounds.set(icon.getBounds());
+                    final int x = (width - iconWidth) / 2;
+                    final int y = (height - iconHeight) / 2;
+                    icon.setBounds(x, y, x + iconWidth, y + iconHeight);
+                    icon.draw(canvas);
+                    icon.setBounds(mOldBounds);
+                    icon = new BitmapDrawable(thumb);
+                }
+            }
+
+            return icon;
+        }
+    }
+
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        
+        mPackageManager = getPackageManager();
+    
+        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+        setProgressBarIndeterminateVisibility(true);
+        setContentView(com.android.internal.R.layout.activity_list);
+        
+            
+        mIntent = new Intent(getTargetIntent());
+        mIntent.setComponent(null);
+        mAdapter = new ActivityAdapter();
         
         setListAdapter(mAdapter);
         getListView().setTextFilterEnabled(true);
+        
+        setProgressBarIndeterminateVisibility(false);
     }
 
-
     @Override
     protected void onListItemClick(ListView l, View v, int position, long id) {
         Intent intent = ((ActivityAdapter)mAdapter).intentForPosition(position);
@@ -221,6 +356,42 @@
         startActivity(intent);
     }
     
-    protected abstract Intent getTargetIntent();
-   
+    /**
+     * Return the actual Intent for a specific position in our
+     * {@link android.widget.ListView}.
+     * @param position The item whose Intent to return
+     */
+    protected Intent intentForPosition(int position) {
+        ActivityAdapter adapter = (ActivityAdapter) mAdapter;
+        return adapter.intentForPosition(position);
+    }
+    
+    /**
+     * Get the base intent to use when running
+     * {@link PackageManager#queryIntentActivities(Intent, int)}.
+     */
+    protected Intent getTargetIntent() {
+        return new Intent();
+    }
+
+    /**
+     * Perform the query to determine which results to show and return a list of them.
+     */
+    public List<ListItem> makeListItems() {
+        // Load all matching activities and sort correctly
+        List<ResolveInfo> list = mPackageManager.queryIntentActivities(mIntent,
+                /* no flags */ 0);
+        Collections.sort(list, new ResolveInfo.DisplayNameComparator(mPackageManager));
+        
+        IconResizer resizer = new IconResizer();
+        
+        ArrayList<ListItem> result = new ArrayList<ListItem>(list.size());
+        int listSize = list.size();
+        for (int i = 0; i < listSize; i++) {
+            ResolveInfo resolveInfo = list.get(i);
+            result.add(new ListItem(mPackageManager, resolveInfo, resizer));
+        }
+
+        return result;
+    }
 }
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index ea67cdb..51fddb1 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -90,8 +90,9 @@
      * The intent to execute when the expanded status entry is clicked.  If
      * this is an activity, it must include the
      * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} flag, which requires
-     * that you take care of task management as described in the
-     * <a href="{@docRoot}intro/appmodel.html">application model</a> document.
+     * that you take care of task management as described in the <em>Activities and Tasks</em>
+     * section of the <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application 
+     * Fundamentals</a> document.
      */
     public PendingIntent contentIntent;
 
@@ -420,8 +421,8 @@
      * @param contentIntent The intent to launch when the user clicks the expanded notification.
      * If this is an activity, it must include the
      * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} flag, which requires
-     * that you take care of task management as described in the
-     * <a href="{@docRoot}intro/appmodel.html">application model</a> document.
+     * that you take care of task management as described in 
+     * <a href="{@docRoot}guide/topics/fundamentals.html#lcycles">Application Fundamentals: Activities and Tasks</a>.
      */
     public void setLatestEventInfo(Context context,
             CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent) {
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 2e2a1a1..64f1ba2 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -16,11 +16,14 @@
 
 package android.app;
 
+import android.content.ActivityNotFoundException;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.content.res.Resources.NotFoundException;
@@ -34,6 +37,7 @@
 import android.os.ServiceManager;
 import android.os.SystemClock;
 import android.server.search.SearchableInfo;
+import android.speech.RecognizerIntent;
 import android.text.Editable;
 import android.text.InputType;
 import android.text.TextUtils;
@@ -50,6 +54,7 @@
 import android.widget.AutoCompleteTextView;
 import android.widget.Button;
 import android.widget.CursorAdapter;
+import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;
@@ -59,6 +64,7 @@
 import android.widget.AdapterView.OnItemSelectedListener;
 
 import java.lang.ref.WeakReference;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
 
 /**
@@ -94,6 +100,7 @@
     private TextView mBadgeLabel;
     private AutoCompleteTextView mSearchTextField;
     private Button mGoButton;
+    private ImageButton mVoiceButton;
 
     // interaction with searchable application
     private ComponentName mLaunchComponent;
@@ -115,6 +122,10 @@
     private Uri mSuggestionData = null;
     private String mSuggestionQuery = null;
     
+    // For voice searching
+    private Intent mVoiceWebSearchIntent;
+    private Intent mVoiceAppSearchIntent;
+
     // support for AutoCompleteTextView suggestions display
     private SuggestionsAdapter mSuggestionsAdapter;
 
@@ -153,12 +164,15 @@
         mSearchTextField = (AutoCompleteTextView) 
                 findViewById(com.android.internal.R.id.search_src_text);
         mGoButton = (Button) findViewById(com.android.internal.R.id.search_go_btn);
+        mVoiceButton = (ImageButton) findViewById(com.android.internal.R.id.search_voice_btn);
         
         // attach listeners
         mSearchTextField.addTextChangedListener(mTextWatcher);
         mSearchTextField.setOnKeyListener(mTextKeyListener);
         mGoButton.setOnClickListener(mGoButtonClickListener);
         mGoButton.setOnKeyListener(mButtonsKeyListener);
+        mVoiceButton.setOnClickListener(mVoiceButtonClickListener);
+        mVoiceButton.setOnKeyListener(mButtonsKeyListener);
 
         // pre-hide all the extraneous elements
         mBadgeLabel.setVisibility(View.GONE);
@@ -169,13 +183,19 @@
         setCanceledOnTouchOutside(true);
         
         // Set up broadcast filters
-        mCloseDialogsFilter = new
-        IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
+        mCloseDialogsFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
         mPackageFilter = new IntentFilter();
         mPackageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
         mPackageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
         mPackageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
         mPackageFilter.addDataScheme("package");
+        
+        // Save voice intent for later queries/launching
+        mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
+        mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
+                RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
+        
+        mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
     }
 
     /**
@@ -261,16 +281,15 @@
     }
 
     /**
-     * Dismiss the search dialog.
+     * The search dialog is being dismissed, so handle all of the local shutdown operations.
      * 
-     * This function is designed to be idempotent so it can be safely called at any time
+     * This function is designed to be idempotent so that dismiss() can be safely called at any time
      * (even if already closed) and more likely to really dump any memory.  No leaks!
      */
     @Override
-    public void dismiss() {
-        if (isShowing()) {
-            super.dismiss();
-        }
+    public void onStop() {
+        super.onStop();
+        
         setOnCancelListener(null);
         setOnDismissListener(null);
         
@@ -281,6 +300,11 @@
             // This is OK - it just means we didn't have any registered
         }
         
+        // close any leftover cursor
+        if (mSuggestionsAdapter != null) {
+            mSuggestionsAdapter.changeCursor(null);
+        }
+        
         // dump extra memory we're hanging on to
         mLaunchComponent = null;
         mAppSearchData = null;
@@ -408,6 +432,7 @@
             updateSearchButton();
             updateSearchBadge();
             updateQueryHint();
+            updateVoiceButton();
             
             // In order to properly configure the input method (if one is being used), we
             // need to let it know if we'll be providing suggestions.  Although it would be
@@ -500,6 +525,30 @@
     }
 
     /**
+     * Update the visibility of the voice button.  There are actually two voice search modes, 
+     * either of which will activate the button.
+     */
+    private void updateVoiceButton() {
+        int visibility = View.GONE;
+        if (mSearchable.getVoiceSearchEnabled()) {
+            Intent testIntent = null;
+            if (mSearchable.getVoiceSearchLaunchWebSearch()) {
+                testIntent = mVoiceWebSearchIntent;
+            } else if (mSearchable.getVoiceSearchLaunchRecognizer()) {
+                testIntent = mVoiceAppSearchIntent;
+            }      
+            if (testIntent != null) {
+                List<ResolveInfo> list = getContext().getPackageManager().
+                        queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY);
+                if (list.size() > 0) {
+                    visibility = View.VISIBLE;
+                }
+            }
+        }
+        mVoiceButton.setVisibility(visibility);
+    }
+    
+    /**
      * Listeners of various types
      */
 
@@ -642,11 +691,97 @@
     };
     
     /**
+     * React to a click in the voice search button.
+     */
+    View.OnClickListener mVoiceButtonClickListener = new View.OnClickListener() {
+        public void onClick(View v) {
+            try {
+                if (mSearchable.getVoiceSearchLaunchWebSearch()) {
+                    getContext().startActivity(mVoiceWebSearchIntent);
+                    dismiss();
+                } else if (mSearchable.getVoiceSearchLaunchRecognizer()) {
+                    Intent appSearchIntent = createVoiceAppSearchIntent(mVoiceAppSearchIntent);
+                    getContext().startActivity(appSearchIntent);
+                    dismiss();
+                }
+            } catch (ActivityNotFoundException e) {
+                // Should not happen, since we check the availability of
+                // voice search before showing the button. But just in case...
+                Log.w(LOG_TAG, "Could not find voice search activity");
+            }
+         }
+    };
+    
+    /**
+     * Create and return an Intent that can launch the voice search activity, perform a specific
+     * voice transcription, and forward the results to the searchable activity.
+     * 
+     * @param baseIntent The voice app search intent to start from
+     * @return A completely-configured intent ready to send to the voice search activity
+     */
+    private Intent createVoiceAppSearchIntent(Intent baseIntent) {
+        // create the necessary intent to set up a search-and-forward operation
+        // in the voice search system.   We have to keep the bundle separate,
+        // because it becomes immutable once it enters the PendingIntent
+        Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
+        queryIntent.setComponent(mSearchable.mSearchActivity);
+        PendingIntent pending = PendingIntent.getActivity(
+                getContext(), 0, queryIntent, PendingIntent.FLAG_ONE_SHOT);
+        
+        // Now set up the bundle that will be inserted into the pending intent
+        // when it's time to do the search.  We always build it here (even if empty)
+        // because the voice search activity will always need to insert "QUERY" into
+        // it anyway.
+        Bundle queryExtras = new Bundle();
+        if (mAppSearchData != null) {
+            queryExtras.putBundle(SearchManager.APP_DATA, mAppSearchData);
+        }
+        
+        // Now build the intent to launch the voice search.  Add all necessary
+        // extras to launch the voice recognizer, and then all the necessary extras
+        // to forward the results to the searchable activity
+        Intent voiceIntent = new Intent(baseIntent);
+        
+        // Add all of the configuration options supplied by the searchable's metadata
+        String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
+        String prompt = null;
+        String language = null;
+        int maxResults = 1;
+        Resources resources = mActivityContext.getResources();
+        if (mSearchable.getVoiceLanguageModeId() != 0) {
+            languageModel = resources.getString(mSearchable.getVoiceLanguageModeId());
+        }
+        if (mSearchable.getVoicePromptTextId() != 0) {
+            prompt = resources.getString(mSearchable.getVoicePromptTextId());
+        }
+        if (mSearchable.getVoiceLanguageId() != 0) {
+            language = resources.getString(mSearchable.getVoiceLanguageId());
+        }
+        if (mSearchable.getVoiceMaxResults() != 0) {
+            maxResults = mSearchable.getVoiceMaxResults();
+        }
+        voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
+        voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
+        voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
+        voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
+        
+        // Add the values that configure forwarding the results
+        voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
+        voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
+        
+        return voiceIntent;
+    }
+
+    /**
      * React to the user typing "enter" or other hardwired keys while typing in the search box.
      * This handles these special keys while the edit box has focus.
      */
     View.OnKeyListener mTextKeyListener = new View.OnKeyListener() {
         public boolean onKey(View v, int keyCode, KeyEvent event) {
+            if (keyCode == KeyEvent.KEYCODE_BACK) {
+                cancel();
+                return true;
+            }
             // also guard against possible race conditions (late arrival after dismiss)
             if (mSearchable != null && 
                     TextUtils.getTrimmedLength(mSearchTextField.getText()) > 0) {
@@ -793,24 +928,6 @@
     };
 
     /**
-     * UI-thread handling of dialog dismiss.  Called by mBroadcastReceiver.onReceive().
-     *
-     * TODO: This is a really heavyweight solution for something that should be so simple.
-     * For example, we already have a handler, in our superclass, why aren't we sharing that?
-     * I think we need to investigate simplifying this entire methodology, or perhaps boosting
-     * it up into the Dialog class.
-     */
-    private static final int MESSAGE_DISMISS = 0;
-    private Handler mDismissHandler = new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-            if (msg.what == MESSAGE_DISMISS) {
-                dismiss();
-            }
-        }
-    };
-    
-    /**
      * Various ways to launch searches
      */
 
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 0a37e81..2cc6de9 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -168,7 +168,8 @@
  * <p><b>Managing focus and knowing if Search is active.</b>  The search UI is not a separate
  * activity, and when the UI is invoked or dismissed, your activity will not typically be paused,
  * resumed, or otherwise notified by the methods defined in 
- * <a href="android.app.Activity#ActivityLifecycle">Activity Lifecycle</a>.  The search UI is
+ * <a href="{@docRoot}guide/topics/fundamentals.html#actlife">Application Fundamentals: 
+ * Activity Lifecycle</a>.  The search UI is
  * handled in the same way as other system UI elements which may appear from time to time, such as 
  * notifications, screen locks, or other system alerts:  
  * <p>When the search UI appears, your activity will lose input focus.
@@ -212,11 +213,11 @@
  * {@link #QUERY getStringExtra(SearchManager.QUERY)}.</li>
  * <li>To identify and support your searchable activity, you'll need to 
  * provide an XML file providing searchability configuration parameters, a reference to that 
- * in your searchable activity's <a href="../../../devel/bblocks-manifest.html">manifest</a>
+ * in your searchable activity's <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a>
  * entry, and an intent-filter declaring that you can 
  * receive ACTION_SEARCH intents.  This is described in more detail in the 
  * <a href="#SearchabilityMetadata">Searchability Metadata</a> section.</li>
- * <li>Your <a href="../../../devel/bblocks-manifest.html">manifest</a> also needs a metadata entry
+ * <li>Your <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> also needs a metadata entry
  * providing a global reference to the searchable activity.  This is the "glue" directing the search
  * UI, when invoked from any of your <i>other</i> activities, to use your application as the
  * default search context.  This is also described in more detail in the 
@@ -359,7 +360,7 @@
  * <li>Implement a Content Provider that provides suggestions.  If you already have one, and it 
  * has access to your suggestions data.  If not, you'll have to create one.
  * You'll also provide information about your Content Provider in your 
- * package's <a href="../../../devel/bblocks-manifest.html">manifest</a>.</li>
+ * package's <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a>.</li>
  * <li>Update your searchable activity's XML configuration file.  There are two categories of
  * information used for suggestions:
  * <ul><li>The first is (required) data that the search manager will
@@ -634,7 +635,7 @@
  *
  * <p><b>Metadata for searchable activity.</b>  As with your search implementations described 
  * above, you must first identify which of your activities is searchable.  In the 
- * <a href="../../../devel/bblocks-manifest.html">manifest</a> entry for this activity, you must 
+ * <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> entry for this activity, you must 
  * provide two elements:
  * <ul><li>An intent-filter specifying that you can receive and process the 
  * {@link android.content.Intent#ACTION_SEARCH ACTION_SEARCH} {@link android.content.Intent Intent}.
@@ -643,7 +644,7 @@
  * remaining configuration information for how your application implements search.</li></ul>
  * 
  * <p>Here is a snippet showing the necessary elements in the 
- * <a href="../../../devel/bblocks-manifest.html">manifest</a> entry for your searchable activity.
+ * <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> entry for your searchable activity.
  * <pre class="prettyprint">
  *        &lt;!-- Search Activity - searchable --&gt;
  *        &lt;activity android:name="MySearchActivity" 
@@ -765,9 +766,8 @@
  * <li>.../res/values/strings.xml</li></ul>
  * 
  * <p>For more complete documentation on this capability, see
- * <a href="../../../devel/resources-i18n.html#AlternateResources">Resources and 
- * Internationalization: Supporting Alternate Resources for Alternate Languages and Configurations
- * </a>.
+ * <a href="{@docRoot}guide/topics/resources/resources-i18n.html#AlternateResources">Resources and 
+ * Internationalization: Alternate Resources</a>.
  *
  * <p><b>Metadata for non-searchable activities.</b>  Activities which are part of a searchable
  * application, but don't implement search itself, require a bit of "glue" in order to cause
@@ -775,7 +775,7 @@
  * provided, then searches from these activities will use the system default search context.
  * 
  * <p>The simplest way to specify this is to add a <i>search reference</i> element to the
- * application entry in the <a href="../../../devel/bblocks-manifest.html">manifest</a> file.  
+ * application entry in the <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a> file.  
  * The value of this reference can be either of:
  * <ul><li>The name of your searchable activity.  
  * It is typically prefixed by '.' to indicate that it's in the same package.</li>
@@ -803,7 +803,7 @@
  * to generate search suggestions, you'll need to publish it to the system, and you'll need to 
  * provide a bit of additional XML metadata in order to configure communications with it.
  * 
- * <p>First, in your <a href="../../../devel/bblocks-manifest.html">manifest</a>, you'll add the
+ * <p>First, in your <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a>, you'll add the
  * following lines.
  * <pre class="prettyprint">
  *        &lt;!-- Content provider for search suggestions --&gt;
@@ -832,7 +832,7 @@
  *     <tbody>
  *     <tr><th>android:searchSuggestAuthority</th>
  *         <td>This value must match the authority string provided in the <i>provider</i> section 
- *             of your <a href="../../../devel/bblocks-manifest.html">manifest</a>.</td>
+ *             of your <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest</a>.</td>
  *         <td align="center">Yes</td>
  *     </tr>
  *     
diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java
index 6c08e75..72692f4 100644
--- a/core/java/android/app/Service.java
+++ b/core/java/android/app/Service.java
@@ -42,12 +42,12 @@
  * thread of their hosting process.  This means that, if your service is going
  * to do any CPU intensive (such as MP3 playback) or blocking (such as
  * networking) operations, it should spawn its own thread in which to do that
- * work.  More information on this can be found in the
- * <a href="{@docRoot}intro/appmodel.html#Threads">Threading section of the
- * Application Model overview</a>.</p>
+ * work.  More information on this can be found in
+ * <a href="{@docRoot}guide/topics/fundamentals.html#procthread">Application Fundamentals:
+ * Processes and Threads</a>.</p>
  * 
  * <p>The Service class is an important part of an
- * <a href="{@docRoot}intro/lifecycle.html">application's overall lifecycle</a>.</p>
+ * <a href="{@docRoot}guide/topics/fundamentals.html#lcycles">application's overall lifecycle</a>.</p>
  * 
  * <p>Topics covered here:
  * <ol>
@@ -79,7 +79,7 @@
  * to the service.  The service will remain running as long as the connection
  * is established (whether or not the client retains a reference on the
  * service's IBinder).  Usually the IBinder returned is for a complex
- * interface that has been <a href="{@docRoot}reference/aidl.html">written
+ * interface that has been <a href="{@docRoot}guide/developing/tools/aidl.html">written
  * in aidl</a>.
  * 
  * <p>A service can be both started and have connections bound to it.  In such
@@ -106,7 +106,7 @@
  * {@link #checkCallingPermission}
  * method before executing the implementation of that call.
  * 
- * <p>See the <a href="{@docRoot}devel/security.html">Security Model</a>
+ * <p>See the <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
  * document for more information on permissions and security in general.
  * 
  * <a name="ProcessLifecycle"></a>
@@ -201,14 +201,14 @@
      * Return the communication channel to the service.  May return null if 
      * clients can not bind to the service.  The returned
      * {@link android.os.IBinder} is usually for a complex interface
-     * that has been <a href="{@docRoot}reference/aidl.html">described using
+     * that has been <a href="{@docRoot}guide/developing/tools/aidl.html">described using
      * aidl</a>.
      * 
      * <p><em>Note that unlike other application components, calls on to the
      * IBinder interface returned here may not happen on the main thread
      * of the process</em>.  More information about this can be found
-     * in the <a href="{@docRoot}intro/appmodel.html#Threads">Threading section
-     * of the Application Model overview</a>.</p>
+     * in <a href="{@docRoot}guide/topics/fundamentals.html#procthread">Application Fundamentals:
+     * Processes and Threads</a>.</p>
      * 
      * @param intent The Intent that was used to bind to this service,
      * as given to {@link android.content.Context#bindService
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index d613e1c..56b231f 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -31,10 +31,15 @@
  * @hide
  */
 public class BluetoothDevice {
-    public static final int MODE_UNKNOWN = -1;
-    public static final int MODE_OFF = 0;
-    public static final int MODE_CONNECTABLE = 1;
-    public static final int MODE_DISCOVERABLE = 2;
+    /** Inquiry scan and page scan are both off.
+     *  Device is neither discoverable nor connectable */
+    public static final int SCAN_MODE_NONE = 0;
+    /** Page scan is on, inquiry scan is off.
+     *  Device is connectable, but not discoverable */
+    public static final int SCAN_MODE_CONNECTABLE = 1;
+    /** Page scan and inquiry scan are on.
+     *  Device is connectable and discoverable */
+    public static final int SCAN_MODE_CONNECTABLE_DISCOVERABLE = 3;
 
     public static final int RESULT_FAILURE = -1;
     public static final int RESULT_SUCCESS = 0;
@@ -54,10 +59,10 @@
     /** A bond attempt failed because the other side explicilty rejected
      * bonding */
     public static final int UNBOND_REASON_AUTH_REJECTED = 2;
-    /** A bond attempt failed because we cancelled the bonding process */
-    public static final int UNBOND_REASON_CANCELLED = 3;
+    /** A bond attempt failed because we canceled the bonding process */
+    public static final int UNBOND_REASON_AUTH_CANCELED = 3;
     /** A bond attempt failed because we could not contact the remote device */
-    public static final int UNBOND_REASON_AUTH_REMOTE_DEVICE_DOWN = 4;
+    public static final int UNBOND_REASON_REMOTE_DEVICE_DOWN = 4;
     /** An existing bond was explicitly revoked */
     public static final int UNBOND_REASON_REMOVED = 5;
 
@@ -174,18 +179,6 @@
         return false;
     }
 
-    public String getMajorClass() {
-        try {
-            return mService.getMajorClass();
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return null;
-    }
-    public String getMinorClass() {
-        try {
-            return mService.getMinorClass();
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return null;
-    }
     public String getVersion() {
         try {
             return mService.getVersion();
@@ -211,15 +204,26 @@
         return null;
     }
 
-    public int getMode() {
+    /**
+     * Get the current scan mode.
+     * Used to determine if the local device is connectable and/or discoverable
+     * @return Scan mode, one of SCAN_MODE_* or an error code
+     */
+    public int getScanMode() {
         try {
-            return mService.getMode();
+            return mService.getScanMode();
         } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return MODE_UNKNOWN;
+        return BluetoothError.ERROR_IPC;
     }
-    public void setMode(int mode) {
+
+    /**
+     * Set the current scan mode.
+     * Used to make the local device connectable and/or discoverable
+     * @param scanMode One of SCAN_MODE_*
+     */
+    public void setScanMode(int scanMode) {
         try {
-            mService.setMode(mode);
+            mService.setScanMode(scanMode);
         } catch (RemoteException e) {Log.e(TAG, "", e);}
     }
 
@@ -435,24 +439,6 @@
         return null;
     }
 
-    public String getRemoteAlias(String address) {
-        try {
-            return mService.getRemoteAlias(address);
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return null;
-    }
-    public boolean setRemoteAlias(String address, String alias) {
-        try {
-            return mService.setRemoteAlias(address, alias);
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return false;
-    }
-    public boolean clearRemoteAlias(String address) {
-        try {
-            return mService.clearRemoteAlias(address);
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return false;
-    }
     public String getRemoteVersion(String address) {
         try {
             return mService.getRemoteVersion(address);
@@ -477,24 +463,6 @@
         } catch (RemoteException e) {Log.e(TAG, "", e);}
         return null;
     }
-    public String getRemoteMajorClass(String address) {
-        try {
-            return mService.getRemoteMajorClass(address);
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return null;
-    }
-    public String getRemoteMinorClass(String address) {
-        try {
-            return mService.getRemoteMinorClass(address);
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return null;
-    }
-    public String[] getRemoteServiceClasses(String address) {
-        try {
-            return mService.getRemoteServiceClasses(address);
-        } catch (RemoteException e) {Log.e(TAG, "", e);}
-        return null;
-    }
 
     /**
      * Returns the RFCOMM channel associated with the 16-byte UUID on
@@ -512,12 +480,19 @@
         return false;
     }
 
+    /**
+     * Get the major, minor and servics classes of a remote device.
+     * These classes are encoded as a 32-bit integer. See BluetoothClass.
+     * @param address remote device
+     * @return 32-bit class suitable for use with BluetoothClass.
+     */
     public int getRemoteClass(String address) {
         try {
             return mService.getRemoteClass(address);
         } catch (RemoteException e) {Log.e(TAG, "", e);}
         return BluetoothClass.ERROR;
     }
+
     public byte[] getRemoteFeatures(String address) {
         try {
             return mService.getRemoteFeatures(address);
@@ -576,8 +551,8 @@
     }
     
 
-    /* Sanity check a bluetooth address, such as "00:43:A8:23:10:F0" */
     private static final int ADDRESS_LENGTH = 17;
+    /** Sanity check a bluetooth address, such as "00:43:A8:23:10:F0" */
     public static boolean checkBluetoothAddress(String address) {
         if (address == null || address.length() != ADDRESS_LENGTH) {
             return false;
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java
index c315271..34196bf 100644
--- a/core/java/android/bluetooth/BluetoothHeadset.java
+++ b/core/java/android/bluetooth/BluetoothHeadset.java
@@ -69,8 +69,8 @@
 
     public static final int RESULT_FAILURE = 0;
     public static final int RESULT_SUCCESS = 1;
-    /** Connection cancelled before completetion. */
-    public static final int RESULT_CANCELLED = 2;
+    /** Connection canceled before completetion. */
+    public static final int RESULT_CANCELED = 2;
 
     /** Default priority for headsets that should be auto-connected */
     public static final int PRIORITY_AUTO = 100;
@@ -318,6 +318,12 @@
      * @return True if this device might support HSP or HFP.
      */
     public static boolean doesClassMatch(int btClass) {
+        // The render service class is required by the spec for HFP, so is a
+        // pretty good signal
+        if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.RENDER)) {
+            return true;
+        }
+        // Just in case they forgot the render service class
         switch (BluetoothClass.Device.getDevice(btClass)) {
         case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
         case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
diff --git a/core/java/android/bluetooth/BluetoothIntent.java b/core/java/android/bluetooth/BluetoothIntent.java
index 57c46f9..b66b06e 100644
--- a/core/java/android/bluetooth/BluetoothIntent.java
+++ b/core/java/android/bluetooth/BluetoothIntent.java
@@ -29,8 +29,8 @@
  * @hide
  */
 public interface BluetoothIntent {
-    public static final String MODE =
-        "android.bluetooth.intent.MODE";
+    public static final String SCAN_MODE =
+        "android.bluetooth.intent.SCAN_MODE";
     public static final String ADDRESS =
         "android.bluetooth.intent.ADDRESS";
     public static final String NAME =
@@ -62,9 +62,14 @@
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String NAME_CHANGED_ACTION  =
         "android.bluetooth.intent.action.NAME_CHANGED";
+
+    /**
+     * Broadcast when the scan mode changes. Always contains an int extra
+     * named SCAN_MODE that contains the new scan mode.
+     */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String MODE_CHANGED_ACTION         =
-        "android.bluetooth.intent.action.MODE_CHANGED";
+    public static final String SCAN_MODE_CHANGED_ACTION         =
+        "android.bluetooth.intent.action.SCAN_MODE_CHANGED";
 
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String DISCOVERY_STARTED_ACTION          =
@@ -104,12 +109,6 @@
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String REMOTE_NAME_FAILED_ACTION         =
         "android.bluetooth.intent.action.REMOTE_NAME_FAILED";
-    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String REMOTE_ALIAS_CHANGED_ACTION       =
-        "android.bluetooth.intent.action.REMOTE_ALIAS_CHANGED";
-    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
-    public static final String REMOTE_ALIAS_CLEARED_ACTION       =
-        "android.bluetooth.intent.action.REMOTE_ALIAS_CLEARED";
 
     /**
      * Broadcast when the bond state of a remote device changes.
diff --git a/core/java/android/bluetooth/HeadsetBase.java b/core/java/android/bluetooth/HeadsetBase.java
index bce3388..fd2d2ab 100644
--- a/core/java/android/bluetooth/HeadsetBase.java
+++ b/core/java/android/bluetooth/HeadsetBase.java
@@ -21,13 +21,10 @@
 import android.os.PowerManager.WakeLock;
 import android.util.Log;
 
-import java.io.IOException;
-import java.lang.Thread;
-
 /**
  * The Android Bluetooth API is not finalized, and *will* change. Use at your
  * own risk.
- * 
+ *
  * The base RFCOMM (service) connection for a headset or handsfree device.
  *
  * In the future this class will be removed.
@@ -90,7 +87,7 @@
 
     /* Create from an already exisiting rfcomm connection */
     public HeadsetBase(PowerManager pm, BluetoothDevice bluetooth, String address, int socketFd,
-                       int rfcommChannel, Handler handler) {
+            int rfcommChannel, Handler handler) {
         mDirection = DIRECTION_INCOMING;
         mConnectTimestamp = System.currentTimeMillis();
         mBluetooth = bluetooth;
@@ -132,30 +129,8 @@
      */
     protected void initializeAtParser() {
         mAtParser = new AtParser();
-
-        // Microphone Gain
-        mAtParser.register("+VGM", new AtCommandHandler() {
-            @Override
-            public AtCommandResult handleSetCommand(Object[] args) {
-                // AT+VGM=<gain>    in range [0,15]
-                // Headset/Handsfree is reporting its current gain setting
-                //TODO: sync to android UI
-                //TODO: Send unsolicited +VGM when volume changed on AG
-                return new AtCommandResult(AtCommandResult.OK);
-            }
-        });
-
-        // Speaker Gain
-        mAtParser.register("+VGS", new AtCommandHandler() {
-            @Override
-            public AtCommandResult handleSetCommand(Object[] args) {
-                // AT+VGS=<gain>    in range [0,15]
-                // Headset/Handsfree is reporting its current gain to Android
-                //TODO: sync to AG UI
-                //TODO: Send unsolicited +VGS when volume changed on AG
-                return new AtCommandResult(AtCommandResult.OK);
-            }
-        });
+        //TODO(): Get rid of this as there are no parsers registered. But because of dependencies,
+        //it needs to be done as part of refactoring HeadsetBase and BluetoothHandsfree
     }
 
     public AtParser getAtParser() {
diff --git a/core/java/android/bluetooth/IBluetoothDevice.aidl b/core/java/android/bluetooth/IBluetoothDevice.aidl
index 59f679f..4351d2e 100644
--- a/core/java/android/bluetooth/IBluetoothDevice.aidl
+++ b/core/java/android/bluetooth/IBluetoothDevice.aidl
@@ -32,15 +32,13 @@
     String getAddress();
     String getName();
     boolean setName(in String name);
-    String getMajorClass();
-    String getMinorClass();
     String getVersion();
     String getRevision();
     String getManufacturer();
     String getCompany();
 
-    int getMode();
-    boolean setMode(int mode);
+    int getScanMode();
+    boolean setScanMode(int mode);
 
     int getDiscoverableTimeout();
     boolean setDiscoverableTimeout(int timeout);
@@ -64,17 +62,11 @@
     int getBondState(in String address);
 
     String getRemoteName(in String address);
-    String getRemoteAlias(in String address);
-    boolean setRemoteAlias(in String address, in String alias);
-    boolean clearRemoteAlias(in String address);
     String getRemoteVersion(in String address);
     String getRemoteRevision(in String address);
     int getRemoteClass(in String address);
     String getRemoteManufacturer(in String address);
     String getRemoteCompany(in String address);
-    String getRemoteMajorClass(in String address);
-    String getRemoteMinorClass(in String address);
-    String[] getRemoteServiceClasses(in String address);
     boolean getRemoteServiceChannel(in String address, int uuid16, in IBluetoothDeviceCallback callback);
     byte[] getRemoteFeatures(in String adddress);
     String lastSeen(in String address);
diff --git a/core/java/android/content/AsyncQueryHandler.java b/core/java/android/content/AsyncQueryHandler.java
index 2d651a7..ac851cc 100644
--- a/core/java/android/content/AsyncQueryHandler.java
+++ b/core/java/android/content/AsyncQueryHandler.java
@@ -146,6 +146,20 @@
      * @param token A token passed into {@link #onQueryComplete} to identify
      *  the query.
      * @param cookie An object that gets passed into {@link #onQueryComplete}
+     * @param uri The URI, using the content:// scheme, for the content to
+     *         retrieve.
+     * @param projection A list of which columns to return. Passing null will
+     *         return all columns, which is discouraged to prevent reading data
+     *         from storage that isn't going to be used.
+     * @param selection A filter declaring which rows to return, formatted as an
+     *         SQL WHERE clause (excluding the WHERE itself). Passing null will
+     *         return all rows for the given URI.
+     * @param selectionArgs You may include ?s in selection, which will be
+     *         replaced by the values from selectionArgs, in the order that they
+     *         appear in the selection. The values will be bound as Strings.
+     * @param orderBy How to order the rows, formatted as an SQL ORDER BY
+     *         clause (excluding the ORDER BY itself). Passing null will use the
+     *         default sort order, which may be unordered.
      */
     public void startQuery(int token, Object cookie, Uri uri,
             String[] projection, String selection, String[] selectionArgs,
diff --git a/core/java/android/content/BroadcastReceiver.java b/core/java/android/content/BroadcastReceiver.java
index cd92002..ee08eea 100644
--- a/core/java/android/content/BroadcastReceiver.java
+++ b/core/java/android/content/BroadcastReceiver.java
@@ -16,7 +16,11 @@
 
 package android.content;
 
+import android.app.ActivityManagerNative;
+import android.app.IActivityManager;
 import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
 import android.util.Log;
 
 /**
@@ -175,7 +179,9 @@
      * return a result to you asynchronously -- in particular, for interacting
      * with services, you should use
      * {@link Context#startService(Intent)} instead of
-     * {@link Context#bindService(Intent, ServiceConnection, int)}.
+     * {@link Context#bindService(Intent, ServiceConnection, int)}.  If you wish
+     * to interact with a service that is already running, you can use
+     * {@link #peekService}.
      * 
      * @param context The Context in which the receiver is running.
      * @param intent The Intent being received.
@@ -183,6 +189,26 @@
     public abstract void onReceive(Context context, Intent intent);
 
     /**
+     * Provide a binder to an already-running service.  This method is synchronous
+     * and will not start the target service if it is not present, so it is safe
+     * to call from {@link #onReceive}.
+     * 
+     * @param myContext The Context that had been passed to {@link #onReceive(Context, Intent)}
+     * @param service The Intent indicating the service you wish to use.  See {@link
+     * Context#startService(Intent)} for more information.
+     */
+    public IBinder peekService(Context myContext, Intent service) {
+        IActivityManager am = ActivityManagerNative.getDefault();
+        IBinder binder = null;
+        try {
+            binder = am.peekService(service, service.resolveTypeIfNeeded(
+                    myContext.getContentResolver()));
+        } catch (RemoteException e) {
+        }
+        return binder;
+    }
+
+    /**
      * Change the current result code of this broadcast; only works with
      * broadcasts sent through
      * {@link Context#sendOrderedBroadcast(Intent, String)
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 3908aa1..e0fe533 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -127,7 +127,7 @@
      * current process.
      */
     public abstract Context getApplicationContext();
-    
+
     /**
      * Return a localized, styled CharSequence from the application's package's
      * default string table.
@@ -428,7 +428,7 @@
      *     cursor when query is called.
      *
      * @return The contents of a newly created database with the given name.
-     * @throws SQLiteException if the database file could not be opened.
+     * @throws android.database.sqlite.SQLiteException if the database file could not be opened.
      *
      * @see #MODE_PRIVATE
      * @see #MODE_WORLD_READABLE
@@ -1064,7 +1064,7 @@
      * @see #AUDIO_SERVICE
      * @see android.media.AudioManager
      * @see #TELEPHONY_SERVICE
-     * @see android.internal.TelephonyManager
+     * @see android.telephony.TelephonyManager
      * @see #INPUT_METHOD_SERVICE
      * @see android.view.inputmethod.InputMethodManager
      */
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index e2d3576..52aae0d 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -504,6 +504,8 @@
  *     <li> {@link #ACTION_PACKAGE_ADDED}
  *     <li> {@link #ACTION_PACKAGE_CHANGED}
  *     <li> {@link #ACTION_PACKAGE_REMOVED}
+ *     <li> {@link #ACTION_PACKAGE_RESTARTED}
+ *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
  *     <li> {@link #ACTION_UID_REMOVED}
  *     <li> {@link #ACTION_BATTERY_CHANGED}
  * </ul>
@@ -1107,6 +1109,10 @@
     /**
      * Broadcast Action: A new application package has been installed on the
      * device. The data contains the name of the package.
+     * <p>My include the following extras:
+     * <ul>
+     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
+     * </ul>
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
@@ -1114,23 +1120,49 @@
      * Broadcast Action: An existing application package has been removed from
      * the device.  The data contains the name of the package.  The package
      * that is being installed does <em>not</em> receive this Intent.
+     * <ul>
+     * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
+     * to the package.
+     * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
+     * application -- data and code -- is being removed.
+     * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
+     * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
+     * </ul>
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
     /**
      * Broadcast Action: An existing application package has been changed (e.g. a component has been
      * enabled or disabled.  The data contains the name of the package.
+     * <ul>
+     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
+     * </ul>
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
     /**
-     * Broadcast Action: The user has restarted a package, all runtime state
+     * Broadcast Action: The user has restarted a package, and all of its
+     * processes have been killed.  All runtime state
      * associated with it (processes, alarms, notifications, etc) should
-     * be remove.  The data contains the name of the package.
+     * be removed.  The data contains the name of the package.
+     * <ul>
+     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
+     * </ul>
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
     /**
+     * Broadcast Action: The user has cleared the data of a package.  This should
+     * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
+     * its persistent data is erased and this broadcast sent.  The data contains
+     * the name of the package.
+     * <ul>
+     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
+     * </ul>
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
+    /**
      * Broadcast Action: A user ID has been removed from the system.  The user
      * ID number is stored in the extra data under {@link #EXTRA_UID}.
      */
@@ -1227,7 +1259,6 @@
     /**
      * Broadcast Action:  External media is present, and being disk-checked
      * The path to the mount point for the checking media is contained in the Intent.mData field.
-     * @hide
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
@@ -1235,7 +1266,6 @@
     /**
      * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
      * The path to the mount point for the checking media is contained in the Intent.mData field.
-     * @hide
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
@@ -1656,6 +1686,22 @@
     public static final String EXTRA_UID = "android.intent.extra.UID";
 
     /**
+     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
+     * intents to indicate whether this represents a full uninstall (removing
+     * both the code and its data) or a partial uninstall (leaving its data,
+     * implying that this is an update).
+     */
+    public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
+    
+    /**
+     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
+     * intents to indicate that this is a replacement of the package, so this
+     * broadcast will immediately be followed by an add broadcast for a
+     * different version of the same package.
+     */
+    public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
+    
+    /**
      * Used as an int extra field in {@link android.app.AlarmManager} intents
      * to tell the application being invoked how many pending alarms are being
      * delievered with the intent.  For one-shot alarms this will always be 1.
@@ -1770,8 +1816,8 @@
      * Intent, resulting in the stack now being: A, B.
      *
      * <p>The currently running instance of task B in the above example will
-     * either receiving the new intent you are starting here in its
-     * onNewIntent() method, or be itself finished and restarting with the
+     * either receive the new intent you are starting here in its
+     * onNewIntent() method, or be itself finished and restarted with the
      * new intent.  If it has declared its launch mode to be "multiple" (the
      * default) it will be finished and re-created; for all other launch modes
      * it will receive the Intent in the current instance.
@@ -1855,7 +1901,7 @@
      */
     public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
     /**
-     * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaving}
+     * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
      * callback from occurring on the current frontmost activity before it is
      * paused as the newly-started activity is brought to the front.
      * 
@@ -1871,12 +1917,39 @@
      * activity does not think the user has acknowledged its notification. 
      */
     public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
-
+    /**
+     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
+     * this flag will cause the launched activity to be brought to the front of its
+     * task's history stack if it is already running.
+     * 
+     * <p>For example, consider a task consisting of four activities: A, B, C, D.
+     * If D calls startActivity() with an Intent that resolves to the component
+     * of activity B, then B will be brought to the front of the history stack,
+     * with this resulting order:  A, C, D, B.
+     * 
+     * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
+     * specified. 
+     */
+    public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
     /**
      * If set, when sending a broadcast only registered receivers will be
      * called -- no BroadcastReceiver components will be launched.
      */
     public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
+    /**
+     * If set, when sending a broadcast <i>before boot has completed</i> only
+     * registered receivers will be called -- no BroadcastReceiver components
+     * will be launched.  Sticky intent state will be recorded properly even
+     * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
+     * is specified in the broadcast intent, this flag is unnecessary.
+     * 
+     * <p>This flag is only for use by system sevices as a convenience to
+     * avoid having to implement a more complex mechanism around detection
+     * of boot completion.
+     * 
+     * @hide
+     */
+    public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x20000000;
 
     // ---------------------------------------------------------------------
 
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 6bc3774..96470c3 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -123,7 +123,7 @@
 
     private static final String SYNC_WAKE_LOCK = "SyncManagerSyncWakeLock";
     private static final String HANDLE_SYNC_ALARM_WAKE_LOCK = "SyncManagerHandleSyncAlarmWakeLock";
-    
+
     private Context mContext;
     private ContentResolver mContentResolver;
 
@@ -249,7 +249,7 @@
         mSyncQueue = new SyncQueue(mSyncStorageEngine);
 
         mContext = context;
-        
+
         mSyncThread = new HandlerThread("SyncHandlerThread", Process.THREAD_PRIORITY_BACKGROUND);
         mSyncThread.start();
         mSyncHandler = new SyncHandler(mSyncThread.getLooper());
@@ -489,7 +489,7 @@
         // Require the precise value "yes" to discourage accidental activation.
         return "yes".equals(SystemProperties.get("ro.config.sync"));
     }
-    
+
     /**
      * Initiate a sync. This can start a sync for all providers
      * (pass null to url, set onlyTicklable to false), only those
@@ -515,7 +515,7 @@
 *          syncs of a specific provider. Can be null. Is ignored
 *          if the url is null.
      * @param delay how many milliseconds in the future to wait before performing this
-     *   sync. -1 means to make this the next sync to perform. 
+     *   sync. -1 means to make this the next sync to perform.
      */
     public void scheduleSync(Uri url, Bundle extras, long delay) {
         boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE);
@@ -694,7 +694,7 @@
     class SyncHandlerMessagePayload {
         public final ActiveSyncContext activeSyncContext;
         public final SyncResult syncResult;
-        
+
         SyncHandlerMessagePayload(ActiveSyncContext syncContext, SyncResult syncResult) {
             this.activeSyncContext = syncContext;
             this.syncResult = syncResult;
@@ -740,7 +740,7 @@
         if (newDelayInMs > maxSyncRetryTimeInSeconds * 1000) {
             newDelayInMs = maxSyncRetryTimeInSeconds * 1000;
         }
-        
+
         SyncOperation rescheduledSyncOperation = new SyncOperation(syncOperation);
         rescheduledSyncOperation.setDelay(newDelayInMs);
         scheduleSyncOperation(rescheduledSyncOperation);
@@ -786,7 +786,7 @@
             // key than the one we are scheduling.
             if (!activeIsExpedited && !hasSameKey) {
                 rescheduleImmediately(activeSyncContext.mSyncOperation);
-                sendSyncFinishedOrCanceledMessage(activeSyncContext, 
+                sendSyncFinishedOrCanceledMessage(activeSyncContext,
                         null /* no result since this is a cancel */);
             }
         }
@@ -1323,7 +1323,7 @@
         public SyncHandler(Looper looper) {
             super(looper);
         }
-        
+
         public void handleMessage(Message msg) {
             handleSyncHandlerMessage(msg);
         }
@@ -1462,6 +1462,9 @@
             // start it, otherwise just get out.
             SyncOperation syncOperation;
             final Sync.Settings.QueryMap syncSettings = getSyncSettings();
+            final ConnectivityManager connManager = (ConnectivityManager)
+                    mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+            final boolean backgroundDataSetting = connManager.getBackgroundDataSetting();
             synchronized (mSyncQueue) {
                 while (true) {
                     syncOperation = mSyncQueue.head();
@@ -1484,10 +1487,10 @@
                     // skip the sync if it isn't a force and the settings are off for this provider
                     final boolean force = syncOperation.extras.getBoolean(
                             ContentResolver.SYNC_EXTRAS_FORCE, false);
-                    if (!force && (!syncSettings.getBackgroundData()
+                    if (!force && (!backgroundDataSetting
                             || !syncSettings.getListenForNetworkTickles()
                             || !syncSettings.getSyncProviderAutomatically(
-                            syncOperation.authority))) {
+                                    syncOperation.authority))) {
                         if (isLoggable) {
                             Log.v(TAG, "runStateIdle: sync off, dropping " + syncOperation);
                         }
@@ -1669,7 +1672,7 @@
          * @param syncResult the SyncResult from which to read
          * @return the most "serious" error set in the SyncResult
          * @throws IllegalStateException if the SyncResult does not indicate any errors.
-         *   If SyncResult.error() is true then it is safe to call this.   
+         *   If SyncResult.error() is true then it is safe to call this.
          */
         private int syncResultToErrorNumber(SyncResult syncResult) {
             if (syncResult.syncAlreadyInProgress) return History.ERROR_SYNC_ALREADY_IN_PROGRESS;
@@ -1679,7 +1682,8 @@
             if (syncResult.stats.numConflictDetectedExceptions > 0) return History.ERROR_CONFLICT;
             if (syncResult.tooManyDeletions) return History.ERROR_TOO_MANY_DELETIONS;
             if (syncResult.tooManyRetries) return History.ERROR_TOO_MANY_RETRIES;
-            throw new IllegalStateException("we are not in an error state, " + toString());
+            if (syncResult.databaseError) return History.ERROR_INTERNAL;
+            throw new IllegalStateException("we are not in an error state, " + syncResult);
         }
 
         private void manageSyncNotification() {
@@ -1717,7 +1721,7 @@
                 if (mSyncNotificationInfo.isActive) {
                     shouldInstall = shouldCancel;
                 } else {
-                    final boolean timeToShowNotification = 
+                    final boolean timeToShowNotification =
                             now > mSyncNotificationInfo.startTime + SYNC_NOTIFICATION_DELAY;
                     final boolean syncIsForced = syncOperation.extras
                             .getBoolean(ContentResolver.SYNC_EXTRAS_FORCE, false);
@@ -1769,7 +1773,7 @@
             if (!mDataConnectionIsConnected) return;
             if (mAccounts == null) return;
             if (mStorageIsLow) return;
-            
+
             // Compute the alarm fire time:
             // - not syncing: time of the next sync operation
             // - syncing, no notification: time from sync start to notification create time
@@ -1850,12 +1854,12 @@
             clickIntent.putExtra("account", account);
             clickIntent.putExtra("provider", authority);
             clickIntent.putExtra("numDeletes", numDeletes);
-            
+
             if (!isActivityAvailable(clickIntent)) {
                 Log.w(TAG, "No activity found to handle too many deletes.");
                 return;
             }
-            
+
             final PendingIntent pendingIntent = PendingIntent
                     .getActivity(mContext, 0, clickIntent, PendingIntent.FLAG_CANCEL_CURRENT);
 
@@ -1877,7 +1881,7 @@
 
         /**
          * Checks whether an activity exists on the system image for the given intent.
-         * 
+         *
          * @param intent The intent for an activity.
          * @return Whether or not an activity exists.
          */
@@ -1892,10 +1896,10 @@
                     return true;
                 }
             }
-            
+
             return false;
         }
-        
+
         public long insertStartSyncEvent(SyncOperation syncOperation) {
             final int source = syncOperation.syncSource;
             final long now = System.currentTimeMillis();
diff --git a/core/java/android/content/TempProviderSyncAdapter.java b/core/java/android/content/TempProviderSyncAdapter.java
index 78510aa..eb3a5da 100644
--- a/core/java/android/content/TempProviderSyncAdapter.java
+++ b/core/java/android/content/TempProviderSyncAdapter.java
@@ -1,11 +1,11 @@
 package android.content;
 
-import com.google.android.net.NetStats;
-
 import android.database.SQLException;
 import android.os.Bundle;
 import android.os.Debug;
+import android.os.NetStat;
 import android.os.Parcelable;
+import android.os.Process;
 import android.os.SystemProperties;
 import android.text.TextUtils;
 import android.util.Config;
@@ -177,7 +177,8 @@
         private final Bundle mExtras;
         private final SyncContext mSyncContext;
         private volatile boolean mIsCanceled = false;
-        private long[] mNetStats;
+        private long mInitialTxBytes;
+        private long mInitialRxBytes;
         private final SyncResult mResult;
 
         SyncThread(SyncContext syncContext, String account, Bundle extras) {
@@ -193,15 +194,18 @@
             if (mAdapterSyncStarted) onSyncCanceled();
             if (mProviderSyncStarted) mProvider.onSyncCanceled();
             // We may lose the last few sync events when canceling.  Oh well.
-            long[] newNetStats = NetStats.getStats();
-            logSyncDetails(newNetStats[0] - mNetStats[0], newNetStats[1] - mNetStats[1], mResult);
+            int uid = Process.myUid();
+            logSyncDetails(NetStat.getUidTxBytes(uid) - mInitialTxBytes,
+                    NetStat.getUidRxBytes(uid) - mInitialRxBytes, mResult);
         }
         
         @Override
         public void run() {
-            android.os.Process.setThreadPriority(android.os.Process.myTid(),
-                    android.os.Process.THREAD_PRIORITY_BACKGROUND);
-            mNetStats = NetStats.getStats();
+            Process.setThreadPriority(Process.myTid(),
+                    Process.THREAD_PRIORITY_BACKGROUND);
+            int uid = Process.myUid();
+            mInitialTxBytes = NetStat.getUidTxBytes(uid);
+            mInitialRxBytes = NetStat.getUidRxBytes(uid);
             try {
                 sync(mSyncContext, mAccount, mExtras);
             } catch (SQLException e) {
@@ -210,8 +214,8 @@
             } finally {
                 mSyncThread = null;
                 if (!mIsCanceled) {
-                    long[] newNetStats = NetStats.getStats();
-                    logSyncDetails(newNetStats[0] - mNetStats[0], newNetStats[1] - mNetStats[1], mResult);
+                    logSyncDetails(NetStat.getUidTxBytes(uid) - mInitialTxBytes,
+                    NetStat.getUidRxBytes(uid) - mInitialRxBytes, mResult);
                     mSyncContext.onFinished(mResult);
                 }
             }
diff --git a/core/java/android/content/pm/ConfigurationInfo.java b/core/java/android/content/pm/ConfigurationInfo.java
index 9115225..dcc7463 100755
--- a/core/java/android/content/pm/ConfigurationInfo.java
+++ b/core/java/android/content/pm/ConfigurationInfo.java
@@ -16,7 +16,6 @@
 
 package android.content.pm;
 
-import android.content.res.Configuration;
 import android.os.Parcel;
 import android.os.Parcelable;
 
@@ -60,12 +59,12 @@
     
     /**
      * Value for {@link #reqInputFeatures}: if set, indicates that the application
-     * requires a hard keyboard
+     * requires a five way navigation device
      */
     public static final int INPUT_FEATURE_FIVE_WAY_NAV = 0x00000002;
     
     /**
-     * Flags associated with the application.  Any combination of
+     * Flags associated with the input features.  Any combination of
      * {@link #INPUT_FEATURE_HARD_KEYBOARD},
      * {@link #INPUT_FEATURE_FIVE_WAY_NAV}
      */
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index ea86188..d3f6f3c5 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -255,8 +255,15 @@
      * retrieval of information is complete.
      */
     void getPackageSizeInfo(in String packageName, IPackageStatsObserver observer);
+    
+    /**
+     * Get a list of shared libraries that are available on the
+     * system.
+     */
+    String[] getSystemSharedLibraryNames();
 
     void enterSafeMode();
+    boolean isSafeMode();
     void systemReady();
     boolean hasSystemUidErrors();
 }
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 4b902e9..698f27f 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -851,6 +851,16 @@
      * @see #GET_UNINSTALLED_PACKAGES
      */
     public abstract List<ApplicationInfo> getInstalledApplications(int flags);
+    
+    /**
+     * Get a list of shared libraries that are available on the
+     * system.
+     * 
+     * @return An array of shared library names that are
+     * available on the system, or null if none are installed.
+     * 
+     */
+    public abstract String[] getSystemSharedLibraryNames();
 
     /**
      * Determine the best action to perform for a given Intent.  This is how
@@ -1608,4 +1618,9 @@
      * the manifest as found in {@link ComponentInfo}.
      */
     public abstract int getApplicationEnabledSetting(String packageName);
+
+    /**
+     * Return whether the device has been booted into safe mode.
+     */
+    public abstract boolean isSafeMode();
 }
diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java
index 4b1e678..17cb687 100644
--- a/core/java/android/content/res/ColorStateList.java
+++ b/core/java/android/content/res/ColorStateList.java
@@ -304,6 +304,11 @@
     }
 
     public void writeToParcel(Parcel dest, int flags) {
+        final int N = mStateSpecs.length;
+        dest.writeInt(N);
+        for (int i=0; i<N; i++) {
+            dest.writeIntArray(mStateSpecs[i]);
+        }
         dest.writeArray(mStateSpecs);
         dest.writeIntArray(mColors);
     }
@@ -315,14 +320,11 @@
         }
 
         public ColorStateList createFromParcel(Parcel source) {
-            Object[] o = source.readArray(
-                                    ColorStateList.class.getClassLoader());
-            int[][] stateSpecs = new int[o.length][];
-
-            for (int i = 0; i < o.length; i++) {
-                stateSpecs[i] = (int[]) o[i];
+            final int N = source.readInt();
+            int[][] stateSpecs = new int[N][];
+            for (int i=0; i<N; i++) {
+                stateSpecs[i] = source.createIntArray();
             }
-
             int[] colors = source.createIntArray();
             return new ColorStateList(stateSpecs, colors);
         }
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 10eced6..5a0daea 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -22,7 +22,6 @@
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
-import android.content.Intent;
 import android.graphics.Movie;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.ColorDrawable;
@@ -399,7 +398,6 @@
      * 
      * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
      *
-     * @return CharSequence The string data associated with the resource, plus
      * @see #getDimensionPixelOffset
      * @see #getDimensionPixelSize
      */
@@ -432,7 +430,6 @@
      * 
      * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
      *
-     * @return CharSequence The string data associated with the resource, plus
      * @see #getDimension
      * @see #getDimensionPixelSize
      */
@@ -467,7 +464,6 @@
      *  
      * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
      *
-     * @return CharSequence The string data associated with the resource, plus
      * @see #getDimension
      * @see #getDimensionPixelOffset
      */
@@ -486,6 +482,36 @@
     }
 
     /**
+     * Retrieve a fractional unit for a particular resource ID.
+     * 
+     * @param id The desired resource identifier, as generated by the aapt
+     *           tool. This integer encodes the package, type, and resource
+     *           entry. The value 0 is an invalid identifier.
+     * @param base The base value of this fraction.  In other words, a 
+     *             standard fraction is multiplied by this value.
+     * @param pbase The parent base value of this fraction.  In other 
+     *             words, a parent fraction (nn%p) is multiplied by this
+     *             value.
+     * 
+     * @return Attribute fractional value multiplied by the appropriate 
+     * base value.
+     *  
+     * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
+     */
+    public float getFraction(int id, int base, int pbase) {
+        synchronized (mTmpValue) {
+            TypedValue value = mTmpValue;
+            getValue(id, value, true);
+            if (value.type == TypedValue.TYPE_FRACTION) {
+                return TypedValue.complexToFraction(value.data, base, pbase);
+            }
+            throw new NotFoundException(
+                    "Resource ID #0x" + Integer.toHexString(id) + " type #0x"
+                    + Integer.toHexString(value.type) + " is not valid");
+        }
+    }
+    
+    /**
      * Return a drawable object associated with a particular resource ID.
      * Various types of objects will be returned depending on the underlying
      * resource -- for example, a solid color, PNG image, scalable image, etc.
@@ -721,22 +747,36 @@
      */
     public InputStream openRawResource(int id) throws NotFoundException {
         synchronized (mTmpValue) {
-            TypedValue value = mTmpValue;
-            getValue(id, value, true);
+            return openRawResource(id, mTmpValue);
+        }
+    }
 
-            try {
-                return mAssets.openNonAsset(
-                    value.assetCookie, value.string.toString(),
+    /**
+     * Open a data stream for reading a raw resource.  This can only be used
+     * with resources whose value is the name of an asset files -- that is, it can be
+     * used to open drawable, sound, and raw resources; it will fail on string
+     * and color resources.
+     *
+     * @param id The resource identifier to open, as generated by the appt tool.
+     * @param value The TypedValue object to hold the resource information.
+     *
+     * @return InputStream Access to the resource data.
+     *
+     * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
+     *
+     * @hide Pending API council approval
+     */
+    public InputStream openRawResource(int id, TypedValue value) throws NotFoundException {
+        getValue(id, value, true);
+
+        try {
+            return mAssets.openNonAsset(value.assetCookie, value.string.toString(),
                     AssetManager.ACCESS_STREAMING);
-            } catch (Exception e) {
-                NotFoundException rnf = new NotFoundException(
-                    "File " + value.string.toString()
-                    + " from drawable resource ID #0x"
-                    + Integer.toHexString(id));
-                rnf.initCause(e);
-                throw rnf;
-            }
-
+        } catch (Exception e) {
+            NotFoundException rnf = new NotFoundException("File " + value.string.toString() +
+                    " from drawable resource ID #0x" + Integer.toHexString(id));
+            rnf.initCause(e);
+            throw rnf;
         }
     }
 
@@ -1588,7 +1628,7 @@
                     InputStream is = mAssets.openNonAsset(
                             value.assetCookie, file, AssetManager.ACCESS_BUFFER);
     //                System.out.println("Opened file " + file + ": " + is);
-                    dr = Drawable.createFromStream(is, file);
+                    dr = Drawable.createFromResourceStream(this, value, is, file);
                     is.close();
     //                System.out.println("Created stream: " + dr);
                 } catch (Exception e) {
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index fa062c8..87bb277 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -25,6 +25,7 @@
 import android.text.TextUtils;
 import android.util.Config;
 import android.util.Log;
+import android.util.EventLog;
 
 import java.io.File;
 import java.util.HashMap;
@@ -51,7 +52,8 @@
  * is the Unicode Collation Algorithm and not tailored to the current locale.
  */
 public class SQLiteDatabase extends SQLiteClosable {
-    private final static String TAG = "Database";
+    private static final String TAG = "Database";
+    private static final int DB_OPERATION_EVENT = 52000;
 
     /**
      * Algorithms used in ON CONFLICT clause
@@ -207,6 +209,11 @@
     private WeakHashMap<SQLiteClosable, Object> mPrograms;
  
     private final RuntimeException mLeakedException;
+
+    // package visible, since callers will access directly to minimize overhead in the case
+    // that logging is not enabled.
+    /* package */ final boolean mLogStats;
+    
     /**
      * @param closable
      */
@@ -436,7 +443,14 @@
             if (mTransactionIsSuccessful) {
                 execSQL("COMMIT;");
             } else {
-                execSQL("ROLLBACK;");
+                try {
+                    execSQL("ROLLBACK;");
+                } catch (SQLException e) {
+                    if (Config.LOGD) {
+                        Log.d(TAG, "exception during rollback, maybe the DB previously "
+                                + "performed an auto-rollback");
+                    }
+                }
             }
         } finally {
             unlockForced();
@@ -1472,10 +1486,8 @@
      * @throws SQLException If the SQL string is invalid for some reason
      */
     public void execSQL(String sql) throws SQLException {
-        long timeStart = 0;
-        if (Config.LOGV) {
-            timeStart = System.currentTimeMillis();
-        }
+        boolean logStats = mLogStats;
+        long timeStart = logStats ? SystemClock.elapsedRealtime() : 0;
         lock();
         try {
             native_execSQL(sql);
@@ -1485,9 +1497,8 @@
         } finally {
             unlock();
         }
-        if (Config.LOGV) {
-            long timeEnd = System.currentTimeMillis();
-            Log.v(TAG, "Executed (" + (timeEnd - timeStart) + " ms):" + sql);
+        if (logStats) {
+            logTimeStat(false /* not a read */, timeStart, SystemClock.elapsedRealtime());
         }
     }
 
@@ -1504,10 +1515,9 @@
         if (bindArgs == null) {
             throw new IllegalArgumentException("Empty bindArgs");
         }
-        long timeStart = 0;
-        if (Config.LOGV) {
-            timeStart = System.currentTimeMillis();
-        }
+
+        boolean logStats = mLogStats;
+        long timeStart = logStats ? SystemClock.elapsedRealtime() : 0;
         lock();
         SQLiteStatement statement = null;
         try {
@@ -1528,9 +1538,8 @@
             }
             unlock();
         }
-        if (Config.LOGV) {
-            long timeEnd = System.currentTimeMillis();
-            Log.v(TAG, "Executed (" + (timeEnd - timeStart) + " ms):" + sql);
+        if (logStats) {
+            logTimeStat(false /* not a read */, timeStart, SystemClock.elapsedRealtime());
         }
     }
 
@@ -1550,7 +1559,7 @@
     }
 
     /**
-     * Private constructor. See {@link createDatabase} and {@link openDatabase}.
+     * Private constructor. See {@link #create} and {@link #openDatabase}.
      *
      * @param path The full path to the database
      * @param factory The factory to use when creating cursors, may be NULL.
@@ -1563,6 +1572,8 @@
         }
         mFlags = flags;
         mPath = path;
+        mLogStats = "1".equals(android.os.SystemProperties.get("db.logstats"));
+        
         mLeakedException = new IllegalStateException(path +
             " SQLiteDatabase created and never closed");
         mFactory = factory;
@@ -1605,6 +1616,10 @@
         return mPath;
     }
 
+    /* package */ void logTimeStat(boolean read, long begin, long end) {
+        EventLog.writeEvent(DB_OPERATION_EVENT, mPath, read ? 0 : 1, end - begin);
+    }
+
     /**
      * Sets the locale for this database.  Does nothing if this database has
      * the NO_LOCALIZED_COLLATORS flag set or was opened read only.
@@ -1629,7 +1644,7 @@
     private native void dbopen(String path, int flags);
 
     /**
-     * Native call to execute a raw SQL statement. {@link mLock} must be held
+     * Native call to execute a raw SQL statement. {@link #lock} must be held
      * when calling this method.
      *
      * @param sql The raw SQL string
@@ -1638,7 +1653,7 @@
     /* package */ native void native_execSQL(String sql) throws SQLException;
 
     /**
-     * Native call to set the locale.  {@link mLock} must be held when calling
+     * Native call to set the locale.  {@link #lock} must be held when calling
      * this method.
      * @throws SQLException
      */
diff --git a/core/java/android/database/sqlite/SQLiteOpenHelper.java b/core/java/android/database/sqlite/SQLiteOpenHelper.java
index 35bf645..52aac3a 100644
--- a/core/java/android/database/sqlite/SQLiteOpenHelper.java
+++ b/core/java/android/database/sqlite/SQLiteOpenHelper.java
@@ -26,6 +26,8 @@
  * optionally {@link #onOpen}, and this class takes care of opening the database
  * if it exists, creating it if it does not, and upgrading it as necessary.
  * Transactions are used to make sure the database is always in a sensible state.
+ * <p>For an example, see the NotePadProvider class in the NotePad sample application,
+ * in the <em>samples/</em> directory of the SDK.</p>
  */
 public abstract class SQLiteOpenHelper {
     private static final String TAG = SQLiteOpenHelper.class.getSimpleName();
diff --git a/core/java/android/database/sqlite/SQLiteQuery.java b/core/java/android/database/sqlite/SQLiteQuery.java
index 22c53ab..5bfa0e8 100644
--- a/core/java/android/database/sqlite/SQLiteQuery.java
+++ b/core/java/android/database/sqlite/SQLiteQuery.java
@@ -17,6 +17,7 @@
 package android.database.sqlite;
 
 import android.database.CursorWindow;
+import android.os.SystemClock;
 
 /**
  * A SQLite program that represents a query that reads the resulting rows into a CursorWindow.
@@ -55,12 +56,14 @@
      * Reads rows into a buffer. This method acquires the database lock.
      * 
      * @param window The window to fill into
-     * @param startPos The position to start reading rows from
      * @return number of total rows in the query
      */
     /* package */ int fillWindow(CursorWindow window,  
             int maxRead, int lastPos) {
         mDatabase.lock();
+
+        boolean logStats = mDatabase.mLogStats;
+        long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
         try {
             acquireReference();
             try {
@@ -68,8 +71,13 @@
                 // if the start pos is not equal to 0, then most likely window is 
                 // too small for the data set, loading by another thread
                 // is not safe in this situation. the native code will ignore maxRead
-                return native_fill_window(window, window.getStartPosition(), mOffsetIndex, 
+                int numRows = native_fill_window(window, window.getStartPosition(), mOffsetIndex,
                         maxRead, lastPos);
+                if (logStats) {
+                    mDatabase.logTimeStat(true /* read */, startTime,
+                            SystemClock.elapsedRealtime());
+                }
+                return numRows;
             } catch (IllegalStateException e){
                 // simply ignore it
                 return 0;
diff --git a/core/java/android/database/sqlite/SQLiteStatement.java b/core/java/android/database/sqlite/SQLiteStatement.java
index bf9361d..d169259 100644
--- a/core/java/android/database/sqlite/SQLiteStatement.java
+++ b/core/java/android/database/sqlite/SQLiteStatement.java
@@ -16,6 +16,8 @@
 
 package android.database.sqlite;
 
+import android.os.SystemClock;
+
 /**
  * A pre-compiled statement against a {@link SQLiteDatabase} that can be reused.
  * The statement cannot return multiple rows, but 1x1 result sets are allowed.
@@ -43,10 +45,16 @@
      */
     public void execute() {
         mDatabase.lock();
+        boolean logStats = mDatabase.mLogStats;
+        long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
+
         acquireReference();
         try {
             native_execute();
-        } finally {
+            if (logStats) {
+                mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
+            }
+        } finally {                    
             releaseReference();
             mDatabase.unlock();
         }
@@ -64,9 +72,15 @@
      */
     public long executeInsert() {
         mDatabase.lock();
+        boolean logStats = mDatabase.mLogStats;
+        long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
+
         acquireReference();
         try {
             native_execute();
+            if (logStats) {
+                mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
+            }
             return mDatabase.lastInsertRow();
         } finally {
             releaseReference();
@@ -84,9 +98,16 @@
      */
     public long simpleQueryForLong() {
         mDatabase.lock();
+        boolean logStats = mDatabase.mLogStats;
+        long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
+
         acquireReference();
         try {
-            return native_1x1_long();
+            long retValue = native_1x1_long();
+            if (logStats) {
+                mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
+            }
+            return retValue;
         } finally {
             releaseReference();
             mDatabase.unlock();
@@ -103,9 +124,16 @@
      */
     public String simpleQueryForString() {
         mDatabase.lock();
+        boolean logStats = mDatabase.mLogStats;
+        long startTime = logStats ? SystemClock.elapsedRealtime() : 0;
+
         acquireReference();
         try {
-            return native_1x1_string();
+            String retValue = native_1x1_string();
+            if (logStats) {
+                mDatabase.logTimeStat(false /* write */, startTime, SystemClock.elapsedRealtime());
+            }
+            return retValue;
         } finally {
             releaseReference();
             mDatabase.unlock();
diff --git a/core/java/android/database/sqlite/package.html b/core/java/android/database/sqlite/package.html
index c03a8dc..ff0f9f5 100644
--- a/core/java/android/database/sqlite/package.html
+++ b/core/java/android/database/sqlite/package.html
@@ -6,7 +6,7 @@
 Applications use these classes to maange private databases. If creating a
 content provider, you will probably have to use these classes to create and
 manage your own database to store content. See <a
-href="{@docRoot}devel/data.html">Storing, Retrieving and Exposing Data</a> to learn
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> to learn
 the conventions for implementing a content provider. See the
 NotePadProvider class in the NotePad sample application in the SDK for an
 example of a content provider. Android ships with SQLite version 3.4.0
diff --git a/core/java/android/gadget/GadgetHost.java b/core/java/android/gadget/GadgetHost.java
index 418f2aa..9176d18 100644
--- a/core/java/android/gadget/GadgetHost.java
+++ b/core/java/android/gadget/GadgetHost.java
@@ -17,14 +17,67 @@
 package android.gadget;
 
 import android.content.Context;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.RemoteException;
+import android.os.ServiceManager;
 import android.widget.RemoteViews;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import com.android.internal.gadget.IGadgetHost;
+import com.android.internal.gadget.IGadgetService;
+
 /**
  * GadgetHost provides the interaction with the Gadget Service for apps,
  * like the home screen, that want to embed gadgets in their UI.
  */
 public class GadgetHost {
+
+    static final int HANDLE_UPDATE = 1;
+
+    static Object sServiceLock = new Object();
+    static IGadgetService sService;
+
+    Context mContext;
+    String mPackageName;
+
+    class Callbacks extends IGadgetHost.Stub {
+        public void updateGadget(int gadgetId, RemoteViews views) {
+            Message msg = mHandler.obtainMessage(HANDLE_UPDATE);
+            msg.arg1 = gadgetId;
+            msg.obj = views;
+            msg.sendToTarget();
+        }
+    }
+
+    Handler mHandler = new Handler() {
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case HANDLE_UPDATE: {
+                    updateGadgetView(msg.arg1, (RemoteViews)msg.obj);
+                    break;
+                }
+            }
+        }
+    };
+
+    int mHostId;
+    Callbacks mCallbacks = new Callbacks();
+    HashMap<Integer,GadgetHostView> mViews = new HashMap();
+
     public GadgetHost(Context context, int hostId) {
+        mContext = context;
+        mHostId = hostId;
+        synchronized (sServiceLock) {
+            if (sService == null) {
+                IBinder b = ServiceManager.getService(Context.GADGET_SERVICE);
+                sService = IGadgetService.Stub.asInterface(b);
+            }
+        }
     }
 
     /**
@@ -32,6 +85,23 @@
      * becomes visible, i.e. from onStart() in your Activity.
      */
     public void startListening() {
+        int[] updatedIds = null;
+        ArrayList<RemoteViews> updatedViews = new ArrayList();
+        
+        try {
+            if (mPackageName == null) {
+                mPackageName = mContext.getPackageName();
+            }
+            updatedIds = sService.startListening(mCallbacks, mPackageName, mHostId, updatedViews);
+        }
+        catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
+
+        final int N = updatedIds.length;
+        for (int i=0; i<N; i++) {
+            updateGadgetView(updatedIds[i], updatedViews.get(i));
+        }
     }
 
     /**
@@ -39,25 +109,93 @@
      * no longer visible, i.e. from onStop() in your Activity.
      */
     public void stopListening() {
+        try {
+            sService.stopListening(mHostId);
+        }
+        catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
     }
 
     /**
-     * Stop listening to changes for this gadget.
+     * Get a gadgetId for a host in the calling process.
+     *
+     * @return a gadgetId
      */
-    public void gadgetRemoved(int gadgetId) {
+    public int allocateGadgetId() {
+        try {
+            if (mPackageName == null) {
+                mPackageName = mContext.getPackageName();
+            }
+            return sService.allocateGadgetId(mPackageName, mHostId);
+        }
+        catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
     }
 
     /**
-     * Remove all records about gadget instances from the gadget manager.  Call this when
-     * initializing your database, as it might be because of a data wipe.
+     * Stop listening to changes for this gadget.  
      */
-    public void clearGadgets() {
+    public void deleteGadgetId(int gadgetId) {
+        synchronized (mViews) {
+            mViews.remove(gadgetId);
+            try {
+                sService.deleteGadgetId(gadgetId);
+            }
+            catch (RemoteException e) {
+                throw new RuntimeException("system server dead?", e);
+            }
+        }
+    }
+
+    /**
+     * Remove all records about this host from the gadget manager.
+     * <ul>
+     *   <li>Call this when initializing your database, as it might be because of a data wipe.</li>
+     *   <li>Call this to have the gadget manager release all resources associated with your
+     *   host.  Any future calls about this host will cause the records to be re-allocated.</li>
+     * </ul>
+     */
+    public void deleteHost() {
+        try {
+            sService.deleteHost(mHostId);
+        }
+        catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
+    }
+
+    /**
+     * Remove all records about all hosts for your package.
+     * <ul>
+     *   <li>Call this when initializing your database, as it might be because of a data wipe.</li>
+     *   <li>Call this to have the gadget manager release all resources associated with your
+     *   host.  Any future calls about this host will cause the records to be re-allocated.</li>
+     * </ul>
+     */
+    public static void deleteAllHosts() {
+        try {
+            sService.deleteAllHosts();
+        }
+        catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
     }
 
     public final GadgetHostView createView(Context context, int gadgetId, GadgetInfo gadget) {
         GadgetHostView view = onCreateView(context, gadgetId, gadget);
         view.setGadget(gadgetId, gadget);
-        view.updateGadget(null);
+        synchronized (mViews) {
+            mViews.put(gadgetId, view);
+        }
+        RemoteViews views = null;
+        try {
+            views = sService.getGadgetViews(gadgetId);
+        } catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
+        view.updateGadget(views);
         return view;
     }
 
@@ -68,5 +206,16 @@
     protected GadgetHostView onCreateView(Context context, int gadgetId, GadgetInfo gadget) {
         return new GadgetHostView(context);
     }
+
+    void updateGadgetView(int gadgetId, RemoteViews views) {
+        GadgetHostView v;
+        synchronized (mViews) {
+            v = mViews.get(gadgetId);
+        }
+        if (v != null) {
+            v.updateGadget(views);
+        }
+    }
 }
 
+
diff --git a/core/java/android/gadget/GadgetHostView.java b/core/java/android/gadget/GadgetHostView.java
index e2bef8c..d92c123 100644
--- a/core/java/android/gadget/GadgetHostView.java
+++ b/core/java/android/gadget/GadgetHostView.java
@@ -19,16 +19,21 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.gadget.GadgetInfo;
-import android.util.AttributeSet;
+import android.graphics.Color;
+import android.util.Config;
 import android.util.Log;
+import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.FrameLayout;
 import android.widget.RemoteViews;
 import android.widget.TextView;
+import android.widget.ViewAnimator;
 
-public class GadgetHostView extends FrameLayout {
+public class GadgetHostView extends ViewAnimator {
     static final String TAG = "GadgetHostView";
+    static final boolean LOGD = Config.LOGD || true;
 
     // When we're inflating the initialLayout for a gadget, we only allow
     // views that are allowed in RemoteViews.
@@ -40,63 +45,139 @@
 
     int mGadgetId;
     GadgetInfo mInfo;
-    View mContentView;
+    View mActiveView;
+    View mStaleView;
+    
+    protected int mDefaultGravity = Gravity.CENTER;
 
     public GadgetHostView(Context context) {
         super(context);
     }
 
     public void setGadget(int gadgetId, GadgetInfo info) {
+        if (LOGD) Log.d(TAG, "setGadget is incoming with info=" + info);
         if (mInfo != null) {
             // TODO: remove the old view, or whatever
         }
         mGadgetId = gadgetId;
         mInfo = info;
+        
+        View defaultView = getDefaultView();
+        flipUpdate(defaultView);
+    }
+    
+    /**
+     * Trigger actual animation between current and new content in the
+     * {@link ViewAnimator}.
+     */
+    protected void flipUpdate(View newContent) {
+        if (LOGD) Log.d(TAG, "pushing an update to surface");
+        
+        // Take requested dimensions from parent, but apply default gravity.
+        ViewGroup.LayoutParams requested = newContent.getLayoutParams();
+        if (requested == null) {
+            requested = new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
+                    LayoutParams.FILL_PARENT);
+        }
+        
+        FrameLayout.LayoutParams params =
+            new FrameLayout.LayoutParams(requested.width, requested.height);
+        params.gravity = mDefaultGravity;
+        newContent.setLayoutParams(params);
+        
+        // Add new content and animate to it
+        addView(newContent);
+        showNext();
+        
+        // Dispose old stale view
+        removeView(mStaleView);
+        mStaleView = mActiveView;
+        mActiveView = newContent;
     }
 
+    /**
+     * Process a set of {@link RemoteViews} coming in as an update from the
+     * gadget provider. Will animate into these new views as needed.
+     */
     public void updateGadget(RemoteViews remoteViews) {
-        Context context = getContext();
-
-        View contentView = null;
+        if (LOGD) Log.d(TAG, "updateGadget() with remoteViews = " + remoteViews);
+        
+        View newContent = null;
         Exception exception = null;
+        
         try {
             if (remoteViews == null) {
                 // there is no remoteViews (yet), so use the initial layout
-                Context theirContext = context.createPackageContext(mInfo.provider.getPackageName(),
-                        0);
-                LayoutInflater inflater = (LayoutInflater)theirContext.getSystemService(
-                        Context.LAYOUT_INFLATER_SERVICE);
-                inflater = inflater.cloneInContext(theirContext);
-                inflater.setFilter(sInflaterFilter);
-                contentView = inflater.inflate(mInfo.initialLayout, this, false);
+                newContent = getDefaultView();
             } else {
                 // use the RemoteViews
-                contentView = remoteViews.apply(mContext, this);
+                // TODO: try applying RemoteViews to existing staleView if available 
+                newContent = remoteViews.apply(mContext, this);
             }
-        }
-        catch (PackageManager.NameNotFoundException e) {
+        } catch (RuntimeException e) {
             exception = e;
         }
-        catch (RuntimeException e) {
-            exception = e;
-        }
-        if (contentView == null) {
+        
+        if (exception != null && LOGD) {
             Log.w(TAG, "Error inflating gadget " + mInfo, exception);
+        }
+        
+        if (newContent == null) {
             // TODO: Should we throw an exception here for the host activity to catch?
             // Maybe we should show a generic error widget.
-            TextView tv = new TextView(context);
-            tv.setText("Error inflating gadget");
-            contentView = tv;
+            if (LOGD) Log.d(TAG, "updateGadget couldn't find any view, so inflating error");
+            newContent = getErrorView();
         }
 
-        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
-                FrameLayout.LayoutParams.WRAP_CONTENT,
-                FrameLayout.LayoutParams.WRAP_CONTENT);
-
-        mContentView = contentView;
-        this.addView(contentView, lp);
-
-        // TODO: do an animation (maybe even one provided by the gadget).
+        flipUpdate(newContent);
+    }
+    
+    /**
+     * Inflate and return the default layout requested by gadget provider.
+     */
+    protected View getDefaultView() {
+        View defaultView = null;
+        Exception exception = null;
+        
+        try {
+            if (mInfo != null) {
+                Context theirContext = mContext.createPackageContext(
+                        mInfo.provider.getPackageName(), 0 /* no flags */);
+                LayoutInflater inflater = (LayoutInflater)
+                        theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+                inflater = inflater.cloneInContext(theirContext);
+                inflater.setFilter(sInflaterFilter);
+                defaultView = inflater.inflate(mInfo.initialLayout, this, false);
+            } else {
+                Log.w(TAG, "can't inflate defaultView because mInfo is missing");
+            }
+        } catch (PackageManager.NameNotFoundException e) {
+            exception = e;
+        } catch (RuntimeException e) {
+            exception = e;
+        }
+        
+        if (exception != null && LOGD) {
+            Log.w(TAG, "Error inflating gadget " + mInfo, exception);
+        }
+        
+        if (defaultView == null) {
+            if (LOGD) Log.d(TAG, "getDefaultView couldn't find any view, so inflating error");
+            defaultView = getErrorView();
+        }
+        
+        return defaultView;
+    }
+    
+    /**
+     * Inflate and return a view that represents an error state.
+     */
+    protected View getErrorView() {
+        TextView tv = new TextView(mContext);
+        // TODO: move this error string and background color into resources
+        tv.setText("Error inflating gadget");
+        tv.setBackgroundColor(Color.argb(127, 0, 0, 0));
+        return tv;
     }
 }
 
diff --git a/core/java/android/gadget/GadgetInfo.java b/core/java/android/gadget/GadgetInfo.java
index 1a7a9a0..5ac3da9 100644
--- a/core/java/android/gadget/GadgetInfo.java
+++ b/core/java/android/gadget/GadgetInfo.java
@@ -58,6 +58,16 @@
      */
     public ComponentName configure;
 
+    /**
+     * The label to display to the user.
+     */
+    public String label;
+
+    /**
+     * The icon to display for this gadget in the picker list.
+     */
+    public int icon;
+
     public GadgetInfo() {
     }
 
@@ -75,6 +85,8 @@
         if (0 != in.readInt()) {
             this.configure = new ComponentName(in);
         }
+        this.label = in.readString();
+        this.icon = in.readInt();
     }
 
 
@@ -95,6 +107,8 @@
         } else {
             out.writeInt(0);
         }
+        out.writeString(this.label);
+        out.writeInt(this.icon);
     }
 
     public int describeContents() {
diff --git a/core/java/android/gadget/GadgetManager.java b/core/java/android/gadget/GadgetManager.java
index 088dc86..20f4014 100644
--- a/core/java/android/gadget/GadgetManager.java
+++ b/core/java/android/gadget/GadgetManager.java
@@ -30,6 +30,10 @@
 import java.util.List;
 import java.util.WeakHashMap;
 
+/**
+ * Updates gadget state; gets information about installed gadget providers and other
+ * gadget related state.
+ */
 public class GadgetManager {
     static final String TAG = "GadgetManager";
 
@@ -40,9 +44,8 @@
      * The system will respond with an onActivityResult call with the following extras in
      * the intent:
      * <ul>
-     *   <li><b>gadgetId</b></li>
-     *   <li><b>gadgetId</b></li>
-     *   <li><b>gadgetId</b></li>
+     *   <li><b>gadgetIds</b></li>
+     *   <li><b>hostId</b></li>
      * </ul>
      * TODO: Add constants for these.
      * TODO: Where does this go?
@@ -50,21 +53,42 @@
     public static final String GADGET_PICK_ACTION = "android.gadget.action.PICK_GADGET";
 
     public static final String EXTRA_GADGET_ID = "gadgetId";
+    public static final String EXTRA_GADGET_IDS = "gadgetIds";
+    public static final String EXTRA_HOST_ID = "hostId";
 
     /**
      * Sent when it is time to update your gadget.
+     *
+     * <p>This may be sent in response to a new instance for this gadget provider having
+     * been instantiated, the requested {@link GadgetInfo#updatePeriodMillis update interval}
+     * having lapsed, or the system booting.
      */
     public static final String GADGET_UPDATE_ACTION = "android.gadget.action.GADGET_UPDATE";
 
     /**
-     * Sent when the gadget is added to a host for the first time. TODO: Maybe we don't want this.
+     * Sent when it is time to configure your gadget.  This action is not sent as a broadcast
+     * to the gadget provider, but as a startActivity to the activity specified in the
+     * {@link GadgetInfo GadgetInfo meta-data}.
+     *
+     * <p>The {@link #EXTRA_GADGET_ID} extra contains the gadget ID.
      */
-    public static final String GADGET_ENABLE_ACTION = "android.gadget.action.GADGET_ENABLE";
+    public static final String GADGET_CONFIGURE_ACTION = "android.gadget.action.GADGET_CONFIGURE";
 
     /**
-     * Sent when the gadget is removed from the last host. TODO: Maybe we don't want this.
+     * Sent when the gadget is added to a host for the first time.  This broadcast is sent at
+     * boot time if there is a gadget host installed with an instance for this provider.
      */
-    public static final String GADGET_DISABLE_ACTION = "android.gadget.action.GADGET_DISABLE";
+    public static final String GADGET_ENABLED_ACTION = "android.gadget.action.GADGET_ENABLED";
+
+    /**
+     * Sent when an instances of a gadget is deleted from the host.
+     */
+    public static final String GADGET_DELETED_ACTION = "android.gadget.action.GADGET_DELETED";
+
+    /**
+     * Sent when the gadget is removed from the last host.
+     */
+    public static final String GADGET_DISABLED_ACTION = "android.gadget.action.GADGET_DISABLED";
 
     /**
      * Field for the manifest meta-data tag.
@@ -106,10 +130,36 @@
      * <p>
      * This method will only work when called from the uid that owns the gadget provider.
      *
-     * @param gadgetId      The gadget instance for which to set the RemoteViews.
+     * @param gadgetIds     The gadget instances for which to set the RemoteViews.
      * @param views         The RemoteViews object to show.
      */
-    public void updateGadget(int gadgetId, RemoteViews views) {
+    public void updateGadget(int[] gadgetIds, RemoteViews views) {
+        try {
+            sService.updateGadgetIds(gadgetIds, views);
+        }
+        catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
+    }
+
+    /**
+     * Call this with the new RemoteViews for your gadget whenever you need to.
+     *
+     * <p>
+     * This method will only work when called from the uid that owns the gadget provider.
+     *
+     * @param provider      The {@link ComponentName} for the {@link
+     * android.content.BroadcastReceiver BroadcastReceiver} provider
+     *                      for your gadget.
+     * @param views         The RemoteViews object to show.
+     */
+    public void updateGadget(ComponentName provider, RemoteViews views) {
+        try {
+            sService.updateGadgetProvider(provider, views);
+        }
+        catch (RemoteException e) {
+            throw new RuntimeException("system server dead?", e);
+        }
     }
 
     /**
@@ -140,32 +190,6 @@
     }
 
     /**
-     * Get a gadgetId for a host in the calling process.
-     *
-     * @return a gadgetId
-     */
-    public int allocateGadgetId(String hostPackage) {
-        try {
-            return sService.allocateGadgetId(hostPackage);
-        }
-        catch (RemoteException e) {
-            throw new RuntimeException("system server dead?", e);
-        }
-    }
-
-    /**
-     * Delete the gadgetId.  Same as removeGadget on GadgetHost.
-     */
-    public void deleteGadgetId(int gadgetId) {
-        try {
-            sService.deleteGadgetId(gadgetId);
-        }
-        catch (RemoteException e) {
-            throw new RuntimeException("system server dead?", e);
-        }
-    }
-
-    /**
      * Set the component for a given gadgetId.  You need the GADGET_LIST permission.
      */
     public void bindGadgetId(int gadgetId, ComponentName provider) {
diff --git a/core/java/android/gadget/GadgetProvider.java b/core/java/android/gadget/GadgetProvider.java
new file mode 100755
index 0000000..1ddfe3f
--- /dev/null
+++ b/core/java/android/gadget/GadgetProvider.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.gadget;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+/**
+ * A conveience class to aid in implementing a gadget provider.
+ * Everything you can do with GadgetProvider, you can do with a regular {@link BroadcastReceiver}.
+ * GadgetProvider merely parses the relevant fields out of the Intent that is received in
+ * {@link #onReceive(Context,Intent) onReceive(Context,Intent)}, and calls hook methods
+ * with the received extras.
+ *
+ * <p>Extend this class and override one or more of the {@link #onUpdate}, {@link #onDeleted},
+ * {@link #onEnabled} or {@link #onDisabled} methods to implement your own gadget functionality.
+ *
+ * <h3>Sample Code</h3>
+ * For an example of how to write a gadget provider, see the
+ * <a href="{@toroot}reference/android/gadget/package-descr.html#providers">android.gadget
+ * package overview</a>.
+ */
+public class GadgetProvider extends BroadcastReceiver {
+    /**
+     * Constructor to initialize GadgetProvider.
+     */
+    public GadgetProvider() {
+    }
+
+    /**
+     * Implements {@link BroadcastReceiver#onReceive} to dispatch calls to the various
+     * other methods on GadgetProvider.  
+     *
+     * @param context The Context in which the receiver is running.
+     * @param intent The Intent being received.
+     */
+    // BEGIN_INCLUDE(onReceive)
+    public void onReceive(Context context, Intent intent) {
+        // Protect against rogue update broadcasts (not really a security issue,
+        // just filter bad broacasts out so subclasses are less likely to crash).
+        String action = intent.getAction();
+        if (GadgetManager.GADGET_UPDATE_ACTION.equals(action)) {
+            Bundle extras = intent.getExtras();
+            if (extras != null) {
+                int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS);
+                if (gadgetIds != null && gadgetIds.length > 0) {
+                    this.onUpdate(context, GadgetManager.getInstance(context), gadgetIds);
+                }
+            }
+        }
+        else if (GadgetManager.GADGET_DELETED_ACTION.equals(action)) {
+            Bundle extras = intent.getExtras();
+            if (extras != null) {
+                int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS);
+                if (gadgetIds != null && gadgetIds.length > 0) {
+                    this.onDeleted(context, gadgetIds);
+                }
+            }
+        }
+        else if (GadgetManager.GADGET_ENABLED_ACTION.equals(action)) {
+            this.onEnabled(context);
+        }
+        else if (GadgetManager.GADGET_DISABLED_ACTION.equals(action)) {
+            this.onDisabled(context);
+        }
+    }
+    // END_INCLUDE(onReceive)
+    
+    /**
+     * Called in response to the {@link GadgetManager#GADGET_UPDATE_ACTION} broadcast when
+     * this gadget provider is being asked to provide {@link android.widget.RemoteViews RemoteViews}
+     * for a set of gadgets.  Override this method to implement your own gadget functionality.
+     *
+     * {@more}
+     * <p class="note">If you want this method called, you must declare in an intent-filter in
+     * your AndroidManifest.xml file that you accept the GADGET_UPDATE_ACTION intent action.
+     * For example:
+     * <font color=red>TODO: SAMPLE CODE GOES HERE</font>
+     * </p>
+     * 
+     * @param context   The {@link android.content.Context Context} in which this receiver is
+     *                  running.
+     * @param gadgetManager A {@link GadgetManager} object you can call {@link
+     *                  GadgetManager#updateGadgets} on.
+     * @param gadgetIds The gadgetsIds for which an update is needed.  Note that this
+     *                  may be all of the gadget instances for this provider, or just
+     *                  a subset of them.
+     *
+     * @see GadgetManager#GADGET_UPDATE_ACTION
+     */
+    public void onUpdate(Context context, GadgetManager gadgetManager, int[] gadgetIds) {
+    }
+    
+    /**
+     * Called in response to the {@link GadgetManager#GADGET_DELETED_ACTION} broadcast when
+     * one or more gadget instances have been deleted.  Override this method to implement
+     * your own gadget functionality.
+     *
+     * {@more}
+     * <p class="note">If you want this method called, you must declare in an intent-filter in
+     * your AndroidManifest.xml file that you accept the GADGET_DELETED_ACTION intent action.
+     * For example:
+     * <font color=red>TODO: SAMPLE CODE GOES HERE</font>
+     * </p>
+     * 
+     * @param context   The {@link android.content.Context Context} in which this receiver is
+     *                  running.
+     * @param gadgetIds The gadgetsIds that have been deleted from their host.
+     *
+     * @see GadgetManager#GADGET_DELETED_ACTION
+     */
+    public void onDeleted(Context context, int[] gadgetIds) {
+    }
+
+    /**
+     * Called in response to the {@link GadgetManager#GADGET_ENABLED_ACTION} broadcast when
+     * the a gadget for this provider is instantiated.  Override this method to implement your
+     * own gadget functionality.
+     *
+     * {@more}
+     * When the last gadget for this provider is deleted,
+     * {@link GadgetManager#GADGET_DISABLED_ACTION} is sent and {@link #onDisabled}
+     * is called.  If after that, a gadget for this provider is created again, onEnabled() will
+     * be called again.
+     *
+     * <p class="note">If you want this method called, you must declare in an intent-filter in
+     * your AndroidManifest.xml file that you accept the GADGET_ENABLED_ACTION intent action.
+     * For example:
+     * <font color=red>TODO: SAMPLE CODE GOES HERE</font>
+     * </p>
+     * 
+     * @param context   The {@link android.content.Context Context} in which this receiver is
+     *                  running.
+     *
+     * @see GadgetManager#GADGET_ENABLED_ACTION
+     */
+    public void onEnabled(Context context) {
+    }
+
+    /**
+     * Called in response to the {@link GadgetManager#GADGET_DISABLED_ACTION} broadcast, which
+     * is sent when the last gadget instance for this provider is deleted.  Override this method
+     * to implement your own gadget functionality.
+     *
+     * {@more}
+     * <p class="note">If you want this method called, you must declare in an intent-filter in
+     * your AndroidManifest.xml file that you accept the GADGET_DISABLED_ACTION intent action.
+     * For example:
+     * <font color=red>TODO: SAMPLE CODE GOES HERE</font>
+     * </p>
+     * 
+     * @param context   The {@link android.content.Context Context} in which this receiver is
+     *                  running.
+     *
+     * @see GadgetManager#GADGET_DISABLED_ACTION
+     */
+    public void onDisabled(Context context) {
+    }
+}
diff --git a/core/java/android/gadget/package.html b/core/java/android/gadget/package.html
index 280ccfb..4b8b9d9 100644
--- a/core/java/android/gadget/package.html
+++ b/core/java/android/gadget/package.html
@@ -1,4 +1,51 @@
 <body>
-@hide
+{@hide}
+<p>Android allows applications to publish views to be embedded in other applications.  These
+views are called gadgets, and are published by "gadget providers."  The component that can
+contain gadgets is called a "gadget host."  See the links below for more information.
+</p>
+<h3><a href="{@toroot}reference/android/gadget/package-descr.html#providers">Gadget Providers</a></h3>
+<ul>
+  <li><a href="{@toroot}reference/android/gadget/package-descr.html#provider_manifest">Declaring a gadget in the AndroidManifest</a></li>
+  <li><a href="{@toroot}reference/android/gadget/package-descr.html#provider_meta_data">Adding the {@link android.gadget.GadgetInfo GadgetInfo} meta-data</a></li>
+  <li><a href="{@toroot}reference/android/gadget/package-descr.html#provider_GadgetProvider">Using the {@link android.gadget.GadgetProvider GadgetProvider} class</a></li>
+  <li><a href="{@toroot}reference/android/gadget/package-descr.html#provider_configuration">Gadget Configuration UI</a></li>
+  <li><a href="{@toroot}reference/android/gadget/package-descr.html#provider_broadcasts">Gadget Broadcast Intents</a></li>
+</ul>
+<h3><a href="{@toroot}reference/android/gadget/package-descr.html#">Gadget Hosts</a></h3>
+<ul>
+  <li><a href="{@toroot}reference/android/gadget/package-descr.html#">asdf</a></li>
+</ul>
+{@more}
+<h2><a name="providers"></a>Gadget Providers</h2>
+<p>Any application can publish gadgets.  All an application needs to do to publish a gadget is
+to have a {@link android.content.BroadcastReceiver} that receives the {@link
+android.gadget.GadgetManager#GADGET_UPDATE_ACTION GadgetManager.GADGET_UPDATE_ACTION} intent,
+and provide some meta-data about the gadget.
+
+<h3><a name="provider_manifest"></a>Declaring a gadget in the AndroidManifest</h3>
+
+<h3><a name="provider_meta_data"></a>Adding the {@link android.gadget.GadgetInfo GadgetInfo} meta-data</h3>
+
+<h3><a name="provider_GadgetProvider"></a>Using the {@link android.gadget.GadgetProvider GadgetProvider} class</h3>
+
+<h3><a name="provider_configuration"></a>Gadget Configuration UI</h3>
+
+<h3><a name="providers_broadcasts"></a>Gadget Broadcast Intents</h3>
+
+<p>{@link GadgetProvider} is just a convenience class.  If you would like to receive the
+gadget broadcasts directly, you can.  By way of example, the implementation of
+{@link GadgetProvider.onReceive} is quite simple:</p>
+
+{@sample frameworks/base/core/java/android/gadget/GadgetProvider.java onReceive}
+
+
+<h2>Gadget Hosts</h3>
+<p>Gadget hosts are the containers in which gadgets can be placed.  Most of the look and feel
+details are left up to the gadget hosts.  For example, the home screen has one way of viewing
+gadgets, but the lock screen could also contain gadgets, and it would have a different way of
+adding, removing and otherwise managing gadgets.</p>
+<p>For more information on implementing your own gadget host, see the
+{@link android.gadget.GadgetHost GadgetHost} class.</p>
 </body>
 
diff --git a/core/java/android/hardware/GeomagneticField.java b/core/java/android/hardware/GeomagneticField.java
new file mode 100644
index 0000000..b4c04b1
--- /dev/null
+++ b/core/java/android/hardware/GeomagneticField.java
@@ -0,0 +1,409 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware;
+
+import java.util.GregorianCalendar;
+
+/**
+ * This class is used to estimated estimate magnetic field at a given point on
+ * Earth, and in particular, to compute the magnetic declination from true
+ * north.
+ *
+ * <p>This uses the World Magnetic Model produced by the United States National
+ * Geospatial-Intelligence Agency.  More details about the model can be found at
+ * <a href="http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml">http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml</a>.
+ * This class currently uses WMM-2005 which is valid until 2010, but should
+ * produce acceptable results for several years after that.
+ */
+public class GeomagneticField {
+    // The magnetic field at a given point, in nonoteslas in geodetic
+    // coordinates.
+    private float mX;
+    private float mY;
+    private float mZ;
+
+    // Geocentric coordinates -- set by computeGeocentricCoordinates.
+    private float mGcLatitudeRad;
+    private float mGcLongitudeRad;
+    private float mGcRadiusKm;
+
+    // Constants from WGS84 (the coordinate system used by GPS)
+    static private final float EARTH_SEMI_MAJOR_AXIS_KM = 6378.137f;
+    static private final float EARTH_SEMI_MINOR_AXIS_KM = 6356.7523f;
+    static private final float EARTH_REFERENCE_RADIUS_KM = 6371.2f;
+
+    // These coefficients and the formulae used below are from:
+    // NOAA Technical Report: The US/UK World Magnetic Model for 2005-2010
+    static private final float[][] G_COEFF = new float[][] {
+        { 0f },
+        { -29556.8f, -1671.7f },
+        { -2340.6f, 3046.9f, 1657.0f },
+        { 1335.4f, -2305.1f, 1246.7f, 674.0f },
+        { 919.8f, 798.1f, 211.3f, -379.4f, 100.0f },
+        { -227.4f, 354.6f, 208.7f, -136.5f, -168.3f, -14.1f },
+        { 73.2f, 69.7f, 76.7f, -151.2f, -14.9f, 14.6f, -86.3f },
+        { 80.1f, -74.5f, -1.4f, 38.5f, 12.4f, 9.5f, 5.7f, 1.8f },
+        { 24.9f, 7.7f, -11.6f, -6.9f, -18.2f, 10.0f, 9.2f, -11.6f, -5.2f },
+        { 5.6f, 9.9f, 3.5f, -7.0f, 5.1f, -10.8f, -1.3f, 8.8f, -6.7f, -9.1f },
+        { -2.3f, -6.3f, 1.6f, -2.6f, 0.0f, 3.1f, 0.4f, 2.1f, 3.9f, -0.1f, -2.3f },
+        { 2.8f, -1.6f, -1.7f, 1.7f, -0.1f, 0.1f, -0.7f, 0.7f, 1.8f, 0.0f, 1.1f, 4.1f },
+        { -2.4f, -0.4f, 0.2f, 0.8f, -0.3f, 1.1f, -0.5f, 0.4f, -0.3f, -0.3f, -0.1f,
+          -0.3f, -0.1f } };
+
+    static private final float[][] H_COEFF = new float[][] {
+        { 0f },
+        { 0.0f, 5079.8f },
+        { 0.0f, -2594.7f, -516.7f },
+        { 0.0f, -199.9f, 269.3f, -524.2f },
+        { 0.0f, 281.5f, -226.0f, 145.8f, -304.7f },
+        { 0.0f, 42.4f, 179.8f, -123.0f, -19.5f, 103.6f },
+        { 0.0f, -20.3f, 54.7f, 63.6f, -63.4f, -0.1f, 50.4f },
+        { 0.0f, -61.5f, -22.4f, 7.2f, 25.4f, 11.0f, -26.4f, -5.1f },
+        { 0.0f, 11.2f, -21.0f, 9.6f, -19.8f, 16.1f, 7.7f, -12.9f, -0.2f },
+        { 0.0f, -20.1f, 12.9f, 12.6f, -6.7f, -8.1f, 8.0f, 2.9f, -7.9f, 6.0f },
+        { 0.0f, 2.4f, 0.2f, 4.4f, 4.8f, -6.5f, -1.1f, -3.4f, -0.8f, -2.3f, -7.9f },
+        { 0.0f, 0.3f, 1.2f, -0.8f, -2.5f, 0.9f, -0.6f, -2.7f, -0.9f, -1.3f, -2.0f, -1.2f },
+        { 0.0f, -0.4f, 0.3f, 2.4f, -2.6f, 0.6f, 0.3f, 0.0f, 0.0f, 0.3f, -0.9f, -0.4f,
+          0.8f } };
+
+    static private final float[][] DELTA_G = new float[][] {
+        { 0f },
+        { 8.0f, 10.6f },
+        { -15.1f, -7.8f, -0.8f },
+        { 0.4f, -2.6f, -1.2f, -6.5f },
+        { -2.5f, 2.8f, -7.0f, 6.2f, -3.8f },
+        { -2.8f, 0.7f, -3.2f, -1.1f, 0.1f, -0.8f },
+        { -0.7f, 0.4f, -0.3f, 2.3f, -2.1f, -0.6f, 1.4f },
+        { 0.2f, -0.1f, -0.3f, 1.1f, 0.6f, 0.5f, -0.4f, 0.6f },
+        { 0.1f, 0.3f, -0.4f, 0.3f, -0.3f, 0.2f, 0.4f, -0.7f, 0.4f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } };
+
+    static private final float[][] DELTA_H = new float[][] {
+        { 0f },
+        { 0.0f, -20.9f },
+        { 0.0f, -23.2f, -14.6f },
+        { 0.0f, 5.0f, -7.0f, -0.6f },
+        { 0.0f, 2.2f, 1.6f, 5.8f, 0.1f },
+        { 0.0f, 0.0f, 1.7f, 2.1f, 4.8f, -1.1f },
+        { 0.0f, -0.6f, -1.9f, -0.4f, -0.5f, -0.3f, 0.7f },
+        { 0.0f, 0.6f, 0.4f, 0.2f, 0.3f, -0.8f, -0.2f, 0.1f },
+        { 0.0f, -0.2f, 0.1f, 0.3f, 0.4f, 0.1f, -0.2f, 0.4f, 0.4f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+        { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } };
+
+    static private final long BASE_TIME =
+        new GregorianCalendar(2005, 1, 1).getTimeInMillis();
+
+    // The ratio between the Gauss-normalized associated Legendre functions and
+    // the Schmid quasi-normalized ones. Compute these once staticly since they
+    // don't depend on input variables at all.
+    static private final float[][] SCHMIDT_QUASI_NORM_FACTORS =
+        computeSchmidtQuasiNormFactors(G_COEFF.length);
+
+    /**
+     * Estimate the magnetic field at a given point and time.
+     *
+     * @param gdLatitudeDeg
+     *            Latitude in WGS84 geodetic coordinates -- positive is east.
+     * @param gdLongitudeDeg
+     *            Longitude in WGS84 geodetic coordinates -- positive is north.
+     * @param altitudeMeters
+     *            Altitude in WGS84 geodetic coordinates, in meters.
+     * @param timeMillis
+     *            Time at which to evaluate the declination, in milliseconds
+     *            since January 1, 1970. (approximate is fine -- the declination
+     *            changes very slowly).
+     */
+    public GeomagneticField(float gdLatitudeDeg,
+                            float gdLongitudeDeg,
+                            float altitudeMeters,
+                            long timeMillis) {
+        final int MAX_N = G_COEFF.length; // Maximum degree of the coefficients.
+
+        // We don't handle the north and south poles correctly -- pretend that
+        // we're not quite at them to avoid crashing.
+        gdLatitudeDeg = Math.min(90.0f - 1e-5f,
+                                 Math.max(-90.0f + 1e-5f, gdLatitudeDeg));
+        computeGeocentricCoordinates(gdLatitudeDeg,
+                                     gdLongitudeDeg,
+                                     altitudeMeters);
+
+        assert G_COEFF.length == H_COEFF.length;
+
+        // Note: LegendreTable computes associated Legendre functions for
+        // cos(theta).  We want the associated Legendre functions for
+        // sin(latitude), which is the same as cos(PI/2 - latitude), except the
+        // derivate will be negated.
+        LegendreTable legendre =
+            new LegendreTable(MAX_N - 1,
+                              (float) (Math.PI / 2.0 - mGcLatitudeRad));
+
+        // Compute a table of (EARTH_REFERENCE_RADIUS_KM / radius)^n for i in
+        // 0..MAX_N-2 (this is much faster than calling Math.pow MAX_N+1 times).
+        float[] relativeRadiusPower = new float[MAX_N + 2];
+        relativeRadiusPower[0] = 1.0f;
+        relativeRadiusPower[1] = EARTH_REFERENCE_RADIUS_KM / mGcRadiusKm;
+        for (int i = 2; i < relativeRadiusPower.length; ++i) {
+            relativeRadiusPower[i] = relativeRadiusPower[i - 1] *
+                relativeRadiusPower[1];
+        }
+
+        // Compute tables of sin(lon * m) and cos(lon * m) for m = 0..MAX_N --
+        // this is much faster than calling Math.sin and Math.com MAX_N+1 times.
+        float[] sinMLon = new float[MAX_N];
+        float[] cosMLon = new float[MAX_N];
+        sinMLon[0] = 0.0f;
+        cosMLon[0] = 1.0f;
+        sinMLon[1] = (float) Math.sin(mGcLongitudeRad);
+        cosMLon[1] = (float) Math.cos(mGcLongitudeRad);
+
+        for (int m = 2; m < MAX_N; ++m) {
+            // Standard expansions for sin((m-x)*theta + x*theta) and
+            // cos((m-x)*theta + x*theta).
+            int x = m >> 1;
+            sinMLon[m] = sinMLon[m-x] * cosMLon[x] + cosMLon[m-x] * sinMLon[x];
+            cosMLon[m] = cosMLon[m-x] * cosMLon[x] - sinMLon[m-x] * sinMLon[x];
+        }
+
+        float inverseCosLatitude = 1.0f / (float) Math.cos(mGcLatitudeRad);
+        float yearsSinceBase =
+            (timeMillis - BASE_TIME) / (365f * 24f * 60f * 60f * 1000f);
+
+        // We now compute the magnetic field strength given the geocentric
+        // location. The magnetic field is the derivative of the potential
+        // function defined by the model. See NOAA Technical Report: The US/UK
+        // World Magnetic Model for 2005-2010 for the derivation.
+        float gcX = 0.0f;  // Geocentric northwards component.
+        float gcY = 0.0f;  // Geocentric eastwards component.
+        float gcZ = 0.0f;  // Geocentric downwards component.
+
+        for (int n = 1; n < MAX_N; n++) {
+            for (int m = 0; m <= n; m++) {
+                // Adjust the coefficients for the current date.
+                float g = G_COEFF[n][m] + yearsSinceBase * DELTA_G[n][m];
+                float h = H_COEFF[n][m] + yearsSinceBase * DELTA_H[n][m];
+
+                // Negative derivative with respect to latitude, divided by
+                // radius.  This looks like the negation of the version in the
+                // NOAA Techincal report because that report used
+                // P_n^m(sin(theta)) and we use P_n^m(cos(90 - theta)), so the
+                // derivative with respect to theta is negated.
+                gcX += relativeRadiusPower[n+2]
+                    * (g * cosMLon[m] + h * sinMLon[m])
+                    * legendre.mPDeriv[n][m]
+                    * SCHMIDT_QUASI_NORM_FACTORS[n][m];
+
+                // Negative derivative with respect to longitude, divided by
+                // radius.
+                gcY += relativeRadiusPower[n+2] * m
+                    * (g * sinMLon[m] - h * cosMLon[m])
+                    * legendre.mP[n][m]
+                    * SCHMIDT_QUASI_NORM_FACTORS[n][m]
+                    * inverseCosLatitude;
+
+                // Negative derivative with respect to radius.
+                gcZ -= (n + 1) * relativeRadiusPower[n+2]
+                    * (g * cosMLon[m] + h * sinMLon[m])
+                    * legendre.mP[n][m]
+                    * SCHMIDT_QUASI_NORM_FACTORS[n][m];
+            }
+        }
+
+        // Convert back to geodetic coordinates.  This is basically just a
+        // rotation around the Y-axis by the difference in latitudes between the
+        // geocentric frame and the geodetic frame.
+        double latDiffRad = Math.toRadians(gdLatitudeDeg) - mGcLatitudeRad;
+        mX = (float) (gcX * Math.cos(latDiffRad)
+                      + gcZ * Math.sin(latDiffRad));
+        mY = gcY;
+        mZ = (float) (- gcX * Math.sin(latDiffRad)
+                      + gcZ * Math.cos(latDiffRad));
+    }
+
+    /**
+     * @return The X (northward) component of the magnetic field in nanoteslas.
+     */
+    public float getX() {
+        return mX;
+    }
+
+    /**
+     * @return The Y (eastward) component of the magnetic field in nanoteslas.
+     */
+    public float getY() {
+        return mY;
+    }
+
+    /**
+     * @return The Z (downward) component of the magnetic field in nanoteslas.
+     */
+    public float getZ() {
+        return mZ;
+    }
+
+    /**
+     * @return The declination of the horizontal component of the magnetic
+     *         field from true north, in degrees (i.e. positive means the
+     *         magnetic field is rotated east that much from true north).
+     */
+    public float getDeclination() {
+        return (float) Math.toDegrees(Math.atan2(mY, mX));
+    }
+
+    /**
+     * @return The inclination of the magnetic field in degrees -- positive
+     *         means the magnetic field is rotated downwards.
+     */
+    public float getInclination() {
+        return (float) Math.toDegrees(Math.atan2(mZ,
+                                                 getHorizontalStrength()));
+    }
+
+    /**
+     * @return  Horizontal component of the field strength in nonoteslas.
+     */
+    public float getHorizontalStrength() {
+        return (float) Math.sqrt(mX * mX + mY * mY);
+    }
+
+    /**
+     * @return  Total field strength in nanoteslas.
+     */
+    public float getFieldStrength() {
+        return (float) Math.sqrt(mX * mX + mY * mY + mZ * mZ);
+    }
+
+    /**
+     * @param gdLatitudeDeg
+     *            Latitude in WGS84 geodetic coordinates.
+     * @param gdLongitudeDeg
+     *            Longitude in WGS84 geodetic coordinates.
+     * @param altitudeMeters
+     *            Altitude above sea level in WGS84 geodetic coordinates.
+     * @return Geocentric latitude (i.e. angle between closest point on the
+     *         equator and this point, at the center of the earth.
+     */
+    private void computeGeocentricCoordinates(float gdLatitudeDeg,
+                                              float gdLongitudeDeg,
+                                              float altitudeMeters) {
+        float altitudeKm = altitudeMeters / 1000.0f;
+        float a2 = EARTH_SEMI_MAJOR_AXIS_KM * EARTH_SEMI_MAJOR_AXIS_KM;
+        float b2 = EARTH_SEMI_MINOR_AXIS_KM * EARTH_SEMI_MINOR_AXIS_KM;
+        double gdLatRad = Math.toRadians(gdLatitudeDeg);
+        float clat = (float) Math.cos(gdLatRad);
+        float slat = (float) Math.sin(gdLatRad);
+        float tlat = slat / clat;
+        float latRad =
+            (float) Math.sqrt(a2 * clat * clat + b2 * slat * slat);
+
+        mGcLatitudeRad = (float) Math.atan(tlat * (latRad * altitudeKm + b2)
+                                           / (latRad * altitudeKm + a2));
+
+        mGcLongitudeRad = (float) Math.toRadians(gdLongitudeDeg);
+
+        float radSq = altitudeKm * altitudeKm
+            + 2 * altitudeKm * (float) Math.sqrt(a2 * clat * clat +
+                                                 b2 * slat * slat)
+            + (a2 * a2 * clat * clat + b2 * b2 * slat * slat)
+            / (a2 * clat * clat + b2 * slat * slat);
+        mGcRadiusKm = (float) Math.sqrt(radSq);
+    }
+
+
+    /**
+     * Utility class to compute a table of Gauss-normalized associated Legendre
+     * functions P_n^m(cos(theta))
+     */
+    static private class LegendreTable {
+        // These are the Gauss-normalized associated Legendre functions -- that
+        // is, they are normal Legendre functions multiplied by
+        // (n-m)!/(2n-1)!! (where (2n-1)!! = 1*3*5*...*2n-1)
+        public final float[][] mP;
+
+        // Derivative of mP, with respect to theta.
+        public final float[][] mPDeriv;
+
+        /**
+         * @param maxN
+         *            The maximum n- and m-values to support
+         * @param thetaRad
+         *            Returned functions will be Gauss-normalized
+         *            P_n^m(cos(thetaRad)), with thetaRad in radians.
+         */
+        public LegendreTable(int maxN, float thetaRad) {
+            // Compute the table of Gauss-normalized associated Legendre
+            // functions using standard recursion relations. Also compute the
+            // table of derivatives using the derivative of the recursion
+            // relations.
+            float cos = (float) Math.cos(thetaRad);
+            float sin = (float) Math.sin(thetaRad);
+
+            mP = new float[maxN + 1][];
+            mPDeriv = new float[maxN + 1][];
+            mP[0] = new float[] { 1.0f };
+            mPDeriv[0] = new float[] { 0.0f };
+            for (int n = 1; n <= maxN; n++) {
+            	mP[n] = new float[n + 1];
+                mPDeriv[n] = new float[n + 1];
+                for (int m = 0; m <= n; m++) {
+                    if (n == m) {
+                        mP[n][m] = sin * mP[n - 1][m - 1];
+                        mPDeriv[n][m] = cos * mP[n - 1][m - 1]
+                            + sin * mPDeriv[n - 1][m - 1];
+                    } else if (n == 1 || m == n - 1) {
+                        mP[n][m] = cos * mP[n - 1][m];
+                        mPDeriv[n][m] = -sin * mP[n - 1][m]
+                            + cos * mPDeriv[n - 1][m];
+                    } else {
+                        assert n > 1 && m < n - 1;
+                        float k = ((n - 1) * (n - 1) - m * m)
+                            / (float) ((2 * n - 1) * (2 * n - 3));
+                        mP[n][m] = cos * mP[n - 1][m] - k * mP[n - 2][m];
+                        mPDeriv[n][m] = -sin * mP[n - 1][m]
+                            + cos * mPDeriv[n - 1][m] - k * mPDeriv[n - 2][m];
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Compute the ration between the Gauss-normalized associated Legendre
+     * functions and the Schmidt quasi-normalized version. This is equivalent to
+     * sqrt((m==0?1:2)*(n-m)!/(n+m!))*(2n-1)!!/(n-m)!
+     */
+    private static float[][] computeSchmidtQuasiNormFactors(int maxN) {
+        float[][] schmidtQuasiNorm = new float[maxN + 1][];
+        schmidtQuasiNorm[0] = new float[] { 1.0f };
+        for (int n = 1; n <= maxN; n++) {
+            schmidtQuasiNorm[n] = new float[n + 1];
+            schmidtQuasiNorm[n][0] =
+                schmidtQuasiNorm[n - 1][0] * (2 * n - 1) / (float) n;
+            for (int m = 1; m <= n; m++) {
+                schmidtQuasiNorm[n][m] = schmidtQuasiNorm[n][m - 1]
+                    * (float) Math.sqrt((n - m + 1) * (m == 1 ? 2 : 1)
+                                / (float) (n + m));
+            }
+        }
+        return schmidtQuasiNorm;
+    }
+}
\ No newline at end of file
diff --git a/core/java/android/hardware/ISensorService.aidl b/core/java/android/hardware/ISensorService.aidl
index 8aad9b4..04af2ae 100644
--- a/core/java/android/hardware/ISensorService.aidl
+++ b/core/java/android/hardware/ISensorService.aidl
@@ -25,5 +25,5 @@
 interface ISensorService
 {
     ParcelFileDescriptor getDataChanel();
-    boolean enableSensor(IBinder listener, int sensor, int enable);
+    boolean enableSensor(IBinder listener, String name, int sensor, int enable);
 }
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java
index f02094e..3981f27 100644
--- a/core/java/android/hardware/SensorManager.java
+++ b/core/java/android/hardware/SensorManager.java
@@ -741,7 +741,7 @@
      */
     @Deprecated
     public void unregisterListener(SensorListener listener) {
-        unregisterListener(listener, SENSOR_ALL);
+        unregisterListener(listener, SENSOR_ALL | SENSOR_ORIENTATION_RAW);
     }
 
     /**
@@ -829,9 +829,11 @@
                     }
                 }
 
+                String name = sensor.getName();
+                int handle = sensor.getHandle();
                 if (l == null) {
                     l = new ListenerDelegate(listener, sensor, handler);
-                    result = mSensorService.enableSensor(l, sensor.getHandle(), delay);
+                    result = mSensorService.enableSensor(l, name, handle, delay);
                     if (result) {
                         sListeners.add(l);
                         sListeners.notify();
@@ -840,7 +842,7 @@
                         sSensorThread.startLocked(mSensorService);
                     }
                 } else {
-                    result = mSensorService.enableSensor(l, sensor.getHandle(), delay);
+                    result = mSensorService.enableSensor(l, name, handle, delay);
                     if (result) {
                         l.addSensor(sensor);
                     }
@@ -861,8 +863,9 @@
                     ListenerDelegate l = sListeners.get(i);
                     if (l.getListener() == listener) {
                         // disable these sensors
+                        String name = sensor.getName();
                         int handle = sensor.getHandle();
-                        mSensorService.enableSensor(l, handle, SENSOR_DISABLE);
+                        mSensorService.enableSensor(l, name, handle, SENSOR_DISABLE);
                         // if we have no more sensors enabled on this listener,
                         // take it off the list.
                         if (l.removeSensor(sensor) == 0) {
@@ -886,7 +889,9 @@
                     if (l.getListener() == listener) {
                         // disable all sensors for this listener
                         for (Sensor sensor : l.getSensors()) {
-                            mSensorService.enableSensor(l, sensor.getHandle(), SENSOR_DISABLE);
+                            String name = sensor.getName();
+                            int handle = sensor.getHandle();
+                            mSensorService.enableSensor(l, name, handle, SENSOR_DISABLE);
                         }
                         sListeners.remove(i);
                         break;
diff --git a/core/java/android/inputmethodservice/AbstractInputMethodService.java b/core/java/android/inputmethodservice/AbstractInputMethodService.java
index 7d02f65..eedcc35 100644
--- a/core/java/android/inputmethodservice/AbstractInputMethodService.java
+++ b/core/java/android/inputmethodservice/AbstractInputMethodService.java
@@ -24,6 +24,9 @@
 import android.view.inputmethod.InputMethod;
 import android.view.inputmethod.InputMethodSession;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
 /**
  * AbstractInputMethodService provides a abstract base class for input methods.
  * Normal input method implementations will not derive from this directly,
@@ -156,6 +159,13 @@
      */
     public abstract AbstractInputMethodSessionImpl onCreateInputMethodSessionInterface();
     
+    /**
+     * Implement this to handle {@link android.os.Binder#dump Binder.dump()}
+     * calls on your input method.
+     */
+    protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
+    }
+
     @Override
     final public IBinder onBind(Intent intent) {
         if (mInputMethod == null) {
diff --git a/core/java/android/inputmethodservice/ExtractEditText.java b/core/java/android/inputmethodservice/ExtractEditText.java
index e59f38b..d9f10a9 100644
--- a/core/java/android/inputmethodservice/ExtractEditText.java
+++ b/core/java/android/inputmethodservice/ExtractEditText.java
@@ -2,6 +2,7 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.view.inputmethod.ExtractedText;
 import android.widget.EditText;
 
 /***
@@ -9,6 +10,9 @@
  * extracted text in a full-screen input method.
  */
 public class ExtractEditText extends EditText {
+    private InputMethodService mIME;
+    private int mSettingExtractedText;
+    
     public ExtractEditText(Context context) {
         super(context, null);
     }
@@ -20,4 +24,101 @@
     public ExtractEditText(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
     }
+    
+    void setIME(InputMethodService ime) {
+        mIME = ime;
+    }
+    
+    /**
+     * Start making changes that will not be reported to the client.  That
+     * is, {@link #onSelectionChanged(int, int)} will not result in sending
+     * the new selection to the client
+     */
+    public void startInternalChanges() {
+        mSettingExtractedText += 1;
+    }
+    
+    /**
+     * Finish making changes that will not be reported to the client.  That
+     * is, {@link #onSelectionChanged(int, int)} will not result in sending
+     * the new selection to the client
+     */
+    public void finishInternalChanges() {
+        mSettingExtractedText -= 1;
+    }
+    
+    /**
+     * Implement just to keep track of when we are setting text from the
+     * client (vs. seeing changes in ourself from the user).
+     */
+    @Override public void setExtractedText(ExtractedText text) {
+        try {
+            mSettingExtractedText++;
+            super.setExtractedText(text);
+        } finally {
+            mSettingExtractedText--;
+        }
+    }
+    
+    /**
+     * Report to the underlying text editor about selection changes.
+     */
+    @Override protected void onSelectionChanged(int selStart, int selEnd) {
+        if (mSettingExtractedText == 0 && mIME != null && selStart >= 0 && selEnd >= 0) {
+            mIME.onExtractedSelectionChanged(selStart, selEnd);
+        }
+    }
+    
+    /**
+     * Redirect clicks to the IME for handling there.  First allows any
+     * on click handler to run, though.
+     */
+    @Override public boolean performClick() {
+        if (!super.performClick() && mIME != null) {
+            mIME.onExtractedTextClicked();
+            return true;
+        }
+        return false;
+    }
+    
+    @Override public boolean onTextContextMenuItem(int id) {
+        if (mIME != null) {
+            if (mIME.onExtractTextContextMenuItem(id)) {
+                return true;
+            }
+        }
+        return super.onTextContextMenuItem(id);
+    }
+    
+    /**
+     * We are always considered to be an input method target.
+     */
+    public boolean isInputMethodTarget() {
+        return true;
+    }
+    
+    /**
+     * Pretend like the window this view is in always has focus, so its
+     * highlight and cursor will be displayed.
+     */
+    @Override public boolean hasWindowFocus() {
+        return true;
+    }
+
+    /**
+     * Pretend like this view always has focus, so its
+     * highlight and cursor will be displayed.
+     */
+    @Override public boolean isFocused() {
+        return true;
+    }
+
+    /**
+     * Pretend like this view always has focus, so its
+     * highlight and cursor will be displayed.
+     */
+    @Override public boolean hasFocus() {
+        return true;
+    }
+    
 }
diff --git a/core/java/android/inputmethodservice/IInputMethodWrapper.java b/core/java/android/inputmethodservice/IInputMethodWrapper.java
index 9abc23b..a2c75b5 100644
--- a/core/java/android/inputmethodservice/IInputMethodWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodWrapper.java
@@ -8,6 +8,8 @@
 import com.android.internal.view.InputConnectionWrapper;
 
 import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Binder;
 import android.os.IBinder;
 import android.os.Message;
 import android.os.RemoteException;
@@ -18,6 +20,11 @@
 import android.view.inputmethod.InputMethod;
 import android.view.inputmethod.InputMethodSession;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 /**
  * Implements the internal IInputMethod interface to convert incoming calls
  * on to it back to calls on the public InputMethod interface, scheduling
@@ -28,6 +35,7 @@
     private static final String TAG = "InputMethodWrapper";
     private static final boolean DEBUG = false;
     
+    private static final int DO_DUMP = 1;
     private static final int DO_ATTACH_TOKEN = 10;
     private static final int DO_SET_INPUT_CONTEXT = 20;
     private static final int DO_UNSET_INPUT_CONTEXT = 30;
@@ -39,9 +47,14 @@
     private static final int DO_SHOW_SOFT_INPUT = 60;
     private static final int DO_HIDE_SOFT_INPUT = 70;
    
+    final AbstractInputMethodService mTarget;
     final HandlerCaller mCaller;
     final InputMethod mInputMethod;
     
+    static class Notifier {
+        boolean notified;
+    }
+    
     // NOTE: we should have a cache of these.
     static class InputMethodSessionCallbackWrapper implements InputMethod.SessionCallback {
         final Context mContext;
@@ -64,7 +77,9 @@
         }
     }
     
-    public IInputMethodWrapper(Context context, InputMethod inputMethod) {
+    public IInputMethodWrapper(AbstractInputMethodService context,
+            InputMethod inputMethod) {
+        mTarget = context;
         mCaller = new HandlerCaller(context, this);
         mInputMethod = inputMethod;
     }
@@ -75,6 +90,20 @@
 
     public void executeMessage(Message msg) {
         switch (msg.what) {
+            case DO_DUMP: {
+                HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
+                try {
+                    mTarget.dump((FileDescriptor)args.arg1,
+                            (PrintWriter)args.arg2, (String[])args.arg3);
+                } catch (RuntimeException e) {
+                    ((PrintWriter)args.arg2).println("Exception: " + e);
+                }
+                synchronized (args.arg4) {
+                    ((CountDownLatch)args.arg4).countDown();
+                }
+                return;
+            }
+            
             case DO_ATTACH_TOKEN: {
                 mInputMethod.attachToken((IBinder)msg.obj);
                 return;
@@ -86,12 +115,22 @@
             case DO_UNSET_INPUT_CONTEXT:
                 mInputMethod.unbindInput();
                 return;
-            case DO_START_INPUT:
-                mInputMethod.startInput((EditorInfo)msg.obj);
+            case DO_START_INPUT: {
+                HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
+                IInputContext inputContext = (IInputContext)args.arg1;
+                InputConnection ic = inputContext != null
+                        ? new InputConnectionWrapper(inputContext) : null;
+                mInputMethod.startInput(ic, (EditorInfo)args.arg2);
                 return;
-            case DO_RESTART_INPUT:
-                mInputMethod.restartInput((EditorInfo)msg.obj);
+            }
+            case DO_RESTART_INPUT: {
+                HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
+                IInputContext inputContext = (IInputContext)args.arg1;
+                InputConnection ic = inputContext != null
+                        ? new InputConnectionWrapper(inputContext) : null;
+                mInputMethod.restartInput(ic, (EditorInfo)args.arg2);
                 return;
+            }
             case DO_CREATE_SESSION: {
                 mInputMethod.createSession(new InputMethodSessionCallbackWrapper(
                         mCaller.mContext, (IInputMethodCallback)msg.obj));
@@ -105,8 +144,7 @@
                 mInputMethod.revokeSession((InputMethodSession)msg.obj);
                 return;
             case DO_SHOW_SOFT_INPUT:
-                mInputMethod.showSoftInput(
-                        msg.arg1 != 0 ? InputMethod.SHOW_EXPLICIT : 0);
+                mInputMethod.showSoftInput(msg.arg1);
                 return;
             case DO_HIDE_SOFT_INPUT:
                 mInputMethod.hideSoftInput();
@@ -115,6 +153,28 @@
         Log.w(TAG, "Unhandled message code: " + msg.what);
     }
     
+    @Override protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
+        if (mTarget.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
+                != PackageManager.PERMISSION_GRANTED) {
+            
+            fout.println("Permission Denial: can't dump InputMethodManager from from pid="
+                    + Binder.getCallingPid()
+                    + ", uid=" + Binder.getCallingUid());
+            return;
+        }
+
+        CountDownLatch latch = new CountDownLatch(1);
+        mCaller.executeOrSendMessage(mCaller.obtainMessageOOOO(DO_DUMP,
+                fd, fout, args, latch));
+        try {
+            if (!latch.await(5, TimeUnit.SECONDS)) {
+                fout.println("Timeout waiting for dump");
+            }
+        } catch (InterruptedException e) {
+            fout.println("Interrupted waiting for dump");
+        }
+    }
+
     public void attachToken(IBinder token) {
         mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_ATTACH_TOKEN, token));
     }
@@ -130,12 +190,14 @@
         mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_UNSET_INPUT_CONTEXT));
     }
 
-    public void startInput(EditorInfo attribute) {
-        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_START_INPUT, attribute));
+    public void startInput(IInputContext inputContext, EditorInfo attribute) {
+        mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_START_INPUT,
+                inputContext, attribute));
     }
 
-    public void restartInput(EditorInfo attribute) {
-        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_RESTART_INPUT, attribute));
+    public void restartInput(IInputContext inputContext, EditorInfo attribute) {
+        mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_RESTART_INPUT,
+                inputContext, attribute));
     }
 
     public void createSession(IInputMethodCallback callback) {
@@ -163,9 +225,9 @@
         }
     }
     
-    public void showSoftInput(boolean explicit) {
+    public void showSoftInput(int flags) {
         mCaller.executeOrSendMessage(mCaller.obtainMessageI(DO_SHOW_SOFT_INPUT,
-                explicit ? 1 : 0));
+                flags));
     }
     
     public void hideSoftInput() {
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 3a9b26a..ea5f741 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -26,7 +26,13 @@
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.IBinder;
+import android.provider.Settings;
+import android.text.Layout;
+import android.text.Spannable;
+import android.text.method.MovementMethod;
 import android.util.Log;
+import android.util.PrintWriterPrinter;
+import android.util.Printer;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -45,12 +51,31 @@
 import android.view.inputmethod.EditorInfo;
 import android.widget.FrameLayout;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
 /**
  * InputMethodService provides a standard implementation of an InputMethod,
  * which final implementations can derive from and customize.  See the
  * base class {@link AbstractInputMethodService} and the {@link InputMethod}
  * interface for more information on the basics of writing input methods.
  * 
+ * <p>In addition to the normal Service lifecycle methods, this class
+ * introduces some new specific callbacks that most subclasses will want
+ * to make use of:</p>
+ * <ul>
+ * <li> {@link #onInitializeInterface()} for user-interface initialization,
+ * in particular to deal with configuration changes while the service is
+ * running.
+ * <li> {@link #onBindInput} to find out about switching to a new client.
+ * <li> {@link #onStartInput} to deal with an input session starting with
+ * the client.
+ * <li> {@link #onCreateInputView()}, {@link #onCreateCandidatesView()},
+ * and {@link #onCreateExtractTextView()} for non-demand generation of the UI.
+ * <li> {@link #onStartInputView(EditorInfo, boolean)} to deal with input
+ * starting within the input area of the IME.
+ * </ul>
+ * 
  * <p>An input method has significant discretion in how it goes about its
  * work: the {@link android.inputmethodservice.InputMethodService} provides
  * a basic framework for standard UI elements (input view, candidates view,
@@ -184,6 +209,7 @@
     LayoutInflater mInflater;
     View mRootView;
     SoftInputWindow mWindow;
+    boolean mInitialized;
     boolean mWindowCreated;
     boolean mWindowAdded;
     boolean mWindowVisible;
@@ -196,11 +222,16 @@
     InputBinding mInputBinding;
     InputConnection mInputConnection;
     boolean mInputStarted;
+    boolean mInputViewStarted;
+    boolean mCandidatesViewStarted;
+    InputConnection mStartedInputConnection;
     EditorInfo mInputEditorInfo;
     
     boolean mShowInputRequested;
     boolean mLastShowInputRequested;
-    boolean mShowCandidatesRequested;
+    int mCandidatesVisibility;
+    
+    boolean mShowInputForced;
     
     boolean mFullscreenApplied;
     boolean mIsFullscreen;
@@ -262,6 +293,7 @@
             mInputConnection = binding.getConnection();
             if (DEBUG) Log.v(TAG, "bindInput(): binding=" + binding
                     + " ic=" + mInputConnection);
+            initialize();
             onBindInput();
         }
 
@@ -277,14 +309,14 @@
             mInputConnection = null;
         }
 
-        public void startInput(EditorInfo attribute) {
+        public void startInput(InputConnection ic, EditorInfo attribute) {
             if (DEBUG) Log.v(TAG, "startInput(): editor=" + attribute);
-            doStartInput(attribute, false);
+            doStartInput(ic, attribute, false);
         }
 
-        public void restartInput(EditorInfo attribute) {
+        public void restartInput(InputConnection ic, EditorInfo attribute) {
             if (DEBUG) Log.v(TAG, "restartInput(): editor=" + attribute);
-            doStartInput(attribute, true);
+            doStartInput(ic, attribute, true);
         }
 
         /**
@@ -293,6 +325,7 @@
         public void hideSoftInput() {
             if (DEBUG) Log.v(TAG, "hideSoftInput()");
             mShowInputRequested = false;
+            mShowInputForced = false;
             hideWindow();
         }
 
@@ -316,8 +349,7 @@
                 return;
             }
             if (DEBUG) Log.v(TAG, "finishInput() in " + this);
-            onFinishInput();
-            mInputStarted = false;
+            doFinishInput();
         }
 
         /**
@@ -444,17 +476,37 @@
         mWindow.getWindow().setLayout(FILL_PARENT, WRAP_CONTENT);
     }
     
+    /**
+     * This is a hook that subclasses can use to perform initialization of
+     * their interface.  It is called for you prior to any of your UI objects
+     * being created, both after the service is first created and after a
+     * configuration change happens.
+     */
+    public void onInitializeInterface() {
+    }
+    
+    void initialize() {
+        if (!mInitialized) {
+            mInitialized = true;
+            onInitializeInterface();
+        }
+    }
+    
     void initViews() {
-        mWindowVisible = false;
+        mInitialized = false;
         mWindowCreated = false;
         mShowInputRequested = false;
-        mShowCandidatesRequested = false;
+        mShowInputForced = false;
         
         mRootView = mInflater.inflate(
                 com.android.internal.R.layout.input_method, null);
         mWindow.setContentView(mRootView);
         mRootView.getViewTreeObserver().addOnComputeInternalInsetsListener(mInsetsComputer);
-        
+        if (Settings.System.getInt(getContentResolver(),
+                Settings.System.FANCY_IME_ANIMATIONS, 0) != 0) {
+            mWindow.getWindow().setWindowAnimations(
+                    com.android.internal.R.style.Animation_InputMethodFancy);
+        }
         mExtractFrame = (FrameLayout)mRootView.findViewById(android.R.id.extractArea);
         mExtractView = null;
         mExtractEditText = null;
@@ -466,7 +518,8 @@
         mIsInputViewShown = false;
         
         mExtractFrame.setVisibility(View.GONE);
-        mCandidatesFrame.setVisibility(View.INVISIBLE);
+        mCandidatesVisibility = getCandidatesHiddenVisibility();
+        mCandidatesFrame.setVisibility(mCandidatesVisibility);
         mInputFrame.setVisibility(View.GONE);
     }
     
@@ -486,19 +539,36 @@
      * regenerating the input method UI as a result of the configuration
      * change, so you can rely on your {@link #onCreateInputView} and
      * other methods being called as appropriate due to a configuration change.
+     * 
+     * <p>When a configuration change does happen,
+     * {@link #onInitializeInterface()} is guaranteed to be called the next
+     * time prior to any of the other input or UI creation callbacks.  The
+     * following will be called immediately depending if appropriate for current 
+     * state: {@link #onStartInput} if input is active, and
+     * {@link #onCreateInputView} and {@link #onStartInputView} and related
+     * appropriate functions if the UI is displayed.
      */
     @Override public void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
         
         boolean visible = mWindowVisible;
         boolean showingInput = mShowInputRequested;
-        boolean showingCandidates = mShowCandidatesRequested;
+        boolean showingForced = mShowInputForced;
+        boolean showingCandidates = mCandidatesVisibility == View.VISIBLE;
         initViews();
+        mInputViewStarted = false;
+        mCandidatesViewStarted = false;
+        if (mInputStarted) {
+            doStartInput(getCurrentInputConnection(),
+                    getCurrentInputEditorInfo(), true);
+        }
         if (visible) {
-            if (showingCandidates) {
-                setCandidatesViewShown(true);
-            }
-            if (showingInput) {
+            if (showingForced) {
+                // If we are showing the full soft keyboard, then go through
+                // this path to take care of current decisions about fullscreen
+                // etc.
+                onShowRequested(InputMethod.SHOW_FORCED|InputMethod.SHOW_EXPLICIT);
+            } else if (showingInput) {
                 // If we are showing the full soft keyboard, then go through
                 // this path to take care of current decisions about fullscreen
                 // etc.
@@ -507,6 +577,9 @@
                 // Otherwise just put it back for its candidates.
                 showWindow(false);
             }
+            if (showingCandidates) {
+                setCandidatesViewShown(true);
+            }
         }
     }
 
@@ -568,6 +641,10 @@
      * the input method, or null if there is none.
      */
     public InputConnection getCurrentInputConnection() {
+        InputConnection ic = mStartedInputConnection;
+        if (ic != null) {
+            return ic;
+        }
         return mInputConnection;
     }
     
@@ -594,6 +671,7 @@
             changed = true;
             mIsFullscreen = isFullscreen;
             mFullscreenApplied = true;
+            initialize();
             Drawable bg = onCreateBackgroundDrawable();
             if (bg == null) {
                 // We need to give the window a real drawable, so that it
@@ -708,6 +786,7 @@
             mIsInputViewShown = isShown;
             mInputFrame.setVisibility(isShown ? View.VISIBLE : View.GONE);
             if (mInputView == null) {
+                initialize();
                 View v = onCreateInputView();
                 if (v != null) {
                     setInputView(v);
@@ -717,12 +796,19 @@
     }
     
     /**
+     * Returns true if we have been asked to show our input view.
+     */
+    public boolean isShowInputRequested() {
+        return mShowInputRequested;
+    }
+    
+    /**
      * Return whether the soft input view is <em>currently</em> shown to the
      * user.  This is the state that was last determined and
      * applied by {@link #updateInputViewShown()}.
      */
     public boolean isInputViewShown() {
-        return mIsInputViewShown;
+        return mIsInputViewShown && mWindowVisible;
     }
     
     /**
@@ -744,9 +830,10 @@
      * it is hidden.
      */
     public void setCandidatesViewShown(boolean shown) {
-        if (mShowCandidatesRequested != shown) {
-            mCandidatesFrame.setVisibility(shown ? View.VISIBLE : View.INVISIBLE);
-            mShowCandidatesRequested = shown;
+        int vis = shown ? View.VISIBLE : getCandidatesHiddenVisibility();
+        if (mCandidatesVisibility != vis) {
+            mCandidatesFrame.setVisibility(vis);
+            mCandidatesVisibility = vis;
         }
         if (!mShowInputRequested && mWindowVisible != shown) {
             // If we are being asked to show the candidates view while the app
@@ -760,10 +847,24 @@
         }
     }
     
+    /**
+     * Returns the visibility mode (either {@link View#INVISIBLE View.INVISIBLE}
+     * or {@link View#GONE View.GONE}) of the candidates view when it is not
+     * shown.  The default implementation returns GONE when in fullscreen mode,
+     * otherwise VISIBLE.  Be careful if you change this to return GONE in
+     * other situations -- if showing or hiding the candidates view causes
+     * your window to resize, this can cause temporary drawing artifacts as
+     * the resize takes place.
+     */
+    public int getCandidatesHiddenVisibility() {
+        return isFullscreenMode() ? View.GONE : View.INVISIBLE;
+    }
+    
     public void setStatusIcon(int iconResId) {
         mStatusIcon = iconResId;
-        if (mInputConnection != null && mWindowVisible) {
-            mInputConnection.showStatusIcon(getPackageName(), iconResId);
+        InputConnection ic = getCurrentInputConnection();
+        if (ic != null && mWindowVisible) {
+            ic.showStatusIcon(getPackageName(), iconResId);
         }
     }
     
@@ -783,11 +884,12 @@
         mExtractFrame.removeAllViews();
         mExtractFrame.addView(view, new FrameLayout.LayoutParams(
                 ViewGroup.LayoutParams.FILL_PARENT,
-                ViewGroup.LayoutParams.WRAP_CONTENT));
+                ViewGroup.LayoutParams.FILL_PARENT));
         mExtractView = view;
         if (view != null) {
             mExtractEditText = (ExtractEditText)view.findViewById(
                     com.android.internal.R.id.inputExtractEditText);
+            mExtractEditText.setIME(this);
             startExtractingText();
         } else {
             mExtractEditText = null;
@@ -890,6 +992,72 @@
     }
     
     /**
+     * Called when the input view is being hidden from the user.  This will
+     * be called either prior to hiding the window, or prior to switching to
+     * another target for editing.
+     * 
+     * <p>The default
+     * implementation uses the InputConnection to clear any active composing
+     * text; you can override this (not calling the base class implementation)
+     * to perform whatever behavior you would like.
+     * 
+     * @boolean finishingInput If true, {@link #onFinishInput} will be
+     * called immediately after.
+     */
+    public void onFinishInputView(boolean finishingInput) {
+        if (!finishingInput) {
+            InputConnection ic = getCurrentInputConnection();
+            if (ic != null) {
+                ic.finishComposingText();
+            }
+        }
+    }
+    
+    /**
+     * Called when only the candidates view has been shown for showing
+     * processing as the user enters text through a hard keyboard.
+     * This will always be called after {@link #onStartInput},
+     * allowing you to do your general setup there and just view-specific
+     * setup here.  You are guaranteed that {@link #onCreateCandidatesView()}
+     * will have been called some time before this function is called.
+     * 
+     * <p>Note that this will <em>not</em> be called when the input method
+     * is running in full editing mode, and thus receiving
+     * {@link #onStartInputView} to initiate that operation.  This is only
+     * for the case when candidates are being shown while the input method
+     * editor is hidden but wants to show its candidates UI as text is
+     * entered through some other mechanism.
+     * 
+     * @param info Description of the type of text being edited.
+     * @param restarting Set to true if we are restarting input on the
+     * same text field as before.
+     */
+    public void onStartCandidatesView(EditorInfo info, boolean restarting) {
+    }
+    
+    /**
+     * Called when the candidates view is being hidden from the user.  This will
+     * be called either prior to hiding the window, or prior to switching to
+     * another target for editing.
+     * 
+     * <p>The default
+     * implementation uses the InputConnection to clear any active composing
+     * text; you can override this (not calling the base class implementation)
+     * to perform whatever behavior you would like.
+     * 
+     * @boolean finishingInput If true, {@link #onFinishInput} will be
+     * called immediately after.
+     */
+    public void onFinishCandidatesView(boolean finishingInput) {
+        if (!finishingInput) {
+            InputConnection ic = getCurrentInputConnection();
+            if (ic != null) {
+                ic.finishComposingText();
+            }
+        }
+    }
+    
+    /**
      * The system has decided that it may be time to show your input method.
      * This is called due to a corresponding call to your
      * {@link InputMethod#showSoftInput(int) InputMethod.showSoftInput(int)}
@@ -905,10 +1073,22 @@
         if (!onEvaluateInputViewShown()) {
             return;
         }
-        if ((flags&InputMethod.SHOW_EXPLICIT) == 0 && onEvaluateFullscreenMode()) {
-            // Don't show if this is not explicit requested by the user and
-            // the input method is fullscreen.  That would be too disruptive.
-            return;
+        if ((flags&InputMethod.SHOW_EXPLICIT) == 0) {
+            if (onEvaluateFullscreenMode()) {
+                // Don't show if this is not explicitly requested by the user and
+                // the input method is fullscreen.  That would be too disruptive.
+                return;
+            }
+            Configuration config = getResources().getConfiguration();
+            if (config.keyboard != Configuration.KEYBOARD_NOKEYS) {
+                // And if the device has a hard keyboard, even if it is
+                // currently hidden, don't show the input method implicitly.
+                // These kinds of devices don't need it that much.
+                return;
+            }
+        }
+        if ((flags&InputMethod.SHOW_FORCED) != 0) {
+            mShowInputForced = true;
         }
         showWindow(true);
     }
@@ -922,6 +1102,7 @@
                 + " mInputStarted=" + mInputStarted);
         boolean doShowInput = false;
         boolean wasVisible = mWindowVisible;
+        boolean wasCreated = mWindowCreated;
         mWindowVisible = true;
         if (!mShowInputRequested) {
             if (mInputStarted) {
@@ -935,41 +1116,66 @@
         }
         
         if (DEBUG) Log.v(TAG, "showWindow: updating UI");
+        initialize();
         updateFullscreenMode();
         updateInputViewShown();
         
         if (!mWindowAdded || !mWindowCreated) {
             mWindowAdded = true;
             mWindowCreated = true;
+            initialize();
+            if (DEBUG) Log.v(TAG, "CALL: onCreateCandidatesView");
             View v = onCreateCandidatesView();
             if (DEBUG) Log.v(TAG, "showWindow: candidates=" + v);
             if (v != null) {
                 setCandidatesView(v);
             }
         }
-        if (doShowInput) {
-            if (mInputStarted) {
-                if (DEBUG) Log.v(TAG, "showWindow: starting input view");
+        if (mShowInputRequested) {
+            if (!mInputViewStarted) {
+                if (DEBUG) Log.v(TAG, "CALL: onStartInputView");
+                mInputViewStarted = true;
                 onStartInputView(mInputEditorInfo, false);
             }
+        } else if (!mCandidatesViewStarted) {
+            if (DEBUG) Log.v(TAG, "CALL: onStartCandidatesView");
+            mCandidatesViewStarted = true;
+            onStartCandidatesView(mInputEditorInfo, false);
+        }
+        
+        if (doShowInput) {
             startExtractingText();
         }
         
         if (!wasVisible) {
             if (DEBUG) Log.v(TAG, "showWindow: showing!");
             mWindow.show();
-            if (mInputConnection != null) {
-                mInputConnection.showStatusIcon(getPackageName(), mStatusIcon);
+        }
+        
+        if (!wasVisible || !wasCreated) {
+            InputConnection ic = getCurrentInputConnection();
+            if (ic != null) {
+                ic.showStatusIcon(getPackageName(), mStatusIcon);
             }
         }
     }
     
     public void hideWindow() {
+        if (mInputViewStarted) {
+            if (DEBUG) Log.v(TAG, "CALL: onFinishInputView");
+            onFinishInputView(false);
+        } else if (mCandidatesViewStarted) {
+            if (DEBUG) Log.v(TAG, "CALL: onFinishCandidatesView");
+            onFinishCandidatesView(false);
+        }
+        mInputViewStarted = false;
+        mCandidatesViewStarted = false;
         if (mWindowVisible) {
             mWindow.hide();
             mWindowVisible = false;
-            if (mInputConnection != null) {
-                mInputConnection.hideStatusIcon();
+            InputConnection ic = getCurrentInputConnection();
+            if (ic != null) {
+                ic.hideStatusIcon();
             }
         }
     }
@@ -1008,18 +1214,45 @@
     public void onStartInput(EditorInfo attribute, boolean restarting) {
     }
     
-    void doStartInput(EditorInfo attribute, boolean restarting) {
-        if (mInputStarted && !restarting) {
+    void doFinishInput() {
+        if (mInputViewStarted) {
+            if (DEBUG) Log.v(TAG, "CALL: onFinishInputView");
+            onFinishInputView(true);
+        } else if (mCandidatesViewStarted) {
+            if (DEBUG) Log.v(TAG, "CALL: onFinishCandidatesView");
+            onFinishCandidatesView(true);
+        }
+        mInputViewStarted = false;
+        mCandidatesViewStarted = false;
+        if (mInputStarted) {
+            if (DEBUG) Log.v(TAG, "CALL: onFinishInput");
             onFinishInput();
         }
+        mInputStarted = false;
+        mStartedInputConnection = null;
+    }
+    
+    void doStartInput(InputConnection ic, EditorInfo attribute, boolean restarting) {
+        if (!restarting) {
+            doFinishInput();
+        }
         mInputStarted = true;
+        mStartedInputConnection = ic;
         mInputEditorInfo = attribute;
+        initialize();
+        if (DEBUG) Log.v(TAG, "CALL: onStartInput");
         onStartInput(attribute, restarting);
         if (mWindowVisible) {
             if (mShowInputRequested) {
+                if (DEBUG) Log.v(TAG, "CALL: onStartInputView");
+                mInputViewStarted = true;
                 onStartInputView(mInputEditorInfo, restarting);
+                startExtractingText();
+            } else if (mCandidatesVisibility == View.VISIBLE) {
+                if (DEBUG) Log.v(TAG, "CALL: onStartCandidatesView");
+                mCandidatesViewStarted = true;
+                onStartCandidatesView(mInputEditorInfo, restarting);
             }
-            startExtractingText();
         }
     }
     
@@ -1029,8 +1262,17 @@
      * {@link #onStartInput(EditorInfo, boolean)} to perform input in a
      * new editor, or the input method may be left idle.  This method is
      * <em>not</em> called when input restarts in the same editor.
+     * 
+     * <p>The default
+     * implementation uses the InputConnection to clear any active composing
+     * text; you can override this (not calling the base class implementation)
+     * to perform whatever behavior you would like.
      */
     public void onFinishInput() {
+        InputConnection ic = getCurrentInputConnection();
+        if (ic != null) {
+            ic.finishComposingText();
+        }
     }
     
     /**
@@ -1073,9 +1315,12 @@
     public void onUpdateSelection(int oldSelStart, int oldSelEnd,
             int newSelStart, int newSelEnd,
             int candidatesStart, int candidatesEnd) {
-        if (mExtractEditText != null && mExtractedText != null) {
+        final ExtractEditText eet = mExtractEditText;
+        if (eet != null && mExtractedText != null) {
             final int off = mExtractedText.startOffset;
-            mExtractEditText.setSelection(newSelStart-off, newSelEnd-off);
+            eet.startInternalChanges();
+            eet.setSelection(newSelStart-off, newSelEnd-off);
+            eet.finishInternalChanges();
         }
     }
 
@@ -1100,6 +1345,18 @@
                 .hideSoftInputFromInputMethod(mToken, flags);
     }
     
+    /**
+     * Override this to intercept key down events before they are processed by the
+     * application.  If you return true, the application will not itself
+     * process the event.  If you return true, the normal application processing
+     * will occur as if the IME had not seen the event at all.
+     * 
+     * <p>The default implementation intercepts {@link KeyEvent#KEYCODE_BACK
+     * KeyEvent.KEYCODE_BACK} to hide the current IME UI if it is shown.  In
+     * additional, in fullscreen mode only, it will consume DPAD movement
+     * events to move the cursor in the extracted text view, not allowing
+     * them to perform navigation in the underlying application.
+     */
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         if (event.getKeyCode() == KeyEvent.KEYCODE_BACK
                 && event.getRepeatCount() == 0) {
@@ -1108,25 +1365,54 @@
                 // consume the back key.
                 dismissSoftInput(0);
                 return true;
-            }
-            if (mShowCandidatesRequested) {
-                // If the candidates are shown, we just want to make sure
-                // they are now hidden but otherwise let the app execute
-                // the back.
-                // XXX this needs better interaction with the soft input
-                // implementation.
-                //setCandidatesViewShown(false);
+            } else if (mWindowVisible) {
+                if (mCandidatesVisibility == View.VISIBLE) {
+                    // If we are showing candidates even if no input area, then
+                    // hide them.
+                    setCandidatesViewShown(false);
+                    return true;
+                } else {
+                    // If we have the window visible for some other reason --
+                    // most likely to show candidates -- then just get rid
+                    // of it.  This really shouldn't happen, but just in case...
+                    hideWindow();
+                    return true;
+                }
             }
         }
-        return false;
+        
+        return doMovementKey(keyCode, event, MOVEMENT_DOWN);
     }
 
+    /**
+     * Override this to intercept special key multiple events before they are
+     * processed by the
+     * application.  If you return true, the application will not itself
+     * process the event.  If you return true, the normal application processing
+     * will occur as if the IME had not seen the event at all.
+     * 
+     * <p>The default implementation always returns false, except when
+     * in fullscreen mode, where it will consume DPAD movement
+     * events to move the cursor in the extracted text view, not allowing
+     * them to perform navigation in the underlying application.
+     */
     public boolean onKeyMultiple(int keyCode, int count, KeyEvent event) {
-        return false;
+        return doMovementKey(keyCode, event, count);
     }
 
+    /**
+     * Override this to intercept key up events before they are processed by the
+     * application.  If you return true, the application will not itself
+     * process the event.  If you return true, the normal application processing
+     * will occur as if the IME had not seen the event at all.
+     * 
+     * <p>The default implementation always returns false, except when
+     * in fullscreen mode, where it will consume DPAD movement
+     * events to move the cursor in the extracted text view, not allowing
+     * them to perform navigation in the underlying application.
+     */
     public boolean onKeyUp(int keyCode, KeyEvent event) {
-        return false;
+        return doMovementKey(keyCode, event, MOVEMENT_UP);
     }
 
     public boolean onTrackballEvent(MotionEvent event) {
@@ -1136,21 +1422,176 @@
     public void onAppPrivateCommand(String action, Bundle data) {
     }
     
+    static final int MOVEMENT_DOWN = -1;
+    static final int MOVEMENT_UP = -2;
+    
+    boolean doMovementKey(int keyCode, KeyEvent event, int count) {
+        final ExtractEditText eet = mExtractEditText;
+        if (isFullscreenMode() && isInputViewShown() && eet != null) {
+            // If we are in fullscreen mode, the cursor will move around
+            // the extract edit text, but should NOT cause focus to move
+            // to other fields.
+            MovementMethod movement = eet.getMovementMethod();
+            Layout layout = eet.getLayout();
+            if (movement != null && layout != null) {
+                // We want our own movement method to handle the key, so the
+                // cursor will properly move in our own word wrapping.
+                if (count == MOVEMENT_DOWN) {
+                    if (movement.onKeyDown(eet,
+                            (Spannable)eet.getText(), keyCode, event)) {
+                        return true;
+                    }
+                } else if (count == MOVEMENT_UP) {
+                    if (movement.onKeyUp(eet,
+                            (Spannable)eet.getText(), keyCode, event)) {
+                        return true;
+                    }
+                } else {
+                    KeyEvent down = new KeyEvent(event, KeyEvent.ACTION_DOWN);
+                    if (movement.onKeyDown(eet,
+                            (Spannable)eet.getText(), keyCode, down)) {
+                        KeyEvent up = new KeyEvent(event, KeyEvent.ACTION_UP);
+                        movement.onKeyUp(eet,
+                                (Spannable)eet.getText(), keyCode, up);
+                        while (--count > 0) {
+                            movement.onKeyDown(eet,
+                                    (Spannable)eet.getText(), keyCode, down);
+                            movement.onKeyUp(eet,
+                                    (Spannable)eet.getText(), keyCode, up);
+                        }
+                    }
+                }
+            }
+            // Regardless of whether the movement method handled the key,
+            // we never allow DPAD navigation to the application.
+            switch (keyCode) {
+                case KeyEvent.KEYCODE_DPAD_LEFT:
+                case KeyEvent.KEYCODE_DPAD_RIGHT:
+                case KeyEvent.KEYCODE_DPAD_UP:
+                case KeyEvent.KEYCODE_DPAD_DOWN:
+                    return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    /**
+     * This is called when the user has moved the cursor in the extracted
+     * text view, when running in fullsreen mode.  The default implementation
+     * performs the corresponding selection change on the underlying text
+     * editor.
+     */
+    public void onExtractedSelectionChanged(int start, int end) {
+        InputConnection conn = getCurrentInputConnection();
+        if (conn != null) {
+            conn.setSelection(start, end);
+        }
+    }
+    
+    /**
+     * This is called when the user has clicked on the extracted text view,
+     * when running in fullscreen mode.  The default implementation hides
+     * the candidates view when this happens.  Re-implement this to provide
+     * whatever behavior you want.
+     */
+    public void onExtractedTextClicked() {
+        setCandidatesViewShown(false);
+    }
+    
+    /**
+     * This is called when the user has selected a context menu item from the
+     * extracted text view, when running in fullscreen mode.  The default
+     * implementation sends this action to the current InputConnection's
+     * {@link InputConnection#performContextMenuAction(int)}, for it
+     * to be processed in underlying "real" editor.  Re-implement this to
+     * provide whatever behavior you want.
+     */
+    public boolean onExtractTextContextMenuItem(int id) {
+        InputConnection ic = getCurrentInputConnection();
+        if (ic != null) {
+            ic.performContextMenuAction(id);
+        }
+        return true;
+    }
+    
     void startExtractingText() {
-        if (mExtractEditText != null && getCurrentInputStarted()
+        final ExtractEditText eet = mExtractEditText;
+        if (eet != null && getCurrentInputStarted()
                 && isFullscreenMode()) {
             mExtractedToken++;
             ExtractedTextRequest req = new ExtractedTextRequest();
             req.token = mExtractedToken;
+            req.flags = InputConnection.GET_TEXT_WITH_STYLES;
             req.hintMaxLines = 10;
             req.hintMaxChars = 10000;
-            mExtractedText = mInputConnection.getExtractedText(req,
-                    InputConnection.EXTRACTED_TEXT_MONITOR);
-            if (mExtractedText != null) {
-                mExtractEditText.setExtractedText(mExtractedText);
+            mExtractedText = getCurrentInputConnection().getExtractedText(req,
+                    InputConnection.GET_EXTRACTED_TEXT_MONITOR);
+            try {
+                eet.startInternalChanges();
+                int inputType = getCurrentInputEditorInfo().inputType;
+                if ((inputType&EditorInfo.TYPE_MASK_CLASS)
+                        == EditorInfo.TYPE_CLASS_TEXT) {
+                    if ((inputType&EditorInfo.TYPE_TEXT_FLAG_IME_MULTI_LINE) != 0) {
+                        inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
+                    }
+                }
+                eet.setInputType(inputType);
+                eet.setHint(mInputEditorInfo.hintText);
+                if (mExtractedText != null) {
+                    eet.setExtractedText(mExtractedText);
+                }
+            } finally {
+                eet.finishInternalChanges();
             }
-            mExtractEditText.setInputType(getCurrentInputEditorInfo().inputType);
-            mExtractEditText.setHint(mInputEditorInfo.hintText);
         }
     }
+    
+    /**
+     * Performs a dump of the InputMethodService's internal state.  Override
+     * to add your own information to the dump.
+     */
+    @Override protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
+        final Printer p = new PrintWriterPrinter(fout);
+        p.println("Input method service state for " + this + ":");
+        p.println("  mWindowCreated=" + mWindowCreated
+                + " mWindowAdded=" + mWindowAdded
+                + " mWindowVisible=" + mWindowVisible);
+        p.println("  Configuration=" + getResources().getConfiguration());
+        p.println("  mToken=" + mToken);
+        p.println("  mInputBinding=" + mInputBinding);
+        p.println("  mInputConnection=" + mInputConnection);
+        p.println("  mStartedInputConnection=" + mStartedInputConnection);
+        p.println("  mInputStarted=" + mInputStarted
+                + " mInputViewStarted=" + mInputViewStarted
+                + " mCandidatesViewStarted=" + mCandidatesViewStarted);
+        
+        if (mInputEditorInfo != null) {
+            p.println("  mInputEditorInfo:");
+            mInputEditorInfo.dump(p, "    ");
+        } else {
+            p.println("  mInputEditorInfo: null");
+        }
+        
+        p.println("  mShowInputRequested=" + mShowInputRequested
+                + " mLastShowInputRequested=" + mLastShowInputRequested
+                + " mShowInputForced=" + mShowInputForced);
+        p.println("  mCandidatesVisibility=" + mCandidatesVisibility
+                + " mFullscreenApplied=" + mFullscreenApplied
+                + " mIsFullscreen=" + mIsFullscreen);
+        
+        if (mExtractedText != null) {
+            p.println("  mExtractedText:");
+            p.println("    text=" + mExtractedText.text.length() + " chars"
+                    + " startOffset=" + mExtractedText.startOffset);
+            p.println("    selectionStart=" + mExtractedText.selectionStart
+                    + " selectionEnd=" + mExtractedText.selectionEnd
+                    + " flags=0x" + Integer.toHexString(mExtractedText.flags));
+        } else {
+            p.println("  mExtractedText: null");
+        }
+        p.println("  mExtractedToken=" + mExtractedToken);
+        p.println("  mIsInputViewShown=" + mIsInputViewShown
+                + " mStatusIcon=" + mStatusIcon);
+    }
 }
diff --git a/core/java/android/inputmethodservice/Keyboard.java b/core/java/android/inputmethodservice/Keyboard.java
index cfd3188..228acbe 100755
--- a/core/java/android/inputmethodservice/Keyboard.java
+++ b/core/java/android/inputmethodservice/Keyboard.java
@@ -177,13 +177,13 @@
                     parent.mDisplayWidth, parent.mDefaultWidth);
             defaultHeight = getDimensionOrFraction(a, 
                     com.android.internal.R.styleable.Keyboard_keyHeight, 
-                    parent.mDisplayWidth, parent.mDefaultHeight);
-            defaultHorizontalGap = getDimensionOrFraction(a, 
+                    parent.mDisplayHeight, parent.mDefaultHeight);
+            defaultHorizontalGap = getDimensionOrFraction(a,
                     com.android.internal.R.styleable.Keyboard_horizontalGap, 
                     parent.mDisplayWidth, parent.mDefaultHorizontalGap);
             verticalGap = getDimensionOrFraction(a, 
                     com.android.internal.R.styleable.Keyboard_verticalGap, 
-                    parent.mDisplayWidth, parent.mDefaultVerticalGap);
+                    parent.mDisplayHeight, parent.mDefaultVerticalGap);
             a.recycle();
             a = res.obtainAttributes(Xml.asAttributeSet(parser),
                     com.android.internal.R.styleable.Keyboard_Row);
@@ -540,7 +540,6 @@
         row.defaultHorizontalGap = mDefaultHorizontalGap;
         row.verticalGap = mDefaultVerticalGap;
         row.rowEdgeFlags = EDGE_TOP | EDGE_BOTTOM;
-        
         final int maxColumns = columns == -1 ? Integer.MAX_VALUE : columns;
         for (int i = 0; i < characters.length(); i++) {
             char c = characters.charAt(i);
diff --git a/core/java/android/inputmethodservice/KeyboardView.java b/core/java/android/inputmethodservice/KeyboardView.java
index 2f3b54b..b2c74f2 100755
--- a/core/java/android/inputmethodservice/KeyboardView.java
+++ b/core/java/android/inputmethodservice/KeyboardView.java
@@ -149,6 +149,7 @@
     private int mMiniKeyboardOffsetY;
     private Map<Key,View> mMiniKeyboardCache;
     private int[] mWindowOffset;
+    private Key[] mKeys;
 
     /** Listener for {@link OnKeyboardActionListener}. */
     private OnKeyboardActionListener mKeyboardActionListener;
@@ -163,7 +164,7 @@
 
     private boolean mPreviewCentered = false;
     private boolean mShowPreview = true;
-    private boolean mShowTouchPoints = false;
+    private boolean mShowTouchPoints = true;
     private int mPopupPreviewX;
     private int mPopupPreviewY;
 
@@ -334,7 +335,7 @@
     }
 
     private void initGestureDetector() {
-        mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
+        mGestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
             @Override
             public boolean onFling(MotionEvent me1, MotionEvent me2, 
                     float velocityX, float velocityY) {
@@ -386,6 +387,8 @@
             showPreview(NOT_A_KEY);
         }
         mKeyboard = keyboard;
+        List<Key> keys = mKeyboard.getKeys();
+        mKeys = keys.toArray(new Key[keys.size()]);
         requestLayout();
         invalidate();
         computeProximityThreshold(keyboard);
@@ -521,16 +524,16 @@
      */
     private void computeProximityThreshold(Keyboard keyboard) {
         if (keyboard == null) return;
-        List<Key> keys = keyboard.getKeys();
+        final Key[] keys = mKeys;
         if (keys == null) return;
-        int length = keys.size();
+        int length = keys.length;
         int dimensionSum = 0;
         for (int i = 0; i < length; i++) {
-            Key key = keys.get(i);
-            dimensionSum += key.width + key.gap + key.height; 
+            Key key = keys[i];
+            dimensionSum += Math.min(key.width, key.height) + key.gap;
         }
         if (dimensionSum < 0 || length == 0) return;
-        mProximityThreshold = dimensionSum / (length * 2);
+        mProximityThreshold = (int) (dimensionSum * 1.5f / length);
         mProximityThreshold *= mProximityThreshold; // Square it
     }
     
@@ -545,7 +548,7 @@
         final Rect padding = mPadding;
         final int kbdPaddingLeft = mPaddingLeft;
         final int kbdPaddingTop = mPaddingTop;
-        final List<Key> keys = mKeyboard.getKeys();
+        final Key[] keys = mKeys;
         final Key invalidKey = mInvalidatedKey;
         //canvas.translate(0, mKeyboardPaddingTop);
         paint.setAlpha(255);
@@ -565,9 +568,9 @@
                 drawSingleKey = true;
             }
         }
-        final int keyCount = keys.size();
+        final int keyCount = keys.length;
         for (int i = 0; i < keyCount; i++) {
-            final Key key = keys.get(i);
+            final Key key = keys[i];
             if (drawSingleKey && invalidKey != key) {
                 continue;
             }
@@ -638,15 +641,15 @@
     }
 
     private int getKeyIndices(int x, int y, int[] allKeys) {
-        final List<Key> keys = mKeyboard.getKeys();
+        final Key[] keys = mKeys;
         final boolean shifted = mKeyboard.isShifted();
         int primaryIndex = NOT_A_KEY;
         int closestKey = NOT_A_KEY;
         int closestKeyDist = mProximityThreshold + 1;
         java.util.Arrays.fill(mDistances, Integer.MAX_VALUE);
-        final int keyCount = keys.size();
+        final int keyCount = keys.length;
         for (int i = 0; i < keyCount; i++) {
-            final Key key = keys.get(i);
+            final Key key = keys[i];
             int dist = 0;
             boolean isInside = key.isInside(x,y);
             if (((mProximityCorrectOn 
@@ -694,7 +697,7 @@
     private void detectAndSendKey(int x, int y, long eventTime) {
         int index = mCurrentKey;
         if (index != NOT_A_KEY) {
-            final Key key = mKeyboard.getKeys().get(index);
+            final Key key = mKeys[index];
             if (key.text != null) {
                 for (int i = 0; i < key.text.length(); i++) {
                     mKeyboardActionListener.onKey(key.text.charAt(i), key.codes);
@@ -743,14 +746,14 @@
         
         mCurrentKeyIndex = keyIndex;
         // Release the old key and press the new key
-        final List<Key> keys = mKeyboard.getKeys();
+        final Key[] keys = mKeys;
         if (oldKeyIndex != mCurrentKeyIndex) {
-            if (oldKeyIndex != NOT_A_KEY && keys.size() > oldKeyIndex) {
-                keys.get(oldKeyIndex).onReleased(mCurrentKeyIndex == NOT_A_KEY);
+            if (oldKeyIndex != NOT_A_KEY && keys.length > oldKeyIndex) {
+                keys[oldKeyIndex].onReleased(mCurrentKeyIndex == NOT_A_KEY);
                 invalidateKey(oldKeyIndex);
             }
-            if (mCurrentKeyIndex != NOT_A_KEY && keys.size() > mCurrentKeyIndex) {
-                keys.get(mCurrentKeyIndex).onPressed();
+            if (mCurrentKeyIndex != NOT_A_KEY && keys.length > mCurrentKeyIndex) {
+                keys[mCurrentKeyIndex].onPressed();
                 invalidateKey(mCurrentKeyIndex);
             }
         }
@@ -764,7 +767,7 @@
                 }
             }
             if (keyIndex != NOT_A_KEY) {
-                Key key = keys.get(keyIndex);
+                Key key = keys[keyIndex];
                 if (key.icon != null) {
                     mPreviewText.setCompoundDrawables(null, null, null, 
                             key.iconPreview != null ? key.iconPreview : key.icon);
@@ -774,8 +777,10 @@
                     mPreviewText.setText(getPreviewText(key));
                     if (key.label.length() > 1 && key.codes.length < 2) {
                         mPreviewText.setTextSize(mLabelTextSize);
+                        mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
                     } else {
                         mPreviewText.setTextSize(mPreviewTextSizeLarge);
+                        mPreviewText.setTypeface(Typeface.DEFAULT);
                     }
                 }
                 mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), 
@@ -788,8 +793,6 @@
                     lp.width = popupWidth;
                     lp.height = popupHeight;
                 }
-                previewPopup.setWidth(popupWidth);
-                previewPopup.setHeight(popupHeight);
                 if (!mPreviewCentered) {
                     mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
                     mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
@@ -809,25 +812,27 @@
                 mPreviewText.getBackground().setState(
                         key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
                 if (previewPopup.isShowing()) {
-                    previewPopup.update(mPopupParent, mPopupPreviewX + mOffsetInWindow[0],
+                    previewPopup.update(mPopupPreviewX + mOffsetInWindow[0],
                             mPopupPreviewY + mOffsetInWindow[1], 
                             popupWidth, popupHeight);
                 } else {
+                    previewPopup.setWidth(popupWidth);
+                    previewPopup.setHeight(popupHeight);
                     previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, 
                             mPopupPreviewX + mOffsetInWindow[0], 
                             mPopupPreviewY + mOffsetInWindow[1]);
                 }
-                mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SHOW_PREVIEW, keyIndex, 0), 
+                mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SHOW_PREVIEW, keyIndex, 0),
                         ViewConfiguration.getTapTimeout());
             }
         }
     }
 
     private void invalidateKey(int keyIndex) {
-        if (keyIndex < 0 || keyIndex >= mKeyboard.getKeys().size()) {
+        if (keyIndex < 0 || keyIndex >= mKeys.length) {
             return;
         }
-        final Key key = mKeyboard.getKeys().get(keyIndex);
+        final Key key = mKeys[keyIndex];
         mInvalidatedKey = key;
         invalidate(key.x + mPaddingLeft, key.y + mPaddingTop, 
                 key.x + key.width + mPaddingLeft, key.y + key.height + mPaddingTop);
@@ -838,11 +843,11 @@
         if (mPopupLayout == 0) {
             return false;
         }
-        if (mCurrentKey < 0 || mCurrentKey >= mKeyboard.getKeys().size()) {
+        if (mCurrentKey < 0 || mCurrentKey >= mKeys.length) {
             return false;
         }
 
-        Key popupKey = mKeyboard.getKeys().get(mCurrentKey);        
+        Key popupKey = mKeys[mCurrentKey];        
         boolean result = onLongPress(popupKey);
         if (result) {
             mAbortKey = true;
@@ -968,8 +973,8 @@
                 mLastMoveTime = mDownTime;
                 checkMultiTap(eventTime, keyIndex);
                 mKeyboardActionListener.onPress(keyIndex != NOT_A_KEY ? 
-                        mKeyboard.getKeys().get(keyIndex).codes[0] : 0);
-                if (mCurrentKey >= 0 && mKeyboard.getKeys().get(mCurrentKey).repeatable) {
+                        mKeys[keyIndex].codes[0] : 0);
+                if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) {
                     mRepeatKeyIndex = mCurrentKey;
                     repeatKey();
                     Message msg = mHandler.obtainMessage(MSG_REPEAT);
@@ -1054,7 +1059,7 @@
     }
 
     private boolean repeatKey() {
-        Key key = mKeyboard.getKeys().get(mRepeatKeyIndex);
+        Key key = mKeys[mRepeatKeyIndex];
         detectAndSendKey(key.x, key.y, mLastTapTime);
         return true;
     }
@@ -1113,7 +1118,7 @@
     
     private void checkMultiTap(long eventTime, int keyIndex) {
         if (keyIndex == NOT_A_KEY) return;
-        Key key = mKeyboard.getKeys().get(keyIndex);
+        Key key = mKeys[keyIndex];
         if (key.codes.length > 1) {
             mInMultiTap = true;
             if (eventTime < mLastTapTime + MULTITAP_INTERVAL
diff --git a/core/java/android/inputmethodservice/SoftInputWindow.java b/core/java/android/inputmethodservice/SoftInputWindow.java
index 9ff1665..da67c6d 100644
--- a/core/java/android/inputmethodservice/SoftInputWindow.java
+++ b/core/java/android/inputmethodservice/SoftInputWindow.java
@@ -18,6 +18,7 @@
 
 import android.app.Dialog;
 import android.content.Context;
+import android.content.pm.ActivityInfo;
 import android.os.IBinder;
 import android.view.Gravity;
 import android.view.WindowManager;
@@ -139,6 +140,8 @@
 
         lp.gravity = Gravity.BOTTOM;
         lp.width = -1;
+        // Let the input method window's orientation follow sensor based rotation
+        lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
 
         getWindow().setAttributes(lp);
         getWindow().setFlags(
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 213813a..1429bc1 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -16,6 +16,8 @@
 
 package android.net;
 
+import android.annotation.SdkConstant;
+import android.annotation.SdkConstant.SdkConstantType;
 import android.os.RemoteException;
 
 /**
@@ -100,6 +102,18 @@
      */
     public static final String EXTRA_EXTRA_INFO = "extraInfo";
 
+    /**
+     * Broadcast Action: The setting for background data usage has changed
+     * values. Use {@link #getBackgroundDataSetting()} to get the current value.
+     * <p>
+     * If an application uses the network in the background, it should listen
+     * for this broadcast and stop using the background data if the value is
+     * false.
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED =
+            "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED";
+
     public static final int TYPE_MOBILE = 0;
     public static final int TYPE_WIFI   = 1;
 
@@ -224,6 +238,43 @@
     }
 
     /**
+     * Returns the value of the setting for background data usage. If false,
+     * applications should not use the network if the application is not in the
+     * foreground. Developers should respect this setting, and check the value
+     * of this before performing any background data operations.
+     * <p>
+     * All applications that have background services that use the network
+     * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}.
+     * 
+     * @return Whether background data usage is allowed.
+     */
+    public boolean getBackgroundDataSetting() {
+        try {
+            return mService.getBackgroundDataSetting();
+        } catch (RemoteException e) {
+            // Err on the side of safety 
+            return false;
+        }
+    }
+
+    /**
+     * Sets the value of the setting for background data usage.
+     * 
+     * @param allowBackgroundData Whether an application should use data while
+     *            it is in the background.
+     *            
+     * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING
+     * @see #getBackgroundDataSetting()
+     * @hide
+     */
+    public void setBackgroundDataSetting(boolean allowBackgroundData) {
+        try {
+            mService.setBackgroundDataSetting(allowBackgroundData);
+        } catch (RemoteException e) {
+        }
+    }
+    
+    /**
      * Don't allow use of default constructor.
      */
     @SuppressWarnings({"UnusedDeclaration"})
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index e1d921f..de68598 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -44,4 +44,8 @@
     int stopUsingNetworkFeature(int networkType, in String feature);
 
     boolean requestRouteToHost(int networkType, int hostAddress);
+
+    boolean getBackgroundDataSetting();
+
+    void setBackgroundDataSetting(boolean allowBackgroundData);
 }
diff --git a/core/java/android/net/Uri.java b/core/java/android/net/Uri.java
index 32a26e4..c23df21 100644
--- a/core/java/android/net/Uri.java
+++ b/core/java/android/net/Uri.java
@@ -2235,12 +2235,13 @@
     }
 
     /**
-     * Creates a new Uri by encoding and appending a path segment to a base Uri.
+     * Creates a new Uri by appending an already-encoded path segment to a
+     * base Uri.
      *
      * @param baseUri Uri to append path segment to
-     * @param pathSegment to encode and append
-     * @return a new Uri based on baseUri with the given segment encoded and
-     * appended to the path
+     * @param pathSegment encoded path segment to append
+     * @return a new Uri based on baseUri with the given segment appended to 
+     *  the path
      * @throws NullPointerException if baseUri is null
      */
     public static Uri withAppendedPath(Uri baseUri, String pathSegment) {
diff --git a/core/java/android/net/http/AndroidHttpClient.java b/core/java/android/net/http/AndroidHttpClient.java
index 01442ae..4fb1499 100644
--- a/core/java/android/net/http/AndroidHttpClient.java
+++ b/core/java/android/net/http/AndroidHttpClient.java
@@ -26,7 +26,6 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.entity.AbstractHttpEntity;
 import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.client.CookieStore;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.ResponseHandler;
 import org.apache.http.client.ClientProtocolException;
@@ -56,7 +55,6 @@
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
 import java.net.URI;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import android.util.Log;
 import android.content.ContentResolver;
@@ -347,6 +345,13 @@
         }
 
         /**
+         * Returns true if auth logging is turned on for this configuration.
+         */
+        private boolean isAuthLoggable() {
+            return Log.isLoggable(tag + "-auth", level);
+        }
+
+        /**
          * Prints a message using this configuration.
          */
         private void println(String message) {
@@ -392,7 +397,8 @@
             if (configuration != null
                     && configuration.isLoggable()
                     && request instanceof HttpUriRequest) {
-                configuration.println(toCurl((HttpUriRequest) request));
+                configuration.println(toCurl((HttpUriRequest) request,
+                        configuration.isAuthLoggable()));
             }
         }
     }
@@ -400,12 +406,17 @@
     /**
      * Generates a cURL command equivalent to the given request.
      */
-    private static String toCurl(HttpUriRequest request) throws IOException {
+    private static String toCurl(HttpUriRequest request, boolean logAuthToken) throws IOException {
         StringBuilder builder = new StringBuilder();
 
         builder.append("curl ");
 
         for (Header header: request.getAllHeaders()) {
+            if (!logAuthToken
+                    && (header.getName().equals("Authorization") ||
+                        header.getName().equals("Cookie"))) {
+                continue;
+            }
             builder.append("--header \"");
             builder.append(header.toString().trim());
             builder.append("\" ");
diff --git a/core/java/android/net/http/RequestHandle.java b/core/java/android/net/http/RequestHandle.java
index 65e6117..c4ee5b0 100644
--- a/core/java/android/net/http/RequestHandle.java
+++ b/core/java/android/net/http/RequestHandle.java
@@ -55,7 +55,7 @@
     private final static String AUTHORIZATION_HEADER = "Authorization";
     private final static String PROXY_AUTHORIZATION_HEADER = "Proxy-Authorization";
 
-    private final static int MAX_REDIRECT_COUNT = 16;
+    public final static int MAX_REDIRECT_COUNT = 16;
 
     /**
      * Creates a new request session.
@@ -106,6 +106,14 @@
         return mRedirectCount >= MAX_REDIRECT_COUNT;
     }
 
+    public int getRedirectCount() {
+        return mRedirectCount;
+    }
+
+    public void setRedirectCount(int count) {
+        mRedirectCount = count;
+    }
+
     /**
      * Create and queue a redirect request.
      *
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index ed7c366..017b14d 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -15,19 +15,26 @@
 public abstract class BatteryStats {
 
     /**
-     * A constant indicating a partial wake lock.
+     * A constant indicating a partial wake lock timer.
      */
     public static final int WAKE_TYPE_PARTIAL = 0;
 
     /**
-     * A constant indicating a full wake lock.
+     * A constant indicating a full wake lock timer.
      */
     public static final int WAKE_TYPE_FULL = 1;
 
     /**
-     * A constant indicating a window wake lock.
+     * A constant indicating a window wake lock timer.
      */
     public static final int WAKE_TYPE_WINDOW = 2;
+    
+    /**
+     * A constant indicating a sensor timer.
+     * 
+     * {@hide}
+     */
+    public static final int SENSOR = 3;
 
     /**
      * Include all of the data in the stats, including previously saved data.
@@ -48,6 +55,21 @@
      * Include only the run since the last time the device was unplugged in the stats.
      */
     public static final int STATS_UNPLUGGED = 3;
+    
+    /**
+     * Bump the version on this if the checkin format changes.
+     */
+    private static final int BATTERY_STATS_CHECKIN_VERSION = 1;
+    
+    // TODO: Update this list if you add/change any stats above.
+    private static final String[] STAT_NAMES = { "total", "last", "current", "unplugged" };
+
+    private static final String APK_DATA = "apk";
+    private static final String PROCESS_DATA = "process";
+    private static final String SENSOR_DATA = "sensor";
+    private static final String WAKELOCK_DATA = "wakelock";
+    private static final String NETWORK_DATA = "network";
+    private static final String BATTERY_DATA = "battery";
 
     private final StringBuilder mFormatBuilder = new StringBuilder(8);
     private final Formatter mFormatter = new Formatter(mFormatBuilder);
@@ -115,8 +137,28 @@
          * @return a Map from Strings to Uid.Pkg objects.
          */
         public abstract Map<String, ? extends Pkg> getPackageStats();
+        
+        /**
+         * {@hide}
+         */
+        public abstract int getUid();
+        
+        /**
+         * {@hide}
+         */
+        public abstract long getTcpBytesReceived(int which);
+        
+        /**
+         * {@hide}
+         */
+        public abstract long getTcpBytesSent(int which);
 
         public static abstract class Sensor {
+            /**
+             * {@hide}
+             */
+            public abstract String getName();
+            
             public abstract Timer getSensorTime();
         }
 
@@ -200,6 +242,22 @@
      * Returns the number of times the device has been started.
      */
     public abstract int getStartCount();
+    
+    /**
+     * Returns the time in milliseconds that the screen has been on while the device was
+     * running on battery.
+     * 
+     * {@hide}
+     */
+    public abstract long getBatteryScreenOnTime();
+    
+    /**
+     * Returns the time in milliseconds that the screen has been on while the device was
+     * plugged in.
+     * 
+     * {@hide}
+     */
+    public abstract long getPluggedScreenOnTime();
 
     /**
      * Returns a SparseArray containing the statistics for each uid.
@@ -318,11 +376,14 @@
      * @param linePrefix a String to be prepended to each line of output.
      * @return the line prefix
      */
-    private final String printWakeLock(StringBuilder sb, Timer timer, long now,
+    private static final String printWakeLock(StringBuilder sb, Timer timer, long now,
         String name, int which, String linePrefix) {
+        
         if (timer != null) {
             // Convert from microseconds to milliseconds with rounding
-            long totalTimeMillis = (timer.getTotalTime(now, which) + 500) / 1000;
+            long totalTimeMicros = timer.getTotalTime(now, which);
+            long totalTimeMillis = (totalTimeMicros + 500) / 1000;
+            
             int count = timer.getCount(which);
             if (totalTimeMillis != 0) {
                 sb.append(linePrefix);
@@ -337,6 +398,184 @@
         }
         return linePrefix;
     }
+    
+    /**
+     * Checkin version of wakelock printer. Prints simple comma-separated list.
+     * 
+     * @param sb a StringBuilder object.
+     * @param timer a Timer object contining the wakelock times.
+     * @param now the current time in microseconds.
+     * @param name the name of the wakelock.
+     * @param which which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT.
+     * @param linePrefix a String to be prepended to each line of output.
+     * @return the line prefix
+     */
+    private static final String printWakeLockCheckin(StringBuilder sb, Timer timer, long now,
+        String name, int which, String linePrefix) {
+        long totalTimeMicros = 0;
+        int count = 0;
+        if (timer != null) {
+            totalTimeMicros = timer.getTotalTime(now, which);
+            count = timer.getCount(which); 
+        }
+        sb.append(linePrefix);
+        sb.append((totalTimeMicros + 500) / 1000); // microseconds to milliseconds with rounding
+        sb.append(',');
+        sb.append(name);
+        sb.append(',');
+        sb.append(count);
+        return ",";
+    }
+    
+    /**
+     * Dump a comma-separated line of values for terse checkin mode.
+     * 
+     * @param pw the PageWriter to dump log to
+     * @param category category of data (e.g. "total", "last", "unplugged", "current" )
+     * @param type type of data (e.g. "wakelock", "sensor", "process", "apk" ,  "process", "network")
+     * @param args type-dependent data arguments
+     */
+    private static final void dumpLine(PrintWriter pw, int uid, String category, String type, 
+           Object... args ) {
+        pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(',');
+        pw.print(uid); pw.print(',');
+        pw.print(category); pw.print(',');
+        pw.print(type); 
+        
+        for (Object arg : args) {  
+            pw.print(','); 
+            pw.print(arg); 
+        }
+        pw.print('\n');
+    }
+    
+    /**
+     * Checkin server version of dump to produce more compact, computer-readable log.
+     * 
+     * NOTE: all times are expressed in 'ms'.
+     * @param fd
+     * @param pw
+     * @param which
+     */
+    private final void dumpCheckinLocked(FileDescriptor fd, PrintWriter pw, int which) {
+        long uSecTime = SystemClock.elapsedRealtime() * 1000;
+        final long uSecNow = getBatteryUptime(uSecTime);
+       
+        StringBuilder sb = new StringBuilder(128);
+        long batteryUptime = computeBatteryUptime(uSecNow, which);
+        long batteryRealtime = computeBatteryRealtime(getBatteryRealtime(uSecTime), which);
+        long elapsedRealtime = computeRealtime(uSecTime, which);
+        long uptime = computeUptime(SystemClock.uptimeMillis() * 1000, which);
+        
+        String category = STAT_NAMES[which];
+        
+        // Dump "battery" stat
+        dumpLine(pw, 0 /* uid */, category, BATTERY_DATA, 
+                which == STATS_TOTAL ? getStartCount() : "N/A",
+                batteryUptime / 1000, 
+                formatRatioLocked(batteryUptime, elapsedRealtime),
+                batteryRealtime / 1000, 
+                formatRatioLocked(batteryRealtime, elapsedRealtime),
+                uptime / 1000,
+                elapsedRealtime / 1000); 
+        
+        SparseArray<? extends Uid> uidStats = getUidStats();
+        final int NU = uidStats.size();
+        for (int iu = 0; iu < NU; iu++) {
+            final int uid = uidStats.keyAt(iu);
+            Uid u = uidStats.valueAt(iu);
+            // Dump Network stats per uid, if any
+            long rx = u.getTcpBytesReceived(which);
+            long tx = u.getTcpBytesSent(which);
+            if (rx > 0 || tx > 0) dumpLine(pw, uid, category, NETWORK_DATA, rx, tx);
+
+            Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats();
+            if (wakelocks.size() > 0) {
+                for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> ent
+                        : wakelocks.entrySet()) {
+                    Uid.Wakelock wl = ent.getValue();
+                    String linePrefix = "";
+                    sb.setLength(0);
+                    linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_FULL), uSecNow,
+                            "full", which, linePrefix);
+                    linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_PARTIAL), uSecNow,
+                            "partial", which, linePrefix);
+                    linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_WINDOW), uSecNow,
+                            "window", which, linePrefix);
+                    
+                    // Only log if we had at lease one wakelock...
+                    if (sb.length() > 0) {
+                       dumpLine(pw, uid, category, WAKELOCK_DATA, ent.getKey(), sb.toString());
+                    }
+                }
+            }
+                
+            Map<Integer, ? extends BatteryStats.Uid.Sensor> sensors = u.getSensorStats();
+            if (sensors.size() > 0)  {
+                for (Map.Entry<Integer, ? extends BatteryStats.Uid.Sensor> ent
+                        : sensors.entrySet()) {
+                    Uid.Sensor se = ent.getValue();
+                    int sensorNumber = ent.getKey();
+                    Timer timer = se.getSensorTime();
+                    if (timer != null) {
+                        // Convert from microseconds to milliseconds with rounding
+                        long totalTime = (timer.getTotalTime(uSecNow, which) + 500) / 1000;
+                        int count = timer.getCount(which);
+                        if (totalTime != 0) {
+                            dumpLine(pw, uid, category, SENSOR_DATA, sensorNumber, totalTime, count);
+                        }
+                    } 
+                }
+            }
+
+            Map<String, ? extends BatteryStats.Uid.Proc> processStats = u.getProcessStats();
+            if (processStats.size() > 0) {
+                for (Map.Entry<String, ? extends BatteryStats.Uid.Proc> ent
+                        : processStats.entrySet()) {
+                    Uid.Proc ps = ent.getValue();
+    
+                    long userTime = ps.getUserTime(which);
+                    long systemTime = ps.getSystemTime(which);
+                    int starts = ps.getStarts(which);
+    
+                    if (userTime != 0 || systemTime != 0 || starts != 0) {
+                        dumpLine(pw, uid, category, PROCESS_DATA, 
+                                ent.getKey(), // proc
+                                userTime * 10, // cpu time in ms
+                                systemTime * 10, // user time in ms
+                                starts); // process starts
+                    }
+                }
+            }
+
+            Map<String, ? extends BatteryStats.Uid.Pkg> packageStats = u.getPackageStats();
+            if (packageStats.size() > 0) {
+                for (Map.Entry<String, ? extends BatteryStats.Uid.Pkg> ent
+                        : packageStats.entrySet()) {
+              
+                    Uid.Pkg ps = ent.getValue();
+                    int wakeups = ps.getWakeups(which);
+                    Map<String, ? extends  Uid.Pkg.Serv> serviceStats = ps.getServiceStats();
+                    for (Map.Entry<String, ? extends BatteryStats.Uid.Pkg.Serv> sent
+                            : serviceStats.entrySet()) {
+                        BatteryStats.Uid.Pkg.Serv ss = sent.getValue();
+                        long startTime = ss.getStartTime(uSecNow, which);
+                        int starts = ss.getStarts(which);
+                        int launches = ss.getLaunches(which);
+                        if (startTime != 0 || starts != 0 || launches != 0) {
+                            dumpLine(pw, uid, category, APK_DATA, 
+                                    wakeups, // wakeup alarms
+                                    ent.getKey(), // Apk
+                                    sent.getKey(), // service
+                                    startTime / 1000, // time spent started, in ms
+                                    starts,
+                                    launches);
+                        }
+                    }
+                }
+            }
+        }
+    }
 
     @SuppressWarnings("unused")
     private final void dumpLocked(FileDescriptor fd, PrintWriter pw, String prefix, int which) {
@@ -344,13 +583,22 @@
         final long uSecNow = getBatteryUptime(uSecTime);
 
         StringBuilder sb = new StringBuilder(128);
-        if (which == STATS_TOTAL) {
-            pw.println(prefix + "Current and Historic Battery Usage Statistics:");
-            pw.println(prefix + "  System starts: " + getStartCount());
-        } else if (which == STATS_LAST) {
-            pw.println(prefix + "Last Battery Usage Statistics:");
-        } else {
-            pw.println(prefix + "Current Battery Usage Statistics:");
+        switch (which) {
+            case STATS_TOTAL:
+                pw.println(prefix + "Current and Historic Battery Usage Statistics:");
+                pw.println(prefix + "  System starts: " + getStartCount());
+                break;
+            case STATS_LAST:
+                pw.println(prefix + "Last Battery Usage Statistics:");
+                break;
+            case STATS_UNPLUGGED:
+                pw.println(prefix + "Last Unplugged Battery Usage Statistics:");
+                break;
+            case STATS_CURRENT:
+                pw.println(prefix + "Current Battery Usage Statistics:");
+                break;
+            default:
+                throw new IllegalArgumentException("which = " + which);
         }
         long batteryUptime = computeBatteryUptime(uSecNow, which);
         long batteryRealtime = computeBatteryRealtime(getBatteryRealtime(uSecTime), which);
@@ -359,7 +607,7 @@
 
         pw.println(prefix
                 + "  On battery: " + formatTimeMs(batteryUptime / 1000) + "("
-                + formatRatioLocked(batteryUptime, batteryRealtime)
+                + formatRatioLocked(batteryUptime, elapsedRealtime)
                 + ") uptime, "
                 + formatTimeMs(batteryRealtime / 1000) + "("
                 + formatRatioLocked(batteryRealtime, elapsedRealtime)
@@ -380,6 +628,9 @@
             Uid u = uidStats.valueAt(iu);
             pw.println(prefix + "  #" + uid + ":");
             boolean uidActivity = false;
+            
+            pw.println(prefix + "    Network: " + u.getTcpBytesReceived(which) + " bytes received, "
+                    + u.getTcpBytesSent(which) + " bytes sent");
 
             Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats();
             if (wakelocks.size() > 0) {
@@ -512,12 +763,30 @@
      */
     @SuppressWarnings("unused")
     public void dumpLocked(FileDescriptor fd, PrintWriter pw, String[] args) {
+        boolean isCheckin = false;
+        if (args != null) {
+            for (String arg : args) {
+                if ("-c".equals(arg)) {
+                    isCheckin = true;
+                    break;
+                }
+            }
+        }
         synchronized (this) {
-            dumpLocked(fd, pw, "", STATS_TOTAL);
-            pw.println("");
-            dumpLocked(fd, pw, "", STATS_LAST);
-            pw.println("");
-            dumpLocked(fd, pw, "", STATS_CURRENT);
+            if (isCheckin) {
+                dumpCheckinLocked(fd, pw, STATS_TOTAL);
+                dumpCheckinLocked(fd, pw, STATS_LAST);
+                dumpCheckinLocked(fd, pw, STATS_UNPLUGGED);
+                dumpCheckinLocked(fd, pw, STATS_CURRENT);
+            } else {
+                dumpLocked(fd, pw, "", STATS_TOTAL);
+                pw.println("");
+                dumpLocked(fd, pw, "", STATS_LAST);
+                pw.println("");
+                dumpLocked(fd, pw, "", STATS_UNPLUGGED);
+                pw.println("");
+                dumpLocked(fd, pw, "", STATS_CURRENT);
+            }
         }
     }
 }
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 528e6bd..df10c6a 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -33,7 +33,7 @@
  * the standard support creating a local implementation of such an object.
  * 
  * <p>Most developers will not implement this class directly, instead using the
- * <a href="{@docRoot}reference/aidl.html">aidl</a> tool to describe the desired
+ * <a href="{@docRoot}guide/developing/tools/aidl.html">aidl</a> tool to describe the desired
  * interface, having it generate the appropriate Binder subclass.  You can,
  * however, derive directly from Binder to implement your own custom RPC
  * protocol or simply instantiate a raw Binder object directly to use as a
@@ -194,18 +194,15 @@
             return true;
         } else if (code == DUMP_TRANSACTION) {
             ParcelFileDescriptor fd = data.readFileDescriptor();
-            FileOutputStream fout = fd != null
-                    ? new FileOutputStream(fd.getFileDescriptor()) : null;
-            PrintWriter pw = fout != null ? new PrintWriter(fout) : null;
-            if (pw != null) {
-                String[] args = data.readStringArray();
-                dump(fd.getFileDescriptor(), pw, args);
-                pw.flush();
-            }
+            String[] args = data.readStringArray();
             if (fd != null) {
                 try {
-                    fd.close();
-                } catch (IOException e) {
+                    dump(fd.getFileDescriptor(), args);
+                } finally {
+                    try {
+                        fd.close();
+                    } catch (IOException e) {
+                    }
                 }
             }
             return true;
@@ -214,6 +211,20 @@
     }
 
     /**
+     * Implemented to call the more convenient version
+     * {@link #dump(FileDescriptor, PrintWriter, String[])}.
+     */
+    public void dump(FileDescriptor fd, String[] args) {
+        FileOutputStream fout = new FileOutputStream(fd);
+        PrintWriter pw = new PrintWriter(fout);
+        try {
+            dump(fd, pw, args);
+        } finally {
+            pw.flush();
+        }
+    }
+    
+    /**
      * Print the object's state into the given stream.
      * 
      * @param fd The raw file descriptor that the dump is being sent to.
@@ -302,6 +313,17 @@
             throws RemoteException;
     public native boolean unlinkToDeath(DeathRecipient recipient, int flags);
 
+    public void dump(FileDescriptor fd, String[] args) throws RemoteException {
+        Parcel data = Parcel.obtain();
+        data.writeFileDescriptor(fd);
+        data.writeStringArray(args);
+        try {
+            transact(DUMP_TRANSACTION, data, null, 0);
+        } finally {
+            data.recycle();
+        }
+    }
+    
     BinderProxy() {
         mSelf = new WeakReference(this);
     }
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index cdf907b..467c17f 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -26,6 +26,9 @@
     /** Either a changelist number, or a label like "M4-rc20". */
     public static final String ID = getString("ro.build.id");
 
+    /** A build ID string meant for displaying to the user */
+    public static final String DISPLAY = getString("ro.build.display.id");
+
     /** The name of the overall product. */
     public static final String PRODUCT = getString("ro.product.name");
 
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index 5f7f91f..950bb09 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -17,6 +17,7 @@
 package android.os;
 
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 
@@ -28,12 +29,13 @@
 import dalvik.system.VMDebug;
 
 
-/** Provides various debugging functions for Android applications, including
+/**
+ * Provides various debugging functions for Android applications, including
  * tracing and allocation counts.
  * <p><strong>Logging Trace Files</strong></p>
  * <p>Debug can create log files that give details about an application, such as
  * a call stack and start/stop times for any running methods. See <a
-href="{@docRoot}reference/traceview.html">Running the Traceview Debugging Program</a> for
+href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for
  * information about reading trace files. To start logging trace files, call one
  * of the startMethodTracing() methods. To stop tracing, call
  * {@link #stopMethodTracing()}.
@@ -285,7 +287,7 @@
 
     /**
      * Start method tracing with default log name and buffer size. See <a
-href="{@docRoot}reference/traceview.html">Running the Traceview Debugging Program</a> for
+href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for
      * information about reading these files. Call stopMethodTracing() to stop
      * tracing.
      */
@@ -297,7 +299,7 @@
      * Start method tracing, specifying the trace log file name.  The trace
      * file will be put under "/sdcard" unless an absolute path is given.
      * See <a
-       href="{@docRoot}reference/traceview.html">Running the Traceview Debugging Program</a> for
+       href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for
      * information about reading trace files.
      *
      * @param traceName Name for the trace log file to create.
@@ -313,7 +315,7 @@
      * Start method tracing, specifying the trace log file name and the
      * buffer size. The trace files will be put under "/sdcard" unless an
      * absolute path is given. See <a
-       href="{@docRoot}reference/traceview.html">Running the Traceview Debugging Program</a> for
+       href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for
      * information about reading trace files.
      * @param traceName    Name for the trace log file to create.
      * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace".
@@ -330,7 +332,7 @@
      * Start method tracing, specifying the trace log file name and the
      * buffer size. The trace files will be put under "/sdcard" unless an
      * absolute path is given. See <a
-       href="{@docRoot}reference/traceview.html">Running the Traceview Debugging Program</a> for
+       href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for
      * information about reading trace files.
      *
      * <p>
@@ -581,6 +583,18 @@
     }
 
     /**
+     * Dump "hprof" data to the specified file.  This will cause a GC.
+     *
+     * @param fileName Full pathname of output file (e.g. "/sdcard/dump.hprof").
+     * @throws UnsupportedOperationException if the VM was built without
+     *         HPROF support.
+     * @throws IOException if an error occurs while opening or writing files.
+     */
+    public static void dumpHprofData(String fileName) throws IOException {
+        VMDebug.dumpHprofData(fileName);
+    }
+
+    /**
      * Returns the number of sent transactions from this process.
      * @return The number of sent transactions or -1 if it could not read t.
      */
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index e37b551..f761e8e 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -75,6 +75,18 @@
     public static final String MEDIA_UNMOUNTED = "unmounted";
 
     /**
+     * getExternalStorageState() returns MEDIA_CHECKING if the media is present
+     * and being disk-checked
+     */
+    public static final String MEDIA_CHECKING = "checking";
+
+    /**
+     * getExternalStorageState() returns MEDIA_NOFS if the media is present
+     * but is blank or is using an unsupported filesystem
+     */
+    public static final String MEDIA_NOFS = "nofs";
+
+    /**
      * getExternalStorageState() returns MEDIA_MOUNTED if the media is present
      * and mounted at its mount point with read/write access. 
      */
diff --git a/core/java/android/os/IBinder.java b/core/java/android/os/IBinder.java
index 3ec0e9b..5c40c9a0 100644
--- a/core/java/android/os/IBinder.java
+++ b/core/java/android/os/IBinder.java
@@ -16,6 +16,9 @@
 
 package android.os;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
 /**
  * Base interface for a remotable object, the core part of a lightweight
  * remote procedure call mechanism designed for high performance when
@@ -145,6 +148,14 @@
     public IInterface queryLocalInterface(String descriptor);
     
     /**
+     * Print the object's state into the given stream.
+     * 
+     * @param fd The raw file descriptor that the dump is being sent to.
+     * @param args additional arguments to the dump request.
+     */
+    public void dump(FileDescriptor fd, String[] args) throws RemoteException;
+    
+    /**
      * Perform a generic operation with the object.
      * 
      * @param code The action to perform.  This should
diff --git a/core/java/android/os/ICheckinService.aidl b/core/java/android/os/ICheckinService.aidl
index 70ad28e..11becc4 100644
--- a/core/java/android/os/ICheckinService.aidl
+++ b/core/java/android/os/ICheckinService.aidl
@@ -26,6 +26,9 @@
  * {@hide}
  */
 interface ICheckinService {
+    /** Synchronously attempt a checkin with the server, return true on success. */
+    boolean checkin();
+
     /** Direct submission of crash data; returns after writing the crash. */
     void reportCrashSync(in byte[] crashData);
 
diff --git a/core/java/android/os/IMountService.aidl b/core/java/android/os/IMountService.aidl
index 0397446..88dae85 100644
--- a/core/java/android/os/IMountService.aidl
+++ b/core/java/android/os/IMountService.aidl
@@ -48,4 +48,19 @@
      * Safely unmount external storage at given mount point.
      */
     void unmountMedia(String mountPoint);
+
+    /**
+     * Format external storage given a mount point
+     */
+    void formatMedia(String mountPoint);
+
+    /**
+     * Returns true if media notification sounds are enabled.
+     */
+    boolean getPlayNotificationSounds();
+
+    /**
+     * Sets whether or not media notification sounds are played.
+     */
+    void setPlayNotificationSounds(boolean value);
 }
diff --git a/core/java/android/os/INetStatService.aidl b/core/java/android/os/INetStatService.aidl
index fb840d8..a8f3de0 100644
--- a/core/java/android/os/INetStatService.aidl
+++ b/core/java/android/os/INetStatService.aidl
@@ -17,14 +17,19 @@
 package android.os;
 
 /**
- * Retrieves packet and byte counts for the phone data interface.
+ * Retrieves packet and byte counts for the phone data interface,
+ * and for all interfaces.
  * Used for the data activity icon and the phone status in Settings.
  *
  * {@hide}
  */
 interface INetStatService {
-    int getTxPackets();
-    int getRxPackets();
-    int getTxBytes();
-    int getRxBytes();
+    long getMobileTxPackets();
+    long getMobileRxPackets();
+    long getMobileTxBytes();
+    long getMobileRxBytes();
+    long getTotalTxPackets();
+    long getTotalRxPackets();
+    long getTotalTxBytes();
+    long getTotalRxBytes();
 }
diff --git a/core/java/android/os/NetStat.java b/core/java/android/os/NetStat.java
index 7312236..733137a 100644
--- a/core/java/android/os/NetStat.java
+++ b/core/java/android/os/NetStat.java
@@ -16,36 +16,197 @@
 
 package android.os;
 
+import android.util.Log;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+
 /** @hide */
 public class NetStat{
 
     /**
-     * Get total number of tx packets sent through ppp0
+     * Get total number of tx packets sent through rmnet0 or ppp0
      *
-     * @return number of Tx packets through ppp0
+     * @return number of Tx packets through rmnet0 or ppp0
      */
-
-    public native static int netStatGetTxPkts();
+    public static long getMobileTxPkts() {
+        return getMobileStat("tx_packets");
+    }
 
     /**
-     *  Get total number of rx packets received through ppp0
+     *  Get total number of rx packets received through rmnet0 or ppp0
      *
-     * @return number of Rx packets through ppp0
+     * @return number of Rx packets through rmnet0 or ppp0
      */
-    public native static int netStatGetRxPkts();
+    public static long getMobileRxPkts() {
+        return getMobileStat("rx_packets");
+    }
 
       /**
-     *  Get total number of tx bytes received through ppp0
+     *  Get total number of tx bytes received through rmnet0 or ppp0
      *
-     * @return number of Tx bytes through ppp0
+     * @return number of Tx bytes through rmnet0 or ppp0
      */
-    public native static int netStatGetTxBytes();
+      public static long getMobileTxBytes() {
+          return getMobileStat("tx_bytes");
+      }
 
     /**
-     *  Get total number of rx bytes received through ppp0
+     *  Get total number of rx bytes received through rmnet0 or ppp0
      *
-     * @return number of Rx bytes through ppp0
+     * @return number of Rx bytes through rmnet0 or ppp0
      */
-    public native static int netStatGetRxBytes();
+    public static long getMobileRxBytes() {
+        return getMobileStat("rx_bytes");
+    }
 
+    /**
+     * Get the total number of packets sent through all network interfaces.
+     *
+     * @return the number of packets sent through all network interfaces
+     */
+    public static long getTotalTxPkts() {
+        return getTotalStat("tx_packets");
+    }
+
+    /**
+     * Get the total number of packets received through all network interfaces.
+     *
+     * @return the number of packets received through all network interfaces
+     */
+    public static long getTotalRxPkts() {
+        return getTotalStat("rx_packets");
+    }
+
+    /**
+     * Get the total number of bytes sent through all network interfaces.
+     *
+     * @return the number of bytes sent through all network interfaces
+     */
+    public static long getTotalTxBytes() {
+        return getTotalStat("tx_bytes");
+    }
+
+    /**
+     * Get the total number of bytes received through all network interfaces.
+     *
+     * @return the number of bytes received through all network interfaces
+     */
+    public static long getTotalRxBytes() {
+        return getTotalStat("rx_bytes");
+    }
+
+    /**
+     * Gets network bytes sent for this UID.
+     * The statistics are across all interfaces.
+     * The statistics come from /proc/uid_stat.
+     *
+     * {@see android.os.Process#myUid()}.
+     * 
+     * @param uid
+     * @return byte count
+     */
+    public static long getUidTxBytes(int uid) {
+        return getNumberFromFilePath("/proc/uid_stat/" + uid + "/tcp_snd");
+    }
+
+    /**
+     * Gets network bytes received for this UID.
+     * The statistics are across all interfaces.
+     * The statistics come from /proc/uid_stat.
+     *
+     * {@see android.os.Process#myUid()}.
+     *
+     * @param uid
+     * @return byte count
+     */
+    public static long getUidRxBytes(int uid) {
+        return getNumberFromFilePath("/proc/uid_stat/" + uid + "/tcp_rcv");
+    }
+
+    private static String TAG = "netstat";
+    private static final byte[] buf = new byte[16];
+
+    private static long getTotalStat(String whatStat) {
+        File netdir = new File("/sys/class/net");
+
+        File[] nets = netdir.listFiles();
+        if (nets == null) {
+            return 0;
+        }
+        long total = 0;
+	StringBuffer strbuf = new StringBuffer();
+        for (File net : nets) {
+	    strbuf.append(net.getPath()).append(File.separator).append("statistics")
+		.append(File.separator).append(whatStat);
+            total += getNumberFromFilePath(strbuf.toString());
+	    strbuf.setLength(0);
+        }
+        return total;
+    }
+
+    private static long getMobileStat(String whatStat) {
+        String filename = "/sys/class/net/rmnet0/statistics/" + whatStat;
+        RandomAccessFile raf = getFile(filename);
+        if (raf == null) {
+            filename = "/sys/class/net/ppp0/statistics/" + whatStat;
+            raf = getFile(filename);
+        }
+        if (raf == null) {
+            return 0L;
+        }
+        return getNumberFromFile(raf, filename);
+    }
+
+    // File will have format <number><newline>
+    private static long getNumberFromFilePath(String filename) {
+        RandomAccessFile raf = getFile(filename);
+        if (raf == null) {
+            return 0L;
+        }
+        return getNumberFromFile(raf, filename);
+    }
+
+    private static synchronized long getNumberFromFile(RandomAccessFile raf, String filename) {
+        try {
+            raf.read(buf);
+            raf.close();
+        } catch (IOException e) {
+            Log.w(TAG, "Exception getting TCP bytes from " + filename, e);
+            return 0L;
+        } finally {
+            if (raf != null) {
+                try {
+                    raf.close();
+                } catch (IOException e) {
+                    Log.w(TAG, "Exception closing " + filename, e);
+                }
+            }
+        }
+
+        long num = 0L;
+        for (int i = 0; i < buf.length; i++) {
+            if (buf[i] < '0' || buf[i] > '9') {
+                break;
+            }
+            num *= 10;
+            num += buf[i] - '0';
+        }
+        return num;
+    }
+
+    private static RandomAccessFile getFile(String filename) {
+        File f = new File(filename);
+        if (!f.canRead()) {
+            return null;
+        }
+
+        try {
+            return new RandomAccessFile(f, "r");
+        } catch (IOException e) {
+            Log.w(TAG, "Exception opening TCP statistics file " + filename, e);
+            return null;
+        }
+    }
 }
diff --git a/core/java/android/package.html b/core/java/android/package.html
index b6d2999..1f1be2d 100644
--- a/core/java/android/package.html
+++ b/core/java/android/package.html
@@ -5,6 +5,6 @@
 This package contains the resource classes that Android defines to be used in 
 Android applications. Third party developers can use many of them also for their applications.
 To learn more about how to use these classes, and what a 
-resource is, see <a href="{@docRoot}devel/resources-i18n.html">Resources</a>. 
+resource is, see <a href="{@docRoot}guide/topics/resources/index.html">Resources and Assets</a>. 
 </BODY>
 </HTML>
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index 95970ea..837ce91 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -103,8 +103,6 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        requestWindowFeature(Window.FEATURE_NO_TITLE);
-    
         setContentView(com.android.internal.R.layout.preference_list_content);
         
         mPreferenceManager = onCreatePreferenceManager();
@@ -214,6 +212,11 @@
     public void setPreferenceScreen(PreferenceScreen preferenceScreen) {
         if (mPreferenceManager.setPreferences(preferenceScreen) && preferenceScreen != null) {
             postBindPreferences();
+            CharSequence title = getPreferenceScreen().getTitle();
+            // Set the title of the activity
+            if (title != null) {
+                setTitle(title);
+            }
         }
     }
     
diff --git a/core/java/android/preference/PreferenceGroup.java b/core/java/android/preference/PreferenceGroup.java
index 4258b41..d008fd6 100644
--- a/core/java/android/preference/PreferenceGroup.java
+++ b/core/java/android/preference/PreferenceGroup.java
@@ -25,6 +25,7 @@
 import android.content.res.TypedArray;
 import android.os.Bundle;
 import android.os.Parcelable;
+import android.text.TextUtils;
 import android.util.AttributeSet;
 
 /**
@@ -223,6 +224,9 @@
      * @return The {@link Preference} with the key, or null.
      */
     public Preference findPreference(CharSequence key) {
+        if (TextUtils.equals(getKey(), key)) {
+            return this;
+        }
         final int preferenceCount = getPreferenceCount();
         for (int i = 0; i < preferenceCount; i++) {
             final Preference preference = getPreference(i);
diff --git a/core/java/android/provider/Checkin.java b/core/java/android/provider/Checkin.java
index ef5eded..5767c65 100644
--- a/core/java/android/provider/Checkin.java
+++ b/core/java/android/provider/Checkin.java
@@ -30,10 +30,13 @@
 import java.io.DataOutputStream;
 
 /**
- * Contract class for {@link android.server.checkin.CheckinProvider}.
+ * Contract class for the checkin provider, used to store events and
+ * statistics that will be uploaded to a checkin server eventually.
  * Describes the exposed database schema, and offers methods to add
  * events and statistics to be uploaded.
  *
+ * TODO: Move this to vendor/google when we have a home for it.
+ *
  * @hide
  */
 public final class Checkin {
@@ -56,6 +59,12 @@
 
         /** Valid tag values.  Extend as necessary for your needs. */
         public enum Tag {
+            AUTOTEST_FAILURE,
+            AUTOTEST_SEQUENCE_BEGIN,
+            AUTOTEST_SUITE_BEGIN,
+            AUTOTEST_TEST_BEGIN,
+            AUTOTEST_TEST_FAILURE,
+            AUTOTEST_TEST_SUCCESS,
             BROWSER_BUG_REPORT,
             CARRIER_BUG_REPORT,
             CHECKIN_FAILURE,
@@ -195,8 +204,11 @@
             values.put(Events.TAG, tag.toString());
             if (value != null) values.put(Events.VALUE, value);
             return resolver.insert(Events.CONTENT_URI, values);
+        } catch (IllegalArgumentException e) {  // thrown when provider is unavailable.
+            Log.w(TAG, "Can't log event " + tag + ": " + e);
+            return null;
         } catch (SQLException e) {
-            Log.e(TAG, "Can't log event: " + tag, e);  // Database errors are not fatal.
+            Log.e(TAG, "Can't log event " + tag, e);  // Database errors are not fatal.
             return null;
         }
     }
@@ -218,8 +230,11 @@
             if (count != 0) values.put(Stats.COUNT, count);
             if (sum != 0.0) values.put(Stats.SUM, sum);
             return resolver.insert(Stats.CONTENT_URI, values);
+        } catch (IllegalArgumentException e) {  // thrown when provider is unavailable.
+            Log.w(TAG, "Can't update stat " + tag + ": " + e);
+            return null;
         } catch (SQLException e) {
-            Log.e(TAG, "Can't update stat: " + tag, e);  // Database errors are not fatal.
+            Log.e(TAG, "Can't update stat " + tag, e);  // Database errors are not fatal.
             return null;
         }
     }
@@ -285,4 +300,3 @@
         }
     }
 }
-
diff --git a/core/java/android/provider/Contacts.java b/core/java/android/provider/Contacts.java
index 085c095..3bffaec 100644
--- a/core/java/android/provider/Contacts.java
+++ b/core/java/android/provider/Contacts.java
@@ -932,27 +932,33 @@
         }
         
         /**
-         * This looks up the provider category defined in
-         * {@link android.provider.Im.ProviderCategories} from the predefined IM protocol id.
+         * This looks up the provider name defined in
+         * {@link android.provider.Im.ProviderNames} from the predefined IM protocol id.
          * This is used for interacting with the IM application.
-         * 
+         *
          * @param protocol the protocol ID
-         * @return the provider category the IM app uses for the given protocol, or null if no
+         * @return the provider name the IM app uses for the given protocol, or null if no
          * provider is defined for the given protocol
          * @hide
          */
-        public static String lookupProviderCategoryFromId(int protocol) {
+        public static String lookupProviderNameFromId(int protocol) {
             switch (protocol) {
                 case PROTOCOL_GOOGLE_TALK:
-                    return Im.ProviderCategories.GTALK;
+                    return Im.ProviderNames.GTALK;
                 case PROTOCOL_AIM:
-                    return Im.ProviderCategories.AIM;
+                    return Im.ProviderNames.AIM;
                 case PROTOCOL_MSN:
-                    return Im.ProviderCategories.MSN;
+                    return Im.ProviderNames.MSN;
                 case PROTOCOL_YAHOO:
-                    return Im.ProviderCategories.YAHOO;
+                    return Im.ProviderNames.YAHOO;
                 case PROTOCOL_ICQ:
-                    return Im.ProviderCategories.ICQ;
+                    return Im.ProviderNames.ICQ;
+                case PROTOCOL_JABBER:
+                    return Im.ProviderNames.JABBER;
+                case PROTOCOL_SKYPE:
+                    return Im.ProviderNames.SKYPE;
+                case PROTOCOL_QQ:
+                    return Im.ProviderNames.QQ;
             }
             return null;
         }
diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java
index a5a30b9..4c58e0d 100644
--- a/core/java/android/provider/Downloads.java
+++ b/core/java/android/provider/Downloads.java
@@ -471,34 +471,40 @@
     public static final int STATUS_UNHANDLED_REDIRECT = 493;
 
     /**
-     * This download couldn't be completed because there were
-     * too many redirects.
-     */
-    public static final int STATUS_TOO_MANY_REDIRECTS = 494;
-
-    /**
      * This download couldn't be completed because of an
      * unspecified unhandled HTTP code.
      */
-    public static final int STATUS_UNHANDLED_HTTP_CODE = 495;
+    public static final int STATUS_UNHANDLED_HTTP_CODE = 494;
 
     /**
      * This download couldn't be completed because of an
      * error receiving or processing data at the HTTP level.
      */
-    public static final int STATUS_HTTP_DATA_ERROR = 496;
+    public static final int STATUS_HTTP_DATA_ERROR = 495;
 
     /**
-     * This download is visible and shows in the notifications while
-     * in progress and after completion.
+     * This download couldn't be completed because of an
+     * HttpException while setting up the request.
      */
-    public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED = 0;
+    public static final int STATUS_HTTP_EXCEPTION = 496;
+
+    /**
+     * This download couldn't be completed because there were
+     * too many redirects.
+     */
+    public static final int STATUS_TOO_MANY_REDIRECTS = 497;
 
     /**
      * This download is visible but only shows in the notifications
      * while it's in progress.
      */
-    public static final int VISIBILITY_VISIBLE = 1;
+    public static final int VISIBILITY_VISIBLE = 0;
+
+    /**
+     * This download is visible and shows in the notifications while
+     * in progress and after completion.
+     */
+    public static final int VISIBILITY_VISIBLE_NOTIFY_COMPLETED = 1;
 
     /**
      * This download doesn't show in the UI or in the notifications.
diff --git a/core/java/android/provider/Gmail.java b/core/java/android/provider/Gmail.java
index 325f19d..253dd4a 100644
--- a/core/java/android/provider/Gmail.java
+++ b/core/java/android/provider/Gmail.java
@@ -370,6 +370,25 @@
                 "maxAttachmentSize";
     }
 
+    /**
+     * These flags can be included as Selection Arguments when
+     * querying the provider.
+     */
+    public static class SelectionArguments {
+        private SelectionArguments() {
+            // forbid instantiation
+        }
+
+        /**
+         * Specifies that you do NOT wish the returned cursor to
+         * become the Active Network Cursor.  If you do not include
+         * this flag as a selectionArg, the new cursor will become the
+         * Active Network Cursor by default.
+         */
+        public static final String DO_NOT_BECOME_ACTIVE_NETWORK_CURSOR =
+                "SELECTION_ARGUMENT_DO_NOT_BECOME_ACTIVE_NETWORK_CURSOR";
+    }
+
     // These are the projections that we need when getting cursors from the
     // content provider.
     private static String[] CONVERSATION_PROJECTION = {
@@ -436,6 +455,28 @@
     }
 
     /**
+     * Behavior for a new cursor: should it become the Active Network
+     * Cursor?  This could potentially lead to bad behavior if someone
+     * else is using the Active Network Cursor, since theirs will stop
+     * being the Active Network Cursor.
+     */
+    public static enum BecomeActiveNetworkCursor {
+        /**
+         * The new cursor should become the one and only Active
+         * Network Cursor.  Any other cursor that might already be the
+         * Active Network Cursor will cease to be so.
+         */
+        YES,
+
+        /**
+         * The new cursor should not become the Active Network
+         * Cursor. Any other cursor that might already be the Active
+         * Network Cursor will continue to be so.
+         */
+        NO
+    }
+
+    /**
      * Wraps a Cursor in a ConversationCursor
      *
      * @param account the account the cursor is associated with
@@ -450,6 +491,20 @@
     }
 
     /**
+     * Creates an array of SelectionArguments suitable for passing to the provider's query.
+     * Currently this only handles one flag, but it could be expanded in the future.
+     */
+    private static String[] getSelectionArguments(
+            BecomeActiveNetworkCursor becomeActiveNetworkCursor) {
+        if (BecomeActiveNetworkCursor.NO == becomeActiveNetworkCursor) {
+            return new String[] {SelectionArguments.DO_NOT_BECOME_ACTIVE_NETWORK_CURSOR};
+        } else {
+            // Default behavior; no args required.
+            return null;
+        }
+    }
+
+    /**
      * Asynchronously gets a cursor over all conversations matching a query. The
      * query is in Gmail's query syntax. When the operation is complete the handler's
      * onQueryComplete() method is called with the resulting Cursor.
@@ -458,14 +513,17 @@
      * @param handler An AsyncQueryHanlder that will be used to run the query
      * @param token The token to pass to startQuery, which will be passed back to onQueryComplete
      * @param query a query in Gmail's query syntax
+     * @param becomeActiveNetworkCursor whether or not the returned
+     * cursor should become the Active Network Cursor
      */
     public void runQueryForConversations(String account, AsyncQueryHandler handler, int token,
-            String query) {
+            String query, BecomeActiveNetworkCursor becomeActiveNetworkCursor) {
         if (TextUtils.isEmpty(account)) {
             throw new IllegalArgumentException("account is empty");
         }
+        String[] selectionArgs = getSelectionArguments(becomeActiveNetworkCursor);
         handler.startQuery(token, null, Uri.withAppendedPath(CONVERSATIONS_URI, account),
-                CONVERSATION_PROJECTION, query, null, null);
+                CONVERSATION_PROJECTION, query, selectionArgs, null);
     }
 
     /**
@@ -474,11 +532,15 @@
      *
      * @param account run the query on this account
      * @param query a query in Gmail's query syntax
+     * @param becomeActiveNetworkCursor whether or not the returned
+     * cursor should become the Active Network Cursor
      */
-    public ConversationCursor getConversationCursorForQuery(String account, String query) {
+    public ConversationCursor getConversationCursorForQuery(
+            String account, String query, BecomeActiveNetworkCursor becomeActiveNetworkCursor) {
+        String[] selectionArgs = getSelectionArguments(becomeActiveNetworkCursor);
         Cursor cursor = mContentResolver.query(
                 Uri.withAppendedPath(CONVERSATIONS_URI, account), CONVERSATION_PROJECTION,
-                query, null, null);
+                query, selectionArgs, null);
         return new ConversationCursor(this, account, cursor);
     }
 
@@ -559,12 +621,10 @@
      *   server message id.
      * @param label the label to add or remove
      * @param add true to add the label, false to remove it
-     * @throws NonexistentLabelException thrown if the label does not exist
      */
     public void addOrRemoveLabelOnConversation(
             String account, long conversationId, long maxServerMessageId, String label,
-            boolean add)
-            throws NonexistentLabelException {
+            boolean add) {
         if (TextUtils.isEmpty(account)) {
             throw new IllegalArgumentException("account is empty");
         }
@@ -599,7 +659,6 @@
      * @param messageId the id of the message to whose labels should be changed
      * @param label the label to add or remove
      * @param add true to add the label, false to remove it
-     * @throws NonexistentLabelException thrown if the label does not exist
      */
     public static void addOrRemoveLabelOnMessage(ContentResolver contentResolver, String account,
             long conversationId, long messageId, String label, boolean add) {
@@ -1175,19 +1234,6 @@
     }
 
     /**
-     * Thrown when an operation is requested with a label that does not exist.
-     *
-     * TODO: this is here because I wanted a checked exception. However, I don't
-     * think that that is appropriate. In fact, I don't think that we should
-     * throw an exception at all because the label might have been valid when
-     * the caller presented it to the user but removed as a result of a sync.
-     * Maybe we should kill this and eat the errors.
-     */
-    public static class NonexistentLabelException extends Exception {
-        // TODO: Add label name?
-    }
-
-    /**
      * A cursor over labels.
      */
     public final class LabelCursor extends MailCursor {
@@ -2021,10 +2067,8 @@
          *
          * @param label the label to add or remove
          * @param add whether to add or remove the label
-         * @throws NonexistentLabelException thrown if the named label does not
-         *         exist
          */
-        public void addOrRemoveLabel(String label, boolean add) throws NonexistentLabelException {
+        public void addOrRemoveLabel(String label, boolean add) {
             addOrRemoveLabelOnMessage(mContentResolver, mAccount, getConversationId(),
                     getMessageId(), label, add);
         }
diff --git a/core/java/android/provider/Im.java b/core/java/android/provider/Im.java
index 68b2acd..bea857f 100644
--- a/core/java/android/provider/Im.java
+++ b/core/java/android/provider/Im.java
@@ -78,21 +78,10 @@
         String MSN = "MSN";
         String ICQ = "ICQ";
         String AIM = "AIM";
-    }
-
-    /**
-     * The ProviderCategories definitions are used for the Intent category for the Intent
-     *
-     *     Intent intent = new Intent(Intent.ACTION_SENDTO,
-     *             Uri.fromParts("im", data, null)).
-     *                     addCategory(category);
-     */
-    public interface ProviderCategories {
-        String GTALK = "com.android.im.category.GTALK";
-        String AIM = "com.android.im.category.AIM";
-        String MSN = "com.android.im.category.MSN";
-        String YAHOO = "com.android.im.category.YAHOO";
-        String ICQ = "com.android.im.category.ICQ";
+        String XMPP = "XMPP";
+        String JABBER = "JABBER";
+        String SKYPE = "SKYPE";
+        String QQ = "QQ";
     }
 
     /**
@@ -140,54 +129,6 @@
             return retVal;
         }
 
-        /**
-         * This returns the provider name given a provider category.
-         *
-         * @param providerCategory the provider category defined in {@link ProviderCategories}.
-         * @return the corresponding provider name defined in {@link ProviderNames}.
-         */
-        public static String getProviderNameForCategory(String providerCategory) {
-            if (providerCategory != null) {
-                if (providerCategory.equalsIgnoreCase(ProviderCategories.GTALK)) {
-                    return ProviderNames.GTALK;
-                } else if (providerCategory.equalsIgnoreCase(ProviderCategories.AIM)) {
-                    return ProviderNames.AIM;
-                } else if (providerCategory.equalsIgnoreCase(ProviderCategories.MSN)) {
-                    return ProviderNames.MSN;
-                } else if (providerCategory.equalsIgnoreCase(ProviderCategories.YAHOO)) {
-                    return ProviderNames.YAHOO;
-                } else if (providerCategory.equalsIgnoreCase(ProviderCategories.ICQ)) {
-                    return ProviderNames.ICQ;
-                }
-            }
-
-            return null;
-        }
-
-        /**
-         * This returns the provider category given a provider name.
-         *
-         * @param providername the provider name defined in {@link ProviderNames}.
-         * @return the provider category defined in {@link ProviderCategories}.
-         */
-        public static String getProviderCategoryFromName(String providername) {
-            if (providername != null) {
-                if (providername.equalsIgnoreCase(Im.ProviderNames.GTALK)) {
-                    return Im.ProviderCategories.GTALK;
-                } else if (providername.equalsIgnoreCase(Im.ProviderNames.AIM)) {
-                    return Im.ProviderCategories.AIM;
-                } else if (providername.equalsIgnoreCase(Im.ProviderNames.MSN)) {
-                    return Im.ProviderCategories.MSN;
-                } else if (providername.equalsIgnoreCase(Im.ProviderNames.YAHOO)) {
-                    return Im.ProviderCategories.YAHOO;
-                } else if (providername.equalsIgnoreCase(Im.ProviderNames.ICQ)) {
-                    return Im.ProviderCategories.ICQ;
-                }
-            }
-
-            return null;
-        }
-
         private static final String[] PROVIDER_PROJECTION = new String[] {
                 _ID,
                 NAME
@@ -797,6 +738,13 @@
         String ETAG = "etag";
 
         /**
+         * The OTR etag, computed by the server, stored on the client. There is one OTR etag
+         * per account roster.
+         * <P>Type: TEXT</P>
+         */
+        String OTR_ETAG = "otr_etag";
+
+        /**
          * The account id for the etag.
          * <P> Type: INTEGER </P>
          */
@@ -837,12 +785,38 @@
             return retVal;
         }
 
+        public static final String getOtrEtag(ContentResolver resolver, long accountId) {
+            String retVal = null;
+
+            Cursor c = resolver.query(CONTENT_URI,
+                    CONTACT_OTR_ETAG_PROJECTION,
+                    ACCOUNT + "=" + accountId,
+                    null /* selection args */,
+                    null /* sort order */);
+
+            try {
+                if (c.moveToFirst()) {
+                    retVal = c.getString(COLUMN_OTR_ETAG);
+                }
+            } finally {
+                c.close();
+            }
+
+            return retVal;
+        }
+
         private static final String[] CONTACT_ETAG_PROJECTION = new String[] {
                 Im.ContactsEtag.ETAG    // 0
         };
 
         private static int COLUMN_ETAG = 0;
 
+        private static final String[] CONTACT_OTR_ETAG_PROJECTION = new String[] {
+                Im.ContactsEtag.OTR_ETAG    // 0
+        };
+
+        private static int COLUMN_OTR_ETAG = 0;
+
         /**
          * The content:// style URL for this table
          */
@@ -1271,9 +1245,9 @@
     }
 
     /**
-     * Columns shared between the IM and contacts presence tables
+     * Common presence columns shared between the IM and contacts presence tables
      */
-    interface CommonPresenceColumns {
+    public interface CommonPresenceColumns {
         /**
          * The priority, an integer, used by XMPP presence
          * <P>Type: INTEGER</P>
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java
index 87a02e6..2897b4e 100644
--- a/core/java/android/provider/MediaStore.java
+++ b/core/java/android/provider/MediaStore.java
@@ -91,14 +91,14 @@
     public static final String EXTRA_SCREEN_ORIENTATION = "android.intent.extra.screenOrientation";
 
     /**
-     * The name of the Intent-extra used to control the orientation of a ViewImage.
+     * The name of an Intent-extra used to control the UI of a ViewImage.
      * This is a boolean property that overrides the activity's default fullscreen state.
      * @hide
      */
     public static final String EXTRA_FULL_SCREEN = "android.intent.extra.fullScreen";
 
     /**
-     * The name of the Intent-extra used to control the orientation of a ViewImage.
+     * The name of an Intent-extra used to control the UI of a ViewImage.
      * This is a boolean property that specifies whether or not to show action icons.
      * @hide
      */
@@ -117,25 +117,36 @@
      */
     public static final String INTENT_ACTION_STILL_IMAGE_CAMERA = "android.media.action.STILL_IMAGE_CAMERA";
 
-
     /**
      * The name of the Intent action used to launch a camera in video mode.
      */
     public static final String INTENT_ACTION_VIDEO_CAMERA = "android.media.action.VIDEO_CAMERA";
 
     /**
-     * Standard Intent action that can be sent to have the media application
-     * capture an image and return it.  The image is returned as a Bitmap
-     * object in the extra field.
-     * @hide
+     * Standard Intent action that can be sent to have the camera application
+     * capture an image and return it.
+     * <p>
+     * The caller may pass an extra EXTRA_OUTPUT to control where this image will be written.
+     * If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap
+     * object in the extra field. This is useful for applications that only need a small image.
+     * If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri
+     * value of EXTRA_OUTPUT.
+     * @see #EXTRA_OUTPUT
+     * @see #EXTRA_VIDEO_QUALITY
      */
     public final static String ACTION_IMAGE_CAPTURE = "android.media.action.IMAGE_CAPTURE";
 
     /**
-     * Standard Intent action that can be sent to have the media application
-     * capture an video and return it.  The caller may pass in an extra EXTRA_VIDEO_QUALITY
-     * control the video quality.
-     * @hide
+     * Standard Intent action that can be sent to have the camera application
+     * capture an video and return it.
+     * <p>
+     * The caller may pass in an extra EXTRA_VIDEO_QUALITY to control the video quality.
+     * <p>
+     * The caller may pass in an extra EXTRA_OUTPUT to control
+     * where the video is written. If EXTRA_OUTPUT is not present the video will be
+     * written to the standard location for videos, and the Uri of that location will be
+     * returned in the data field of the Uri.
+     * @see #EXTRA_OUTPUT
      */
     public final static String ACTION_VIDEO_CAPTURE = "android.media.action.VIDEO_CAPTURE";
 
@@ -143,14 +154,12 @@
      * The name of the Intent-extra used to control the quality of a recorded video. This is an
      * integer property. Currently value 0 means low quality, suitable for MMS messages, and
      * value 1 means high quality. In the future other quality levels may be added.
-     * @hide
      */
     public final static String EXTRA_VIDEO_QUALITY = "android.intent.extra.videoQuality";
 
     /**
-     * The name of the Intent-extra used to indicate a Uri to be used to
+     * The name of the Intent-extra used to indicate a content resolver Uri to be used to
      * store the requested image or video.
-     * @hide
      */
     public final static String EXTRA_OUTPUT = "output";
 
@@ -471,7 +480,7 @@
             /**
              * The default sort order for this table
              */
-            public static final String DEFAULT_SORT_ORDER = "name ASC";
+            public static final String DEFAULT_SORT_ORDER = ImageColumns.BUCKET_DISPLAY_NAME;
        }
 
         public static class Thumbnails implements BaseColumns
@@ -582,6 +591,14 @@
             public static final String DURATION = "duration";
 
             /**
+             * The position, in ms, playback was at when playback for this file
+             * was last stopped.
+             * <P>Type: INTEGER (long)</P>
+             * @hide
+             */
+            public static final String BOOKMARK = "bookmark";
+
+            /**
              * The id of the artist who created the audio file, if any
              * <P>Type: INTEGER (long)</P>
              */
@@ -654,6 +671,13 @@
             public static final String IS_MUSIC = "is_music";
 
             /**
+             * Non-zero if the audio file is a podcast
+             * <P>Type: INTEGER (boolean)</P>
+             * @hide
+             */
+            public static final String IS_PODCAST = "is_podcast";
+
+            /**
              * Non-zero id the audio file may be a ringtone
              * <P>Type: INTEGER (boolean)</P>
              */
@@ -1198,22 +1222,15 @@
     }
 
     public static final class Video {
-        /**
-         *  deprecated  Replaced by DEFAULT_SORT_ORDER2
-         *  This variable is a mistake that is retained for backwards compatibility.
-         *  (There is no "name" column in the Video table.)
-         */
-        public static final String DEFAULT_SORT_ORDER = "name ASC";
 
         /**
-         * The default sort order for this table
-         * @hide
+         * The default sort order for this table.
          */
-        public static final String DEFAULT_SORT_ORDER2 = MediaColumns.DISPLAY_NAME;
+        public static final String DEFAULT_SORT_ORDER = MediaColumns.DISPLAY_NAME;
 
         public static final Cursor query(ContentResolver cr, Uri uri, String[] projection)
         {
-            return cr.query(uri, projection, null, null, DEFAULT_SORT_ORDER2);
+            return cr.query(uri, projection, null, null, DEFAULT_SORT_ORDER);
         }
 
         public interface VideoColumns extends MediaColumns {
@@ -1316,7 +1333,6 @@
              * video should start playing at the next time it is opened. If the value is null or
              * out of the range 0..DURATION-1 then the video should start playing from the
              * beginning.
-             * @hide
              * <P>Type: INTEGER</P>
              */
             public static final String BOOKMARK = "bookmark";
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index abbfd5b..054da1d 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -235,6 +235,35 @@
             "android.settings.LOCALE_SETTINGS";
 
     /**
+     * Activity Action: Show settings to configure input methods, in particular
+     * allowing the user to enable input methods.
+     * <p>
+     * In some cases, a matching Activity may not exist, so ensure you
+     * safeguard against this.
+     * <p>
+     * Input: Nothing.
+     * <p>
+     * Output: Nothing.
+     */
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+    public static final String ACTION_INPUT_METHOD_SETTINGS =
+            "android.settings.INPUT_METHOD_SETTINGS";
+
+    /**
+     * Activity Action: Show settings to manage the user input dictionary.
+     * <p>
+     * In some cases, a matching Activity may not exist, so ensure you
+     * safeguard against this.
+     * <p>
+     * Input: Nothing.
+     * <p>
+     * Output: Nothing.
+     */
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+    public static final String ACTION_USER_DICTIONARY_SETTINGS =
+            "android.settings.USER_DICTIONARY_SETTINGS";
+
+    /**
      * Activity Action: Show settings to allow configuration of application-related settings.
      * <p>
      * In some cases, a matching Activity may not exist, so ensure you
@@ -1233,6 +1262,13 @@
         public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
 
         /**
+         * Scaling factor for normal window animations. Setting to 0 will disable window
+         * animations.
+         * @hide
+         */
+        public static final String FANCY_IME_ANIMATIONS = "fancy_ime_animations";
+
+        /**
          * Control whether the accelerometer will be used to change screen
          * orientation.  If 0, it will not be used unless explicitly requested
          * by the application; if 1, it will be used by default unless explicitly
@@ -2008,6 +2044,14 @@
          */
         public static final String WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS =
             "wifi_mobile_data_transition_wakelock_timeout_ms";
+
+        /**
+         * Whether background data usage is allowed by the user. See
+         * ConnectivityManager for more info.
+         * 
+         * @hide pending API council
+         */
+        public static final String BACKGROUND_DATA = "background_data";
     }
     
     /**
@@ -2130,6 +2174,11 @@
          * Event tags from the kernel event log to upload during checkin.
          */
         public static final String CHECKIN_EVENTS = "checkin_events";
+        
+        /**
+         * Event tags for list of services to upload during checkin.
+         */
+        public static final String CHECKIN_DUMPSYS_LIST = "checkin_dumpsys_list";
 
         /**
          * The interval (in seconds) between periodic checkin attempts.
@@ -2704,8 +2753,27 @@
          * Speech encoding used with voice search on WIFI networks. To be factored out of this class.
          */
         public static final String VOICE_SEARCH_ENCODING_WIFI = "voice_search_encoding_wifi";
-        
-        
+
+        /**
+         * Prefix for rules that launch automatic instrumentation test cycles.
+         * The format is the InstrumentationTestRunner (or compatible) package and class,
+         * followed optionally by space-separated key value pairs to pass to it.
+         */
+        public static final String AUTOTEST_PREFIX = "autotest:";
+
+        /**
+         * Interval between synchronous checkins forced by the automatic test runner.
+         * If you set this to a value smaller than CHECKIN_INTERVAL, then the test runner's
+         * frequent checkins will prevent asynchronous background checkins from interfering
+         * with any performance measurements.
+         */
+        public static final String AUTOTEST_CHECKIN_SECONDS = "autotest_checkin_seconds";
+
+        /**
+         * Interval between reboots forced by the automatic test runner.
+         */
+        public static final String AUTOTEST_REBOOT_SECONDS = "autotest_reboot_seconds";
+
         /**
          * @deprecated
          * @hide
@@ -2912,9 +2980,10 @@
          * 
          * @param context A context.
          * @param cursor A cursor pointing to the row whose title should be
-         *            returned. The cursor must contain at least the
-         *            {@link #TITLE} and {@link #INTENT} columns.
-         * @return A title that is localized and can be displayed to the user.
+         *        returned. The cursor must contain at least the {@link #TITLE}
+         *        and {@link #INTENT} columns.
+         * @return A title that is localized and can be displayed to the user,
+         *         or the empty string if one could not be found.
          */
         public static CharSequence getTitle(Context context, Cursor cursor) {
             int titleColumn = cursor.getColumnIndex(TITLE);
@@ -2943,7 +3012,7 @@
             
             PackageManager packageManager = context.getPackageManager();
             ResolveInfo info = packageManager.resolveActivity(intent, 0);
-            return info.loadLabel(packageManager);
+            return info != null ? info.loadLabel(packageManager) : "";
         }
     }
 
diff --git a/core/java/android/provider/Sync.java b/core/java/android/provider/Sync.java
index 94bf807..628852f 100644
--- a/core/java/android/provider/Sync.java
+++ b/core/java/android/provider/Sync.java
@@ -273,6 +273,7 @@
         public static final int ERROR_CONFLICT = 5;
         public static final int ERROR_TOO_MANY_DELETIONS = 6;
         public static final int ERROR_TOO_MANY_RETRIES = 7;
+        public static final int ERROR_INTERNAL = 8;
 
         // The MESG column will contain one of these or one of the Error types.
         public static final String MESG_SUCCESS = "success";
@@ -292,6 +293,7 @@
                 case ERROR_CONFLICT: return "conflict detected";
                 case ERROR_TOO_MANY_DELETIONS: return "too many deletions";
                 case ERROR_TOO_MANY_RETRIES: return "too many retries";
+                case ERROR_INTERNAL: return "internal error";
                 default: return "unknown error";
             }
         }
@@ -491,11 +493,6 @@
         /** controls whether or not the device listens for sync tickles */
         public static final String SETTING_LISTEN_FOR_TICKLES = "listen_for_tickles";
 
-        /** controls whether or not the device connect to Google in background for various
-         *  stuff, including GTalk, checkin, Market and data sync ...
-         */
-        public static final String SETTING_BACKGROUND_DATA = "background_data";
-
         /** controls whether or not the individual provider is synced when tickles are received */
         public static final String SETTING_SYNC_PROVIDER_PREFIX = "sync_provider_";
 
@@ -572,18 +569,6 @@
             putBoolean(contentResolver, SETTING_LISTEN_FOR_TICKLES, flag);
         }
 
-        /**
-         * A convenience method to set whether or not the device should connect to Google
-         * in background.
-         *
-         * @param contentResolver the ContentResolver to use to access the settings table
-         * @param flag true if it should connect.
-         */
-        static public void setBackgroundData(ContentResolver contentResolver,
-                boolean flag) {
-            putBoolean(contentResolver, SETTING_BACKGROUND_DATA, flag);
-        }
-
         public static class QueryMap extends ContentQueryMap {
             private ContentResolver mContentResolver;
 
@@ -632,24 +617,6 @@
             }
 
             /**
-             * Set whether or not the device should connect to Google in background
-             *
-             * @param flag true if it should
-             */
-            public void setBackgroundData(boolean flag) {
-                Settings.setBackgroundData(mContentResolver, flag);
-            }
-
-            /**
-             * Check if the device should connect to Google in background.
-
-             * @return true if it should
-             */
-            public boolean getBackgroundData() {
-                return getBoolean(SETTING_BACKGROUND_DATA, true);
-            }
-
-            /**
              * Convenience function for retrieving a single settings value
              * as a boolean.
              *
diff --git a/core/java/android/provider/UserDictionary.java b/core/java/android/provider/UserDictionary.java
index 58e5731..5a7ef85 100644
--- a/core/java/android/provider/UserDictionary.java
+++ b/core/java/android/provider/UserDictionary.java
@@ -25,10 +25,13 @@
 import android.text.TextUtils;
 
 /**
- * 
- * @hide Pending API council approval
+ * A provider of user defined words for input methods to use for predictive text input.
+ * Applications and input methods may add words into the dictionary. Words can have associated
+ * frequency information and locale information.
  */
 public class UserDictionary {
+
+    /** Authority string for this provider. */
     public static final String AUTHORITY = "user_dictionary";
 
     /**
@@ -39,7 +42,6 @@
 
     /**
      * Contains the user defined words.
-     * @hide Pending API council approval
      */
     public static class Words implements BaseColumns {
         /**
@@ -67,14 +69,14 @@
         public static final String WORD = "word";
 
         /**
-         * The frequency column. A value between 1 and 255.
+         * The frequency column. A value between 1 and 255. Higher values imply higher frequency.
          * <p>TYPE: INTEGER</p>
          */
         public static final String FREQUENCY = "frequency";
 
         /**
          * The locale that this word belongs to. Null if it pertains to all
-         * locales. Locale is a 5 letter string such as <pre>en_US</pre>.
+         * locales. Locale is as defined by the string returned by Locale.toString().
          * <p>TYPE: TEXT</p>
          */
         public static final String LOCALE = "locale";
@@ -85,8 +87,10 @@
          */
         public static final String APP_ID = "appid";
 
+        /** The locale type to specify that the word is common to all locales. */
         public static final int LOCALE_TYPE_ALL = 0;
         
+        /** The locale type to specify that the word is for the current locale. */
         public static final int LOCALE_TYPE_CURRENT = 1;
         
         /**
@@ -94,7 +98,14 @@
          */
         public static final String DEFAULT_SORT_ORDER = FREQUENCY + " DESC";
 
-
+        /** Adds a word to the dictionary, with the given frequency and the specified
+         *  specified locale type.
+         *  @param context the current application context
+         *  @param word the word to add to the dictionary. This should not be null or
+         *  empty.
+         *  @param localeType the locale type for this word. It should be one of
+         *  {@link #LOCALE_TYPE_ALL} or {@link #LOCALE_TYPE_CURRENT}.
+         */
         public static void addWord(Context context, String word, 
                 int frequency, int localeType) {
             final ContentResolver resolver = context.getContentResolver();
diff --git a/core/java/android/provider/package.html b/core/java/android/provider/package.html
index a553592..055b037 100644
--- a/core/java/android/provider/package.html
+++ b/core/java/android/provider/package.html
@@ -6,6 +6,6 @@
 as contact informations, calendar information, and media files. These classes
 provide simplified methods of adding or retrieving data from these content
 providers. For information about how to use a content provider, see <a
-href="{@docRoot}devel/data.html">Reading and Writing Persistent Data</a>.
+href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>.
 </BODY>
 </HTML>
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index 8486e4b..58f9491 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -55,6 +55,7 @@
     private static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH;
 
     private static final String A2DP_SINK_ADDRESS = "a2dp_sink_address";
+    private static final String BLUETOOTH_ENABLED = "bluetooth_enabled";
 
     private final Context mContext;
     private final IntentFilter mIntentFilter;
@@ -136,10 +137,28 @@
                                                       BluetoothA2dp.STATE_DISCONNECTED));
             }
         }
+        mAudioManager.setParameter(BLUETOOTH_ENABLED, "true");
     }
 
     private synchronized void onBluetoothDisable() {
-        mAudioDevices = null;
+        if (mAudioDevices != null) {
+            for (String path : mAudioDevices.keySet()) {
+                switch (mAudioDevices.get(path).state) {
+                    case BluetoothA2dp.STATE_CONNECTING:
+                    case BluetoothA2dp.STATE_CONNECTED:
+                    case BluetoothA2dp.STATE_PLAYING:
+                        disconnectSinkNative(path);
+                        updateState(path, BluetoothA2dp.STATE_DISCONNECTED);
+                        break;
+                    case BluetoothA2dp.STATE_DISCONNECTING:
+                        updateState(path, BluetoothA2dp.STATE_DISCONNECTED);
+                        break;
+                }
+            }
+            mAudioDevices = null;
+        }
+        mAudioManager.setBluetoothA2dpOn(false);
+        mAudioManager.setParameter(BLUETOOTH_ENABLED, "false");
     }
 
     public synchronized int connectSink(String address) {
@@ -289,6 +308,7 @@
             }
         }
 
+        updateState(path, BluetoothA2dp.STATE_CONNECTING);
         mAudioManager.setParameter(A2DP_SINK_ADDRESS, lookupAddress(path));
         mAudioManager.setBluetoothA2dpOn(true);
         updateState(path, BluetoothA2dp.STATE_CONNECTED);
@@ -309,6 +329,11 @@
 
     private synchronized final String lookupAddress(String path) {
         if (mAudioDevices == null) return null;
+        SinkState sink = mAudioDevices.get(path);
+        if (sink == null) {
+            Log.w(TAG, "lookupAddress() called for unknown device " + path);
+            updateState(path, BluetoothA2dp.STATE_DISCONNECTED);
+        }
         String address = mAudioDevices.get(path).address;
         if (address == null) Log.e(TAG, "Can't find address for " + path);
         return address;
@@ -349,6 +374,15 @@
             intent.putExtra(BluetoothA2dp.SINK_PREVIOUS_STATE, prevState);
             intent.putExtra(BluetoothA2dp.SINK_STATE, state);
             mContext.sendBroadcast(intent, BLUETOOTH_PERM);
+
+            if ((prevState == BluetoothA2dp.STATE_CONNECTED ||
+                 prevState == BluetoothA2dp.STATE_PLAYING) &&
+                    (state != BluetoothA2dp.STATE_CONNECTED &&
+                     state != BluetoothA2dp.STATE_PLAYING)) {
+                // disconnected
+                intent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
+                mContext.sendBroadcast(intent);
+            }
         }
     }
 
diff --git a/core/java/android/server/BluetoothDeviceService.java b/core/java/android/server/BluetoothDeviceService.java
index 3ce34c3..d149761 100644
--- a/core/java/android/server/BluetoothDeviceService.java
+++ b/core/java/android/server/BluetoothDeviceService.java
@@ -91,8 +91,6 @@
         mIsDiscovering = false;
         mEventLoop = new BluetoothEventLoop(mContext, this);
         registerForAirplaneMode();
-
-        disableEsco();  // TODO: enable eSCO support once its fully supported
     }
     private native void initializeNativeDataNative();
 
@@ -130,10 +128,21 @@
         }
         mEventLoop.stop();
         disableNative();
+
+        // mark in progress bondings as cancelled
+        for (String address : mBondState.listInState(BluetoothDevice.BOND_BONDING)) {
+            mBondState.setBondState(address, BluetoothDevice.BOND_NOT_BONDED,
+                                    BluetoothDevice.UNBOND_REASON_AUTH_CANCELED);
+        }
+        // update mode
+        Intent intent = new Intent(BluetoothIntent.SCAN_MODE_CHANGED_ACTION);
+        intent.putExtra(BluetoothIntent.SCAN_MODE, BluetoothDevice.SCAN_MODE_NONE);
+        mContext.sendBroadcast(intent, BLUETOOTH_PERM);
+
         mIsEnabled = false;
-        Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.BLUETOOTH_ON, 0);
+        persistBluetoothOnSetting(false);
         mIsDiscovering = false;
-        Intent intent = new Intent(BluetoothIntent.DISABLED_ACTION);
+        intent = new Intent(BluetoothIntent.DISABLED_ACTION);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
         return true;
     }
@@ -202,18 +211,27 @@
 
             if (res) {
                 mIsEnabled = true;
-                Settings.Secure.putInt(mContext.getContentResolver(),
-                                       Settings.Secure.BLUETOOTH_ON, 1);
+                persistBluetoothOnSetting(true);
                 mIsDiscovering = false;
                 Intent intent = new Intent(BluetoothIntent.ENABLED_ACTION);
                 mBondState.loadBondState();
                 mContext.sendBroadcast(intent, BLUETOOTH_PERM);
                 mHandler.sendMessageDelayed(mHandler.obtainMessage(REGISTER_SDP_RECORDS), 3000);
+
+                // Update mode
+                mEventLoop.onModeChanged(getModeNative());
             }
             mEnableThread = null;
         }
-    };
+    }
 
+    private void persistBluetoothOnSetting(boolean bluetoothOn) {
+        long origCallerIdentityToken = Binder.clearCallingIdentity();
+        Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.BLUETOOTH_ON,
+                bluetoothOn ? 1 : 0);
+        Binder.restoreCallingIdentity(origCallerIdentityToken);        
+    }
+    
     private native int enableNative();
     private native int disableNative();
 
@@ -288,10 +306,10 @@
             return state.intValue();
         }
 
-        public synchronized String[] listBonds() {
+        private synchronized String[] listInState(int state) {
             ArrayList<String> result = new ArrayList<String>(mState.size());
             for (Map.Entry<String, Integer> e : mState.entrySet()) {
-                if (e.getValue().intValue() == BluetoothDevice.BOND_BONDED) {
+                if (e.getValue().intValue() == state) {
                     result.add(e.getKey());
                 }
             }
@@ -353,18 +371,6 @@
     }
     private native boolean setNameNative(String name);
 
-    public synchronized String getMajorClass() {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        return getMajorClassNative();
-    }
-    private native String getMajorClassNative();
-
-    public synchronized String getMinorClass() {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        return getMinorClassNative();
-    }
-    private native String getMinorClassNative();
-
     /**
      * Returns the user-friendly name of a remote device.  This value is
      * retrned from our local cache, which is updated during device discovery.
@@ -386,24 +392,6 @@
 
     /* pacakge */ native String getAdapterPathNative();
 
-    /**
-     * Initiate a remote-device-discovery procedure.  This procedure may be
-     * canceled by calling {@link #stopDiscovery}.  Remote-device discoveries
-     * are returned as intents
-     * <p>
-     * Typically, when a remote device is found, your
-     * android.bluetooth.DiscoveryEventNotifier#notifyRemoteDeviceFound
-     *  method will be invoked, and subsequently, your
-     * android.bluetooth.RemoteDeviceEventNotifier#notifyRemoteNameUpdated
-     * will tell you the user-friendly name of the remote device.  However,
-     * it is possible that the name update may fail for various reasons, so you
-     * should display the device's Bluetooth address as soon as you get a
-     * notifyRemoteDeviceFound event, and update the name when you get the
-     * remote name.
-     *
-     * @return true if discovery has started,
-     *         false otherwise.
-     */
     public synchronized boolean startDiscovery(boolean resolveNames) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
@@ -411,12 +399,6 @@
     }
     private native boolean startDiscoveryNative(boolean resolveNames);
 
-    /**
-     * Cancel a remote-device discovery.
-     *
-     * Note: you may safely call this method even when discovery has not been
-     *       started.
-     */
     public synchronized boolean cancelDiscovery() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
@@ -492,171 +474,23 @@
     }
     private native boolean isConnectedNative(String address);
 
-    /**
-     * Detetermines whether this device is connectable (that is, whether remote
-     * devices can connect to it.)
-     * <p>
-     * Note: A Bluetooth adapter has separate connectable and discoverable
-     *       states, and you could have any combination of those.  Although
-     *       any combination is possible (such as discoverable but not
-     *       connectable), we restrict the possible combinations to one of
-     *       three possibilities: discoverable and connectable, connectable
-     *       but not discoverable, and neither connectable nor discoverable.
-     *
-     * @return true if this adapter is connectable
-     *         false otherwise
-     *
-     * @see #isDiscoverable
-     * @see #getMode
-     * @see #setMode
-     */
-    public synchronized boolean isConnectable() {
+    public synchronized int getScanMode() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        return isConnectableNative();
-    }
-    private native boolean isConnectableNative();
-
-    /**
-     * Detetermines whether this device is discoverable.
-     *
-     * Note: a Bluetooth adapter has separate connectable and discoverable
-     *       states, and you could have any combination of those.  Although
-     *       any combination is possible (such as discoverable but not
-     *       connectable), we restrict the possible combinations to one of
-     *       three possibilities: discoverable and connectable, connectable
-     *       but not discoverable, and neither connectable nor discoverable.
-     *
-     * @return true if this adapter is discoverable
-     *         false otherwise
-     *
-     * @see #isConnectable
-     * @see #getMode
-     * @see #setMode
-     */
-    public synchronized boolean isDiscoverable() {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        return isDiscoverableNative();
-    }
-    private native boolean isDiscoverableNative();
-
-    /**
-     * Determines which one of three modes this adapter is in: discoverable and
-     * connectable, not discoverable but connectable, or neither.
-     *
-     * @return Mode enumeration containing the current mode.
-     *
-     * @see #setMode
-     */
-    public synchronized int getMode() {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        String mode = getModeNative();
-        if (mode == null) {
-            return BluetoothDevice.MODE_UNKNOWN;
-        }
-        if (mode.equalsIgnoreCase("off")) {
-            return BluetoothDevice.MODE_OFF;
-        }
-        else if (mode.equalsIgnoreCase("connectable")) {
-            return BluetoothDevice.MODE_CONNECTABLE;
-        }
-        else if (mode.equalsIgnoreCase("discoverable")) {
-            return BluetoothDevice.MODE_DISCOVERABLE;
-        }
-        else {
-            return BluetoothDevice.MODE_UNKNOWN;
-        }
+        return bluezStringToScanMode(getModeNative());
     }
     private native String getModeNative();
 
-    /**
-     * Set the discoverability and connectability mode of this adapter.  The
-     * possibilities are discoverable and connectable (MODE_DISCOVERABLE),
-     * connectable but not discoverable (MODE_CONNECTABLE), and neither
-     * (MODE_OFF).
-     *
-     * Note: MODE_OFF does not mean that the adapter is physically off.  It
-     *       may be neither discoverable nor connectable, but it could still
-     *       initiate outgoing connections, or could participate in a
-     *       connection initiated by a remote device before its mode was set
-     *       to MODE_OFF.
-     *
-     * @param mode the new mode
-     * @see #getMode
-     */
-    public synchronized boolean setMode(int mode) {
+    public synchronized boolean setScanMode(int mode) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
-        switch (mode) {
-        case BluetoothDevice.MODE_OFF:
-            return setModeNative("off");
-        case BluetoothDevice.MODE_CONNECTABLE:
-            return setModeNative("connectable");
-        case BluetoothDevice.MODE_DISCOVERABLE:
-            return setModeNative("discoverable");
+        String bluezMode = scanModeToBluezString(mode);
+        if (bluezMode != null) {
+            return setModeNative(bluezMode);
         }
         return false;
     }
     private native boolean setModeNative(String mode);
 
-    /**
-     * Retrieves the alias of a remote device.  The alias is a local feature,
-     * and allows us to associate a name with a remote device that is different
-     * from that remote device's user-friendly name.  The remote device knows
-     * nothing about this.  The alias can be changed with
-     * {@link #setRemoteAlias}, and it may be removed with
-     * {@link #clearRemoteAlias}
-     *
-     * @param address Bluetooth address of remote device.
-     *
-     * @return The alias of the remote device.
-     */
-    public synchronized String getRemoteAlias(String address) {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        if (!BluetoothDevice.checkBluetoothAddress(address)) {
-            return null;
-        }
-        return getRemoteAliasNative(address);
-    }
-    private native String getRemoteAliasNative(String address);
-
-    /**
-     * Changes the alias of a remote device.  The alias is a local feature,
-     * from that remote device's user-friendly name.  The remote device knows
-     * nothing about this.  The alias can be retrieved with
-     * {@link #getRemoteAlias}, and it may be removed with
-     * {@link #clearRemoteAlias}.
-     *
-     * @param address Bluetooth address of remote device
-     * @param alias Alias for the remote device
-     */
-    public synchronized boolean setRemoteAlias(String address, String alias) {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
-                                                "Need BLUETOOTH_ADMIN permission");
-        if (alias == null || !BluetoothDevice.checkBluetoothAddress(address)) {
-            return false;
-        }
-        return setRemoteAliasNative(address, alias);
-    }
-    private native boolean setRemoteAliasNative(String address, String alias);
-
-    /**
-     * Removes the alias of a remote device.  The alias is a local feature,
-     * from that remote device's user-friendly name.  The remote device knows
-     * nothing about this.  The alias can be retrieved with
-     * {@link #getRemoteAlias}.
-     *
-     * @param address Bluetooth address of remote device
-     */
-    public synchronized boolean clearRemoteAlias(String address) {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
-                                                "Need BLUETOOTH_ADMIN permission");
-        if (!BluetoothDevice.checkBluetoothAddress(address)) {
-            return false;
-        }
-        return clearRemoteAliasNative(address);
-    }
-    private native boolean clearRemoteAliasNative(String address);
-
     public synchronized boolean disconnectRemoteDeviceAcl(String address) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                                 "Need BLUETOOTH_ADMIN permission");
@@ -699,7 +533,7 @@
         }
 
         mBondState.setBondState(address, BluetoothDevice.BOND_NOT_BONDED,
-                                BluetoothDevice.UNBOND_REASON_CANCELLED);
+                                BluetoothDevice.UNBOND_REASON_AUTH_CANCELED);
         cancelBondingProcessNative(address);
         return true;
     }
@@ -717,7 +551,7 @@
 
     public synchronized String[] listBonds() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        return mBondState.listBonds();
+        return mBondState.listInState(BluetoothDevice.BOND_BONDED);
     }
 
     public synchronized int getBondState(String address) {
@@ -919,69 +753,6 @@
     private native String lastUsedNative(String address);
 
     /**
-     * Gets the major device class of the specified device.
-     * Example: "computer"
-     *
-     * Note:  This is simply a string desciption of the major class of the
-     *        device-class information, which is returned as a 32-bit value
-     *        during device discovery.
-     *
-     * @param address The Bluetooth address of the remote device.
-     *
-     * @return remote-device major class
-     *
-     * @see #getRemoteClass
-     */
-    public synchronized String getRemoteMajorClass(String address) {
-        if (!BluetoothDevice.checkBluetoothAddress(address)) {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-            return null;
-        }
-        return getRemoteMajorClassNative(address);
-    }
-    private native String getRemoteMajorClassNative(String address);
-
-    /**
-     * Gets the minor device class of the specified device.
-     * Example: "laptop"
-     *
-     * Note:  This is simply a string desciption of the minor class of the
-     *        device-class information, which is returned as a 32-bit value
-     *        during device discovery.
-     *
-     * @param address The Bluetooth address of the remote device.
-     *
-     * @return remote-device minor class
-     *
-     * @see #getRemoteClass
-     */
-    public synchronized String getRemoteMinorClass(String address) {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        if (!BluetoothDevice.checkBluetoothAddress(address)) {
-            return null;
-        }
-        return getRemoteMinorClassNative(address);
-    }
-    private native String getRemoteMinorClassNative(String address);
-
-    /**
-     * Gets the service classes of the specified device.
-     * Example: ["networking", "object transfer"]
-     *
-     * @return a String array with the descriptions of the service classes.
-     *
-     * @see #getRemoteClass
-     */
-    public synchronized String[] getRemoteServiceClasses(String address) {
-        mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        if (!BluetoothDevice.checkBluetoothAddress(address)) {
-            return null;
-        }
-        return getRemoteServiceClassesNative(address);
-    }
-    private native String[] getRemoteServiceClassesNative(String address);
-
-    /**
      * Gets the remote major, minor, and service classes encoded as a 32-bit
      * integer.
      *
@@ -1188,16 +959,6 @@
                 Settings.System.AIRPLANE_MODE_ON, 0) == 1;
     }
 
-    private static final String DISABLE_ESCO_PATH = "/sys/module/sco/parameters/disable_esco";
-    private static void disableEsco() {
-        try {
-            FileWriter file = new FileWriter(DISABLE_ESCO_PATH);
-            file.write("Y");
-            file.close();
-        } catch (FileNotFoundException e) {
-        } catch (IOException e) {}
-    }
-
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
         if (mIsEnabled) {
@@ -1248,6 +1009,34 @@
         pw.println("\nmIsAirplaneSensitive = " + mIsAirplaneSensitive);
     }
 
+    /* package */ static int bluezStringToScanMode(String mode) {
+        if (mode == null) {
+            return BluetoothError.ERROR;
+        }
+        mode = mode.toLowerCase();
+        if (mode.equals("off")) {
+            return BluetoothDevice.SCAN_MODE_NONE;
+        } else if (mode.equals("connectable")) {
+            return BluetoothDevice.SCAN_MODE_CONNECTABLE;
+        } else if (mode.equals("discoverable")) {
+            return BluetoothDevice.SCAN_MODE_CONNECTABLE_DISCOVERABLE;
+        } else {
+            return BluetoothError.ERROR;
+        }
+    }
+
+    /* package */ static String scanModeToBluezString(int mode) {
+        switch (mode) {
+        case BluetoothDevice.SCAN_MODE_NONE:
+            return "off";
+        case BluetoothDevice.SCAN_MODE_CONNECTABLE:
+            return "connectable";
+        case BluetoothDevice.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
+            return "discoverable";
+        }
+        return null;
+    }
+
     private static void log(String msg) {
         Log.d(TAG, msg);
     }
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index 4f63f98..0f60fae 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -16,6 +16,7 @@
 
 package android.server;
 
+import android.bluetooth.BluetoothA2dp;
 import android.bluetooth.BluetoothClass;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothError;
@@ -114,9 +115,7 @@
 
     public synchronized void stop() {
         if (mThread != null) {
-
             mInterrupted = true;
-
             try {
                 mThread.join();
                 mThread = null;
@@ -130,104 +129,86 @@
         return mThread != null;
     }
 
-    public void onModeChanged(String mode) {
-        Intent intent = new Intent(BluetoothIntent.MODE_CHANGED_ACTION);
-        int intMode = BluetoothDevice.MODE_UNKNOWN;
-        if (mode.equalsIgnoreCase("off")) {
-            intMode = BluetoothDevice.MODE_OFF;
+    /*package*/ void onModeChanged(String bluezMode) {
+        int mode = BluetoothDeviceService.bluezStringToScanMode(bluezMode);
+        if (mode >= 0) {
+            Intent intent = new Intent(BluetoothIntent.SCAN_MODE_CHANGED_ACTION);
+            intent.putExtra(BluetoothIntent.SCAN_MODE, mode);
+            mContext.sendBroadcast(intent, BLUETOOTH_PERM);
         }
-        else if (mode.equalsIgnoreCase("connectable")) {
-            intMode = BluetoothDevice.MODE_CONNECTABLE;
-        }
-        else if (mode.equalsIgnoreCase("discoverable")) {
-            intMode = BluetoothDevice.MODE_DISCOVERABLE;
-        }
-        intent.putExtra(BluetoothIntent.MODE, intMode);
-        mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
 
-    public void onDiscoveryStarted() {
+    private void onDiscoveryStarted() {
         mBluetoothService.setIsDiscovering(true);
         Intent intent = new Intent(BluetoothIntent.DISCOVERY_STARTED_ACTION);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onDiscoveryCompleted() {
+    private void onDiscoveryCompleted() {
         mBluetoothService.setIsDiscovering(false);
         Intent intent = new Intent(BluetoothIntent.DISCOVERY_COMPLETED_ACTION);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
 
-    public void onPairingRequest() {
+    private void onPairingRequest() {
         Intent intent = new Intent(BluetoothIntent.PAIRING_REQUEST_ACTION);
         mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
     }
     
-    public void onPairingCancel() {
+    private void onPairingCancel() {
         Intent intent = new Intent(BluetoothIntent.PAIRING_CANCEL_ACTION);
         mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
     }
 
-    public void onRemoteDeviceFound(String address, int deviceClass, short rssi) {
+    private void onRemoteDeviceFound(String address, int deviceClass, short rssi) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_FOUND_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         intent.putExtra(BluetoothIntent.CLASS, deviceClass);
         intent.putExtra(BluetoothIntent.RSSI, rssi);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteDeviceDisappeared(String address) {
+    private void onRemoteDeviceDisappeared(String address) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_DISAPPEARED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteClassUpdated(String address, int deviceClass) {
+    private void onRemoteClassUpdated(String address, int deviceClass) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_CLASS_UPDATED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         intent.putExtra(BluetoothIntent.CLASS, deviceClass);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteDeviceConnected(String address) {
+    private void onRemoteDeviceConnected(String address) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_CONNECTED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteDeviceDisconnectRequested(String address) {
+    private void onRemoteDeviceDisconnectRequested(String address) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_DISCONNECT_REQUESTED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteDeviceDisconnected(String address) {
+    private void onRemoteDeviceDisconnected(String address) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_DEVICE_DISCONNECTED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteNameUpdated(String address, String name) {
+    private void onRemoteNameUpdated(String address, String name) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         intent.putExtra(BluetoothIntent.NAME, name);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteNameFailed(String address) {
+    private void onRemoteNameFailed(String address) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_NAME_FAILED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteNameChanged(String address, String name) {
+    private void onRemoteNameChanged(String address, String name) {
         Intent intent = new Intent(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         intent.putExtra(BluetoothIntent.NAME, name);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
-    public void onRemoteAliasChanged(String address, String alias) {
-        Intent intent = new Intent(BluetoothIntent.REMOTE_ALIAS_CHANGED_ACTION);
-        intent.putExtra(BluetoothIntent.ADDRESS, address);
-        intent.putExtra(BluetoothIntent.ALIAS, alias);
-        mContext.sendBroadcast(intent, BLUETOOTH_PERM);
-    }
-    public void onRemoteAliasCleared(String address) {
-        Intent intent = new Intent(BluetoothIntent.REMOTE_ALIAS_CLEARED_ACTION);
-        intent.putExtra(BluetoothIntent.ADDRESS, address);
-        mContext.sendBroadcast(intent, BLUETOOTH_PERM);
-    }
 
     private void onCreateBondingResult(String address, int result) {
         address = address.toUpperCase();
@@ -239,23 +220,23 @@
         }
     }
 
-    public void onBondingCreated(String address) {
+    private void onBondingCreated(String address) {
         mBluetoothService.getBondState().setBondState(address.toUpperCase(),
                                                       BluetoothDevice.BOND_BONDED);
     }
 
-    public void onBondingRemoved(String address) {
+    private void onBondingRemoved(String address) {
         mBluetoothService.getBondState().setBondState(address.toUpperCase(),
                 BluetoothDevice.BOND_NOT_BONDED, BluetoothDevice.UNBOND_REASON_REMOVED);
     }
 
-    public void onNameChanged(String name) {
+    private void onNameChanged(String name) {
         Intent intent = new Intent(BluetoothIntent.NAME_CHANGED_ACTION);
         intent.putExtra(BluetoothIntent.NAME, name);
         mContext.sendBroadcast(intent, BLUETOOTH_PERM);
     }
 
-    public void onPasskeyAgentRequest(String address, int nativeData) {
+    private void onPasskeyAgentRequest(String address, int nativeData) {
         address = address.toUpperCase();
         mPasskeyAgentRequestData.put(address, new Integer(nativeData));
 
@@ -284,14 +265,36 @@
         mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
     }
 
-    public void onPasskeyAgentCancel(String address) {
+    private void onPasskeyAgentCancel(String address) {
         address = address.toUpperCase();
         mPasskeyAgentRequestData.remove(address);
         Intent intent = new Intent(BluetoothIntent.PAIRING_CANCEL_ACTION);
         intent.putExtra(BluetoothIntent.ADDRESS, address);
         mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM);
         mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_NOT_BONDED,
-                                                      BluetoothDevice.UNBOND_REASON_CANCELLED);
+                                                      BluetoothDevice.UNBOND_REASON_AUTH_CANCELED);
+    }
+
+    private boolean onAuthAgentAuthorize(String address, String service, String uuid) {
+        boolean authorized = false;
+        if (service.endsWith("service_audio")) {
+            BluetoothA2dp a2dp = new BluetoothA2dp(mContext);
+            authorized = a2dp.getSinkPriority(address) > BluetoothA2dp.PRIORITY_OFF;
+            if (authorized) {
+                Log.i(TAG, "Allowing incoming A2DP connection from " + address);
+            } else {
+                Log.i(TAG, "Rejecting incoming A2DP connection from " + address);
+            }
+        } else {
+            Log.i(TAG, "Rejecting incoming " + service + " connection from " + address);
+        }
+        return authorized;
+    }
+
+    private void onAuthAgentCancel(String address, String service, String uuid) {
+        // We immediately response to DBUS Authorize() so this should not
+        // usually happen
+        log("onAuthAgentCancel(" + address + ", " + service + ", " + uuid + ")");
     }
 
     private void onGetRemoteServiceChannelResult(String address, int channel) {
diff --git a/core/java/android/server/checkin/CheckinProvider.java b/core/java/android/server/checkin/CheckinProvider.java
deleted file mode 100644
index 86ece4a..0000000
--- a/core/java/android/server/checkin/CheckinProvider.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.server.checkin;
-
-import android.content.ContentProvider;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.database.sqlite.SQLiteQueryBuilder;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.BaseColumns;
-import android.provider.Checkin;
-import android.util.Log;
-
-import java.io.File;
-
-/**
- * Content provider for the database used to store events and statistics
- * while they wait to be uploaded by the checkin service.
- */
-public class CheckinProvider extends ContentProvider {
-    /** Class identifier for logging. */
-    private static final String TAG = "CheckinProvider";
-
-    /** Filename of database (in /data directory). */
-    private static final String DATABASE_FILENAME = "checkin.db";
-
-    /** Version of database schema.  */
-    private static final int DATABASE_VERSION = 1;
-
-    /** Maximum number of events recorded. */
-    private static final int EVENT_LIMIT = 1000;
-
-    /** Maximum size of individual event data. */
-    private static final int EVENT_SIZE = 8192;
-
-    /** Maximum number of crashes recorded. */
-    private static final int CRASH_LIMIT = 25;
-
-    /** Maximum size of individual crashes recorded. */
-    private static final int CRASH_SIZE = 16384;
-
-    /** Permission required for access to the 'properties' database. */
-    private static final String PROPERTIES_PERMISSION =
-            "android.permission.ACCESS_CHECKIN_PROPERTIES";
-
-    /** Lock for stats read-modify-write update cycle (see {@link #insert}). */
-    private final Object mStatsLock = new Object();
-
-    /** The underlying SQLite database. */
-    private SQLiteOpenHelper mOpenHelper;
-
-    private static class OpenHelper extends SQLiteOpenHelper {
-        public OpenHelper(Context context) {
-            super(context, DATABASE_FILENAME, null, DATABASE_VERSION);
-
-            // The database used to live in /data/checkin.db.
-            File oldLocation = Environment.getDataDirectory();
-            File old = new File(oldLocation, DATABASE_FILENAME);
-            File file = context.getDatabasePath(DATABASE_FILENAME);
-
-            // Try to move the file to the new location.
-            // TODO: Remove this code before shipping.
-            if (old.exists() && !file.exists() && !old.renameTo(file)) {
-               Log.e(TAG, "Can't rename " + old + " to " + file);
-            }
-            if (old.exists() && !old.delete()) {
-               // Clean up the old data file in any case.
-               Log.e(TAG, "Can't remove " + old);
-            }
-        }
-
-        @Override
-        public void onCreate(SQLiteDatabase db) {
-            db.execSQL("CREATE TABLE " + Checkin.Events.TABLE_NAME + " (" +
-                    BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
-                    Checkin.Events.TAG + " TEXT NOT NULL," +
-                    Checkin.Events.VALUE + " TEXT DEFAULT \"\"," +
-                    Checkin.Events.DATE + " INTEGER NOT NULL)");
-
-            db.execSQL("CREATE INDEX events_index ON " +
-                    Checkin.Events.TABLE_NAME + " (" +
-                    Checkin.Events.TAG + ")");
-
-            db.execSQL("CREATE TABLE " + Checkin.Stats.TABLE_NAME + " (" +
-                    BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
-                    Checkin.Stats.TAG + " TEXT UNIQUE," +
-                    Checkin.Stats.COUNT + " INTEGER DEFAULT 0," +
-                    Checkin.Stats.SUM + " REAL DEFAULT 0.0)");
-
-            db.execSQL("CREATE TABLE " + Checkin.Crashes.TABLE_NAME + " (" +
-                    BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
-                    Checkin.Crashes.DATA + " TEXT NOT NULL," +
-                    Checkin.Crashes.LOGS + " TEXT)");
-
-            db.execSQL("CREATE TABLE " + Checkin.Properties.TABLE_NAME + " (" +
-                    BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
-                    Checkin.Properties.TAG + " TEXT UNIQUE ON CONFLICT REPLACE,"
-                    + Checkin.Properties.VALUE + " TEXT DEFAULT \"\")");
-        }
-
-        @Override
-        public void onUpgrade(SQLiteDatabase db, int old, int version) {
-            db.execSQL("DROP TABLE IF EXISTS " + Checkin.Events.TABLE_NAME);
-            db.execSQL("DROP TABLE IF EXISTS " + Checkin.Stats.TABLE_NAME);
-            db.execSQL("DROP TABLE IF EXISTS " + Checkin.Crashes.TABLE_NAME);
-            db.execSQL("DROP TABLE IF EXISTS " + Checkin.Properties.TABLE_NAME);
-            onCreate(db);
-        }
-    }
-
-    @Override public boolean onCreate() {
-        mOpenHelper = new OpenHelper(getContext());
-        return true;
-    }
-
-    @Override
-    public Cursor query(Uri uri, String[] select,
-            String where, String[] args, String sort) {
-        checkPermissions(uri);
-        SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
-        qb.setTables(uri.getPathSegments().get(0));
-        if (uri.getPathSegments().size() == 2) {
-            qb.appendWhere("_id=" + ContentUris.parseId(uri));
-        } else if (uri.getPathSegments().size() != 1) {
-            throw new IllegalArgumentException("Invalid query URI: " + uri);
-        }
-
-        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
-        Cursor cursor = qb.query(db, select, where, args, null, null, sort);
-        cursor.setNotificationUri(getContext().getContentResolver(), uri);
-        return cursor;
-    }
-
-    @Override
-    public Uri insert(Uri uri, ContentValues values) {
-        checkPermissions(uri);
-        if (uri.getPathSegments().size() != 1) {
-            throw new IllegalArgumentException("Invalid insert URI: " + uri);
-        }
-
-        long id;
-        String table = uri.getPathSegments().get(0);
-        if (Checkin.Events.TABLE_NAME.equals(table)) {
-            id = insertEvent(values);
-        } else if (Checkin.Stats.TABLE_NAME.equals(table)) {
-            id = insertStats(values);
-        } else if (Checkin.Crashes.TABLE_NAME.equals(table)) {
-            id = insertCrash(values);
-        } else {
-            id = mOpenHelper.getWritableDatabase().insert(table, null, values);
-        }
-
-        if (id < 0) {
-            return null;
-        } else {
-            uri = ContentUris.withAppendedId(uri, id);
-            getContext().getContentResolver().notifyChange(uri, null);
-            return uri;
-        }
-    }
-
-    /**
-     * Insert an entry into the events table.
-     * Trims old events from the table to keep the size bounded.
-     * @param values to insert
-     * @return the row ID of the new entry
-     */
-    private long insertEvent(ContentValues values) {
-        String value = values.getAsString(Checkin.Events.VALUE);
-        if (value != null && value.length() > EVENT_SIZE) {
-            // Event values are readable text, so they can be truncated.
-            value = value.substring(0, EVENT_SIZE - 3) + "...";
-            values.put(Checkin.Events.VALUE, value);
-        }
-
-        if (!values.containsKey(Checkin.Events.DATE)) {
-            values.put(Checkin.Events.DATE, System.currentTimeMillis());
-        }
-
-        // TODO: Make this more efficient; don't do it on every insert.
-        // Also, consider keeping the most recent instance of every tag,
-        // and possibly update a counter when events are deleted.
-
-        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        db.execSQL("DELETE FROM " +
-                Checkin.Events.TABLE_NAME + " WHERE " +
-                Checkin.Events._ID + " IN (SELECT " +
-                Checkin.Events._ID + " FROM " +
-                Checkin.Events.TABLE_NAME + " ORDER BY " +
-                Checkin.Events.DATE + " DESC LIMIT -1 OFFSET " +
-                (EVENT_LIMIT - 1) + ")");
-        return db.insert(Checkin.Events.TABLE_NAME, null, values);
-    }
-
-    /**
-     * Add an entry into the stats table.
-     * For statistics, instead of just inserting a row into the database,
-     * we add the count and sum values to the existing values (if any)
-     * for the specified tag.  This must be done with a lock held,
-     * to avoid a race condition during the read-modify-write update.
-     * @param values to insert
-     * @return the row ID of the modified entry
-     */
-    private long insertStats(ContentValues values) {
-        synchronized (mStatsLock) {
-            String tag = values.getAsString(Checkin.Stats.TAG);
-            if (tag == null) {
-                throw new IllegalArgumentException("Tag required:" + values);
-            }
-
-            // Look for existing values with this tag.
-            SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-            Cursor cursor = db.query(false,
-                    Checkin.Stats.TABLE_NAME,
-                    new String[] {
-                            Checkin.Stats._ID,
-                            Checkin.Stats.COUNT,
-                            Checkin.Stats.SUM
-                    },
-                    Checkin.Stats.TAG + "=?",
-                    new String[] { tag },
-                    null, null, null, null /* limit */);
-
-            try {
-                if (cursor == null || !cursor.moveToNext()) {
-                    // This is a new statistic, insert it directly.
-                    return db.insert(Checkin.Stats.TABLE_NAME, null, values);
-                } else {
-                    // Depend on SELECT column order to avoid getColumnIndex()
-                    long id = cursor.getLong(0);
-                    int count = cursor.getInt(1);
-                    double sum = cursor.getDouble(2);
-
-                    Integer countAdd = values.getAsInteger(Checkin.Stats.COUNT);
-                    if (countAdd != null) count += countAdd.intValue();
-
-                    Double sumAdd = values.getAsDouble(Checkin.Stats.SUM);
-                    if (sumAdd != null) sum += sumAdd.doubleValue();
-
-                    if (count <= 0 && sum == 0.0) {
-                        // Updated to nothing: delete the row!
-                        cursor.deleteRow();
-                        getContext().getContentResolver().notifyChange(
-                                ContentUris.withAppendedId(Checkin.Stats.CONTENT_URI, id), null);
-                        return -1;
-                    } else {
-                        if (countAdd != null) cursor.updateInt(1, count);
-                        if (sumAdd != null) cursor.updateDouble(2, sum);
-                        cursor.commitUpdates();
-                        return id;
-                    }
-                }
-            } finally {
-                // Always clean up the cursor.
-                if (cursor != null) cursor.close();
-            }
-        }
-    }
-
-    /**
-     * Add an entry into the crashes table.
-     * @param values to insert
-     * @return the row ID of the modified entry
-     */
-    private long insertCrash(ContentValues values) {
-        try {
-            int crashSize = values.getAsString(Checkin.Crashes.DATA).length();
-            if (crashSize > CRASH_SIZE) {
-                // The crash is too big.  Don't report it, but do log a stat.
-                Checkin.updateStats(getContext().getContentResolver(),
-                        Checkin.Stats.Tag.CRASHES_TRUNCATED, 1, 0.0);
-                throw new IllegalArgumentException("Too big: " + crashSize);
-            }
-
-            // Count the number of crashes reported, even if they roll over.
-            Checkin.updateStats(getContext().getContentResolver(),
-                    Checkin.Stats.Tag.CRASHES_REPORTED, 1, 0.0);
-
-            // Trim the crashes database, if needed.
-            SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-            db.execSQL("DELETE FROM " +
-                    Checkin.Crashes.TABLE_NAME + " WHERE " +
-                    Checkin.Crashes._ID + " IN (SELECT " +
-                    Checkin.Crashes._ID + " FROM " +
-                    Checkin.Crashes.TABLE_NAME + " ORDER BY " +
-                    Checkin.Crashes._ID + " DESC LIMIT -1 OFFSET " +
-                    (CRASH_LIMIT - 1) + ")");
-
-            return db.insert(Checkin.Crashes.TABLE_NAME, null, values);
-        } catch (Throwable t) {
-            // To avoid an infinite crash-reporting loop, swallow the error.
-            Log.e("CheckinProvider", "Error inserting crash: " + t);
-            return -1;
-        }
-    }
-
-    // TODO: optimize bulkInsert, especially for stats?
-
-    @Override
-    public int update(Uri uri, ContentValues values,
-            String where, String[] args) {
-        checkPermissions(uri);
-        if (uri.getPathSegments().size() == 2) {
-            if (where != null && where.length() > 0) {
-                throw new UnsupportedOperationException(
-                        "WHERE clause not supported for update: " + uri);
-            }
-            where = "_id=" + ContentUris.parseId(uri);
-            args = null;
-        } else if (uri.getPathSegments().size() != 1) {
-            throw new IllegalArgumentException("Invalid update URI: " + uri);
-        }
-
-        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        int count = db.update(uri.getPathSegments().get(0), values, where, args);
-        getContext().getContentResolver().notifyChange(uri, null);
-        return count;
-    }
-
-    @Override
-    public int delete(Uri uri, String where, String[] args) {
-        checkPermissions(uri);
-        if (uri.getPathSegments().size() == 2) {
-            if (where != null && where.length() > 0) {
-                throw new UnsupportedOperationException(
-                        "WHERE clause not supported for delete: " + uri);
-            }
-            where = "_id=" + ContentUris.parseId(uri);
-            args = null;
-        } else if (uri.getPathSegments().size() != 1) {
-            throw new IllegalArgumentException("Invalid delete URI: " + uri);
-        }
-
-        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        int count = db.delete(uri.getPathSegments().get(0), where, args);
-        getContext().getContentResolver().notifyChange(uri, null);
-        return count;
-    }
-
-    @Override
-    public String getType(Uri uri) {
-        if (uri.getPathSegments().size() == 1) {
-            return "vnd.android.cursor.dir/" + uri.getPathSegments().get(0);
-        } else if (uri.getPathSegments().size() == 2) {
-            return "vnd.android.cursor.item/" + uri.getPathSegments().get(0);
-        } else {
-            throw new IllegalArgumentException("Invalid URI: " + uri);
-        }
-    }
-
-    /**
-     * Make sure the caller has permission to the database.
-     * @param uri the caller is requesting access to
-     * @throws SecurityException if the caller is forbidden.
-     */
-    private void checkPermissions(Uri uri) {
-        if (uri.getPathSegments().size() < 1) {
-            throw new IllegalArgumentException("Invalid query URI: " + uri);
-        }
-
-        String table = uri.getPathSegments().get(0);
-        if (table.equals(Checkin.Properties.TABLE_NAME) &&
-            getContext().checkCallingOrSelfPermission(PROPERTIES_PERMISSION) !=
-                PackageManager.PERMISSION_GRANTED) {
-            throw new SecurityException("Cannot access checkin properties");
-        }
-    }
-}
diff --git a/core/java/android/server/checkin/FallbackCheckinService.java b/core/java/android/server/checkin/FallbackCheckinService.java
deleted file mode 100644
index 65921af..0000000
--- a/core/java/android/server/checkin/FallbackCheckinService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.server.checkin;
-
-import android.os.ICheckinService;
-import android.os.RemoteException;
-import android.os.IParentalControlCallback;
-import com.google.android.net.ParentalControlState;
-
-/**
- * @hide
- */
-public final class FallbackCheckinService extends ICheckinService.Stub {
-    public FallbackCheckinService() {
-    }
-
-    public void reportCrashSync(byte[] crashData) throws RemoteException {
-    }
-
-    public void reportCrashAsync(byte[] crashData) throws RemoteException {
-    }
-
-    public void masterClear() throws RemoteException {
-    }
-
-    public void getParentalControlState(IParentalControlCallback p) throws RemoteException {
-        ParentalControlState state = new ParentalControlState();
-        state.isEnabled = false;
-        p.onResult(state);
-    }
-    
-    public void getParentalControlState(IParentalControlCallback p, String requestingApp)
-            throws android.os.RemoteException {
-    }
-}
diff --git a/core/java/android/server/checkin/package.html b/core/java/android/server/checkin/package.html
deleted file mode 100644
index 1c9bf9d..0000000
--- a/core/java/android/server/checkin/package.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<html>
-<body>
-    {@hide}
-</body>
-</html>
diff --git a/core/java/android/server/search/SearchableInfo.java b/core/java/android/server/search/SearchableInfo.java
index c8f395e..c18675e 100644
--- a/core/java/android/server/search/SearchableInfo.java
+++ b/core/java/android/server/search/SearchableInfo.java
@@ -86,6 +86,16 @@
     private String mSuggestProviderPackage = null;
     private Context mCacheActivityContext = null;   // use during setup only - don't hold memory!
     
+    // Flag values for Searchable_voiceSearchMode
+    private static int VOICE_SEARCH_SHOW_BUTTON = 1;
+    private static int VOICE_SEARCH_LAUNCH_WEB_SEARCH = 2;
+    private static int VOICE_SEARCH_LAUNCH_RECOGNIZER = 4;
+    private int mVoiceSearchMode = 0;
+    private int mVoiceLanguageModeId;       // voiceLanguageModel
+    private int mVoicePromptTextId;         // voicePromptText
+    private int mVoiceLanguageId;           // voiceLanguage
+    private int mVoiceMaxResults;           // voiceMaxResults
+    
     /**
      * Set the default searchable activity (when none is specified).
      */
@@ -420,7 +430,7 @@
             mSearchInputType = a.getInt(com.android.internal.R.styleable.Searchable_inputType, 
                     InputType.TYPE_CLASS_TEXT |
                     InputType.TYPE_TEXT_FLAG_SEARCH |
-                    InputType.TYPE_TEXT_VARIATION_SEARCH_STRING);
+                    InputType.TYPE_TEXT_VARIATION_NORMAL);
 
             setSearchModeFlags();
             if (DBG_INHIBIT_SUGGESTIONS == 0) {
@@ -435,6 +445,18 @@
                 mSuggestIntentData = a.getString(
                         com.android.internal.R.styleable.Searchable_searchSuggestIntentData);
             }
+            mVoiceSearchMode = 
+                a.getInt(com.android.internal.R.styleable.Searchable_voiceSearchMode, 0);
+            // TODO this didn't work - came back zero from YouTube
+            mVoiceLanguageModeId = 
+                a.getResourceId(com.android.internal.R.styleable.Searchable_voiceLanguageModel, 0);
+            mVoicePromptTextId = 
+                a.getResourceId(com.android.internal.R.styleable.Searchable_voicePromptText, 0);
+            mVoiceLanguageId = 
+                a.getResourceId(com.android.internal.R.styleable.Searchable_voiceLanguage, 0);
+            mVoiceMaxResults = 
+                a.getInt(com.android.internal.R.styleable.Searchable_voiceMaxResults, 0);
+
             a.recycle();
 
             // get package info for suggestions provider (if any)
@@ -462,11 +484,6 @@
      * Convert searchmode to flags.
      */
     private void setSearchModeFlags() {
-        // decompose searchMode attribute
-        // TODO How do I reconcile these hardcoded values with the flag bits defined in
-        // in attrs.xml?  e.g. android.R.id.filterMode = 0x010200a4 instead of just "1"
-    /*  mFilterMode = (0 != (mSearchMode & 1));  */
-    /*  mQuickStart = (0 != (mSearchMode & 2));  */
         mBadgeLabel = (0 != (mSearchMode & 4));
         mBadgeIcon = (0 != (mSearchMode & 8)) && (mIconId != 0);
         mQueryRewriteFromData = (0 != (mSearchMode & 0x10));
@@ -654,6 +671,59 @@
     }
     
     /**
+     * @return true if android:voiceSearchMode="showVoiceSearchButton"
+     */
+    public boolean getVoiceSearchEnabled() {
+        return 0 != (mVoiceSearchMode & VOICE_SEARCH_SHOW_BUTTON);
+    }
+    
+    /**
+     * @return true if android:voiceSearchMode="launchWebSearch"
+     */
+    public boolean getVoiceSearchLaunchWebSearch() {
+        return 0 != (mVoiceSearchMode & VOICE_SEARCH_LAUNCH_WEB_SEARCH);
+    }
+    
+    /**
+     * @return true if android:voiceSearchMode="launchRecognizer"
+     */
+    public boolean getVoiceSearchLaunchRecognizer() {
+        return 0 != (mVoiceSearchMode & VOICE_SEARCH_LAUNCH_RECOGNIZER);
+    }
+    
+    /**
+     * @return the resource Id of the language model string, if specified in the searchable
+     * activity's metadata, or 0 if not specified.  
+     */
+    public int getVoiceLanguageModeId() {
+        return mVoiceLanguageModeId;
+    }
+    
+    /**
+     * @return the resource Id of the voice prompt text string, if specified in the searchable
+     * activity's metadata, or 0 if not specified.  
+     */
+    public int getVoicePromptTextId() {
+        return mVoicePromptTextId;
+    }
+    
+    /**
+     * @return the resource Id of the spoken langauge, if specified in the searchable
+     * activity's metadata, or 0 if not specified.  
+     */
+    public int getVoiceLanguageId() {
+        return mVoiceLanguageId;
+    }
+    
+    /**
+     * @return the max results count, if specified in the searchable
+     * activity's metadata, or 0 if not specified.  
+     */
+    public int getVoiceMaxResults() {
+        return mVoiceMaxResults;
+    }
+    
+    /**
      * Return the resource Id of replacement text for the "Search" button.
      * 
      * @return Returns the resource Id, or 0 if not specified by this package.
@@ -727,6 +797,12 @@
         }
         
         mSuggestProviderPackage = in.readString();
+        
+        mVoiceSearchMode = in.readInt();
+        mVoiceLanguageModeId = in.readInt();
+        mVoicePromptTextId = in.readInt();
+        mVoiceLanguageId = in.readInt();
+        mVoiceMaxResults = in.readInt();
     }
 
     public int describeContents() {
@@ -764,5 +840,11 @@
         }
         
         dest.writeString(mSuggestProviderPackage);
+
+        dest.writeInt(mVoiceSearchMode);
+        dest.writeInt(mVoiceLanguageModeId);
+        dest.writeInt(mVoicePromptTextId);
+        dest.writeInt(mVoiceLanguageId);
+        dest.writeInt(mVoiceMaxResults);
     }
 }
diff --git a/core/java/android/speech/RecognizerIntent.java b/core/java/android/speech/RecognizerIntent.java
index abbf8a7..987e763 100644
--- a/core/java/android/speech/RecognizerIntent.java
+++ b/core/java/android/speech/RecognizerIntent.java
@@ -22,8 +22,6 @@
 
 /**
  * Constants for supporting speech recognition through starting an {@link Intent}
- * 
- * @hide {pending API council review}
  */
 public class RecognizerIntent {
     private RecognizerIntent() {
@@ -32,7 +30,8 @@
 
     /**
      * Starts an activity that will prompt the user for speech and sends it through a
-     * speech recognizer.
+     * speech recognizer.  The results will be returned via activity results, or forwarded
+     * via a PendingIntent if one is provided.
      * 
      * <p>Required extras:
      * <ul>
@@ -41,9 +40,11 @@
      * 
      * <p>Optional extras:
      * <ul>
-     *   <li>{@link Intent#EXTRA_PROMPT}
+     *   <li>{@link #EXTRA_PROMPT}
      *   <li>{@link #EXTRA_LANGUAGE}
      *   <li>{@link #EXTRA_MAX_RESULTS}
+     *   <li>{@link #EXTRA_RESULTS_PENDINGINTENT}
+     *   <li>{@link #EXTRA_RESULTS_PENDINGINTENT_BUNDLE}
      * </ul>
      * 
      * <p> Result extras:
@@ -57,6 +58,32 @@
     public static final String ACTION_RECOGNIZE_SPEECH = "android.speech.action.RECOGNIZE_SPEECH";
 
     /**
+     * Starts an activity that will prompt the user for speech, sends it through a
+     * speech recognizer, and invokes and displays a web search result.
+     * 
+     * <p>Required extras:
+     * <ul>
+     *   <li>{@link #EXTRA_LANGUAGE_MODEL}
+     * </ul>
+     * 
+     * <p>Optional extras:
+     * <ul>
+     *   <li>{@link #EXTRA_PROMPT}
+     *   <li>{@link #EXTRA_LANGUAGE}
+     *   <li>{@link #EXTRA_MAX_RESULTS}
+     * </ul>
+     * 
+     * <p> Result extras:
+     * <ul>
+     *   <li>{@link #EXTRA_RESULTS}
+     * </ul>
+     * 
+     * <p>NOTE: There may not be any applications installed to handle this action, so you should
+     * make sure to catch {@link ActivityNotFoundException}.
+     */
+    public static final String ACTION_WEB_SEARCH = "android.speech.action.WEB_SEARCH";
+
+    /**
      * Informs the recognizer which speech model to prefer when performing
      * {@link #ACTION_RECOGNIZE_SPEECH}. The recognizer uses this
      * information to fine tune the results. This extra is required. Activities implementing
@@ -65,27 +92,51 @@
      *  @see #LANGUAGE_MODEL_FREE_FORM
      *  @see #LANGUAGE_MODEL_WEB_SEARCH
      */
-    public static final String EXTRA_LANGUAGE_MODEL = "language_model";
+    public static final String EXTRA_LANGUAGE_MODEL = "android.speech.extra.LANGUAGE_MODEL";
 
-    /** Free form speech recognition */
+    /** 
+     * Use a language model based on free-form speech recognition.  This is a value to use for 
+     * {@link #EXTRA_LANGUAGE_MODEL}. 
+     * @see #EXTRA_LANGUAGE_MODEL
+     */
     public static final String LANGUAGE_MODEL_FREE_FORM = "free_form";
-    /** Use a language model based on web search terms */
+    /** 
+     * Use a language model based on web search terms.  This is a value to use for 
+     * {@link #EXTRA_LANGUAGE_MODEL}. 
+     * @see #EXTRA_LANGUAGE_MODEL
+     */
     public static final String LANGUAGE_MODEL_WEB_SEARCH = "web_search";
 
     /** Optional text prompt to show to the user when asking them to speak. */
-    public static final String EXTRA_PROMPT = "prompt";
+    public static final String EXTRA_PROMPT = "android.speech.extra.PROMPT";
 
     /**
      * Optional language override to inform the recognizer that it should expect speech in
      * a language different than the one set in the {@link java.util.Locale#getDefault()}. 
      */
-    public static final String EXTRA_LANGUAGE = "lang";
+    public static final String EXTRA_LANGUAGE = "android.speech.extra.LANGUAGE";
 
     /** 
      * Optional limit on the maximum number of results to return. If omitted the recognizer
      * will choose how many results to return. Must be an integer.
      */
-    public static final String EXTRA_MAX_RESULTS = "max_results";
+    public static final String EXTRA_MAX_RESULTS = "android.speech.extra.MAX_RESULTS";
+    
+    /**
+     * When the intent is {@link #ACTION_RECOGNIZE_SPEECH}, the speech input activity will
+     * return results to you via the activity results mechanism.  Alternatively, if you use this
+     * extra to supply a PendingIntent, the results will be added to its bundle and the 
+     * PendingIntent will be sent to its target.
+     */
+    public static final String EXTRA_RESULTS_PENDINGINTENT = 
+            "android.speech.extra.RESULTS_PENDINGINTENT";
+    /**
+     * If you use {@link #EXTRA_RESULTS_PENDINGINTENT} to supply a forwarding intent, you can
+     * also use this extra to supply additional extras for the final intent.  The search results
+     * will be added to this bundle, and the combined bundle will be sent to the target.
+     */
+    public static final String EXTRA_RESULTS_PENDINGINTENT_BUNDLE = 
+            "android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE";
 
     /** Result code returned when no matches are found for the given speech */
     public static final int RESULT_NO_MATCH = Activity.RESULT_FIRST_USER;
@@ -102,5 +153,5 @@
      * An ArrayList<String> of the potential results when performing
      * {@link #ACTION_RECOGNIZE_SPEECH}. Only present when {@link Activity#RESULT_OK} is returned.
      */
-    public static final String EXTRA_RESULTS = "results";
+    public static final String EXTRA_RESULTS = "android.speech.extra.RESULTS";
 }
diff --git a/core/java/android/text/Annotation.java b/core/java/android/text/Annotation.java
index a3812a8..dbc290b 100644
--- a/core/java/android/text/Annotation.java
+++ b/core/java/android/text/Annotation.java
@@ -16,20 +16,40 @@
 
 package android.text;
 
+import android.os.Parcel;
+
 /**
  * Annotations are simple key-value pairs that are preserved across
  * TextView save/restore cycles and can be used to keep application-specific
  * data that needs to be maintained for regions of text.
  */
-public class Annotation {
-    private String mKey;
-    private String mValue;
+public class Annotation implements ParcelableSpan {
+    private final String mKey;
+    private final String mValue;
 
     public Annotation(String key, String value) {
         mKey = key;
         mValue = value;
     }
 
+    public Annotation(Parcel src) {
+        mKey = src.readString();
+        mValue = src.readString();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.ANNOTATION;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(mKey);
+        dest.writeString(mValue);
+    }
+
     public String getKey() {
         return mKey;
     }
diff --git a/core/java/android/text/Html.java b/core/java/android/text/Html.java
index 90f5e4c..8495714 100644
--- a/core/java/android/text/Html.java
+++ b/core/java/android/text/Html.java
@@ -700,7 +700,41 @@
     }
 
     public void characters(char ch[], int start, int length) throws SAXException {
-        mSpannableStringBuilder.append(CharBuffer.wrap(ch, start, length));
+        StringBuilder sb = new StringBuilder();
+
+        /*
+         * Ignore whitespace that immediately follows other whitespace;
+         * newlines count as spaces.
+         */
+
+        for (int i = 0; i < length; i++) {
+            char c = ch[i + start];
+
+            if (c == ' ' || c == '\n') {
+                char pred;
+                int len = sb.length();
+
+                if (len == 0) {
+                    len = mSpannableStringBuilder.length();
+
+                    if (len == 0) {
+                        pred = '\n';
+                    } else {
+                        pred = mSpannableStringBuilder.charAt(len - 1);
+                    }
+                } else {
+                    pred = sb.charAt(len - 1);
+                }
+
+                if (pred != ' ' && pred != '\n') {
+                    sb.append(' ');
+                }
+            } else {
+                sb.append(c);
+            }
+        }
+
+        mSpannableStringBuilder.append(sb);
     }
 
     public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
diff --git a/core/java/android/text/InputType.java b/core/java/android/text/InputType.java
index bd86834..a073cf4 100644
--- a/core/java/android/text/InputType.java
+++ b/core/java/android/text/InputType.java
@@ -116,14 +116,22 @@
     
     /**
      * Flag for {@link #TYPE_CLASS_TEXT}: multiple lines of text can be
-     * entered into the field.
+     * entered into the field.  If this flag is not set, the text field 
+     * will be constrained to a single line.
      */
     public static final int TYPE_TEXT_FLAG_MULTI_LINE = 0x00020000;
     
     /**
+     * Flag for {@link #TYPE_CLASS_TEXT}: the regular text view associated
+     * with this should not be multi-line, but when a fullscreen input method
+     * is providing text it should use multiple lines if it can.
+     */
+    public static final int TYPE_TEXT_FLAG_IME_MULTI_LINE = 0x00040000;
+    
+    /**
      * Flag for {@link #TYPE_CLASS_TEXT}: flags any text being used as a search string
      */
-    public static final int TYPE_TEXT_FLAG_SEARCH = 0x00040000;
+    public static final int TYPE_TEXT_FLAG_SEARCH = 0x00080000;
     
     // ----------------------------------------------------------------------
     
@@ -149,30 +157,31 @@
     public static final int TYPE_TEXT_VARIATION_EMAIL_SUBJECT = 0x00000030;
     
     /**
-     * Variation of {@link #TYPE_CLASS_TEXT}: entering the content of
-     * an e-mail.
+     * Variation of {@link #TYPE_CLASS_TEXT}: entering a short, possibly informal
+     * message such as an instant message or a text message.
      */
-    public static final int TYPE_TEXT_VARIATION_EMAIL_CONTENT = 0x00000040;
+    public static final int TYPE_TEXT_VARIATION_SHORT_MESSAGE = 0x00000040;
     
     /**
+     * Variation of {@link #TYPE_CLASS_TEXT}: entering the content of a long, possibly 
+     * formal message such as the body of an e-mail.
+     */
+    public static final int TYPE_TEXT_VARIATION_LONG_MESSAGE = 0x00000050;
+
+    /**
      * Variation of {@link #TYPE_CLASS_TEXT}: entering the name of a person.
      */
-    public static final int TYPE_TEXT_VARIATION_PERSON_NAME = 0x00000050;
+    public static final int TYPE_TEXT_VARIATION_PERSON_NAME = 0x00000060;
     
     /**
      * Variation of {@link #TYPE_CLASS_TEXT}: entering a postal mailing address.
      */
-    public static final int TYPE_TEXT_VARIATION_POSTAL_ADDRESS = 0x00000060;
+    public static final int TYPE_TEXT_VARIATION_POSTAL_ADDRESS = 0x00000070;
     
     /**
      * Variation of {@link #TYPE_CLASS_TEXT}: entering a password.
      */
-    public static final int TYPE_TEXT_VARIATION_PASSWORD = 0x00000070;
-    
-    /**
-     * Variation of {@link #TYPE_CLASS_TEXT}: entering a simple text search (e.g. web search)
-     */
-    public static final int TYPE_TEXT_VARIATION_SEARCH_STRING = 0x00000080;
+    public static final int TYPE_TEXT_VARIATION_PASSWORD = 0x00000080;
     
     /**
      * Variation of {@link #TYPE_CLASS_TEXT}: entering text inside of a web form.
diff --git a/core/java/android/text/NoCopySpan.java b/core/java/android/text/NoCopySpan.java
new file mode 100644
index 0000000..0855c0b
--- /dev/null
+++ b/core/java/android/text/NoCopySpan.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.text;
+
+/**
+ * This interface should be added to a span object that should not be copied
+ * into a new Spenned when performing a slice or copy operation on the original
+ * Spanned it was placed in.
+ */
+public interface NoCopySpan {
+    /**
+     * Convenience equivalent for when you would just want a new Object() for
+     * a span but want it to be no-copy.  Use this instead.
+     */
+    public class Concrete implements NoCopySpan {
+    }
+}
diff --git a/core/java/android/text/ParcelableSpan.java b/core/java/android/text/ParcelableSpan.java
new file mode 100644
index 0000000..224511a
--- /dev/null
+++ b/core/java/android/text/ParcelableSpan.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.text;
+
+import android.os.Parcelable;
+
+/**
+ * A special kind of Parcelable for objects that will serve as text spans.
+ * This can only be used by code in the framework; it is not intended for
+ * applications to implement their own Parcelable spans.
+ */
+public interface ParcelableSpan extends Parcelable {
+    /**
+     * Return a special type identifier for this span class.
+     */
+    public abstract int getSpanTypeId();
+}
diff --git a/core/java/android/text/Selection.java b/core/java/android/text/Selection.java
index 44469ec..bb98bce 100644
--- a/core/java/android/text/Selection.java
+++ b/core/java/android/text/Selection.java
@@ -72,7 +72,7 @@
     
         if (ostart != start || oend != stop) {
             text.setSpan(SELECTION_START, start, start,
-                         Spanned.SPAN_POINT_POINT);
+                         Spanned.SPAN_POINT_POINT|Spanned.SPAN_INTERMEDIATE);
             text.setSpan(SELECTION_END, stop, stop,
                          Spanned.SPAN_POINT_POINT);
         }
@@ -417,8 +417,8 @@
         }
     }
 
-    private static final class START { };
-    private static final class END { };
+    private static final class START implements NoCopySpan { };
+    private static final class END implements NoCopySpan { };
     
     /*
      * Public constants
diff --git a/core/java/android/text/SpanWatcher.java b/core/java/android/text/SpanWatcher.java
index f99882a..01e82c8 100644
--- a/core/java/android/text/SpanWatcher.java
+++ b/core/java/android/text/SpanWatcher.java
@@ -21,7 +21,7 @@
  * will be called to notify it that other markup objects have been
  * added, changed, or removed.
  */
-public interface SpanWatcher {
+public interface SpanWatcher extends NoCopySpan {
     /**
      * This method is called to notify you that the specified object
      * has been attached to the specified range of the text.
diff --git a/core/java/android/text/SpannableStringBuilder.java b/core/java/android/text/SpannableStringBuilder.java
index 223ce2f..caaafa1 100644
--- a/core/java/android/text/SpannableStringBuilder.java
+++ b/core/java/android/text/SpannableStringBuilder.java
@@ -70,6 +70,10 @@
             Object[] spans = sp.getSpans(start, end, Object.class);
 
             for (int i = 0; i < spans.length; i++) {
+                if (spans[i] instanceof NoCopySpan) {
+                    continue;
+                }
+                
                 int st = sp.getSpanStart(spans[i]) - start;
                 int en = sp.getSpanEnd(spans[i]) - start;
                 int fl = sp.getSpanFlags(spans[i]);
diff --git a/core/java/android/text/Spanned.java b/core/java/android/text/Spanned.java
index bd0a16b..154497d 100644
--- a/core/java/android/text/Spanned.java
+++ b/core/java/android/text/Spanned.java
@@ -106,6 +106,14 @@
     public static final int SPAN_COMPOSING = 0x100;
     
     /**
+     * This flag will be set for intermediate span changes, meaning there
+     * is guaranteed to be another change following it.  Typically it is
+     * used for {@link Selection} which automatically uses this with the first
+     * offset it sets when updating the selection.
+     */
+    public static final int SPAN_INTERMEDIATE = 0x200;
+    
+    /**
      * The bits numbered SPAN_USER_SHIFT and above are available
      * for callers to use to store scalar data associated with their
      * span object.
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index ceb9f4f..0fef40b 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -576,7 +576,28 @@
                         if (fmbottom > fitbottom)
                             fitbottom = fmbottom;
 
-                        if (c == ' ' || c == '\t') {
+                        /*
+                         * From the Unicode Line Breaking Algorithm:
+                         * (at least approximately)
+                         *  
+                         * .,:; are class IS: breakpoints
+                         *      except when adjacent to digits
+                         * /    is class SY: a breakpoint
+                         *      except when followed by a digit.
+                         * -    is class HY: a breakpoint
+                         *      except when followed by a digit.
+                         *
+                         * Ideographs are class ID: breakpoints when adjacent.
+                         */
+
+                        if (c == ' ' || c == '\t' ||
+                            ((c == '.'  || c == ',' || c == ':' || c == ';') &&
+                             (j - 1 < here || !Character.isDigit(chs[j - 1 - start])) &&
+                             (j + 1 >= next || !Character.isDigit(chs[j + 1 - start]))) ||
+                            ((c == '/' || c == '-') &&
+                             (j + 1 >= next || !Character.isDigit(chs[j + 1 - start]))) ||
+                            (c >= FIRST_CJK && isIdeographic(c) &&
+                             j + 1 < next && isIdeographic(chs[j + 1 - start]))) {
                             okwidth = w;
                             ok = j + 1;
 
@@ -592,6 +613,11 @@
                     } else if (breakOnlyAtSpaces) {
                         if (ok != here) {
                             // Log.e("text", "output ok " + here + " to " +ok);
+
+                            while (ok < next && chs[ok - start] == ' ') {
+                                ok++;
+                            }
+
                             v = out(source,
                                     here, ok,
                                     okascent, okdescent, oktop, okbottom,
@@ -623,6 +649,11 @@
                     } else {
                         if (ok != here) {
                             // Log.e("text", "output ok " + here + " to " +ok);
+
+                            while (ok < next && chs[ok - start] == ' ') {
+                                ok++;
+                            }
+
                             v = out(source,
                                     here, ok,
                                     okascent, okdescent, oktop, okbottom,
@@ -739,6 +770,51 @@
         }
     }
 
+    private static final char FIRST_CJK = '\u2E80';
+    /**
+     * Returns true if the specified character is one of those specified
+     * as being Ideographic (class ID) by the Unicode Line Breaking Algorithm
+     * (http://www.unicode.org/unicode/reports/tr14/), and is therefore OK
+     * to break between a pair of.
+     */
+    private static final boolean isIdeographic(char c) {
+        if (c >= '\u2E80' && c <= '\u2FFF') {
+            return true; // CJK, KANGXI RADICALS, DESCRIPTION SYMBOLS
+        }
+        if (c == '\u3000') {
+            return true; // IDEOGRAPHIC SPACE
+        }
+        if (c >= '\u3040' && c <= '\u309F') {
+            return true; // Hiragana (except small characters)
+        }
+        if (c >= '\u30A0' && c <= '\u30FF') {
+            return true; // Katakana (except small characters)
+        }
+        if (c >= '\u3400' && c <= '\u4DB5') {
+            return true; // CJK UNIFIED IDEOGRAPHS EXTENSION A
+        }
+        if (c >= '\u4E00' && c <= '\u9FBB') {
+            return true; // CJK UNIFIED IDEOGRAPHS
+        }
+        if (c >= '\uF900' && c <= '\uFAD9') {
+            return true; // CJK COMPATIBILITY IDEOGRAPHS
+        }
+        if (c >= '\uA000' && c <= '\uA48F') {
+            return true; // YI SYLLABLES
+        }
+        if (c >= '\uA490' && c <= '\uA4CF') {
+            return true; // YI RADICALS
+        }
+        if (c >= '\uFE62' && c <= '\uFE66') {
+            return true; // SMALL PLUS SIGN to SMALL EQUALS SIGN
+        }
+        if (c >= '\uFF10' && c <= '\uFF19') {
+            return true; // WIDE DIGITS
+        }
+
+        return false;
+    }
+
 /*
     private static void dump(byte[] data, int count, String label) {
         if (false) {
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index 405d934..5b4c380 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -236,6 +236,13 @@
         return match;
     }
 
+    /**
+     * Create a new String object containing the given range of characters
+     * from the source string.  This is different than simply calling
+     * {@link CharSequence#subSequence(int, int) CharSequence.subSequence}
+     * in that it does not preserve any style runs in the source sequence,
+     * allowing a more efficient implementation.
+     */
     public static String substring(CharSequence source, int start, int end) {
         if (source instanceof String)
             return ((String) source).substring(start, end);
@@ -447,13 +454,26 @@
 
     /**
      * Returns true if a and b are equal, including if they are both null.
-     *
+     * <p><i>Note: In platform versions 1.1 and earlier, this method only worked well if
+     * both the arguments were instances of String.</i></p>
      * @param a first CharSequence to check
      * @param b second CharSequence to check
      * @return true if a and b are equal
      */
     public static boolean equals(CharSequence a, CharSequence b) {
-        return a == b || (a != null && a.equals(b));
+        if (a == b) return true;
+        int length;
+        if (a != null && b != null && (length = a.length()) == b.length()) {
+            if (a instanceof String && b instanceof String) {
+                return a.equals(b);
+            } else {
+                for (int i = 0; i < length; i++) {
+                    if (a.charAt(i) != b.charAt(i)) return false;
+                }
+                return true;
+            }
+        }
+        return false;
     }
 
     // XXX currently this only reverses chars, not spans
@@ -510,24 +530,42 @@
         private int mEnd;
     }
 
-    private static final int ALIGNMENT_SPAN = 1;
-    private static final int FOREGROUND_COLOR_SPAN = 2;
-    private static final int RELATIVE_SIZE_SPAN = 3;
-    private static final int SCALE_X_SPAN = 4;
-    private static final int STRIKETHROUGH_SPAN = 5;
-    private static final int UNDERLINE_SPAN = 6;
-    private static final int STYLE_SPAN = 7;
-    private static final int BULLET_SPAN = 8;
-    private static final int QUOTE_SPAN = 9;
-    private static final int LEADING_MARGIN_SPAN = 10;
-    private static final int URL_SPAN = 11;
-    private static final int BACKGROUND_COLOR_SPAN = 12;
-    private static final int TYPEFACE_SPAN = 13;
-    private static final int SUPERSCRIPT_SPAN = 14;
-    private static final int SUBSCRIPT_SPAN = 15;
-    private static final int ABSOLUTE_SIZE_SPAN = 16;
-    private static final int TEXT_APPEARANCE_SPAN = 17;
-    private static final int ANNOTATION = 18;
+    /** @hide */
+    public static final int ALIGNMENT_SPAN = 1;
+    /** @hide */
+    public static final int FOREGROUND_COLOR_SPAN = 2;
+    /** @hide */
+    public static final int RELATIVE_SIZE_SPAN = 3;
+    /** @hide */
+    public static final int SCALE_X_SPAN = 4;
+    /** @hide */
+    public static final int STRIKETHROUGH_SPAN = 5;
+    /** @hide */
+    public static final int UNDERLINE_SPAN = 6;
+    /** @hide */
+    public static final int STYLE_SPAN = 7;
+    /** @hide */
+    public static final int BULLET_SPAN = 8;
+    /** @hide */
+    public static final int QUOTE_SPAN = 9;
+    /** @hide */
+    public static final int LEADING_MARGIN_SPAN = 10;
+    /** @hide */
+    public static final int URL_SPAN = 11;
+    /** @hide */
+    public static final int BACKGROUND_COLOR_SPAN = 12;
+    /** @hide */
+    public static final int TYPEFACE_SPAN = 13;
+    /** @hide */
+    public static final int SUPERSCRIPT_SPAN = 14;
+    /** @hide */
+    public static final int SUBSCRIPT_SPAN = 15;
+    /** @hide */
+    public static final int ABSOLUTE_SIZE_SPAN = 16;
+    /** @hide */
+    public static final int TEXT_APPEARANCE_SPAN = 17;
+    /** @hide */
+    public static final int ANNOTATION = 18;
 
     /**
      * Flatten a CharSequence and whatever styles can be copied across processes
@@ -555,136 +593,10 @@
                     prop = ((CharacterStyle) prop).getUnderlying();
                 }
 
-                if (prop instanceof AlignmentSpan) {
-                    p.writeInt(ALIGNMENT_SPAN);
-                    p.writeString(((AlignmentSpan) prop).getAlignment().name());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof ForegroundColorSpan) {
-                    p.writeInt(FOREGROUND_COLOR_SPAN);
-                    p.writeInt(((ForegroundColorSpan) prop).getForegroundColor());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof RelativeSizeSpan) {
-                    p.writeInt(RELATIVE_SIZE_SPAN);
-                    p.writeFloat(((RelativeSizeSpan) prop).getSizeChange());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof ScaleXSpan) {
-                    p.writeInt(SCALE_X_SPAN);
-                    p.writeFloat(((ScaleXSpan) prop).getScaleX());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof StrikethroughSpan) {
-                    p.writeInt(STRIKETHROUGH_SPAN);
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof UnderlineSpan) {
-                    p.writeInt(UNDERLINE_SPAN);
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof StyleSpan) {
-                    p.writeInt(STYLE_SPAN);
-                    p.writeInt(((StyleSpan) prop).getStyle());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof LeadingMarginSpan) {
-                    if (prop instanceof BulletSpan) {
-                        p.writeInt(BULLET_SPAN);
-                        writeWhere(p, sp, o);
-                    } else if (prop instanceof QuoteSpan) {
-                        p.writeInt(QUOTE_SPAN);
-                        p.writeInt(((QuoteSpan) prop).getColor());
-                        writeWhere(p, sp, o);
-                    } else {
-                        p.writeInt(LEADING_MARGIN_SPAN);
-                        p.writeInt(((LeadingMarginSpan) prop).
-                                           getLeadingMargin(true));
-                        p.writeInt(((LeadingMarginSpan) prop).
-                                           getLeadingMargin(false));
-                        writeWhere(p, sp, o);
-                    }
-                }
-
-                if (prop instanceof URLSpan) {
-                    p.writeInt(URL_SPAN);
-                    p.writeString(((URLSpan) prop).getURL());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof BackgroundColorSpan) {
-                    p.writeInt(BACKGROUND_COLOR_SPAN);
-                    p.writeInt(((BackgroundColorSpan) prop).getBackgroundColor());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof TypefaceSpan) {
-                    p.writeInt(TYPEFACE_SPAN);
-                    p.writeString(((TypefaceSpan) prop).getFamily());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof SuperscriptSpan) {
-                    p.writeInt(SUPERSCRIPT_SPAN);
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof SubscriptSpan) {
-                    p.writeInt(SUBSCRIPT_SPAN);
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof AbsoluteSizeSpan) {
-                    p.writeInt(ABSOLUTE_SIZE_SPAN);
-                    p.writeInt(((AbsoluteSizeSpan) prop).getSize());
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof TextAppearanceSpan) {
-                    TextAppearanceSpan tas = (TextAppearanceSpan) prop;
-                    p.writeInt(TEXT_APPEARANCE_SPAN);
-
-                    String tf = tas.getFamily();
-                    if (tf != null) {
-                        p.writeInt(1);
-                        p.writeString(tf);
-                    } else {
-                        p.writeInt(0);
-                    }
-
-                    p.writeInt(tas.getTextStyle());
-                    p.writeInt(tas.getTextSize());
-
-                    ColorStateList csl = tas.getTextColor();
-                    if (csl == null) {
-                        p.writeInt(0);
-                    } else {
-                        p.writeInt(1);
-                        csl.writeToParcel(p, parcelableFlags);
-                    }
-
-                    csl = tas.getLinkTextColor();
-                    if (csl == null) {
-                        p.writeInt(0);
-                    } else {
-                        p.writeInt(1);
-                        csl.writeToParcel(p, parcelableFlags);
-                    }
-
-                    writeWhere(p, sp, o);
-                }
-
-                if (prop instanceof Annotation) {
-                    p.writeInt(ANNOTATION);
-                    p.writeString(((Annotation) prop).getKey());
-                    p.writeString(((Annotation) prop).getValue());
+                if (prop instanceof ParcelableSpan) {
+                    ParcelableSpan ps = (ParcelableSpan)prop;
+                    p.writeInt(ps.getSpanTypeId());
+                    ps.writeToParcel(p, parcelableFlags);
                     writeWhere(p, sp, o);
                 }
             }
@@ -707,8 +619,7 @@
     }
 
     public static final Parcelable.Creator<CharSequence> CHAR_SEQUENCE_CREATOR
-            = new Parcelable.Creator<CharSequence>()
-    {
+            = new Parcelable.Creator<CharSequence>() {
         /**
          * Read and return a new CharSequence, possibly with styles,
          * from the parcel.
@@ -729,89 +640,75 @@
 
                 switch (kind) {
                 case ALIGNMENT_SPAN:
-                    readSpan(p, sp, new AlignmentSpan.Standard(
-                            Layout.Alignment.valueOf(p.readString())));
+                    readSpan(p, sp, new AlignmentSpan.Standard(p));
                     break;
 
                 case FOREGROUND_COLOR_SPAN:
-                    readSpan(p, sp, new ForegroundColorSpan(p.readInt()));
+                    readSpan(p, sp, new ForegroundColorSpan(p));
                     break;
 
                 case RELATIVE_SIZE_SPAN:
-                    readSpan(p, sp, new RelativeSizeSpan(p.readFloat()));
+                    readSpan(p, sp, new RelativeSizeSpan(p));
                     break;
 
                 case SCALE_X_SPAN:
-                    readSpan(p, sp, new ScaleXSpan(p.readFloat()));
+                    readSpan(p, sp, new ScaleXSpan(p));
                     break;
 
                 case STRIKETHROUGH_SPAN:
-                    readSpan(p, sp, new StrikethroughSpan());
+                    readSpan(p, sp, new StrikethroughSpan(p));
                     break;
 
                 case UNDERLINE_SPAN:
-                    readSpan(p, sp, new UnderlineSpan());
+                    readSpan(p, sp, new UnderlineSpan(p));
                     break;
 
                 case STYLE_SPAN:
-                    readSpan(p, sp, new StyleSpan(p.readInt()));
+                    readSpan(p, sp, new StyleSpan(p));
                     break;
 
                 case BULLET_SPAN:
-                    readSpan(p, sp, new BulletSpan());
+                    readSpan(p, sp, new BulletSpan(p));
                     break;
 
                 case QUOTE_SPAN:
-                    readSpan(p, sp, new QuoteSpan(p.readInt()));
+                    readSpan(p, sp, new QuoteSpan(p));
                     break;
 
                 case LEADING_MARGIN_SPAN:
-                    readSpan(p, sp, new LeadingMarginSpan.Standard(p.readInt(),
-                                                                   p.readInt()));
+                    readSpan(p, sp, new LeadingMarginSpan.Standard(p));
                 break;
 
                 case URL_SPAN:
-                    readSpan(p, sp, new URLSpan(p.readString()));
+                    readSpan(p, sp, new URLSpan(p));
                     break;
 
                 case BACKGROUND_COLOR_SPAN:
-                    readSpan(p, sp, new BackgroundColorSpan(p.readInt()));
+                    readSpan(p, sp, new BackgroundColorSpan(p));
                     break;
 
                 case TYPEFACE_SPAN:
-                    readSpan(p, sp, new TypefaceSpan(p.readString()));
+                    readSpan(p, sp, new TypefaceSpan(p));
                     break;
 
                 case SUPERSCRIPT_SPAN:
-                    readSpan(p, sp, new SuperscriptSpan());
+                    readSpan(p, sp, new SuperscriptSpan(p));
                     break;
 
                 case SUBSCRIPT_SPAN:
-                    readSpan(p, sp, new SubscriptSpan());
+                    readSpan(p, sp, new SubscriptSpan(p));
                     break;
 
                 case ABSOLUTE_SIZE_SPAN:
-                    readSpan(p, sp, new AbsoluteSizeSpan(p.readInt()));
+                    readSpan(p, sp, new AbsoluteSizeSpan(p));
                     break;
 
                 case TEXT_APPEARANCE_SPAN:
-                    readSpan(p, sp, new TextAppearanceSpan(
-                        p.readInt() != 0
-                            ? p.readString()
-                            : null,
-                        p.readInt(), // style
-                        p.readInt(), // size
-                        p.readInt() != 0
-                            ? ColorStateList.CREATOR.createFromParcel(p)
-                            : null,
-                        p.readInt() != 0
-                            ? ColorStateList.CREATOR.createFromParcel(p)
-                            : null));
+                    readSpan(p, sp, new TextAppearanceSpan(p));
                     break;
 
                 case ANNOTATION:
-                    readSpan(p, sp,
-                             new Annotation(p.readString(), p.readString()));
+                    readSpan(p, sp, new Annotation(p));
                     break;
 
                 default:
diff --git a/core/java/android/text/TextWatcher.java b/core/java/android/text/TextWatcher.java
index 7456b28..bad09f2 100644
--- a/core/java/android/text/TextWatcher.java
+++ b/core/java/android/text/TextWatcher.java
@@ -20,7 +20,7 @@
  * When an object of a type is attached to an Editable, its methods will
  * be called when the text is changed.
  */
-public interface TextWatcher {
+public interface TextWatcher extends NoCopySpan {
     /**
      * This method is called to notify you that, within <code>s</code>,
      * the <code>count</code> characters beginning at <code>start</code>
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java
index 73adedf..0dc96c3 100644
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -27,6 +27,7 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
+import java.util.Locale;
 import java.util.TimeZone;
 import java.text.SimpleDateFormat;
 
@@ -188,6 +189,12 @@
      */
     public  static final char    YEAR                   =    'y';
 
+
+    private static final Object sLocaleLock = new Object();
+    private static Locale sIs24HourLocale;
+    private static boolean sIs24Hour;
+
+
     /**
      * Returns true if user preference is set to 24-hour format.
      * @param context the context to use for the content resolver
@@ -198,20 +205,34 @@
                 Settings.System.TIME_12_24);
 
         if (value == null) {
+            Locale locale = context.getResources().getConfiguration().locale;
+
+            synchronized (sLocaleLock) {
+                if (sIs24HourLocale != null && sIs24HourLocale.equals(locale)) {
+                    return sIs24Hour;
+                }
+            }
+
             java.text.DateFormat natural =
                 java.text.DateFormat.getTimeInstance(
-                    java.text.DateFormat.LONG,
-                    context.getResources().getConfiguration().locale);
+                    java.text.DateFormat.LONG, locale);
 
             if (natural instanceof SimpleDateFormat) {
                 SimpleDateFormat sdf = (SimpleDateFormat) natural;
                 String pattern = sdf.toPattern();
 
                 if (pattern.indexOf('H') >= 0) {
-                    return true;
+                    value = "24";
                 } else {
-                    return false;
+                    value = "12";
                 }
+            } else {
+                value = "12";
+            }
+
+            synchronized (sLocaleLock) {
+                sIs24HourLocale = locale;
+                sIs24Hour = !value.equals("12");
             }
         }
 
diff --git a/core/java/android/text/method/ArrowKeyMovementMethod.java b/core/java/android/text/method/ArrowKeyMovementMethod.java
index 7457439..a559b9d 100644
--- a/core/java/android/text/method/ArrowKeyMovementMethod.java
+++ b/core/java/android/text/method/ArrowKeyMovementMethod.java
@@ -131,6 +131,16 @@
     }
 
     public boolean onKeyDown(TextView widget, Spannable buffer, int keyCode, KeyEvent event) {
+        if (executeDown(widget, buffer, keyCode)) {
+            MetaKeyKeyListener.adjustMetaAfterKeypress(buffer);
+            MetaKeyKeyListener.resetLockedMeta(buffer);
+            return true;
+        }
+
+        return false;
+    }
+
+    private boolean executeDown(TextView widget, Spannable buffer, int keyCode) {
         boolean handled = false;
 
         switch (keyCode) {
@@ -170,6 +180,26 @@
         return false;
     }
 
+    public boolean onKeyOther(TextView view, Spannable text, KeyEvent event) {
+        int code = event.getKeyCode();
+        if (code != KeyEvent.KEYCODE_UNKNOWN
+                && event.getAction() == KeyEvent.ACTION_MULTIPLE) {
+            int repeat = event.getRepeatCount();
+            boolean first = true;
+            boolean handled = false;
+            while ((--repeat) > 0) {
+                if (first && executeDown(view, text, code)) {
+                    handled = true;
+                    MetaKeyKeyListener.adjustMetaAfterKeypress(text);
+                    MetaKeyKeyListener.resetLockedMeta(text);
+                }
+                first = false;
+            }
+            return handled;
+        }
+        return false;
+    }
+    
     public boolean onTrackballEvent(TextView widget, Spannable text,
             MotionEvent event) {
         return false;
diff --git a/core/java/android/text/method/BaseKeyListener.java b/core/java/android/text/method/BaseKeyListener.java
index a875368..6df6a3a 100644
--- a/core/java/android/text/method/BaseKeyListener.java
+++ b/core/java/android/text/method/BaseKeyListener.java
@@ -18,7 +18,6 @@
 
 import android.view.KeyEvent;
 import android.view.View;
-import android.text.InputType;
 import android.text.*;
 import android.text.method.TextKeyListener.Capitalize;
 import android.widget.TextView;
@@ -26,7 +25,7 @@
 public abstract class BaseKeyListener
 extends MetaKeyKeyListener
 implements KeyListener {
-    /* package */ static final Object OLD_SEL_START = new Object();
+    /* package */ static final Object OLD_SEL_START = new NoCopySpan.Concrete();
 
     /**
      * Performs the action that happens when you press the DEL key in
@@ -127,5 +126,35 @@
         
         return super.onKeyDown(view, content, keyCode, event);
     }
+    
+    /**
+     * Base implementation handles ACTION_MULTIPLE KEYCODE_UNKNOWN by inserting
+     * the event's text into the content.
+     */
+    public boolean onKeyOther(View view, Editable content, KeyEvent event) {
+        if (event.getAction() != KeyEvent.ACTION_MULTIPLE
+                || event.getKeyCode() != KeyEvent.KEYCODE_UNKNOWN) {
+            // Not something we are interested in.
+            return false;
+        }
+        
+        int selStart, selEnd;
+
+        {
+            int a = Selection.getSelectionStart(content);
+            int b = Selection.getSelectionEnd(content);
+
+            selStart = Math.min(a, b);
+            selEnd = Math.max(a, b);
+        }
+
+        CharSequence text = event.getCharacters();
+        if (text == null) {
+            return false;
+        }
+        
+        content.replace(selStart, selEnd, text);
+        return true;
+    }
 }
 
diff --git a/core/java/android/text/method/KeyListener.java b/core/java/android/text/method/KeyListener.java
index 4ae6191..8594852 100644
--- a/core/java/android/text/method/KeyListener.java
+++ b/core/java/android/text/method/KeyListener.java
@@ -66,6 +66,13 @@
                            int keyCode, KeyEvent event);
     
     /**
+     * If the key listener wants to other kinds of key events, return true,
+     * otherwise return false and the caller (i.e. the widget host)
+     * will handle the key.
+     */
+    public boolean onKeyOther(View view, Editable text, KeyEvent event);
+    
+    /**
      * Remove the given shift states from the edited text.
      */
     public void clearMetaKeyState(View view, Editable content, int states);
diff --git a/core/java/android/text/method/LinkMovementMethod.java b/core/java/android/text/method/LinkMovementMethod.java
index 92ac531..22e9cc6 100644
--- a/core/java/android/text/method/LinkMovementMethod.java
+++ b/core/java/android/text/method/LinkMovementMethod.java
@@ -252,5 +252,5 @@
     }
 
     private static LinkMovementMethod sInstance;
-    private static Object FROM_BELOW = new Object();
+    private static Object FROM_BELOW = new NoCopySpan.Concrete();
 }
diff --git a/core/java/android/text/method/MetaKeyKeyListener.java b/core/java/android/text/method/MetaKeyKeyListener.java
index d5a473b..d89fbec 100644
--- a/core/java/android/text/method/MetaKeyKeyListener.java
+++ b/core/java/android/text/method/MetaKeyKeyListener.java
@@ -71,10 +71,10 @@
             | META_SYM_LOCKED | META_SYM_USED
             | META_SYM_PRESSED | META_SYM_RELEASED;
     
-    private static final Object CAP = new Object();
-    private static final Object ALT = new Object();
-    private static final Object SYM = new Object();
-    private static final Object SELECTING = new Object();
+    private static final Object CAP = new NoCopySpan.Concrete();
+    private static final Object ALT = new NoCopySpan.Concrete();
+    private static final Object SYM = new NoCopySpan.Concrete();
+    private static final Object SELECTING = new NoCopySpan.Concrete();
 
     /**
      * Resets all meta state to inactive.
@@ -283,6 +283,10 @@
     }
 
     public void clearMetaKeyState(View view, Editable content, int states) {
+        clearMetaKeyState(content, states);
+    }
+
+    public static void clearMetaKeyState(Editable content, int states) {
         if ((states&META_SHIFT_ON) != 0) resetLock(content, CAP);
         if ((states&META_ALT_ON) != 0) resetLock(content, ALT);
         if ((states&META_SYM_ON) != 0) resetLock(content, SYM);
diff --git a/core/java/android/text/method/MovementMethod.java b/core/java/android/text/method/MovementMethod.java
index 9e37e59..29f67a1 100644
--- a/core/java/android/text/method/MovementMethod.java
+++ b/core/java/android/text/method/MovementMethod.java
@@ -26,6 +26,14 @@
     public void initialize(TextView widget, Spannable text);
     public boolean onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event);
     public boolean onKeyUp(TextView widget, Spannable text, int keyCode, KeyEvent event);
+    
+    /**
+     * If the key listener wants to other kinds of key events, return true,
+     * otherwise return false and the caller (i.e. the widget host)
+     * will handle the key.
+     */
+    public boolean onKeyOther(TextView view, Spannable text, KeyEvent event);
+    
     public void onTakeFocus(TextView widget, Spannable text, int direction);
     public boolean onTrackballEvent(TextView widget, Spannable text,
                                     MotionEvent event);
diff --git a/core/java/android/text/method/NumberKeyListener.java b/core/java/android/text/method/NumberKeyListener.java
index 348b658..e500fae 100644
--- a/core/java/android/text/method/NumberKeyListener.java
+++ b/core/java/android/text/method/NumberKeyListener.java
@@ -24,7 +24,6 @@
 import android.text.Spannable;
 import android.text.SpannableStringBuilder;
 import android.text.Spanned;
-import android.util.SparseIntArray;
 
 /**
  * For numeric text entry
diff --git a/core/java/android/text/method/PasswordTransformationMethod.java b/core/java/android/text/method/PasswordTransformationMethod.java
index edaa836..85adabd 100644
--- a/core/java/android/text/method/PasswordTransformationMethod.java
+++ b/core/java/android/text/method/PasswordTransformationMethod.java
@@ -22,6 +22,7 @@
 import android.view.View;
 import android.text.Editable;
 import android.text.GetChars;
+import android.text.NoCopySpan;
 import android.text.TextUtils;
 import android.text.TextWatcher;
 import android.text.Selection;
@@ -249,7 +250,8 @@
      * Used to stash a reference back to the View in the Editable so we
      * can use it to check the settings.
      */
-    private static class ViewReference extends WeakReference<View> {
+    private static class ViewReference extends WeakReference<View>
+            implements NoCopySpan {
         public ViewReference(View v) {
             super(v);
         }
diff --git a/core/java/android/text/method/QwertyKeyListener.java b/core/java/android/text/method/QwertyKeyListener.java
index 863b2e2..0b39517 100644
--- a/core/java/android/text/method/QwertyKeyListener.java
+++ b/core/java/android/text/method/QwertyKeyListener.java
@@ -16,18 +16,12 @@
 
 package android.text.method;
 
-import android.os.Message;
-import android.os.Handler;
 import android.text.*;
 import android.text.method.TextKeyListener.Capitalize;
 import android.util.SparseArray;
-import android.util.SparseIntArray;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.View;
-import android.widget.TextView;
-
-import java.util.HashMap;
 
 /**
  * This is the standard key listener for alphabetic input on qwerty
@@ -442,7 +436,7 @@
         return Character.toUpperCase(src.charAt(0)) + src.substring(1);
     }
 
-    /* package */ static class Replaced
+    /* package */ static class Replaced implements NoCopySpan
     {
         public Replaced(char[] text) {
             mText = text;
diff --git a/core/java/android/text/method/ScrollingMovementMethod.java b/core/java/android/text/method/ScrollingMovementMethod.java
index db470be..563ceed 100644
--- a/core/java/android/text/method/ScrollingMovementMethod.java
+++ b/core/java/android/text/method/ScrollingMovementMethod.java
@@ -144,6 +144,10 @@
     }
 
     public boolean onKeyDown(TextView widget, Spannable buffer, int keyCode, KeyEvent event) {
+        return executeDown(widget, buffer, keyCode);
+    }
+
+    private boolean executeDown(TextView widget, Spannable buffer, int keyCode) {
         boolean handled = false;
 
         switch (keyCode) {
@@ -171,6 +175,26 @@
         return false;
     }
 
+    public boolean onKeyOther(TextView view, Spannable text, KeyEvent event) {
+        int code = event.getKeyCode();
+        if (code != KeyEvent.KEYCODE_UNKNOWN
+                && event.getAction() == KeyEvent.ACTION_MULTIPLE) {
+            int repeat = event.getRepeatCount();
+            boolean first = true;
+            boolean handled = false;
+            while ((--repeat) > 0) {
+                if (first && executeDown(view, text, code)) {
+                    handled = true;
+                    MetaKeyKeyListener.adjustMetaAfterKeypress(text);
+                    MetaKeyKeyListener.resetLockedMeta(text);
+                }
+                first = false;
+            }
+            return handled;
+        }
+        return false;
+    }
+    
     public boolean onTrackballEvent(TextView widget, Spannable text,
             MotionEvent event) {
         return false;
diff --git a/core/java/android/text/method/SingleLineTransformationMethod.java b/core/java/android/text/method/SingleLineTransformationMethod.java
index a4fcf15..6a05fe4 100644
--- a/core/java/android/text/method/SingleLineTransformationMethod.java
+++ b/core/java/android/text/method/SingleLineTransformationMethod.java
@@ -27,22 +27,24 @@
 
 /**
  * This transformation method causes any newline characters (\n) to be
- * displayed as spaces instead of causing line breaks.
+ * displayed as spaces instead of causing line breaks, and causes
+ * carriage return characters (\r) to have no appearance.
  */
 public class SingleLineTransformationMethod
 extends ReplacementTransformationMethod {
-    private static char[] ORIGINAL = new char[] { '\n' };
-    private static char[] REPLACEMENT = new char[] { ' ' };
+    private static char[] ORIGINAL = new char[] { '\n', '\r' };
+    private static char[] REPLACEMENT = new char[] { ' ', '\uFEFF' };
 
     /**
-     * The character to be replaced is \n.
+     * The characters to be replaced are \n and \r.
      */
     protected char[] getOriginal() {
         return ORIGINAL;
     }
 
     /**
-     * The character \n is replaced with is space.
+     * The character \n is replaced with is space;
+     * the character \r is replaced with is FEFF (zero width space).
      */
     protected char[] getReplacement() {
         return REPLACEMENT;
diff --git a/core/java/android/text/method/TextKeyListener.java b/core/java/android/text/method/TextKeyListener.java
index b1c380a..5be2a48 100644
--- a/core/java/android/text/method/TextKeyListener.java
+++ b/core/java/android/text/method/TextKeyListener.java
@@ -38,10 +38,10 @@
     private static TextKeyListener[] sInstance =
         new TextKeyListener[Capitalize.values().length * 2];
 
-    /* package */ static final Object ACTIVE = new Object();
-    /* package */ static final Object CAPPED = new Object();
-    /* package */ static final Object INHIBIT_REPLACEMENT = new Object();
-    /* package */ static final Object LAST_TYPED = new Object();
+    /* package */ static final Object ACTIVE = new NoCopySpan.Concrete();
+    /* package */ static final Object CAPPED = new NoCopySpan.Concrete();
+    /* package */ static final Object INHIBIT_REPLACEMENT = new NoCopySpan.Concrete();
+    /* package */ static final Object LAST_TYPED = new NoCopySpan.Concrete();
 
     private Capitalize mAutoCap;
     private boolean mAutoText;
@@ -140,6 +140,13 @@
         return im.onKeyUp(view, content, keyCode, event);
     }
 
+    @Override
+    public boolean onKeyOther(View view, Editable content, KeyEvent event) {
+        KeyListener im = getKeyListener(event);
+
+        return im.onKeyOther(view, content, event);
+    }
+
     /**
      * Clear all the input state (autotext, autocap, multitap, undo)
      * from the specified Editable, going beyond Editable.clear(), which
@@ -205,6 +212,10 @@
             return false;
         }
 
+        public boolean onKeyOther(View view, Editable content, KeyEvent event) {
+            return false;
+        }
+
         public void clearMetaKeyState(View view, Editable content, int states) {
         }
         
diff --git a/core/java/android/text/method/Touch.java b/core/java/android/text/method/Touch.java
index 8b097c5..65036ad 100644
--- a/core/java/android/text/method/Touch.java
+++ b/core/java/android/text/method/Touch.java
@@ -17,6 +17,7 @@
 package android.text.method;
 
 import android.text.Layout;
+import android.text.NoCopySpan;
 import android.text.Layout.Alignment;
 import android.text.Spannable;
 import android.view.MotionEvent;
@@ -103,7 +104,7 @@
 
             if (ds.length > 0) {
                 if (ds[0].mFarEnough == false) {
-                    int slop = ViewConfiguration.getTouchSlop();
+                    int slop = ViewConfiguration.get(widget.getContext()).getScaledTouchSlop();
 
                     if (Math.abs(event.getX() - ds[0].mX) >= slop ||
                         Math.abs(event.getY() - ds[0].mY) >= slop) {
@@ -141,7 +142,7 @@
         return false;
     }
 
-    private static class DragState {
+    private static class DragState implements NoCopySpan {
         public float mX;
         public float mY;
         public boolean mFarEnough;
diff --git a/core/java/android/text/style/AbsoluteSizeSpan.java b/core/java/android/text/style/AbsoluteSizeSpan.java
index 8f6ed5a..484f8ce4 100644
--- a/core/java/android/text/style/AbsoluteSizeSpan.java
+++ b/core/java/android/text/style/AbsoluteSizeSpan.java
@@ -16,17 +16,35 @@
 
 package android.text.style;
 
-import android.graphics.Paint;
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class AbsoluteSizeSpan extends MetricAffectingSpan {
+public class AbsoluteSizeSpan extends MetricAffectingSpan implements ParcelableSpan {
 
-    private int mSize;
+    private final int mSize;
 
     public AbsoluteSizeSpan(int size) {
         mSize = size;
     }
 
+    public AbsoluteSizeSpan(Parcel src) {
+        mSize = src.readInt();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.ABSOLUTE_SIZE_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mSize);
+    }
+
     public int getSize() {
         return mSize;
     }
diff --git a/core/java/android/text/style/AlignmentSpan.java b/core/java/android/text/style/AlignmentSpan.java
index d51edcc..b8a37da 100644
--- a/core/java/android/text/style/AlignmentSpan.java
+++ b/core/java/android/text/style/AlignmentSpan.java
@@ -16,24 +16,40 @@
 
 package android.text.style;
 
+import android.os.Parcel;
 import android.text.Layout;
+import android.text.ParcelableSpan;
+import android.text.TextUtils;
 
-public interface AlignmentSpan
-extends ParagraphStyle
-{
+public interface AlignmentSpan extends ParagraphStyle {
     public Layout.Alignment getAlignment();
 
     public static class Standard
-    implements AlignmentSpan
-    {
+    implements AlignmentSpan, ParcelableSpan {
         public Standard(Layout.Alignment align) {
             mAlignment = align;
         }
 
+        public Standard(Parcel src) {
+            mAlignment = Layout.Alignment.valueOf(src.readString());
+        }
+        
+        public int getSpanTypeId() {
+            return TextUtils.ALIGNMENT_SPAN;
+        }
+        
+        public int describeContents() {
+            return 0;
+        }
+
+        public void writeToParcel(Parcel dest, int flags) {
+            dest.writeString(mAlignment.name());
+        }
+
         public Layout.Alignment getAlignment() {
             return mAlignment;
         }
 
-        private Layout.Alignment mAlignment;
+        private final Layout.Alignment mAlignment;
     }
 }
diff --git a/core/java/android/text/style/BackgroundColorSpan.java b/core/java/android/text/style/BackgroundColorSpan.java
index 27eda69..580a369 100644
--- a/core/java/android/text/style/BackgroundColorSpan.java
+++ b/core/java/android/text/style/BackgroundColorSpan.java
@@ -16,16 +16,36 @@
 
 package android.text.style;
 
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class BackgroundColorSpan extends CharacterStyle implements UpdateAppearance {
+public class BackgroundColorSpan extends CharacterStyle
+        implements UpdateAppearance, ParcelableSpan {
 
-    private int mColor;
+    private final int mColor;
 
 	public BackgroundColorSpan(int color) {
 		mColor = color;
 	}
 
+    public BackgroundColorSpan(Parcel src) {
+        mColor = src.readInt();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.BACKGROUND_COLOR_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mColor);
+    }
+
 	public int getBackgroundColor() {
 		return mColor;
 	}
diff --git a/core/java/android/text/style/BulletSpan.java b/core/java/android/text/style/BulletSpan.java
index 70c4d33..655bd81 100644
--- a/core/java/android/text/style/BulletSpan.java
+++ b/core/java/android/text/style/BulletSpan.java
@@ -18,17 +18,30 @@
 
 import android.graphics.Canvas;
 import android.graphics.Paint;
+import android.os.Parcel;
 import android.text.Layout;
+import android.text.ParcelableSpan;
 import android.text.Spanned;
+import android.text.TextUtils;
 
-public class BulletSpan implements LeadingMarginSpan {
+public class BulletSpan implements LeadingMarginSpan, ParcelableSpan {
+    private final int mGapWidth;
+    private final boolean mWantColor;
+    private final int mColor;
+
+    private static final int BULLET_RADIUS = 3;
+    public static final int STANDARD_GAP_WIDTH = 2;
 
     public BulletSpan() {
         mGapWidth = STANDARD_GAP_WIDTH;
+        mWantColor = false;
+        mColor = 0;
     }
 
     public BulletSpan(int gapWidth) {
         mGapWidth = gapWidth;
+        mWantColor = false;
+        mColor = 0;
     }
 
     public BulletSpan(int gapWidth, int color) {
@@ -37,6 +50,26 @@
         mColor = color;
     }
 
+    public BulletSpan(Parcel src) {
+        mGapWidth = src.readInt();
+        mWantColor = src.readInt() != 0;
+        mColor = src.readInt();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.BULLET_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mGapWidth);
+        dest.writeInt(mWantColor ? 1 : 0);
+        dest.writeInt(mColor);
+    }
+
     public int getLeadingMargin(boolean first) {
         return 2 * BULLET_RADIUS + mGapWidth;
     }
@@ -66,11 +99,4 @@
             p.setStyle(style);
         }
     }
-
-    private int mGapWidth;
-    private boolean mWantColor;
-    private int mColor;
-
-    private static final int BULLET_RADIUS = 3;
-    public static final int STANDARD_GAP_WIDTH = 2;
 }
diff --git a/core/java/android/text/style/ForegroundColorSpan.java b/core/java/android/text/style/ForegroundColorSpan.java
index 99b3381..476124d 100644
--- a/core/java/android/text/style/ForegroundColorSpan.java
+++ b/core/java/android/text/style/ForegroundColorSpan.java
@@ -16,16 +16,36 @@
 
 package android.text.style;
 
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class ForegroundColorSpan extends CharacterStyle implements UpdateAppearance {
+public class ForegroundColorSpan extends CharacterStyle
+        implements UpdateAppearance, ParcelableSpan {
 
-    private int mColor;
+    private final int mColor;
 
 	public ForegroundColorSpan(int color) {
 		mColor = color;
 	}
 
+    public ForegroundColorSpan(Parcel src) {
+        mColor = src.readInt();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.FOREGROUND_COLOR_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mColor);
+    }
+
 	public int getForegroundColor() {
 		return mColor;
 	}
diff --git a/core/java/android/text/style/LeadingMarginSpan.java b/core/java/android/text/style/LeadingMarginSpan.java
index 85a27dc..8e212e3 100644
--- a/core/java/android/text/style/LeadingMarginSpan.java
+++ b/core/java/android/text/style/LeadingMarginSpan.java
@@ -18,7 +18,10 @@
 
 import android.graphics.Paint;
 import android.graphics.Canvas;
+import android.os.Parcel;
 import android.text.Layout;
+import android.text.ParcelableSpan;
+import android.text.TextUtils;
 
 public interface LeadingMarginSpan
 extends ParagraphStyle
@@ -30,9 +33,9 @@
                                   CharSequence text, int start, int end,
                                   boolean first, Layout layout);
 
-    public static class Standard
-    implements LeadingMarginSpan
-    {
+    public static class Standard implements LeadingMarginSpan, ParcelableSpan {
+        private final int mFirst, mRest;
+        
         public Standard(int first, int rest) {
             mFirst = first;
             mRest = rest;
@@ -42,6 +45,24 @@
             this(every, every);
         }
 
+        public Standard(Parcel src) {
+            mFirst = src.readInt();
+            mRest = src.readInt();
+        }
+        
+        public int getSpanTypeId() {
+            return TextUtils.LEADING_MARGIN_SPAN;
+        }
+        
+        public int describeContents() {
+            return 0;
+        }
+
+        public void writeToParcel(Parcel dest, int flags) {
+            dest.writeInt(mFirst);
+            dest.writeInt(mRest);
+        }
+
         public int getLeadingMargin(boolean first) {
             return first ? mFirst : mRest;
         }
@@ -53,7 +74,5 @@
                                       boolean first, Layout layout) {
             ;
         }
-
-        private int mFirst, mRest;
     }
 }
diff --git a/core/java/android/text/style/QuoteSpan.java b/core/java/android/text/style/QuoteSpan.java
index 3f4a32f..29dd273 100644
--- a/core/java/android/text/style/QuoteSpan.java
+++ b/core/java/android/text/style/QuoteSpan.java
@@ -18,26 +18,43 @@
 
 import android.graphics.Paint;
 import android.graphics.Canvas;
-import android.graphics.RectF;
+import android.os.Parcel;
 import android.text.Layout;
+import android.text.ParcelableSpan;
+import android.text.TextUtils;
 
-public class QuoteSpan
-implements LeadingMarginSpan
-{
+public class QuoteSpan implements LeadingMarginSpan, ParcelableSpan {
     private static final int STRIPE_WIDTH = 2;
     private static final int GAP_WIDTH = 2;
 
-    private int mColor = 0xff0000ff;
+    private final int mColor;
 
     public QuoteSpan() {
         super();
+        mColor = 0xff0000ff;
     }
     
     public QuoteSpan(int color) {
-        this();
+        super();
         mColor = color;
     }
 
+    public QuoteSpan(Parcel src) {
+        mColor = src.readInt();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.QUOTE_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mColor);
+    }
+
     public int getColor() {
         return mColor;
     }
diff --git a/core/java/android/text/style/RelativeSizeSpan.java b/core/java/android/text/style/RelativeSizeSpan.java
index a8ad076..9717362 100644
--- a/core/java/android/text/style/RelativeSizeSpan.java
+++ b/core/java/android/text/style/RelativeSizeSpan.java
@@ -16,17 +16,35 @@
 
 package android.text.style;
 
-import android.graphics.Paint;
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class RelativeSizeSpan extends MetricAffectingSpan {
+public class RelativeSizeSpan extends MetricAffectingSpan implements ParcelableSpan {
 
-	private float mProportion;
+	private final float mProportion;
 
 	public RelativeSizeSpan(float proportion) {
 		mProportion = proportion;
 	}
 
+    public RelativeSizeSpan(Parcel src) {
+        mProportion = src.readFloat();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.RELATIVE_SIZE_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeFloat(mProportion);
+    }
+
 	public float getSizeChange() {
 		return mProportion;
 	}
diff --git a/core/java/android/text/style/ScaleXSpan.java b/core/java/android/text/style/ScaleXSpan.java
index ac9e35d..655064b 100644
--- a/core/java/android/text/style/ScaleXSpan.java
+++ b/core/java/android/text/style/ScaleXSpan.java
@@ -16,17 +16,35 @@
 
 package android.text.style;
 
-import android.graphics.Paint;
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class ScaleXSpan extends MetricAffectingSpan {
+public class ScaleXSpan extends MetricAffectingSpan implements ParcelableSpan {
 
-	private float mProportion;
+	private final float mProportion;
 
 	public ScaleXSpan(float proportion) {
 		mProportion = proportion;
 	}
 
+    public ScaleXSpan(Parcel src) {
+        mProportion = src.readFloat();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.SCALE_X_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeFloat(mProportion);
+    }
+
 	public float getScaleX() {
 		return mProportion;
 	}
diff --git a/core/java/android/text/style/StrikethroughSpan.java b/core/java/android/text/style/StrikethroughSpan.java
index dd430e5..b51363a 100644
--- a/core/java/android/text/style/StrikethroughSpan.java
+++ b/core/java/android/text/style/StrikethroughSpan.java
@@ -16,9 +16,29 @@
 
 package android.text.style;
 
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class StrikethroughSpan extends CharacterStyle implements UpdateAppearance {
+public class StrikethroughSpan extends CharacterStyle
+        implements UpdateAppearance, ParcelableSpan {
+    public StrikethroughSpan() {
+    }
+    
+    public StrikethroughSpan(Parcel src) {
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.STRIKETHROUGH_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+    }
 
 	@Override
 	public void updateDrawState(TextPaint ds) {
diff --git a/core/java/android/text/style/StyleSpan.java b/core/java/android/text/style/StyleSpan.java
index cc8b06c..8e6147c 100644
--- a/core/java/android/text/style/StyleSpan.java
+++ b/core/java/android/text/style/StyleSpan.java
@@ -18,7 +18,10 @@
 
 import android.graphics.Paint;
 import android.graphics.Typeface;
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
 /**
  * 
@@ -28,9 +31,9 @@
  * you get bold italic.  You can't turn off a style from the base style.
  *
  */
-public class StyleSpan extends MetricAffectingSpan {
+public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {
 
-	private int mStyle;
+	private final int mStyle;
 
 	/**
 	 * 
@@ -42,6 +45,22 @@
 		mStyle = style;
 	}
 
+    public StyleSpan(Parcel src) {
+        mStyle = src.readInt();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.STYLE_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(mStyle);
+    }
+
 	/**
 	 * Returns the style constant defined in {@link android.graphics.Typeface}. 
 	 */
diff --git a/core/java/android/text/style/SubscriptSpan.java b/core/java/android/text/style/SubscriptSpan.java
index 78d6ba9..de1d8b2 100644
--- a/core/java/android/text/style/SubscriptSpan.java
+++ b/core/java/android/text/style/SubscriptSpan.java
@@ -16,9 +16,29 @@
 
 package android.text.style;
 
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class SubscriptSpan extends MetricAffectingSpan {
+public class SubscriptSpan extends MetricAffectingSpan implements ParcelableSpan {
+    public SubscriptSpan() {
+    }
+    
+    public SubscriptSpan(Parcel src) {
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.SUBSCRIPT_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+    }
+
     @Override
     public void updateDrawState(TextPaint tp) {
         tp.baselineShift -= (int) (tp.ascent() / 2);
diff --git a/core/java/android/text/style/SuperscriptSpan.java b/core/java/android/text/style/SuperscriptSpan.java
index 79be4de..285fe84 100644
--- a/core/java/android/text/style/SuperscriptSpan.java
+++ b/core/java/android/text/style/SuperscriptSpan.java
@@ -16,9 +16,29 @@
 
 package android.text.style;
 
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class SuperscriptSpan extends MetricAffectingSpan {
+public class SuperscriptSpan extends MetricAffectingSpan implements ParcelableSpan {
+    public SuperscriptSpan() {
+    }
+    
+    public SuperscriptSpan(Parcel src) {
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.SUPERSCRIPT_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+    }
+
     @Override
     public void updateDrawState(TextPaint tp) {
         tp.baselineShift += (int) (tp.ascent() / 2);
diff --git a/core/java/android/text/style/TextAppearanceSpan.java b/core/java/android/text/style/TextAppearanceSpan.java
index c4ec976..de929e3 100644
--- a/core/java/android/text/style/TextAppearanceSpan.java
+++ b/core/java/android/text/style/TextAppearanceSpan.java
@@ -19,20 +19,22 @@
 import android.content.Context;
 import android.content.res.ColorStateList;
 import android.content.res.TypedArray;
-import android.graphics.Paint;
 import android.graphics.Typeface;
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
 /**
  * Sets the text color, size, style, and typeface to match a TextAppearance
  * resource.
  */
-public class TextAppearanceSpan extends MetricAffectingSpan {
-    private String mTypeface;
-    private int mStyle;
-    private int mTextSize;
-    private ColorStateList mTextColor;
-    private ColorStateList mTextColorLink;
+public class TextAppearanceSpan extends MetricAffectingSpan implements ParcelableSpan {
+    private final String mTypeface;
+    private final int mStyle;
+    private final int mTextSize;
+    private final ColorStateList mTextColor;
+    private final ColorStateList mTextColorLink;
 
     /**
      * Uses the specified TextAppearance resource to determine the
@@ -53,11 +55,13 @@
      */
     public TextAppearanceSpan(Context context, int appearance,
                               int colorList) {
+        ColorStateList textColor;
+        
         TypedArray a =
             context.obtainStyledAttributes(appearance,
                                            com.android.internal.R.styleable.TextAppearance);
 
-        mTextColor = a.getColorStateList(com.android.internal.R.styleable.
+        textColor = a.getColorStateList(com.android.internal.R.styleable.
                                         TextAppearance_textColor);
         mTextColorLink = a.getColorStateList(com.android.internal.R.styleable.
                                         TextAppearance_textColorLink);
@@ -79,6 +83,10 @@
             case 3:
                 mTypeface = "monospace";
                 break;
+                
+            default:
+                mTypeface = null;
+                break;
         }
 
         a.recycle();
@@ -87,9 +95,11 @@
             a = context.obtainStyledAttributes(com.android.internal.R.style.Theme,
                                             com.android.internal.R.styleable.Theme);
 
-            mTextColor = a.getColorStateList(colorList);
+            textColor = a.getColorStateList(colorList);
             a.recycle();
         }
+        
+        mTextColor = textColor;
     }
 
     /**
@@ -105,6 +115,48 @@
         mTextColorLink = linkColor;
     }
 
+    public TextAppearanceSpan(Parcel src) {
+        mTypeface = src.readString();
+        mStyle = src.readInt();
+        mTextSize = src.readInt();
+        if (src.readInt() != 0) {
+            mTextColor = ColorStateList.CREATOR.createFromParcel(src);
+        } else {
+            mTextColor = null;
+        }
+        if (src.readInt() != 0) {
+            mTextColorLink = ColorStateList.CREATOR.createFromParcel(src);
+        } else {
+            mTextColorLink = null;
+        }
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.TEXT_APPEARANCE_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(mTypeface);
+        dest.writeInt(mStyle);
+        dest.writeInt(mTextSize);
+        if (mTextColor != null) {
+            dest.writeInt(1);
+            mTextColor.writeToParcel(dest, flags);
+        } else {
+            dest.writeInt(0);
+        }
+        if (mTextColorLink != null) {
+            dest.writeInt(1);
+            mTextColorLink.writeToParcel(dest, flags);
+        } else {
+            dest.writeInt(0);
+        }
+    }
+
     /**
      * Returns the typeface family specified by this span, or <code>null</code>
      * if it does not specify one.
diff --git a/core/java/android/text/style/TypefaceSpan.java b/core/java/android/text/style/TypefaceSpan.java
index 7519ac2b..f194060 100644
--- a/core/java/android/text/style/TypefaceSpan.java
+++ b/core/java/android/text/style/TypefaceSpan.java
@@ -18,13 +18,16 @@
 
 import android.graphics.Paint;
 import android.graphics.Typeface;
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
 /**
  * Changes the typeface family of the text to which the span is attached.
  */
-public class TypefaceSpan extends MetricAffectingSpan {
-    private String mFamily;
+public class TypefaceSpan extends MetricAffectingSpan implements ParcelableSpan {
+    private final String mFamily;
 
     /**
      * @param family The font family for this typeface.  Examples include
@@ -34,6 +37,22 @@
         mFamily = family;
     }
 
+    public TypefaceSpan(Parcel src) {
+        mFamily = src.readString();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.TYPEFACE_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(mFamily);
+    }
+
     /**
      * Returns the font family name.
      */
diff --git a/core/java/android/text/style/URLSpan.java b/core/java/android/text/style/URLSpan.java
index 79809b5..f458611 100644
--- a/core/java/android/text/style/URLSpan.java
+++ b/core/java/android/text/style/URLSpan.java
@@ -18,17 +18,35 @@
 
 import android.content.Intent;
 import android.net.Uri;
-import android.text.TextPaint;
+import android.os.Parcel;
+import android.text.ParcelableSpan;
+import android.text.TextUtils;
 import android.view.View;
 
-public class URLSpan extends ClickableSpan {
+public class URLSpan extends ClickableSpan implements ParcelableSpan {
 
-    private String mURL;
+    private final String mURL;
 
     public URLSpan(String url) {
         mURL = url;
     }
 
+    public URLSpan(Parcel src) {
+        mURL = src.readString();
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.URL_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(mURL);
+    }
+
     public String getURL() {
         return mURL;
     }
diff --git a/core/java/android/text/style/UnderlineSpan.java b/core/java/android/text/style/UnderlineSpan.java
index ca6f10c5..b0cb0e8 100644
--- a/core/java/android/text/style/UnderlineSpan.java
+++ b/core/java/android/text/style/UnderlineSpan.java
@@ -16,9 +16,29 @@
 
 package android.text.style;
 
+import android.os.Parcel;
+import android.text.ParcelableSpan;
 import android.text.TextPaint;
+import android.text.TextUtils;
 
-public class UnderlineSpan extends CharacterStyle implements UpdateAppearance {
+public class UnderlineSpan extends CharacterStyle
+        implements UpdateAppearance, ParcelableSpan {
+    public UnderlineSpan() {
+    }
+    
+    public UnderlineSpan(Parcel src) {
+    }
+    
+    public int getSpanTypeId() {
+        return TextUtils.UNDERLINE_SPAN;
+    }
+    
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+    }
 
 	@Override
 	public void updateDrawState(TextPaint ds) {
diff --git a/core/java/android/text/util/Rfc822Validator.java b/core/java/android/text/util/Rfc822Validator.java
index 9f03bb0..6a6bf69 100644
--- a/core/java/android/text/util/Rfc822Validator.java
+++ b/core/java/android/text/util/Rfc822Validator.java
@@ -16,6 +16,7 @@
 
 package android.text.util;
 
+import android.text.TextUtils;
 import android.widget.AutoCompleteTextView;
 
 import java.util.regex.Pattern;
@@ -67,7 +68,7 @@
     
     /**
      * @return a string in which all the characters that are illegal for the username
-     * part of the email address have been removed.
+     * or the domain name part of the email address have been removed.
      */
     private String removeIllegalCharacters(String s) {
         StringBuilder result = new StringBuilder();
@@ -101,6 +102,9 @@
      * {@inheritDoc}
      */
     public CharSequence fixText(CharSequence cs) {
+        // Return an empty string if the email address only contains spaces, \n or \t
+        if (TextUtils.getTrimmedLength(cs) == 0) return "";
+
         Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(cs);
         StringBuilder sb = new StringBuilder();
 
@@ -111,10 +115,10 @@
                 // If there is no @, just append the domain of the account
                 tokens[i].setAddress(removeIllegalCharacters(text) + "@" + mDomain);
             } else {
-                // Otherwise, remove everything right of the '@' and append the domain
-                // ("a@b" becomes "a@gmail.com").
+                // Otherwise, remove the illegal characters on both sides of the '@'
                 String fix = removeIllegalCharacters(text.substring(0, index));
-                tokens[i].setAddress(fix + "@" + mDomain);
+                String domain = removeIllegalCharacters(text.substring(index + 1));
+                tokens[i].setAddress(fix + "@" + (domain.length() != 0 ? domain : mDomain));
             }
 
             sb.append(tokens[i].toString());
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java
index 8fc3602..9de4cbe 100644
--- a/core/java/android/util/DisplayMetrics.java
+++ b/core/java/android/util/DisplayMetrics.java
@@ -16,6 +16,8 @@
 
 package android.util;
 
+import android.os.*;
+
 
 /**
  * A structure describing general information about a display, such as its
@@ -23,6 +25,16 @@
  */
 public class DisplayMetrics {
     /**
+     * The reference density used throughout the system.
+     * 
+     * @hide Pending API council approval
+     */
+    public static final int DEFAULT_DENSITY = 160;
+
+    private static final int sLcdDensity = SystemProperties.getInt("ro.sf.lcd_density",
+            DEFAULT_DENSITY);
+
+    /**
      * The absolute width of the display in pixels.
      */
     public int widthPixels;
@@ -43,7 +55,9 @@
      * example, a 240x320 screen will have a density of 1 even if its width is 
      * 1.8", 1.3", etc. However, if the screen resolution is increased to 
      * 320x480 but the screen size remained 1.5"x2" then the density would be 
-     * increased (probably to 1.5). 
+     * increased (probably to 1.5).
+     *
+     * @see #DEFAULT_DENSITY
      */
     public float density;
     /**
@@ -60,7 +74,7 @@
      * The exact physical pixels per inch of the screen in the Y dimension.
      */
     public float ydpi;
-    
+
     public DisplayMetrics() {
     }
     
@@ -76,10 +90,9 @@
     public void setToDefaults() {
         widthPixels = 0;
         heightPixels = 0;
-        density = 1;
-        scaledDensity = 1;
-        xdpi = 160;
-        ydpi = 160;
+        density = sLcdDensity / (float) DEFAULT_DENSITY;
+        scaledDensity = density;
+        xdpi = sLcdDensity;
+        ydpi = sLcdDensity;
     }
 }
-
diff --git a/core/java/android/util/TypedValue.java b/core/java/android/util/TypedValue.java
index a4ee35a..d4ba9e2 100644
--- a/core/java/android/util/TypedValue.java
+++ b/core/java/android/util/TypedValue.java
@@ -16,9 +16,6 @@
 
 package android.util;
 
-import android.util.Config;
-import android.util.Log;
-
 /**
  * Container for a dynamically typed data value.  Primarily used with
  * {@link android.content.res.Resources} for holding resource values.
@@ -141,6 +138,16 @@
 
     /* ------------------------------------------------------------ */
 
+    /**
+     * If {@link #density} is equal to this value, then the density should be
+     * treated as the system's default density value: {@link DisplayMetrics#DEFAULT_DENSITY}.
+     *
+     * @hide Pending API council approval
+     */
+    public static final int DENSITY_DEFAULT = 0;
+
+    /* ------------------------------------------------------------ */
+
     /** The type held by this value, as defined by the constants here.
      *  This tells you how to interpret the other fields in the object. */
     public int type;
@@ -161,7 +168,14 @@
     /** If Value came from a resource, these are the configurations for which
      *  its contents can change. */
     public int changingConfigurations = -1;
-    
+
+    /**
+     * If the Value came from a resource, this holds the corresponding pixel density.
+     * 
+     * @hide Pending API council approval
+     * */
+    public int density;
+
     /* ------------------------------------------------------------ */
 
     /** Return the data for this value as a float.  Only use for values
@@ -454,6 +468,7 @@
         data = other.data;
         assetCookie = other.assetCookie;
         resourceId = other.resourceId;
+        density = other.density;
     }
 
     public String toString()
diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java
index 4048763..15fb839 100644
--- a/core/java/android/view/FocusFinder.java
+++ b/core/java/android/view/FocusFinder.java
@@ -397,7 +397,7 @@
 
         int numTouchables = touchables.size();
         
-        int edgeSlop = ViewConfiguration.getEdgeSlop();
+        int edgeSlop = ViewConfiguration.get(root.mContext).getScaledEdgeSlop();
         
         Rect closestBounds = new Rect();
         Rect touchableBounds = mOtherRect;
diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java
index fc9af05..a472689 100644
--- a/core/java/android/view/GestureDetector.java
+++ b/core/java/android/view/GestureDetector.java
@@ -18,6 +18,7 @@
 
 import android.os.Handler;
 import android.os.Message;
+import android.content.Context;
 
 /**
  * Detects various gestures and events using the supplied {@link MotionEvent}s.
@@ -34,7 +35,6 @@
  * </ul>
  */
 public class GestureDetector {
-
     /**
      * The listener that is used to notify when gestures occur.
      * If you want to listen for all the different gestures then implement
@@ -113,6 +113,14 @@
     }
 
     /**
+     * @hide pending API council
+     */
+    public interface OnDoubleTapListener {
+        boolean onSingleTapConfirmed(MotionEvent e);
+        boolean onDoubleTapEvent(MotionEvent e);
+    }
+    
+    /**
      * A convenience class to extend when you only want to listen for a
      * subset of all the gestures. This implements all methods in the
      * {@link OnGestureListener} but does nothing and return {@code false}
@@ -144,22 +152,40 @@
         }
     }
 
-    private static final int TOUCH_SLOP_SQUARE = ViewConfiguration.getTouchSlop()
-            * ViewConfiguration.getTouchSlop();
+    // TODO: ViewConfiguration
+    private int mBiggerTouchSlopSquare = 20 * 20;
+    
+    private int mTouchSlopSquare;
+    private int mDoubleTapSlopSquare;    
+    private int mMinimumFlingVelocity;
 
+    private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
+    private static final int TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
+    // TODO make new double-tap timeout, and define its events (i.e. either time
+    // between down-down or time between up-down)
+    private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getJumpTapTimeout();
+    
     // constants for Message.what used by GestureHandler below
     private static final int SHOW_PRESS = 1;
     private static final int LONG_PRESS = 2;
+    private static final int TAP = 3;
 
     private final Handler mHandler;
     private final OnGestureListener mListener;
+    private OnDoubleTapListener mDoubleTapListener;
 
     private boolean mInLongPress;
     private boolean mAlwaysInTapRegion;
+    private boolean mAlwaysInBiggerTapRegion;
 
     private MotionEvent mCurrentDownEvent;
-    private MotionEvent mCurrentUpEvent;
-
+    
+    /**
+     * True when the user is still touching for the second tap (down, move, and
+     * up events). Can only be true if there is a double tap listener attached.
+     */
+    private boolean mIsDoubleTapping;
+    
     private float mLastMotionY;
     private float mLastMotionX;
 
@@ -189,6 +215,12 @@
             case LONG_PRESS:
                 dispatchLongPress();
                 break;
+                
+            case TAP:
+                if (mDoubleTapListener != null) {
+                    mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent);
+                }
+                break;
 
             default:
                 throw new RuntimeException("Unknown message " + msg); //never                
@@ -203,16 +235,17 @@
      * 
      * @param listener the listener invoked for all the callbacks, this must
      * not be null.
-     * @param handler the handler to use, this must
-     * not be null.
+     * @param handler the handler to use
      *
      * @throws NullPointerException if either {@code listener} or
      * {@code handler} is null.
+     *
+     * @deprecated Use {@link #GestureDetector(android.content.Context,
+     *      android.view.GestureDetector.OnGestureListener, android.os.Handler)} instead.
      */
+    @Deprecated
     public GestureDetector(OnGestureListener listener, Handler handler) {
-        mHandler = new GestureHandler(handler);
-        mListener = listener;
-        init();        
+        this(null, listener, handler);
     }
 
     /**
@@ -222,19 +255,84 @@
      * 
      * @param listener the listener invoked for all the callbacks, this must
      * not be null.
+     * 
      * @throws NullPointerException if {@code listener} is null.
+     *
+     * @deprecated Use {@link #GestureDetector(android.content.Context,
+     *      android.view.GestureDetector.OnGestureListener)} instead.
      */
+    @Deprecated
     public GestureDetector(OnGestureListener listener) {
-        mHandler = new GestureHandler();
-        mListener = listener;
-        init();
+        this(null, listener, null);
     }
 
-    private void init() {
+    /**
+     * Creates a GestureDetector with the supplied listener.
+     * You may only use this constructor from a UI thread (this is the usual situation).
+     * @see android.os.Handler#Handler()
+     *
+     * @param context the application's context
+     * @param listener the listener invoked for all the callbacks, this must
+     * not be null.
+     *
+     * @throws NullPointerException if {@code listener} is null.
+     */
+    public GestureDetector(Context context, OnGestureListener listener) {
+        this(context, listener, null);
+    }
+
+    /**
+     * Creates a GestureDetector with the supplied listener.
+     * You may only use this constructor from a UI thread (this is the usual situation).
+     * @see android.os.Handler#Handler()
+     *
+     * @param context the application's context
+     * @param listener the listener invoked for all the callbacks, this must
+     * not be null.
+     * @param handler the handler to use     
+     *
+     * @throws NullPointerException if {@code listener} is null.
+     */
+    public GestureDetector(Context context, OnGestureListener listener, Handler handler) {
+        if (handler != null) {
+            mHandler = new GestureHandler(handler);
+        } else {
+            mHandler = new GestureHandler();
+        }
+        mListener = listener;
+        init(context);
+    }
+
+    private void init(Context context) {
         if (mListener == null) {
             throw new NullPointerException("OnGestureListener must not be null");
         }
         mIsLongpressEnabled = true;
+
+        // Fallback to support pre-donuts releases
+        int touchSlop, doubleTapSlop;
+        if (context == null) {
+            //noinspection deprecation
+            touchSlop = ViewConfiguration.getTouchSlop();
+            doubleTapSlop = ViewConfiguration.getDoubleTapSlop();
+            //noinspection deprecation
+            mMinimumFlingVelocity = ViewConfiguration.getMinimumFlingVelocity();
+        } else {
+            final ViewConfiguration configuration = ViewConfiguration.get(context);
+            touchSlop = configuration.getScaledTouchSlop();
+            doubleTapSlop = configuration.getScaledDoubleTapSlop();
+            mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity();
+        }
+        mTouchSlopSquare = touchSlop * touchSlop;
+        mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
+    }
+
+    /**
+     * @hide pending API council
+     * @param onDoubleTapListener
+     */
+    public void setOnDoubleTapListener(OnDoubleTapListener onDoubleTapListener) {
+        mDoubleTapListener = onDoubleTapListener;
     }
 
     /**
@@ -266,9 +364,6 @@
      *              else false.
      */
     public boolean onTouchEvent(MotionEvent ev) {
-        final long tapTime = ViewConfiguration.getTapTimeout();
-        final long longpressTime = ViewConfiguration.getLongPressTimeout();
-        final int touchSlop = ViewConfiguration.getTouchSlop();
         final int action = ev.getAction();
         final float y = ev.getY();
         final float x = ev.getX();
@@ -282,19 +377,32 @@
 
         switch (action) {
         case MotionEvent.ACTION_DOWN:
+            if (mDoubleTapListener != null) {
+                mHandler.removeMessages(TAP);
+                if (mCurrentDownEvent != null && isConsideredDoubleTap(mCurrentDownEvent, ev)) {
+                    // This is a second tap
+                    mIsDoubleTapping = true;
+                    handled = mDoubleTapListener.onDoubleTapEvent(ev);  
+                } else {
+                    // This is a first tap
+                    mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT);
+                }
+            }
+
             mLastMotionX = x;
             mLastMotionY = y;
             mCurrentDownEvent = MotionEvent.obtain(ev);
             mAlwaysInTapRegion = true;
+            mAlwaysInBiggerTapRegion = true;
             mInLongPress = false;
-
+            
             if (mIsLongpressEnabled) {
                 mHandler.removeMessages(LONG_PRESS);
                 mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
-                        + tapTime + longpressTime);
+                        + TAP_TIMEOUT + LONGPRESS_TIMEOUT);
             }
-            mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + tapTime);
-            handled = mListener.onDown(ev);
+            mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
+            handled |= mListener.onDown(ev);
             break;
 
         case MotionEvent.ACTION_MOVE:
@@ -303,11 +411,13 @@
             }
             final float scrollX = mLastMotionX - x;
             final float scrollY = mLastMotionY - y;
-            if (mAlwaysInTapRegion) {
+            if (mIsDoubleTapping) {
+                handled = mDoubleTapListener.onDoubleTapEvent(ev);
+            } else if (mAlwaysInTapRegion) {
                 final int deltaX = (int) (x - mCurrentDownEvent.getX());
                 final int deltaY = (int) (y - mCurrentDownEvent.getY());
                 int distance = (deltaX * deltaX) + (deltaY * deltaY);
-                if (distance > TOUCH_SLOP_SQUARE) {
+                if (distance > mTouchSlopSquare) {
                     handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
                     mLastMotionX = x;
                     mLastMotionY = y;
@@ -315,6 +425,9 @@
                     mHandler.removeMessages(SHOW_PRESS);
                     mHandler.removeMessages(LONG_PRESS);
                 }
+                if (distance > mBiggerTouchSlopSquare) {
+                    mAlwaysInBiggerTapRegion = false;
+                }
             } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) {
                 handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY);
                 mLastMotionX = x;
@@ -323,8 +436,13 @@
             break;
 
         case MotionEvent.ACTION_UP:
-            mCurrentUpEvent = MotionEvent.obtain(ev);
-            if (mInLongPress) {
+            MotionEvent currentUpEvent = MotionEvent.obtain(ev);
+            if (mIsDoubleTapping) {
+                handled = mDoubleTapListener.onDoubleTapEvent(ev);
+                mIsDoubleTapping = false;
+                break;
+            } else if (mInLongPress) {
+                mHandler.removeMessages(TAP);
                 mInLongPress = false;
                 break;
             }
@@ -338,9 +456,9 @@
                 final float velocityY = velocityTracker.getYVelocity();
                 final float velocityX = velocityTracker.getXVelocity();
 
-                if ((Math.abs(velocityY) > ViewConfiguration.getMinimumFlingVelocity())
-                        || (Math.abs(velocityX) > ViewConfiguration.getMinimumFlingVelocity())){
-                    handled = mListener.onFling(mCurrentDownEvent, mCurrentUpEvent, velocityX, velocityY);
+                if ((Math.abs(velocityY) > mMinimumFlingVelocity)
+                        || (Math.abs(velocityX) > mMinimumFlingVelocity)){
+                    handled = mListener.onFling(mCurrentDownEvent, currentUpEvent, velocityX, velocityY);
                 }
             }
             mVelocityTracker.recycle();
@@ -351,6 +469,7 @@
         case MotionEvent.ACTION_CANCEL:
             mHandler.removeMessages(SHOW_PRESS);
             mHandler.removeMessages(LONG_PRESS);
+            mHandler.removeMessages(TAP);
             mVelocityTracker.recycle();
             mVelocityTracker = null;
             if (mInLongPress) {
@@ -361,6 +480,20 @@
         return handled;
     }
 
+    private boolean isConsideredDoubleTap(MotionEvent firstDown, MotionEvent secondDown) {
+        if (!mAlwaysInBiggerTapRegion) {
+            return false;
+        }
+        
+        if (secondDown.getEventTime() - firstDown.getEventTime() > DOUBLE_TAP_TIMEOUT) {
+            return false;
+        }
+
+        int deltaX = (int) firstDown.getX() - (int) secondDown.getX();
+        int deltaY = (int) firstDown.getY() - (int) secondDown.getY();
+        return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare);
+    }
+    
     private void dispatchLongPress() {
         mInLongPress = true;
         mListener.onLongPress(mCurrentDownEvent);
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 40251db..a856b24 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -104,6 +104,9 @@
     int getKeycodeState(int sw);
     int getKeycodeStateForDevice(int devid, int sw);
     
+    // Report whether the hardware supports the given keys; returns true if successful
+    boolean hasKeys(in int[] keycodes, inout boolean[] keyExists);
+    
     // For testing
     void setInTouchMode(boolean showFocus);
     
diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java
index 0347d50..25958aa 100644
--- a/core/java/android/view/KeyCharacterMap.java
+++ b/core/java/android/view/KeyCharacterMap.java
@@ -18,6 +18,8 @@
 
 import android.text.method.MetaKeyKeyListener;
 import android.util.SparseIntArray;
+import android.os.RemoteException;
+import android.os.ServiceManager;
 import android.os.SystemClock;
 import android.util.SparseArray;
 
@@ -350,6 +352,28 @@
         return getKeyboardType_native(mPointer);
     }
 
+    /**
+     * Queries the framework about whether any physical keys exist on the
+     * device that are capable of producing the given key codes.
+     */
+    public static boolean deviceHasKey(int keyCode) {
+        int[] codeArray = new int[1];
+        codeArray[0] = keyCode;
+        boolean[] ret = deviceHasKeys(codeArray);
+        return ret[0];
+    }
+    
+    public static boolean[] deviceHasKeys(int[] keyCodes) {
+        boolean[] ret = new boolean[keyCodes.length];
+        IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
+        try {
+            wm.hasKeys(keyCodes, ret);
+        } catch (RemoteException e) {
+            // no fallback; just return the empty array
+        }
+        return ret;
+    }
+
     private int mPointer;
     private int mKeyboardDevice;
 
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 1575aad..d5434b6 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -92,7 +92,7 @@
     public static final int KEYCODE_SYM             = 63;
     public static final int KEYCODE_EXPLORER        = 64;
     public static final int KEYCODE_ENVELOPE        = 65;
-    public static final int KEYCODE_ENTER         = 66;
+    public static final int KEYCODE_ENTER           = 66;
     public static final int KEYCODE_DEL             = 67;
     public static final int KEYCODE_GRAVE           = 68;
     public static final int KEYCODE_MINUS           = 69;
@@ -144,8 +144,12 @@
     public static final int ACTION_UP               = 1;
     /**
      * {@link #getAction} value: multiple duplicate key events have
-     * occurred in a row.  The {#link {@link #getRepeatCount()} method returns
-     * the number of duplicates.
+     * occurred in a row, or a complex string is being delivered.  If the
+     * key code is not {#link {@link #KEYCODE_UNKNOWN} then the
+     * {#link {@link #getRepeatCount()} method returns the number of times
+     * the given key code should be executed.
+     * Otherwise, if the key code {@link #KEYCODE_UNKNOWN}, then
+     * this is a sequence of characters as returned by {@link #getCharacters}.
      */
     public static final int ACTION_MULTIPLE         = 2;
 
@@ -248,6 +252,7 @@
     private int mFlags;
     private long mDownTime;
     private long mEventTime;
+    private String mCharacters;
 
     public interface Callback {
         /**
@@ -406,6 +411,28 @@
     }
 
     /**
+     * Create a new key event for a string of characters.  The key code,
+     * action, and repeat could will automatically be set to
+     * {@link #KEYCODE_UNKNOWN}, {@link #ACTION_MULTIPLE}, and 0 for you.
+     * 
+     * @param time The time (in {@link android.os.SystemClock#uptimeMillis})
+     * at which this event occured.
+     * @param characters The string of characters.
+     * @param device The device ID that generated the key event.
+     * @param flags The flags for this key event
+     */
+    public KeyEvent(long time, String characters, int device, int flags) {
+        mDownTime = time;
+        mEventTime = time;
+        mCharacters = characters;
+        mAction = ACTION_MULTIPLE;
+        mKeyCode = KEYCODE_UNKNOWN;
+        mRepeatCount = 0;
+        mDeviceId = device;
+        mFlags = flags;
+    }
+
+    /**
      * Copy an existing key event, modifying its time and repeat count.
      * 
      * @param origEvent The existing event to be copied.
@@ -423,6 +450,7 @@
         mDeviceId = origEvent.mDeviceId;
         mScancode = origEvent.mScancode;
         mFlags = origEvent.mFlags;
+        mCharacters = origEvent.mCharacters;
     }
 
     /**
@@ -441,6 +469,8 @@
         mDeviceId = origEvent.mDeviceId;
         mScancode = origEvent.mScancode;
         mFlags = origEvent.mFlags;
+        // Don't copy mCharacters, since one way or the other we'll lose it
+        // when changing the action.
     }
 
     /**
@@ -580,7 +610,7 @@
 
     /**
      * Retrieve the key code of the key event.  This is the physical key that
-     * was pressed -- not the Unicode character.
+     * was pressed, <em>not</em> the Unicode character.
      * 
      * @return The key code of the event.
      */
@@ -589,6 +619,18 @@
     }
 
     /**
+     * For the special case of a {@link #ACTION_MULTIPLE} event with key
+     * code of {@link #KEYCODE_UNKNOWN}, this is a raw string of characters
+     * associated with the event.  In all other cases it is null.
+     * 
+     * @return Returns a String of 1 or more characters associated with
+     * the event.
+     */
+    public final String getCharacters() {
+        return mCharacters;
+    }
+    
+    /**
      * Retrieve the hardware key id of this key event.  These values are not
      * reliable and vary from device to device.
      *
@@ -772,16 +814,18 @@
                 if (receiver.onKeyMultiple(code, count, this)) {
                     return true;
                 }
-                mAction = ACTION_DOWN;
-                mRepeatCount = 0;
-                boolean handled = receiver.onKeyDown(code, this);
-                if (handled) {
-                    mAction = ACTION_UP;
-                    receiver.onKeyUp(code, this);
+                if (code != KeyEvent.KEYCODE_UNKNOWN) {
+                    mAction = ACTION_DOWN;
+                    mRepeatCount = 0;
+                    boolean handled = receiver.onKeyDown(code, this);
+                    if (handled) {
+                        mAction = ACTION_UP;
+                        receiver.onKeyUp(code, this);
+                    }
+                    mAction = ACTION_MULTIPLE;
+                    mRepeatCount = count;
+                    return handled;
                 }
-                mAction = ACTION_MULTIPLE;
-                mRepeatCount = count;
-                return handled;
         }
         return false;
     }
diff --git a/core/java/android/view/TouchDelegate.java b/core/java/android/view/TouchDelegate.java
index 057df92..27b49db 100644
--- a/core/java/android/view/TouchDelegate.java
+++ b/core/java/android/view/TouchDelegate.java
@@ -77,7 +77,9 @@
      * actual extent.
      */
     public static final int TO_RIGHT = 8;
-    
+
+    private int mSlop;
+
     /**
      * Constructor
      * 
@@ -87,10 +89,10 @@
      */
     public TouchDelegate(Rect bounds, View delegateView) {
         mBounds = bounds;
-        
-        int slop = ViewConfiguration.getTouchSlop();
+
+        mSlop = ViewConfiguration.get(delegateView.getContext()).getScaledTouchSlop();
         mSlopBounds = new Rect(bounds);
-        mSlopBounds.inset(-slop, -slop);
+        mSlopBounds.inset(-mSlop, -mSlop);
         mDelegateView = delegateView;
     }
 
@@ -141,7 +143,7 @@
             } else {
                 // Offset event coordinates to be outside the target view (in case it does
                 // something like tracking pressed state)
-                int slop = ViewConfiguration.getTouchSlop();
+                int slop = mSlop;
                 event.setLocation(-(slop * 2), -(slop * 2));
             }
             handled = delegateView.dispatchTouchEvent(event);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 85f482c..a51b564 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -60,12 +60,31 @@
 
 /**
  * <p>
- * The <code>View</code> class represents the basic UI building block. A view
+ * This class represents the basic building block for user interface components. A View
  * occupies a rectangular area on the screen and is responsible for drawing and
- * event handling. <code>View</code> is the base class for <em>widgets</em>,
- * used to create interactive graphical user interfaces.
+ * event handling. View is the base class for <em>widgets</em>, which are
+ * used to create interactive UI components (buttons, text fields, etc.). The 
+ * {@link android.view.ViewGroup} subclass is the base class for <em>layouts</em>, which
+ * are invisible containers that hold other Views (or other ViewGroups) and define
+ * their layout properties.
  * </p>
  *
+ * <div class="special">
+ * <p>For an introduction to using this class to develop your 
+ * application's user interface, read the Developer Guide documentation on 
+ * <strong><a href="{@docRoot}guide/topics/ui/index.html">User Interface</a></strong>. Special topics
+ * include: 
+ * <br/><a href="{@docRoot}guide/topics/ui/declaring-layout.html">Declaring Layout</a>
+ * <br/><a href="{@docRoot}guide/topics/ui/menus.html">Creating Menus</a>
+ * <br/><a href="{@docRoot}guide/topics/ui/layout-objects.html">Common Layout Objects</a>
+ * <br/><a href="{@docRoot}guide/topics/ui/binding.html">Binding to Data with AdapterView</a>
+ * <br/><a href="{@docRoot}guide/topics/ui/ui-events.html">Handling UI Events</a>
+ * <br/><a href="{@docRoot}guide/topics/ui/themes.html">Applying Styles and Themes</a>
+ * <br/><a href="{@docRoot}guide/topics/ui/custom-components.html">Building Custom Components</a>
+ * <br/><a href="{@docRoot}guide/topics/ui/how-android-draws.html">How Android Draws Views</a>.
+ * </p>
+ * </div>
+ * 
  * <a name="Using"></a>
  * <h3>Using Views</h3>
  * <p>
@@ -1308,6 +1327,14 @@
     static final int HAS_BOUNDS                     = 0x00000010;
     /** {@hide} */
     static final int DRAWN                          = 0x00000020;
+    /**
+     * When this flag is set, this view is running an animation on behalf of its
+     * children and should therefore not cancel invalidate requests, even if they
+     * lie outside of this view's bounds.
+     *
+     * {@hide}
+     */
+    static final int DRAW_ANIMATION                 = 0x00000040;
     /** {@hide} */
     static final int SKIP_DRAW                      = 0x00000080;
     /** {@hide} */
@@ -1353,8 +1380,6 @@
      */
     static final int SCROLL_CONTAINER_ADDED         = 0x00100000;
 
-    // Note: flag 0x00000040 is available
-
     /**
      * The parent this view is attached to.
      * {@hide}
@@ -1559,6 +1584,7 @@
     private int mNextFocusDownId = View.NO_ID;
 
     private CheckForLongPress mPendingCheckForLongPress;
+    private UnsetPressedState mUnsetPressedState;
 
     /**
      * Whether the long press's action has been invoked.  The tap's action is invoked on the
@@ -1898,7 +1924,8 @@
         initScrollCache();
 
         mScrollCache.fadingEdgeLength = a.getDimensionPixelSize(
-                R.styleable.View_fadingEdgeLength, ViewConfiguration.getFadingEdgeLength());
+                R.styleable.View_fadingEdgeLength,
+                ViewConfiguration.get(mContext).getScaledFadingEdgeLength());
     }
 
     /**
@@ -2013,36 +2040,38 @@
             mScrollCache.scrollBar = new ScrollBarDrawable();
         }
 
-        mScrollCache.scrollBarSize = a.getDimensionPixelSize(
+        final ScrollabilityCache scrollabilityCache = mScrollCache;
+
+        scrollabilityCache.scrollBarSize = a.getDimensionPixelSize(
                 com.android.internal.R.styleable.View_scrollbarSize,
-                ViewConfiguration.getScrollBarSize());
+                ViewConfiguration.get(mContext).getScaledScrollBarSize());
 
         Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal);
-        mScrollCache.scrollBar.setHorizontalTrackDrawable(track);
+        scrollabilityCache.scrollBar.setHorizontalTrackDrawable(track);
 
         Drawable thumb = a.getDrawable(R.styleable.View_scrollbarThumbHorizontal);
         if (thumb != null) {
-            mScrollCache.scrollBar.setHorizontalThumbDrawable(thumb);
+            scrollabilityCache.scrollBar.setHorizontalThumbDrawable(thumb);
         }
 
         boolean alwaysDraw = a.getBoolean(R.styleable.View_scrollbarAlwaysDrawHorizontalTrack,
                 false);
         if (alwaysDraw) {
-            mScrollCache.scrollBar.setAlwaysDrawHorizontalTrack(true);
+            scrollabilityCache.scrollBar.setAlwaysDrawHorizontalTrack(true);
         }
 
         track = a.getDrawable(R.styleable.View_scrollbarTrackVertical);
-        mScrollCache.scrollBar.setVerticalTrackDrawable(track);
+        scrollabilityCache.scrollBar.setVerticalTrackDrawable(track);
 
         thumb = a.getDrawable(R.styleable.View_scrollbarThumbVertical);
         if (thumb != null) {
-            mScrollCache.scrollBar.setVerticalThumbDrawable(thumb);
+            scrollabilityCache.scrollBar.setVerticalThumbDrawable(thumb);
         }
 
         alwaysDraw = a.getBoolean(R.styleable.View_scrollbarAlwaysDrawVerticalTrack,
                 false);
         if (alwaysDraw) {
-            mScrollCache.scrollBar.setAlwaysDrawVerticalTrack(true);
+            scrollabilityCache.scrollBar.setAlwaysDrawVerticalTrack(true);
         }
 
         // Re-apply user/background padding so that scrollbar(s) get added
@@ -2056,7 +2085,7 @@
      */
     private void initScrollCache() {
         if (mScrollCache == null) {
-            mScrollCache = new ScrollabilityCache();
+            mScrollCache = new ScrollabilityCache(ViewConfiguration.get(mContext));
         }
     }
 
@@ -2635,6 +2664,7 @@
      */
     public void setVisibility(int visibility) {
         setFlags(visibility, VISIBILITY_MASK);
+        if (mBGDrawable != null) mBGDrawable.setVisible(visibility == VISIBLE, false);
     }
 
     /**
@@ -3410,6 +3440,7 @@
     }
 
     void performCollectViewAttributes(int visibility) {
+        //noinspection PointlessBitwiseExpression
         if (((visibility | mViewFlags) & (VISIBILITY_MASK | KEEP_SCREEN_ON))
                 == (VISIBLE | KEEP_SCREEN_ON)) {
             mAttachInfo.mKeepScreenOn = true;
@@ -3708,10 +3739,13 @@
                             }
                         }
 
-                        final UnsetPressedState unsetPressedState = new UnsetPressedState();
-                        if (!post(unsetPressedState)) {
+                        if (mUnsetPressedState == null) {
+                            mUnsetPressedState = new UnsetPressedState();
+                        }
+
+                        if (!post(mUnsetPressedState)) {
                             // If the post failed, unpress right now
-                            unsetPressedState.run();
+                            mUnsetPressedState.run();
                         }
                     }
                     break;
@@ -3734,7 +3768,7 @@
                     final int y = (int) event.getY();
 
                     // Be lenient about moving outside of buttons
-                    int slop = ViewConfiguration.getTouchSlop();
+                    int slop = ViewConfiguration.get(mContext).getScaledTouchSlop();
                     if ((x < 0 - slop) || (x >= getWidth() + slop) ||
                             (y < 0 - slop) || (y >= getHeight() + slop)) {
                         // Outside button
@@ -4413,14 +4447,7 @@
      * @see #invalidate()
      */
     public void postInvalidate() {
-        // We try only with the AttachInfo because there's no point in invalidating
-        // if we are not attached to our window
-        if (mAttachInfo != null) {
-            Message msg = Message.obtain();
-            msg.what = AttachInfo.INVALIDATE_MSG;
-            msg.obj = this;
-            mAttachInfo.mHandler.sendMessage(msg);
-        }
+        postInvalidateDelayed(0);
     }
 
     /**
@@ -4436,16 +4463,7 @@
      * @see #invalidate(Rect)
      */
     public void postInvalidate(int left, int top, int right, int bottom) {
-        // We try only with the AttachInfo because there's no point in invalidating
-        // if we are not attached to our window
-        if (mAttachInfo != null) {
-            Message msg = Message.obtain();
-            msg.what = AttachInfo.INVALIDATE_RECT_MSG;
-            msg.obj = this;
-            msg.arg1 = (left << 16) | (top & 0xFFFF);
-            msg.arg2 = (right << 16) | (bottom & 0xFFFF);
-            mAttachInfo.mHandler.sendMessage(msg);
-        }
+        postInvalidateDelayed(0, left, top, right, bottom);
     }
 
     /**
@@ -4477,16 +4495,22 @@
      * @param right The right coordinate of the rectangle to invalidate.
      * @param bottom The bottom coordinate of the rectangle to invalidate.
      */
-    public void postInvalidateDelayed(long delayMilliseconds, int left, int top
-            , int right, int bottom) {
+    public void postInvalidateDelayed(long delayMilliseconds, int left, int top,
+            int right, int bottom) {
+
         // We try only with the AttachInfo because there's no point in invalidating
         // if we are not attached to our window
         if (mAttachInfo != null) {
-            Message msg = Message.obtain();
+            final AttachInfo.InvalidateInfo info = AttachInfo.InvalidateInfo.acquire();
+            info.target = this;
+            info.left = left;
+            info.top = top;
+            info.right = right;
+            info.bottom = bottom;
+
+            final Message msg = Message.obtain();
             msg.what = AttachInfo.INVALIDATE_RECT_MSG;
-            msg.obj = this;
-            msg.arg1 = (left << 16) | (top & 0xFFFF);
-            msg.arg2 = (right << 16) | (bottom & 0xFFFF);
+            msg.obj = info;
             mAttachInfo.mHandler.sendMessageDelayed(msg, delayMilliseconds);
         }
     }
@@ -4865,7 +4889,8 @@
             final boolean drawHorizontalScrollBar =
                 (viewFlags & SCROLLBARS_HORIZONTAL) == SCROLLBARS_HORIZONTAL;
             final boolean drawVerticalScrollBar =
-                (viewFlags & SCROLLBARS_VERTICAL) == SCROLLBARS_VERTICAL;
+                (viewFlags & SCROLLBARS_VERTICAL) == SCROLLBARS_VERTICAL
+                && !isVerticalScrollBarHidden();
 
             if (drawVerticalScrollBar || drawHorizontalScrollBar) {
                 final int width = mRight - mLeft;
@@ -4887,6 +4912,16 @@
             }
         }
     }
+    
+    /**
+     * Override this if the vertical scrollbar needs to be hidden in a subclass, like when 
+     * FastScroller is visible.
+     * @return whether to temporarily hide the vertical scrollbar
+     * @hide
+     */
+    protected boolean isVerticalScrollBarHidden() {
+        return false;
+    }
 
     /**
      * <p>Draw the horizontal scrollbar if
@@ -5022,6 +5057,7 @@
         if (mPendingCheckForLongPress != null) {
             removeCallbacks(mPendingCheckForLongPress);
         }
+        destroyDrawingCache();
     }
 
     /**
@@ -5408,7 +5444,7 @@
 
             if (width <= 0 || height <= 0 ||
                     (width * height * (opaque ? 2 : 4) >= // Projected bitmap size in bytes
-                            ViewConfiguration.getMaximumDrawingCacheSize())) {
+                            ViewConfiguration.get(mContext).getScaledMaximumDrawingCacheSize())) {
                 if (mDrawingCache != null) {
                     mDrawingCache.recycle();
                 }
@@ -5485,9 +5521,10 @@
             final int restoreCount = canvas.save();
             canvas.translate(-mScrollX, -mScrollY);
 
+            mPrivateFlags |= DRAWN;
+
             // Fast path for layouts with no backgrounds
             if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
-                mPrivateFlags |= DRAWN;
                 if (ViewDebug.TRACE_HIERARCHY) {
                     ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
                 }
@@ -5616,6 +5653,8 @@
             ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
         }
 
+        mPrivateFlags |= DRAWN;                    
+
         /*
          * Draw traversal performs several drawing steps which must be executed
          * in the appropriate order:
@@ -5656,7 +5695,6 @@
         boolean verticalEdges = (viewFlags & FADING_EDGE_VERTICAL) != 0;
         if (!verticalEdges && !horizontalEdges) {
             // Step 3, draw the content
-            mPrivateFlags |= DRAWN;
             onDraw(canvas);
 
             // Step 4, draw the children
@@ -5760,7 +5798,6 @@
         }
 
         // Step 3, draw the content
-        mPrivateFlags |= DRAWN;
         onDraw(canvas);
 
         // Step 4, draw the children
@@ -7671,6 +7708,67 @@
             void playSoundEffect(int effectId);
         }
 
+        /**
+         * InvalidateInfo is used to post invalidate(int, int, int, int) messages
+         * to a Handler. This class contains the target (View) to invalidate and
+         * the coordinates of the dirty rectangle.
+         *
+         * For performance purposes, this class also implements a pool of up to
+         * POOL_LIMIT objects that get reused. This reduces memory allocations
+         * whenever possible.
+         *
+         * The pool is implemented as a linked list of InvalidateInfo object with
+         * the root pointing to the next available InvalidateInfo. If the root
+         * is null (i.e. when all instances from the pool have been acquired),
+         * then a new InvalidateInfo is created and returned to the caller.
+         *
+         * An InvalidateInfo is sent back to the pool by calling its release()
+         * method. If the pool is full the object is simply discarded.
+         *
+         * This implementation follows the object pool pattern used in the
+         * MotionEvent class.
+         */
+        static class InvalidateInfo {
+            private static final int POOL_LIMIT = 10;
+            private static final Object sLock = new Object();
+
+            private static int sAcquiredCount = 0;
+            private static InvalidateInfo sRoot;
+
+            private InvalidateInfo next;
+
+            View target;
+
+            int left;
+            int top;
+            int right;
+            int bottom;
+
+            static InvalidateInfo acquire() {
+                synchronized (sLock) {
+                    if (sRoot == null) {
+                        return new InvalidateInfo();
+                    }
+
+                    InvalidateInfo info = sRoot;
+                    sRoot = info.next;
+                    sAcquiredCount--;
+
+                    return info;
+                }
+            }
+
+            void release() {
+                synchronized (sLock) {
+                    if (sAcquiredCount < POOL_LIMIT) {
+                        sAcquiredCount++;
+                        next = sRoot;
+                        sRoot = this;
+                    }
+                }
+            }
+        }
+
         final IWindowSession mSession;
 
         final IWindow mWindow;
@@ -7839,18 +7937,21 @@
      * instances of View.</p>
      */
     private static class ScrollabilityCache {
-        public int fadingEdgeLength = ViewConfiguration.getFadingEdgeLength();
+        public int fadingEdgeLength;
 
-        public int scrollBarSize = ViewConfiguration.getScrollBarSize();
+        public int scrollBarSize;
         public ScrollBarDrawable scrollBar;
 
         public final Paint paint;
         public final Matrix matrix;
         public Shader shader;
 
-        private int mLastColor = 0;
+        private int mLastColor;
 
-        public ScrollabilityCache() {
+        public ScrollabilityCache(ViewConfiguration configuration) {
+            fadingEdgeLength = configuration.getScaledFadingEdgeLength();
+            scrollBarSize = configuration.getScaledScrollBarSize();
+
             paint = new Paint();
             matrix = new Matrix();
             // use use a height of 1, and then wack the matrix each time we
diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java
index b7110ce..7153ea1 100644
--- a/core/java/android/view/ViewConfiguration.java
+++ b/core/java/android/view/ViewConfiguration.java
@@ -16,17 +16,19 @@
 
 package android.view;
 
+import android.content.Context;
+import android.util.DisplayMetrics;
+import android.util.SparseArray;
+
 /**
  * Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
- *
  */
 public class ViewConfiguration {
-
     /**
      * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in
      * pixels
      */
-    private static final int SCROLL_BAR_SIZE = 6;
+    private static final int SCROLL_BAR_SIZE = 10;
 
     /**
      * Defines the length of the fading edges in pixels
@@ -83,6 +85,11 @@
     private static final int TOUCH_SLOP = 12;
     
     /**
+     * Distance between the first touch and second touch to still be considered a double tap
+     */
+    private static final int DOUBLE_TAP_SLOP = 100;
+    
+    /**
      * Distance a touch needs to be outside of a window's bounds for it to
      * count as outside for purposes of dismissing the window.
      */
@@ -97,28 +104,124 @@
      * The maximum size of View's drawing cache, expressed in bytes. This size
      * should be at least equal to the size of the screen in ARGB888 format.
      */
-    private static final int MAXIMUM_DRAWING_CACHE_SIZE = 320 * 480 * 4; // One HVGA screen, ARGB8888
+    @Deprecated
+    private static final int MAXIMUM_DRAWING_CACHE_SIZE = 320 * 480 * 4; // HVGA screen, ARGB8888
 
     /**
      * The coefficient of friction applied to flings/scrolls.
      */
     private static float SCROLL_FRICTION = 0.015f;
 
+    private final int mEdgeSlop;
+    private final int mFadingEdgeLength;
+    private final int mMinimumFlingVelocity;
+    private final int mScrollbarSize;
+    private final int mTouchSlop;
+    private final int mDoubleTapSlop;
+    private final int mWindowTouchSlop;
+    private final int mMaximumDrawingCacheSize;
+
+    private static final SparseArray<ViewConfiguration> sConfigurations =
+            new SparseArray<ViewConfiguration>(2);
+
+    /**
+     * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
+     */
+    @Deprecated
+    public ViewConfiguration() {
+        mEdgeSlop = EDGE_SLOP;
+        mFadingEdgeLength = FADING_EDGE_LENGTH;
+        mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
+        mScrollbarSize = SCROLL_BAR_SIZE;
+        mTouchSlop = TOUCH_SLOP;
+        mDoubleTapSlop = DOUBLE_TAP_SLOP;
+        mWindowTouchSlop = WINDOW_TOUCH_SLOP;
+        //noinspection deprecation
+        mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
+    }
+
+    /**
+     * Creates a new configuration for the specified context. The configuration depends on
+     * various parameters of the context, like the dimension of the display or the density
+     * of the display.
+     *
+     * @param context The application context used to initialize this view configuration.
+     *
+     * @see #get(android.content.Context) 
+     * @see android.util.DisplayMetrics
+     */
+    private ViewConfiguration(Context context) {
+        final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
+        final float density = metrics.density;
+
+        mEdgeSlop = (int) (density * EDGE_SLOP + 0.5f);
+        mFadingEdgeLength = (int) (density * FADING_EDGE_LENGTH + 0.5f);
+        mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
+        mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
+        mTouchSlop = (int) (density * TOUCH_SLOP + 0.5f);
+        mDoubleTapSlop = (int) (density * DOUBLE_TAP_SLOP + 0.5f);
+        mWindowTouchSlop = (int) (density * WINDOW_TOUCH_SLOP + 0.5f);
+
+        // Size of the screen in bytes, in ARGB_8888 format
+        mMaximumDrawingCacheSize = 4 * metrics.widthPixels * metrics.heightPixels;
+    }
+
+    /**
+     * Returns a configuration for the specified context. The configuration depends on
+     * various parameters of the context, like the dimension of the display or the
+     * density of the display.
+     *
+     * @param context The application context used to initialize the view configuration.
+     */
+    public static ViewConfiguration get(Context context) {
+        final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
+        final int density = (int) (100.0f * metrics.density);
+
+        ViewConfiguration configuration = sConfigurations.get(density);
+        if (configuration == null) {
+            configuration = new ViewConfiguration(context);
+            sConfigurations.put(density, configuration);
+        }
+
+        return configuration;
+    }
+
     /**
      * @return The width of the horizontal scrollbar and the height of the vertical
      *         scrollbar in pixels
+     *
+     * @deprecated Use {@link #getScaledScrollBarSize()} instead.
      */
+    @Deprecated
     public static int getScrollBarSize() {
         return SCROLL_BAR_SIZE;
     }
 
     /**
-     * @return Defines the length of the fading edges in pixels
+     * @return The width of the horizontal scrollbar and the height of the vertical
+     *         scrollbar in pixels
      */
+    public int getScaledScrollBarSize() {
+        return mScrollbarSize;
+    }
+
+    /**
+     * @return Defines the length of the fading edges in pixels
+     *
+     * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
+     */
+    @Deprecated
     public static int getFadingEdgeLength() {
         return FADING_EDGE_LENGTH;
     }
-    
+
+    /**
+     * @return Defines the length of the fading edges in pixels
+     */
+    public int getScaledFadingEdgeLength() {
+        return mFadingEdgeLength;
+    }
+
     /**
      * @return Defines the duration in milliseconds of the pressed state in child
      * components.
@@ -156,32 +259,109 @@
     /**
      * @return Inset in pixels to look for touchable content when the user touches the edge of the
      *         screen
+     *
+     * @deprecated Use {@link #getScaledEdgeSlop()} instead.
      */
+    @Deprecated
     public static int getEdgeSlop() {
         return EDGE_SLOP;
     }
-    
+
+    /**
+     * @return Inset in pixels to look for touchable content when the user touches the edge of the
+     *         screen
+     */
+    public int getScaledEdgeSlop() {
+        return mEdgeSlop;
+    }
+
     /**
      * @return Distance a touch can wander before we think the user is scrolling in pixels
+     *
+     * @deprecated Use {@link #getScaledTouchSlop()} instead.
      */
+    @Deprecated
     public static int getTouchSlop() {
         return TOUCH_SLOP;
     }
+
+    /**
+     * @return Distance a touch can wander before we think the user is scrolling in pixels
+     */
+    public int getScaledTouchSlop() {
+        return mTouchSlop;
+    }
+
+    /**
+     * @return Distance between the first touch and second touch to still be
+     *         considered a double tap
+     * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
+     * @hide The only client of this should be GestureDetector, which needs this
+     *       for clients that still use its deprecated constructor.
+     */
+    @Deprecated
+    public static int getDoubleTapSlop() {
+        return DOUBLE_TAP_SLOP;
+    }
     
     /**
+     * @return Distance between the first touch and second touch to still be
+     *         considered a double tap
+     * @hide pending API council
+     */
+    public int getScaledDoubleTapSlop() {
+        return mDoubleTapSlop;
+    }
+
+    /**
+     * @return Distance a touch must be outside the bounds of a window for it
+     * to be counted as outside the window for purposes of dismissing that
+     * window.
+     *
+     * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
+     */
+    @Deprecated
+    public static int getWindowTouchSlop() {
+        return WINDOW_TOUCH_SLOP;
+    }
+
+    /**
      * @return Distance a touch must be outside the bounds of a window for it
      * to be counted as outside the window for purposes of dismissing that
      * window.
      */
-    public static int getWindowTouchSlop() {
-        return WINDOW_TOUCH_SLOP;
+    public int getScaledWindowTouchSlop() {
+        return mWindowTouchSlop;
     }
     
     /**
-     * Minimum velocity to initiate a fling, as measured in pixels per second
+     * @return Minimum velocity to initiate a fling, as measured in pixels per second.
+     *
+     * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
      */
-    public static int getMinimumFlingVelocity() {    
-     return MINIMUM_FLING_VELOCITY;
+    @Deprecated
+    public static int getMinimumFlingVelocity() {
+        return MINIMUM_FLING_VELOCITY;
+    }
+
+    /**
+     * @return Minimum velocity to initiate a fling, as measured in pixels per second.
+     */
+    public int getScaledMinimumFlingVelocity() {
+        return mMinimumFlingVelocity;
+    }
+
+    /**
+     * The maximum drawing cache size expressed in bytes.
+     *
+     * @return the maximum size of View's drawing cache expressed in bytes
+     *
+     * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
+     */
+    @Deprecated
+    public static int getMaximumDrawingCacheSize() {
+        //noinspection deprecation
+        return MAXIMUM_DRAWING_CACHE_SIZE;
     }
 
     /**
@@ -189,8 +369,8 @@
      *
      * @return the maximum size of View's drawing cache expressed in bytes
      */
-    public static int getMaximumDrawingCacheSize() {
-        return MAXIMUM_DRAWING_CACHE_SIZE;
+    public int getScaledMaximumDrawingCacheSize() {
+        return mMaximumDrawingCacheSize;
     }
 
     /**
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index e26a19e..c758662 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -25,6 +25,7 @@
 import android.graphics.Paint;
 import android.graphics.Rect;
 import android.graphics.Region;
+import android.graphics.RectF;
 import android.os.Parcelable;
 import android.util.AttributeSet;
 import android.util.EventLog;
@@ -74,6 +75,7 @@
 
     // The current transformation to apply on the child being drawn
     private Transformation mChildTransformation;
+    private RectF mInvalidateRegion;
 
     // Target of Motion events
     private View mMotionTarget;
@@ -1199,6 +1201,8 @@
 
         }
 
+        // We will draw our child's animation, let's reset the flag
+        mPrivateFlags &= ~DRAW_ANIMATION;
         mGroupFlags &= ~FLAG_INVALIDATE_REQUIRED;
 
         boolean more = false;
@@ -1328,8 +1332,15 @@
         boolean concatMatrix = false;
 
         if (a != null) {
-            if (!a.isInitialized()) {
+            if (mInvalidateRegion == null) {
+                mInvalidateRegion = new RectF();
+            }
+            final RectF region = mInvalidateRegion;
+
+            final boolean initialized = a.isInitialized();
+            if (!initialized) {
                 a.initialize(cr - cl, cb - ct, getWidth(), getHeight());
+                a.initializeInvalidateRegion(cl, ct, cr, cb);
                 child.onAnimationStart();
             }
 
@@ -1347,10 +1358,22 @@
                             FLAG_OPTIMIZE_INVALIDATE) {
                         mGroupFlags |= FLAG_INVALIDATE_REQUIRED;
                     } else if ((flags & FLAG_INVALIDATE_REQUIRED) == 0) {
+                        // The child need to draw an animation, potentially offscreen, so
+                        // make sure we do not cancel invalidate requests
+                        mPrivateFlags |= DRAW_ANIMATION;
                         invalidate(cl, ct, cr, cb);
                     }
                 } else {
-                    mGroupFlags |= FLAG_INVALIDATE_REQUIRED;
+                    a.getInvalidateRegion(cl, ct, cr, cb, region, transformToApply);
+
+                    // The child need to draw an animation, potentially offscreen, so
+                    // make sure we do not cancel invalidate requests
+                    mPrivateFlags |= DRAW_ANIMATION;
+                    // Enlarge the invalidate region to account for rounding errors
+                    // in Animation#getInvalidateRegion(); Using 0.5f is unfortunately
+                    // not enough for some types of animations (e.g. scale down.)
+                    invalidate((int) (region.left - 1.0f), (int) (region.top - 1.0f),
+                            (int) (region.right + 1.0f), (int) (region.bottom + 1.0f));
                 }
             }
         } else if ((flags & FLAG_SUPPORT_STATIC_TRANSFORMATIONS) ==
@@ -1367,7 +1390,8 @@
             }
         }
 
-        if (!concatMatrix && canvas.quickReject(cl, ct, cr, cb, Canvas.EdgeType.BW)) {
+        if (!concatMatrix && canvas.quickReject(cl, ct, cr, cb, Canvas.EdgeType.BW) &&
+                (child.mPrivateFlags & DRAW_ANIMATION) == 0) {
             return more;
         }
 
@@ -1435,10 +1459,13 @@
             }
         }
 
+        // Clear the flag as early as possible to allow draw() implementations
+        // to call invalidate() successfully when doing animations
+        child.mPrivateFlags |= DRAWN;
+
         if (hasNoCache) {
             // Fast path for layouts with no backgrounds
             if ((child.mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
-                child.mPrivateFlags |= DRAWN;
                 if (ViewDebug.TRACE_HIERARCHY) {
                     ViewDebug.trace(this, ViewDebug.HierarchyTraceType.DRAW);
                 }
@@ -1455,7 +1482,6 @@
                 cachePaint.setAlpha(255);
                 mGroupFlags &= ~FLAG_ALPHA_LOWER_THAN_ONE;
             }
-            child.mPrivateFlags |= DRAWN;
             if (ViewRoot.PROFILE_DRAWING) {
                 EventLog.writeEvent(60003, hashCode());
             }
@@ -1922,8 +1948,7 @@
         LayoutAnimationController.AnimationParameters animationParams =
                     params.layoutAnimationParameters;
         if (animationParams == null) {
-            animationParams =
-                    new LayoutAnimationController.AnimationParameters();
+            animationParams = new LayoutAnimationController.AnimationParameters();
             params.layoutAnimationParameters = animationParams;
         }
 
@@ -2278,8 +2303,16 @@
             final int[] location = attachInfo.mInvalidateChildLocation;
             location[CHILD_LEFT_INDEX] = child.mLeft;
             location[CHILD_TOP_INDEX] = child.mTop;
+
+            // If the child is drawing an animation, we want to copy this flag onto
+            // ourselves and the parent to make sure the invalidate request goes
+            // through
+            final boolean drawAnimation = (child.mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION;
     
             do {
+                if (drawAnimation && parent instanceof View) {
+                    ((View) parent).mPrivateFlags |= DRAW_ANIMATION;
+                }
                 parent = parent.invalidateChildInParent(location, dirty);
             } while (parent != null);
         }
@@ -2307,7 +2340,8 @@
                 final int left = mLeft;
                 final int top = mTop;
 
-                if (dirty.intersect(0, 0, mRight - left, mBottom - top)) {
+                if (dirty.intersect(0, 0, mRight - left, mBottom - top) ||
+                        (mPrivateFlags & DRAW_ANIMATION) == DRAW_ANIMATION) {
                     mPrivateFlags &= ~DRAWING_CACHE_VALID;
 
                     location[CHILD_LEFT_INDEX] = left;
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 9e0289a..4e46397 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -177,13 +177,14 @@
     boolean mUseGL;
     boolean mGlWanted;
 
+    final ViewConfiguration mViewConfiguration;    
+
     /**
      * see {@link #playSoundEffect(int)}
      */
     AudioManager mAudioManager;
 
 
-
     public ViewRoot(Context context) {
         super();
 
@@ -224,6 +225,7 @@
         mSurface = new Surface();
         mAdded = false;
         mAttachInfo = new View.AttachInfo(sWindowSession, mWindow, this, this);
+        mViewConfiguration = ViewConfiguration.get(context);
     }
 
     @Override
@@ -1101,6 +1103,7 @@
 
                     mAttachInfo.mDrawingTime = SystemClock.uptimeMillis();
                     canvas.translate(0, -yoff);
+                    mView.mPrivateFlags |= View.DRAWN;
                     mView.draw(canvas);
                     canvas.translate(0, yoff);
 
@@ -1139,6 +1142,8 @@
             Canvas canvas;
             try {
                 canvas = surface.lockCanvas(dirty);
+                // TODO: Do this in native
+                canvas.setDensityScale(mView.getResources().getDisplayMetrics().density);
             } catch (Surface.OutOfResourcesException e) {
                 Log.e("ViewRoot", "OutOfResourcesException locking surface", e);
                 // TODO: we should ask the window manager to do something!
@@ -1175,6 +1180,7 @@
                 dirty.setEmpty();
                 mAttachInfo.mDrawingTime = SystemClock.uptimeMillis();
                 canvas.translate(0, -yoff);
+                mView.mPrivateFlags |= View.DRAWN;                    
                 mView.draw(canvas);
                 canvas.translate(0, yoff);
 
@@ -1197,6 +1203,23 @@
             if (LOCAL_LOGV) {
                 Log.v("ViewRoot", "Surface " + surface + " unlockCanvasAndPost");
             }
+            
+        } else if (mWidth == 0 || mHeight == 0) {
+            // This is a special case where a window dimension is 0 -- we
+            // normally wouldn't draw anything because we have an empty
+            // dirty rect, but the surface flinger may be waiting for us to
+            // draw the window before it stops freezing the screen, so we
+            // need to diddle it like this to keep it from getting stuck.
+            Canvas canvas;
+            try {
+                canvas = surface.lockCanvas(dirty);
+            } catch (Surface.OutOfResourcesException e) {
+                Log.e("ViewRoot", "OutOfResourcesException locking surface", e);
+                // TODO: we should ask the window manager to do something!
+                // for now we just do nothing
+                return;
+            }
+            surface.unlockCanvasAndPost(canvas);
         }
         
         if (scrolling) {
@@ -1414,6 +1437,7 @@
     public final static int FINISHED_EVENT = 1010;
     public final static int DISPATCH_KEY_FROM_IME = 1011;
     public final static int FINISH_INPUT_CONNECTION = 1012;
+    public final static int CHECK_FOCUS = 1013;
 
     @Override
     public void handleMessage(Message msg) {
@@ -1422,11 +1446,9 @@
             ((View) msg.obj).invalidate();
             break;
         case View.AttachInfo.INVALIDATE_RECT_MSG:
-            int left = msg.arg1 >>> 16;
-            int top = msg.arg1 & 0xFFFF;
-            int right = msg.arg2 >>> 16;
-            int bottom = msg.arg2 & 0xFFFF;
-            ((View) msg.obj).invalidate(left, top, right, bottom);
+            final View.AttachInfo.InvalidateInfo info = (View.AttachInfo.InvalidateInfo) msg.obj;
+            info.target.invalidate(info.left, info.top, info.right, info.bottom);
+            info.release();
             break;
         case DO_TRAVERSAL:
             if (mProfile) {
@@ -1478,7 +1500,7 @@
                     event.offsetLocation(0, mCurScrollY);
                     handled = mView.dispatchTouchEvent(event);
                     if (!handled && isDown) {
-                        int edgeSlop = ViewConfiguration.getEdgeSlop();
+                        int edgeSlop = mViewConfiguration.getScaledEdgeSlop();
 
                         final int edgeFlags = event.getEdgeFlags();
                         int direction = View.FOCUS_UP;
@@ -1615,7 +1637,7 @@
             dispatchDetachedFromWindow();
             break;
         case DISPATCH_KEY_FROM_IME:
-            if (LOCAL_LOGV) Log.v(
+            if (true) Log.v(
                 "ViewRoot", "Dispatching key "
                 + msg.obj + " from IME to " + mView);
             deliverKeyEventToViewHierarchy((KeyEvent)msg.obj, false);
@@ -1626,6 +1648,12 @@
                 imm.reportFinishInputConnection((InputConnection)msg.obj);
             }
         } break;
+        case CHECK_FOCUS: {
+            InputMethodManager imm = InputMethodManager.peekInstance();
+            if (imm != null) {
+                imm.checkFocus((View)msg.obj);
+            }
+        } break;
         }
     }
 
@@ -2042,8 +2070,10 @@
     }
     
     private void deliverKeyEvent(KeyEvent event, boolean sendDone) {
-        boolean handled = false;
-        handled = mView.dispatchKeyEventPreIme(event);
+        // If mView is null, we just consume the key event because it doesn't
+        // make sense to do anything else with it.
+        boolean handled = mView != null
+                ? mView.dispatchKeyEventPreIme(event) : true;
         if (handled) {
             if (sendDone) {
                 if (LOCAL_LOGV) Log.v(
@@ -2061,7 +2091,7 @@
         if (WindowManager.LayoutParams.mayUseInputMethod(
                 mWindowAttributes.flags)) {
             InputMethodManager imm = InputMethodManager.peekInstance();
-            if (imm != null && mView != null && imm.isActive()) {
+            if (imm != null && mView != null) {
                 int seq = enqueuePendingEvent(event, sendDone);
                 if (DEBUG_IMF) Log.v(TAG, "Sending key event to IME: seq="
                         + seq + " event=" + event);
@@ -2748,7 +2778,6 @@
 
             synchronized (mActions) {
                 final ArrayList<HandlerAction> actions = mActions;
-                final int count = actions.size();
 
                 while (actions.remove(handlerAction)) {
                     // Keep going
@@ -2776,7 +2805,20 @@
 
             @Override
             public boolean equals(Object o) {
-                return action.equals(o);
+                if (this == o) return true;
+                if (o == null || getClass() != o.getClass()) return false;
+
+                HandlerAction that = (HandlerAction) o;
+
+                return !(action != null ? !action.equals(that.action) : that.action != null);
+
+            }
+
+            @Override
+            public int hashCode() {
+                int result = action != null ? action.hashCode() : 0;
+                result = 31 * result + (int) (delay ^ (delay >>> 32));
+                return result;
             }
         }
     }
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index f4d0fde..a573983 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -16,18 +16,17 @@
 
 package android.view;
 
-import android.media.ToneGenerator;
+import android.bluetooth.HeadsetBase;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
 import android.media.AudioManager;
 import android.media.AudioService;
 import android.media.AudioSystem;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.res.Resources;
+import android.media.ToneGenerator;
 import android.os.Handler;
 import android.os.Message;
 import android.os.Vibrator;
-import android.text.TextUtils;
 import android.util.Config;
 import android.util.Log;
 import android.widget.ImageView;
@@ -39,7 +38,7 @@
  * Handle the volume up and down keys.
  *
  * This code really should be moved elsewhere.
- * 
+ *
  * @hide
  */
 public class VolumePanel extends Handler
@@ -54,7 +53,7 @@
      * PhoneWindow will implement this part.
      */
     public static final int PLAY_SOUND_DELAY = 300;
-    
+
     /**
      * The delay before vibrating. This small period exists so if the user is
      * moving to silent mode, it will not emit a short vibrate (it normally
@@ -64,28 +63,30 @@
     public static final int VIBRATE_DELAY = 300;
 
     private static final int VIBRATE_DURATION = 300;
-    private static final int BEEP_DURATION = 150; 
+    private static final int BEEP_DURATION = 150;
     private static final int MAX_VOLUME = 100;
     private static final int FREE_DELAY = 10000;
-    
+
     private static final int MSG_VOLUME_CHANGED = 0;
     private static final int MSG_FREE_RESOURCES = 1;
     private static final int MSG_PLAY_SOUND = 2;
     private static final int MSG_STOP_SOUNDS = 3;
     private static final int MSG_VIBRATE = 4;
-    
+
     private static final int RINGTONE_VOLUME_TEXT = com.android.internal.R.string.volume_ringtone;
     private static final int MUSIC_VOLUME_TEXT = com.android.internal.R.string.volume_music;
     private static final int INCALL_VOLUME_TEXT = com.android.internal.R.string.volume_call;
     private static final int ALARM_VOLUME_TEXT = com.android.internal.R.string.volume_alarm;
     private static final int UNKNOWN_VOLUME_TEXT = com.android.internal.R.string.volume_unknown;
     private static final int NOTIFICATION_VOLUME_TEXT =
-            com.android.internal.R.string.volume_notification; 
-    
+            com.android.internal.R.string.volume_notification;
+    private static final int BLUETOOTH_INCALL_VOLUME_TEXT =
+            com.android.internal.R.string.volume_bluetooth_call;
+
     protected Context mContext;
     private AudioManager mAudioManager;
     protected AudioService mAudioService;
-    
+
     private final Toast mToast;
     private final View mView;
     private final TextView mMessage;
@@ -117,13 +118,13 @@
         mToneGenerators = new ToneGenerator[AudioSystem.getNumStreamTypes()];
         mVibrator = new Vibrator();
     }
-    
+
     public void postVolumeChanged(int streamType, int flags) {
         if (hasMessages(MSG_VOLUME_CHANGED)) return;
         removeMessages(MSG_FREE_RESOURCES);
         obtainMessage(MSG_VOLUME_CHANGED, streamType, flags).sendToTarget();
     }
-    
+
     /**
      * Override this if you have other work to do when the volume changes (for
      * example, vibrating, playing a sound, etc.). Make sure to call through to
@@ -132,31 +133,31 @@
     protected void onVolumeChanged(int streamType, int flags) {
 
         if (LOGD) Log.d(TAG, "onVolumeChanged(streamType: " + streamType + ", flags: " + flags + ")");
-        
+
         if ((flags & AudioManager.FLAG_SHOW_UI) != 0) {
             onShowVolumeChanged(streamType, flags);
         }
-        
+
         if ((flags & AudioManager.FLAG_PLAY_SOUND) != 0) {
             removeMessages(MSG_PLAY_SOUND);
             sendMessageDelayed(obtainMessage(MSG_PLAY_SOUND, streamType, flags), PLAY_SOUND_DELAY);
         }
-        
+
         if ((flags & AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE) != 0) {
             removeMessages(MSG_PLAY_SOUND);
             removeMessages(MSG_VIBRATE);
             onStopSounds();
         }
-        
+
         removeMessages(MSG_FREE_RESOURCES);
-        sendMessageDelayed(obtainMessage(MSG_FREE_RESOURCES), FREE_DELAY); 
+        sendMessageDelayed(obtainMessage(MSG_FREE_RESOURCES), FREE_DELAY);
     }
 
     protected void onShowVolumeChanged(int streamType, int flags) {
         int index = mAudioService.getStreamVolume(streamType);
         int message = UNKNOWN_VOLUME_TEXT;
         int additionalMessage = 0;
-        
+
         if (LOGD) {
             Log.d(TAG, "onShowVolumeChanged(streamType: " + streamType
                     + ", flags: " + flags + "), index: " + index);
@@ -166,13 +167,13 @@
         int max = mAudioService.getStreamMaxVolume(streamType);
 
         switch (streamType) {
-            
+
             case AudioManager.STREAM_RING: {
                 message = RINGTONE_VOLUME_TEXT;
                 setRingerIcon(index);
                 break;
             }
-                
+
             case AudioManager.STREAM_MUSIC: {
                 message = MUSIC_VOLUME_TEXT;
                 if (mAudioManager.isBluetoothA2dpOn()) {
@@ -184,7 +185,7 @@
                 }
                 break;
             }
-                
+
             case AudioManager.STREAM_VOICE_CALL: {
                 /*
                  * For in-call voice call volume, there is no inaudible volume.
@@ -194,13 +195,7 @@
                 index++;
                 max++;
                 message = INCALL_VOLUME_TEXT;
-                if (mAudioManager.isBluetoothScoOn()) {
-                    additionalMessage =
-                        com.android.internal.R.string.volume_call_hint_playing_through_bluetooth;
-                    setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_in_call);
-                } else {
-                    setSmallIcon(index);
-                }
+                setSmallIcon(index);
                 break;
             }
 
@@ -209,12 +204,25 @@
                 setSmallIcon(index);
                 break;
             }
-            
+
             case AudioManager.STREAM_NOTIFICATION: {
                 message = NOTIFICATION_VOLUME_TEXT;
                 setSmallIcon(index);
                 break;
             }
+
+            case AudioManager.STREAM_BLUETOOTH_SCO: {
+                /*
+                 * For in-call voice call volume, there is no inaudible volume.
+                 * Rescale the UI control so the progress bar doesn't go all
+                 * the way to zero and don't show the mute icon.
+                 */
+                index++;
+                max++;
+                message = BLUETOOTH_INCALL_VOLUME_TEXT;
+                setLargeIcon(com.android.internal.R.drawable.ic_volume_bluetooth_in_call);
+                break;
+            }
         }
 
         String messageString = Resources.getSystem().getString(message);
@@ -228,25 +236,25 @@
             mAdditionalMessage.setVisibility(View.VISIBLE);
             mAdditionalMessage.setText(Resources.getSystem().getString(additionalMessage));
         }
-        
+
         if (max != mLevel.getMax()) {
             mLevel.setMax(max);
         }
         mLevel.setProgress(index);
-        
+
         mToast.setView(mView);
         mToast.setDuration(Toast.LENGTH_SHORT);
         mToast.setGravity(Gravity.TOP, 0, 0);
         mToast.show();
-        
+
         // Do a little vibrate if applicable (only when going into vibrate mode)
-        if ((flags & AudioManager.FLAG_VIBRATE) != 0 && 
+        if ((flags & AudioManager.FLAG_VIBRATE) != 0 &&
                 mAudioService.isStreamAffectedByRingerMode(streamType) &&
                 mAudioService.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE &&
                 mAudioService.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
             sendMessageDelayed(obtainMessage(MSG_VIBRATE), VIBRATE_DELAY);
         }
-        
+
     }
 
     protected void onPlaySound(int streamType, int flags) {
@@ -256,7 +264,7 @@
             // Force stop right now
             onStopSounds();
         }
-        
+
         synchronized (this) {
             ToneGenerator toneGen = getOrCreateToneGenerator(streamType);
             toneGen.startTone(ToneGenerator.TONE_PROP_BEEP);
@@ -266,7 +274,7 @@
     }
 
     protected void onStopSounds() {
-        
+
         synchronized (this) {
             int numStreamTypes = AudioSystem.getNumStreamTypes();
             for (int i = numStreamTypes - 1; i >= 0; i--) {
@@ -277,17 +285,17 @@
             }
         }
     }
-    
+
     protected void onVibrate() {
-        
+
         // Make sure we ended up in vibrate ringer mode
         if (mAudioService.getRingerMode() != AudioManager.RINGER_MODE_VIBRATE) {
             return;
         }
-        
+
         mVibrator.vibrate(VIBRATE_DURATION);
     }
-    
+
     /**
      * Lock on this VolumePanel instance as long as you use the returned ToneGenerator.
      */
@@ -303,13 +311,13 @@
 
     /**
      * Makes the small icon visible, and hides the large icon.
-     * 
+     *
      * @param index The volume index, where 0 means muted.
      */
     private void setSmallIcon(int index) {
         mLargeStreamIcon.setVisibility(View.GONE);
         mSmallStreamIcon.setVisibility(View.VISIBLE);
-        
+
         mSmallStreamIcon.setImageResource(index == 0
                 ? com.android.internal.R.drawable.ic_volume_off_small
                 : com.android.internal.R.drawable.ic_volume_small);
@@ -317,7 +325,7 @@
 
     /**
      * Makes the large image view visible with the given icon.
-     * 
+     *
      * @param resId The icon to display.
      */
     private void setLargeIcon(int resId) {
@@ -329,7 +337,7 @@
     /**
      * Makes the ringer icon visible with an icon that is chosen
      * based on the current ringer mode.
-     * 
+     *
      * @param index
      */
     private void setRingerIcon(int index) {
@@ -350,13 +358,13 @@
         }
         mLargeStreamIcon.setImageResource(icon);
     }
-    
+
     protected void onFreeResources() {
         // We'll keep the views, just ditch the cached drawable and hence
         // bitmaps
         mSmallStreamIcon.setImageDrawable(null);
         mLargeStreamIcon.setImageDrawable(null);
-        
+
         synchronized (this) {
             for (int i = mToneGenerators.length - 1; i >= 0; i--) {
                 if (mToneGenerators[i] != null) {
@@ -366,26 +374,26 @@
             }
         }
     }
-    
+
     @Override
     public void handleMessage(Message msg) {
         switch (msg.what) {
-            
+
             case MSG_VOLUME_CHANGED: {
                 onVolumeChanged(msg.arg1, msg.arg2);
                 break;
             }
-            
+
             case MSG_FREE_RESOURCES: {
                 onFreeResources();
                 break;
             }
-            
+
             case MSG_STOP_SOUNDS: {
                 onStopSounds();
                 break;
             }
-            
+
             case MSG_PLAY_SOUND: {
                 onPlaySound(msg.arg1, msg.arg2);
                 break;
@@ -395,8 +403,8 @@
                 onVibrate();
                 break;
             }
-            
+
         }
     }
-    
+
 }
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index a68436b..428de67 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -525,6 +525,21 @@
     }
 
     /**
+     * Specify custom animations to use for the window, as per
+     * {@link WindowManager.LayoutParams#windowAnimations
+     * WindowManager.LayoutParams.windowAnimations}.  Providing anything besides
+     * 0 here will override the animations the window would
+     * normally retrieve from its theme.
+     */
+    public void setWindowAnimations(int resId) {
+        final WindowManager.LayoutParams attrs = getAttributes();
+        attrs.windowAnimations = resId;
+        if (mCallback != null) {
+            mCallback.onWindowAttributesChanged(attrs);
+        }
+    }
+
+    /**
      * Specify an explicit soft input mode to use for the window, as per
      * {@link WindowManager.LayoutParams#softInputMode
      * WindowManager.LayoutParams.softInputMode}.  Providing anything besides
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 7e47ad1..d08a6fa 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -16,6 +16,7 @@
 
 package android.view;
 
+import android.content.pm.ActivityInfo;
 import android.graphics.PixelFormat;
 import android.os.IBinder;
 import android.os.Parcel;
@@ -126,8 +127,6 @@
          * @see #TYPE_APPLICATION_MEDIA
          * @see #TYPE_APPLICATION_SUB_PANEL
          * @see #TYPE_APPLICATION_ATTACHED_DIALOG
-         * @see #TYPE_INPUT_METHOD
-         * @see #TYPE_INPUT_METHOD_DIALOG
          * @see #TYPE_STATUS_BAR
          * @see #TYPE_SEARCH_BAR
          * @see #TYPE_PHONE
@@ -645,6 +644,17 @@
          */
         public String packageName = null;
         
+        /**
+         * Specific orientation value for a window.
+         * May be any of the same values allowed
+         * for {@link android.content.pm.ActivityInfo#screenOrientation}. 
+         * If not set, a default value of 
+         * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 
+         * will be used.
+         */
+        public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+        
+        
         public LayoutParams() {
             super(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
             type = TYPE_APPLICATION;
@@ -722,6 +732,7 @@
             out.writeStrongBinder(token);
             out.writeString(packageName);
             TextUtils.writeToParcel(mTitle, out, parcelableFlags);
+            out.writeInt(screenOrientation);
         }
         
         public static final Parcelable.Creator<LayoutParams> CREATOR
@@ -755,6 +766,7 @@
             token = in.readStrongBinder();
             packageName = in.readString();
             mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
+            screenOrientation = in.readInt();
         }
     
         public static final int LAYOUT_CHANGED = 1<<0;
@@ -767,6 +779,7 @@
         public static final int ALPHA_CHANGED = 1<<7;
         public static final int MEMORY_TYPE_CHANGED = 1<<8;
         public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
+        public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
     
         public final int copyFrom(LayoutParams o) {
             int changes = 0;
@@ -862,6 +875,10 @@
                 changes |= DIM_AMOUNT_CHANGED;
             }
     
+            if (screenOrientation != o.screenOrientation) {
+                screenOrientation = o.screenOrientation;
+                changes |= SCREEN_ORIENTATION_CHANGED;
+            }
             return changes;
         }
     
@@ -907,6 +924,10 @@
                 sb.append(" wanim=0x");
                 sb.append(Integer.toHexString(windowAnimations));
             }
+            if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
+                sb.append("or=");
+                sb.append(screenOrientation);
+            }
             sb.append('}');
             return sb.toString();
         }
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 6af4915..542b35f 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -289,16 +289,18 @@
          * Can be called by the policy to force a window to be hidden,
          * regardless of whether the client or window manager would like
          * it shown.  Must be called with the window manager lock held.
+         * Returns true if {@link #showLw} was last called for the window.
          */
-        public void hideLw(boolean doAnimation);
+        public boolean hideLw(boolean doAnimation);
         
         /**
          * Can be called to undo the effect of {@link #hideLw}, allowing a
          * window to be shown as long as the window manager and client would
          * also like it to be shown.  Must be called with the window manager
          * lock held.
+         * Returns true if {@link #hideLw} was last called for the window.
          */
-        public void showLw(boolean doAnimation);
+        public boolean showLw(boolean doAnimation);
     }
 
     /** No transition happening. */
@@ -735,10 +737,17 @@
      * ActivityInfo.SCREEN_ORIENTATION_PORTRAIT}), return a surface
      * rotation.
      */
-    public int rotationForOrientation(int orientation);
+    public int rotationForOrientation(int orientation, int lastRotation,
+            boolean displayEnabled);
     
     /**
-     * Called when the system is mostly done booting
+     * Called when the system is mostly done booting to dentermine whether
+     * the system should go into safe mode.
+     */
+    public boolean detectSafeMode();
+    
+    /**
+     * Called when the system is mostly done booting.
      */
     public void systemReady();
 
diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java
index 9264398..c96b3e5 100644
--- a/core/java/android/view/animation/Animation.java
+++ b/core/java/android/view/animation/Animation.java
@@ -20,13 +20,14 @@
 import android.content.res.TypedArray;
 import android.util.AttributeSet;
 import android.util.TypedValue;
+import android.graphics.RectF;
 
 /**
  * Abstraction for an Animation that can be applied to Views, Surfaces, or
  * other objects. See the {@link android.view.animation animation package
  * description file}.
  */
-public abstract class Animation {
+public abstract class Animation implements Cloneable {
     /**
      * Repeat the animation indefinitely.
      */
@@ -174,8 +175,12 @@
      */
     private int mZAdjustment;
     
-    // Indicates what was the last value returned by getTransformation()
     private boolean mMore = true;
+    private boolean mOneMoreTime = true;
+
+    RectF mPreviousRegion = new RectF();
+    Transformation mTransformation = new Transformation();
+    Transformation mPreviousTransformation = new Transformation();
 
     /**
      * Creates a new animation with a duration of 0ms, the default interpolator, with
@@ -217,16 +222,28 @@
         a.recycle();
     }
 
+    @Override
+    protected Animation clone() throws CloneNotSupportedException {
+        final Animation animation = (Animation) super.clone();
+        animation.mPreviousRegion = new RectF();
+        animation.mTransformation = new Transformation();
+        animation.mPreviousTransformation = new Transformation();
+        return animation;
+    }
+
     /**
      * Reset the initialization state of this animation.
      *
      * @see #initialize(int, int, int, int)
      */
     public void reset() {
+        mPreviousRegion.setEmpty();
+        mPreviousTransformation.clear();
         mInitialized = false;
         mCycleFlip = false;
         mRepeated = 0;
         mMore = true;
+        mOneMoreTime = true;
     }
 
     /**
@@ -255,10 +272,8 @@
      * @param parentHeight Height of the animated object's parent
      */
     public void initialize(int width, int height, int parentWidth, int parentHeight) {
+        reset();
         mInitialized = true;
-        mCycleFlip = false;
-        mRepeated = 0;
-        mMore = true;
     }
 
     /**
@@ -707,6 +722,11 @@
             }
         }
 
+        if (!mMore && mOneMoreTime) {
+            mOneMoreTime = false;
+            return true;
+        }
+
         return mMore;
     }
 
@@ -765,7 +785,54 @@
                 return value;
         }
     }
-    
+
+    /**
+     * @param left
+     * @param top
+     * @param right
+     * @param bottom
+     * @param invalidate
+     * @param transformation
+     * 
+     * @hide
+     */
+    public void getInvalidateRegion(int left, int top, int right, int bottom,
+            RectF invalidate, Transformation transformation) {
+
+        final RectF previousRegion = mPreviousRegion;
+
+        invalidate.set(left, top, right, bottom);
+        transformation.getMatrix().mapRect(invalidate);
+        invalidate.union(previousRegion);
+
+        previousRegion.set(left, top, right, bottom);
+        transformation.getMatrix().mapRect(previousRegion);
+
+        final Transformation tempTransformation = mTransformation;
+        final Transformation previousTransformation = mPreviousTransformation;
+
+        tempTransformation.set(transformation);
+        transformation.set(previousTransformation);
+        previousTransformation.set(tempTransformation);
+    }
+
+    /**
+     * @param left
+     * @param top
+     * @param right
+     * @param bottom
+     *
+     * @hide
+     */
+    public void initializeInvalidateRegion(int left, int top, int right, int bottom) {
+        final RectF region = mPreviousRegion;
+        region.set(left, top, right, bottom);
+        if (mFillBefore) {
+            final Transformation previousTransformation = mPreviousTransformation;
+            applyTransformation(0.0f, previousTransformation);
+        }
+    }
+
     /**
      * Utility class to parse a string description of a size.
      */
diff --git a/core/java/android/view/animation/AnimationSet.java b/core/java/android/view/animation/AnimationSet.java
index 688da70..7b56f00 100644
--- a/core/java/android/view/animation/AnimationSet.java
+++ b/core/java/android/view/animation/AnimationSet.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.util.AttributeSet;
+import android.graphics.RectF;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -39,6 +40,7 @@
     private static final int PROPERTY_SHARE_INTERPOLATOR_MASK = 0x10;
     private static final int PROPERTY_DURATION_MASK           = 0x20;
     private static final int PROPERTY_MORPH_MATRIX_MASK       = 0x40;
+    private static final int PROPERTY_CHANGE_BOUNDS_MASK      = 0x80;
 
     private int mFlags = 0;
 
@@ -82,6 +84,22 @@
         init();
     }
 
+    @Override
+    protected AnimationSet clone() throws CloneNotSupportedException {
+        final AnimationSet animation = (AnimationSet) super.clone();
+        animation.mTempTransformation = new Transformation();
+        animation.mAnimations = new ArrayList<Animation>();
+
+        final int count = mAnimations.size();
+        final ArrayList<Animation> animations = mAnimations;
+
+        for (int i = 0; i < count; i++) {
+            animation.mAnimations.add(animations.get(i).clone());
+        }
+
+        return animation;
+    }
+
     private void setFlag(int mask, boolean value) {
         if (value) {
             mFlags |= mask;
@@ -145,6 +163,11 @@
             mFlags |= PROPERTY_MORPH_MATRIX_MASK;
         }
 
+        boolean changeBounds = (mFlags & PROPERTY_CHANGE_BOUNDS_MASK) == 0;
+        if (changeBounds && a.willChangeTransformationMatrix()) {
+            mFlags |= PROPERTY_CHANGE_BOUNDS_MASK;
+        }
+
         if (mAnimations.size() == 1) {
             mDuration = a.getStartOffset() + a.getDuration();
             mLastEnd = mStartOffset + mDuration;
@@ -239,7 +262,54 @@
         }
         return duration;
     }
-    
+
+    /**
+     * @hide
+     */
+    public void getInvalidateRegion(int left, int top, int right, int bottom,
+            RectF invalidate, Transformation transformation) {
+
+        final RectF previousRegion = mPreviousRegion;
+
+        invalidate.set(left, top, right, bottom);
+        transformation.getMatrix().mapRect(invalidate);
+        invalidate.union(previousRegion);
+
+        previousRegion.set(left, top, right, bottom);
+        transformation.getMatrix().mapRect(previousRegion);
+
+        final Transformation tempTransformation = mTransformation;
+        final Transformation previousTransformation = mPreviousTransformation;
+
+        tempTransformation.set(transformation);
+        transformation.set(previousTransformation);
+        previousTransformation.set(tempTransformation);
+    }
+
+    /**
+     * @hide
+     */
+    public void initializeInvalidateRegion(int left, int top, int right, int bottom) {
+        final RectF region = mPreviousRegion;
+        region.set(left, top, right, bottom);
+
+        if (mFillBefore) {
+            final int count = mAnimations.size();
+            final ArrayList<Animation> animations = mAnimations;
+            final Transformation temp = mTempTransformation;
+
+            final Transformation previousTransformation = mPreviousTransformation;
+
+            for (int i = count - 1; i >= 0; --i) {
+                final Animation a = animations.get(i);
+
+                temp.clear();
+                a.applyTransformation(0.0f, temp);
+                previousTransformation.compose(temp);
+            }
+        }
+    }
+
     /**
      * The transformation of an animation set is the concatenation of all of its
      * component animations.
@@ -313,7 +383,7 @@
                 == PROPERTY_SHARE_INTERPOLATOR_MASK;
         boolean startOffsetSet = (mFlags & PROPERTY_START_OFFSET_MASK)
                 == PROPERTY_START_OFFSET_MASK;
-       
+
         if (shareInterpolator) {
             ensureInterpolator();
         }
@@ -327,7 +397,13 @@
         final int repeatMode = mRepeatMode;
         final Interpolator interpolator = mInterpolator;
         final long startOffset = mStartOffset;
-        
+
+
+        long[] storedOffsets = mStoredOffsets;
+        if (storedOffsets == null || storedOffsets.length != count) {
+            storedOffsets = mStoredOffsets = new long[count];
+        }
+
         for (int i = 0; i < count; i++) {
             Animation a = children.get(i);
             if (durationSet) {
@@ -346,42 +422,36 @@
                 a.setInterpolator(interpolator);
             }
             if (startOffsetSet) {
-                a.setStartOffset(startOffset);
+                long offset = a.getStartOffset();
+                a.setStartOffset(offset + startOffset);
+                storedOffsets[i] = offset;
             }
             a.initialize(width, height, parentWidth, parentHeight);
         }
     }
 
-    /**
-     * @hide
-     * @param startOffset the startOffset to add to the children's startOffset
-     */
-    void saveChildrenStartOffset(long startOffset) {
-        final ArrayList<Animation> children = mAnimations;
-        final int count = children.size();
-        long[] storedOffsets = mStoredOffsets = new long[count];
-
-        for (int i = 0; i < count; i++) {
-            Animation animation = children.get(i);
-            long offset = animation.getStartOffset();
-            animation.setStartOffset(offset + startOffset);
-            storedOffsets[i] = offset;
-        }
+    @Override
+    public void reset() {
+        super.reset();
+        restoreChildrenStartOffset();
     }
 
     /**
      * @hide
      */
     void restoreChildrenStartOffset() {
+        final long[] offsets = mStoredOffsets;
+        if (offsets == null) return;
+
         final ArrayList<Animation> children = mAnimations;
         final int count = children.size();
-        final long[] offsets = mStoredOffsets;
+
 
         for (int i = 0; i < count; i++) {
             children.get(i).setStartOffset(offsets[i]);
         }
     }
-    
+
     /**
      * @return All the child animations in this AnimationSet. Note that
      * this may include other AnimationSets, which are not expanded.
@@ -394,4 +464,9 @@
     public boolean willChangeTransformationMatrix() {
         return (mFlags & PROPERTY_MORPH_MATRIX_MASK) == PROPERTY_MORPH_MATRIX_MASK;
     }
+
+    @Override
+    public boolean willChangeBounds() {
+        return (mFlags & PROPERTY_CHANGE_BOUNDS_MASK) == PROPERTY_CHANGE_BOUNDS_MASK;
+    }
 }
diff --git a/core/java/android/view/animation/LayoutAnimationController.java b/core/java/android/view/animation/LayoutAnimationController.java
index 9cfa8d7..882e738 100644
--- a/core/java/android/view/animation/LayoutAnimationController.java
+++ b/core/java/android/view/animation/LayoutAnimationController.java
@@ -318,9 +318,16 @@
      * @see #getDelayForView(android.view.View)
      */
     public final Animation getAnimationForView(View view) {
-        final long delay = getDelayForView(view);
+        final long delay = getDelayForView(view) + mAnimation.getStartOffset();
         mMaxDelay = Math.max(mMaxDelay, delay);
-        return new DelayedAnimation(delay, mAnimation);
+
+        try {
+            final Animation animation = mAnimation.clone();
+            animation.setStartOffset(delay);
+            return animation;
+        } catch (CloneNotSupportedException e) {
+            return null;
+        }
     }
 
     /**
@@ -425,149 +432,4 @@
          */
         public int index;
     }
-
-    /**
-     * Encapsulates an animation and delays its start offset by a specified
-     * amount. This allows to reuse the same base animation for various views
-     * and get the effect of running multiple instances of the animation at
-     * different times.
-     */
-    private static class DelayedAnimation extends Animation {
-        private final long mDelay;
-        private final Animation mAnimation;
-
-        /**
-         * Creates a new delayed animation that will delay the controller's
-         * animation by the specified delay in milliseconds.
-         *
-         * @param delay the delay in milliseconds by which to offset the
-         * @param animation the animation to delay
-         */
-        private DelayedAnimation(long delay, Animation animation) {
-            mDelay = delay;
-            mAnimation = animation;
-        }
-
-        @Override
-        public boolean isInitialized() {
-            return mAnimation.isInitialized();
-        }
-
-        @Override
-        public void initialize(int width, int height, int parentWidth, int parentHeight) {
-            mAnimation.initialize(width, height, parentWidth, parentHeight);
-        }
-
-        @Override
-        public void reset() {
-            mAnimation.reset();
-        }
-
-        @Override
-        public boolean getTransformation(long currentTime, Transformation outTransformation) {
-            final long oldOffset = mAnimation.getStartOffset();
-            final boolean isSet = mAnimation instanceof AnimationSet;
-            if (isSet) {
-                AnimationSet set = ((AnimationSet) mAnimation);
-                set.saveChildrenStartOffset(mDelay);
-            }
-            mAnimation.setStartOffset(oldOffset + mDelay);
-
-            boolean result = mAnimation.getTransformation(currentTime,
-                    outTransformation);
-            
-            if (isSet) {
-                AnimationSet set = ((AnimationSet) mAnimation);
-                set.restoreChildrenStartOffset();
-            }
-            mAnimation.setStartOffset(oldOffset);
-
-            return result;
-        }
-
-        @Override
-        public void setStartTime(long startTimeMillis) {
-            mAnimation.setStartTime(startTimeMillis);
-        }
-
-        @Override
-        public long getStartTime() {
-            return mAnimation.getStartTime();
-        }
-
-        @Override
-        public void setInterpolator(Interpolator i) {
-            mAnimation.setInterpolator(i);
-        }
-
-        @Override
-        public void setStartOffset(long startOffset) {
-            mAnimation.setStartOffset(startOffset);
-        }
-
-        @Override
-        public void setDuration(long durationMillis) {
-            mAnimation.setDuration(durationMillis);
-        }
-
-        @Override
-        public void scaleCurrentDuration(float scale) {
-            mAnimation.scaleCurrentDuration(scale);
-        }
-
-        @Override
-        public void setRepeatMode(int repeatMode) {
-            mAnimation.setRepeatMode(repeatMode);
-        }
-
-        @Override
-        public void setFillBefore(boolean fillBefore) {
-            mAnimation.setFillBefore(fillBefore);
-        }
-
-        @Override
-        public void setFillAfter(boolean fillAfter) {
-            mAnimation.setFillAfter(fillAfter);
-        }
-
-        @Override
-        public Interpolator getInterpolator() {
-            return mAnimation.getInterpolator();
-        }
-
-        @Override
-        public long getDuration() {
-            return mAnimation.getDuration();
-        }
-
-        @Override
-        public long getStartOffset() {
-            return mAnimation.getStartOffset() + mDelay;
-        }
-
-        @Override
-        public int getRepeatMode() {
-            return mAnimation.getRepeatMode();
-        }
-
-        @Override
-        public boolean getFillBefore() {
-            return mAnimation.getFillBefore();
-        }
-
-        @Override
-        public boolean getFillAfter() {
-            return mAnimation.getFillAfter();
-        }
-
-        @Override
-        public boolean willChangeTransformationMatrix() {
-            return mAnimation.willChangeTransformationMatrix();
-        }
-
-        @Override
-        public boolean willChangeBounds() {
-            return mAnimation.willChangeBounds();
-        }
-    }
 }
diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java
index a6ce293..56c6c92 100644
--- a/core/java/android/view/inputmethod/BaseInputConnection.java
+++ b/core/java/android/view/inputmethod/BaseInputConnection.java
@@ -17,34 +17,364 @@
 package android.view.inputmethod;
 
 import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.Bundle;
 import android.os.Handler;
-import android.os.Message;
+import android.os.SystemClock;
+import android.text.Editable;
+import android.text.NoCopySpan;
+import android.text.Selection;
+import android.text.Spannable;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
+import android.text.TextUtils;
+import android.text.method.MetaKeyKeyListener;
+import android.util.Log;
+import android.util.LogPrinter;
+import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.ViewRoot;
 
+class ComposingText implements NoCopySpan {
+}
+
 /**
  * Base class for implementors of the InputConnection interface, taking care
- * of implementing common system-oriented parts of the functionality.
+ * of most of the common behavior for providing a connection to an Editable.
+ * Implementors of this class will want to be sure to implement
+ * {@link #getEditable} to provide access to their own editable object.
  */
-public abstract class BaseInputConnection implements InputConnection {
+public class BaseInputConnection implements InputConnection {
+    private static final boolean DEBUG = false;
+    private static final String TAG = "BaseInputConnection";
+    static final Object COMPOSING = new ComposingText();
+    
     final InputMethodManager mIMM;
     final Handler mH;
     final View mTargetView;
+    final boolean mDummyMode;
     
-    BaseInputConnection(InputMethodManager mgr) {
+    private Object[] mDefaultComposingSpans;
+    
+    Editable mEditable;
+    KeyCharacterMap mKeyCharacterMap;
+    
+    BaseInputConnection(InputMethodManager mgr, boolean dummyMode) {
         mIMM = mgr;
         mTargetView = null;
         mH = null;
+        mDummyMode = dummyMode;
     }
     
-    public BaseInputConnection(View targetView) {
+    public BaseInputConnection(View targetView, boolean dummyMode) {
         mIMM = (InputMethodManager)targetView.getContext().getSystemService(
                 Context.INPUT_METHOD_SERVICE);
         mH = targetView.getHandler();
         mTargetView = targetView;
+        mDummyMode = dummyMode;
     }
     
+    public static final void removeComposingSpans(Spannable text) {
+        text.removeSpan(COMPOSING);
+        Object[] sps = text.getSpans(0, text.length(), Object.class);
+        if (sps != null) {
+            for (int i=sps.length-1; i>=0; i--) {
+                Object o = sps[i];
+                if ((text.getSpanFlags(o)&Spanned.SPAN_COMPOSING) != 0) {
+                    text.removeSpan(o);
+                }
+            }
+        }
+    }
+    
+    public static void setComposingSpans(Spannable text) {
+        final Object[] sps = text.getSpans(0, text.length(), Object.class);
+        if (sps != null) {
+            for (int i=sps.length-1; i>=0; i--) {
+                final Object o = sps[i];
+                if (o == COMPOSING) {
+                    text.removeSpan(o);
+                    continue;
+                }
+                final int fl = text.getSpanFlags(o);
+                if ((fl&(Spanned.SPAN_COMPOSING|Spanned.SPAN_POINT_MARK_MASK)) 
+                        != (Spanned.SPAN_COMPOSING|Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)) {
+                    text.setSpan(o, text.getSpanStart(o), text.getSpanEnd(o),
+                            (fl&Spanned.SPAN_POINT_MARK_MASK)
+                                    | Spanned.SPAN_COMPOSING
+                                    | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+                }
+            }
+        }
+        
+        text.setSpan(COMPOSING, 0, text.length(),
+                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
+    }
+    
+    public static int getComposingSpanStart(Spannable text) {
+        return text.getSpanStart(COMPOSING);
+    }
+    
+    public static int getComposingSpanEnd(Spannable text) {
+        return text.getSpanEnd(COMPOSING);
+    }
+    
+    /**
+     * Return the target of edit operations.  The default implementation
+     * returns its own fake editable that is just used for composing text;
+     * subclasses that are real text editors should override this and
+     * supply their own.
+     */
+    public Editable getEditable() {
+        if (mEditable == null) {
+            mEditable = Editable.Factory.getInstance().newEditable("");
+            Selection.setSelection(mEditable, 0);
+        }
+        return mEditable;
+    }
+    
+    /**
+     * Default implementation does nothing.
+     */
+    public boolean beginBatchEdit() {
+        return false;
+    }
+
+    /**
+     * Default implementation does nothing.
+     */
+    public boolean endBatchEdit() {
+        return false;
+    }
+
+    /**
+     * Default implementation uses
+     * {@link MetaKeyKeyListener#clearMetaKeyState(long, int)
+     * MetaKeyKeyListener.clearMetaKeyState(long, int)} to clear the state.
+     */
+    public boolean clearMetaKeyStates(int states) {
+        final Editable content = getEditable();
+        if (content == null) return false;
+        MetaKeyKeyListener.clearMetaKeyState(content, states);
+        return true;
+    }
+
+    /**
+     * Default implementation does nothing.
+     */
+    public boolean commitCompletion(CompletionInfo text) {
+        return false;
+    }
+
+    /**
+     * Default implementation replaces any existing composing text with
+     * the given text.  In addition, only if dummy mode, a key event is
+     * sent for the new text and the current editable buffer cleared.
+     */
+    public boolean commitText(CharSequence text, int newCursorPosition) {
+        if (DEBUG) Log.v(TAG, "commitText " + text);
+        replaceText(text, newCursorPosition, false);
+        sendCurrentText();
+        return true;
+    }
+
+    /**
+     * The default implementation performs the deletion around the current
+     * selection position of the editable text.
+     */
+    public boolean deleteSurroundingText(int leftLength, int rightLength) {
+        if (DEBUG) Log.v(TAG, "deleteSurroundingText " + leftLength
+                + " / " + rightLength);
+        final Editable content = getEditable();
+        if (content == null) return false;
+
+        beginBatchEdit();
+        
+        int a = Selection.getSelectionStart(content);
+        int b = Selection.getSelectionEnd(content);
+
+        if (a > b) {
+            int tmp = a;
+            a = b;
+            b = tmp;
+        }
+
+        // ignore the composing text.
+        int ca = getComposingSpanStart(content);
+        int cb = getComposingSpanEnd(content);
+        if (cb < ca) {
+            int tmp = ca;
+            ca = cb;
+            cb = tmp;
+        }
+        if (ca != -1 && cb != -1) {
+            if (ca < a) a = ca;
+            if (cb > b) b = cb;
+        }
+
+        int deleted = 0;
+
+        if (leftLength > 0) {
+            int start = a - leftLength;
+            if (start < 0) start = 0;
+            content.delete(start, a);
+            deleted = a - start;
+        }
+
+        if (rightLength > 0) {
+            b = b - deleted;
+
+            int end = b + rightLength;
+            if (end > content.length()) end = content.length();
+
+            content.delete(b, end);
+        }
+        
+        endBatchEdit();
+        
+        return true;
+    }
+
+    /**
+     * The default implementation removes the composing state from the
+     * current editable text.  In addition, only if dummy mode, a key event is
+     * sent for the new text and the current editable buffer cleared.
+     */
+    public boolean finishComposingText() {
+        if (DEBUG) Log.v(TAG, "finishComposingText");
+        final Editable content = getEditable();
+        if (content != null) {
+            beginBatchEdit();
+            removeComposingSpans(content);
+            endBatchEdit();
+            sendCurrentText();
+        }
+        return true;
+    }
+
+    /**
+     * The default implementation uses TextUtils.getCapsMode to get the
+     * cursor caps mode for the current selection position in the editable
+     * text, unless in dummy mode in which case 0 is always returned.
+     */
+    public int getCursorCapsMode(int reqModes) {
+        if (mDummyMode) return 0;
+        
+        final Editable content = getEditable();
+        if (content == null) return 0;
+        
+        int a = Selection.getSelectionStart(content);
+        int b = Selection.getSelectionEnd(content);
+
+        if (a > b) {
+            int tmp = a;
+            a = b;
+            b = tmp;
+        }
+
+        return TextUtils.getCapsMode(content, a, reqModes);
+    }
+
+    /**
+     * The default implementation always returns null.
+     */
+    public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
+        return null;
+    }
+
+    /**
+     * The default implementation returns the given amount of text from the
+     * current cursor position in the buffer.
+     */
+    public CharSequence getTextBeforeCursor(int length, int flags) {
+        final Editable content = getEditable();
+        if (content == null) return null;
+
+        int a = Selection.getSelectionStart(content);
+        int b = Selection.getSelectionEnd(content);
+
+        if (a > b) {
+            int tmp = a;
+            a = b;
+            b = tmp;
+        }
+
+        if (length > a) {
+            length = a;
+        }
+
+        if ((flags&GET_TEXT_WITH_STYLES) != 0) {
+            return content.subSequence(a - length, a);
+        }
+        return TextUtils.substring(content, a - length, a);
+    }
+
+    /**
+     * The default implementation returns the given amount of text from the
+     * current cursor position in the buffer.
+     */
+    public CharSequence getTextAfterCursor(int length, int flags) {
+        final Editable content = getEditable();
+        if (content == null) return null;
+
+        int a = Selection.getSelectionStart(content);
+        int b = Selection.getSelectionEnd(content);
+
+        if (a > b) {
+            int tmp = a;
+            a = b;
+            b = tmp;
+        }
+
+        if (b + length > content.length()) {
+            length = content.length() - b;
+        }
+
+
+        if ((flags&GET_TEXT_WITH_STYLES) != 0) {
+            return content.subSequence(b, b + length);
+        }
+        return TextUtils.substring(content, b, b + length);
+    }
+
+    /**
+     * The default implementation does nothing.
+     */
+    public boolean performContextMenuAction(int id) {
+        return false;
+    }
+
+    /**
+     * The default implementation does nothing.
+     */
+    public boolean performPrivateCommand(String action, Bundle data) {
+        return false;
+    }
+
+    /**
+     * The default implementation places the given text into the editable,
+     * replacing any existing composing text.  The new text is marked as
+     * in a composing state with the composing style.
+     */
+    public boolean setComposingText(CharSequence text, int newCursorPosition) {
+        if (DEBUG) Log.v(TAG, "setComposingText " + text);
+        replaceText(text, newCursorPosition, true);
+        return true;
+    }
+
+    /**
+     * The default implementation changes the selection position in the
+     * current editable text.
+     */
+    public boolean setSelection(int start, int end) {
+        if (DEBUG) Log.v(TAG, "setSelection " + start + ", " + end);
+        final Editable content = getEditable();
+        if (content == null) return false;
+        Selection.setSelection(content, start, end);
+        return true;
+    }
+
     /**
      * Provides standard implementation for sending a key event to the window
      * attached to the input connection's view.
@@ -82,4 +412,144 @@
         mIMM.updateStatusIcon(resId, packageName);
         return true;
     }
+    
+    private void sendCurrentText() {
+        if (!mDummyMode) {
+            return;
+        }
+        
+        Editable content = getEditable();
+        if (content != null) {
+            if (content.length() == 1) {
+                // If it's 1 character, we have a chance of being
+                // able to generate normal key events...
+                if (mKeyCharacterMap == null) {
+                    mKeyCharacterMap = KeyCharacterMap.load(
+                            KeyCharacterMap.BUILT_IN_KEYBOARD);
+                }
+                char[] chars = new char[1];
+                content.getChars(0, 1, chars, 0);
+                KeyEvent[] events = mKeyCharacterMap.getEvents(chars);
+                if (events != null) {
+                    for (int i=0; i<events.length; i++) {
+                        if (DEBUG) Log.v(TAG, "Sending: " + events[i]);
+                        sendKeyEvent(events[i]);
+                    }
+                    content.clear();
+                    return;
+                }
+            }
+            
+            // Otherwise, revert to the special key event containing
+            // the actual characters.
+            KeyEvent event = new KeyEvent(SystemClock.uptimeMillis(),
+                    content.toString(), KeyCharacterMap.BUILT_IN_KEYBOARD, 0);
+            sendKeyEvent(event);
+            content.clear();
+        }
+    }
+    
+    private void replaceText(CharSequence text, int newCursorPosition,
+            boolean composing) {
+        final Editable content = getEditable();
+        if (content == null) {
+            return;
+        }
+        
+        beginBatchEdit();
+        
+        // delete composing text set previously.
+        int a = getComposingSpanStart(content);
+        int b = getComposingSpanEnd(content);
+
+        if (DEBUG) Log.v(TAG, "Composing span: " + a + " to " + b);
+        
+        if (b < a) {
+            int tmp = a;
+            a = b;
+            b = tmp;
+        }
+
+        if (a != -1 && b != -1) {
+            removeComposingSpans(content);
+        } else {
+            a = Selection.getSelectionStart(content);
+            b = Selection.getSelectionEnd(content);
+            if (a >=0 && b>= 0 && a != b) {
+                if (b < a) {
+                    int tmp = a;
+                    a = b;
+                    b = tmp;
+                }
+            }
+        }
+
+        if (composing) {
+            Spannable sp = null;
+            if (!(text instanceof Spannable)) {
+                sp = new SpannableStringBuilder(text);
+                text = sp;
+                if (mDefaultComposingSpans == null) {
+                    Context context;
+                    if (mTargetView != null) {
+                        context = mTargetView.getContext();
+                    } else if (mIMM.mServedView != null) {
+                        context = mIMM.mServedView.getContext();
+                    } else {
+                        context = null;
+                    }
+                    if (context != null) {
+                        TypedArray ta = context.getTheme()
+                                .obtainStyledAttributes(new int[] {
+                                        com.android.internal.R.attr.candidatesTextStyleSpans
+                                });
+                        CharSequence style = ta.getText(0);
+                        ta.recycle();
+                        if (style != null && style instanceof Spanned) {
+                            mDefaultComposingSpans = ((Spanned)style).getSpans(
+                                    0, style.length(), Object.class);
+                        }
+                    }
+                }
+                if (mDefaultComposingSpans != null) {
+                    for (int i = 0; i < mDefaultComposingSpans.length; ++i) {
+                        sp.setSpan(mDefaultComposingSpans[i], 0, sp.length(),
+                                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+                    }
+                }
+            } else {
+                sp = (Spannable)text;
+            }
+            setComposingSpans(sp);
+        }
+        
+        // Adjust newCursorPosition to be relative the start of the text.
+        newCursorPosition += a;
+
+        if (DEBUG) Log.v(TAG, "Replacing from " + a + " to " + b + " with \""
+                + text + "\", composing=" + composing
+                + ", type=" + text.getClass().getCanonicalName());
+        
+        if (DEBUG) {
+            LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
+            lp.println("Current text:");
+            TextUtils.dumpSpans(content, lp, "  ");
+            lp.println("Composing text:");
+            TextUtils.dumpSpans(text, lp, "  ");
+        }
+        
+        content.replace(a, b, text);
+        if (newCursorPosition < 0) newCursorPosition = 0;
+        if (newCursorPosition > content.length())
+            newCursorPosition = content.length();
+        Selection.setSelection(content, newCursorPosition);
+        
+        if (DEBUG) {
+            LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
+            lp.println("Final text:");
+            TextUtils.dumpSpans(content, lp, "  ");
+        }
+        
+        endBatchEdit();
+    }
 }
diff --git a/core/java/android/view/inputmethod/DefaultInputMethod.java b/core/java/android/view/inputmethod/DefaultInputMethod.java
deleted file mode 100644
index 073b01c..0000000
--- a/core/java/android/view/inputmethod/DefaultInputMethod.java
+++ /dev/null
@@ -1,239 +0,0 @@
-package android.view.inputmethod;
-
-import android.graphics.Rect;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-import com.android.internal.view.IInputContext;
-import com.android.internal.view.IInputMethod;
-import com.android.internal.view.IInputMethodCallback;
-import com.android.internal.view.IInputMethodSession;
-import com.android.internal.view.InputConnectionWrapper;
-
-/**
- * This is the default input method that runs in the same context of the
- * application that requests text input. It does nothing but returns false for
- * any key events, so that all key events will be processed by the key listener
- * of the focused text box.
- * {@hide}
- */
-public class DefaultInputMethod implements InputMethod, InputMethodSession {
-    private static IInputMethod sInstance = new SimpleInputMethod(
-            new DefaultInputMethod());
-
-    private static InputMethodInfo sProperty = new InputMethodInfo(
-            "android.text.inputmethod", DefaultInputMethod.class.getName(),
-            "Default", "android.text.inputmethod.defaultImeSettings");
-
-    private InputConnection mInputConnection;
-
-    public static IInputMethod getInstance() {
-        return sInstance;
-    }
-
-    public static InputMethodInfo getMetaInfo() {
-        return sProperty;
-    }
-
-    public void bindInput(InputBinding binding) {
-        mInputConnection = binding.getConnection();
-    }
-
-    public void unbindInput() {
-    }
-
-    public void createSession(SessionCallback callback) {
-        callback.sessionCreated(this);
-    }
-
-    public void setSessionEnabled(InputMethodSession session, boolean enabled) {
-    }
-
-    public void revokeSession(InputMethodSession session) {
-    }
-
-    public void finishInput() {
-        mInputConnection.hideStatusIcon();
-    }
-
-    public void displayCompletions(CompletionInfo[] completions) {
-    }
-    
-    public void updateExtractedText(int token, ExtractedText text) {
-    }
-    
-    public void updateSelection(int oldSelStart, int oldSelEnd,
-            int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd) {
-    }
-
-    public void updateCursor(Rect newCursor) {
-    }
-
-    public void dispatchKeyEvent(int seq, KeyEvent event, EventCallback callback) {
-        callback.finishedEvent(seq, false);
-    }
-
-    public void dispatchTrackballEvent(int seq, MotionEvent event, EventCallback callback) {
-        callback.finishedEvent(seq, false);
-    }
-
-    public void restartInput(EditorInfo attribute) {
-    }
-
-    public void attachToken(IBinder token) {
-    }
-
-    public void startInput(EditorInfo attribute) {
-        mInputConnection
-                .showStatusIcon("android", com.android.internal.R.drawable.ime_qwerty);
-    }
-
-    public void appPrivateCommand(String action, Bundle data) {
-    }
-    
-    public void hideSoftInput() {
-    }
-
-    public void showSoftInput(int flags) {
-    }
-}
-
-// ----------------------------------------------------------------------
-
-class SimpleInputMethod extends IInputMethod.Stub {
-    final InputMethod mInputMethod;
-
-    static class Session extends IInputMethodSession.Stub {
-        final InputMethodSession mSession;
-        
-        Session(InputMethodSession session) {
-            mSession = session;
-        }
-        
-        public void finishInput() {
-            mSession.finishInput();
-        }
-        
-        public void updateSelection(int oldSelStart, int oldSelEnd,
-                int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd) {
-            mSession.updateSelection(oldSelStart, oldSelEnd,
-                    newSelStart, newSelEnd, candidatesStart, candidatesEnd);
-        }
-
-        public void updateCursor(Rect newCursor) {
-            mSession.updateCursor(newCursor);
-        }
-
-        static class InputMethodEventCallbackWrapper implements InputMethodSession.EventCallback {
-            final IInputMethodCallback mCb;
-            InputMethodEventCallbackWrapper(IInputMethodCallback cb) {
-                mCb = cb;
-            }
-            public void finishedEvent(int seq, boolean handled) {
-                try {
-                    mCb.finishedEvent(seq, handled);
-                } catch (RemoteException e) {
-                }
-            }
-        }
-        
-        public void dispatchKeyEvent(int seq, KeyEvent event, IInputMethodCallback callback) {
-            mSession.dispatchKeyEvent(seq, event,
-                    new InputMethodEventCallbackWrapper(callback));
-        }
-
-        public void dispatchTrackballEvent(int seq, MotionEvent event, IInputMethodCallback callback) {
-            mSession.dispatchTrackballEvent(seq, event,
-                    new InputMethodEventCallbackWrapper(callback));
-        }
-        
-        public void displayCompletions(CompletionInfo[] completions) {
-            mSession.displayCompletions(completions);
-        }
-        
-        public void updateExtractedText(int token, ExtractedText text) {
-            mSession.updateExtractedText(token, text);
-        }
-        
-        public void appPrivateCommand(String action, Bundle data) {
-            mSession.appPrivateCommand(action, data);
-        }
-    }
-    
-    public SimpleInputMethod(InputMethod inputMethod) {
-        mInputMethod = inputMethod;
-    }
-
-    public InputMethod getInternalInputMethod() {
-        return mInputMethod;
-    }
-
-    public void attachToken(IBinder token) {
-        mInputMethod.attachToken(token);
-    }
-    
-    public void bindInput(InputBinding binding) {
-        InputConnectionWrapper ic = new InputConnectionWrapper(
-                IInputContext.Stub.asInterface(binding.getConnectionToken()));
-        InputBinding nu = new InputBinding(ic, binding);
-        mInputMethod.bindInput(nu);
-    }
-
-    public void unbindInput() {
-        mInputMethod.unbindInput();
-    }
-
-    public void restartInput(EditorInfo attribute) {
-        mInputMethod.restartInput(attribute);
-    }
-
-    public void startInput(EditorInfo attribute) {
-        mInputMethod.startInput(attribute);
-    }
-
-    static class InputMethodSessionCallbackWrapper implements InputMethod.SessionCallback {
-        final IInputMethodCallback mCb;
-        InputMethodSessionCallbackWrapper(IInputMethodCallback cb) {
-            mCb = cb;
-        }
-        
-        public void sessionCreated(InputMethodSession session) {
-            try {
-                mCb.sessionCreated(new Session(session));
-            } catch (RemoteException e) {
-            }
-        }
-    }
-    
-    public void createSession(IInputMethodCallback callback) throws RemoteException {
-        mInputMethod.createSession(new InputMethodSessionCallbackWrapper(callback));
-    }
-
-    public void setSessionEnabled(IInputMethodSession session, boolean enabled) throws RemoteException {
-        try {
-            InputMethodSession ls = ((Session)session).mSession;
-            mInputMethod.setSessionEnabled(ls, enabled);
-        } catch (ClassCastException e) {
-            Log.w("SimpleInputMethod", "Incoming session not of correct type: " + session, e);
-        }
-    }
-
-    public void revokeSession(IInputMethodSession session) throws RemoteException {
-        try {
-            InputMethodSession ls = ((Session)session).mSession;
-            mInputMethod.revokeSession(ls);
-        } catch (ClassCastException e) {
-            Log.w("SimpleInputMethod", "Incoming session not of correct type: " + session, e);
-        }
-    }
-
-    public void showSoftInput(boolean blah) {
-    }
-    
-    public void hideSoftInput() {
-    }
-}
diff --git a/core/java/android/view/inputmethod/EditorInfo.java b/core/java/android/view/inputmethod/EditorInfo.java
index c050691..b2f26d7 100644
--- a/core/java/android/view/inputmethod/EditorInfo.java
+++ b/core/java/android/view/inputmethod/EditorInfo.java
@@ -5,6 +5,7 @@
 import android.os.Parcelable;
 import android.text.InputType;
 import android.text.TextUtils;
+import android.util.Printer;
 
 /**
  * An EditorInfo describes several attributes of a text editing object
@@ -21,7 +22,7 @@
      * @see #TYPE_MASK_VARIATION
      * @see #TYPE_MASK_FLAGS
      */
-    public int inputType = TYPE_CLASS_TEXT;
+    public int inputType = TYPE_NULL;
 
     /**
      * A string supplying additional information about the content type that
@@ -71,6 +72,26 @@
     public CharSequence label;
     
     /**
+     * Name of the package that owns this editor.
+     */
+    public String packageName;
+    
+    /**
+     * Identifier for the editor's field.  This is optional, and may be
+     * 0.  By default it is filled in with the result of
+     * {@link android.view.View#getId() View.getId()} on the View that
+     * is being edited.
+     */
+    public int fieldId;
+    
+    /**
+     * Additional name for the editor's field.  This can supply additional
+     * name information for the field.  By default it is null.  The actual
+     * contents have no meaning.
+     */
+    public String fieldName;
+    
+    /**
      * Any extra data to supply to the input method.  This is for extended
      * communication with specific input methods; the name fields in the
      * bundle should be scoped (such as "com.mydomain.im.SOME_FIELD") so
@@ -81,6 +102,24 @@
     public Bundle extras;
     
     /**
+     * Write debug output of this object.
+     */
+    public void dump(Printer pw, String prefix) {
+        pw.println(prefix + "inputType=0x" + Integer.toHexString(inputType)
+                + " privateContentType=" + privateContentType);
+        pw.println(prefix + "initialSelStart=" + initialSelStart
+                + " initialSelEnd=" + initialSelEnd
+                + " initialCapsMode=0x"
+                + Integer.toHexString(initialCapsMode));
+        pw.println(prefix + "hintText=" + hintText
+                + " label=" + label);
+        pw.println(prefix + "packageName=" + packageName
+                + " fieldId=" + fieldId
+                + " fieldName=" + fieldName);
+        pw.println(prefix + "extras=" + extras);
+    }
+    
+    /**
      * Used to package this object into a {@link Parcel}.
      * 
      * @param dest The {@link Parcel} to be written.
@@ -94,6 +133,9 @@
         dest.writeInt(initialCapsMode);
         TextUtils.writeToParcel(hintText, dest, flags);
         TextUtils.writeToParcel(label, dest, flags);
+        dest.writeString(packageName);
+        dest.writeInt(fieldId);
+        dest.writeString(fieldName);
         dest.writeBundle(extras);
     }
 
@@ -110,6 +152,9 @@
             res.initialCapsMode = source.readInt();
             res.hintText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
             res.label = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
+            res.packageName = source.readString();
+            res.fieldId = source.readInt();
+            res.fieldName = source.readString();
             res.extras = source.readBundle();
             return res;
         }
diff --git a/core/java/android/view/inputmethod/ExtractedText.java b/core/java/android/view/inputmethod/ExtractedText.java
index 0ca3c79..e5d3cae 100644
--- a/core/java/android/view/inputmethod/ExtractedText.java
+++ b/core/java/android/view/inputmethod/ExtractedText.java
@@ -19,6 +19,22 @@
     public int startOffset;
     
     /**
+     * If the content is a report of a partial text change, this is the
+     * offset where the change starts and it runs until
+     * {@link #partialEndOffset}.  If the content is the full text, this
+     * field is -1.
+     */
+    public int partialStartOffset;
+    
+    /**
+     * If the content is a report of a partial text change, this is the offset
+     * where the change ends.  Note that the actual text may be larger or
+     * smaller than the difference between this and {@link #partialEndOffset},
+     * meaning a reduction or increase, respectively, in the total text.
+     */
+    public int partialEndOffset;
+    
+    /**
      * The offset where the selection currently starts within the extracted
      * text.  The real selection start position is at
      * <var>startOffset</var>+<var>selectionStart</var>.
@@ -52,6 +68,8 @@
     public void writeToParcel(Parcel dest, int flags) {
         TextUtils.writeToParcel(text, dest, flags);
         dest.writeInt(startOffset);
+        dest.writeInt(partialStartOffset);
+        dest.writeInt(partialEndOffset);
         dest.writeInt(selectionStart);
         dest.writeInt(selectionEnd);
         dest.writeInt(flags);
@@ -65,6 +83,8 @@
             ExtractedText res = new ExtractedText();
             res.text = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
             res.startOffset = source.readInt();
+            res.partialStartOffset = source.readInt();
+            res.partialEndOffset = source.readInt();
             res.selectionStart = source.readInt();
             res.selectionEnd = source.readInt();
             res.flags = source.readInt();
diff --git a/core/java/android/view/inputmethod/ExtractedTextRequest.java b/core/java/android/view/inputmethod/ExtractedTextRequest.java
index d962329..e84b094 100644
--- a/core/java/android/view/inputmethod/ExtractedTextRequest.java
+++ b/core/java/android/view/inputmethod/ExtractedTextRequest.java
@@ -16,6 +16,13 @@
     public int token;
     
     /**
+     * Additional request flags, having the same possible values as the
+     * flags parameter of {@link InputConnection#getTextBeforeCursor
+     * InputConnection.getTextBeforeCursor()}.
+     */
+    public int flags;
+    
+    /**
      * Hint for the maximum number of lines to return.
      */
     public int hintMaxLines;
@@ -33,6 +40,7 @@
      */
     public void writeToParcel(Parcel dest, int flags) {
         dest.writeInt(token);
+        dest.writeInt(this.flags);
         dest.writeInt(hintMaxLines);
         dest.writeInt(hintMaxChars);
     }
@@ -45,6 +53,7 @@
         public ExtractedTextRequest createFromParcel(Parcel source) {
             ExtractedTextRequest res = new ExtractedTextRequest();
             res.token = source.readInt();
+            res.flags = source.readInt();
             res.hintMaxLines = source.readInt();
             res.hintMaxChars = source.readInt();
             return res;
diff --git a/core/java/android/view/inputmethod/InputConnection.java b/core/java/android/view/inputmethod/InputConnection.java
index bd7b050..8c30d3f 100644
--- a/core/java/android/view/inputmethod/InputConnection.java
+++ b/core/java/android/view/inputmethod/InputConnection.java
@@ -32,6 +32,21 @@
  */
 public interface InputConnection {
     /**
+     * Flag for use with {@link #getTextAfterCursor} and
+     * {@link #getTextBeforeCursor} to have style information returned along
+     * with the text.  If not set, you will receive only the raw text.  If
+     * set, you may receive a complex CharSequence of both text and style
+     * spans.
+     */
+    static final int GET_TEXT_WITH_STYLES = 0x0001;
+    
+    /**
+     * Flag for use with {@link #getExtractedText} to indicate you would
+     * like to receive updates when the extracted text changes.
+     */
+    public static final int GET_EXTRACTED_TEXT_MONITOR = 0x0001;
+    
+    /**
      * Get <var>n</var> characters of text before the current cursor position.
      * 
      * <p>This method may fail either if the input connection has become invalid
@@ -40,11 +55,13 @@
      * In either case, a null is returned.
      * 
      * @param n The expected length of the text.
+     * @param flags Supplies additional options controlling how the text is
+     * returned.  May be either 0 or {@link #GET_TEXT_WITH_STYLES}.
      * 
      * @return Returns the text before the cursor position; the length of the
      * returned text might be less than <var>n</var>.
      */
-    public CharSequence getTextBeforeCursor(int n);
+    public CharSequence getTextBeforeCursor(int n, int flags);
 
     /**
      * Get <var>n</var> characters of text after the current cursor position.
@@ -55,11 +72,13 @@
      * In either case, a null is returned.
      * 
      * @param n The expected length of the text.
+     * @param flags Supplies additional options controlling how the text is
+     * returned.  May be either 0 or {@link #GET_TEXT_WITH_STYLES}.
      * 
      * @return Returns the text after the cursor position; the length of the
      * returned text might be less than <var>n</var>.
      */
-    public CharSequence getTextAfterCursor(int n);
+    public CharSequence getTextAfterCursor(int n, int flags);
 
     /**
      * Retrieve the current capitalization mode in effect at the current
@@ -82,8 +101,6 @@
      */
     public int getCursorCapsMode(int reqModes);
     
-    public static final int EXTRACTED_TEXT_MONITOR = 0x0001;
-    
     /**
      * Retrieve the current text in the input connection's editor, and monitor
      * for any changes to it.  This function returns with the current text,
@@ -97,7 +114,7 @@
      * 
      * @param request Description of how the text should be returned.
      * @param flags Additional options to control the client, either 0 or
-     * {@link #EXTRACTED_TEXT_MONITOR}.
+     * {@link #GET_EXTRACTED_TEXT_MONITOR}.
      * 
      * @return Returns an ExtractedText object describing the state of the
      * text view and containing the extracted text itself.
@@ -141,7 +158,7 @@
 
     /**
      * Have the text editor finish whatever composing text is currently
-     * active.  This simple leaves the text as-is, removing any special
+     * active.  This simply leaves the text as-is, removing any special
      * composing styling or other state that was around it.  The cursor
      * position remains unchanged.
      */
@@ -177,6 +194,22 @@
     public boolean commitCompletion(CompletionInfo text);
 
     /**
+     * Set the selection of the text editor.  To set the cursor position,
+     * start and end should have the same value.
+     */
+    public boolean setSelection(int start, int end);
+    
+    /**
+     * Perform a context menu action on the field.  The given id may be one of:
+     * {@link android.R.id#selectAll},
+     * {@link android.R.id#startSelectingText}, {@link android.R.id#stopSelectingText},
+     * {@link android.R.id#cut}, {@link android.R.id#copy},
+     * {@link android.R.id#paste}, {@link android.R.id#copyUrl},
+     * or {@link android.R.id#switchInputMethod}
+     */
+    public boolean performContextMenuAction(int id);
+    
+    /**
      * Tell the editor that you are starting a batch of editor operations.
      * The editor will try to avoid sending you updates about its state
      * until {@link #endBatchEdit} is called.
diff --git a/core/java/android/view/inputmethod/InputConnectionWrapper.java b/core/java/android/view/inputmethod/InputConnectionWrapper.java
deleted file mode 100644
index f65b2a10..0000000
--- a/core/java/android/view/inputmethod/InputConnectionWrapper.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2007-2008 The Android Open Source Project
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package android.view.inputmethod;
-
-import android.os.Bundle;
-import android.view.KeyEvent;
-
-/**
- * Wrapper around InputConnection interface, calling through to another
- * implementation of it.
- */
-public class InputConnectionWrapper implements InputConnection {
-    InputConnection mBase;
-    
-    /**
-     * Create a new wrapper around an existing InputConnection implementation.
-     */
-    public InputConnectionWrapper(InputConnection base) {
-        mBase = base;
-    }
-    
-    /**
-     * Return the base InputConnection that this class is wrapping.
-     */
-    InputConnection getBase() {
-        return mBase;
-    }
-    
-    public CharSequence getTextBeforeCursor(int n) {
-        return mBase.getTextBeforeCursor(n);
-    }
-
-    public CharSequence getTextAfterCursor(int n) {
-        return mBase.getTextAfterCursor(n);
-    }
-
-    public int getCursorCapsMode(int reqModes) {
-        return mBase.getCursorCapsMode(reqModes);
-    }
-    
-    public ExtractedText getExtractedText(ExtractedTextRequest request,
-            int flags) {
-        return mBase.getExtractedText(request, flags);
-    }
-
-    public boolean deleteSurroundingText(int leftLength, int rightLength) {
-        return mBase.deleteSurroundingText(leftLength, rightLength);
-    }
-
-    public boolean setComposingText(CharSequence text, int newCursorPosition) {
-        return mBase.setComposingText(text, newCursorPosition);
-    }
-
-    public boolean finishComposingText() {
-        return mBase.finishComposingText();
-    }
-    
-    public boolean commitText(CharSequence text, int newCursorPosition) {
-        return mBase.commitText(text, newCursorPosition);
-    }
-
-    public boolean commitCompletion(CompletionInfo text) {
-        return mBase.commitCompletion(text);
-    }
-    
-    public boolean beginBatchEdit() {
-        return mBase.beginBatchEdit();
-    }
-    
-    public boolean endBatchEdit() {
-        return mBase.endBatchEdit();
-    }
-    
-    public boolean sendKeyEvent(KeyEvent event) {
-        return mBase.sendKeyEvent(event);
-    }
-
-    public boolean clearMetaKeyStates(int states) {
-        return mBase.clearMetaKeyStates(states);
-    }
-    
-    public boolean performPrivateCommand(String action, Bundle data) {
-        return mBase.performPrivateCommand(action, data);
-    }
-    
-    public boolean showStatusIcon(String packageName, int resId) {
-        return mBase.showStatusIcon(packageName, resId);
-    }
-    
-    public boolean hideStatusIcon() {
-        return mBase.hideStatusIcon();
-    }
-}
diff --git a/core/java/android/view/inputmethod/InputMethod.java b/core/java/android/view/inputmethod/InputMethod.java
index c0e6590c..740dca8 100644
--- a/core/java/android/view/inputmethod/InputMethod.java
+++ b/core/java/android/view/inputmethod/InputMethod.java
@@ -113,12 +113,15 @@
      * is ready for this input method to process received events and send result
      * text back to the application.
      * 
-     * @param attribute The attribute of the text box (typically, a EditText)
+     * @param inputConnection Optional specific input connection for
+     * communicating with the text box; if null, you should use the generic
+     * bound input connection.
+     * @param info Information about the text box (typically, an EditText)
      *        that requests input.
      * 
      * @see EditorInfo
      */
-    public void startInput(EditorInfo attribute);
+    public void startInput(InputConnection inputConnection, EditorInfo info);
 
     /**
      * This method is called when the state of this input method needs to be
@@ -128,12 +131,15 @@
      * Typically, this method is called when the input focus is moved from one
      * text box to another.
      * 
+     * @param inputConnection Optional specific input connection for
+     * communicating with the text box; if null, you should use the generic
+     * bound input connection.
      * @param attribute The attribute of the text box (typically, a EditText)
      *        that requests input.
      * 
      * @see EditorInfo
      */
-    public void restartInput(EditorInfo attribute);
+    public void restartInput(InputConnection inputConnection, EditorInfo attribute);
 
     /**
      * Create a new {@link InputMethodSession} that can be handed to client
@@ -173,6 +179,13 @@
     public static final int SHOW_EXPLICIT = 0x00001;
     
     /**
+     * Flag for {@link #showSoftInput(int)}: this show has been forced to
+     * happen by the user.  If set, the input method should remain visible
+     * until deliberated dismissed by the user in its UI.
+     */
+    public static final int SHOW_FORCED = 0x00002;
+    
+    /**
      * Request that any soft input part of the input method be shown to the user.
      * 
      * @param flags Provide additional information about the show request.
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index a9a9594..99d5aa5 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -26,11 +26,14 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.util.Log;
+import android.util.PrintWriterPrinter;
+import android.util.Printer;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewRoot;
 
+import com.android.internal.os.HandlerCaller;
 import com.android.internal.view.IInputConnectionWrapper;
 import com.android.internal.view.IInputContext;
 import com.android.internal.view.IInputMethodCallback;
@@ -39,7 +42,11 @@
 import com.android.internal.view.IInputMethodSession;
 import com.android.internal.view.InputBindResult;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Central system API to the overall input method framework (IMF) architecture,
@@ -199,8 +206,7 @@
     // global lock.
     final H mH;
     
-    // The currently active input connection.
-    final MutableInputConnectionWrapper mInputConnectionWrapper;
+    // Our generic input connection if the current target does not have its own.
     final IInputContext mIInputContext;
 
     /**
@@ -208,11 +214,6 @@
      */
     boolean mActive = false;
     
-    /**
-     * The current base input connection, used when mActive is true.
-     */
-    InputConnection mCurrentInputConnection;
-
     // -----------------------------------------------------------
     
     /**
@@ -270,7 +271,7 @@
 
     // -----------------------------------------------------------
     
-    static final int MSG_CHECK_FOCUS = 1;
+    static final int MSG_DUMP = 1;
     
     class H extends Handler {
         H(Looper looper) {
@@ -280,85 +281,55 @@
         @Override
         public void handleMessage(Message msg) {
             switch (msg.what) {
-                case MSG_CHECK_FOCUS:
-                    checkFocus();
+                case MSG_DUMP: {
+                    HandlerCaller.SomeArgs args = (HandlerCaller.SomeArgs)msg.obj;
+                    try {
+                        doDump((FileDescriptor)args.arg1,
+                                (PrintWriter)args.arg2, (String[])args.arg3);
+                    } catch (RuntimeException e) {
+                        ((PrintWriter)args.arg2).println("Exception: " + e);
+                    }
+                    synchronized (args.arg4) {
+                        ((CountDownLatch)args.arg4).countDown();
+                    }
                     return;
+                }
             }
         }
     }
     
-    static class NoOpInputConnection implements InputConnection {
-
-        public boolean clearMetaKeyStates(int states) {
-            return false;
+    class ControlledInputConnectionWrapper extends IInputConnectionWrapper {
+        public ControlledInputConnectionWrapper(Looper mainLooper, InputConnection conn) {
+            super(mainLooper, conn);
         }
 
-        public boolean beginBatchEdit() {
-            return false;
-        }
-        
-        public boolean endBatchEdit() {
-            return false;
-        }
-        
-        public boolean commitCompletion(CompletionInfo text) {
-            return false;
-        }
-
-        public boolean commitText(CharSequence text, int newCursorPosition) {
-            return false;
-        }
-
-        public boolean deleteSurroundingText(int leftLength, int rightLength) {
-            return false;
-        }
-
-        public int getCursorCapsMode(int reqModes) {
-            return 0;
-        }
-
-        public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
-            return null;
-        }
-
-        public CharSequence getTextAfterCursor(int n) {
-            return null;
-        }
-
-        public CharSequence getTextBeforeCursor(int n) {
-            return null;
-        }
-
-        public boolean hideStatusIcon() {
-            return false;
-        }
-
-        public boolean performPrivateCommand(String action, Bundle data) {
-            return false;
-        }
-
-        public boolean sendKeyEvent(KeyEvent event) {
-            return false;
-        }
-
-        public boolean setComposingText(CharSequence text, int newCursorPosition) {
-            return false;
-        }
-
-        public boolean finishComposingText() {
-            return false;
-        }
-
-        public boolean showStatusIcon(String packageName, int resId) {
-            return false;
+        public boolean isActive() {
+            return mActive;
         }
     }
     
-    final NoOpInputConnection mNoOpInputConnection = new NoOpInputConnection();
-
     final IInputMethodClient.Stub mClient = new IInputMethodClient.Stub() {
-        public void setUsingInputMethod(boolean state) {
+        @Override protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
+            // No need to check for dump permission, since we only give this
+            // interface to the system.
             
+            CountDownLatch latch = new CountDownLatch(1);
+            HandlerCaller.SomeArgs sargs = new HandlerCaller.SomeArgs();
+            sargs.arg1 = fd;
+            sargs.arg2 = fout;
+            sargs.arg3 = args;
+            sargs.arg4 = latch;
+            mH.sendMessage(mH.obtainMessage(MSG_DUMP, sargs));
+            try {
+                if (!latch.await(5, TimeUnit.SECONDS)) {
+                    fout.println("Timeout waiting for dump");
+                }
+            } catch (InterruptedException e) {
+                fout.println("Interrupted waiting for dump");
+            }
+        }
+        
+        public void setUsingInputMethod(boolean state) {
         }
         
         public void onBindMethod(InputBindResult res) {
@@ -403,62 +374,17 @@
         
         public void setActive(boolean active) {
             mActive = active;
-            mInputConnectionWrapper.setBaseInputConnection(active
-                    ? mCurrentInputConnection : mNoOpInputConnection);
         }
     };    
     
-    final InputConnection mDummyInputConnection = new BaseInputConnection(this) {
-        public boolean beginBatchEdit() {
-            return false;
-        }
-        public boolean endBatchEdit() {
-            return false;
-        }
-        public boolean commitText(CharSequence text, int newCursorPosition) {
-            return false;
-        }
-        public boolean commitCompletion(CompletionInfo text) {
-            return false;
-        }
-        public boolean deleteSurroundingText(int leftLength, int rightLength) {
-            return false;
-        }
-        public ExtractedText getExtractedText(ExtractedTextRequest request,
-                int flags) {
-            return null;
-        }
-        public CharSequence getTextAfterCursor(int n) {
-            return null;
-        }
-        public CharSequence getTextBeforeCursor(int n) {
-            return null;
-        }
-        public int getCursorCapsMode(int reqModes) {
-            return 0;
-        }
-        public boolean clearMetaKeyStates(int states) {
-            return false;
-        }
-        public boolean performPrivateCommand(String action, Bundle data) {
-            return false;
-        }
-        public boolean setComposingText(CharSequence text, int newCursorPosition) {
-            return false;
-        }
-        public boolean finishComposingText() {
-            return false;
-        }
-    };
+    final InputConnection mDummyInputConnection = new BaseInputConnection(this, true);
     
     InputMethodManager(IInputMethodManager service, Looper looper) {
         mService = service;
         mMainLooper = looper;
         mH = new H(looper);
-        mInputConnectionWrapper = new MutableInputConnectionWrapper(mNoOpInputConnection);
-        mIInputContext = new IInputConnectionWrapper(looper,
-                mInputConnectionWrapper);
-        setCurrentInputConnection(mDummyInputConnection);
+        mIInputContext = new ControlledInputConnectionWrapper(looper,
+                mDummyInputConnection);
         
         if (mInstance == null) {
             mInstance = this;
@@ -563,22 +489,12 @@
     }
     
     /**
-     * Record the desired input connection, but only set it if mActive is true.
-     */
-    void setCurrentInputConnection(InputConnection connection) {
-        mCurrentInputConnection = connection;
-        mInputConnectionWrapper.setBaseInputConnection(mActive
-                ? connection : mNoOpInputConnection);
-    }
-    
-    /**
      * Reset all of the state associated with a served view being connected
      * to an input method
      */
     void clearConnectionLocked() {
         mCurrentTextBoxAttribute = null;
         mServedInputConnection = null;
-        setCurrentInputConnection(mDummyInputConnection);
     }
     
     /**
@@ -659,13 +575,20 @@
     }
     
     /**
-     * Flag for {@link #showSoftInput} to indicate that the this is an implicit
+     * Flag for {@link #showSoftInput} to indicate that this is an implicit
      * request to show the input window, not as the result of a direct request
      * by the user.  The window may not be shown in this case.
      */
     public static final int SHOW_IMPLICIT = 0x0001;
     
     /**
+     * Flag for {@link #showSoftInput} to indicate that the user has forced
+     * the input method open (such as by long-pressing menu) so it should
+     * not be closed until they explicitly do so.
+     */
+    public static final int SHOW_FORCED = 0x0002;
+    
+    /**
      * Explicitly request that the current input method's soft input area be
      * shown to the user, if needed.  Call this if the user interacts with
      * your view in such a way that they have expressed they would like to
@@ -689,6 +612,14 @@
         }
     }
     
+    /** @hide */
+    public void showSoftInputUnchecked(int flags) {
+        try {
+            mService.showSoftInput(mClient, flags);
+        } catch (RemoteException e) {
+        }
+    }
+    
     /**
      * Flag for {@link #hideSoftInputFromWindow} to indicate that the soft
      * input window should only be hidden if it was not explicitly shown
@@ -697,6 +628,13 @@
     public static final int HIDE_IMPLICIT_ONLY = 0x0001;
     
     /**
+     * Flag for {@link #hideSoftInputFromWindow} to indicate that the soft
+     * input window should normally be hidden, unless it was originally
+     * shown with {@link #SHOW_FORCED}.
+     */
+    public static final int HIDE_NOT_ALWAYS = 0x0002;
+    
+    /**
      * Request to hide the soft input window from the context of the window
      * that is currently accepting input.  This should be called as a result
      * of the user doing some actually than fairly explicitly requests to
@@ -779,6 +717,8 @@
         // do its stuff.
         // Life is good: let's hook everything up!
         EditorInfo tba = new EditorInfo();
+        tba.packageName = view.getContext().getPackageName();
+        tba.fieldId = view.getId();
         InputConnection ic = view.onCreateInputConnection(tba);
         if (DEBUG) Log.v(TAG, "Starting input: tba=" + tba + " ic=" + ic);
         
@@ -801,22 +741,23 @@
             mCurrentTextBoxAttribute = tba;
             mServedConnecting = false;
             mServedInputConnection = ic;
+            IInputContext servedContext;
             if (ic != null) {
                 mCursorSelStart = tba.initialSelStart;
                 mCursorSelEnd = tba.initialSelEnd;
                 mCursorCandStart = -1;
                 mCursorCandEnd = -1;
                 mCursorRect.setEmpty();
-                setCurrentInputConnection(ic);
+                servedContext = new ControlledInputConnectionWrapper(vh.getLooper(), ic);
             } else {
-                setCurrentInputConnection(mDummyInputConnection);
+                servedContext = null;
             }
             
             try {
                 if (DEBUG) Log.v(TAG, "START INPUT: " + view + " ic="
                         + ic + " tba=" + tba + " initial=" + initial);
-                InputBindResult res = mService.startInput(mClient, tba, initial,
-                        mCurMethod == null);
+                InputBindResult res = mService.startInput(mClient,
+                        servedContext, tba, initial, mCurMethod == null);
                 if (DEBUG) Log.v(TAG, "Starting input: Bind result=" + res);
                 if (res != null) {
                     if (res.id != null) {
@@ -885,10 +826,20 @@
                     + " winFocus=" + view.hasWindowFocus());
             if (mServedView == view) {
                 ic = mServedInputConnection;
-                if (view.hasWindowFocus()) {
+                // The following code would auto-hide the IME if we end up
+                // with no more views with focus.  This can happen, however,
+                // whenever we go into touch mode, so it ends up hiding
+                // at times when we don't really want it to.  For now it
+                // seems better to just turn it all off.
+                if (false && view.hasWindowFocus()) {
                     mLastServedView = view;
-                    mH.removeMessages(MSG_CHECK_FOCUS);
-                    mH.sendEmptyMessage(MSG_CHECK_FOCUS);
+                    Handler vh = view.getHandler();
+                    if (vh != null) {
+                        // This will result in a call to checkFocus() below.
+                        vh.removeMessages(ViewRoot.CHECK_FOCUS);
+                        vh.sendMessage(vh.obtainMessage(ViewRoot.CHECK_FOCUS,
+                                view));
+                    }
                 }
             }
         }
@@ -898,8 +849,14 @@
         }
     }
 
-    void checkFocus() {
+    /**
+     * @hide
+     */
+    public void checkFocus(View view) {
         synchronized (mH) {
+            if (view != mLastServedView) {
+                return;
+            }
             if (DEBUG) Log.v(TAG, "checkFocus: view=" + mServedView
                     + " last=" + mLastServedView);
             if (mServedView == mLastServedView) {
@@ -915,7 +872,7 @@
     
     void closeCurrentInput() {
         try {
-            mService.hideSoftInput(mClient, 0);
+            mService.hideSoftInput(mClient, HIDE_NOT_ALWAYS);
         } catch (RemoteException e) {
         }
     }
@@ -1006,6 +963,32 @@
     }
 
     /**
+     * Call {@link InputMethodSession#appPrivateCommand(String, Bundle)
+     * InputMethodSession.appPrivateCommand()} on the current Input Method.
+     * @param view Optional View that is sending the command, or null if
+     * you want to send the command regardless of the view that is attached
+     * to the input method.
+     * @param action Name of the command to be performed.  This <em>must</em>
+     * be a scoped name, i.e. prefixed with a package name you own, so that
+     * different developers will not create conflicting commands.
+     * @param data Any data to include with the command.
+     */
+    public void sendAppPrivateCommand(View view, String action, Bundle data) {
+        synchronized (mH) {
+            if ((view != null && mServedView != view)
+                    || mCurrentTextBoxAttribute == null || mCurMethod == null) {
+                return;
+            }
+            try {
+                if (DEBUG) Log.v(TAG, "APP PRIVATE COMMAND " + action + ": " + data);
+                mCurMethod.appPrivateCommand(action, data);
+            } catch (RemoteException e) {
+                Log.w(TAG, "IME died: " + mCurId, e);
+            }
+        }
+    }
+    
+    /**
      * Force switch to a new input method component.  This can only be called
      * from the currently active input method, as validated by the given token.
      * @param token Supplies the identifying token given to an input method
@@ -1048,7 +1031,7 @@
         synchronized (mH) {
             if (DEBUG) Log.d(TAG, "dispatchKeyEvent");
     
-            if (mCurMethod == null || mCurrentTextBoxAttribute == null) {
+            if (mCurMethod == null) {
                 try {
                     callback.finishedEvent(seq, false);
                 } catch (RemoteException e) {
@@ -1116,4 +1099,33 @@
             }
         }
     }
+    
+    void doDump(FileDescriptor fd, PrintWriter fout, String[] args) {
+        final Printer p = new PrintWriterPrinter(fout);
+        p.println("Input method client state for " + this + ":");
+        
+        p.println("  mService=" + mService);
+        p.println("  mMainLooper=" + mMainLooper);
+        p.println("  mIInputContext=" + mIInputContext);
+        p.println("  mActive=" + mActive
+                + " mBindSequence=" + mBindSequence
+                + " mCurId=" + mCurId);
+        p.println("  mCurMethod=" + mCurMethod);
+        p.println("  mServedView=" + mServedView);
+        p.println("  mLastServedView=" + mLastServedView);
+        p.println("  mServedConnecting=" + mServedConnecting);
+        if (mCurrentTextBoxAttribute != null) {
+            p.println("  mCurrentTextBoxAttribute:");
+            mCurrentTextBoxAttribute.dump(p, "    ");
+        } else {
+            p.println("  mCurrentTextBoxAttribute: null");
+        }
+        p.println("  mServedInputConnection=" + mServedInputConnection);
+        p.println("  mCompletions=" + mCompletions);
+        p.println("  mCursorRect=" + mCursorRect);
+        p.println("  mCursorSelStart=" + mCursorSelStart
+                + " mCursorSelEnd=" + mCursorSelEnd
+                + " mCursorCandStart=" + mCursorCandStart
+                + " mCursorCandEnd=" + mCursorCandEnd);
+    }
 }
diff --git a/core/java/android/view/inputmethod/MutableInputConnectionWrapper.java b/core/java/android/view/inputmethod/MutableInputConnectionWrapper.java
deleted file mode 100644
index 025a059..0000000
--- a/core/java/android/view/inputmethod/MutableInputConnectionWrapper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007-2008 The Android Open Source Project
- * 
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package android.view.inputmethod;
-
-
-/**
- * Special version of {@link InputConnectionWrapper} that allows the base
- * input connection to be modified after it is initially set.
- */
-public class MutableInputConnectionWrapper extends InputConnectionWrapper {
-    public MutableInputConnectionWrapper(InputConnection base) {
-        super(base);
-    }
-
-    /**
-     * Change the base InputConnection for this wrapper. All calls will then be
-     * delegated to the base input connection.
-     * 
-     * @param base The new base InputConnection for this wrapper.
-     */
-    public void setBaseInputConnection(InputConnection base) {
-        mBase = base;
-    }
-}
diff --git a/core/java/android/webkit/ByteArrayBuilder.java b/core/java/android/webkit/ByteArrayBuilder.java
index 16d663c..806b458 100644
--- a/core/java/android/webkit/ByteArrayBuilder.java
+++ b/core/java/android/webkit/ByteArrayBuilder.java
@@ -94,6 +94,14 @@
         return mChunks.isEmpty();
     }
 
+    public synchronized void clear() {
+        Chunk c = getFirstChunk();
+        while (c != null) {
+            releaseChunk(c);
+            c = getFirstChunk();
+        }
+    }
+
     private Chunk appendChunk(int length) {
         if (length < mMinCapacity) {
             length = mMinCapacity;
diff --git a/core/java/android/webkit/FileLoader.java b/core/java/android/webkit/FileLoader.java
index 10343b2..54a4c1d 100644
--- a/core/java/android/webkit/FileLoader.java
+++ b/core/java/android/webkit/FileLoader.java
@@ -76,8 +76,12 @@
     protected boolean setupStreamAndSendStatus() {
         try {
             if (mIsAsset) {
-                mDataStream = mContext.getAssets().open(mPath,
-                        AssetManager.ACCESS_STREAMING);
+                try {
+                    mDataStream = mContext.getAssets().open(mPath);
+                } catch (java.io.FileNotFoundException ex) {
+                    // try the rest files included in the package
+                    mDataStream = mContext.getAssets().openNonAsset(mPath);
+                }
             } else {
                 if (!mAllowFileAccess) {
                     mHandler.error(EventHandler.FILE_ERROR,
diff --git a/core/java/android/webkit/FrameLoader.java b/core/java/android/webkit/FrameLoader.java
index 7a3bbe6..5e323eb 100644
--- a/core/java/android/webkit/FrameLoader.java
+++ b/core/java/android/webkit/FrameLoader.java
@@ -220,6 +220,7 @@
         // Tell the Listener respond with the cache file
         CacheLoader cacheLoader =
                 new CacheLoader(mListener, result);
+        mListener.setCacheLoader(cacheLoader);
         cacheLoader.load();
     }
 
diff --git a/core/java/android/webkit/LoadListener.java b/core/java/android/webkit/LoadListener.java
index 3f2bbe5..3694969 100644
--- a/core/java/android/webkit/LoadListener.java
+++ b/core/java/android/webkit/LoadListener.java
@@ -33,6 +33,8 @@
 import android.util.Log;
 import android.webkit.CacheManager.CacheResult;
 
+import com.android.internal.R;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -56,6 +58,9 @@
     private static final int MSG_CONTENT_ERROR = 130;
     private static final int MSG_LOCATION_CHANGED = 140;
     private static final int MSG_LOCATION_CHANGED_REQUEST = 150;
+    private static final int MSG_STATUS = 160;
+    private static final int MSG_SSL_CERTIFICATE = 170;
+    private static final int MSG_SSL_ERROR = 180;
 
     // Standard HTTP status codes in a more representative format
     private static final int HTTP_OK = 200;
@@ -166,9 +171,7 @@
                  * available. The headers are sent onto WebCore to see what we
                  * should do with them.
                  */
-                if (mNativeLoader != 0) {
-                    commitHeadersCheckRedirect();
-                }
+                handleHeaders((Headers) msg.obj);
                 break;
 
             case MSG_CONTENT_DATA:
@@ -177,7 +180,7 @@
                  * in it's data buffer. This data buffer could be filled from a
                  * file (this thread) or from http (Network thread).
                  */
-                if (mNativeLoader != 0) {
+                if (mNativeLoader != 0 && !ignoreCallbacks()) {
                     commitLoad();
                 }
                 break;
@@ -189,7 +192,7 @@
                  * error.
                  *
                  */
-                tearDown();
+                handleEndData();
                 break;
 
             case MSG_CONTENT_ERROR:
@@ -197,8 +200,7 @@
                  * This message is sent when a load error has occured. The
                  * LoadListener will clean itself up.
                  */
-                notifyError();
-                tearDown();
+                handleError(msg.arg1, (String) msg.obj);
                 break;
 
             case MSG_LOCATION_CHANGED:
@@ -224,6 +226,33 @@
                         stopMsg, contMsg);
                 break;
 
+            case MSG_STATUS:
+                /*
+                 * This message is sent from the network thread when the http
+                 * stack has received the status response from the server.
+                 */
+                HashMap status = (HashMap) msg.obj;
+                handleStatus(((Integer) status.get("major")).intValue(),
+                        ((Integer) status.get("minor")).intValue(),
+                        ((Integer) status.get("code")).intValue(),
+                        (String) status.get("reason"));
+                break;
+
+            case MSG_SSL_CERTIFICATE:
+                /*
+                 * This message is sent when the network thread receives a ssl
+                 * certificate.
+                 */
+                handleCertificate((SslCertificate) msg.obj);
+                break;
+
+            case MSG_SSL_ERROR:
+                /*
+                 * This message is sent when the network thread encounters a
+                 * ssl error.
+                 */
+                handleSslError((SslError) msg.obj);
+                break;
         }
     }
 
@@ -257,6 +286,11 @@
      */
     public void headers(Headers headers) {
         if (Config.LOGV) Log.v(LOGTAG, "LoadListener.headers");
+        sendMessageInternal(obtainMessage(MSG_CONTENT_HEADERS, headers));
+    }
+
+    // Does the header parsing work on the WebCore thread.
+    private void handleHeaders(Headers headers) {
         if (mCancelled) return;
         mHeaders = headers;
         mMimeType = "";
@@ -375,7 +409,7 @@
                 mCacheResult.encoding = mEncoding;
             }
         }
-        sendMessageInternal(obtainMessage(MSG_CONTENT_HEADERS));
+        commitHeadersCheckRedirect();
     }
 
     /**
@@ -404,11 +438,20 @@
                     + " code: " + code
                     + " reason: " + reasonPhrase);
         }
+        HashMap status = new HashMap();
+        status.put("major", majorVersion);
+        status.put("minor", minorVersion);
+        status.put("code", code);
+        status.put("reason", reasonPhrase);
+        sendMessageInternal(obtainMessage(MSG_STATUS, status));
+    }
 
+    // Handle the status callback on the WebCore thread.
+    private void handleStatus(int major, int minor, int code, String reason) {
         if (mCancelled) return;
 
         mStatusCode = code;
-        mStatusText = reasonPhrase;
+        mStatusText = reason;
         mPermanent = false;
     }
 
@@ -418,8 +461,15 @@
      * connection. In this context, can be called multiple
      * times if we have redirects
      * @param certificate The SSL certifcate
+     * IMPORTANT: as this is called from network thread, can't call native
+     * directly
      */
     public void certificate(SslCertificate certificate) {
+        sendMessageInternal(obtainMessage(MSG_SSL_CERTIFICATE, certificate));
+    }
+
+    // Handle the certificate on the WebCore thread.
+    private void handleCertificate(SslCertificate certificate) {
         // if this is the top-most main-frame page loader
         if (mIsMainPageLoader) {
             // update the browser frame (ie, the main frame)
@@ -436,14 +486,20 @@
      * directly
      */
     public void error(int id, String description) {
-        mErrorID = id;
-        mErrorDescription = description;
-        sendMessageInternal(obtainMessage(MSG_CONTENT_ERROR));
         if (Config.LOGV) {
             Log.v(LOGTAG, "LoadListener.error url:" +
                     url() + " id:" + id + " description:" + description);
         }
+        sendMessageInternal(obtainMessage(MSG_CONTENT_ERROR, id, 0, description));
+    }
+
+    // Handle the error on the WebCore thread.
+    private void handleError(int id, String description) {
+        mErrorID = id;
+        mErrorDescription = description;
         detachRequestHandle();
+        notifyError();
+        tearDown();
     }
 
     /**
@@ -453,11 +509,15 @@
      * @param length The length of data.
      * IMPORTANT: as this is called from network thread, can't call native
      * directly
+     * XXX: Unlike the other network thread methods, this method can do the
+     * work of decoding the data and appending it to the data builder because
+     * mDataBuilder is a thread-safe structure.
      */
     public void data(byte[] data, int length) {
         if (Config.LOGV) {
             Log.v(LOGTAG, "LoadListener.data(): url: " + url());
         }
+
         // Decode base64 data
         // Note: It's fine that we only decode base64 here and not in the other
         // data call because the only caller of the stream version is not
@@ -479,7 +539,7 @@
             sendMessage = mDataBuilder.isEmpty();
             mDataBuilder.append(data, 0, length);
         }
-        if (sendMessage && !ignoreCallbacks()) {
+        if (sendMessage) {
             // Send a message whenever data comes in after a write to WebCore
             sendMessageInternal(obtainMessage(MSG_CONTENT_DATA));
         }
@@ -495,7 +555,11 @@
         if (Config.LOGV) {
             Log.v(LOGTAG, "LoadListener.endData(): url: " + url());
         }
+        sendMessageInternal(obtainMessage(MSG_CONTENT_FINISHED));
+    }
 
+    // Handle the end of data.
+    private void handleEndData() {
         if (mCancelled) return;
 
         switch (mStatusCode) {
@@ -505,17 +569,13 @@
             case HTTP_FOUND:
             case HTTP_SEE_OTHER:
             case HTTP_TEMPORARY_REDIRECT:
-                if (mMethod == null && mRequestHandle == null) {
-                    Log.e(LOGTAG, "LoadListener.endData(): method is null!");
-                    Log.e(LOGTAG, "LoadListener.endData(): url = " + url());
-                }
                 // 301, 302, 303, and 307 - redirect
                 if (mStatusCode == HTTP_TEMPORARY_REDIRECT) {
                     if (mRequestHandle != null && 
                                 mRequestHandle.getMethod().equals("POST")) {
                         sendMessageInternal(obtainMessage(
                                 MSG_LOCATION_CHANGED_REQUEST));  
-                    } else if (mMethod != null && mMethod.equals("POST"))  {
+                    } else if (mMethod.equals("POST"))  {
                         sendMessageInternal(obtainMessage(
                                 MSG_LOCATION_CHANGED_REQUEST));
                     } else {
@@ -558,9 +618,14 @@
             default:
                 break;
         }
-
-        sendMessageInternal(obtainMessage(MSG_CONTENT_FINISHED));
         detachRequestHandle();
+        tearDown();
+    }
+
+    /* This method is called from CacheLoader when the initial request is
+     * serviced by the Cache. */
+    /* package */ void setCacheLoader(CacheLoader c) {
+        mCacheLoader = c;
     }
 
     /**
@@ -574,9 +639,16 @@
         CacheResult result = CacheManager.getCacheFile(url(),
                 headers);
 
+        // Go ahead and set the cache loader to null in case the result is
+        // null.
+        mCacheLoader = null;
+
         if (result != null) {
-            CacheLoader cacheLoader =
-                    new CacheLoader(this, result);
+            // The contents of the cache may need to be revalidated so just
+            // remember the cache loader in the case that the server responds
+            // positively to the cached content. This is also used to detect if
+            // a redirect came from the cache.
+            mCacheLoader = new CacheLoader(this, result);
 
             // If I got a cachedUrl and the revalidation header was not
             // added, then the cached content valid, we should use it.
@@ -589,14 +661,8 @@
                             "and usable: " + url());
                 }
                 // Load the cached file
-                cacheLoader.load();
+                mCacheLoader.load();
                 return true;
-            } else {
-                // The contents of the cache need to be revalidated
-                // so just provide the listener with the cache loader
-                // in the case that the server response positively to
-                // the cached content.
-                setCacheLoader(cacheLoader);
             }
         }
         return false;
@@ -615,7 +681,11 @@
                     " primary error: " + error.getPrimaryError() +
                     " certificate: " + error.getCertificate());
         }
+        sendMessageInternal(obtainMessage(MSG_SSL_ERROR, error));
+    }
 
+    // Handle the ssl error on the WebCore thread.
+    private void handleSslError(SslError error) {
         if (!mCancelled) {
             mSslError = error;
             Network.getInstance(mContext).handleSslErrorRequest(this);
@@ -705,14 +775,6 @@
     }
 
     /**
-     * Set the CacheLoader for the case where we might want to load from cache
-     * @param result
-     */
-    void setCacheLoader(CacheLoader result) {
-        mCacheLoader = result;
-    }
-    
-    /**
      * This is called when a request can be satisfied by the cache, however,
      * the cache result could be a redirect. In this case we need to issue
      * the network request.
@@ -1002,6 +1064,11 @@
         clearNativeLoader();
     }
 
+    // This count is transferred from RequestHandle to LoadListener when
+    // loading from the cache so that we can detect redirect loops that switch
+    // between the network and the cache.
+    private int mCacheRedirectCount;
+
     /*
      * Perform the actual redirection. This involves setting up the new URL,
      * informing WebCore and then telling the Network to start loading again.
@@ -1014,6 +1081,14 @@
             return;
         }
 
+        // Do the same check for a redirect loop that
+        // RequestHandle.setupRedirect does.
+        if (mCacheRedirectCount >= RequestHandle.MAX_REDIRECT_COUNT) {
+            handleError(EventHandler.ERROR_REDIRECT_LOOP, mContext.getString(
+                    R.string.httpErrorRedirectLoop));
+            return;
+        }
+
         String redirectTo = mHeaders.getLocation();
         if (redirectTo != null) {
             int nativeResponse = createNativeResponse();
@@ -1031,7 +1106,7 @@
                 return;
             } else if (!URLUtil.isNetworkUrl(redirectTo)) {
                 final String text = mContext
-                        .getString(com.android.internal.R.string.open_permission_deny)
+                        .getString(R.string.open_permission_deny)
                         + "\n" + redirectTo;
                 nativeAddData(text.getBytes(), text.length());
                 nativeFinished();
@@ -1057,6 +1132,13 @@
             if (mRequestHeaders == null) {
                 mRequestHeaders = new HashMap<String, String>();
             }
+            boolean fromCache = false;
+            if (mCacheLoader != null) {
+                // This is a redirect from the cache loader. Increment the
+                // redirect count to avoid redirect loops.
+                mCacheRedirectCount++;
+                fromCache = true;
+            }
             if (!checkCache(mRequestHeaders)) {
                 // mRequestHandle can be null when the request was satisfied
                 // by the cache, and the cache returned a redirect
@@ -1064,23 +1146,37 @@
                     mRequestHandle.setupRedirect(redirectTo, mStatusCode,
                             mRequestHeaders);
                 } else {
-                    String method = mMethod;
-
-                    if (method == null) {
+                    // If the original request came from the cache, there is no
+                    // RequestHandle, we have to create a new one through
+                    // Network.requestURL.
+                    Network network = Network.getInstance(getContext());
+                    if (!network.requestURL(mMethod, mRequestHeaders,
+                            mPostData, this, mIsHighPriority)) {
+                        // Signal a bad url error if we could not load the
+                        // redirection.
+                        handleError(EventHandler.ERROR_BAD_URL,
+                                mContext.getString(R.string.httpErrorBadUrl));
                         return;
                     }
-
-                    Network network = Network.getInstance(getContext());
-                    network.requestURL(method, mRequestHeaders,
-                            mPostData, this, mIsHighPriority);
                 }
+                if (fromCache) {
+                    // If we are coming from a cache load, we need to transfer
+                    // the redirect count to the new (or old) RequestHandle to
+                    // keep the redirect count in sync.
+                    mRequestHandle.setRedirectCount(mCacheRedirectCount);
+                }
+            } else if (!fromCache) {
+                // Switching from network to cache means we need to grab the
+                // redirect count from the RequestHandle to keep the count in
+                // sync. Add 1 to account for the current redirect.
+                mCacheRedirectCount = mRequestHandle.getRedirectCount() + 1;
             }
+            // Clear the buffered data since the redirect is valid.
+            mDataBuilder.clear();
         } else {
-            // With a null redirect, commit the original headers, the buffered
-            // data, and then finish the load.
             commitHeaders();
             commitLoad();
-            nativeFinished();
+            tearDown();
         }
 
         if (Config.LOGV) {
@@ -1167,14 +1263,16 @@
                         quoted = !quoted;
                     } else {
                         if (!quoted) {
-                            if (header.startsWith(
-                                    HttpAuthHeader.BASIC_TOKEN, i)) {
+                            if (header.regionMatches(true, i,
+                                    HttpAuthHeader.BASIC_TOKEN, 0,
+                                    HttpAuthHeader.BASIC_TOKEN.length())) {
                                 pos[posLen++] = i;
                                 continue;
                             }
 
-                            if (header.startsWith(
-                                    HttpAuthHeader.DIGEST_TOKEN, i)) {
+                            if (header.regionMatches(true, i,
+                                    HttpAuthHeader.DIGEST_TOKEN, 0,
+                                    HttpAuthHeader.DIGEST_TOKEN.length())) {
                                 pos[posLen++] = i;
                                 continue;
                             }
@@ -1186,8 +1284,9 @@
             if (posLen > 0) {
                 // consider all digest schemes first (if any)
                 for (int i = 0; i < posLen; i++) {
-                    if (header.startsWith(HttpAuthHeader.DIGEST_TOKEN,
-                                pos[i])) {
+                    if (header.regionMatches(true, pos[i],
+                                HttpAuthHeader.DIGEST_TOKEN, 0,
+                                HttpAuthHeader.DIGEST_TOKEN.length())) {
                         String sub = header.substring(pos[i],
                                 (i + 1 < posLen ? pos[i + 1] : headerLen));
 
@@ -1201,7 +1300,9 @@
 
                 // ...then consider all basic schemes (if any)
                 for (int i = 0; i < posLen; i++) {
-                    if (header.startsWith(HttpAuthHeader.BASIC_TOKEN, pos[i])) {
+                    if (header.regionMatches(true, pos[i],
+                                HttpAuthHeader.BASIC_TOKEN, 0,
+                                HttpAuthHeader.BASIC_TOKEN.length())) {
                         String sub = header.substring(pos[i],
                                 (i + 1 < posLen ? pos[i + 1] : headerLen));
 
@@ -1262,9 +1363,8 @@
         // type (implying text/plain).
         if (URLUtil.isDataUrl(mUrl) && mMimeType.length() != 0) {
             cancel();
-            final String text = mContext.getString(
-                    com.android.internal.R.string.httpErrorBadUrl);
-            error(EventHandler.ERROR_BAD_URL, text);
+            final String text = mContext.getString(R.string.httpErrorBadUrl);
+            handleError(EventHandler.ERROR_BAD_URL, text);
         } else {
             // Note: This is ok because this is used only for the main content
             // of frames. If no content-type was specified, it is fine to
diff --git a/core/java/android/webkit/MimeTypeMap.java b/core/java/android/webkit/MimeTypeMap.java
index 685e352..c9cc208 100644
--- a/core/java/android/webkit/MimeTypeMap.java
+++ b/core/java/android/webkit/MimeTypeMap.java
@@ -480,6 +480,7 @@
             sMimeTypeMap.loadEntry("video/mpeg", "mpg", false);
             sMimeTypeMap.loadEntry("video/mpeg", "mpe", false);
             sMimeTypeMap.loadEntry("video/mp4", "mp4", false);
+            sMimeTypeMap.loadEntry("video/mpeg", "VOB", false);
             sMimeTypeMap.loadEntry("video/quicktime", "qt", false);
             sMimeTypeMap.loadEntry("video/quicktime", "mov", false);
             sMimeTypeMap.loadEntry("video/vnd.mpegurl", "mxu", false);
diff --git a/core/java/android/webkit/TextDialog.java b/core/java/android/webkit/TextDialog.java
index b7b40b1..9af30c5 100644
--- a/core/java/android/webkit/TextDialog.java
+++ b/core/java/android/webkit/TextDialog.java
@@ -33,7 +33,6 @@
 import android.text.Spannable;
 import android.text.TextPaint;
 import android.text.TextUtils;
-import android.text.method.MetaKeyKeyListener;
 import android.text.method.MovementMethod;
 import android.text.method.PasswordTransformationMethod;
 import android.text.method.TextKeyListener;
@@ -44,7 +43,6 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.View.MeasureSpec;
 import android.view.ViewConfiguration;
 import android.widget.AbsoluteLayout.LayoutParams;
 import android.widget.ArrayAdapter;
@@ -69,10 +67,8 @@
     // on the enter key.  The method for blocking unmatched key ups prevents
     // the shift key from working properly.
     private boolean         mGotEnterDown;
-    // Determines whether we allow calls to requestRectangleOnScreen to
-    // propagate.  We only want to scroll if the user is typing.  If the
-    // user is simply navigating through a textfield, we do not want to
-    // scroll.
+    // mScrollToAccommodateCursor being set to false prevents us from scrolling
+    // the cursor on screen when using the trackball to select a textfield.
     private boolean         mScrollToAccommodateCursor;
     private int             mMaxLength;
     // Keep track of the text before the change so we know whether we actually
@@ -183,6 +179,11 @@
                     mWebView.shortPressOnTextField();
                     return true;
                 }
+                // If we reached here, then this is a single line textfield, and
+                // the user pressed ENTER.  In this case, we want to hide the
+                // soft input method.
+                InputMethodManager.getInstance(mContext)
+                        .hideSoftInputFromWindow(getWindowToken(), 0);
                 sendDomEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
                 sendDomEvent(event);
             }
@@ -405,6 +406,12 @@
             //mWebView.setSelection(start, end);
             return true;
         }
+        // If the user is in a textfield, and the movement method is not
+        // handling the trackball events, it means they are at the end of the
+        // field and continuing to move the trackball.  In this case, we should
+        // not scroll the cursor on screen bc the user may be attempting to
+        // scroll the page, possibly in the opposite direction of the cursor.
+        mScrollToAccommodateCursor = false;
         return false;
     }
 
@@ -419,6 +426,17 @@
         mHandler.removeMessages(LONGPRESS);
         mWebView.removeView(this);
         mWebView.requestFocus();
+        mScrollToAccommodateCursor = false;
+    }
+
+    /* package */ void enableScrollOnScreen(boolean enable) {
+        mScrollToAccommodateCursor = enable;
+    }
+
+    /* package */ void bringIntoView() {
+        if (getLayout() != null) {
+            bringPointIntoView(Selection.getSelectionEnd(getText()));
+        }
     }
 
     @Override
@@ -437,8 +455,16 @@
         mWebView.passToJavaScript(getText().toString(), event);
     }
 
+    /**
+     *  Always use this instead of setAdapter, as this has features specific to
+     *  the TextDialog.
+     */
     public void setAdapterCustom(AutoCompleteAdapter adapter) {
-        adapter.setTextView(this);
+        if (adapter != null) {
+            adapter.setTextView(this);
+        } else {
+            setInputType(EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE);
+        }
         super.setAdapter(adapter);
     }
 
@@ -483,12 +509,12 @@
         PasswordTransformationMethod method;
         if (inPassword) {
             method = PasswordTransformationMethod.getInstance();
+            setInputType(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.
+                    TYPE_TEXT_VARIATION_PASSWORD);
         } else {
             method = null;
         }
         setTransformationMethod(method);
-        setInputType(inPassword ? EditorInfo.TYPE_TEXT_VARIATION_PASSWORD :
-                EditorInfo.TYPE_CLASS_TEXT);
     }
 
     /* package */ void setMaxLength(int maxLength) {
@@ -539,7 +565,6 @@
         // Set up a measure spec so a layout can always be recreated.
         mWidthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
         mHeightSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
-        mScrollToAccommodateCursor = false;
         requestFocus();
     }
 
@@ -547,18 +572,23 @@
      * Set whether this is a single-line textfield or a multi-line textarea.
      * Textfields scroll horizontally, and do not handle the enter key.
      * Textareas behave oppositely.
+     * Do NOT call this after calling setInPassword(true).  This will result in
+     * removing the password input type.
      */
     public void setSingleLine(boolean single) {
         if (mSingle != single) {
             TextKeyListener.Capitalize cap;
+            int inputType = EditorInfo.TYPE_CLASS_TEXT;
             if (single) {
                 cap = TextKeyListener.Capitalize.NONE;
             } else {
                 cap = TextKeyListener.Capitalize.SENTENCES;
+                inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
             }
             setKeyListener(TextKeyListener.getInstance(!single, cap));
             mSingle = single;
             setHorizontallyScrolling(single);
+            setInputType(inputType);
         }
     }
 
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 1a7c4ff..5c470cf 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -316,10 +316,15 @@
             buffer.append("en");
         }
         
-        final String device = Build.DEVICE;
-        if (device.length() > 0) {
+        final String model = Build.MODEL;
+        if (model.length() > 0) {
             buffer.append("; ");
-            buffer.append(device);
+            buffer.append(model);
+        }
+        final String id = Build.ID;
+        if (id.length() > 0) {
+            buffer.append(" Build/");
+            buffer.append(id);
         }
         final String base = mContext.getResources().getText(
                 com.android.internal.R.string.web_user_agent).toString();
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index cab278be..3306700 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -68,6 +68,8 @@
 import android.widget.Scroller;
 import android.widget.Toast;
 import android.widget.ZoomControls;
+import android.widget.ZoomRingController;
+import android.widget.FrameLayout;
 import android.widget.AdapterView.OnItemClickListener;
 
 import java.io.File;
@@ -107,17 +109,14 @@
     static final boolean DEBUG = false;
     static final boolean LOGV_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
 
-    private class ExtendedZoomControls extends RelativeLayout {
+    private class ExtendedZoomControls extends FrameLayout {
         public ExtendedZoomControls(Context context, AttributeSet attrs) {
             super(context, attrs);
-            LayoutInflater inflater = (LayoutInflater) context
-                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-            inflater.inflate(com.android.internal.R.layout.zoom_magnify, this 
-                    , true);
-            mZoomControls = (ZoomControls) findViewById
-                    (com.android.internal.R.id.zoomControls);
-            mZoomMagnify = (ImageView) findViewById
-                    (com.android.internal.R.id.zoomMagnify);
+            LayoutInflater inflater = (LayoutInflater)
+                    context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            inflater.inflate(com.android.internal.R.layout.zoom_magnify, this, true);
+            mZoomControls = (ZoomControls) findViewById(com.android.internal.R.id.zoomControls);
+            mZoomMagnify = (ImageView) findViewById(com.android.internal.R.id.zoomMagnify);
         }
         
         public void show(boolean showZoom, boolean canZoomOut) {
@@ -258,6 +257,27 @@
     // Whether to forward the touch events to WebCore
     private boolean mForwardTouchEvents = false;
 
+    // Whether we are in the drag tap mode, which exists starting at the second
+    // tap's down, through its move, and includes its up. These events should be
+    // given to the method on the zoom controller.
+    private boolean mInZoomTapDragMode;
+    
+    // The event time of the previous touch up. 
+    private long mPreviousUpTime;
+    
+    private Runnable mRemoveReleaseSingleTap = new Runnable() {
+        public void run() {
+            mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP);
+            mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
+            mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
+        }
+    };
+    
+    // Whether to prevent drag during touch. The initial value depends on
+    // mForwardTouchEvents. If WebCore wants touch events, we assume it will
+    // take control of touch events unless it says no for touch down event.
+    private boolean mPreventDrag;
+
     // If updateTextEntry gets called while we are out of focus, use this 
     // variable to remember to do it next time we gain focus.
     private boolean mNeedsUpdateTextEntry = false;
@@ -269,8 +289,7 @@
      * Customizable constant
      */
     // pre-computed square of ViewConfiguration.getTouchSlop()
-    private static final int TOUCH_SLOP_SQUARE =
-            ViewConfiguration.getTouchSlop() * ViewConfiguration.getTouchSlop();
+    private int mTouchSlopSquare;
     // This should be ViewConfiguration.getTapTimeout()
     // But system time out is 100ms, which is too short for the browser.
     // In the browser, if it switches out of tap too soon, jump tap won't work.
@@ -360,6 +379,8 @@
     static final int LONG_PRESS_ENTER               = 23;
     static final int PREVENT_TOUCH_ID               = 24;
     static final int WEBCORE_NEED_TOUCH_EVENTS      = 25;
+    // obj=Rect in doc coordinates
+    static final int INVAL_RECT_MSG_ID              = 26;
 
     // width which view is considered to be fully zoomed out
     static final int ZOOM_OUT_WIDTH = 1024;
@@ -373,6 +394,9 @@
     // initial scale in percent. 0 means using default.
     private int mInitialScale = 0;
 
+    // set to true temporarily while the zoom control is being dragged
+    private boolean mPreviewZoomOnly = false;
+
     // computed scale and inverse, from mZoomWidth.
     private float mActualScale = 1;
     private float mInvActualScale = 1;
@@ -490,7 +514,73 @@
             return mExtra;
         }
     }
+    
+    private ZoomRingController mZoomRingController;
 
+    private ZoomRingController.OnZoomListener mZoomListener =
+            new ZoomRingController.OnZoomListener() {
+        
+        public void onCenter(int x, int y) {
+            // Don't translate when the control is invoked, hence we do nothing
+            // in this callback
+        }
+
+        public boolean onPan(int deltaX, int deltaY) {
+            return pinScrollBy(deltaX, deltaY, false, 0);
+        }
+
+        public void onVisibilityChanged(boolean visible) {
+            if (visible) {
+                mZoomControls.show(false, canZoomScrollOut());
+            } else {
+                mZoomControls.hide();
+            }
+        }
+                
+        public void onBeginDrag(float startAngle) {
+            mPreviewZoomOnly = true;
+        }
+        
+        public void onEndDrag(float endAngle) {
+            mPreviewZoomOnly = false;
+            setNewZoomScale(mActualScale, true);
+        }
+
+        public boolean onDragZoom(int deltaZoomLevel, int centerX,
+                int centerY, float startAngle, float curAngle) {
+
+            if (mZoomScale == mMinZoomScale && deltaZoomLevel < 0 ||
+                    mZoomScale == mMaxZoomScale && deltaZoomLevel > 0 ||
+                    deltaZoomLevel == 0) {
+                return false;
+            }
+            
+            int deltaX = centerX - getViewWidth() / 2;
+            int deltaY = centerY - getViewHeight() / 2;
+
+            pinScrollBy(deltaX, deltaY, false, 0);
+            
+            while (deltaZoomLevel != 0) {
+                if (deltaZoomLevel > 0) {
+                    if (!zoomIn()) return false;
+                    deltaZoomLevel--;
+                } else {
+                    if (!zoomOut()) return false;
+                    deltaZoomLevel++;
+                }
+            }
+            
+            pinScrollBy(-deltaX, -deltaY, false, 0);
+                    
+            return true;
+        }
+        
+        public void onSimpleZoom(boolean zoomIn) {
+            if (zoomIn) zoomIn();
+            else zoomOut();
+        }
+    };
+    
     /**
      * Construct a new WebView with a Context object.
      * @param context A Context object used to access application assets.
@@ -518,11 +608,6 @@
         super(context, attrs, defStyle);
         init();
 
-        TypedArray a = context.obtainStyledAttributes(
-                com.android.internal.R.styleable.View);
-        initializeScrollbars(a);
-        a.recycle();
-
         mCallbackProxy = new CallbackProxy(context, this);
         mWebViewCore = new WebViewCore(context, this, mCallbackProxy);
         mDatabase = WebViewDatabase.getInstance(context);
@@ -532,6 +617,8 @@
         mFocusData.mX = 0;
         mFocusData.mY = 0;
         mScroller = new Scroller(context);
+        mZoomRingController = new ZoomRingController(context, this);
+        mZoomRingController.setCallback(mZoomListener);
     }
 
     private void init() {
@@ -541,9 +628,9 @@
         setClickable(true);
         setLongClickable(true);
 
-        // should be conditional on if we're in the browser activity? 
-        setHorizontalScrollBarEnabled(true);
-        setVerticalScrollBarEnabled(true);
+        final int slop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
+        mTouchSlopSquare = slop * slop;
+        mMinLockSnapReverseDistance = slop;
     }
 
     /* package */ boolean onSavePassword(String schemePlusHost, String username,
@@ -648,7 +735,7 @@
      * to.
      */
     private int getViewWidth() {
-        if (mOverlayVerticalScrollbar) {
+        if (!isVerticalScrollBarEnabled() || mOverlayVerticalScrollbar) {
             return getWidth();
         } else {
             return getWidth() - getVerticalScrollbarWidth();
@@ -660,7 +747,7 @@
      * to.
      */
     private int getViewHeight() {
-        if (mOverlayHorizontalScrollbar) {
+        if (!isHorizontalScrollBarEnabled() || mOverlayHorizontalScrollbar) {
             return getHeight();
         } else {
             return getHeight() - getHorizontalScrollbarHeight();
@@ -732,7 +819,6 @@
      */
     public void destroy() {
         clearTextEntry();
-        getViewTreeObserver().removeOnGlobalFocusChangeListener(this);
         if (mWebViewCore != null) {
             // Set the handlers to null before destroying WebViewCore so no
             // more messages will be posted. 
@@ -1165,7 +1251,7 @@
         nativeClearFocus(-1, -1);
         if (top) {
             // go to the top of the document
-            return pinScrollTo(mScrollX, 0, true);
+            return pinScrollTo(mScrollX, 0, true, 0);
         }
         // Page up
         int h = getHeight();
@@ -1176,7 +1262,7 @@
             y = -h / 2;
         }
         mUserScroll = true;
-        return mScroller.isFinished() ? pinScrollBy(0, y, true) 
+        return mScroller.isFinished() ? pinScrollBy(0, y, true, 0) 
                 : extendScroll(y);
     }
     
@@ -1191,7 +1277,7 @@
         }
         nativeClearFocus(-1, -1);
         if (bottom) {
-            return pinScrollTo(mScrollX, mContentHeight, true);
+            return pinScrollTo(mScrollX, mContentHeight, true, 0);
         }
         // Page down.
         int h = getHeight();
@@ -1202,7 +1288,7 @@
             y = h / 2;
         }
         mUserScroll = true;
-        return mScroller.isFinished() ? pinScrollBy(0, y, true) 
+        return mScroller.isFinished() ? pinScrollBy(0, y, true, 0) 
                 : extendScroll(y);
     }
 
@@ -1485,12 +1571,14 @@
             if (mDrawHistory) {
                 // If history Picture is drawn, don't update scroll. They will
                 // be updated when we get out of that mode.
-                if (scale != mActualScale) {
+                if (scale != mActualScale && !mPreviewZoomOnly) {
                     mCallbackProxy.onScaleChanged(mActualScale, scale);
                 }
                 mActualScale = scale;
                 mInvActualScale = 1 / scale;
-                sendViewSizeZoom();
+                if (!mPreviewZoomOnly) {
+                    sendViewSizeZoom();
+                }
             } else {
                 // update our scroll so we don't appear to jump
                 // i.e. keep the center of the doc in the center of the view
@@ -1502,7 +1590,7 @@
                 float sy = ratio * oldY + (ratio - 1) * getViewHeight() * 0.5f;
 
                 // now update our new scale and inverse
-                if (scale != mActualScale) {
+                if (scale != mActualScale && !mPreviewZoomOnly) {
                     mCallbackProxy.onScaleChanged(mActualScale, scale);
                 }
                 mActualScale = scale;
@@ -1514,8 +1602,10 @@
                 mScrollX = pinLocX(Math.round(sx));
                 mScrollY = pinLocY(Math.round(sy));
 
-                sendViewSizeZoom();
-                sendOurVisibleRect();
+                if (!mPreviewZoomOnly) {
+                    sendViewSizeZoom();
+                    sendOurVisibleRect();
+                }
             }
         }
     }
@@ -1716,8 +1806,8 @@
      */
     public void clearFormData() {
         if (inEditingMode()) {
-            ArrayAdapter<String> adapter = null;
-            mTextEntry.setAdapter(adapter);
+            AutoCompleteAdapter adapter = null;
+            mTextEntry.setAdapterCustom(adapter);
         }
     }
 
@@ -1812,7 +1902,7 @@
         nativeSetFindIsDown();
         // Now that the dialog has been removed, ensure that we scroll to a
         // location that is not beyond the end of the page.
-        pinScrollTo(mScrollX, mScrollY, false);
+        pinScrollTo(mScrollX, mScrollY, false, 0);
         invalidate();
     }
 
@@ -1855,13 +1945,13 @@
 
     // helper to pin the scrollBy parameters (already in view coordinates)
     // returns true if the scroll was changed
-    private boolean pinScrollBy(int dx, int dy, boolean animate) {
-        return pinScrollTo(mScrollX + dx, mScrollY + dy, animate);
+    private boolean pinScrollBy(int dx, int dy, boolean animate, int animationDuration) {
+        return pinScrollTo(mScrollX + dx, mScrollY + dy, animate, animationDuration);
     }
 
     // helper to pin the scrollTo parameters (already in view coordinates)
     // returns true if the scroll was changed
-    private boolean pinScrollTo(int x, int y, boolean animate) {
+    private boolean pinScrollTo(int x, int y, boolean animate, int animationDuration) {
         x = pinLocX(x);
         y = pinLocY(y);
         int dx = x - mScrollX;
@@ -1875,7 +1965,7 @@
             //        Log.d(LOGTAG, "startScroll: " + dx + " " + dy);
 
             mScroller.startScroll(mScrollX, mScrollY, dx, dy,
-                                  computeDuration(dx, dy));
+                    animationDuration > 0 ? animationDuration : computeDuration(dx, dy));
             invalidate();
         } else {
             mScroller.abortAnimation(); // just in case
@@ -1910,10 +2000,10 @@
             // vertical scroll?
 //                Log.d(LOGTAG, "setContentScrollBy cy=" + cy);
             if (cy == 0 && cx != 0) {
-                pinScrollBy(cx, 0, true);
+                pinScrollBy(cx, 0, true, 0);
             }
         } else {
-            pinScrollBy(cx, cy, true);
+            pinScrollBy(cx, cy, true, 0);
         }
     }
 
@@ -1933,7 +2023,7 @@
         int vy = contentToView(cy);
 //        Log.d(LOGTAG, "content scrollTo [" + cx + " " + cy + "] view=[" +
 //                      vx + " " + vy + "]");
-        pinScrollTo(vx, vy, false);
+        pinScrollTo(vx, vy, false, 0);
         if (mScrollX != vx || mScrollY != vy) {
             return true;
         } else {
@@ -1950,7 +2040,7 @@
         }
         int vx = contentToView(cx);
         int vy = contentToView(cy);
-        pinScrollTo(vx, vy, true);
+        pinScrollTo(vx, vy, true, 0);
     }
 
     /**
@@ -2692,12 +2782,9 @@
         InputMethodManager imm = (InputMethodManager)
                 getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
         imm.showSoftInput(mTextEntry, 0);
+        mTextEntry.enableScrollOnScreen(true);
     }
 
-    // Used to register the global focus change listener one time to avoid
-    // multiple references to WebView
-    private boolean mGlobalFocusChangeListenerAdded;
-    
     private void updateTextEntry() {
         if (mTextEntry == null) {
             mTextEntry = new TextDialog(mContext, WebView.this);
@@ -2730,9 +2817,6 @@
         // Note that sendOurVisibleRect calls viewToContent, so the coordinates
         // should be in content coordinates.
         if (!Rect.intersects(node.mBounds, visibleRect)) {
-            if (alreadyThere) {
-                mTextEntry.remove();
-            }
             // Node is not on screen, so do not bother.
             return;
         }
@@ -2785,21 +2869,32 @@
                 }
             }
             mTextEntry.setMaxLength(maxLength);
-            ArrayAdapter<String> adapter = null;
-            mTextEntry.setAdapter(adapter);
-            mTextEntry.setInPassword(node.mIsPassword);
+            AutoCompleteAdapter adapter = null;
+            mTextEntry.setAdapterCustom(adapter);
             mTextEntry.setSingleLine(node.mIsTextField);
+            mTextEntry.setInPassword(node.mIsPassword);
             if (null == text) {
                 mTextEntry.setText("", 0, 0);
             } else {
-                mTextEntry.setText(text, 0, text.length());
+                // Change to true to enable the old style behavior, where
+                // entering a textfield/textarea always set the selection to the
+                // whole field.  This was desirable for the case where the user
+                // intends to scroll past the field using the trackball.
+                // However, it causes a problem when replying to emails - the
+                // user expects the cursor to be at the beginning of the
+                // textarea.  Testing out a new behavior, where textfields set
+                // selection at the end, and textareas at the beginning.
+                if (false) {
+                    mTextEntry.setText(text, 0, text.length());
+                } else if (node.mIsTextField) {
+                    int length = text.length();
+                    mTextEntry.setText(text, length, length);
+                } else {
+                    mTextEntry.setText(text, 0, 0);
+                }
             }
             mTextEntry.requestFocus();
         }
-        if (!mGlobalFocusChangeListenerAdded) {
-            getViewTreeObserver().addOnGlobalFocusChangeListener(this);
-            mGlobalFocusChangeListenerAdded = true;
-        }
     }
 
     private class UpdateTextEntryAdapter implements Runnable {
@@ -3114,24 +3209,17 @@
     // Implementation for OnHierarchyChangeListener
     public void onChildViewAdded(View parent, View child) {}
     
-    // When we are removed, remove this as a global focus change listener.
     public void onChildViewRemoved(View p, View child) {
         if (child == this) {
-            p.getViewTreeObserver().removeOnGlobalFocusChangeListener(this);
-            mGlobalFocusChangeListenerAdded = false;
+            if (inEditingMode()) {
+                clearTextEntry();
+                mNeedsUpdateTextEntry = true;
+            }
         }
     }
-    
-    // Use this to know when the textview has lost focus, and something other
-    // than the webview has gained focus.  Stop drawing the focus ring, remove
-    // the TextView, and set a flag to put it back when we regain focus.
+
+    @Deprecated
     public void onGlobalFocusChanged(View oldFocus, View newFocus) {
-        if (oldFocus == mTextEntry && newFocus != this) {
-            mDrawFocusRing = false;
-            mTextEntry.updateCachedTextfield();
-            removeView(mTextEntry);
-            mNeedsUpdateTextEntry = true;
-        }
     }
 
     // To avoid drawing the focus ring, and remove the TextView when our window
@@ -3153,16 +3241,10 @@
                 mDrawFocusRing = false;
             }
         } else {
-            // If our window has lost focus, stop drawing the focus ring, and
-            // remove the TextView if displayed, and flag it to be added when
-            // we regain focus.
+            // If our window has lost focus, stop drawing the focus ring
             mDrawFocusRing = false;
             mGotKeyDown = false;
             mShiftIsPressed = false;
-            if (inEditingMode()) {
-                clearTextEntry();
-                mNeedsUpdateTextEntry = true;
-            }
         }
         invalidate();
         super.onWindowFocusChanged(hasWindowFocus);
@@ -3245,9 +3327,8 @@
     // 3. If there is a same direction back and forth, lock it.
 
     // adjustable parameters
+    private int mMinLockSnapReverseDistance;
     private static final float MAX_SLOPE_FOR_DIAG = 1.5f;
-    private static final int MIN_LOCK_SNAP_REVERSE_DISTANCE = 
-            ViewConfiguration.getTouchSlop();
     private static final int MIN_BREAK_SNAP_CROSS_DISTANCE = 80;
 
     @Override
@@ -3261,6 +3342,27 @@
                     + mTouchMode);
         }
 
+        if (mZoomRingController.isVisible()) {
+            if (mInZoomTapDragMode) {
+                mZoomRingController.handleDoubleTapEvent(ev);
+                if (ev.getAction() == MotionEvent.ACTION_UP) {
+                    // Just released the second tap, no longer in tap-drag mode
+                    mInZoomTapDragMode = false;
+                }
+                return true;
+            } else {
+                // TODO: properly do this.
+                /*
+                 * When the zoom widget is showing, the user can tap outside of
+                 * it to dismiss it. Furthermore, he can drag outside of it to
+                 * pan the browser. However, we do not want a tap on a link to
+                 * open the link.
+                 */
+                post(mRemoveReleaseSingleTap);
+                // Continue through to normal processing
+            }
+        }
+
         int action = ev.getAction();
         float x = ev.getX();
         float y = ev.getY();
@@ -3315,8 +3417,20 @@
                     nativeMoveSelection(viewToContent(mSelectX)
                             , viewToContent(mSelectY), false);
                     mTouchSelection = mExtendSelection = true;
+                } else if (!ZoomRingController.useOldZoom(mContext) &&
+                        eventTime - mPreviousUpTime < DOUBLE_TAP_TIMEOUT &&
+                        getSettings().supportZoom() &&
+                        mMinZoomScale < mMaxZoomScale) {
+                    // Found doubletap, invoke the zoom controller
+                    mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
+                    mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
+                    mPrivateHandler.removeMessages(RELEASE_SINGLE_TAP);
+                    mZoomRingController.setVisible(true);
+                    mInZoomTapDragMode = true;
+                    mZoomRingController.handleDoubleTapEvent(ev);
                 } else {
                     mTouchMode = TOUCH_INIT_MODE;
+                    mPreventDrag = mForwardTouchEvents;
                 }
                 if (mTouchMode == TOUCH_INIT_MODE) {
                     mPrivateHandler.sendMessageDelayed(mPrivateHandler
@@ -3359,8 +3473,8 @@
                         invalidate();
                         break;
                     }
-                    if ((deltaX * deltaX + deltaY * deltaY)
-                            < TOUCH_SLOP_SQUARE) {
+                    if (mPreventDrag || (deltaX * deltaX + deltaY * deltaY)
+                            < mTouchSlopSquare) {
                         break;
                     }
 
@@ -3371,6 +3485,9 @@
                         mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
                     }
 
+                    // Prevent double-tap from being invoked
+                    mPreviousUpTime = 0;
+                    
                     // if it starts nearly horizontal or vertical, enforce it
                     int ax = Math.abs(deltaX);
                     int ay = Math.abs(deltaY);
@@ -3418,9 +3535,9 @@
                             // reverse direction means lock in the snap mode
                             if ((ax > MAX_SLOPE_FOR_DIAG * ay) &&
                                     ((mSnapPositive && 
-                                    deltaX < -MIN_LOCK_SNAP_REVERSE_DISTANCE)
+                                    deltaX < -mMinLockSnapReverseDistance)
                                     || (!mSnapPositive &&
-                                    deltaX > MIN_LOCK_SNAP_REVERSE_DISTANCE))) {
+                                    deltaX > mMinLockSnapReverseDistance))) {
                                 mSnapScrollMode = SNAP_X_LOCK;
                             }
                         } else {
@@ -3432,9 +3549,9 @@
                             // reverse direction means lock in the snap mode
                             if ((ay > MAX_SLOPE_FOR_DIAG * ax) &&
                                     ((mSnapPositive && 
-                                    deltaY < -MIN_LOCK_SNAP_REVERSE_DISTANCE)
+                                    deltaY < -mMinLockSnapReverseDistance)
                                     || (!mSnapPositive && 
-                                    deltaY > MIN_LOCK_SNAP_REVERSE_DISTANCE))) {
+                                    deltaY > mMinLockSnapReverseDistance))) {
                                 mSnapScrollMode = SNAP_Y_LOCK;
                             }
                         }
@@ -3457,16 +3574,18 @@
                     mUserScroll = true;
                 }
 
-                boolean showPlusMinus = mMinZoomScale < mMaxZoomScale;
-                boolean showMagnify = canZoomScrollOut();
-                if (mZoomControls != null && (showPlusMinus || showMagnify)) {
-                    if (mZoomControls.getVisibility() == View.VISIBLE) {
-                        mPrivateHandler.removeCallbacks(mZoomControlRunnable);
-                    } else {
-                        mZoomControls.show(showPlusMinus, showMagnify);
+                if (ZoomRingController.useOldZoom(mContext)) {
+                    boolean showPlusMinus = mMinZoomScale < mMaxZoomScale;
+                    boolean showMagnify = canZoomScrollOut();
+                    if (mZoomControls != null && (showPlusMinus || showMagnify)) {
+                        if (mZoomControls.getVisibility() == View.VISIBLE) {
+                            mPrivateHandler.removeCallbacks(mZoomControlRunnable);
+                        } else {
+                            mZoomControls.show(showPlusMinus, showMagnify);
+                        }
+                        mPrivateHandler.postDelayed(mZoomControlRunnable,
+                                ZOOM_CONTROLS_TIMEOUT);
                     }
-                    mPrivateHandler.postDelayed(mZoomControlRunnable,
-                            ZOOM_CONTROLS_TIMEOUT);
                 }
                 if (done) {
                     // return false to indicate that we can't pan out of the
@@ -3479,7 +3598,8 @@
                 switch (mTouchMode) {
                     case TOUCH_INIT_MODE: // tap
                         mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
-                        if (getSettings().supportZoom()) {
+                        if (getSettings().supportZoom()
+                                && (mMinZoomScale < mMaxZoomScale)) {
                             mPrivateHandler.sendMessageDelayed(mPrivateHandler
                                     .obtainMessage(RELEASE_SINGLE_TAP),
                                     DOUBLE_TAP_TIMEOUT);
@@ -3559,6 +3679,7 @@
                     mVelocityTracker.recycle();
                     mVelocityTracker = null;
                 }
+                mPreviousUpTime = eventTime;
                 break;
             }
             case MotionEvent.ACTION_CANCEL: {
@@ -3604,6 +3725,7 @@
     private static final int TRACKBALL_WAIT = 100;
     private static final int TRACKBALL_SCALE = 400;
     private static final int TRACKBALL_SCROLL_COUNT = 5;
+    private static final int TRACKBALL_MOVE_COUNT = 10;
     private static final int TRACKBALL_MULTIPLIER = 3;
     private static final int SELECT_CURSOR_OFFSET = 16;
     private int mSelectX = 0;
@@ -3658,7 +3780,11 @@
             mTrackballDown = false;
             mTrackballUpTime = time;
             if (mShiftIsPressed) {
-                mExtendSelection = true;
+                if (mExtendSelection) {
+                    commitCopy();
+                } else {
+                    mExtendSelection = true;
+                }
             }
             if (LOGV_ENABLED) {
                 Log.v(LOGTAG, "onTrackballEvent up ev=" + ev
@@ -3735,7 +3861,7 @@
         int scrollY = mSelectY < mScrollY ? -SELECT_CURSOR_OFFSET
                 : mSelectY > maxY - SELECT_CURSOR_OFFSET ? SELECT_CURSOR_OFFSET 
                 : 0;
-        pinScrollBy(scrollX, scrollY, true);
+        pinScrollBy(scrollX, scrollY, true, 0);
         Rect select = new Rect(mSelectX, mSelectY, mSelectX + 1, mSelectY + 1);
         requestRectangleOnScreen(select);
         invalidate();
@@ -3841,6 +3967,7 @@
                     KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN : 
                     mTrackballRemainsX < 0 ? KeyEvent.KEYCODE_DPAD_LEFT :
                     KeyEvent.KEYCODE_DPAD_RIGHT;
+            count = Math.min(count, TRACKBALL_MOVE_COUNT);
             if (LOGV_ENABLED) {
                 Log.v(LOGTAG, "doTrackball keyCode=" + selectKeyCode 
                         + " count=" + count
@@ -3870,7 +3997,7 @@
                 yMove = 0;
             }
             if (xMove != 0 || yMove != 0) {
-                pinScrollBy(xMove, yMove, true);
+                pinScrollBy(xMove, yMove, true, 0);
             }
             mUserScroll = true;
         } 
@@ -4056,7 +4183,7 @@
             View v = mTextEntry;
             int x = viewToContent((v.getLeft() + v.getRight()) >> 1);
             int y = viewToContent((v.getTop() + v.getBottom()) >> 1);
-            int contentSize = ViewConfiguration.getTouchSlop();
+            int contentSize = ViewConfiguration.get(getContext()).getScaledTouchSlop();
             nativeMotionUp(x, y, contentSize, true);
         }
     }
@@ -4066,21 +4193,15 @@
             return;
         }
         switchOutDrawHistory();
-        // call uiOverride to check whether it is a special node,
-        // phone/email/address, which are not handled by WebKit
+        // FIXME: we don't know if the current (x,y) is on a focus node or
+        // not -- so playing the sound effect here is premature
         if (nativeUpdateFocusNode()) {
-            FocusNode node = mFocusNode;
-            if (!node.mIsTextField && !node.mIsTextArea) {
-                if (mCallbackProxy.uiOverrideUrlLoading(node.mText)) {
-                    return;
-                }
-            }
             playSoundEffect(SoundEffectConstants.CLICK);
         }
         // mLastTouchX and mLastTouchY are the point in the current viewport
         int contentX = viewToContent((int) mLastTouchX + mScrollX);
         int contentY = viewToContent((int) mLastTouchY + mScrollY);
-        int contentSize = ViewConfiguration.getTouchSlop();
+        int contentSize = ViewConfiguration.get(getContext()).getScaledTouchSlop();
         nativeMotionUp(contentX, contentY, contentSize, true);
     }
 
@@ -4208,7 +4329,7 @@
         }
 
         if ((scrollYDelta | scrollXDelta) != 0) {
-            return pinScrollBy(scrollXDelta, scrollYDelta, !immediate);
+            return pinScrollBy(scrollXDelta, scrollYDelta, !immediate, 0);
         }
 
         return false;
@@ -4443,6 +4564,15 @@
                     }
                     break;
                 case UPDATE_TEXT_ENTRY_MSG_ID:
+                    // this is sent after finishing resize in WebViewCore. Make 
+                    // sure the text edit box is still on the  screen.
+                    boolean alreadyThere = inEditingMode();
+                    if (alreadyThere && nativeUpdateFocusNode()) {
+                        FocusNode node = mFocusNode;
+                        if (node.mIsTextField || node.mIsTextArea) {
+                            mTextEntry.bringIntoView();
+                        }
+                    }
                     updateTextEntry();
                     break;
                 case RECOMPUTE_FOCUS_MSG_ID:
@@ -4450,6 +4580,17 @@
                         nativeRecomputeFocus();
                     }
                     break;
+                case INVAL_RECT_MSG_ID: {
+                    Rect r = (Rect)msg.obj;
+                    if (r == null) {
+                        invalidate();
+                    } else {
+                        // we need to scale r from content into view coords,
+                        // which viewInvalidate() does for us
+                        viewInvalidate(r.left, r.top, r.right, r.bottom);
+                    }
+                    break;
+                }
                 case UPDATE_TEXT_ENTRY_ADAPTER:
                     HashMap data = (HashMap) msg.obj;
                     if (mTextEntry.isSameTextField(msg.arg1)) {
@@ -4494,12 +4635,12 @@
                     break;
 
                 case PREVENT_TOUCH_ID:
-                // update may have already been paused by touch; restore since
-                // this effectively aborts touch and skips logic in touch up
-                    if (mTouchMode == TOUCH_DRAG_MODE) {
-                        WebViewCore.resumeUpdate(mWebViewCore);
+                    if (msg.arg1 == MotionEvent.ACTION_DOWN) {
+                        mPreventDrag = msg.arg2 == 1;
+                        if (mPreventDrag) {
+                            mTouchMode = TOUCH_DONE_MODE;
+                        }
                     }
-                    mTouchMode = TOUCH_DONE_MODE;
                     break;
 
                 default:
@@ -4665,6 +4806,12 @@
                     listView.setSelection(mSelection);
                 }
             }
+            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
+                public void onCancel(DialogInterface dialog) {
+                    mWebViewCore.sendMessage(
+                                EventHub.SINGLE_LISTBOX_CHOICE, -2, 0);
+                }
+            });
             dialog.show();
         }
     }
@@ -4809,11 +4956,11 @@
         // FIXME: Necessary because ScrollView/ListView do not scroll left/right
         int maxH = Math.min(viewFocus.right - visRect.right, maxXScroll);
         if (maxH > 0) {
-            pinScrollBy(maxH, 0, true);
+            pinScrollBy(maxH, 0, true, 0);
         } else {
             maxH = Math.max(viewFocus.left - visRect.left, -maxXScroll);
             if (maxH < 0) {
-                pinScrollBy(maxH, 0, true);
+                pinScrollBy(maxH, 0, true, 0);
             }
         }
         if (mLastFocusBounds.isEmpty()) return keyHandled;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 323b44d..8f78887 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -799,12 +799,11 @@
 
                         case TOUCH_EVENT: {
                             TouchEventData ted = (TouchEventData) msg.obj;
-                            if (nativeHandleTouchEvent(ted.mAction, ted.mX,
-                                    ted.mY)) {
-                                Message.obtain(mWebView.mPrivateHandler,
-                                        WebView.PREVENT_TOUCH_ID)
-                                        .sendToTarget();
-                            }
+                            Message.obtain(
+                                    mWebView.mPrivateHandler,
+                                    WebView.PREVENT_TOUCH_ID, ted.mAction,
+                                    nativeHandleTouchEvent(ted.mAction, ted.mX,
+                                            ted.mY) ? 1 : 0).sendToTarget();
                             break;
                         }
 
@@ -1434,10 +1433,15 @@
         }
     }
 
-    // called by JNI
+    /*  Called by JNI. The coordinates are in doc coordinates, so they need to
+        be scaled before they can be used by the view system, which happens
+        in WebView since it (and its thread) know the current scale factor.
+     */
     private void sendViewInvalidate(int left, int top, int right, int bottom) {
         if (mWebView != null) {
-            mWebView.postInvalidate(left, top, right, bottom);
+            Message.obtain(mWebView.mPrivateHandler,
+                           WebView.INVAL_RECT_MSG_ID,
+                           new Rect(left, top, right, bottom)).sendToTarget();
         }
     }
 
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 19ec77d..378d218 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -369,7 +369,6 @@
 
     private int mLastTouchMode = TOUCH_MODE_UNKNOWN;
 
-    // TODO: REMOVE WHEN WE'RE DONE WITH PROFILING
     private static final boolean PROFILE_SCROLLING = false;
     private boolean mScrollProfilingStarted = false;
 
@@ -423,6 +422,8 @@
      */
     private FastScroller mFastScroller;
 
+    private int mTouchSlop;
+
     /**
      * Interface definition for a callback to be invoked when the list or grid
      * has been scrolled.
@@ -558,6 +559,15 @@
     public boolean isFastScrollEnabled() {
         return mFastScrollEnabled;
     }
+    
+    /**
+     * If fast scroll is visible, then don't draw the vertical scrollbar.
+     * @hide 
+     */
+    @Override
+    protected boolean isVerticalScrollBarHidden() {
+        return mFastScroller != null ? mFastScroller.isVisible() : false;
+    }
 
     /**
      * When smooth scrollbar is enabled, the position and size of the scrollbar thumb
@@ -696,6 +706,8 @@
         setWillNotDraw(false);
         setAlwaysDrawnWithCacheEnabled(false);
         setScrollingCacheEnabled(true);
+
+        mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
     }
 
     private void useDefaultSelector() {
@@ -1758,8 +1770,7 @@
         // Check if we have moved far enough that it looks more like a
         // scroll than a tap
         final int distance = Math.abs(deltaY);
-        int touchSlop = ViewConfiguration.getTouchSlop();
-        if (distance > touchSlop) {
+        if (distance > mTouchSlop) {
             createScrollingCache();
             mTouchMode = TOUCH_MODE_SCROLL;
             mMotionCorrection = deltaY;
@@ -1979,8 +1990,9 @@
                 velocityTracker.computeCurrentVelocity(1000);
                 int initialVelocity = (int)velocityTracker.getYVelocity();
 
-                if ((Math.abs(initialVelocity) > ViewConfiguration.getMinimumFlingVelocity()) &&
-                        (getChildCount() > 0)){
+                if ((Math.abs(initialVelocity) >
+                        ViewConfiguration.get(mContext).getScaledMinimumFlingVelocity()) &&
+                        (getChildCount() > 0)) {
                     if (mFlingRunnable == null) {
                         mFlingRunnable = new FlingRunnable();
                     }
@@ -2714,7 +2726,9 @@
             int screenHeight = WindowManagerImpl.getDefault().getDefaultDisplay().getHeight();
             final int[] xy = new int[2];
             getLocationOnScreen(xy);
-            int bottomGap = screenHeight - xy[1] - getHeight() + 20;
+            // TODO: The 20 below should come from the theme and be expressed in dip
+            final float scale = getContext().getResources().getDisplayMetrics().density;
+            int bottomGap = screenHeight - xy[1] - getHeight() + (int) (scale * 20);
             mPopup.showAtLocation(this, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL,
                     xy[0], bottomGap);
             // Make sure we get focus if we are showing the popup
diff --git a/core/java/android/widget/AnalogClock.java b/core/java/android/widget/AnalogClock.java
index fbb0105..cf9c588 100644
--- a/core/java/android/widget/AnalogClock.java
+++ b/core/java/android/widget/AnalogClock.java
@@ -28,6 +28,7 @@
 import android.text.format.Time;
 import android.util.AttributeSet;
 import android.view.View;
+import android.widget.RemoteViews.RemoteView;
 
 import java.util.TimeZone;
 
@@ -35,6 +36,7 @@
  * This widget display an analogic clock with two hands for hours and
  * minutes.
  */
+@RemoteView
 public class AnalogClock extends View {
     private Time mCalendar;
 
diff --git a/core/java/android/widget/AutoCompleteTextView.java b/core/java/android/widget/AutoCompleteTextView.java
index 7d52901..7a51676 100644
--- a/core/java/android/widget/AutoCompleteTextView.java
+++ b/core/java/android/widget/AutoCompleteTextView.java
@@ -110,8 +110,14 @@
 
     private Validator mValidator = null;
 
+    private boolean mBlockCompletion;
+
     private AutoCompleteTextView.ListSelectorHider mHideSelector;
 
+    // Indicates whether this AutoCompleteTextView is attached to a window or not
+    // The widget is attached to a window when mAttachCount > 0
+    private int mAttachCount;
+
     public AutoCompleteTextView(Context context) {
         this(context, null);
     }
@@ -145,19 +151,13 @@
         mHintResource = a.getResourceId(R.styleable.AutoCompleteTextView_completionHintView,
                 R.layout.simple_dropdown_hint);
 
-        // A little trickiness for backwards compatibility: if the app
-        // didn't specify an explicit content type, then we will fill in the
-        // auto complete flag for them.
-        int contentType = a.getInt(
-                R.styleable.AutoCompleteTextView_inputType,
-                EditorInfo.TYPE_NULL);
-        if (contentType == EditorInfo.TYPE_NULL) {
-            contentType = getInputType();
-            if ((contentType&EditorInfo.TYPE_MASK_CLASS)
-                    == EditorInfo.TYPE_CLASS_TEXT) {
-                contentType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
-                setRawInputType(contentType);
-            }
+        // Always turn on the auto complete input type flag, since it
+        // makes no sense to use this widget without it.
+        int inputType = getInputType();
+        if ((inputType&EditorInfo.TYPE_MASK_CLASS)
+                == EditorInfo.TYPE_CLASS_TEXT) {
+            inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
+            setRawInputType(inputType);
         }
 
         a.recycle();
@@ -300,6 +300,15 @@
     /**
      * <p>Changes the list of data used for auto completion. The provided list
      * must be a filterable list adapter.</p>
+     * 
+     * <p>The caller is still responsible for managing any resources used by the adapter.
+     * Notably, when the AutoCompleteTextView is closed or released, the adapter is not notified.
+     * A common case is the use of {@link android.widget.CursorAdapter}, which
+     * contains a {@link android.database.Cursor} that must be closed.  This can be done
+     * automatically (see 
+     * {@link android.app.Activity#startManagingCursor(android.database.Cursor) 
+     * startManagingCursor()}),
+     * or by manually closing the cursor when the AutoCompleteTextView is dismissed.</p>
      *
      * @param adapter the adapter holding the auto completion data
      *
@@ -368,7 +377,10 @@
                                     && keyCode != KeyEvent.KEYCODE_DPAD_CENTER))) {
                 int curIndex = mDropDownList.getSelectedItemPosition();
                 boolean consumed;
-                if (keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex <= 0) {
+                final boolean below = !mPopup.isAboveAnchor();
+                if ((below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex <= 0) ||
+                        (!below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN && curIndex >=
+                        mDropDownList.getAdapter().getCount() - 1)) {
                     // When the selection is at the top, we block the key
                     // event to prevent focus from moving.
                     mDropDownList.hideSelector();
@@ -409,13 +421,15 @@
                             return true;
                     }
                 } else {
-                    if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
+                    if (below && keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
                         // when the selection is at the bottom, we block the
                         // event to avoid going to the next focusable widget
                         Adapter adapter = mDropDownList.getAdapter();
                         if (adapter != null && curIndex == adapter.getCount() - 1) {
                             return true;
                         }
+                    } else if (!below && keyCode == KeyEvent.KEYCODE_DPAD_UP && curIndex == 0) {
+                        return true;
                     }
                 }
             }
@@ -462,6 +476,8 @@
     }
 
     void doBeforeTextChanged() {
+        if (mBlockCompletion) return;
+
         // when text is changed, inserted or deleted, we attempt to show
         // the drop down
         mOpenBefore = isPopupShowing();
@@ -469,6 +485,8 @@
     }
 
     void doAfterTextChanged() {
+        if (mBlockCompletion) return;
+
         // if the list was open before the keystroke, but closed afterwards,
         // then something in the keystroke processing (an input filter perhaps)
         // called performCompletion() and we shouldn't do any more processing.
@@ -579,9 +597,13 @@
         performCompletion(null, -1, -1);
     }
 
-    @Override public void onCommitCompletion(CompletionInfo completion) {
+    @Override
+    public void onCommitCompletion(CompletionInfo completion) {
         if (isPopupShowing()) {
+            mBlockCompletion = true;
             replaceText(completion.getText());
+            mBlockCompletion = false;
+
             if (mItemClickListener != null) {
                 final DropDownListView list = mDropDownList;
                 // Note that we don't have a View here, so we will need to
@@ -604,7 +626,10 @@
                 Log.w(TAG, "performCompletion: no selected item");
                 return;
             }
+
+            mBlockCompletion = true;
             replaceText(convertSelectionToString(selectedItem));
+            mBlockCompletion = false;            
 
             if (mItemClickListener != null) {
                 final DropDownListView list = mDropDownList;
@@ -620,6 +645,14 @@
 
         dismissDropDown();
     }
+    
+    /**
+     * Identifies whether the view is currently performing a text completion, so subclasses
+     * can decide whether to respond to text changed events.
+     */
+    public boolean isPerformingCompletion() {
+        return mBlockCompletion;
+    }
 
     /**
      * <p>Performs the text completion by replacing the current text by the
@@ -636,6 +669,8 @@
     }
 
     public void onFilterComplete(int count) {
+        if (mAttachCount <= 0) return;
+
         /*
          * This checks enoughToFilter() again because filtering requests
          * are asynchronous, so the result may come back after enough text
@@ -671,8 +706,15 @@
     }
 
     @Override
+    protected void onAttachedToWindow() {
+        super.onAttachedToWindow();
+        mAttachCount++;
+    }
+
+    @Override
     protected void onDetachedFromWindow() {
         dismissDropDown();
+        mAttachCount--;
         super.onDetachedFromWindow();
     }
 
@@ -694,7 +736,7 @@
         boolean result = super.setFrame(l, t, r, b);
 
         if (mPopup.isShowing()) {
-            mPopup.update(this, getMeasuredWidth() - mPaddingLeft - mPaddingRight, -1);
+            mPopup.update(this, r - l, -1);
         }
 
         return result;
@@ -707,10 +749,10 @@
         int height = buildDropDown();
         if (mPopup.isShowing()) {
             mPopup.update(this, mDropDownHorizontalOffset, mDropDownVerticalOffset,
-                    getMeasuredWidth() - mPaddingLeft - mPaddingRight, height);
+                    getWidth(), height);
         } else {
             mPopup.setWindowLayoutMode(0, ViewGroup.LayoutParams.WRAP_CONTENT);
-            mPopup.setWidth(getMeasuredWidth() - mPaddingLeft - mPaddingRight);
+            mPopup.setWidth(getWidth());
             mPopup.setHeight(height);
             mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
             mPopup.setOutsideTouchable(true);
@@ -739,7 +781,7 @@
                 int N = mAdapter.getCount();
                 if (N > 20) N = 20;
                 CompletionInfo[] completions = new CompletionInfo[N];
-                for (int i=0; i<N; i++) {
+                for (int i = 0; i < N; i++) {
                     Object item = mAdapter.getItem(i);
                     long id = mAdapter.getItemId(i);
                     completions[i] = new CompletionInfo(id, i,
@@ -783,7 +825,7 @@
 
                 // measure the hint's height to find how much more vertical space
                 // we need to add to the drop down's height
-                int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
+                int widthSpec = MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST);
                 int heightSpec = MeasureSpec.UNSPECIFIED;
                 hintView.measure(widthSpec, heightSpec);
 
@@ -807,8 +849,8 @@
         }
 
         // Max height available on the screen for a popup anchored to us
-        final int maxHeight = mPopup.getMaxAvailableHeight(this);
-        otherHeights += dropDownView.getPaddingTop() + dropDownView.getPaddingBottom();
+        final int maxHeight = mPopup.getMaxAvailableHeight(this, mDropDownVerticalOffset);
+        //otherHeights += dropDownView.getPaddingTop() + dropDownView.getPaddingBottom();
 
         return mDropDownList.measureHeightOfChildren(MeasureSpec.UNSPECIFIED,
                 0, ListView.NO_POSITION, maxHeight - otherHeights, 2) + otherHeights;
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index e56a741..d4482dc 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -251,7 +251,12 @@
             invalidate();
         }
     }
-    
+
+    @Override
+    protected boolean verifyDrawable(Drawable who) {
+        return super.verifyDrawable(who) || who == mButtonDrawable;
+    }
+
     static class SavedState extends BaseSavedState {
         boolean checked;
 
diff --git a/core/java/android/widget/ExpandableListView.java b/core/java/android/widget/ExpandableListView.java
index 3de561a..0fc8f49 100644
--- a/core/java/android/widget/ExpandableListView.java
+++ b/core/java/android/widget/ExpandableListView.java
@@ -187,6 +187,9 @@
     private Drawable mChildDivider;
     private boolean mClipChildDivider;
 
+    // Bounds of the indicator to be drawn
+    private final Rect mIndicatorRect = new Rect();
+
     public ExpandableListView(Context context) {
         this(context, null);
     }
@@ -247,17 +250,16 @@
 
         final int myB = mBottom; 
         
-        PositionMetadata pos = null;
+        PositionMetadata pos;
         View item;
         Drawable indicator; 
         int t, b;
         
         // Start at a value that is neither child nor group
         int lastItemType = ~(ExpandableListPosition.CHILD | ExpandableListPosition.GROUP);
-        
-        // Bounds of the indicator to be drawn
-        Rect indicatorRect = new Rect();
-        
+
+        final Rect indicatorRect = mIndicatorRect;
+
         // The "child" mentioned in the following two lines is this
         // View's child, not referring to an expandable list's
         // notion of a child (as opposed to a group)
@@ -303,11 +305,11 @@
                 // Use item's full height + the divider height
                 if (mStackFromBottom) {
                     // See ListView#dispatchDraw
-                    indicatorRect.top = t - mDividerHeight;
+                    indicatorRect.top = t;// - mDividerHeight;
                     indicatorRect.bottom = b;
                 } else {
                     indicatorRect.top = t;
-                    indicatorRect.bottom = b + mDividerHeight;
+                    indicatorRect.bottom = b;// + mDividerHeight;
                 }
                 
                 // Get the indicator (with its state set to the item's state)
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java
index bdcfeef..57e21e4 100644
--- a/core/java/android/widget/FastScroller.java
+++ b/core/java/android/widget/FastScroller.java
@@ -34,7 +34,8 @@
  */
 class FastScroller {
    
-    
+    // Minimum number of pages to justify showing a fast scroll thumb
+    private static int MIN_PAGES = 4;
     // Scroll thumb not showing
     private static final int STATE_NONE = 0;
     // Not implemented yet - fade-in transition
@@ -154,6 +155,10 @@
         setState(STATE_NONE);
     }
     
+    boolean isVisible() {
+        return !(mState == STATE_NONE);
+    }
+    
     public void draw(Canvas canvas) {
         
         if (mState == STATE_NONE) {
@@ -214,7 +219,13 @@
     
     void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, 
             int totalItemCount) {
-        
+        // Are there enough pages to require fast scroll?
+        if (visibleItemCount > 0 && totalItemCount / visibleItemCount < MIN_PAGES) {
+            if (mState != STATE_NONE) {
+                setState(STATE_NONE);
+            }
+            return;
+        }
         if (totalItemCount - visibleItemCount > 0 && mState != STATE_DRAGGING ) {
             mThumbY = ((mList.getHeight() - mThumbH) * firstVisibleItem) 
                     / (totalItemCount - visibleItemCount);
diff --git a/core/java/android/widget/Gallery.java b/core/java/android/widget/Gallery.java
index 7b9735c..ffabb02 100644
--- a/core/java/android/widget/Gallery.java
+++ b/core/java/android/widget/Gallery.java
@@ -180,7 +180,7 @@
     public Gallery(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         
-        mGestureDetector = new GestureDetector(this);
+        mGestureDetector = new GestureDetector(context, this);
         mGestureDetector.setIsLongpressEnabled(true);
         
         TypedArray a = context.obtainStyledAttributes(
diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java
new file mode 100644
index 0000000..96fe595
--- /dev/null
+++ b/core/java/android/widget/HorizontalScrollView.java
@@ -0,0 +1,1197 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.widget;
+
+import android.util.AttributeSet;
+import android.graphics.Rect;
+import android.view.View;
+import android.view.VelocityTracker;
+import android.view.ViewConfiguration;
+import android.view.ViewGroup;
+import android.view.KeyEvent;
+import android.view.FocusFinder;
+import android.view.MotionEvent;
+import android.view.ViewParent;
+import android.view.animation.AnimationUtils;
+import android.content.Context;
+import android.content.res.TypedArray;
+
+import java.util.List;
+
+/**
+ * Layout container for a view hierarchy that can be scrolled by the user,
+ * allowing it to be larger than the physical display.  A HorizontalScrollView
+ * is a {@link FrameLayout}, meaning you should place one child in it
+ * containing the entire contents to scroll; this child may itself be a layout
+ * manager with a complex hierarchy of objects.  A child that is often used
+ * is a {@link LinearLayout} in a horizontal orientation, presenting a horizontal
+ * array of top-level items that the user can scroll through.
+ *
+ * <p>You should never use a HorizontalScrollView with a {@link ListView}, since
+ * ListView takes care of its own scrolling.  Most importantly, doing this
+ * defeats all of the important optimizations in ListView for dealing with
+ * large lists, since it effectively forces the ListView to display its entire
+ * list of items to fill up the infinite container supplied by HorizontalScrollView.
+ *
+ * <p>The {@link TextView} class also
+ * takes care of its own scrolling, so does not require a ScrollView, but
+ * using the two together is possible to achieve the effect of a text view
+ * within a larger container.
+ *
+ * <p>HorizontalScrollView only supports horizontal scrolling.
+ */
+public class HorizontalScrollView extends FrameLayout {
+    private static final int ANIMATED_SCROLL_GAP = ScrollView.ANIMATED_SCROLL_GAP;
+
+    private static final float MAX_SCROLL_FACTOR = ScrollView.MAX_SCROLL_FACTOR;
+
+
+    private long mLastScroll;
+
+    private final Rect mTempRect = new Rect();
+    private Scroller mScroller;
+
+    /**
+     * Flag to indicate that we are moving focus ourselves. This is so the
+     * code that watches for focus changes initiated outside this ScrollView
+     * knows that it does not have to do anything.
+     */
+    private boolean mScrollViewMovedFocus;
+
+    /**
+     * Position of the last motion event.
+     */
+    private float mLastMotionX;
+
+    /**
+     * True when the layout has changed but the traversal has not come through yet.
+     * Ideally the view hierarchy would keep track of this for us.
+     */
+    private boolean mIsLayoutDirty = true;
+
+    /**
+     * The child to give focus to in the event that a child has requested focus while the
+     * layout is dirty. This prevents the scroll from being wrong if the child has not been
+     * laid out before requesting focus.
+     */
+    private View mChildToScrollTo = null;
+
+    /**
+     * True if the user is currently dragging this ScrollView around. This is
+     * not the same as 'is being flinged', which can be checked by
+     * mScroller.isFinished() (flinging begins when the user lifts his finger).
+     */
+    private boolean mIsBeingDragged = false;
+
+    /**
+     * Determines speed during touch scrolling
+     */
+    private VelocityTracker mVelocityTracker;
+
+    /**
+     * When set to true, the scroll view measure its child to make it fill the currently
+     * visible area.
+     */
+    private boolean mFillViewport;
+
+    /**
+     * Whether arrow scrolling is animated.
+     */
+    private boolean mSmoothScrollingEnabled = true;
+
+    private int mTouchSlop;
+
+    public HorizontalScrollView(Context context) {
+        this(context, null);
+    }
+
+    public HorizontalScrollView(Context context, AttributeSet attrs) {
+        this(context, attrs, com.android.internal.R.attr.horizontalScrollViewStyle);
+    }
+
+    public HorizontalScrollView(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        initScrollView();
+
+        TypedArray a = context.obtainStyledAttributes(attrs,
+                android.R.styleable.HorizontalScrollView, defStyle, 0);
+
+        setFillViewport(a.getBoolean(android.R.styleable.HorizontalScrollView_fillViewport, false));
+
+        a.recycle();
+    }
+
+    @Override
+    protected float getLeftFadingEdgeStrength() {
+        if (getChildCount() == 0) {
+            return 0.0f;
+        }
+
+        final int length = getHorizontalFadingEdgeLength();
+        if (mScrollX < length) {
+            return mScrollX / (float) length;
+        }
+
+        return 1.0f;
+    }
+
+    @Override
+    protected float getRightFadingEdgeStrength() {
+        if (getChildCount() == 0) {
+            return 0.0f;
+        }
+
+        final int length = getHorizontalFadingEdgeLength();
+        final int rightEdge = getWidth() - mPaddingRight;
+        final int span = getChildAt(0).getRight() - mScrollX - rightEdge;
+        if (span < length) {
+            return span / (float) length;
+        }
+
+        return 1.0f;
+    }
+
+    /**
+     * @return The maximum amount this scroll view will scroll in response to
+     *   an arrow event.
+     */
+    public int getMaxScrollAmount() {
+        return (int) (MAX_SCROLL_FACTOR * (mRight - mLeft));
+    }
+
+
+    private void initScrollView() {
+        mScroller = new Scroller(getContext());
+        setFocusable(true);
+        setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
+        setWillNotDraw(false);
+        mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
+    }
+
+    @Override
+    public void addView(View child) {
+        if (getChildCount() > 0) {
+            throw new IllegalStateException("HorizontalScrollView can host only one direct child");
+        }
+
+        super.addView(child);
+    }
+
+    @Override
+    public void addView(View child, int index) {
+        if (getChildCount() > 0) {
+            throw new IllegalStateException("HorizontalScrollView can host only one direct child");
+        }
+
+        super.addView(child, index);
+    }
+
+    @Override
+    public void addView(View child, ViewGroup.LayoutParams params) {
+        if (getChildCount() > 0) {
+            throw new IllegalStateException("HorizontalScrollView can host only one direct child");
+        }
+
+        super.addView(child, params);
+    }
+
+    @Override
+    public void addView(View child, int index, ViewGroup.LayoutParams params) {
+        if (getChildCount() > 0) {
+            throw new IllegalStateException("HorizontalScrollView can host only one direct child");
+        }
+
+        super.addView(child, index, params);
+    }
+
+    /**
+     * @return Returns true this HorizontalScrollView can be scrolled
+     */
+    private boolean canScroll() {
+        View child = getChildAt(0);
+        if (child != null) {
+            int childWidth = child.getWidth();
+            return getWidth() < childWidth + mPaddingLeft + mPaddingRight ;
+        }
+        return false;
+    }
+
+    /**
+     * Indicates whether this ScrollView's content is stretched to fill the viewport.
+     *
+     * @return True if the content fills the viewport, false otherwise.
+     */
+    public boolean isFillViewport() {
+        return mFillViewport;
+    }
+
+    /**
+     * Indicates this ScrollView whether it should stretch its content width to fill
+     * the viewport or not.
+     *
+     * @param fillViewport True to stretch the content's width to the viewport's
+     *        boundaries, false otherwise.
+     */
+    public void setFillViewport(boolean fillViewport) {
+        if (fillViewport != mFillViewport) {
+            mFillViewport = fillViewport;
+            requestLayout();
+        }
+    }
+
+    /**
+     * @return Whether arrow scrolling will animate its transition.
+     */
+    public boolean isSmoothScrollingEnabled() {
+        return mSmoothScrollingEnabled;
+    }
+
+    /**
+     * Set whether arrow scrolling will animate its transition.
+     * @param smoothScrollingEnabled whether arrow scrolling will animate its transition
+     */
+    public void setSmoothScrollingEnabled(boolean smoothScrollingEnabled) {
+        mSmoothScrollingEnabled = smoothScrollingEnabled;
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+        if (!mFillViewport) {
+            return;
+        }
+
+        final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+        if (widthMode == MeasureSpec.UNSPECIFIED) {
+            return;
+        }
+
+        final View child = getChildAt(0);
+        int width = getMeasuredWidth();
+        if (child.getMeasuredHeight() < width) {
+            final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+            int childHeightMeasureSpec = getChildMeasureSpec(heightMeasureSpec, mPaddingTop
+                    + mPaddingBottom, lp.height);
+            width -= mPaddingLeft;
+            width -= mPaddingRight;
+            int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
+
+            child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+        }
+    }
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        // Let the focused view and/or our descendants get the key first
+        boolean handled = super.dispatchKeyEvent(event);
+        if (handled) {
+            return true;
+        }
+        return executeKeyEvent(event);
+    }
+
+    /**
+     * You can call this function yourself to have the scroll view perform
+     * scrolling from a key event, just as if the event had been dispatched to
+     * it by the view hierarchy.
+     *
+     * @param event The key event to execute.
+     * @return Return true if the event was handled, else false.
+     */
+    public boolean executeKeyEvent(KeyEvent event) {
+        mTempRect.setEmpty();
+
+        if (!canScroll()) {
+            if (isFocused()) {
+                View currentFocused = findFocus();
+                if (currentFocused == this) currentFocused = null;
+                View nextFocused = FocusFinder.getInstance().findNextFocus(this,
+                        currentFocused, View.FOCUS_RIGHT);
+                return nextFocused != null && nextFocused != this &&
+                        nextFocused.requestFocus(View.FOCUS_RIGHT);
+            }
+            return false;
+        }
+
+        boolean handled = false;
+        if (event.getAction() == KeyEvent.ACTION_DOWN) {
+            switch (event.getKeyCode()) {
+                case KeyEvent.KEYCODE_DPAD_LEFT:
+                    if (!event.isAltPressed()) {
+                        handled = arrowScroll(View.FOCUS_LEFT);
+                    } else {
+                        handled = fullScroll(View.FOCUS_LEFT);
+                    }
+                    break;
+                case KeyEvent.KEYCODE_DPAD_RIGHT:
+                    if (!event.isAltPressed()) {
+                        handled = arrowScroll(View.FOCUS_RIGHT);
+                    } else {
+                        handled = fullScroll(View.FOCUS_RIGHT);
+                    }
+                    break;
+                case KeyEvent.KEYCODE_SPACE:
+                    pageScroll(event.isShiftPressed() ? View.FOCUS_LEFT : View.FOCUS_RIGHT);
+                    break;
+            }
+        }
+
+        return handled;
+    }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent ev) {
+        /*
+         * This method JUST determines whether we want to intercept the motion.
+         * If we return true, onMotionEvent will be called and we do the actual
+         * scrolling there.
+         */
+
+        /*
+        * Shortcut the most recurring case: the user is in the dragging
+        * state and he is moving his finger.  We want to intercept this
+        * motion.
+        */
+        final int action = ev.getAction();
+        if ((action == MotionEvent.ACTION_MOVE) && (mIsBeingDragged)) {
+            return true;
+        }
+
+        if (!canScroll()) {
+            mIsBeingDragged = false;
+            return false;
+        }
+
+        final float x = ev.getX();
+
+        switch (action) {
+            case MotionEvent.ACTION_MOVE:
+                /*
+                 * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
+                 * whether the user has moved far enough from his original down touch.
+                 */
+
+                /*
+                * Locally do absolute value. mLastMotionX is set to the x value
+                * of the down event.
+                */
+                final int xDiff = (int) Math.abs(x - mLastMotionX);
+                if (xDiff > mTouchSlop) {
+                    mIsBeingDragged = true;
+                    if (mParent != null) mParent.requestDisallowInterceptTouchEvent(true);
+                }
+                break;
+
+            case MotionEvent.ACTION_DOWN:
+                /* Remember location of down touch */
+                mLastMotionX = x;
+
+                /*
+                * If being flinged and user touches the screen, initiate drag;
+                * otherwise don't.  mScroller.isFinished should be false when
+                * being flinged.
+                */
+                mIsBeingDragged = !mScroller.isFinished();
+                break;
+
+            case MotionEvent.ACTION_CANCEL:
+            case MotionEvent.ACTION_UP:
+                /* Release the drag */
+                mIsBeingDragged = false;
+                break;
+        }
+
+        /*
+        * The only time we want to intercept motion events is if we are in the
+        * drag mode.
+        */
+        return mIsBeingDragged;
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent ev) {
+
+        if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) {
+            // Don't handle edge touches immediately -- they may actually belong to one of our
+            // descendants.
+            return false;
+        }
+
+        if (!canScroll()) {
+            return false;
+        }
+
+        if (mVelocityTracker == null) {
+            mVelocityTracker = VelocityTracker.obtain();
+        }
+        mVelocityTracker.addMovement(ev);
+
+        final int action = ev.getAction();
+        final float x = ev.getX();
+
+        switch (action) {
+            case MotionEvent.ACTION_DOWN:
+                /*
+                * If being flinged and user touches, stop the fling. isFinished
+                * will be false if being flinged.
+                */
+                if (!mScroller.isFinished()) {
+                    mScroller.abortAnimation();
+                }
+
+                // Remember where the motion event started
+                mLastMotionX = x;
+                break;
+            case MotionEvent.ACTION_MOVE:
+                // Scroll to follow the motion event
+                final int deltaX = (int) (mLastMotionX - x);
+                mLastMotionX = x;
+
+                if (deltaX < 0) {
+                    if (mScrollX > 0) {
+                        scrollBy(deltaX, 0);
+                    }
+                } else if (deltaX > 0) {
+                    final int rightEdge = getWidth() - mPaddingRight;
+                    final int availableToScroll = getChildAt(0).getRight() - mScrollX - rightEdge;
+                    if (availableToScroll > 0) {
+                        scrollBy(Math.min(availableToScroll, deltaX), 0);
+                    }
+                }
+                break;
+            case MotionEvent.ACTION_UP:
+                final VelocityTracker velocityTracker = mVelocityTracker;
+                velocityTracker.computeCurrentVelocity(1000);
+                int initialVelocity = (int) velocityTracker.getXVelocity();
+
+                if ((Math.abs(initialVelocity) >
+                        ViewConfiguration.get(mContext).getScaledMinimumFlingVelocity()) &&
+                        getChildCount() > 0) {
+                    fling(-initialVelocity);
+                }
+
+                if (mVelocityTracker != null) {
+                    mVelocityTracker.recycle();
+                    mVelocityTracker = null;
+                }
+        }
+        return true;
+    }
+
+    /**
+     * <p>
+     * Finds the next focusable component that fits in this View's bounds
+     * (excluding fading edges) pretending that this View's left is located at
+     * the parameter left.
+     * </p>
+     *
+     * @param leftFocus          look for a candidate is the one at the left of the bounds
+     *                           if leftFocus is true, or at the right of the bounds if leftFocus
+     *                           is false
+     * @param left               the left offset of the bounds in which a focusable must be
+     *                           found (the fading edge is assumed to start at this position)
+     * @param preferredFocusable the View that has highest priority and will be
+     *                           returned if it is within my bounds (null is valid)
+     * @return the next focusable component in the bounds or null if none can be found
+     */
+    private View findFocusableViewInMyBounds(final boolean leftFocus,
+            final int left, View preferredFocusable) {
+        /*
+         * The fading edge's transparent side should be considered for focus
+         * since it's mostly visible, so we divide the actual fading edge length
+         * by 2.
+         */
+        final int fadingEdgeLength = getHorizontalFadingEdgeLength() / 2;
+        final int leftWithoutFadingEdge = left + fadingEdgeLength;
+        final int rightWithoutFadingEdge = left + getWidth() - fadingEdgeLength;
+
+        if ((preferredFocusable != null)
+                && (preferredFocusable.getLeft() < rightWithoutFadingEdge)
+                && (preferredFocusable.getRight() > leftWithoutFadingEdge)) {
+            return preferredFocusable;
+        }
+
+        return findFocusableViewInBounds(leftFocus, leftWithoutFadingEdge,
+                rightWithoutFadingEdge);
+    }
+
+    /**
+     * <p>
+     * Finds the next focusable component that fits in the specified bounds.
+     * </p>
+     *
+     * @param leftFocus look for a candidate is the one at the left of the bounds
+     *                  if leftFocus is true, or at the right of the bounds if
+     *                  leftFocus is false
+     * @param left      the left offset of the bounds in which a focusable must be
+     *                  found
+     * @param right     the right offset of the bounds in which a focusable must
+     *                  be found
+     * @return the next focusable component in the bounds or null if none can
+     *         be found
+     */
+    private View findFocusableViewInBounds(boolean leftFocus, int left, int right) {
+
+        List<View> focusables = getFocusables(View.FOCUS_FORWARD);
+        View focusCandidate = null;
+
+        /*
+         * A fully contained focusable is one where its left is below the bound's
+         * left, and its right is above the bound's right. A partially
+         * contained focusable is one where some part of it is within the
+         * bounds, but it also has some part that is not within bounds.  A fully contained
+         * focusable is preferred to a partially contained focusable.
+         */
+        boolean foundFullyContainedFocusable = false;
+
+        int count = focusables.size();
+        for (int i = 0; i < count; i++) {
+            View view = focusables.get(i);
+            int viewLeft = view.getLeft();
+            int viewRight = view.getRight();
+
+            if (left < viewRight && viewLeft < right) {
+                /*
+                 * the focusable is in the target area, it is a candidate for
+                 * focusing
+                 */
+
+                final boolean viewIsFullyContained = (left < viewLeft) &&
+                        (viewRight < right);
+
+                if (focusCandidate == null) {
+                    /* No candidate, take this one */
+                    focusCandidate = view;
+                    foundFullyContainedFocusable = viewIsFullyContained;
+                } else {
+                    final boolean viewIsCloserToBoundary =
+                            (leftFocus && viewLeft < focusCandidate.getLeft()) ||
+                                    (!leftFocus && viewRight > focusCandidate.getRight());
+
+                    if (foundFullyContainedFocusable) {
+                        if (viewIsFullyContained && viewIsCloserToBoundary) {
+                            /*
+                             * We're dealing with only fully contained views, so
+                             * it has to be closer to the boundary to beat our
+                             * candidate
+                             */
+                            focusCandidate = view;
+                        }
+                    } else {
+                        if (viewIsFullyContained) {
+                            /* Any fully contained view beats a partially contained view */
+                            focusCandidate = view;
+                            foundFullyContainedFocusable = true;
+                        } else if (viewIsCloserToBoundary) {
+                            /*
+                             * Partially contained view beats another partially
+                             * contained view if it's closer
+                             */
+                            focusCandidate = view;
+                        }
+                    }
+                }
+            }
+        }
+
+        return focusCandidate;
+    }
+
+    /**
+     * <p>Handles scrolling in response to a "page up/down" shortcut press. This
+     * method will scroll the view by one page left or right and give the focus
+     * to the leftmost/rightmost component in the new visible area. If no
+     * component is a good candidate for focus, this scrollview reclaims the
+     * focus.</p>
+     *
+     * @param direction the scroll direction: {@link android.view.View#FOCUS_LEFT}
+     *                  to go one page left or {@link android.view.View#FOCUS_RIGHT}
+     *                  to go one page right
+     * @return true if the key event is consumed by this method, false otherwise
+     */
+    public boolean pageScroll(int direction) {
+        boolean right = direction == View.FOCUS_RIGHT;
+        int width = getWidth();
+
+        if (right) {
+            mTempRect.left = getScrollX() + width;
+            int count = getChildCount();
+            if (count > 0) {
+                View view = getChildAt(count - 1);
+                if (mTempRect.left + width > view.getRight()) {
+                    mTempRect.left = view.getRight() - width;
+                }
+            }
+        } else {
+            mTempRect.left = getScrollX() - width;
+            if (mTempRect.left < 0) {
+                mTempRect.left = 0;
+            }
+        }
+        mTempRect.right = mTempRect.left + width;
+
+        return scrollAndFocus(direction, mTempRect.left, mTempRect.right);
+    }
+
+    /**
+     * <p>Handles scrolling in response to a "home/end" shortcut press. This
+     * method will scroll the view to the left or right and give the focus
+     * to the leftmost/rightmost component in the new visible area. If no
+     * component is a good candidate for focus, this scrollview reclaims the
+     * focus.</p>
+     *
+     * @param direction the scroll direction: {@link android.view.View#FOCUS_LEFT}
+     *                  to go the left of the view or {@link android.view.View#FOCUS_RIGHT}
+     *                  to go the right
+     * @return true if the key event is consumed by this method, false otherwise
+     */
+    public boolean fullScroll(int direction) {
+        boolean right = direction == View.FOCUS_RIGHT;
+        int width = getWidth();
+
+        mTempRect.left = 0;
+        mTempRect.right = width;
+
+        if (right) {
+            int count = getChildCount();
+            if (count > 0) {
+                View view = getChildAt(count - 1);
+                mTempRect.right = view.getRight();
+                mTempRect.left = mTempRect.right - width;
+            }
+        }
+
+        return scrollAndFocus(direction, mTempRect.left, mTempRect.right);
+    }
+
+    /**
+     * <p>Scrolls the view to make the area defined by <code>left</code> and
+     * <code>right</code> visible. This method attempts to give the focus
+     * to a component visible in this area. If no component can be focused in
+     * the new visible area, the focus is reclaimed by this scrollview.</p>
+     *
+     * @param direction the scroll direction: {@link android.view.View#FOCUS_LEFT}
+     *                  to go left {@link android.view.View#FOCUS_RIGHT} to right
+     * @param left     the left offset of the new area to be made visible
+     * @param right    the right offset of the new area to be made visible
+     * @return true if the key event is consumed by this method, false otherwise
+     */
+    private boolean scrollAndFocus(int direction, int left, int right) {
+        boolean handled = true;
+
+        int width = getWidth();
+        int containerLeft = getScrollX();
+        int containerRight = containerLeft + width;
+        boolean goLeft = direction == View.FOCUS_LEFT;
+
+        View newFocused = findFocusableViewInBounds(goLeft, left, right);
+        if (newFocused == null) {
+            newFocused = this;
+        }
+
+        if (left >= containerLeft && right <= containerRight) {
+            handled = false;
+        } else {
+            int delta = goLeft ? (left - containerLeft) : (right - containerRight);
+            doScrollX(delta);
+        }
+
+        if (newFocused != findFocus() && newFocused.requestFocus(direction)) {
+            mScrollViewMovedFocus = true;
+            mScrollViewMovedFocus = false;
+        }
+
+        return handled;
+    }
+
+    /**
+     * Handle scrolling in response to a left or right arrow click.
+     *
+     * @param direction The direction corresponding to the arrow key that was
+     *                  pressed
+     * @return True if we consumed the event, false otherwise
+     */
+    public boolean arrowScroll(int direction) {
+
+        View currentFocused = findFocus();
+        if (currentFocused == this) currentFocused = null;
+
+        View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
+
+        final int maxJump = getMaxScrollAmount();
+
+        if (nextFocused != null && isWithinDeltaOfScreen(nextFocused, maxJump)) {
+            nextFocused.getDrawingRect(mTempRect);
+            offsetDescendantRectToMyCoords(nextFocused, mTempRect);
+            int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+            doScrollX(scrollDelta);
+            nextFocused.requestFocus(direction);
+        } else {
+            // no new focus
+            int scrollDelta = maxJump;
+
+            if (direction == View.FOCUS_LEFT && getScrollX() < scrollDelta) {
+                scrollDelta = getScrollX();
+            } else if (direction == View.FOCUS_RIGHT) {
+
+                int daRight = getChildAt(getChildCount() - 1).getRight();
+
+                int screenRight = getScrollX() + getWidth();
+
+                if (daRight - screenRight < maxJump) {
+                    scrollDelta = daRight - screenRight;
+                }
+            }
+            if (scrollDelta == 0) {
+                return false;
+            }
+            doScrollX(direction == View.FOCUS_RIGHT ? scrollDelta : -scrollDelta);
+        }
+
+        if (currentFocused != null && currentFocused.isFocused()
+                && isOffScreen(currentFocused)) {
+            // previously focused item still has focus and is off screen, give
+            // it up (take it back to ourselves)
+            // (also, need to temporarily force FOCUS_BEFORE_DESCENDANTS so we are
+            // sure to
+            // get it)
+            final int descendantFocusability = getDescendantFocusability();  // save
+            setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
+            requestFocus();
+            setDescendantFocusability(descendantFocusability);  // restore
+        }
+        return true;
+    }
+
+    /**
+     * @return whether the descendant of this scroll view is scrolled off
+     *  screen.
+     */
+    private boolean isOffScreen(View descendant) {
+        return !isWithinDeltaOfScreen(descendant, 0);
+    }
+
+    /**
+     * @return whether the descendant of this scroll view is within delta
+     *  pixels of being on the screen.
+     */
+    private boolean isWithinDeltaOfScreen(View descendant, int delta) {
+        descendant.getDrawingRect(mTempRect);
+        offsetDescendantRectToMyCoords(descendant, mTempRect);
+
+        return (mTempRect.right + delta) >= getScrollX()
+                && (mTempRect.left - delta) <= (getScrollX() + getWidth());
+    }
+
+    /**
+     * Smooth scroll by a X delta
+     *
+     * @param delta the number of pixels to scroll by on the X axis
+     */
+    private void doScrollX(int delta) {
+        if (delta != 0) {
+            if (mSmoothScrollingEnabled) {
+                smoothScrollBy(delta, 0);
+            } else {
+                scrollBy(delta, 0);
+            }
+        }
+    }
+
+    /**
+     * Like {@link View#scrollBy}, but scroll smoothly instead of immediately.
+     *
+     * @param dx the number of pixels to scroll by on the X axis
+     * @param dy the number of pixels to scroll by on the Y axis
+     */
+    public final void smoothScrollBy(int dx, int dy) {
+        long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
+        if (duration > ANIMATED_SCROLL_GAP) {
+            mScroller.startScroll(mScrollX, mScrollY, dx, dy);
+            invalidate();
+        } else {
+            if (!mScroller.isFinished()) {
+                mScroller.abortAnimation();
+            }
+            scrollBy(dx, dy);
+        }
+        mLastScroll = AnimationUtils.currentAnimationTimeMillis();
+    }
+
+    /**
+     * Like {@link #scrollTo}, but scroll smoothly instead of immediately.
+     *
+     * @param x the position where to scroll on the X axis
+     * @param y the position where to scroll on the Y axis
+     */
+    public final void smoothScrollTo(int x, int y) {
+        smoothScrollBy(x - mScrollX, y - mScrollY);
+    }
+
+    /**
+     * <p>The scroll range of a scroll view is the overall width of all of its
+     * children.</p>
+     */
+    @Override
+    protected int computeHorizontalScrollRange() {
+        int count = getChildCount();
+        return count == 0 ? getWidth() : getChildAt(0).getRight();
+    }
+
+
+    @Override
+    protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) {
+        ViewGroup.LayoutParams lp = child.getLayoutParams();
+
+        int childWidthMeasureSpec;
+        int childHeightMeasureSpec;
+
+        childHeightMeasureSpec = getChildMeasureSpec(parentHeightMeasureSpec, mPaddingTop
+                + mPaddingBottom, lp.height);
+
+        childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+
+        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+    }
+
+    @Override
+    protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed,
+            int parentHeightMeasureSpec, int heightUsed) {
+        final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
+
+        final int childHeightMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
+                mPaddingTop + mPaddingBottom + lp.topMargin + lp.bottomMargin
+                        + heightUsed, lp.height);
+        final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
+                lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
+
+        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
+    }
+
+    @Override
+    public void computeScroll() {
+        if (mScroller.computeScrollOffset()) {
+            // This is called at drawing time by ViewGroup.  We don't want to
+            // re-show the scrollbars at this point, which scrollTo will do,
+            // so we replicate most of scrollTo here.
+            //
+            //         It's a little odd to call onScrollChanged from inside the drawing.
+            //
+            //         It is, except when you remember that computeScroll() is used to
+            //         animate scrolling. So unless we want to defer the onScrollChanged()
+            //         until the end of the animated scrolling, we don't really have a
+            //         choice here.
+            //
+            //         I agree.  The alternative, which I think would be worse, is to post
+            //         something and tell the subclasses later.  This is bad because there
+            //         will be a window where mScrollX/Y is different from what the app
+            //         thinks it is.
+            //
+            int oldX = mScrollX;
+            int oldY = mScrollY;
+            int x = mScroller.getCurrX();
+            int y = mScroller.getCurrY();
+            if (getChildCount() > 0) {
+                View child = getChildAt(0);
+                mScrollX = clamp(x, getWidth() - mPaddingRight - mPaddingLeft, child.getWidth());
+                mScrollY = clamp(y, getHeight() - mPaddingBottom - mPaddingTop, child.getHeight());
+            } else {
+                mScrollX = x;
+                mScrollY = y;
+            }
+            if (oldX != mScrollX || oldY != mScrollY) {
+                onScrollChanged(mScrollX, mScrollY, oldX, oldY);
+            }
+
+            // Keep on drawing until the animation has finished.
+            postInvalidate();
+        }
+    }
+
+    /**
+     * Scrolls the view to the given child.
+     *
+     * @param child the View to scroll to
+     */
+    private void scrollToChild(View child) {
+        child.getDrawingRect(mTempRect);
+
+        /* Offset from child's local coordinates to ScrollView coordinates */
+        offsetDescendantRectToMyCoords(child, mTempRect);
+
+        int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+
+        if (scrollDelta != 0) {
+            scrollBy(scrollDelta, 0);
+        }
+    }
+
+    /**
+     * If rect is off screen, scroll just enough to get it (or at least the
+     * first screen size chunk of it) on screen.
+     *
+     * @param rect      The rectangle.
+     * @param immediate True to scroll immediately without animation
+     * @return true if scrolling was performed
+     */
+    private boolean scrollToChildRect(Rect rect, boolean immediate) {
+        final int delta = computeScrollDeltaToGetChildRectOnScreen(rect);
+        final boolean scroll = delta != 0;
+        if (scroll) {
+            if (immediate) {
+                scrollBy(delta, 0);
+            } else {
+                smoothScrollBy(delta, 0);
+            }
+        }
+        return scroll;
+    }
+
+    /**
+     * Compute the amount to scroll in the X direction in order to get
+     * a rectangle completely on the screen (or, if taller than the screen,
+     * at least the first screen size chunk of it).
+     *
+     * @param rect The rect.
+     * @return The scroll delta.
+     */
+    protected int computeScrollDeltaToGetChildRectOnScreen(Rect rect) {
+
+        int width = getWidth();
+        int screenLeft = getScrollX();
+        int screenRight = screenLeft + width;
+
+        int fadingEdge = getHorizontalFadingEdgeLength();
+
+        // leave room for left fading edge as long as rect isn't at very left
+        if (rect.left > 0) {
+            screenLeft += fadingEdge;
+        }
+
+        // leave room for right fading edge as long as rect isn't at very right
+        if (rect.right < getChildAt(0).getWidth()) {
+            screenRight -= fadingEdge;
+        }
+
+        int scrollXDelta = 0;
+
+        if (rect.right > screenRight && rect.left > screenLeft) {
+            // need to move right to get it in view: move right just enough so
+            // that the entire rectangle is in view (or at least the first
+            // screen size chunk).
+
+            if (rect.width() > width) {
+                // just enough to get screen size chunk on
+                scrollXDelta += (rect.left - screenLeft);
+            } else {
+                // get entire rect at right of screen
+                scrollXDelta += (rect.right - screenRight);
+            }
+
+            // make sure we aren't scrolling beyond the end of our content
+            int right = getChildAt(getChildCount() - 1).getRight();
+            int distanceToRight = right - screenRight;
+            scrollXDelta = Math.min(scrollXDelta, distanceToRight);
+
+        } else if (rect.left < screenLeft && rect.right < screenRight) {
+            // need to move right to get it in view: move right just enough so that
+            // entire rectangle is in view (or at least the first screen
+            // size chunk of it).
+
+            if (rect.width() > width) {
+                // screen size chunk
+                scrollXDelta -= (screenRight - rect.right);
+            } else {
+                // entire rect at left
+                scrollXDelta -= (screenLeft - rect.left);
+            }
+
+            // make sure we aren't scrolling any further than the left our content
+            scrollXDelta = Math.max(scrollXDelta, -getScrollX());
+        }
+        return scrollXDelta;
+    }
+
+    @Override
+    public void requestChildFocus(View child, View focused) {
+        if (!mScrollViewMovedFocus) {
+            if (!mIsLayoutDirty) {
+                scrollToChild(focused);
+            } else {
+                // The child may not be laid out yet, we can't compute the scroll yet
+                mChildToScrollTo = focused;
+            }
+        }
+        super.requestChildFocus(child, focused);
+    }
+
+
+    /**
+     * When looking for focus in children of a scroll view, need to be a little
+     * more careful not to give focus to something that is scrolled off screen.
+     *
+     * This is more expensive than the default {@link android.view.ViewGroup}
+     * implementation, otherwise this behavior might have been made the default.
+     */
+    @Override
+    protected boolean onRequestFocusInDescendants(int direction,
+            Rect previouslyFocusedRect) {
+
+        // convert from forward / backward notation to up / down / left / right
+        // (ugh).
+        if (direction == View.FOCUS_FORWARD) {
+            direction = View.FOCUS_RIGHT;
+        } else if (direction == View.FOCUS_BACKWARD) {
+            direction = View.FOCUS_LEFT;
+        }
+
+        final View nextFocus = previouslyFocusedRect == null ?
+                FocusFinder.getInstance().findNextFocus(this, null, direction) :
+                FocusFinder.getInstance().findNextFocusFromRect(this,
+                        previouslyFocusedRect, direction);
+
+        if (nextFocus == null) {
+            return false;
+        }
+
+        if (isOffScreen(nextFocus)) {
+            return false;
+        }
+
+        return nextFocus.requestFocus(direction, previouslyFocusedRect);
+    }
+
+    @Override
+    public boolean requestChildRectangleOnScreen(View child, Rect rectangle,
+            boolean immediate) {
+        // offset into coordinate space of this scroll view
+        rectangle.offset(child.getLeft() - child.getScrollX(),
+                child.getTop() - child.getScrollY());
+
+        return scrollToChildRect(rectangle, immediate);
+    }
+
+    @Override
+    public void requestLayout() {
+        mIsLayoutDirty = true;
+        super.requestLayout();
+    }
+
+    @Override
+    protected void onLayout(boolean changed, int l, int t, int r, int b) {
+        super.onLayout(changed, l, t, r, b);
+        mIsLayoutDirty = false;
+        // Give a child focus if it needs it
+        if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this)) {
+                scrollToChild(mChildToScrollTo);
+        }
+        mChildToScrollTo = null;
+
+        // Calling this with the present values causes it to re-clam them
+        scrollTo(mScrollX, mScrollY);
+    }
+
+    @Override
+    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        super.onSizeChanged(w, h, oldw, oldh);
+
+        View currentFocused = findFocus();
+        if (null == currentFocused || this == currentFocused)
+            return;
+
+        final int maxJump = mRight - mLeft;
+
+        if (isWithinDeltaOfScreen(currentFocused, maxJump)) {
+            currentFocused.getDrawingRect(mTempRect);
+            offsetDescendantRectToMyCoords(currentFocused, mTempRect);
+            int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
+            doScrollX(scrollDelta);
+        }
+    }
+
+    /**
+     * Return true if child is an descendant of parent, (or equal to the parent).
+     */
+    private boolean isViewDescendantOf(View child, View parent) {
+        if (child == parent) {
+            return true;
+        }
+
+        final ViewParent theParent = child.getParent();
+        return (theParent instanceof ViewGroup) && isViewDescendantOf((View) theParent, parent);
+    }
+
+    /**
+     * Fling the scroll view
+     *
+     * @param velocityX The initial velocity in the X direction. Positive
+     *                  numbers mean that the finger/curor is moving down the screen,
+     *                  which means we want to scroll towards the left.
+     */
+    public void fling(int velocityX) {
+        int width = getWidth() - mPaddingRight - mPaddingLeft;
+        int right = getChildAt(0).getWidth();
+
+        mScroller.fling(mScrollX, mScrollY, velocityX, 0, 0, right - width, 0, 0);
+
+        final boolean movingRight = velocityX > 0;
+
+        View newFocused = findFocusableViewInMyBounds(movingRight,
+                mScroller.getFinalX(), findFocus());
+
+        if (newFocused == null) {
+            newFocused = this;
+        }
+
+        if (newFocused != findFocus()
+                && newFocused.requestFocus(movingRight ? View.FOCUS_RIGHT : View.FOCUS_LEFT)) {
+            mScrollViewMovedFocus = true;
+            mScrollViewMovedFocus = false;
+        }
+
+        invalidate();
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p>This version also clamps the scrolling to the bounds of our child.
+     */
+    public void scrollTo(int x, int y) {
+        // we rely on the fact the View.scrollBy calls scrollTo.
+        if (getChildCount() > 0) {
+            View child = getChildAt(0);
+            x = clamp(x, getWidth() - mPaddingRight - mPaddingLeft, child.getWidth());
+            y = clamp(y, getHeight() - mPaddingBottom - mPaddingTop, child.getHeight());
+            if (x != mScrollX || y != mScrollY) {
+                super.scrollTo(x, y);
+            }
+        }
+    }
+
+    private int clamp(int n, int my, int child) {
+        if (my >= child || n < 0) {
+            return 0;
+        }
+        if ((my + n) > child) {
+            return child - my;
+        }
+        return n;
+    }
+}
diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java
index 36ed8bd..85a7339 100644
--- a/core/java/android/widget/LinearLayout.java
+++ b/core/java/android/widget/LinearLayout.java
@@ -336,7 +336,7 @@
                    // heightMode is either UNSPECIFIED OR AT_MOST, and this child
                    // wanted to stretch to fill available space. Translate that to
                    // WRAP_CONTENT so that it does not end up with a height of 0
-                   oldHeight = lp.height;
+                   oldHeight = 0;
                    lp.height = LayoutParams.WRAP_CONTENT;
                }
 
@@ -475,8 +475,6 @@
                         matchWidthLocally ? margin : measuredWidth);
 
                 allFillParent = allFillParent && lp.width == LayoutParams.FILL_PARENT;
-                alternativeMaxWidth = Math.max(alternativeMaxWidth,
-                        matchWidthLocally ? margin : measuredWidth);
 
                 mTotalLength += child.getMeasuredHeight() + lp.topMargin +
                         lp.bottomMargin + getNextLocationOffset(child);
@@ -607,7 +605,7 @@
                     // widthMode is either UNSPECIFIED OR AT_MOST, and this child
                     // wanted to stretch to fill available space. Translate that to
                     // WRAP_CONTENT so that it does not end up with a width of 0
-                    oldWidth = lp.width;
+                    oldWidth = 0;
                     lp.width = LayoutParams.WRAP_CONTENT;
                 }
 
@@ -766,8 +764,6 @@
                         matchHeightLocally ? margin : childHeight);
 
                 allFillParent = allFillParent && lp.height == LayoutParams.FILL_PARENT;
-                alternativeMaxHeight = Math.max(alternativeMaxHeight,
-                        matchHeightLocally ? margin : childHeight);
 
                 if (baselineAligned) {
                     final int childBaseline = child.getBaseline();
@@ -803,8 +799,7 @@
                 maxHeight = Math.max(maxHeight, ascent + descent);
             }
         } else {
-            alternativeMaxHeight = Math.max(alternativeMaxHeight,
-                                            weightedMaxHeight);
+            alternativeMaxHeight = Math.max(alternativeMaxHeight, weightedMaxHeight);
         }
 
         if (!allFillParent && heightMode != MeasureSpec.EXACTLY) {
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index dfc7bc3..9c7f600 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -1718,12 +1718,11 @@
     }
 
     /**
-     * Sets the currently selected item
+     * Sets the currently selected item. If in touch mode, the item will not be selected
+     * but it will still be positioned appropriately. If the specified selection position
+     * is less than 0, then the item at position 0 will be selected.
      *
      * @param position Index (starting at 0) of the data item to be selected.
-     *
-     * If in touch mode, the item will not be selected but it will still be positioned
-     * appropriately.
      */
     @Override
     public void setSelection(int position) {
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java
index 50248c1..dada105 100644
--- a/core/java/android/widget/PopupWindow.java
+++ b/core/java/android/widget/PopupWindow.java
@@ -632,17 +632,36 @@
 
         WindowManager.LayoutParams p = createPopupLayout(anchor.getWindowToken());
         preparePopup(p);
+        mAboveAnchor = findDropDownPosition(anchor, p, xoff, yoff);
+
         if (mBackground != null) {
             mPopupView.refreshDrawableState();
         }
-        mAboveAnchor = findDropDownPosition(anchor, p, xoff, yoff);
+
         if (mHeightMode < 0) p.height = mLastHeight = mHeightMode;
         if (mWidthMode < 0) p.width = mLastWidth = mWidthMode;
+
         p.windowAnimations = computeAnimationResource();
+
         invokePopup(p);
     }
 
     /**
+     * Indicates whether the popup is showing above (the y coordinate of the popup's bottom
+     * is less than the y coordinate of the anchor) or below the anchor view (the y coordinate
+     * of the popup is greater than y coordinate of the anchor's bottom).
+     *
+     * The value returned
+     * by this method is meaningful only after {@link #showAsDropDown(android.view.View)}
+     * or {@link #showAsDropDown(android.view.View, int, int)} was invoked.
+     *
+     * @return True if this popup is showing above the anchor view, false otherwise.
+     */
+    public boolean isAboveAnchor() {
+        return mAboveAnchor;
+    }
+
+    /**
      * <p>Prepare the popup by embedding in into a new ViewGroup if the
      * background drawable is not null. If embedding is required, the layout
      * parameters' height is mnodified to take into account the background's
@@ -662,18 +681,6 @@
             popupViewContainer.setBackgroundDrawable(mBackground);
             popupViewContainer.addView(mContentView, listParams);
 
-            if (p.height >= 0) {
-                // accomodate the popup's height to take into account the
-                // background's padding
-                p.height += popupViewContainer.getPaddingTop() +
-                        popupViewContainer.getPaddingBottom();
-            }
-            if (p.width >= 0) {
-                // accomodate the popup's width to take into account the
-                // background's padding
-                p.width += popupViewContainer.getPaddingLeft() +
-                        popupViewContainer.getPaddingRight();
-            }
             mPopupView = popupViewContainer;
         } else {
             mPopupView = mContentView;
@@ -720,7 +727,8 @@
         p.flags = computeFlags(p.flags);
         p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
         p.token = token;
-        
+        p.setTitle("PopupWindow:" + Integer.toHexString(hashCode()));
+
         return p;
     }
 
@@ -781,7 +789,9 @@
      *
      * @return true if the popup is translated upwards to fit on screen
      */
-    private boolean findDropDownPosition(View anchor, WindowManager.LayoutParams p, int xoff, int yoff) {
+    private boolean findDropDownPosition(View anchor, WindowManager.LayoutParams p,
+            int xoff, int yoff) {
+
         anchor.getLocationInWindow(mDrawingLocation);
         p.x = mDrawingLocation[0] + xoff;
         p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;
@@ -795,8 +805,7 @@
         anchor.getWindowVisibleDisplayFrame(displayFrame);
         
         final View root = anchor.getRootView();
-        if (mScreenLocation[1] + anchor.getMeasuredHeight() + yoff + mPopupHeight > displayFrame.bottom
-                || p.x + mPopupWidth - root.getWidth() > 0) {
+        if (p.y + mPopupHeight > displayFrame.bottom || p.x + mPopupWidth - root.getWidth() > 0) {
             // if the drop down disappears at the bottom of the screen. we try to
             // scroll a parent scrollview or move the drop down back up on top of
             // the edit box
@@ -815,11 +824,11 @@
             // determine whether there is more space above or below the anchor
             anchor.getLocationOnScreen(mScreenLocation);
             
-            onTop = (displayFrame.bottom - mScreenLocation[1] - anchor.getMeasuredHeight() - yoff)
-                    < (mScreenLocation[1] - yoff - displayFrame.top);
+            onTop = (displayFrame.bottom - mScreenLocation[1] - anchor.getMeasuredHeight() - yoff) <
+                    (mScreenLocation[1] - yoff - displayFrame.top);
             if (onTop) {
                 p.gravity = Gravity.LEFT | Gravity.BOTTOM;
-                p.y = root.getHeight() - mDrawingLocation[1] - yoff;
+                p.y = root.getHeight() - mDrawingLocation[1] + yoff;
             } else {
                 p.y = mDrawingLocation[1] + anchor.getMeasuredHeight() + yoff;
             }
@@ -841,15 +850,30 @@
      *         shown.
      */
     public int getMaxAvailableHeight(View anchor) {
+        return getMaxAvailableHeight(anchor, 0);
+    }
+
+    /**
+     * Returns the maximum height that is available for the popup to be
+     * completely shown. It is recommended that this height be the maximum for
+     * the popup's height, otherwise it is possible that the popup will be
+     * clipped.
+     *
+     * @param anchor The view on which the popup window must be anchored.
+     * @param yOffset y offset from the view's bottom edge
+     * @return The maximum available height for the popup to be completely
+     *         shown.
+     */
+    public int getMaxAvailableHeight(View anchor, int yOffset) {
         final Rect displayFrame = new Rect();
         anchor.getWindowVisibleDisplayFrame(displayFrame);
 
         final int[] anchorPos = mDrawingLocation;
         anchor.getLocationOnScreen(anchorPos);
         
-        final int distanceToBottom = displayFrame.bottom
-                - (anchorPos[1] + anchor.getHeight());
-        final int distanceToTop = anchorPos[1] - displayFrame.top;
+        final int distanceToBottom = displayFrame.bottom -
+                (anchorPos[1] + anchor.getHeight()) - yOffset;
+        final int distanceToTop = anchorPos[1] - displayFrame.top + yOffset;
 
         // anchorPos[1] is distance from anchor to top of screen
         int returnedHeight = Math.max(distanceToBottom, distanceToTop);
@@ -939,10 +963,12 @@
      */
     public void update(int x, int y, int width, int height) {
         if (width != -1) {
+            mLastWidth = width;
             setWidth(width);
         }
 
         if (height != -1) {
+            mLastHeight = height;
             setHeight(height);
         }
 
@@ -990,22 +1016,6 @@
         }
         
         if (update) {
-            if (mPopupView != mContentView) {
-                final View popupViewContainer = mPopupView;
-                if (p.height >= 0) {
-                    // accomodate the popup's height to take into account the
-                    // background's padding
-                    p.height += popupViewContainer.getPaddingTop() +
-                            popupViewContainer.getPaddingBottom();
-                }
-                if (p.width >= 0) {
-                    // accomodate the popup's width to take into account the
-                    // background's padding
-                    p.width += popupViewContainer.getPaddingLeft() +
-                            popupViewContainer.getPaddingRight();
-                }
-            }
-
             mWindowManager.updateViewLayout(mPopupView, p);
         }
     }
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java
index 2e04b5d..434e9f3 100644
--- a/core/java/android/widget/ProgressBar.java
+++ b/core/java/android/widget/ProgressBar.java
@@ -761,7 +761,7 @@
             if (dr == mProgressDrawable || dr == mIndeterminateDrawable) {
                 final Rect dirty = dr.getBounds();
                 final int scrollX = mScrollX + mPaddingLeft;
-                final int scrollY = mScrollY + mPaddingRight;
+                final int scrollY = mScrollY + mPaddingTop;
 
                 invalidate(dirty.left + scrollX, dirty.top + scrollY,
                         dirty.right + scrollX, dirty.bottom + scrollY);
diff --git a/core/java/android/widget/RadioGroup.java b/core/java/android/widget/RadioGroup.java
index ed8df22..393346a 100644
--- a/core/java/android/widget/RadioGroup.java
+++ b/core/java/android/widget/RadioGroup.java
@@ -122,6 +122,23 @@
         }
     }
 
+    @Override
+    public void addView(View child, int index, ViewGroup.LayoutParams params) {
+        if (child instanceof RadioButton) {
+            final RadioButton button = (RadioButton) child;
+            if (button.isChecked()) {
+                mProtectFromCheckedChange = true;
+                if (mCheckedId != -1) {
+                    setCheckedStateForView(mCheckedId, false);
+                }
+                mProtectFromCheckedChange = false;
+                setCheckedId(button.getId());
+            }
+        }
+
+        super.addView(child, index, params);
+    }
+
     /**
      * <p>Sets the selection to the radio button whose identifier is passed in
      * parameter. Using -1 as the selection identifier clears the selection;
diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java
index 91d5805..9ded52b 100644
--- a/core/java/android/widget/RelativeLayout.java
+++ b/core/java/android/widget/RelativeLayout.java
@@ -152,7 +152,7 @@
 
     private void initFromAttributes(Context context, AttributeSet attrs) {
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RelativeLayout);
-        mIgnoreGravity = a.getResourceId(R.styleable.RelativeLayout_ignoreGravity, 0);
+        mIgnoreGravity = a.getResourceId(R.styleable.RelativeLayout_ignoreGravity, View.NO_ID);
         mGravity = a.getInt(R.styleable.RelativeLayout_gravity, mGravity);
         a.recycle();
     }
@@ -263,7 +263,7 @@
         int right = Integer.MIN_VALUE;
         int bottom = Integer.MIN_VALUE;
 
-        if ((horizontalGravity || verticalGravity) && mIgnoreGravity != 0) {
+        if ((horizontalGravity || verticalGravity) && mIgnoreGravity != View.NO_ID) {
             ignore = findViewById(mIgnoreGravity);
         }
 
diff --git a/core/java/android/widget/RemoteViews.aidl b/core/java/android/widget/RemoteViews.aidl
new file mode 100644
index 0000000..ec86410
--- /dev/null
+++ b/core/java/android/widget/RemoteViews.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2007, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ *
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package android.widget;
+
+parcelable RemoteViews;
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 5721095..a1023bd 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -22,6 +22,7 @@
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
+import android.graphics.PorterDuff;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
@@ -422,6 +423,131 @@
     }
 
     /**
+     * Equivalent to calling a combination of {@link Drawable#setAlpha(int)},
+     * {@link Drawable#setColorFilter(int, android.graphics.PorterDuff.Mode)},
+     * and/or {@link Drawable#setLevel(int)} on the {@link Drawable} of a given view.
+     * <p>
+     * These operations will be performed on the {@link Drawable} returned by the
+     * target {@link View#getBackground()} by default.  If targetBackground is false,
+     * we assume the target is an {@link ImageView} and try applying the operations
+     * to {@link ImageView#getDrawable()}.
+     * <p>
+     * You can omit specific calls by marking their values with null or -1.
+     */
+    private class SetDrawableParameters extends Action {
+        public SetDrawableParameters(int id, boolean targetBackground, int alpha,
+                int colorFilter, PorterDuff.Mode mode, int level) {
+            this.viewId = id;
+            this.targetBackground = targetBackground;
+            this.alpha = alpha;
+            this.colorFilter = colorFilter;
+            this.filterMode = mode;
+            this.level = level;
+        }
+        
+        public SetDrawableParameters(Parcel parcel) {
+            viewId = parcel.readInt();
+            targetBackground = parcel.readInt() != 0;
+            alpha = parcel.readInt();
+            colorFilter = parcel.readInt();
+            boolean hasMode = parcel.readInt() != 0;
+            if (hasMode) {
+                filterMode = PorterDuff.Mode.valueOf(parcel.readString());
+            } else {
+                filterMode = null;
+            }
+            level = parcel.readInt();
+        }
+        
+        public void writeToParcel(Parcel dest, int flags) {
+            dest.writeInt(TAG);
+            dest.writeInt(viewId);
+            dest.writeInt(targetBackground ? 1 : 0);
+            dest.writeInt(alpha);
+            dest.writeInt(colorFilter);
+            if (filterMode != null) {
+                dest.writeInt(1);
+                dest.writeString(filterMode.toString());
+            } else {
+                dest.writeInt(0);
+            }
+            dest.writeInt(level);
+        }
+        
+        @Override
+        public void apply(View root) {
+            final View target = root.findViewById(viewId);
+            if (target == null) {
+                return;
+            }
+            
+            // Pick the correct drawable to modify for this view
+            Drawable targetDrawable = null;
+            if (targetBackground) {
+                targetDrawable = target.getBackground();
+            } else if (target instanceof ImageView) {
+                ImageView imageView = (ImageView) target;
+                targetDrawable = imageView.getDrawable();
+            }
+            
+            // Perform modifications only if values are set correctly
+            if (alpha != -1) {
+                targetDrawable.setAlpha(alpha);
+            }
+            if (colorFilter != -1 && filterMode != null) {
+                targetDrawable.setColorFilter(colorFilter, filterMode);
+            }
+            if (level != -1) {
+                targetDrawable.setLevel(level);
+            }
+        }
+        
+        int viewId;
+        boolean targetBackground;
+        int alpha;
+        int colorFilter;
+        PorterDuff.Mode filterMode;
+        int level;
+
+        public final static int TAG = 8;
+    }
+    
+    /**
+     * Equivalent to calling {@link android.widget.TextView#setTextColor(int)}.
+     */
+    private class SetTextColor extends Action {
+        public SetTextColor(int id, int color) {
+            this.viewId = id;
+            this.color = color;
+        }
+        
+        public SetTextColor(Parcel parcel) {
+            viewId = parcel.readInt();
+            color = parcel.readInt();
+        }
+        
+        public void writeToParcel(Parcel dest, int flags) {
+            dest.writeInt(TAG);
+            dest.writeInt(viewId);
+            dest.writeInt(color);
+        }
+        
+        @Override
+        public void apply(View root) {
+            final View target = root.findViewById(viewId);
+            if (target instanceof TextView) {
+                final TextView textView = (TextView) target;
+                textView.setTextColor(color);
+            }
+        }
+        
+        int viewId;
+        int color;
+
+        public final static int TAG = 9;
+    }
+    
+    /**
      * Create a new RemoteViews object that will display the views contained
      * in the specified layout file.
      * 
@@ -471,6 +597,12 @@
                 case SetOnClickPendingIntent.TAG:
                     mActions.add(new SetOnClickPendingIntent(parcel));
                     break;
+                case SetDrawableParameters.TAG:
+                    mActions.add(new SetDrawableParameters(parcel));
+                    break;
+                case SetTextColor.TAG:
+                    mActions.add(new SetTextColor(parcel));
+                    break;
                 default:
                     throw new ActionException("Tag " + tag + "not found");
                 }
@@ -595,6 +727,48 @@
     }
 
     /**
+     * Equivalent to calling a combination of {@link Drawable#setAlpha(int)},
+     * {@link Drawable#setColorFilter(int, android.graphics.PorterDuff.Mode)},
+     * and/or {@link Drawable#setLevel(int)} on the {@link Drawable} of a given
+     * view.
+     * <p>
+     * You can omit specific calls by marking their values with null or -1.
+     * 
+     * @param viewId The id of the view that contains the target
+     *            {@link Drawable}
+     * @param targetBackground If true, apply these parameters to the
+     *            {@link Drawable} returned by
+     *            {@link android.view.View#getBackground()}. Otherwise, assume
+     *            the target view is an {@link ImageView} and apply them to
+     *            {@link ImageView#getDrawable()}.
+     * @param alpha Specify an alpha value for the drawable, or -1 to leave
+     *            unchanged.
+     * @param colorFilter Specify a color for a
+     *            {@link android.graphics.ColorFilter} for this drawable, or -1
+     *            to leave unchanged.
+     * @param mode Specify a PorterDuff mode for this drawable, or null to leave
+     *            unchanged.
+     * @param level Specify the level for the drawable, or -1 to leave
+     *            unchanged.
+     */
+    public void setDrawableParameters(int viewId, boolean targetBackground, int alpha,
+            int colorFilter, PorterDuff.Mode mode, int level) {
+        addAction(new SetDrawableParameters(viewId, targetBackground, alpha,
+                colorFilter, mode, level));
+    }
+
+    /**
+     * Equivalent to calling {@link android.widget.TextView#setTextColor(int)}.
+     * 
+     * @param viewId The id of the view whose text should change
+     * @param color Sets the text color for all the states (normal, selected,
+     *            focused) to be this color.
+     */
+    public void setTextColor(int viewId, int color) {
+        addAction(new SetTextColor(viewId, color));
+    }
+
+    /**
      * Inflates the view hierarchy represented by this object and applies
      * all of the actions.
      * 
diff --git a/core/java/android/widget/ScrollBarDrawable.java b/core/java/android/widget/ScrollBarDrawable.java
index 17f9128..3b113ae 100644
--- a/core/java/android/widget/ScrollBarDrawable.java
+++ b/core/java/android/widget/ScrollBarDrawable.java
@@ -152,10 +152,12 @@
         } else {
             track = mHorizontalTrack;
         }
-        if (mChanged) {
-            track.setBounds(bounds);
+        if (track != null) {
+            if (mChanged) {
+                track.setBounds(bounds);
+            }
+            track.draw(canvas);
         }
-        track.draw(canvas);
     }
 
     protected void drawThumb(Canvas canvas, Rect bounds, int offset, int length, boolean vertical) {
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index 20166cf..c9b3751 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -44,13 +44,7 @@
  * manager with a complex hierarchy of objects.  A child that is often used
  * is a {@link LinearLayout} in a vertical orientation, presenting a vertical
  * array of top-level items that the user can scroll through.
- * 
- * <p>You should never use a ScrollView with a {@link ListView}, since
- * ListView takes care of its own scrolling.  Most importantly, doing this
- * defeats all of the important optimizations in ListView for dealing with
- * large lists, since it effectively forces the ListView to display its entire
- * list of items to fill up the infinite container supplied by ScrollView.
- * 
+ *
  * <p>The {@link TextView} class also
  * takes care of its own scrolling, so does not require a ScrollView, but
  * using the two together is possible to achieve the effect of a text view
@@ -62,13 +56,9 @@
     static final String TAG = "ScrollView";
     static final boolean localLOGV = false || Config.LOGV;
     
-    private static final int ANIMATED_SCROLL_GAP = 250;
+    static final int ANIMATED_SCROLL_GAP = 250;
 
-    /**
-     * When arrow scrolling, ListView will never scroll more than this factor
-     * times the height of the list.
-     */
-    private static final float MAX_SCROLL_FACTOR = 0.5f;
+    static final float MAX_SCROLL_FACTOR = 0.5f;
 
 
     private long mLastScroll;
@@ -124,6 +114,8 @@
      */
     private boolean mSmoothScrollingEnabled = true;
 
+    private int mTouchSlop;
+
     public ScrollView(Context context) {
         this(context, null);
     }
@@ -165,8 +157,8 @@
         }
 
         final int length = getVerticalFadingEdgeLength();
-        final int bottom = getChildAt(0).getBottom();
-        final int span = bottom - mScrollY - getHeight();
+        final int bottomEdge = getHeight() - mPaddingBottom;
+        final int span = getChildAt(0).getBottom() - mScrollY - bottomEdge;
         if (span < length) {
             return span / (float) length;
         }
@@ -188,6 +180,7 @@
         setFocusable(true);
         setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
         setWillNotDraw(false);
+        mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
     }
 
     @Override
@@ -401,7 +394,7 @@
                 * of the down event.
                 */
                 final int yDiff = (int) Math.abs(y - mLastMotionY);
-                if (yDiff > ViewConfiguration.getTouchSlop()) {
+                if (yDiff > mTouchSlop) {
                     mIsBeingDragged = true;
                 }
                 break;
@@ -488,8 +481,9 @@
                 velocityTracker.computeCurrentVelocity(1000);
                 int initialVelocity = (int) velocityTracker.getYVelocity();
 
-                if ((Math.abs(initialVelocity) > ViewConfiguration.getMinimumFlingVelocity()) &&
-                        (getChildCount() > 0)) {
+                if ((Math.abs(initialVelocity) >
+                        ViewConfiguration.get(mContext).getScaledMinimumFlingVelocity()) &&
+                        getChildCount() > 0) {
                     fling(-initialVelocity);
                 }
 
@@ -812,7 +806,7 @@
     /**
      * Smooth scroll by a Y delta
      *
-     * @param delta the number of pixels to scroll by on the X axis
+     * @param delta the number of pixels to scroll by on the Y axis
      */
     private void doScrollY(int delta) {
         if (delta != 0) {
@@ -923,8 +917,8 @@
             int y = mScroller.getCurrY();
             if (getChildCount() > 0) {
                 View child = getChildAt(0);
-                mScrollX = clamp(x, this.getWidth(), child.getWidth());
-                mScrollY = clamp(y, this.getHeight(), child.getHeight());
+                mScrollX = clamp(x, getWidth() - mPaddingRight - mPaddingLeft, child.getWidth());
+                mScrollY = clamp(y, getHeight() - mPaddingBottom - mPaddingTop, child.getHeight());
                 if (localLOGV) Log.v(TAG, "mScrollY=" + mScrollY + " y=" + y
                         + " height=" + this.getHeight()
                         + " child height=" + child.getHeight());
@@ -1167,8 +1161,8 @@
      *                  which means we want to scroll towards the top.
      */
     public void fling(int velocityY) {
-        int height = getHeight();
-        int bottom = getChildAt(getChildCount() - 1).getBottom();
+        int height = getHeight() - mPaddingBottom - mPaddingTop;
+        int bottom = getChildAt(0).getHeight();
 
         mScroller.fling(mScrollX, mScrollY, 0, velocityY, 0, 0, 0, bottom - height);
 
@@ -1198,8 +1192,8 @@
         // we rely on the fact the View.scrollBy calls scrollTo.
         if (getChildCount() > 0) {
             View child = getChildAt(0);
-            x = clamp(x, this.getWidth(), child.getWidth());
-            y = clamp(y, this.getHeight(), child.getHeight());
+            x = clamp(x, getWidth() - mPaddingRight - mPaddingLeft, child.getWidth());
+            y = clamp(y, getHeight() - mPaddingBottom - mPaddingTop, child.getHeight());
             if (x != mScrollX || y != mScrollY) {
                 super.scrollTo(x, y);
             }
diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java
index fbe5e57..febc956 100644
--- a/core/java/android/widget/Scroller.java
+++ b/core/java/android/widget/Scroller.java
@@ -132,6 +132,26 @@
     }
     
     /**
+     * Returns the start X offset in the scroll. 
+     * 
+     * @return The start X offset as an absolute distance from the origin.
+     * @hide pending API council
+     */
+    public final int getStartX() {
+        return mStartX;
+    }
+    
+    /**
+     * Returns the start Y offset in the scroll. 
+     * 
+     * @return The start Y offset as an absolute distance from the origin.
+     * @hide pending API council
+     */
+    public final int getStartY() {
+        return mStartY;
+    }
+    
+    /**
      * Returns where the scroll will end. Valid only for "fling" scrolls.
      * 
      * @return The final X offset as an absolute distance from the origin.
diff --git a/core/java/android/widget/SimpleAdapter.java b/core/java/android/widget/SimpleAdapter.java
index 261da9f..093c24e 100644
--- a/core/java/android/widget/SimpleAdapter.java
+++ b/core/java/android/widget/SimpleAdapter.java
@@ -36,12 +36,16 @@
  * Binding data to views occurs in two phases. First, if a
  * {@link android.widget.SimpleAdapter.ViewBinder} is available,
  * {@link ViewBinder#setViewValue(android.view.View, Object, String)}
- * is invoked. If the returned value is true, binding has occured. If the
- * returned value is false and the view to bind is a TextView,
- * {@link #setViewText(TextView, String)} is invoked. If the returned value
- * is false and the view to bind is an ImageView,
- * {@link #setViewImage(ImageView, int)} or {@link #setViewImage(ImageView, String)} is
- * invoked. If no appropriate binding can be found, an {@link IllegalStateException} is thrown.
+ * is invoked. If the returned value is true, binding has occurred. 
+ * If the returned value is false, the following views are then tried in order:
+ * <ul>
+ * <li> A view that implements Checkable (e.g. CheckBox).  The expected bind value is a boolean.
+ * <li> TextView.  The expected bind value is a string and {@link #setViewText(TextView, String)} 
+ * is invoked.
+ * <li> ImageView. The expected bind value is a resource id or a string and 
+ * {@link #setViewImage(ImageView, int)} or {@link #setViewImage(ImageView, String)} is invoked. 
+ * </ul>
+ * If no appropriate binding can be found, an {@link IllegalStateException} is thrown.
  */
 public class SimpleAdapter extends BaseAdapter implements Filterable {
     private int[] mTo;
@@ -176,7 +180,16 @@
                 }
 
                 if (!bound) {
-                    if (v instanceof TextView) {
+                    if (v instanceof Checkable) {
+                        if (data instanceof Boolean) {
+                            ((Checkable) v).setChecked((Boolean) data);
+                        } else {
+                            throw new IllegalStateException(v.getClass().getName() +
+                                    " should be bound to a Boolean, not a " + data.getClass());
+                        }
+                    } else if (v instanceof TextView) {
+                        // Note: keep the instanceof TextView check at the bottom of these
+                        // ifs since a lot of views are TextViews (e.g. CheckBoxes).
                         setViewText((TextView) v, text);
                     } else if (v instanceof ImageView) {
                         if (data instanceof Integer) {
diff --git a/core/java/com/android/internal/widget/SlidingDrawer.java b/core/java/android/widget/SlidingDrawer.java
similarity index 91%
rename from core/java/com/android/internal/widget/SlidingDrawer.java
rename to core/java/android/widget/SlidingDrawer.java
index a4045d5..e77c4ca 100644
--- a/core/java/com/android/internal/widget/SlidingDrawer.java
+++ b/core/java/android/widget/SlidingDrawer.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.internal.widget;
+package android.widget;
 
 import android.view.ViewGroup;
 import android.view.View;
@@ -30,7 +30,7 @@
 import android.os.SystemClock;
 import android.os.Handler;
 import android.os.Message;
-import com.android.internal.R;
+import android.R;
 
 /**
  * SlidingDrawer hides content out of the screen and allows the user to drag a handle
@@ -48,7 +48,7 @@
  * content:
  *
  * <pre class="prettyprint">
- * &lt;com.android.internal.widget.SlidingDrawer
+ * &lt;SlidingDrawer
  *     android:id="@+id/drawer"
  *     android:layout_width="fill_parent"
  *     android:layout_height="fill_parent"
@@ -66,16 +66,16 @@
  *         android:layout_width="fill_parent"
  *         android:layout_height="fill_parent" /&gt;
  *
- * &lt;/com.android.internal.widget.SlidingDrawer&gt;
+ * &lt;/SlidingDrawer&gt;
  * </pre>
  *
- * @attr ref com.android.internal.R.styleable#SlidingDrawer_content
- * @attr ref com.android.internal.R.styleable#SlidingDrawer_handle
- * @attr ref com.android.internal.R.styleable#SlidingDrawer_topOffset
- * @attr ref com.android.internal.R.styleable#SlidingDrawer_bottomOffset
- * @attr ref com.android.internal.R.styleable#SlidingDrawer_orientation
- * @attr ref com.android.internal.R.styleable#SlidingDrawer_allowSingleTap
- * @attr ref com.android.internal.R.styleable#SlidingDrawer_animateOnClick
+ * @attr ref android.R.styleable#SlidingDrawer_content
+ * @attr ref android.R.styleable#SlidingDrawer_handle
+ * @attr ref android.R.styleable#SlidingDrawer_topOffset
+ * @attr ref android.R.styleable#SlidingDrawer_bottomOffset
+ * @attr ref android.R.styleable#SlidingDrawer_orientation
+ * @attr ref android.R.styleable#SlidingDrawer_allowSingleTap
+ * @attr ref android.R.styleable#SlidingDrawer_animateOnClick
  */
 public class SlidingDrawer extends ViewGroup {
     public static final int ORIENTATION_HORIZONTAL = 0;
@@ -128,6 +128,13 @@
     private boolean mAllowSingleTap;
     private boolean mAnimateOnClick;
 
+    private final int mTapThreshold;
+    private final int mMaximumTapVelocity;
+    private final int mMaximumMinorVelocity;
+    private final int mMaximumMajorVelocity;
+    private final int mMaximumAcceleration;
+    private final int mVelocityUnits;
+
     /**
      * Callback invoked when the drawer is opened.
      */
@@ -206,6 +213,14 @@
         mHandleId = handleId;
         mContentId = contentId;
 
+        final float density = getResources().getDisplayMetrics().density;
+        mTapThreshold = (int) (TAP_THRESHOLD * density + 0.5f);
+        mMaximumTapVelocity = (int) (MAXIMUM_TAP_VELOCITY * density + 0.5f);
+        mMaximumMinorVelocity = (int) (MAXIMUM_MINOR_VELOCITY * density + 0.5f);
+        mMaximumMajorVelocity = (int) (MAXIMUM_MAJOR_VELOCITY * density + 0.5f);
+        mMaximumAcceleration = (int) (MAXIMUM_ACCELERATION * density + 0.5f);
+        mVelocityUnits = (int) (VELOCITY_UNITS * density + 0.5f);
+
         a.recycle();
 
         setAlwaysDrawnWithCacheEnabled(false);
@@ -383,7 +398,7 @@
                 case MotionEvent.ACTION_UP:
                 case MotionEvent.ACTION_CANCEL: {
                     final VelocityTracker velocityTracker = mVelocityTracker;
-                    velocityTracker.computeCurrentVelocity(VELOCITY_UNITS);
+                    velocityTracker.computeCurrentVelocity(mVelocityUnits);
 
                     float yVelocity = velocityTracker.getYVelocity();
                     float xVelocity = velocityTracker.getXVelocity();
@@ -395,16 +410,16 @@
                         if (xVelocity < 0) {
                             xVelocity = -xVelocity;
                         }
-                        if (xVelocity > MAXIMUM_MINOR_VELOCITY) {
-                            xVelocity = MAXIMUM_MINOR_VELOCITY;
+                        if (xVelocity > mMaximumMinorVelocity) {
+                            xVelocity = mMaximumMinorVelocity;
                         }
                     } else {
                         negative = xVelocity < 0;
                         if (yVelocity < 0) {
                             yVelocity = -yVelocity;
                         }
-                        if (yVelocity > MAXIMUM_MINOR_VELOCITY) {
-                            yVelocity = MAXIMUM_MINOR_VELOCITY;
+                        if (yVelocity > mMaximumMinorVelocity) {
+                            yVelocity = mMaximumMinorVelocity;
                         }
                     }
 
@@ -416,13 +431,13 @@
                     final int top = mHandle.getTop();
                     final int left = mHandle.getLeft();
 
-                    if (Math.abs(velocity) < MAXIMUM_TAP_VELOCITY) {
-                        if (vertical ? (mExpanded && top < TAP_THRESHOLD + mTopOffset) ||
+                    if (Math.abs(velocity) < mMaximumTapVelocity) {
+                        if (vertical ? (mExpanded && top < mTapThreshold + mTopOffset) ||
                                 (!mExpanded && top > mBottomOffset + mBottom - mTop -
-                                        mHandleHeight - TAP_THRESHOLD) :
-                                (mExpanded && left < TAP_THRESHOLD + mTopOffset) ||
+                                        mHandleHeight - mTapThreshold) :
+                                (mExpanded && left < mTapThreshold + mTopOffset) ||
                                 (!mExpanded && left > mBottomOffset + mRight - mLeft -
-                                        mHandleWidth - TAP_THRESHOLD)) {
+                                        mHandleWidth - mTapThreshold)) {
 
                             if (mAllowSingleTap) {
                                 playSoundEffect(SoundEffectConstants.CLICK);
@@ -450,12 +465,12 @@
 
     private void animateClose(int position) {
         prepareTracking(position);
-        performFling(position, 2000.0f, true);
+        performFling(position, mMaximumAcceleration, true);
     }
 
     private void animateOpen(int position) {
         prepareTracking(position);
-        performFling(position, -2000.0f, true);
+        performFling(position, -mMaximumAcceleration, true);
     }
 
     private void performFling(int position, float velocity, boolean always) {
@@ -463,35 +478,35 @@
         mAnimatedVelocity = velocity;
 
         if (mExpanded) {
-            if (always || (velocity > MAXIMUM_MAJOR_VELOCITY ||
+            if (always || (velocity > mMaximumMajorVelocity ||
                     (position > mTopOffset + (mVertical ? mHandleHeight : mHandleWidth) &&
-                            velocity > -MAXIMUM_MAJOR_VELOCITY))) {
+                            velocity > -mMaximumMajorVelocity))) {
                 // We are expanded, but they didn't move sufficiently to cause
                 // us to retract.  Animate back to the expanded position.
-                mAnimatedAcceleration = MAXIMUM_ACCELERATION;
+                mAnimatedAcceleration = mMaximumAcceleration;
                 if (velocity < 0) {
                     mAnimatedVelocity = 0;
                 }
             } else {
                 // We are expanded and are now going to animate away.
-                mAnimatedAcceleration = -MAXIMUM_ACCELERATION;
+                mAnimatedAcceleration = -mMaximumAcceleration;
                 if (velocity > 0) {
                     mAnimatedVelocity = 0;
                 }
             }
         } else {
-            if (!always && (velocity > MAXIMUM_MAJOR_VELOCITY ||
+            if (!always && (velocity > mMaximumMajorVelocity ||
                     (position > (mVertical ? getHeight() : getWidth()) / 2 &&
-                            velocity > -MAXIMUM_MAJOR_VELOCITY))) {
+                            velocity > -mMaximumMajorVelocity))) {
                 // We are collapsed, and they moved enough to allow us to expand.
-                mAnimatedAcceleration = MAXIMUM_ACCELERATION;
+                mAnimatedAcceleration = mMaximumAcceleration;
                 if (velocity < 0) {
                     mAnimatedVelocity = 0;
                 }
             } else {
                 // We are collapsed, but they didn't move sufficiently to cause
                 // us to retract.  Animate back to the collapsed position.
-                mAnimatedAcceleration = -MAXIMUM_ACCELERATION;
+                mAnimatedAcceleration = -mMaximumAcceleration;
                 if (velocity > 0) {
                     mAnimatedVelocity = 0;
                 }
@@ -512,8 +527,8 @@
         mVelocityTracker = VelocityTracker.obtain();
         boolean opening = !mExpanded;
         if (opening) {
-            mAnimatedAcceleration = MAXIMUM_ACCELERATION;
-            mAnimatedVelocity = 200;
+            mAnimatedAcceleration = mMaximumAcceleration;
+            mAnimatedVelocity = mMaximumMajorVelocity;
             mAnimationPosition = mBottomOffset +
                     (mVertical ? getHeight() - mHandleHeight : getWidth() - mHandleWidth);
             moveHandle((int) mAnimationPosition);
@@ -782,6 +797,7 @@
     private void closeDrawer() {
         moveHandle(COLLAPSED_FULL_CLOSED);
         mContent.setVisibility(View.GONE);
+        mContent.destroyDrawingCache();
 
         if (!mExpanded) {
             return;
@@ -796,8 +812,6 @@
     private void openDrawer() {
         moveHandle(EXPANDED_FULL_OPEN);
         mContent.setVisibility(View.VISIBLE);
-        // TODO: Should we uncomment to preserve memory, but increase memory churn?
-        // mContent.destroyDrawingCache();
 
         if (mExpanded) {
             return;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index aa70663..d21c017 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -17,6 +17,7 @@
 package android.widget;
 
 import android.content.Context;
+import android.content.Intent;
 import android.content.res.ColorStateList;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
@@ -42,6 +43,7 @@
 import android.text.ClipboardManager;
 import android.text.InputFilter;
 import android.text.Layout;
+import android.text.ParcelableSpan;
 import android.text.Selection;
 import android.text.SpanWatcher;
 import android.text.Spannable;
@@ -69,7 +71,6 @@
 import android.text.style.ParagraphStyle;
 import android.text.style.URLSpan;
 import android.text.style.UpdateAppearance;
-import android.text.style.UpdateLayout;
 import android.text.util.Linkify;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -168,6 +169,9 @@
  */
 @RemoteView
 public class TextView extends View implements ViewTreeObserver.OnPreDrawListener {
+    static final String TAG = "TextView";
+    static final boolean DEBUG_EXTRACT = false;
+    
     private static int PRIORITY = 100;
 
     private ColorStateList mTextColor;
@@ -178,6 +182,9 @@
     private boolean mFreezesText;
     private boolean mFrozenWithFocus;
 
+    private boolean mEatTouchRelease = false;
+    private boolean mScrolled = false;
+
     private Editable.Factory mEditableFactory = Editable.Factory.getInstance();
     private Spannable.Factory mSpannableFactory = Spannable.Factory.getInstance();
 
@@ -213,6 +220,13 @@
     private CharSequence mError;
     private boolean mErrorWasChanged;
     private PopupWindow mPopup;
+    /**
+     * This flag is set if the TextView tries to display an error before it
+     * is attached to the window (so its position is still unknown).
+     * It causes the error to be shown later, when onAttachedToWindow()
+     * is called.
+     */
+    private boolean mShowErrorAfterAttach;
 
     private CharWrapper mCharWrapper = null;
 
@@ -235,7 +249,10 @@
         float[] mTmpOffset = new float[2];
         ExtractedTextRequest mExtracting;
         final ExtractedText mTmpExtracted = new ExtractedText();
-        boolean mBatchEditing;
+        int mBatchEditNesting;
+        boolean mCursorChanged;
+        boolean mContentChanged;
+        int mChangedStart, mChangedEnd, mChangedDelta;
     }
     InputMethodState mInputMethodState;
 
@@ -2342,9 +2359,10 @@
      * Sets the string value of the TextView. TextView <em>does not</em> accept
      * HTML-like formatting, which you can do with text strings in XML resource files.
      * To style your strings, attach android.text.style.* objects to a
-     * {@link android.text.SpannableString SpannableString}, or see
-     * <a href="{@docRoot}reference/available-resources.html#stringresources">
-     * String Resources</a> for an example of setting formatted text in the XML resource file.
+     * {@link android.text.SpannableString SpannableString}, or see the
+     * <a href="{@docRoot}guide/topics/resources/available-resources.html#stringresources">
+     * Available Resource Types</a> documentation for an example of setting 
+     * formatted text in the XML resource file.
      *
      * @attr ref android.R.styleable#TextView_text
      */
@@ -2698,20 +2716,33 @@
      */
     public void setInputType(int type) {
         setInputType(type, false);
-        if ((type&(EditorInfo.TYPE_MASK_CLASS
+        final boolean isPassword = (type&(EditorInfo.TYPE_MASK_CLASS
                 |EditorInfo.TYPE_MASK_VARIATION))
                 == (EditorInfo.TYPE_CLASS_TEXT
-                        |EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) {
+                        |EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
+        boolean forceUpdate = false;
+        if (isPassword) {
             setTransformationMethod(PasswordTransformationMethod.getInstance());
             setTypefaceByIndex(MONOSPACE, 0);
+        } else if (mTransformation == PasswordTransformationMethod.getInstance()) {
+            // We need to clean up if we were previously in password mode.
+            setTypefaceByIndex(-1, -1);
+            forceUpdate = true;
         }
+        
         boolean multiLine = (type&(EditorInfo.TYPE_MASK_CLASS
                         | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) ==
                 (EditorInfo.TYPE_CLASS_TEXT
                         | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE);
-        if (mSingleLine == multiLine) {
-            setSingleLine(!multiLine);
+        
+        // We need to update the single line mode if it has changed or we
+        // were previously in password mode.
+        if (mSingleLine == multiLine || forceUpdate) {
+            // Change single line mode, but only change the transformation if
+            // we are not in password mode.
+            applySingleLine(!multiLine, !isPassword);
         }
+        
         InputMethodManager imm = InputMethodManager.peekInstance();
         if (imm != null) imm.restartInput(this);
     }
@@ -2814,7 +2845,7 @@
      * given integer is the resource ID of an XML resource holding an
      * {@link android.R.styleable#InputExtras &lt;input-extras&gt;} XML tree.
      *
-     * @see #getInputExtras()
+     * @see #getInputExtras(boolean) 
      * @see EditorInfo#extras
      * @attr ref android.R.styleable#TextView_editorExtras
      */
@@ -2832,7 +2863,7 @@
      *
      * @param create If true, the extras will be created if they don't already
      * exist.  Otherwise, null will be returned if none have been created.
-     * @see #setInputExtras(int)
+     * @see #setInputExtras(int)View
      * @see EditorInfo#extras
      * @attr ref android.R.styleable#TextView_editorExtras
      */
@@ -2916,6 +2947,11 @@
     }
 
     private void showError() {
+        if (getWindowToken() == null) {
+            mShowErrorAfterAttach = true;
+            return;
+        }
+
         if (mPopup == null) {
             LayoutInflater inflater = LayoutInflater.from(getContext());
             TextView err = (TextView) inflater.inflate(com.android.internal.R.layout.textview_hint,
@@ -2979,6 +3015,8 @@
                 mPopup.dismiss();
             }
         }
+
+        mShowErrorAfterAttach = false;
     }
 
     private void chooseSize(PopupWindow pop, CharSequence text, TextView tv) {
@@ -3269,6 +3307,16 @@
     }
 
     @Override
+    protected void onAttachedToWindow() {
+        super.onAttachedToWindow();
+
+        if (mShowErrorAfterAttach) {
+            showError();
+            mShowErrorAfterAttach = false;
+        }
+    }
+
+    @Override
     protected void onDetachedFromWindow() {
         super.onDetachedFromWindow();
 
@@ -3311,6 +3359,16 @@
     }
 
     @Override
+    protected boolean verifyDrawable(Drawable who) {
+        final boolean verified = super.verifyDrawable(who);
+        if (!verified && mDrawables != null) {
+            return who == mDrawables.mDrawableLeft || who == mDrawables.mDrawableTop ||
+                    who == mDrawables.mDrawableRight || who == mDrawables.mDrawableBottom;
+        }
+        return verified;
+    }
+
+    @Override
     protected void onDraw(Canvas canvas) {
         // Draw the background for this view
         super.onDraw(canvas);
@@ -3505,38 +3563,48 @@
         }
         */
 
-        InputMethodManager imm = InputMethodManager.peekInstance();
-        if (highlight != null && mInputMethodState != null
-                && !mInputMethodState.mBatchEditing && imm != null) {
-            if (imm.isActive(this)) {
-                int candStart = -1;
-                int candEnd = -1;
-                if (mText instanceof Spannable) {
-                    Spannable sp = (Spannable)mText;
-                    candStart = EditableInputConnection.getComposingSpanStart(sp);
-                    candEnd = EditableInputConnection.getComposingSpanEnd(sp);
+        final InputMethodState ims = mInputMethodState;
+        if (ims != null && ims.mBatchEditNesting == 0) {
+            InputMethodManager imm = InputMethodManager.peekInstance();
+            if (imm != null) {
+                if (imm.isActive(this)) {
+                    boolean reported = false;
+                    if (ims.mContentChanged) {
+                        // We are in extract mode and the content has changed
+                        // in some way... just report complete new text to the
+                        // input method.
+                        reported = reportExtractedText();
+                    }
+                    if (!reported && highlight != null) {
+                        int candStart = -1;
+                        int candEnd = -1;
+                        if (mText instanceof Spannable) {
+                            Spannable sp = (Spannable)mText;
+                            candStart = EditableInputConnection.getComposingSpanStart(sp);
+                            candEnd = EditableInputConnection.getComposingSpanEnd(sp);
+                        }
+                        imm.updateSelection(this, selStart, selEnd, candStart, candEnd);
+                    }
                 }
-                imm.updateSelection(this, selStart, selEnd, candStart, candEnd);
-            }
-            
-            if (imm.isWatchingCursor(this)) {
-                final InputMethodState ims = mInputMethodState;
-                highlight.computeBounds(ims.mTmpRectF, true);
-                ims.mTmpOffset[0] = ims.mTmpOffset[1] = 0;
-
-                canvas.getMatrix().mapPoints(ims.mTmpOffset);
-                ims.mTmpRectF.offset(ims.mTmpOffset[0], ims.mTmpOffset[1]);
-
-                ims.mTmpRectF.offset(0, voffsetCursor - voffsetText);
-
-                ims.mCursorRectInWindow.set((int)(ims.mTmpRectF.left + 0.5),
-                        (int)(ims.mTmpRectF.top + 0.5),
-                        (int)(ims.mTmpRectF.right + 0.5),
-                        (int)(ims.mTmpRectF.bottom + 0.5));
-
-                imm.updateCursor(this,
-                        ims.mCursorRectInWindow.left, ims.mCursorRectInWindow.top,
-                        ims.mCursorRectInWindow.right, ims.mCursorRectInWindow.bottom);
+                
+                if (imm.isWatchingCursor(this) && highlight != null) {
+                    highlight.computeBounds(ims.mTmpRectF, true);
+                    ims.mTmpOffset[0] = ims.mTmpOffset[1] = 0;
+    
+                    canvas.getMatrix().mapPoints(ims.mTmpOffset);
+                    ims.mTmpRectF.offset(ims.mTmpOffset[0], ims.mTmpOffset[1]);
+    
+                    ims.mTmpRectF.offset(0, voffsetCursor - voffsetText);
+    
+                    ims.mCursorRectInWindow.set((int)(ims.mTmpRectF.left + 0.5),
+                            (int)(ims.mTmpRectF.top + 0.5),
+                            (int)(ims.mTmpRectF.right + 0.5),
+                            (int)(ims.mTmpRectF.bottom + 0.5));
+    
+                    imm.updateCursor(this,
+                            ims.mCursorRectInWindow.left, ims.mCursorRectInWindow.top,
+                            ims.mCursorRectInWindow.right, ims.mCursorRectInWindow.bottom);
+                }
             }
         }
 
@@ -3634,7 +3702,7 @@
 
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
-        int which = doKeyDown(keyCode, event);
+        int which = doKeyDown(keyCode, event, null);
         if (which == 0) {
             // Go through default dispatching.
             return super.onKeyDown(keyCode, event);
@@ -3647,12 +3715,18 @@
     public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
         KeyEvent down = new KeyEvent(event, KeyEvent.ACTION_DOWN);
 
-        int which = doKeyDown(keyCode, down);
+        int which = doKeyDown(keyCode, down, event);
         if (which == 0) {
             // Go through default dispatching.
             return super.onKeyMultiple(keyCode, repeatCount, event);
         }
+        if (which == -1) {
+            // Consumed the whole thing.
+            return true;
+        }
 
+        repeatCount--;
+        
         // We are going to dispatch the remaining events to either the input
         // or movement method.  To do this, we will just send a repeated stream
         // of down and up events until we have done the complete repeatCount.
@@ -3680,7 +3754,34 @@
         return true;
     }
 
-    private int doKeyDown(int keyCode, KeyEvent event) {
+    /**
+     * Returns true if pressing ENTER in this field advances focus instead
+     * of inserting the character.  This is true mostly in single-line fields,
+     * but also in mail addresses and subjects which will display on multiple
+     * lines but where it doesn't make sense to insert newlines.
+     */
+    private boolean advanceFocusOnEnter() {
+        if (mInput == null) {
+            return false;
+        }
+
+        if (mSingleLine) {
+            return true;
+        }
+
+        if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
+            int variation = mInputType & EditorInfo.TYPE_MASK_VARIATION;
+
+            if (variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS ||
+                variation == EditorInfo.TYPE_TEXT_VARIATION_EMAIL_SUBJECT) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private int doKeyDown(int keyCode, KeyEvent event, KeyEvent otherEvent) {
         if (!isEnabled()) {
             return 0;
         }
@@ -3688,7 +3789,7 @@
         switch (keyCode) {
             case KeyEvent.KEYCODE_DPAD_CENTER:
             case KeyEvent.KEYCODE_ENTER:
-                if (mSingleLine && mInput != null) {
+                if (advanceFocusOnEnter()) {
                     return 0;
                 }
         }
@@ -3702,20 +3803,63 @@
              */
             mErrorWasChanged = false;
 
-            if (mInput.onKeyDown(this, (Editable) mText, keyCode, event)) {
-                if (mError != null && !mErrorWasChanged) {
-                    setError(null, null);
+            boolean doDown = true;
+            if (otherEvent != null) {
+                try {
+                    beginBatchEdit();
+                    boolean handled = mInput.onKeyOther(this, (Editable) mText,
+                            otherEvent);
+                    if (mError != null && !mErrorWasChanged) {
+                        setError(null, null);
+                    }
+                    doDown = false;
+                    if (handled) {
+                        return -1;
+                    }
+                } catch (AbstractMethodError e) {
+                    // onKeyOther was added after 1.0, so if it isn't
+                    // implemented we need to try to dispatch as a regular down.
+                } finally {
+                    endBatchEdit();
                 }
-                return 1;
+            }
+            
+            if (doDown) {
+                beginBatchEdit();
+                if (mInput.onKeyDown(this, (Editable) mText, keyCode, event)) {
+                    endBatchEdit();
+                    if (mError != null && !mErrorWasChanged) {
+                        setError(null, null);
+                    }
+                    return 1;
+                }
+                endBatchEdit();
             }
         }
 
         // bug 650865: sometimes we get a key event before a layout.
         // don't try to move around if we don't know the layout.
 
-        if (mMovement != null && mLayout != null)
-            if (mMovement.onKeyDown(this, (Spannable)mText, keyCode, event))
-                return 2;
+        if (mMovement != null && mLayout != null) {
+            boolean doDown = true;
+            if (otherEvent != null) {
+                try {
+                    boolean handled = mMovement.onKeyOther(this, (Editable) mText,
+                            otherEvent);
+                    doDown = false;
+                    if (handled) {
+                        return -1;
+                    }
+                } catch (AbstractMethodError e) {
+                    // onKeyOther was added after 1.0, so if it isn't
+                    // implemented we need to try to dispatch as a regular down.
+                }
+            }
+            if (doDown) {
+                if (mMovement.onKeyDown(this, (Spannable)mText, keyCode, event))
+                    return 2;
+            }
+        }
 
         return 0;
     }
@@ -3728,8 +3872,27 @@
 
         switch (keyCode) {
             case KeyEvent.KEYCODE_DPAD_CENTER:
+                /*
+                 * If there is a click listener, just call through to
+                 * super, which will invoke it.
+                 *
+                 * If there isn't a click listener, try to show the soft
+                 * input method.  (It will also
+                 * call performClick(), but that won't do anything in
+                 * this case.)
+                 */
+                if (mOnClickListener == null) {
+                    if (mMovement != null && mText instanceof Editable
+                            && mLayout != null && onCheckIsTextEditor()) {
+                        InputMethodManager imm = (InputMethodManager)
+                                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+                        imm.showSoftInput(this, 0);
+                    }
+                }
+                return super.onKeyUp(keyCode, event);
+                
             case KeyEvent.KEYCODE_ENTER:
-                if (mSingleLine && mInput != null) {
+                if (advanceFocusOnEnter()) {
                     /*
                      * If there is a click listener, just call through to
                      * super, which will invoke it.
@@ -3803,14 +3966,56 @@
     /**
      * If this TextView contains editable content, extract a portion of it
      * based on the information in <var>request</var> in to <var>outText</var>.
-     * @return Returns true if the text is editable and was successfully
-     * extracted, else false.
+     * @return Returns true if the text was successfully extracted, else false.
      */
     public boolean extractText(ExtractedTextRequest request,
             ExtractedText outText) {
-        Editable content = getEditableText();
+        return extractTextInternal(request, -1, -1, -1, outText);
+    }
+    
+    boolean extractTextInternal(ExtractedTextRequest request,
+            int partialStartOffset, int partialEndOffset, int delta,
+            ExtractedText outText) {
+        final CharSequence content = mText;
         if (content != null) {
-            outText.text = content.subSequence(0, content.length());
+            final int N = content.length();
+            if (partialStartOffset < 0) {
+                outText.partialStartOffset = outText.partialEndOffset = -1;
+                partialStartOffset = 0;
+                partialEndOffset = N;
+            } else {
+                // Adjust offsets to ensure we contain full spans.
+                if (content instanceof Spanned) {
+                    Spanned spanned = (Spanned)content;
+                    Object[] spans = spanned.getSpans(partialStartOffset,
+                            partialEndOffset, ParcelableSpan.class);
+                    int i = spans.length;
+                    while (i > 0) {
+                        i--;
+                        int j = spanned.getSpanStart(spans[i]);
+                        if (j < partialStartOffset) partialStartOffset = j;
+                        j = spanned.getSpanEnd(spans[i]);
+                        if (j > partialEndOffset) partialEndOffset = j;
+                    }
+                }
+                outText.partialStartOffset = partialStartOffset;
+                outText.partialEndOffset = partialEndOffset;
+                // Now use the delta to determine the actual amount of text
+                // we need.
+                partialEndOffset += delta;
+                if (partialEndOffset > N) {
+                    partialEndOffset = N;
+                } else if (partialEndOffset < 0) {
+                    partialEndOffset = 0;
+                }
+            }
+            if ((request.flags&InputConnection.GET_TEXT_WITH_STYLES) != 0) {
+                outText.text = content.subSequence(partialStartOffset,
+                        partialEndOffset);
+            } else {
+                outText.text = TextUtils.substring(content, partialStartOffset,
+                        partialEndOffset);
+            }
             outText.startOffset = 0;
             outText.selectionStart = Selection.getSelectionStart(content);
             outText.selectionEnd = Selection.getSelectionEnd(content);
@@ -3819,19 +4024,45 @@
         return false;
     }
     
-    void reportExtractedText() {
-        if (mInputMethodState != null) {
+    boolean reportExtractedText() {
+        final InputMethodState ims = mInputMethodState;
+        if (ims != null && ims.mContentChanged) {
+            ims.mContentChanged = false;
             final ExtractedTextRequest req = mInputMethodState.mExtracting;
             if (req != null) {
                 InputMethodManager imm = InputMethodManager.peekInstance();
                 if (imm != null) {
-                    if (extractText(req, mInputMethodState.mTmpExtracted)) {
+                    if (DEBUG_EXTRACT) Log.v(TAG, "Retrieving extracted start="
+                            + ims.mChangedStart + " end=" + ims.mChangedEnd
+                            + " delta=" + ims.mChangedDelta);
+                    if (extractTextInternal(req, ims.mChangedStart, ims.mChangedEnd,
+                            ims.mChangedDelta, ims.mTmpExtracted)) {
+                        if (DEBUG_EXTRACT) Log.v(TAG, "Reporting extracted start="
+                                + ims.mTmpExtracted.partialStartOffset
+                                + " end=" + ims.mTmpExtracted.partialEndOffset
+                                + ": " + ims.mTmpExtracted.text);
                         imm.updateExtractedText(this, req.token,
                                 mInputMethodState.mTmpExtracted);
+                        return true;
                     }
                 }
             }
         }
+        return false;
+    }
+    
+    /**
+     * This is used to remove all style-impacting spans from text before new
+     * extracted text is being replaced into it, so that we don't have any
+     * lingering spans applied during the replace.
+     */
+    static void removeParcelableSpans(Spannable spannable, int start, int end) {
+        Object[] spans = spannable.getSpans(start, end, ParcelableSpan.class);
+        int i = spans.length;
+        while (i > 0) {
+            i--;
+            spannable.removeSpan(spans[i]);
+        }
     }
     
     /**
@@ -3839,7 +4070,21 @@
      * returned by {@link #extractText(ExtractedTextRequest, ExtractedText)}.
      */
     public void setExtractedText(ExtractedText text) {
-        setText(text.text, TextView.BufferType.EDITABLE);
+        Editable content = getEditableText();
+        if (content == null) {
+            setText(text.text, TextView.BufferType.EDITABLE);
+        } else if (text.partialStartOffset < 0) {
+            removeParcelableSpans(content, 0, content.length());
+            content.replace(0, content.length(), text.text);
+        } else {
+            final int N = content.length();
+            int start = text.partialStartOffset;
+            if (start > N) start = N;
+            int end = text.partialEndOffset;
+            if (end > N) end = N;
+            removeParcelableSpans(content, start, end);
+            content.replace(start, end, text.text);
+        }
         Selection.setSelection((Spannable)getText(),
                 text.selectionStart, text.selectionEnd);
     }
@@ -3866,36 +4111,91 @@
     public void onCommitCompletion(CompletionInfo text) {
     }
 
+    public void beginBatchEdit() {
+        final InputMethodState ims = mInputMethodState;
+        if (ims != null) {
+            int nesting = ++ims.mBatchEditNesting;
+            if (nesting == 1) {
+                ims.mCursorChanged = false;
+                ims.mChangedDelta = 0;
+                if (ims.mContentChanged) {
+                    // We already have a pending change from somewhere else,
+                    // so turn this into a full update.
+                    ims.mChangedStart = 0;
+                    ims.mChangedEnd = mText.length();
+                } else {
+                    ims.mChangedStart = -1;
+                    ims.mChangedEnd = -1;
+                    ims.mContentChanged = false;
+                }
+                onBeginBatchEdit();
+            }
+        }
+    }
+    
+    public void endBatchEdit() {
+        final InputMethodState ims = mInputMethodState;
+        if (ims != null) {
+            int nesting = --ims.mBatchEditNesting;
+            if (nesting == 0) {
+                finishBatchEdit(ims);
+            }
+        }
+    }
+    
+    void ensureEndedBatchEdit() {
+        final InputMethodState ims = mInputMethodState;
+        if (ims != null && ims.mBatchEditNesting != 0) {
+            ims.mBatchEditNesting = 0;
+            finishBatchEdit(ims);
+        }
+    }
+    
+    void finishBatchEdit(final InputMethodState ims) {
+        onEndBatchEdit();
+        
+        if (ims.mContentChanged) {
+            updateAfterEdit();
+            reportExtractedText();
+        } else if (ims.mCursorChanged) {
+            // Cheezy way to get us to report the current cursor location.
+            invalidateCursor();
+        }
+    }
+    
+    void updateAfterEdit() {
+        invalidate();
+        int curs = Selection.getSelectionStart(mText);
+
+        if (curs >= 0 || (mGravity & Gravity.VERTICAL_GRAVITY_MASK) ==
+                             Gravity.BOTTOM) {
+            registerForPreDraw();
+        }
+
+        if (curs >= 0) {
+            mHighlightPathBogus = true;
+
+            if (isFocused()) {
+                mShowCursor = SystemClock.uptimeMillis();
+                makeBlink();
+            }
+        }
+        
+        checkForResize();
+    }
+    
     /**
      * Called by the framework in response to a request to begin a batch
-     * of edit operations from the current input method, as a result of
-     * it calling {@link InputConnection#beginBatchEdit
-     * InputConnection.beginBatchEdit()}.  The default implementation sets
-     * up the TextView's internal state to take care of this; if overriding
-     * you should call through to the super class.
+     * of edit operations through a call to link {@link #beginBatchEdit()}.
      */
     public void onBeginBatchEdit() {
-        if (mInputMethodState != null) {
-            // XXX we should be smarter here, such as not doing invalidates
-            // until all edits are done.
-            mInputMethodState.mBatchEditing = true;
-        }
     }
     
     /**
      * Called by the framework in response to a request to end a batch
-     * of edit operations from the current input method, as a result of
-     * it calling {@link InputConnection#endBatchEdit
-     * InputConnection.endBatchEdit()}.  The default implementation sets
-     * up the TextView's internal state to take care of this; if overriding
-     * you should call through to the super class.
+     * of edit operations through a call to link {@link #endBatchEdit}.
      */
     public void onEndBatchEdit() {
-        if (mInputMethodState != null) {
-            mInputMethodState.mBatchEditing = false;
-            // Cheezy way to get us to report the current cursor location.
-            invalidateCursor();
-        }
     }
     
     /**
@@ -4542,9 +4842,10 @@
     }
 
     /**
-     * Returns true if anything changed.
+     * Move the point, specified by the offset, into the view if it is needed.
+     * This has to be called after layout. Returns true if anything changed.
      */
-    private boolean bringPointIntoView(int offset) {
+    public boolean bringPointIntoView(int offset) {
         boolean changed = false;
 
         int line = mLayout.getLineForOffset(offset);
@@ -4794,7 +5095,6 @@
      * @attr ref android.R.styleable#TextView_singleLine
      */
     public void setSingleLine(boolean singleLine) {
-        mSingleLine = singleLine;
         if ((mInputType&EditorInfo.TYPE_MASK_CLASS)
                 == EditorInfo.TYPE_CLASS_TEXT) {
             if (singleLine) {
@@ -4803,19 +5103,27 @@
                 mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
             }
         }
+        applySingleLine(singleLine, true);
+    }
 
+    private void applySingleLine(boolean singleLine, boolean applyTransformation) {
+        mSingleLine = singleLine;
         if (singleLine) {
             setLines(1);
             setHorizontallyScrolling(true);
-            setTransformationMethod(SingleLineTransformationMethod.
-                                    getInstance());
+            if (applyTransformation) {
+                setTransformationMethod(SingleLineTransformationMethod.
+                                        getInstance());
+            }
         } else {
             setMaxLines(Integer.MAX_VALUE);
             setHorizontallyScrolling(false);
-            setTransformationMethod(null);
+            if (applyTransformation) {
+                setTransformationMethod(null);
+            }
         }
     }
-
+    
     /**
      * Causes words in the text that are longer than the view is wide
      * to be ellipsized instead of broken in the middle.  You may also
@@ -4938,6 +5246,8 @@
         float mScroll;
 
         Marquee(TextView v) {
+            final float density = v.getContext().getResources().getDisplayMetrics().density;
+            mScrollUnit = (MARQUEE_PIXELS_PER_SECOND * density) / (float) MARQUEE_RESOLUTION;
             mView = new WeakReference<TextView>(v);
         }
 
@@ -5006,7 +5316,6 @@
             if (textView != null && textView.mLayout != null) {
                 mStatus = MARQUEE_STARTING;
                 mScroll = 0.0f;
-                mScrollUnit = MARQUEE_PIXELS_PER_SECOND / (float) MARQUEE_RESOLUTION;
                 mMaxScroll = textView.mLayout.getLineWidth(0) - (textView.getWidth() -
                         textView.getCompoundPaddingLeft() - textView.getCompoundPaddingRight());
                 textView.invalidate();
@@ -5046,6 +5355,16 @@
     }
 
     /**
+     * This method is called when the selection has changed, in case any
+     * subclasses would like to know.
+     * 
+     * @param selStart The new selection start location.
+     * @param selEnd The new selection end location.
+     */
+    protected void onSelectionChanged(int selStart, int selEnd) {
+    }
+    
+    /**
      * Adds a TextWatcher to the list of those whose methods are called
      * whenever this TextView's text changes.
      * <p>
@@ -5123,26 +5442,22 @@
      */
     void handleTextChanged(CharSequence buffer, int start,
             int before, int after) {
-        invalidate();
-
-        int curs = Selection.getSelectionStart(buffer);
-
-        if (curs >= 0 || (mGravity & Gravity.VERTICAL_GRAVITY_MASK) ==
-                             Gravity.BOTTOM) {
-            registerForPreDraw();
+        final InputMethodState ims = mInputMethodState;
+        if (ims == null || ims.mBatchEditNesting == 0) {
+            updateAfterEdit();
         }
-
-        if (curs >= 0) {
-            mHighlightPathBogus = true;
-
-            if (isFocused()) {
-                mShowCursor = SystemClock.uptimeMillis();
-                makeBlink();
+        if (ims != null) {
+            ims.mContentChanged = true;
+            if (ims.mChangedStart < 0) {
+                ims.mChangedStart = start;
+                ims.mChangedEnd = start+before;
+            } else {
+                if (ims.mChangedStart > start) ims.mChangedStart = start;
+                if (ims.mChangedEnd < (start+before)) ims.mChangedEnd = start+before;
             }
+            ims.mChangedDelta += after-before;
         }
-
-        checkForResize();
-
+        
         sendOnTextChanged(buffer, start, before, after);
         onTextChanged(buffer, start, before, after);
     }
@@ -5151,19 +5466,27 @@
      * Not private so it can be called from an inner class without going
      * through a thunk.
      */
-    void spanChange(Spanned buf, Object what, int o, int n) {
+    void spanChange(Spanned buf, Object what, int oldStart, int newStart,
+            int oldEnd, int newEnd) {
         // XXX Make the start and end move together if this ends up
         // spending too much time invalidating.
 
+        boolean selChanged = false;
+        int newSelStart=-1, newSelEnd=-1;
+        
+        final InputMethodState ims = mInputMethodState;
+        
         if (what == Selection.SELECTION_END) {
             mHighlightPathBogus = true;
+            selChanged = true;
+            newSelEnd = newStart;
 
             if (!isFocused()) {
                 mSelectionMoved = true;
             }
 
-            if (o >= 0 || n >= 0) {
-                invalidateCursor(Selection.getSelectionStart(buf), o, n);
+            if (oldStart >= 0 || newStart >= 0) {
+                invalidateCursor(Selection.getSelectionStart(buf), oldStart, newStart);
                 registerForPreDraw();
 
                 if (isFocused()) {
@@ -5175,28 +5498,81 @@
 
         if (what == Selection.SELECTION_START) {
             mHighlightPathBogus = true;
+            selChanged = true;
+            newSelStart = newStart;
 
             if (!isFocused()) {
                 mSelectionMoved = true;
             }
 
-            if (o >= 0 || n >= 0) {
-                invalidateCursor(Selection.getSelectionEnd(buf), o, n);
+            if (oldStart >= 0 || newStart >= 0) {
+                int end = Selection.getSelectionEnd(buf);
+                invalidateCursor(end, oldStart, newStart);
             }
         }
 
+        if (selChanged) {
+            if ((buf.getSpanFlags(what)&Spanned.SPAN_INTERMEDIATE) == 0) {
+                if (newSelStart < 0) {
+                    newSelStart = Selection.getSelectionStart(buf);
+                }
+                if (newSelEnd < 0) {
+                    newSelEnd = Selection.getSelectionEnd(buf);
+                }
+                onSelectionChanged(newSelStart, newSelEnd);
+            }
+        }
+        
         if (what instanceof UpdateAppearance ||
             what instanceof ParagraphStyle) {
-            invalidate();
-            mHighlightPathBogus = true;
-            checkForResize();
+            if (ims == null || ims.mBatchEditNesting == 0) {
+                invalidate();
+                mHighlightPathBogus = true;
+                checkForResize();
+            } else {
+                ims.mContentChanged = true;
+            }
         }
 
         if (MetaKeyKeyListener.isMetaTracker(buf, what)) {
             mHighlightPathBogus = true;
 
             if (Selection.getSelectionStart(buf) >= 0) {
-                invalidateCursor();
+                if (ims == null || ims.mBatchEditNesting == 0) {
+                    invalidateCursor();
+                } else {
+                    ims.mCursorChanged = true;
+                }
+            }
+        }
+        
+        if (what instanceof ParcelableSpan) {
+            // If this is a span that can be sent to a remote process,
+            // the current extract editor would be interested in it.
+            if (ims != null && ims.mExtracting != null) {
+                if (ims.mBatchEditNesting != 0) {
+                    if (oldStart >= 0) {
+                        if (ims.mChangedStart > oldStart) {
+                            ims.mChangedStart = oldStart;
+                        }
+                        if (ims.mChangedStart > oldEnd) {
+                            ims.mChangedStart = oldEnd;
+                        }
+                    }
+                    if (newStart >= 0) {
+                        if (ims.mChangedStart > newStart) {
+                            ims.mChangedStart = newStart;
+                        }
+                        if (ims.mChangedStart > newEnd) {
+                            ims.mChangedStart = newEnd;
+                        }
+                    }
+                } else {
+                    if (DEBUG_EXTRACT) Log.v(TAG, "Span change outside of batch: "
+                            + oldStart + "-" + oldEnd + ","
+                            + newStart + "-" + newEnd + what);
+                    ims.mContentChanged = true;
+                }
             }
         }
     }
@@ -5205,36 +5581,45 @@
     implements TextWatcher, SpanWatcher {
         public void beforeTextChanged(CharSequence buffer, int start,
                                       int before, int after) {
+            if (DEBUG_EXTRACT) Log.v(TAG, "beforeTextChanged start=" + start
+                    + " before=" + before + " after=" + after + ": " + buffer);
             TextView.this.sendBeforeTextChanged(buffer, start, before, after);
         }
 
         public void onTextChanged(CharSequence buffer, int start,
                                   int before, int after) {
+            if (DEBUG_EXTRACT) Log.v(TAG, "onTextChanged start=" + start
+                    + " before=" + before + " after=" + after + ": " + buffer);
             TextView.this.handleTextChanged(buffer, start, before, after);
         }
 
         public void afterTextChanged(Editable buffer) {
+            if (DEBUG_EXTRACT) Log.v(TAG, "afterTextChanged: " + buffer);
             TextView.this.sendAfterTextChanged(buffer);
 
             if (MetaKeyKeyListener.getMetaState(buffer,
                                  MetaKeyKeyListener.META_SELECTING) != 0) {
                 MetaKeyKeyListener.stopSelecting(TextView.this, buffer);
             }
-
-            TextView.this.reportExtractedText();
         }
 
         public void onSpanChanged(Spannable buf,
                                   Object what, int s, int e, int st, int en) {
-            TextView.this.spanChange(buf, what, s, st);
+            if (DEBUG_EXTRACT) Log.v(TAG, "onSpanChanged s=" + s + " e=" + e
+                    + " st=" + st + " en=" + en + " what=" + what + ": " + buf);
+            TextView.this.spanChange(buf, what, s, st, e, en);
         }
 
         public void onSpanAdded(Spannable buf, Object what, int s, int e) {
-            TextView.this.spanChange(buf, what, -1, s);
+            if (DEBUG_EXTRACT) Log.v(TAG, "onSpanAdded s=" + s + " e=" + e
+                    + " what=" + what + ": " + buf);
+            TextView.this.spanChange(buf, what, -1, s, -1, e);
         }
 
         public void onSpanRemoved(Spannable buf, Object what, int s, int e) {
-            TextView.this.spanChange(buf, what, s, -1);
+            if (DEBUG_EXTRACT) Log.v(TAG, "onSpanRemoved s=" + s + " e=" + e
+                    + " what=" + what + ": " + buf);
+            TextView.this.spanChange(buf, what, s, -1, e, -1);
         }
     }
 
@@ -5258,6 +5643,8 @@
     protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
         mShowCursor = SystemClock.uptimeMillis();
 
+        ensureEndedBatchEdit();
+        
         if (focused) {
             int selStart = getSelectionStart();
             int selEnd = getSelectionEnd();
@@ -5362,22 +5749,28 @@
     public boolean onTouchEvent(MotionEvent event) {
         final boolean superResult = super.onTouchEvent(event);
 
+        final int action = event.getAction();
+        
         /*
          * Don't handle the release after a long press, because it will
          * move the selection away from whatever the menu action was
          * trying to affect.
          */
-        if (mEatTouchRelease && event.getAction() == MotionEvent.ACTION_UP) {
+        if (mEatTouchRelease && action == MotionEvent.ACTION_UP) {
             mEatTouchRelease = false;
             return superResult;
         }
 
-        if (mMovement != null && mText instanceof Spannable &&
-            mLayout != null) {
+        if (mMovement != null && mText instanceof Spannable && mLayout != null) {
+            
+            if (action == MotionEvent.ACTION_DOWN) {
+                mScrolled = false;
+            }
+            
             boolean moved = mMovement.onTouchEvent(this, (Spannable) mText, event);
 
             if (mText instanceof Editable && onCheckIsTextEditor()) {
-                if (event.getAction() == MotionEvent.ACTION_UP && isFocused()) {
+                if (action == MotionEvent.ACTION_UP && isFocused() && !mScrolled) {
                     InputMethodManager imm = (InputMethodManager)
                             getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                     imm.showSoftInput(this, 0);
@@ -5393,6 +5786,12 @@
     }
 
     @Override
+    public void cancelLongPress() {
+        super.cancelLongPress();
+        mScrolled = true;
+    }
+    
+    @Override
     public boolean onTrackballEvent(MotionEvent event) {
         if (mMovement != null && mText instanceof Spannable &&
             mLayout != null) {
@@ -5568,28 +5967,28 @@
         switch (keyCode) {
         case KeyEvent.KEYCODE_A:
             if (canSelectAll()) {
-                return onMenu(ID_SELECT_ALL);
+                return onTextContextMenuItem(ID_SELECT_ALL);
             }
 
             break;
 
         case KeyEvent.KEYCODE_X:
             if (canCut()) {
-                return onMenu(ID_CUT);
+                return onTextContextMenuItem(ID_CUT);
             }
 
             break;
 
         case KeyEvent.KEYCODE_C:
             if (canCopy()) {
-                return onMenu(ID_COPY);
+                return onTextContextMenuItem(ID_COPY);
             }
 
             break;
 
         case KeyEvent.KEYCODE_V:
             if (canPaste()) {
-                return onMenu(ID_PASTE);
+                return onTextContextMenuItem(ID_PASTE);
             }
 
             break;
@@ -5655,6 +6054,38 @@
         return false;
     }
 
+    /**
+     * Returns a word to add to the dictionary from the context menu,
+     * or null if there is no cursor or no word at the cursor.
+     */
+    private String getWordForDictionary() {
+        int end = getSelectionEnd();
+
+        if (end < 0) {
+            return null;
+        }
+
+        int start = end;
+        char c;
+        int len = mText.length();
+
+        while (start > 0 && (((c = mTransformed.charAt(start - 1)) == '\'') ||
+                             (Character.isLetterOrDigit(c)))) {
+            start--;
+        }
+
+        while (end < len && (((c = mTransformed.charAt(end)) == '\'') ||
+                             (Character.isLetterOrDigit(c)))) {
+            end++;
+        }
+
+        if (start == end) {
+            return null;
+        }
+
+        return TextUtils.substring(mTransformed, start, end);
+    }
+
     @Override
     protected void onCreateContextMenu(ContextMenu menu) {
         super.onCreateContextMenu(menu);
@@ -5696,7 +6127,7 @@
                     setOnMenuItemClickListener(handler);
                 added = true;
             } else {
-                menu.add(0, ID_SELECT_TEXT, 0,
+                menu.add(0, ID_START_SELECTING_TEXT, 0,
                         com.android.internal.R.string.selectText).
                     setOnMenuItemClickListener(handler);
                 added = true;
@@ -5755,34 +6186,60 @@
             }
         }
 
-        InputMethodManager imm = InputMethodManager.peekInstance();
-        if (imm != null && imm.isActive(this)) {
-            menu.add(1, ID_SWITCH_IME, 0, com.android.internal.R.string.inputMethod).
+        if (isInputMethodTarget()) {
+            menu.add(1, ID_SWITCH_INPUT_METHOD, 0, com.android.internal.R.string.inputMethod).
                     setOnMenuItemClickListener(handler);
             added = true;
         }
 
+        String word = getWordForDictionary();
+        if (word != null) {
+            menu.add(1, ID_ADD_TO_DICTIONARY, 0,
+                     getContext().getString(com.android.internal.R.string.addToDictionary, word)).
+                    setOnMenuItemClickListener(handler);
+            added = true;
+
+        }
+
         if (added) {
             menu.setHeaderTitle(com.android.internal.R.string.editTextMenuTitle);
         }
     }
 
-    private static final int ID_SELECT_ALL = com.android.internal.R.id.selectAll;
-    private static final int ID_SELECT_TEXT = com.android.internal.R.id.selectText;
-    private static final int ID_STOP_SELECTING_TEXT = com.android.internal.R.id.stopSelectingText;
-    private static final int ID_CUT = com.android.internal.R.id.cut;
-    private static final int ID_COPY = com.android.internal.R.id.copy;
-    private static final int ID_PASTE = com.android.internal.R.id.paste;
-    private static final int ID_COPY_URL = com.android.internal.R.id.copyUrl;
-    private static final int ID_SWITCH_IME = com.android.internal.R.id.inputMethod;
+    /**
+     * Returns whether this text view is a current input method target.  The
+     * default implementation just checks with {@link InputMethodManager}.
+     */
+    public boolean isInputMethodTarget() {
+        InputMethodManager imm = InputMethodManager.peekInstance();
+        return imm != null && imm.isActive(this);
+    }
+    
+    private static final int ID_SELECT_ALL = android.R.id.selectAll;
+    private static final int ID_START_SELECTING_TEXT = android.R.id.startSelectingText;
+    private static final int ID_STOP_SELECTING_TEXT = android.R.id.stopSelectingText;
+    private static final int ID_CUT = android.R.id.cut;
+    private static final int ID_COPY = android.R.id.copy;
+    private static final int ID_PASTE = android.R.id.paste;
+    private static final int ID_COPY_URL = android.R.id.copyUrl;
+    private static final int ID_SWITCH_INPUT_METHOD = android.R.id.switchInputMethod;
+    private static final int ID_ADD_TO_DICTIONARY = android.R.id.addToDictionary;
 
     private class MenuHandler implements MenuItem.OnMenuItemClickListener {
         public boolean onMenuItemClick(MenuItem item) {
-            return onMenu(item.getItemId());
+            return onTextContextMenuItem(item.getItemId());
         }
     }
 
-    private boolean onMenu(int id) {
+    /**
+     * Called when a context menu option for the text view is selected.  Currently
+     * this will be one of: {@link android.R.id#selectAll},
+     * {@link android.R.id#startSelectingText}, {@link android.R.id#stopSelectingText},
+     * {@link android.R.id#cut}, {@link android.R.id#copy},
+     * {@link android.R.id#paste}, {@link android.R.id#copyUrl},
+     * or {@link android.R.id#switchInputMethod}.
+     */
+    public boolean onTextContextMenuItem(int id) {
         int selStart = getSelectionStart();
         int selEnd = getSelectionEnd();
 
@@ -5807,10 +6264,10 @@
         switch (id) {
             case ID_SELECT_ALL:
                 Selection.setSelection((Spannable) mText, 0,
-                                        mText.length());
+                        mText.length());
                 return true;
 
-            case ID_SELECT_TEXT:
+            case ID_START_SELECTING_TEXT:
                 MetaKeyKeyListener.startSelecting(this, (Spannable) mText);
                 return true;
 
@@ -5865,12 +6322,23 @@
 
                 return true;
 
-            case ID_SWITCH_IME:
+            case ID_SWITCH_INPUT_METHOD:
                 InputMethodManager imm = InputMethodManager.peekInstance();
                 if (imm != null) {
                     imm.showInputMethodPicker();
                 }
                 return true;
+
+            case ID_ADD_TO_DICTIONARY:
+                String word = getWordForDictionary();
+
+                if (word != null) {
+                    Intent i = new Intent("com.android.settings.USER_DICTIONARY_INSERT");
+                    i.putExtra("word", word);
+                    getContext().startActivity(i);
+                }
+
+                return true;
             }
 
         return false;
@@ -5885,8 +6353,6 @@
         return false;
     }
 
-    private boolean mEatTouchRelease = false;
-
     @ViewDebug.ExportedProperty
     private CharSequence            mText;
     private CharSequence            mTransformed;
diff --git a/core/java/android/widget/ViewAnimator.java b/core/java/android/widget/ViewAnimator.java
index acc9c46..8c652e5 100644
--- a/core/java/android/widget/ViewAnimator.java
+++ b/core/java/android/widget/ViewAnimator.java
@@ -144,6 +144,56 @@
         }
     }
 
+    @Override
+    public void removeAllViews() {
+        super.removeAllViews();
+        mWhichChild = 0;
+        mFirstTime = true;
+    }
+
+    @Override
+    public void removeView(View view) {
+        final int index = indexOfChild(view);
+        if (index >= 0) {
+            removeViewAt(index);
+        }
+    }
+
+    @Override
+    public void removeViewAt(int index) {
+        super.removeViewAt(index);
+        final int childCount = getChildCount();
+        if (childCount == 0) {
+            mWhichChild = 0;
+            mFirstTime = true;
+        } else if (mWhichChild >= childCount) {
+            // Displayed is above child count, so float down to top of stack
+            setDisplayedChild(childCount - 1);
+        } else if (mWhichChild == index) {
+            // Displayed was removed, so show the new child living in its place
+            setDisplayedChild(mWhichChild);
+        }
+    }
+
+    public void removeViewInLayout(View view) {
+        removeView(view);
+    }
+
+    public void removeViews(int start, int count) {
+        super.removeViews(start, count);
+        if (getChildCount() == 0) {
+            mWhichChild = 0;
+            mFirstTime = true;
+        } else if (mWhichChild >= start && mWhichChild < start + count) {
+            // Try showing new displayed child, wrapping if needed
+            setDisplayedChild(mWhichChild);
+        }
+    }
+
+    public void removeViewsInLayout(int start, int count) {
+        removeViews(start, count);
+    }
+
     /**
      * Returns the View corresponding to the currently displayed child.
      *
diff --git a/core/java/android/widget/ZoomButton.java b/core/java/android/widget/ZoomButton.java
index 5df8c8a..df3f307 100644
--- a/core/java/android/widget/ZoomButton.java
+++ b/core/java/android/widget/ZoomButton.java
@@ -54,7 +54,7 @@
     public ZoomButton(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         mHandler = new Handler();
-        mGestureDetector = new GestureDetector(new SimpleOnGestureListener() {
+        mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
             @Override
             public void onLongPress(MotionEvent e) {
                 onLongClick(ZoomButton.this);
diff --git a/core/java/android/widget/ZoomControls.java b/core/java/android/widget/ZoomControls.java
index 1fd662c..fdc05b6 100644
--- a/core/java/android/widget/ZoomControls.java
+++ b/core/java/android/widget/ZoomControls.java
@@ -81,7 +81,9 @@
     }
     
     public void show() {
-        fade(View.VISIBLE, 0.0f, 1.0f);
+        if (ZoomRingController.useOldZoom(mContext)) {
+            fade(View.VISIBLE, 0.0f, 1.0f);
+        }
     }
     
     public void hide() {
diff --git a/core/java/android/widget/ZoomRing.java b/core/java/android/widget/ZoomRing.java
new file mode 100644
index 0000000..20d6056
--- /dev/null
+++ b/core/java/android/widget/ZoomRing.java
@@ -0,0 +1,423 @@
+package android.widget;
+
+import com.android.internal.R;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.os.Handler;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+
+/**
+ * @hide
+ */
+public class ZoomRing extends View {
+    
+    // TODO: move to ViewConfiguration?
+    private static final int DOUBLE_TAP_DISMISS_TIMEOUT = ViewConfiguration.getJumpTapTimeout();
+    // TODO: get from theme
+    private static final int DISABLED_ALPHA = 160;
+    
+    private static final String TAG = "ZoomRing";
+
+    // TODO: xml
+    private static final int THUMB_DISTANCE = 63; 
+    
+    /** To avoid floating point calculations, we multiply radians by this value. */
+    public static final int RADIAN_INT_MULTIPLIER = 100000000;
+    /** PI using our multiplier. */
+    public static final int PI_INT_MULTIPLIED = (int) (Math.PI * RADIAN_INT_MULTIPLIER);
+    /** PI/2 using our multiplier. */
+    private static final int HALF_PI_INT_MULTIPLIED = PI_INT_MULTIPLIED / 2;
+
+    private static final int THUMB_GRAB_SLOP = PI_INT_MULTIPLIED / 4;
+    
+    /** The cached X of our center. */
+    private int mCenterX;
+    /** The cached Y of our center. */ 
+    private int mCenterY;
+
+    /** The angle of the thumb (in int radians) */
+    private int mThumbAngle;
+    private boolean mIsThumbAngleValid;
+    private int mThumbCenterX;
+    private int mThumbCenterY;
+    private int mThumbHalfWidth;
+    private int mThumbHalfHeight;
+    
+    private int mCallbackThreshold = Integer.MAX_VALUE;
+    
+    /** The accumulated amount of drag for the thumb (in int radians). */
+    private int mAcculumalatedThumbDrag = 0;
+   
+    /** The inner radius of the track. */
+    private int mBoundInnerRadiusSquared = 0;
+    /** The outer radius of the track. */
+    private int mBoundOuterRadiusSquared = Integer.MAX_VALUE;
+    
+    private int mPreviousWidgetDragX;
+    private int mPreviousWidgetDragY;
+    
+    private boolean mDrawThumb = true;
+    private Drawable mThumbDrawable;
+    
+    private static final int MODE_IDLE = 0;
+    private static final int MODE_DRAG_THUMB = 1;
+    private static final int MODE_MOVE_ZOOM_RING = 2;
+    private static final int MODE_TAP_DRAG = 3;
+    private int mMode;
+
+    private long mPreviousTapTime;
+    
+    private Handler mHandler = new Handler();
+    
+    private Disabler mDisabler = new Disabler();
+    
+    private OnZoomRingCallback mCallback;
+    
+    private boolean mResetThumbAutomatically = true;
+    private int mThumbDragStartAngle;
+    
+    public ZoomRing(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+        // TODO get drawable from style instead
+        Resources res = context.getResources();
+        mThumbDrawable = res.getDrawable(R.drawable.zoom_ring_thumb);
+        
+        // TODO: add padding to drawable
+        setBackgroundResource(R.drawable.zoom_ring_track);
+        // TODO get from style
+        setBounds(30, Integer.MAX_VALUE);
+        
+        mThumbHalfHeight = mThumbDrawable.getIntrinsicHeight() / 2;
+        mThumbHalfWidth = mThumbDrawable.getIntrinsicWidth() / 2;
+        
+        mCallbackThreshold = PI_INT_MULTIPLIED / 6;
+    }
+
+    public ZoomRing(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public ZoomRing(Context context) {
+        this(context, null);
+    }
+    
+    public void setCallback(OnZoomRingCallback callback) {
+        mCallback = callback;
+    }
+
+    // TODO: rename
+    public void setCallbackThreshold(int callbackThreshold) {
+        mCallbackThreshold = callbackThreshold;
+    }
+
+    // TODO: from XML too
+    public void setBounds(int innerRadius, int outerRadius) {
+        mBoundInnerRadiusSquared = innerRadius * innerRadius;
+        if (mBoundInnerRadiusSquared < innerRadius) {
+            // Prevent overflow
+            mBoundInnerRadiusSquared = Integer.MAX_VALUE;
+        }
+
+        mBoundOuterRadiusSquared = outerRadius * outerRadius;
+        if (mBoundOuterRadiusSquared < outerRadius) {
+            // Prevent overflow
+            mBoundOuterRadiusSquared = Integer.MAX_VALUE;
+        }
+    }
+    
+    public void setThumbAngle(int angle) {
+        mThumbAngle = angle;
+        mThumbCenterX = (int) (Math.cos(1f * angle / RADIAN_INT_MULTIPLIER) * THUMB_DISTANCE)
+                + mCenterX;
+        mThumbCenterY = (int) (Math.sin(1f * angle / RADIAN_INT_MULTIPLIER) * THUMB_DISTANCE)
+                * -1 + mCenterY;
+        invalidate();
+    }
+    
+    public void resetThumbAngle() {
+        if (mResetThumbAutomatically) {
+            setThumbAngle(HALF_PI_INT_MULTIPLIED);
+        }
+    }
+    
+    public void setResetThumbAutomatically(boolean resetThumbAutomatically) {
+        mResetThumbAutomatically = resetThumbAutomatically;
+    }
+    
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        setMeasuredDimension(resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec),
+                resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec));
+    }
+
+    @Override
+    protected void onLayout(boolean changed, int left, int top, int right,
+            int bottom) {
+        super.onLayout(changed, left, top, right, bottom);
+        
+        // Cache the center point
+        mCenterX = (right - left) / 2;
+        mCenterY = (bottom - top) / 2;
+
+        // Done here since we now have center, which is needed to calculate some
+        // aux info for thumb angle
+        if (mThumbAngle == Integer.MIN_VALUE) {
+            resetThumbAngle();
+        }
+    }
+    
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        return handleTouch(event.getAction(), event.getEventTime(),
+                (int) event.getX(), (int) event.getY(), (int) event.getRawX(),
+                (int) event.getRawY());
+    }
+
+    private void resetState() {
+        mMode = MODE_IDLE;
+        mPreviousWidgetDragX = mPreviousWidgetDragY = Integer.MIN_VALUE;
+        mAcculumalatedThumbDrag = 0;
+        mIsThumbAngleValid = false;
+    }
+    
+    public void setTapDragMode(boolean tapDragMode, int x, int y) {
+        resetState();
+        mMode = tapDragMode ? MODE_TAP_DRAG : MODE_IDLE;
+        mIsThumbAngleValid = false;
+        
+        if (tapDragMode && mCallback != null) {
+            onThumbDragStarted(getAngle(x - mCenterX, y - mCenterY));
+        }
+    }
+    
+    public boolean handleTouch(int action, long time, int x, int y, int rawX, int rawY) {
+        switch (action) {
+        
+            case MotionEvent.ACTION_DOWN:
+                if (mPreviousTapTime + DOUBLE_TAP_DISMISS_TIMEOUT >= time) {
+                    if (mCallback != null) {
+                        mCallback.onZoomRingDismissed();
+                    }
+                } else {
+                    mPreviousTapTime = time;
+                }
+                resetState();
+                return true;
+                
+            case MotionEvent.ACTION_MOVE:
+                // Fall through to code below switch
+                break;
+                
+            case MotionEvent.ACTION_CANCEL:
+            case MotionEvent.ACTION_UP:
+                if (mCallback != null) {
+                    if (mMode == MODE_MOVE_ZOOM_RING) {
+                        mCallback.onZoomRingMovingStopped();
+                    } else if (mMode == MODE_DRAG_THUMB || mMode == MODE_TAP_DRAG) {
+                        onThumbDragStopped(getAngle(x - mCenterX, y - mCenterY));
+                    }
+                }
+                mDisabler.setEnabling(true);
+                return true;
+                
+            default:
+                return false;
+        }
+        
+        // local{X,Y} will be where the center of the widget is (0,0)
+        int localX = x - mCenterX;
+        int localY = y - mCenterY;
+        boolean isTouchingThumb = true;
+        boolean isInBounds = true;
+        int touchAngle = getAngle(localX, localY);
+        
+        int radiusSquared = localX * localX + localY * localY;
+        if (radiusSquared < mBoundInnerRadiusSquared ||
+                radiusSquared > mBoundOuterRadiusSquared) {
+            // Out-of-bounds
+            isTouchingThumb = false;
+            isInBounds = false;
+        }
+        
+        int deltaThumbAndTouch = getDelta(touchAngle, mThumbAngle);
+        int absoluteDeltaThumbAndTouch = deltaThumbAndTouch >= 0 ?
+                deltaThumbAndTouch : -deltaThumbAndTouch;
+        if (isTouchingThumb &&
+                absoluteDeltaThumbAndTouch > THUMB_GRAB_SLOP) {
+            // Didn't grab close enough to the thumb
+            isTouchingThumb = false;
+        }
+        
+        if (mMode == MODE_IDLE) {
+            mMode = isTouchingThumb ? MODE_DRAG_THUMB : MODE_MOVE_ZOOM_RING;
+            
+            if (mCallback != null) {
+                if (mMode == MODE_DRAG_THUMB) {
+                    onThumbDragStarted(touchAngle);
+                } else if (mMode == MODE_MOVE_ZOOM_RING) {
+                    mCallback.onZoomRingMovingStarted();
+                }
+            }
+        }
+        
+        if (mMode == MODE_DRAG_THUMB || mMode == MODE_TAP_DRAG) {
+            if (isInBounds) {
+                onThumbDragged(touchAngle, mIsThumbAngleValid ? deltaThumbAndTouch : 0);
+            } else {
+                mIsThumbAngleValid = false;
+            }
+        } else if (mMode == MODE_MOVE_ZOOM_RING) {
+            onZoomRingMoved(rawX, rawY);
+        }
+        
+        return true;
+    }
+    
+    private int getDelta(int angle1, int angle2) {
+        int delta = angle1 - angle2;
+                
+        // Assume this is a result of crossing over the discontinuous 0 -> 2pi
+        if (delta > PI_INT_MULTIPLIED || delta < -PI_INT_MULTIPLIED) {
+            // Bring both the radians and previous angle onto a continuous range
+            if (angle1 < HALF_PI_INT_MULTIPLIED) {
+                // Same as deltaRadians = (radians + 2PI) - previousAngle
+                delta += PI_INT_MULTIPLIED * 2;
+            } else if (angle2 < HALF_PI_INT_MULTIPLIED) {
+                // Same as deltaRadians = radians - (previousAngle + 2PI)
+                delta -= PI_INT_MULTIPLIED * 2;
+            }
+        }
+       
+        return delta;
+    }
+
+    private void onThumbDragStarted(int startAngle) {
+        mThumbDragStartAngle = startAngle;
+        mCallback.onZoomRingThumbDraggingStarted(startAngle);
+    }
+    
+    private void onThumbDragged(int touchAngle, int deltaAngle) {
+        mAcculumalatedThumbDrag += deltaAngle;
+        if (mAcculumalatedThumbDrag > mCallbackThreshold
+                || mAcculumalatedThumbDrag < -mCallbackThreshold) {
+            if (mCallback != null) {
+                boolean canStillZoom = mCallback.onZoomRingThumbDragged(
+                        mAcculumalatedThumbDrag / mCallbackThreshold,
+                        mAcculumalatedThumbDrag, mThumbDragStartAngle, touchAngle);
+                mDisabler.setEnabling(canStillZoom);
+            }
+            mAcculumalatedThumbDrag = 0;
+        }
+    
+        setThumbAngle(touchAngle);
+        mIsThumbAngleValid = true;
+    }
+    
+    private void onThumbDragStopped(int stopAngle) {
+        mCallback.onZoomRingThumbDraggingStopped(stopAngle);
+    }
+    
+    private void onZoomRingMoved(int x, int y) {
+        if (mPreviousWidgetDragX != Integer.MIN_VALUE) {
+            int deltaX = x - mPreviousWidgetDragX;
+            int deltaY = y - mPreviousWidgetDragY;
+            
+            if (mCallback != null) {
+                mCallback.onZoomRingMoved(deltaX, deltaY);
+            }
+        }
+        
+        mPreviousWidgetDragX = x;
+        mPreviousWidgetDragY = y;
+    }
+    
+    @Override
+    public void onWindowFocusChanged(boolean hasWindowFocus) {
+        super.onWindowFocusChanged(hasWindowFocus);
+        
+        if (!hasWindowFocus && mCallback != null) {
+            mCallback.onZoomRingDismissed();
+        }
+    }
+
+    private int getAngle(int localX, int localY) {
+        int radians = (int) (Math.atan2(localY, localX) * RADIAN_INT_MULTIPLIER);
+
+        // Convert from [-pi,pi] to {0,2pi]
+        if (radians < 0) {
+            return -radians;
+        } else if (radians > 0) {
+            return 2 * PI_INT_MULTIPLIED - radians;
+        } else {
+            return 0;
+        }
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        
+        if (mDrawThumb) {
+            mThumbDrawable.setBounds(mThumbCenterX - mThumbHalfWidth, mThumbCenterY
+                    - mThumbHalfHeight, mThumbCenterX + mThumbHalfWidth, mThumbCenterY
+                    + mThumbHalfHeight);
+            mThumbDrawable.draw(canvas);
+        }
+    }
+
+    private class Disabler implements Runnable {
+        private static final int DELAY = 15;
+        private static final float ENABLE_RATE = 1.05f;
+        private static final float DISABLE_RATE = 0.95f;
+        
+        private int mAlpha = 255;
+        private boolean mEnabling;
+        
+        public int getAlpha() {
+            return mAlpha;
+        }
+
+        public void setEnabling(boolean enabling) {
+            if ((enabling && mAlpha != 255) || (!enabling && mAlpha != DISABLED_ALPHA)) {
+                mEnabling = enabling;
+                post(this);
+            }
+        }
+        
+        public void run() {
+            mAlpha *= mEnabling ? ENABLE_RATE : DISABLE_RATE;
+            if (mAlpha < DISABLED_ALPHA) {
+                mAlpha = DISABLED_ALPHA;
+            } else if (mAlpha > 255) {
+                mAlpha = 255;
+            } else {
+                // Still more to go
+                postDelayed(this, DELAY);
+            }
+            
+            getBackground().setAlpha(mAlpha);
+            invalidate();
+        }
+    }
+    
+    public interface OnZoomRingCallback {
+        void onZoomRingMovingStarted();
+        boolean onZoomRingMoved(int deltaX, int deltaY);
+        void onZoomRingMovingStopped();
+        
+        void onZoomRingThumbDraggingStarted(int startAngle);
+        boolean onZoomRingThumbDragged(int numLevels, int dragAmount, int startAngle, int curAngle);
+        void onZoomRingThumbDraggingStopped(int endAngle);
+        
+        void onZoomRingDismissed();
+    }
+
+}
diff --git a/core/java/android/widget/ZoomRingController.java b/core/java/android/widget/ZoomRingController.java
new file mode 100644
index 0000000..2ca0374
--- /dev/null
+++ b/core/java/android/widget/ZoomRingController.java
@@ -0,0 +1,819 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.widget;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.os.Handler;
+import android.os.Message;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.view.animation.DecelerateInterpolator;
+
+// TODO: make sure no px values exist, only dip (scale if necessary from Viewconfiguration)
+
+/**
+ * TODO: Docs
+ * @hide
+ */
+public class ZoomRingController implements ZoomRing.OnZoomRingCallback,
+        View.OnTouchListener, View.OnKeyListener {
+    
+    private static final int SHOW_TUTORIAL_TOAST_DELAY = 1000;
+
+    private static final int ZOOM_RING_RECENTERING_DURATION = 500;
+
+    private static final String TAG = "ZoomRing";
+
+    public static final boolean USE_OLD_ZOOM = false; 
+    public static boolean useOldZoom(Context context) {
+        return Settings.System.getInt(context.getContentResolver(), "zoom", 1) == 0;
+    }
+    
+    private static final int ZOOM_CONTROLS_TIMEOUT =
+            (int) ViewConfiguration.getZoomControlsTimeout();
+    
+    // TODO: move these to ViewConfiguration or re-use existing ones
+    // TODO: scale px values based on latest from ViewConfiguration
+    private static final int SECOND_TAP_TIMEOUT = 500;
+    private static final int ZOOM_RING_DISMISS_DELAY = SECOND_TAP_TIMEOUT / 2;
+    private static final int SECOND_TAP_SLOP = 70;  
+    private static final int SECOND_TAP_MOVE_SLOP = 15; 
+    private static final int MAX_PAN_GAP = 30;
+    
+    private static final String SETTING_NAME_SHOWN_TOAST = "shown_zoom_ring_toast";
+    
+    private Context mContext;
+    private WindowManager mWindowManager;
+    
+    /**
+     * The view that is being zoomed by this zoom ring.
+     */
+    private View mOwnerView;
+
+    /**
+     * The bounds of the owner view in global coordinates. This is recalculated
+     * each time the zoom ring is shown.
+     */
+    private Rect mOwnerViewBounds = new Rect();
+
+    /**
+     * The container that is added as a window.
+     */
+    private FrameLayout mContainer;
+    private LayoutParams mContainerLayoutParams;
+
+    /*
+     * Tap-drag is an interaction where the user first taps and then (quickly)
+     * does the clockwise or counter-clockwise drag. In reality, this is: (down,
+     * up, down, move in circles, up). This differs from the usual events of:
+     * (down, up, down, up, down, move in circles, up). While the only
+     * difference is the omission of an (up, down), for power-users this is a
+     * pretty big improvement as it now only requires them to focus on the
+     * screen once (for the first tap down) instead of twice (for the first tap
+     * down and then to grab the thumb).
+     */
+    private int mTapDragStartX;
+    private int mTapDragStartY;
+    
+    private static final int TOUCH_MODE_IDLE = 0;
+    private static final int TOUCH_MODE_WAITING_FOR_SECOND_TAP = 1;
+    private static final int TOUCH_MODE_WAITING_FOR_TAP_DRAG_MOVEMENT = 2;
+    private static final int TOUCH_MODE_FORWARDING_FOR_TAP_DRAG = 3;
+    private int mTouchMode;
+    
+    private boolean mIsZoomRingVisible;
+    
+    private ZoomRing mZoomRing;
+    private int mZoomRingWidth;
+    private int mZoomRingHeight;
+    
+    /** Invokes panning of owner view if the zoom ring is touching an edge. */
+    private Panner mPanner = new Panner();
+    
+    private ImageView mPanningArrows;
+    private Animation mPanningArrowsEnterAnimation;
+    private Animation mPanningArrowsExitAnimation;
+    
+    private Rect mTempRect = new Rect();
+    
+    private OnZoomListener mCallback;
+
+    private ViewConfiguration mViewConfig;
+
+    /**
+     * When the zoom ring is centered on screen, this will be the x value used
+     * for the container's layout params.
+     */
+    private int mCenteredContainerX = Integer.MIN_VALUE;
+
+    /**
+     * When the zoom ring is centered on screen, this will be the y value used
+     * for the container's layout params.
+     */
+    private int mCenteredContainerY = Integer.MIN_VALUE;
+    
+    /**
+     * Scroller used to re-center the zoom ring if the user had dragged it to a
+     * corner and then double-taps any point on the owner view (the owner view
+     * will center the double-tapped point, but we should re-center the zoom
+     * ring).
+     * <p>
+     * The (x,y) of the scroller is the (x,y) of the container's layout params.
+     */
+    private Scroller mScroller;
+    
+    /**
+     * When showing the zoom ring, we add the view as a new window. However,
+     * there is logic that needs to know the size of the zoom ring which is
+     * determined after it's laid out. Therefore, we must post this logic onto
+     * the UI thread so it will be exceuted AFTER the layout. This is the logic.
+     */
+    private Runnable mPostedVisibleInitializer;
+
+    // TODO: need a better way to persist this value, becuase right now this
+    // requires the WRITE_SETTINGS perimssion which the app may not have
+//    private Runnable mShowTutorialToast = new Runnable() {
+//        public void run() {
+//            if (Settings.System.getInt(mContext.getContentResolver(),
+//                    SETTING_NAME_SHOWN_TOAST, 0) == 1) {
+//                return;
+//            }
+//            try {
+//                Settings.System.putInt(mContext.getContentResolver(), SETTING_NAME_SHOWN_TOAST, 1);
+//            } catch (SecurityException e) {
+//                // The app does not have permission to clear this flag, oh well!
+//            }
+//            
+//            Toast.makeText(mContext,
+//                    com.android.internal.R.string.tutorial_double_tap_to_zoom_message,
+//                    Toast.LENGTH_LONG).show();
+//        }
+//    };
+
+    private IntentFilter mConfigurationChangedFilter =
+            new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED);
+    
+    private BroadcastReceiver mConfigurationChangedReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (!mIsZoomRingVisible) return;
+            
+            mHandler.removeMessages(MSG_POST_CONFIGURATION_CHANGED);
+            mHandler.sendEmptyMessage(MSG_POST_CONFIGURATION_CHANGED);
+        }
+    };
+    
+    /** Keeps the scroller going (or starts it). */
+    private static final int MSG_SCROLLER_TICK = 1;
+    /** When configuration changes, this is called after the UI thread is idle. */
+    private static final int MSG_POST_CONFIGURATION_CHANGED = 2;
+    /** Used to delay the zoom ring dismissal. */
+    private static final int MSG_DISMISS_ZOOM_RING = 3;
+    
+    private Handler mHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case MSG_SCROLLER_TICK:
+                    onScrollerTick();
+                    break;
+                    
+                case MSG_POST_CONFIGURATION_CHANGED:
+                    onPostConfigurationChanged();
+                    break;
+                    
+                case MSG_DISMISS_ZOOM_RING:
+                    setVisible(false);
+                    break;
+            }
+        
+        }  
+    };
+    
+    public ZoomRingController(Context context, View ownerView) {
+        mContext = context;
+        mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+        
+        mOwnerView = ownerView;
+        
+        mZoomRing = new ZoomRing(context);
+        mZoomRing.setLayoutParams(new FrameLayout.LayoutParams(
+                FrameLayout.LayoutParams.WRAP_CONTENT,
+                FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
+        mZoomRing.setCallback(this);
+        
+        createPanningArrows();
+
+        mContainer = new FrameLayout(context);
+        mContainer.setMeasureAllChildren(true);
+        mContainer.setOnTouchListener(this);
+        
+        mContainer.addView(mZoomRing);
+        mContainer.addView(mPanningArrows);
+        mContainer.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
+        
+        mContainerLayoutParams = new LayoutParams();
+        mContainerLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
+        mContainerLayoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL |
+                LayoutParams.FLAG_NOT_FOCUSABLE |
+                LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | LayoutParams.FLAG_LAYOUT_NO_LIMITS;
+        mContainerLayoutParams.height = LayoutParams.WRAP_CONTENT;
+        mContainerLayoutParams.width = LayoutParams.WRAP_CONTENT;
+        mContainerLayoutParams.type = LayoutParams.TYPE_APPLICATION_PANEL;
+        mContainerLayoutParams.format = PixelFormat.TRANSLUCENT;
+        // TODO: make a new animation for this
+        mContainerLayoutParams.windowAnimations = com.android.internal.R.style.Animation_Dialog;
+        
+        mScroller = new Scroller(context, new DecelerateInterpolator());
+        
+        mViewConfig = ViewConfiguration.get(context);
+        
+//        mHandler.postDelayed(mShowTutorialToast, SHOW_TUTORIAL_TOAST_DELAY);
+    }
+
+    private void createPanningArrows() {
+        // TODO: style
+        mPanningArrows = new ImageView(mContext);
+        mPanningArrows.setImageResource(com.android.internal.R.drawable.zoom_ring_arrows);
+        mPanningArrows.setLayoutParams(new FrameLayout.LayoutParams(
+                FrameLayout.LayoutParams.WRAP_CONTENT,
+                FrameLayout.LayoutParams.WRAP_CONTENT,
+                Gravity.CENTER));
+        mPanningArrows.setVisibility(View.GONE);
+        
+        mPanningArrowsEnterAnimation = AnimationUtils.loadAnimation(mContext,
+                com.android.internal.R.anim.fade_in);
+        mPanningArrowsExitAnimation = AnimationUtils.loadAnimation(mContext,
+                com.android.internal.R.anim.fade_out);
+    }
+
+    /**
+     * Sets the angle (in radians) a user must travel in order for the client to
+     * get a callback. Once there is a callback, the accumulator resets. For
+     * example, if you set this to PI/6, it will give a callback every time the
+     * user moves PI/6 amount on the ring.
+     * 
+     * @param callbackThreshold The angle for the callback threshold, in radians
+     */
+    public void setZoomCallbackThreshold(float callbackThreshold) {
+        mZoomRing.setCallbackThreshold((int) (callbackThreshold * ZoomRing.RADIAN_INT_MULTIPLIER));
+    }
+    
+    public void setCallback(OnZoomListener callback) {
+        mCallback = callback;
+    }
+    
+    public void setThumbAngle(float angle) {
+        mZoomRing.setThumbAngle((int) (angle * ZoomRing.RADIAN_INT_MULTIPLIER));
+    }
+
+    public void setResetThumbAutomatically(boolean resetThumbAutomatically) {
+        mZoomRing.setResetThumbAutomatically(resetThumbAutomatically);
+    }
+    
+    public boolean isVisible() {
+        return mIsZoomRingVisible;
+    }
+
+    public void setVisible(boolean visible) {
+
+        if (useOldZoom(mContext)) return;
+        
+        if (visible) {
+            dismissZoomRingDelayed(ZOOM_CONTROLS_TIMEOUT);
+        } else {
+            mPanner.stop();
+        }
+        
+        if (mIsZoomRingVisible == visible) {
+            return;
+        }
+
+        if (visible) {
+            if (mContainerLayoutParams.token == null) {
+                mContainerLayoutParams.token = mOwnerView.getWindowToken();
+            }
+
+            mWindowManager.addView(mContainer, mContainerLayoutParams);
+            
+            if (mPostedVisibleInitializer == null) {
+                mPostedVisibleInitializer = new Runnable() {
+                    public void run() {
+                        refreshPositioningVariables();
+                        resetZoomRing();
+                        
+                        // TODO: remove this 'update' and just center zoom ring before the
+                        // 'add', but need to make sure we have the width and height (which
+                        // probably can only be retrieved after it's measured, which happens
+                        // after it's added).
+                        mWindowManager.updateViewLayout(mContainer, mContainerLayoutParams);
+                    }
+                };                
+            }
+            
+            mHandler.post(mPostedVisibleInitializer);
+            
+            // Handle configuration changes when visible
+            mContext.registerReceiver(mConfigurationChangedReceiver, mConfigurationChangedFilter);
+            
+            // Steal key events from the owner
+            mOwnerView.setOnKeyListener(this);
+            
+        } else {
+            // Don't want to steal any more keys
+            mOwnerView.setOnKeyListener(null);
+            
+            // No longer care about configuration changes
+            mContext.unregisterReceiver(mConfigurationChangedReceiver);
+            
+            mWindowManager.removeView(mContainer);
+        }
+        
+        mIsZoomRingVisible = visible;
+
+        if (mCallback != null) {
+            mCallback.onVisibilityChanged(visible);
+        }
+    }
+    
+    private void dismissZoomRingDelayed(int delay) {
+        mHandler.removeMessages(MSG_DISMISS_ZOOM_RING);
+        mHandler.sendEmptyMessageDelayed(MSG_DISMISS_ZOOM_RING, delay);
+    }
+    
+    private void resetZoomRing() {
+        mScroller.abortAnimation();
+        
+        mContainerLayoutParams.x = mCenteredContainerX;
+        mContainerLayoutParams.y = mCenteredContainerY;
+        
+        // Reset the thumb
+        mZoomRing.resetThumbAngle();
+    }
+
+    /**
+     * Should be called by the client for each event belonging to the second tap
+     * (the down, move, up, and cancel events).
+     * 
+     * @param event The event belonging to the second tap.
+     * @return Whether the event was consumed.
+     */
+    public boolean handleDoubleTapEvent(MotionEvent event) {
+        int action = event.getAction();
+        
+        if (action == MotionEvent.ACTION_DOWN) {
+            mTouchMode = TOUCH_MODE_WAITING_FOR_TAP_DRAG_MOVEMENT;
+            int x = (int) event.getX();
+            int y = (int) event.getY();
+            
+            refreshPositioningVariables();
+            setVisible(true);
+            centerPoint(x, y);
+            ensureZoomRingIsCentered();            
+            
+            // Tap drag mode stuff
+            mTapDragStartX = x;
+            mTapDragStartY = y;
+
+        } else if (action == MotionEvent.ACTION_CANCEL) {
+            mTouchMode = TOUCH_MODE_IDLE;
+            
+        } else { // action is move or up
+            switch (mTouchMode) {
+                case TOUCH_MODE_WAITING_FOR_TAP_DRAG_MOVEMENT: {
+                    switch (action) {
+                        case MotionEvent.ACTION_MOVE:
+                            int x = (int) event.getX();
+                            int y = (int) event.getY();
+                            if (Math.abs(x - mTapDragStartX) > mViewConfig.getScaledTouchSlop() ||
+                                    Math.abs(y - mTapDragStartY) >
+                                    mViewConfig.getScaledTouchSlop()) {
+                                mZoomRing.setTapDragMode(true, x, y);
+                                mTouchMode = TOUCH_MODE_FORWARDING_FOR_TAP_DRAG;
+                            }
+                            return true;
+                            
+                        case MotionEvent.ACTION_UP:
+                            mTouchMode = TOUCH_MODE_IDLE;
+                            break;
+                    }
+                    break;
+                }
+                
+                case TOUCH_MODE_FORWARDING_FOR_TAP_DRAG: {
+                    switch (action) {
+                        case MotionEvent.ACTION_MOVE:
+                            giveTouchToZoomRing(event);
+                            return true;
+                    
+                        case MotionEvent.ACTION_UP:
+                            mTouchMode = TOUCH_MODE_IDLE;
+                            mZoomRing.setTapDragMode(false, (int) event.getX(), (int) event.getY());
+                            break;
+                    }
+                    break;
+                }
+            }
+        }
+        
+        return true;
+    }
+    
+    private void ensureZoomRingIsCentered() {
+        LayoutParams lp = mContainerLayoutParams;
+        
+        if (lp.x != mCenteredContainerX || lp.y != mCenteredContainerY) {
+            int width = mContainer.getWidth();
+            int height = mContainer.getHeight();
+            mScroller.startScroll(lp.x, lp.y, mCenteredContainerX - lp.x,
+                    mCenteredContainerY - lp.y, ZOOM_RING_RECENTERING_DURATION);
+            mHandler.sendEmptyMessage(MSG_SCROLLER_TICK);
+        }
+    }
+    
+    private void refreshPositioningVariables() {
+        mZoomRingWidth = mZoomRing.getWidth();
+        mZoomRingHeight = mZoomRing.getHeight();
+        
+        // Calculate the owner view's bounds
+        mOwnerView.getGlobalVisibleRect(mOwnerViewBounds);
+        
+        // Get the center
+        Gravity.apply(Gravity.CENTER, mContainer.getWidth(), mContainer.getHeight(),
+                mOwnerViewBounds, mTempRect);
+        mCenteredContainerX = mTempRect.left;
+        mCenteredContainerY = mTempRect.top;
+        
+    }
+    
+    // MOVE ALL THIS TO GESTURE DETECTOR
+//    public boolean onTouch(View v, MotionEvent event) {
+//        int action = event.getAction();
+//
+//        if (mListenForInvocation) {
+//            switch (mTouchMode) {
+//                case TOUCH_MODE_IDLE: {
+//                    if (action == MotionEvent.ACTION_DOWN) {
+//                        setFirstTap(event);
+//                    }
+//                    break;
+//                }
+//                
+//                case TOUCH_MODE_WAITING_FOR_SECOND_TAP: {
+//                    switch (action) {
+//                        case MotionEvent.ACTION_DOWN:
+//                            if (isSecondTapWithinSlop(event)) {
+//                                handleDoubleTapEvent(event);                                
+//                            } else {
+//                                setFirstTap(event);
+//                            }
+//                            break;
+//                            
+//                        case MotionEvent.ACTION_MOVE:
+//                            int deltaX = (int) event.getX() - mFirstTapX;
+//                            if (deltaX < -SECOND_TAP_MOVE_SLOP ||
+//                                    deltaX > SECOND_TAP_MOVE_SLOP) {
+//                                mTouchMode = TOUCH_MODE_IDLE;
+//                            } else {
+//                                int deltaY = (int) event.getY() - mFirstTapY;
+//                                if (deltaY < -SECOND_TAP_MOVE_SLOP ||
+//                                        deltaY > SECOND_TAP_MOVE_SLOP) {
+//                                    mTouchMode = TOUCH_MODE_IDLE;
+//                                }
+//                            }
+//                            break;
+//                    }
+//                    break;
+//                }
+//                
+//                case TOUCH_MODE_WAITING_FOR_TAP_DRAG_MOVEMENT:
+//                case TOUCH_MODE_FORWARDING_FOR_TAP_DRAG: {
+//                    handleDoubleTapEvent(event);
+//                    break;
+//                }
+//            }
+//            
+//            if (action == MotionEvent.ACTION_CANCEL) {
+//                mTouchMode = TOUCH_MODE_IDLE;
+//            }
+//        }
+//        
+//        return false;
+//    }
+//    
+//    private void setFirstTap(MotionEvent event) {
+//        mFirstTapTime = event.getEventTime();
+//        mFirstTapX = (int) event.getX();
+//        mFirstTapY = (int) event.getY();
+//        mTouchMode = TOUCH_MODE_WAITING_FOR_SECOND_TAP;
+//    }
+//    
+//    private boolean isSecondTapWithinSlop(MotionEvent event) {
+//        return mFirstTapTime + SECOND_TAP_TIMEOUT > event.getEventTime() && 
+//            Math.abs((int) event.getX() - mFirstTapX) < SECOND_TAP_SLOP &&
+//            Math.abs((int) event.getY() - mFirstTapY) < SECOND_TAP_SLOP;
+//    }
+    
+    /**
+     * Centers the point (in owner view's coordinates).
+     */
+    private void centerPoint(int x, int y) {
+        if (mCallback != null) {
+            mCallback.onCenter(x, y);
+        }
+    }
+    
+    private void giveTouchToZoomRing(MotionEvent event) {
+        int rawX = (int) event.getRawX();
+        int rawY = (int) event.getRawY();
+        int x = rawX - mContainerLayoutParams.x - mZoomRing.getLeft();
+        int y = rawY - mContainerLayoutParams.y - mZoomRing.getTop();
+        mZoomRing.handleTouch(event.getAction(), event.getEventTime(), x, y, rawX, rawY);
+    }
+    
+    public void onZoomRingMovingStarted() {
+        mHandler.removeMessages(MSG_DISMISS_ZOOM_RING);
+        mScroller.abortAnimation();
+        setPanningArrowsVisible(true); 
+    }
+    
+    private void setPanningArrowsVisible(boolean visible) {
+        mPanningArrows.startAnimation(visible ? mPanningArrowsEnterAnimation
+                : mPanningArrowsExitAnimation);
+        mPanningArrows.setVisibility(visible ? View.VISIBLE : View.GONE);
+    }
+    
+    public boolean onZoomRingMoved(int deltaX, int deltaY) {
+        WindowManager.LayoutParams lp = mContainerLayoutParams;
+        Rect ownerBounds = mOwnerViewBounds;
+        
+        int zoomRingLeft = mZoomRing.getLeft();
+        int zoomRingTop = mZoomRing.getTop();
+        
+        int newX = lp.x + deltaX;
+        int newZoomRingX = newX + zoomRingLeft;
+        newZoomRingX = (newZoomRingX <= ownerBounds.left) ? ownerBounds.left :
+                (newZoomRingX + mZoomRingWidth > ownerBounds.right) ?
+                        ownerBounds.right - mZoomRingWidth : newZoomRingX;
+        lp.x = newZoomRingX - zoomRingLeft;
+
+        int newY = lp.y + deltaY;
+        int newZoomRingY = newY + zoomRingTop;
+        newZoomRingY = (newZoomRingY <= ownerBounds.top) ? ownerBounds.top :
+            (newZoomRingY + mZoomRingHeight > ownerBounds.bottom) ?
+                    ownerBounds.bottom - mZoomRingHeight : newZoomRingY;
+        lp.y = newZoomRingY - zoomRingTop;
+        
+        mWindowManager.updateViewLayout(mContainer, lp);
+        
+        // Check for pan
+        int leftGap = newZoomRingX - ownerBounds.left;
+        if (leftGap < MAX_PAN_GAP) {
+            mPanner.setHorizontalStrength(-getStrengthFromGap(leftGap));
+        } else {
+            int rightGap = ownerBounds.right - (lp.x + mZoomRingWidth + zoomRingLeft);
+            if (rightGap < MAX_PAN_GAP) {
+                mPanner.setHorizontalStrength(getStrengthFromGap(rightGap));
+            } else {
+                mPanner.setHorizontalStrength(0);
+            }
+        }
+        
+        int topGap = newZoomRingY - ownerBounds.top;
+        if (topGap < MAX_PAN_GAP) {
+            mPanner.setVerticalStrength(-getStrengthFromGap(topGap));
+        } else {
+            int bottomGap = ownerBounds.bottom - (lp.y + mZoomRingHeight + zoomRingTop);
+            if (bottomGap < MAX_PAN_GAP) {
+                mPanner.setVerticalStrength(getStrengthFromGap(bottomGap));
+            } else {
+                mPanner.setVerticalStrength(0);
+            }
+        }
+        
+        return true;
+    }
+    
+    public void onZoomRingMovingStopped() {
+        dismissZoomRingDelayed(ZOOM_CONTROLS_TIMEOUT);
+        mPanner.stop();
+        setPanningArrowsVisible(false); 
+    }
+    
+    private int getStrengthFromGap(int gap) {
+        return gap > MAX_PAN_GAP ? 0 :
+            (MAX_PAN_GAP - gap) * 100 / MAX_PAN_GAP;
+    }
+    
+    public void onZoomRingThumbDraggingStarted(int startAngle) {
+        mHandler.removeMessages(MSG_DISMISS_ZOOM_RING);
+        if (mCallback != null) {
+            mCallback.onBeginDrag((float) startAngle / ZoomRing.RADIAN_INT_MULTIPLIER);
+        }
+    }
+    
+    public boolean onZoomRingThumbDragged(int numLevels, int dragAmount, int startAngle,
+            int curAngle) {
+        if (mCallback != null) {
+            int deltaZoomLevel = -numLevels;
+            int globalZoomCenterX = mContainerLayoutParams.x + mZoomRing.getLeft() +
+                    mZoomRingWidth / 2;
+            int globalZoomCenterY = mContainerLayoutParams.y + mZoomRing.getTop() +
+                    mZoomRingHeight / 2;
+            
+            return mCallback.onDragZoom(deltaZoomLevel, globalZoomCenterX - mOwnerViewBounds.left,
+                    globalZoomCenterY - mOwnerViewBounds.top,
+                    (float) startAngle / ZoomRing.RADIAN_INT_MULTIPLIER,
+                    (float) curAngle / ZoomRing.RADIAN_INT_MULTIPLIER);
+        }
+        
+        return false;
+    }
+    
+    public void onZoomRingThumbDraggingStopped(int endAngle) {
+        dismissZoomRingDelayed(ZOOM_CONTROLS_TIMEOUT);
+        if (mCallback != null) {
+            mCallback.onEndDrag((float) endAngle / ZoomRing.RADIAN_INT_MULTIPLIER);
+        }
+    }
+
+    public void onZoomRingDismissed() {
+        dismissZoomRingDelayed(ZOOM_RING_DISMISS_DELAY);        
+    }
+
+    public boolean onTouch(View v, MotionEvent event) {
+        if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
+            // If the user touches outside of the zoom ring, dismiss the zoom ring
+            dismissZoomRingDelayed(ZOOM_RING_DISMISS_DELAY);
+            return true;
+        }
+        
+        return false;
+    }
+
+    /** Steals key events from the owner view. */
+    public boolean onKey(View v, int keyCode, KeyEvent event) {
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_DPAD_LEFT:
+            case KeyEvent.KEYCODE_DPAD_RIGHT:
+                // Eat these
+                return true;
+                
+            case KeyEvent.KEYCODE_DPAD_UP:
+            case KeyEvent.KEYCODE_DPAD_DOWN:
+                // Keep the zoom alive a little longer
+                dismissZoomRingDelayed(ZOOM_CONTROLS_TIMEOUT);
+                
+                if (mCallback != null && event.getAction() == KeyEvent.ACTION_DOWN) {
+                    mCallback.onSimpleZoom(keyCode == KeyEvent.KEYCODE_DPAD_UP);
+                }
+                
+                return true;
+        }
+        
+        return false;
+    }
+
+    private void onScrollerTick() {
+        if (!mScroller.computeScrollOffset() || !mIsZoomRingVisible) return;
+        
+        mContainerLayoutParams.x = mScroller.getCurrX();
+        mContainerLayoutParams.y = mScroller.getCurrY();
+        mWindowManager.updateViewLayout(mContainer, mContainerLayoutParams);
+
+        mHandler.sendEmptyMessage(MSG_SCROLLER_TICK);
+    }
+    
+    private void onPostConfigurationChanged() {
+        dismissZoomRingDelayed(ZOOM_CONTROLS_TIMEOUT);
+        refreshPositioningVariables();
+        ensureZoomRingIsCentered();
+    }
+
+    private class Panner implements Runnable {
+        private static final int RUN_DELAY = 15;
+        private static final float STOP_SLOWDOWN = 0.8f;
+        
+        private final Handler mUiHandler = new Handler();
+        
+        private int mVerticalStrength;
+        private int mHorizontalStrength;
+
+        private boolean mStopping;
+        
+        /** The time this current pan started. */
+        private long mStartTime;
+        
+        /** The time of the last callback to pan the map/browser/etc. */
+        private long mPreviousCallbackTime;
+        
+        /** -100 (full left) to 0 (none) to 100 (full right) */
+        public void setHorizontalStrength(int horizontalStrength) {
+            if (mHorizontalStrength == 0 && mVerticalStrength == 0 && horizontalStrength != 0) {
+                start();
+            } else if (mVerticalStrength == 0 && horizontalStrength == 0) {
+                stop();
+            }
+            
+            mHorizontalStrength = horizontalStrength;
+            mStopping = false;
+        }
+
+        /** -100 (full up) to 0 (none) to 100 (full down) */
+        public void setVerticalStrength(int verticalStrength) {
+            if (mHorizontalStrength == 0 && mVerticalStrength == 0 && verticalStrength != 0) {
+                start();
+            } else if (mHorizontalStrength == 0 && verticalStrength == 0) {
+                stop();
+            }
+            
+            mVerticalStrength = verticalStrength;            
+            mStopping = false;
+        }
+        
+        private void start() {
+            mUiHandler.post(this);
+            mPreviousCallbackTime = 0;
+            mStartTime = 0;
+        }
+
+        public void stop() {
+            mStopping = true;
+        }
+        
+        public void run() {
+            if (mStopping) {
+                mHorizontalStrength *= STOP_SLOWDOWN;
+                mVerticalStrength *= STOP_SLOWDOWN;
+            }
+            
+            if (mHorizontalStrength == 0 && mVerticalStrength == 0) {
+                return;
+            }
+            
+            boolean firstRun = mPreviousCallbackTime == 0;
+            long curTime = SystemClock.elapsedRealtime();
+            int panAmount = getPanAmount(mStartTime, mPreviousCallbackTime, curTime);
+            mPreviousCallbackTime = curTime;
+            
+            if (firstRun) {
+                mStartTime = curTime;
+            } else {
+                int panX = panAmount * mHorizontalStrength / 100;
+                int panY = panAmount * mVerticalStrength / 100;
+                
+                if (mCallback != null) {
+                    mCallback.onPan(panX, panY);
+                }
+            }
+            
+            mUiHandler.postDelayed(this, RUN_DELAY);
+        }
+        
+        // TODO make setter for this value so zoom clients can have different pan rates, if they want
+        private static final int PAN_VELOCITY_PX_S = 30;
+        private int getPanAmount(long startTime, long previousTime, long currentTime) {
+            return (int) ((currentTime - previousTime) * PAN_VELOCITY_PX_S / 100);
+        }
+    }
+    
+    public interface OnZoomListener {
+        void onBeginDrag(float startAngle);
+        boolean onDragZoom(int deltaZoomLevel, int centerX, int centerY, float startAngle,
+                float curAngle);
+        void onEndDrag(float endAngle);
+        void onSimpleZoom(boolean deltaZoomLevel);
+        boolean onPan(int deltaX, int deltaY);
+        void onCenter(int x, int y);
+        void onVisibilityChanged(boolean visible);
+    }
+}
diff --git a/core/java/com/android/internal/app/ExternalMediaFormatActivity.java b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java
new file mode 100644
index 0000000..000f6c4
--- /dev/null
+++ b/core/java/com/android/internal/app/ExternalMediaFormatActivity.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.app;
+
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IMountService;
+import android.os.Message;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.Environment;
+import android.widget.Toast;
+import android.util.Log;
+
+/**
+ * This activity is shown to the user to confirm formatting of external media.
+ * It uses the alert dialog style. It will be launched from a notification, or from settings
+ */
+public class ExternalMediaFormatActivity extends AlertActivity implements DialogInterface.OnClickListener {
+
+    private static final int POSITIVE_BUTTON = AlertDialog.BUTTON1;
+
+    /** Used to detect when the media state changes, in case we need to call finish() */
+    private BroadcastReceiver mStorageReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            Log.d("ExternalMediaFormatActivity", "got action " + action);
+
+            if (action == Intent.ACTION_MEDIA_REMOVED ||
+                action == Intent.ACTION_MEDIA_CHECKING ||
+                action == Intent.ACTION_MEDIA_MOUNTED ||
+                action == Intent.ACTION_MEDIA_SHARED) {
+                finish();
+            }
+        }
+    };
+    
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        Log.d("ExternalMediaFormatActivity", "onCreate!");
+        // Set up the "dialog"
+        final AlertController.AlertParams p = mAlertParams;
+        p.mIconId = com.android.internal.R.drawable.stat_sys_warning;
+        p.mTitle = getString(com.android.internal.R.string.extmedia_format_title);
+        p.mMessage = getString(com.android.internal.R.string.extmedia_format_message);
+        p.mPositiveButtonText = getString(com.android.internal.R.string.extmedia_format_button_format);
+        p.mPositiveButtonListener = this;
+        p.mNegativeButtonText = getString(com.android.internal.R.string.cancel);
+        p.mNegativeButtonListener = this;
+        setupAlert();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(Intent.ACTION_MEDIA_REMOVED);
+        filter.addAction(Intent.ACTION_MEDIA_CHECKING);
+        filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
+        filter.addAction(Intent.ACTION_MEDIA_SHARED);
+        registerReceiver(mStorageReceiver, filter);
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        
+        unregisterReceiver(mStorageReceiver);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void onClick(DialogInterface dialog, int which) {
+
+        if (which == POSITIVE_BUTTON) {
+            IMountService mountService = IMountService.Stub.asInterface(ServiceManager
+                .getService("mount"));
+            if (mountService != null) {
+                try {
+                    mountService.formatMedia(Environment.getExternalStorageDirectory().toString());
+                } catch (RemoteException e) {
+                }
+            }
+        }
+
+        // No matter what, finish the activity
+        finish();
+    }
+}
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index 434850c..eb232c7 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -22,8 +22,14 @@
     BatteryStatsImpl getStatistics();
     void noteStartWakelock(int uid, String name, int type);
     void noteStopWakelock(int uid, String name, int type);
-    void noteStartSensor(int uid, int sensor);
-    void noteStopSensor(int uid, int sensor);
+    void noteStartSensor(int uid, String name, int sensor);
+    void noteStopSensor(int uid, String name, int sensor);
+    void noteRequestGpsOn(int uid);
+    void noteRequestGpsOff(int uid);
+    void noteStartGps(int uid);
+    void noteStopGps(int uid);
+    void noteScreenOn();
+    void noteScreenOff();
     void setOnBattery(boolean onBattery);
     long getAwakeTimeBattery();
     long getAwakeTimePlugged();
diff --git a/tests/GadgetHost/src/com/android/gadgethost/TestGadgetProvider.java b/core/java/com/android/internal/app/IUsageStats.aidl
old mode 100644
new mode 100755
similarity index 61%
rename from tests/GadgetHost/src/com/android/gadgethost/TestGadgetProvider.java
rename to core/java/com/android/internal/app/IUsageStats.aidl
index 8f9641b..6b053d5
--- a/tests/GadgetHost/src/com/android/gadgethost/TestGadgetProvider.java
+++ b/core/java/com/android/internal/app/IUsageStats.aidl
@@ -14,19 +14,14 @@
  * limitations under the License.
  */
 
-package com.android.gadgethost;
+package com.android.internal.app;
 
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
+import android.content.ComponentName;
+import com.android.internal.os.PkgUsageStats;
 
-public class TestGadgetProvider extends BroadcastReceiver {
-
-    static final String TAG = "TestGadgetProvider";
-
-    public void onReceive(Context context, Intent intent) {
-        Log.d(TAG, "intent=" + intent);
-    }
+interface IUsageStats {
+    void noteResumeComponent(in ComponentName componentName);
+    void notePauseComponent(in ComponentName componentName);
+    PkgUsageStats getPkgUsageStats(in ComponentName componentName);
+    PkgUsageStats[] getAllPkgUsageStats();
 }
-
diff --git a/core/java/com/android/internal/app/UsbStorageStopActivity.java b/core/java/com/android/internal/app/UsbStorageStopActivity.java
new file mode 100644
index 0000000..30523c4
--- /dev/null
+++ b/core/java/com/android/internal/app/UsbStorageStopActivity.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.app;
+
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IMountService;
+import android.os.Message;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.widget.Toast;
+
+/**
+ * This activity is shown to the user for him/her to disable USB mass storage.
+ * It uses the alert dialog style. It will be launched from a notification.
+ */
+public class UsbStorageStopActivity extends AlertActivity implements DialogInterface.OnClickListener {
+
+    private static final int POSITIVE_BUTTON = AlertDialog.BUTTON1;
+
+    /** Used to detect when the USB cable is unplugged, so we can call finish() */
+    private BroadcastReceiver mBatteryReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction() == Intent.ACTION_BATTERY_CHANGED) {
+                handleBatteryChanged(intent);
+            }
+        }
+    };
+    
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        // Set up the "dialog"
+        final AlertController.AlertParams p = mAlertParams;
+        p.mIconId = com.android.internal.R.drawable.stat_sys_warning;
+        p.mTitle = getString(com.android.internal.R.string.usb_storage_stop_title);
+        p.mMessage = getString(com.android.internal.R.string.usb_storage_stop_message);
+        p.mPositiveButtonText = getString(com.android.internal.R.string.usb_storage_stop_button_mount);
+        p.mPositiveButtonListener = this;
+        p.mNegativeButtonText = getString(com.android.internal.R.string.usb_storage_stop_button_unmount);
+        p.mNegativeButtonListener = this;
+        setupAlert();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        registerReceiver(mBatteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        
+        unregisterReceiver(mBatteryReceiver);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void onClick(DialogInterface dialog, int which) {
+
+        if (which == POSITIVE_BUTTON) {
+            stopUsbStorage();
+        }
+
+        // No matter what, finish the activity
+        finish();
+    }
+
+    private void stopUsbStorage() {
+        IMountService mountService = IMountService.Stub.asInterface(ServiceManager
+                .getService("mount"));
+        if (mountService == null) {
+            showStoppingError();
+            return;
+        }
+
+        try {
+            mountService.setMassStorageEnabled(false);
+        } catch (RemoteException e) {
+            showStoppingError();
+            return;
+        }
+    }
+
+    private void handleBatteryChanged(Intent intent) {
+        int pluggedType = intent.getIntExtra("plugged", 0);
+        if (pluggedType == 0) {
+            // It was disconnected from the plug, so finish
+            finish();
+        }
+    }
+    
+    private void showStoppingError() {
+        Toast.makeText(this, com.android.internal.R.string.usb_storage_stop_error_message,
+                Toast.LENGTH_LONG).show();
+    }
+
+}
diff --git a/location/java/com/android/internal/location/protocol/GLatLng.java b/core/java/com/android/internal/gadget/IGadgetHost.aidl
similarity index 64%
rename from location/java/com/android/internal/location/protocol/GLatLng.java
rename to core/java/com/android/internal/gadget/IGadgetHost.aidl
index 90e23df..a5b8654 100644
--- a/location/java/com/android/internal/location/protocol/GLatLng.java
+++ b/core/java/com/android/internal/gadget/IGadgetHost.aidl
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,10 +14,14 @@
  * limitations under the License.
  */
 
-package com.android.internal.location.protocol;
+package com.android.internal.gadget;
 
-public interface GLatLng {
-  static final int LAT_E7 = 1;
-  static final int LNG_E7 = 2;
+import android.content.ComponentName;
+import android.gadget.GadgetInfo;
+import android.widget.RemoteViews;
+
+/** {@hide} */
+oneway interface IGadgetHost {
+    void updateGadget(int gadgetId, in RemoteViews views);
 }
 
diff --git a/core/java/com/android/internal/gadget/IGadgetService.aidl b/core/java/com/android/internal/gadget/IGadgetService.aidl
index 6f9af04..1b3946f 100644
--- a/core/java/com/android/internal/gadget/IGadgetService.aidl
+++ b/core/java/com/android/internal/gadget/IGadgetService.aidl
@@ -18,12 +18,32 @@
 
 import android.content.ComponentName;
 import android.gadget.GadgetInfo;
+import com.android.internal.gadget.IGadgetHost;
+import android.widget.RemoteViews;
 
 /** {@hide} */
 interface IGadgetService {
-    int allocateGadgetId(String hostPackage);
+    
+    //
+    // for GadgetHost
+    //
+    int[] startListening(IGadgetHost host, String packageName, int hostId,
+            out List<RemoteViews> updatedViews);
+    void stopListening(int hostId);
+    int allocateGadgetId(String packageName, int hostId);
     void deleteGadgetId(int gadgetId);
-    void bindGadgetId(int gadgetId, in ComponentName provider);
-    GadgetInfo getGadgetInfo(int gadgetId);
+    void deleteHost(int hostId);
+    void deleteAllHosts();
+    RemoteViews getGadgetViews(int gadgetId);
+
+    //
+    // for GadgetManager
+    //
+    void updateGadgetIds(in int[] gadgetIds, in RemoteViews views);
+    void updateGadgetProvider(in ComponentName provider, in RemoteViews views);
     List<GadgetInfo> getInstalledProviders();
+    GadgetInfo getGadgetInfo(int gadgetId);
+    void bindGadgetId(int gadgetId, in ComponentName provider);
+
 }
+
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 8912960..cbb65dc 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -17,6 +17,7 @@
 package com.android.internal.os;
 
 import android.os.BatteryStats;
+import android.os.NetStat;
 import android.os.Parcel;
 import android.os.ParcelFormatException;
 import android.os.Parcelable;
@@ -28,9 +29,9 @@
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 
 /**
@@ -39,12 +40,14 @@
  * otherwise.
  */
 public final class BatteryStatsImpl extends BatteryStats implements Parcelable {
+    
+    private static final String TAG = "BatteryStatsImpl";
 
     // In-memory Parcel magic number, used to detect attempts to unmarshall bad data
     private static final int MAGIC = 0xBA757475; // 'BATSTATS' 
 
     // Current on-disk Parcel version
-    private static final int VERSION = 13;
+    private static final int VERSION = 15;
 
     private final File mFile;
     private final File mBackupFile;
@@ -77,7 +80,11 @@
     long mRealtime;
     long mRealtimeStart;
     long mLastRealtime;
-
+    
+    boolean mScreenOn;
+    long mLastScreenOnTimeMillis;
+    long mBatteryScreenOnTimeMillis;
+    long mPluggedScreenOnTimeMillis;
     /**
      * These provide time bases that discount the time the device is plugged
      * in to power.
@@ -87,6 +94,11 @@
     long mTrackBatteryUptimeStart;
     long mTrackBatteryPastRealtime;
     long mTrackBatteryRealtimeStart;
+    
+    long mUnpluggedBatteryUptime;
+    long mUnpluggedBatteryRealtime;
+    
+    HashSet<Integer> mGpsRequesters = new HashSet<Integer>();
 
     long mLastWriteTime = 0; // Milliseconds
 
@@ -255,14 +267,13 @@
             long realtime = SystemClock.elapsedRealtime() * 1000; 
             long heldTime = stats.getBatteryUptimeLocked(realtime) - mUpdateTime;
             if (heldTime > 0) {
-                mTotalTime += (heldTime * 1000) / mCount;
+                mTotalTime += heldTime / mCount;
             }
             mUpdateTime = stats.getBatteryUptimeLocked(realtime);
         }
 
         private long computeRunTimeLocked(long curBatteryUptime) {
-            return mTotalTime +
-                (mNesting > 0 ? ((curBatteryUptime * 1000) - mUpdateTime) / mCount : 0);
+            return mTotalTime + (mNesting > 0 ? (curBatteryUptime - mUpdateTime) / mCount : 0);
         }
 
         void writeSummaryFromParcelLocked(Parcel out, long curBatteryUptime) {
@@ -284,6 +295,15 @@
         }
     }
     
+    public void unplugTcpCounters() {
+        final int NU = mUidStats.size();
+        for (int iu = 0; iu < NU; iu++) {
+            Uid u = mUidStats.valueAt(iu);
+            u.mTcpBytesReceivedAtLastUnplug = u.getTcpBytesReceived(STATS_TOTAL);
+            u.mTcpBytesSentAtLastUnplug = u.getTcpBytesSent(STATS_TOTAL);
+        }
+    }
+    
     public void unplugTimers() {
         ArrayList<Timer> timers;
         
@@ -305,6 +325,69 @@
         }
     }
     
+    public void noteStartGps(int uid) {
+        mGpsRequesters.add(uid);
+        mUidStats.get(uid).noteStartGps();
+    }
+    
+    public void noteStopGps(int uid) {
+        mGpsRequesters.remove(uid);
+        mUidStats.get(uid).noteStopGps();
+    }
+    
+    public void noteRequestGpsOn(int uid) {
+        mGpsRequesters.add(uid);
+        mUidStats.get(uid).noteStartGps();
+    }
+    
+    public void noteRequestGpsOff(int uid) {
+        mGpsRequesters.remove(uid);
+        mUidStats.get(uid).noteStopGps();
+    }
+    
+    /**
+     * When the device screen or battery state changes, update the appropriate "screen on time"
+     * counter.
+     */
+    private void updateScreenOnTime(boolean screenOn) {
+        if (!mScreenOn) {
+            Log.w(TAG, "updateScreenOnTime without mScreenOn, ignored");
+            return;
+        }
+        long now = SystemClock.elapsedRealtime();
+        long elapsed = now - mLastScreenOnTimeMillis;
+        if (mOnBattery) {
+            mBatteryScreenOnTimeMillis += elapsed;
+        } else {
+            mPluggedScreenOnTimeMillis += elapsed;
+        }
+        if (screenOn) {
+            mLastScreenOnTimeMillis = now;
+        }
+    }
+    
+    public void noteScreenOn() {
+        mScreenOn = true;
+        mLastScreenOnTimeMillis = SystemClock.elapsedRealtime();
+    }
+    
+    public void noteScreenOff() {
+        if (!mScreenOn) {
+            Log.w(TAG, "noteScreenOff without mScreenOn, ignored");
+            return;
+        }
+        updateScreenOnTime(false);
+        mScreenOn = false;
+    }
+    
+    @Override public long getBatteryScreenOnTime() {
+        return mBatteryScreenOnTimeMillis;
+    }
+    
+    @Override public long getPluggedScreenOnTime() {
+        return mPluggedScreenOnTimeMillis;
+    }
+    
     @Override
     public SparseArray<? extends BatteryStats.Uid> getUidStats() {
         return mUidStats;
@@ -314,6 +397,14 @@
      * The statistics associated with a particular uid.
      */
     public final class Uid extends BatteryStats.Uid {
+        
+        final int mUid;
+        long mLoadedTcpBytesReceived;
+        long mLoadedTcpBytesSent;
+        long mTcpBytesReceivedAtLastUnplug;
+        long mTcpBytesSentAtLastUnplug;
+        
+        private final byte[] mBuf = new byte[16];
 
         /**
          * The statistics we have collected for this uid's wake locks.
@@ -334,6 +425,10 @@
          * The statistics we have collected for this uid's processes.
          */
         final HashMap<String, Pkg> mPackageStats = new HashMap<String, Pkg>();
+        
+        public Uid(int uid) {
+            mUid = uid;
+        }
 
         @Override
         public Map<String, ? extends BatteryStats.Uid.Wakelock> getWakelockStats() {
@@ -354,6 +449,42 @@
         public Map<String, ? extends BatteryStats.Uid.Pkg> getPackageStats() {
             return mPackageStats;
         }
+        
+        public int getUid() {
+            return mUid;
+        }
+        
+        public long getTcpBytesReceived(int which) {
+            long current = NetStat.getUidRxBytes(mUid);
+            
+            if (which == STATS_CURRENT) {
+                return current;
+            } else if (which == STATS_LAST) {
+                return mLoadedTcpBytesReceived;
+            } else if (which == STATS_UNPLUGGED) {
+                return current - mTcpBytesReceivedAtLastUnplug;
+            } else if (which == STATS_TOTAL) {
+                return mLoadedTcpBytesReceived + current;
+            } else {
+                throw new IllegalArgumentException("which = " + which);
+            }
+        }
+        
+        public long getTcpBytesSent(int which) {
+            long current = NetStat.getUidTxBytes(mUid);
+
+            if (which == STATS_CURRENT) {
+                return current;
+            } else if (which == STATS_LAST) {
+                return mLoadedTcpBytesSent;
+            } else if (which == STATS_UNPLUGGED) {
+                return current - mTcpBytesSentAtLastUnplug;
+            } else if (which == STATS_TOTAL) {
+                return mLoadedTcpBytesSent + current;
+            } else {
+                throw new IllegalArgumentException("which = " + which);
+            }
+        }
 
         void writeToParcelLocked(Parcel out) {
             out.writeInt(mWakelockStats.size());
@@ -366,6 +497,7 @@
             out.writeInt(mSensorStats.size());
             for (Map.Entry<Integer, Uid.Sensor> sensorEntry : mSensorStats.entrySet()) {
                 out.writeInt(sensorEntry.getKey());
+                out.writeString(sensorEntry.getValue().getName());
                 Uid.Sensor sensor = sensorEntry.getValue();
                 sensor.writeToParcelLocked(out);
             }
@@ -383,6 +515,11 @@
                 Uid.Pkg pkg = pkgEntry.getValue();
                 pkg.writeToParcelLocked(out);
             }
+            
+            out.writeLong(mLoadedTcpBytesReceived);
+            out.writeLong(mLoadedTcpBytesSent);
+            out.writeLong(mTcpBytesReceivedAtLastUnplug);
+            out.writeLong(mTcpBytesSentAtLastUnplug);
         }
 
         void readFromParcelLocked(Parcel in) {
@@ -399,7 +536,8 @@
             mSensorStats.clear();
             for (int k = 0; k < numSensors; k++) {
                 int sensorNumber = in.readInt();
-                Uid.Sensor sensor = new Sensor();
+                String name = in.readString();
+                Uid.Sensor sensor = new Sensor(name);
                 sensor.readFromParcelLocked(in);
                 mSensorStats.put(sensorNumber, sensor);
             }
@@ -421,6 +559,11 @@
                 pkg.readFromParcelLocked(in);
                 mPackageStats.put(packageName, pkg);
             }
+            
+            mLoadedTcpBytesReceived = in.readLong();
+            mLoadedTcpBytesSent = in.readLong();
+            mTcpBytesReceivedAtLastUnplug = in.readLong();
+            mTcpBytesSentAtLastUnplug = in.readLong();
         }
 
         /**
@@ -499,7 +642,13 @@
         }
 
         public final class Sensor extends BatteryStats.Uid.Sensor {
+            static final int GPS = -10000; // Treat GPS as a sensor
+            final String mName;
             Timer sensorTime;
+            
+            public Sensor(String name) {
+                mName = name;
+            }
 
             private Timer readTimerFromParcel(Parcel in) {
                 if (in.readInt() == 0) {
@@ -530,6 +679,10 @@
             public Timer getSensorTime() {
                 return sensorTime;
             }
+            
+            public String getName() {
+                return mName;
+            }
         }
 
         /**
@@ -1039,19 +1192,19 @@
             }
         }
 
-        public Timer getSensorTimerLocked(int sensor, boolean create) {
+        public Timer getSensorTimerLocked(String name, int sensor, boolean create) {
             Integer sId = Integer.valueOf(sensor);
             Sensor se = mSensorStats.get(sId);
             if (se == null) {
                 if (!create) {
                     return null;
                 }
-                se = new Sensor();
+                se = new Sensor(name);
                 mSensorStats.put(sId, se);
             }
             Timer t = se.sensorTime;
             if (t == null) {
-                t = new Timer(0, mSensorTimers);
+                t = new Timer(BatteryStats.SENSOR, mSensorTimers);
                 se.sensorTime = t;
             }
             return t;
@@ -1071,20 +1224,34 @@
             }
         }
         
-        public void noteStartSensor(int sensor) {
-            Timer t = getSensorTimerLocked(sensor, true);
+        public void noteStartSensor(String name, int sensor) {
+            Timer t = getSensorTimerLocked(name, sensor, true);
             if (t != null) {
                 t.startRunningLocked(BatteryStatsImpl.this);
             }            
         }
 
-        public void noteStopSensor(int sensor) {
+        public void noteStopSensor(String name, int sensor) {
             // Don't create a timer if one doesn't already exist
-            Timer t = getSensorTimerLocked(sensor, false);
+            Timer t = getSensorTimerLocked(name, sensor, false);
             if (t != null) {
                 t.stopRunningLocked(BatteryStatsImpl.this);
             }            
         }
+        
+        public void noteStartGps() {
+            Timer t = getSensorTimerLocked("GPS", Sensor.GPS, true);
+            if (t != null) {
+                t.startRunningLocked(BatteryStatsImpl.this);
+            }  
+        }
+        
+        public void noteStopGps() {
+            Timer t = getSensorTimerLocked("GPS", Sensor.GPS, false);
+            if (t != null) {
+                t.stopRunningLocked(BatteryStatsImpl.this);
+            }  
+        }
 
         public BatteryStatsImpl getBatteryStats() {
             return BatteryStatsImpl.this;
@@ -1100,6 +1267,9 @@
         mTrackBatteryPastRealtime = 0;
         mUptimeStart = mTrackBatteryUptimeStart = SystemClock.uptimeMillis() * 1000;
         mRealtimeStart = mTrackBatteryRealtimeStart = SystemClock.elapsedRealtime() * 1000;
+        
+        mUnpluggedBatteryUptime = getBatteryUptimeLocked(mUptimeStart);
+        mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(mRealtimeStart);
     }
 
     public BatteryStatsImpl(Parcel p) {
@@ -1119,13 +1289,21 @@
     public void setOnBattery(boolean onBattery) {
         synchronized(this) {
             if (mOnBattery != onBattery) {
+                if (mScreenOn) {
+                    updateScreenOnTime(true);
+                }
+                
                 long uptime = SystemClock.uptimeMillis() * 1000;
                 long mSecRealtime = SystemClock.elapsedRealtime();
                 long realtime = mSecRealtime * 1000;
                 if (onBattery) {
-                    mTrackBatteryUptimeStart = uptime;
-                    mTrackBatteryRealtimeStart = realtime;
+                    mTrackBatteryUptimeStart = getBatteryUptime(uptime);
+                    mTrackBatteryRealtimeStart = getBatteryRealtime(realtime);
+                    unplugTcpCounters();
                     unplugTimers();
+                    
+                    mUnpluggedBatteryUptime = getBatteryUptime(uptime);
+                    mUnpluggedBatteryRealtime = getBatteryRealtime(realtime);
                 } else {
                     mTrackBatteryPastUptime += uptime - mTrackBatteryUptimeStart;
                     mTrackBatteryPastRealtime += realtime - mTrackBatteryRealtimeStart;
@@ -1172,14 +1350,16 @@
 
     @Override
     public long computeBatteryUptime(long curTime, int which) {
+        long uptime = getBatteryUptime(curTime);
         switch (which) {
         case STATS_TOTAL:
-            return mBatteryUptime + getBatteryUptime(curTime);
+            return mBatteryUptime + uptime;
         case STATS_LAST:
             return mBatteryLastUptime;
         case STATS_CURRENT:
+            return uptime;
         case STATS_UNPLUGGED:
-            return getBatteryUptime(curTime);
+            return uptime - mUnpluggedBatteryUptime;
         }
         return 0;
     }
@@ -1192,8 +1372,9 @@
         case STATS_LAST:
             return mBatteryLastRealtime;
         case STATS_CURRENT:
-        case STATS_UNPLUGGED:
             return getBatteryRealtimeLocked(curTime);
+        case STATS_UNPLUGGED:
+            return getBatteryRealtimeLocked(curTime) - mUnpluggedBatteryRealtime;
         }
         return 0;
     }
@@ -1234,7 +1415,7 @@
     public Uid getUidStatsLocked(int uid) {
         Uid u = mUidStats.get(uid);
         if (u == null) {
-            u = new Uid();
+            u = new Uid(uid);
             mUidStats.put(uid, u);
         }
         return u;
@@ -1246,7 +1427,7 @@
     public void removeUidStatsLocked(int uid) {
         mUidStats.remove(uid);
     }
-
+    
     /**
      * Retrieve the statistics object for a particular process, creating
      * if needed.
@@ -1388,15 +1569,21 @@
         mRealtime = in.readLong();
         mLastRealtime = in.readLong();
         mStartCount++;
+        
+        if (version >= 14) {
+            mBatteryScreenOnTimeMillis = in.readLong();
+            mPluggedScreenOnTimeMillis = in.readLong();
+            mScreenOn = false;
+        }
 
         final int NU = in.readInt();
-        for (int iu=0; iu<NU; iu++) {
+        for (int iu = 0; iu < NU; iu++) {
             int uid = in.readInt();
-            Uid u = new Uid();
+            Uid u = new Uid(uid);
             mUidStats.put(uid, u);
 
             int NW = in.readInt();
-            for (int iw=0; iw<NW; iw++) {
+            for (int iw = 0; iw < NW; iw++) {
                 String wlName = in.readString();
                 if (in.readInt() != 0) {
                     u.getWakeTimerLocked(wlName, WAKE_TYPE_FULL).readSummaryFromParcelLocked(in);
@@ -1411,16 +1598,21 @@
 
             if (version >= 12) {
                 int NSE = in.readInt();
-                for (int is=0; is<NSE; is++) {
+                for (int is = 0; is < NSE; is++) {
                     int seNumber = in.readInt();
+                    String seName = "<unknown>";
+                    if (version >= 14) {
+                        seName = in.readString();
+                    }
                     if (in.readInt() != 0) {
-                        u.getSensorTimerLocked(seNumber, true).readSummaryFromParcelLocked(in);
+                        u.getSensorTimerLocked(seName, seNumber, true)
+                                .readSummaryFromParcelLocked(in);
                     }
                 }
             }
 
             int NP = in.readInt();
-            for (int ip=0; ip<NP; ip++) {
+            for (int ip = 0; ip < NP; ip++) {
                 String procName = in.readString();
                 Uid.Proc p = u.getProcessStatsLocked(procName);
                 p.mUserTime = p.mLoadedUserTime = in.readLong();
@@ -1432,13 +1624,13 @@
             }
 
             NP = in.readInt();
-            for (int ip=0; ip<NP; ip++) {
+            for (int ip = 0; ip < NP; ip++) {
                 String pkgName = in.readString();
                 Uid.Pkg p = u.getPackageStatsLocked(pkgName);
                 p.mWakeups = p.mLoadedWakeups = in.readInt();
                 p.mLastWakeups = in.readInt();
                 final int NS = in.readInt();
-                for (int is=0; is<NS; is++) {
+                for (int is = 0; is < NS; is++) {
                     String servName = in.readString();
                     Uid.Pkg.Serv s = u.getServiceStatsLocked(pkgName, servName);
                     s.mStartTime = s.mLoadedStartTime = in.readLong();
@@ -1449,6 +1641,11 @@
                     s.mLastLaunches = in.readInt();
                 }
             }
+
+            if (version >= 14) {
+                u.mLoadedTcpBytesReceived = in.readLong();
+                u.mLoadedTcpBytesSent = in.readLong();
+            }
         }
     }
 
@@ -1474,10 +1671,13 @@
         out.writeLong(computeUptime(NOW_SYS, STATS_CURRENT));
         out.writeLong(computeRealtime(NOWREAL_SYS, STATS_TOTAL));
         out.writeLong(computeRealtime(NOWREAL_SYS, STATS_CURRENT));
+        
+        out.writeLong(mBatteryScreenOnTimeMillis);
+        out.writeLong(mPluggedScreenOnTimeMillis);
 
         final int NU = mUidStats.size();
         out.writeInt(NU);
-        for (int iu=0; iu<NU; iu++) {
+        for (int iu = 0; iu < NU; iu++) {
             out.writeInt(mUidStats.keyAt(iu));
             Uid u = mUidStats.valueAt(iu);
 
@@ -1516,6 +1716,7 @@
                     : u.mSensorStats.entrySet()) {
                     out.writeInt(ent.getKey());
                     Uid.Sensor se = ent.getValue();
+                    out.writeString(se.getName());
                     if (se.sensorTime != null) {
                         out.writeInt(1);
                         se.sensorTime.writeSummaryFromParcelLocked(out, NOW);
@@ -1568,6 +1769,9 @@
                     }
                 }
             }
+            
+            out.writeLong(u.getTcpBytesReceived(STATS_TOTAL));
+            out.writeLong(u.getTcpBytesSent(STATS_TOTAL));
         }
     }
 
@@ -1586,6 +1790,9 @@
         mBatteryLastUptime = in.readLong();
         mBatteryRealtime = in.readLong();
         mBatteryLastRealtime = in.readLong();
+        mBatteryScreenOnTimeMillis = in.readLong();
+        mPluggedScreenOnTimeMillis = in.readLong();
+        mScreenOn = false;
         mUptime = in.readLong();
         mUptimeStart = in.readLong();
         mLastUptime = in.readLong();
@@ -1606,10 +1813,10 @@
         int numUids = in.readInt();
         mUidStats.clear();
         for (int i = 0; i < numUids; i++) {
-            int key = in.readInt();
-            Uid uid = new Uid();
-            uid.readFromParcelLocked(in);
-            mUidStats.append(key, uid);
+            int uid = in.readInt();
+            Uid u = new Uid(uid);
+            u.readFromParcelLocked(in);
+            mUidStats.append(uid, u);
         }
     }
 
@@ -1625,6 +1832,8 @@
         out.writeLong(mBatteryLastUptime);
         out.writeLong(mBatteryRealtime);
         out.writeLong(mBatteryLastRealtime);
+        out.writeLong(mBatteryScreenOnTimeMillis);
+        out.writeLong(mPluggedScreenOnTimeMillis);
         out.writeLong(mUptime);
         out.writeLong(mUptimeStart);
         out.writeLong(mLastUptime);
diff --git a/core/java/com/android/internal/os/HandlerCaller.java b/core/java/com/android/internal/os/HandlerCaller.java
index 1ec74a1..bab1e21 100644
--- a/core/java/com/android/internal/os/HandlerCaller.java
+++ b/core/java/com/android/internal/os/HandlerCaller.java
@@ -21,7 +21,8 @@
         
         public Object arg1;
         public Object arg2;
-        Object arg3;
+        public Object arg3;
+        public Object arg4;
         public int argi1;
         public int argi2;
         public int argi3;
@@ -149,6 +150,16 @@
         return mH.obtainMessage(what, 0, 0, args);
     }
     
+    public Message obtainMessageOOOO(int what, Object arg1, Object arg2,
+            Object arg3, Object arg4) {
+        SomeArgs args = obtainArgs();
+        args.arg1 = arg1;
+        args.arg2 = arg2;
+        args.arg3 = arg3;
+        args.arg4 = arg4;
+        return mH.obtainMessage(what, 0, 0, args);
+    }
+    
     public Message obtainMessageIIII(int what, int arg1, int arg2,
             int arg3, int arg4) {
         SomeArgs args = obtainArgs();
diff --git a/core/res/res/drawable/checkbox_background.xml b/core/java/com/android/internal/os/PkgUsageStats.aidl
old mode 100644
new mode 100755
similarity index 70%
copy from core/res/res/drawable/checkbox_background.xml
copy to core/java/com/android/internal/os/PkgUsageStats.aidl
index 68bb178..8305271
--- a/core/res/res/drawable/checkbox_background.xml
+++ b/core/java/com/android/internal/os/PkgUsageStats.aidl
@@ -1,6 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/common/res/drawable/checkbox_background.xml
+/* //device/java/android/android/content/Intent.aidl
 **
 ** Copyright 2007, The Android Open Source Project
 **
@@ -16,8 +14,7 @@
 ** See the License for the specific language governing permissions and 
 ** limitations under the License.
 */
--->
 
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:drawable="@drawable/checkbox_label_background" />
-</selector>
+package com.android.internal.os;
+
+parcelable PkgUsageStats;
diff --git a/core/java/com/android/internal/os/PkgUsageStats.java b/core/java/com/android/internal/os/PkgUsageStats.java
new file mode 100755
index 0000000..e847878
--- /dev/null
+++ b/core/java/com/android/internal/os/PkgUsageStats.java
@@ -0,0 +1,60 @@
+package com.android.internal.os;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * implementation of PkgUsageStats associated with an
+ * application package.
+ *  @hide
+ */
+public class PkgUsageStats implements Parcelable {
+    public String packageName;
+    public int launchCount;
+    public long usageTime;
+    
+    public static final Parcelable.Creator<PkgUsageStats> CREATOR
+    = new Parcelable.Creator<PkgUsageStats>() {
+        public PkgUsageStats createFromParcel(Parcel in) {
+            return new PkgUsageStats(in);
+        }
+
+        public PkgUsageStats[] newArray(int size) {
+            return new PkgUsageStats[size];
+        }
+    };
+    
+    public String toString() {
+        return "PkgUsageStats{"
+        + Integer.toHexString(System.identityHashCode(this))
+        + " " + packageName + "}";
+    }
+    
+    public PkgUsageStats(String pkgName, int count, long time) {
+        packageName = pkgName;
+        launchCount = count;
+        usageTime = time;
+    }
+    
+    public PkgUsageStats(Parcel source) {
+        packageName = source.readString();
+        launchCount = source.readInt();
+        usageTime = source.readLong();
+    }
+    
+    public PkgUsageStats(PkgUsageStats pStats) {
+        packageName = pStats.packageName;
+        launchCount = pStats.launchCount;
+        usageTime = pStats.usageTime;
+    }
+
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int parcelableFlags){
+        dest.writeString(packageName);
+        dest.writeInt(launchCount);
+        dest.writeLong(usageTime);
+    }
+}
diff --git a/core/java/com/android/internal/os/RecoverySystem.java b/core/java/com/android/internal/os/RecoverySystem.java
new file mode 100644
index 0000000..c938610
--- /dev/null
+++ b/core/java/com/android/internal/os/RecoverySystem.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.os;
+
+import android.os.FileUtils;
+import android.os.Power;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Utility class for interacting with the Android recovery partition.
+ * The recovery partition is a small standalone system which can perform
+ * operations that are difficult while the main system is running, like
+ * upgrading system software or reformatting the data partition.
+ * Note that most of these operations must be run as root.
+ *
+ * @hide
+ */
+public class RecoverySystem {
+    private static final String TAG = "RecoverySystem";  // for logging
+
+    // Used to communicate with recovery.  See commands/recovery/recovery.c.
+    private static File RECOVERY_DIR = new File("/cache/recovery");
+    private static File COMMAND_FILE = new File(RECOVERY_DIR, "command");
+    private static File LOG_FILE = new File(RECOVERY_DIR, "log");
+
+    // Length limits for reading files.
+    private static int LOG_FILE_MAX_LENGTH = 8 * 1024;
+
+    /**
+     * Reboot into the recovery system to install a system update.
+     * @param update package to install (must be in /cache or /data).
+     * @throws IOException if something goes wrong.
+     */
+    public static void rebootAndUpdate(File update) throws IOException {
+        String path = update.getCanonicalPath();
+        if (path.startsWith("/cache/")) {
+            path = "CACHE:" + path.substring(7);
+        } else if (path.startsWith("/data/")) {
+            path = "DATA:" + path.substring(6);
+        } else {
+            throw new IllegalArgumentException(
+                    "Must start with /cache or /data: " + path);
+        }
+        bootCommand("--update_package=" + path);
+    }
+
+    /**
+     * Reboot into the recovery system to wipe the /data partition.
+     * @param extras to add to the RECOVERY_COMPLETED intent after rebooting.
+     * @throws IOException if something goes wrong.
+     */
+    public static void rebootAndWipe() throws IOException {
+        bootCommand("--wipe_data");
+    }
+
+    /**
+     * Reboot into the recovery system with the supplied argument.
+     * @param arg to pass to the recovery utility.
+     * @throws IOException if something goes wrong.
+     */
+    private static void bootCommand(String arg) throws IOException {
+        RECOVERY_DIR.mkdirs();  // In case we need it
+        COMMAND_FILE.delete();  // In case it's not writable
+        LOG_FILE.delete();
+
+        FileWriter command = new FileWriter(COMMAND_FILE);
+        try {
+            command.write(arg);
+            command.write("\n");
+        } finally {
+            command.close();
+        }
+
+        // Having written the command file, go ahead and reboot
+        Power.reboot("recovery");
+        throw new IOException("Reboot failed (no permissions?)");
+    }
+
+    /**
+     * Called after booting to process and remove recovery-related files.
+     * @return the log file from recovery, or null if none was found.
+     */
+    public static String handleAftermath() {
+        // Record the tail of the LOG_FILE
+        String log = null;
+        try {
+            log = FileUtils.readTextFile(LOG_FILE, -LOG_FILE_MAX_LENGTH, "...\n");
+        } catch (FileNotFoundException e) {
+            Log.i(TAG, "No recovery log file");
+        } catch (IOException e) {
+            Log.e(TAG, "Error reading recovery log", e);
+        }
+
+        // Delete everything in RECOVERY_DIR
+        String[] names = RECOVERY_DIR.list();
+        for (int i = 0; names != null && i < names.length; i++) {
+            File f = new File(RECOVERY_DIR, names[i]);
+            if (!f.delete()) {
+                Log.e(TAG, "Can't delete: " + f);
+            } else {
+                Log.i(TAG, "Deleted: " + f);
+            }
+        }
+
+        return log;
+    }
+}
diff --git a/core/java/com/android/internal/view/IInputConnectionWrapper.java b/core/java/com/android/internal/view/IInputConnectionWrapper.java
index 011e944..b0b00b2 100644
--- a/core/java/com/android/internal/view/IInputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/IInputConnectionWrapper.java
@@ -13,6 +13,8 @@
 import android.view.inputmethod.ExtractedTextRequest;
 import android.view.inputmethod.InputConnection;
 
+import java.lang.ref.WeakReference;
+
 public class IInputConnectionWrapper extends IInputContext.Stub {
     static final String TAG = "IInputConnectionWrapper";
     
@@ -22,6 +24,8 @@
     private static final int DO_GET_EXTRACTED_TEXT = 40;
     private static final int DO_COMMIT_TEXT = 50;
     private static final int DO_COMMIT_COMPLETION = 55;
+    private static final int DO_SET_SELECTION = 57;
+    private static final int DO_PERFORM_CONTEXT_MENU_ACTION = 58;
     private static final int DO_SET_COMPOSING_TEXT = 60;
     private static final int DO_FINISH_COMPOSING_TEXT = 65;
     private static final int DO_SEND_KEY_EVENT = 70;
@@ -33,7 +37,7 @@
     private static final int DO_PERFORM_PRIVATE_COMMAND = 120;
     private static final int DO_CLEAR_META_KEY_STATES = 130;
         
-    private InputConnection mInputConnection;
+    private WeakReference<InputConnection> mInputConnection;
 
     private Looper mMainLooper;
     private Handler mH;
@@ -57,17 +61,21 @@
     }
     
     public IInputConnectionWrapper(Looper mainLooper, InputConnection conn) {
-        mInputConnection = conn;
+        mInputConnection = new WeakReference<InputConnection>(conn);
         mMainLooper = mainLooper;
         mH = new MyHandler(mMainLooper);
     }
 
-    public void getTextAfterCursor(int length, int seq, IInputContextCallback callback) {
-        dispatchMessage(obtainMessageISC(DO_GET_TEXT_AFTER_CURSOR, length, seq, callback));
+    public boolean isActive() {
+        return true;
     }
     
-    public void getTextBeforeCursor(int length, int seq, IInputContextCallback callback) {
-        dispatchMessage(obtainMessageISC(DO_GET_TEXT_BEFORE_CURSOR, length, seq, callback));
+    public void getTextAfterCursor(int length, int flags, int seq, IInputContextCallback callback) {
+        dispatchMessage(obtainMessageIISC(DO_GET_TEXT_AFTER_CURSOR, length, flags, seq, callback));
+    }
+    
+    public void getTextBeforeCursor(int length, int flags, int seq, IInputContextCallback callback) {
+        dispatchMessage(obtainMessageIISC(DO_GET_TEXT_BEFORE_CURSOR, length, flags, seq, callback));
     }
 
     public void getCursorCapsMode(int reqModes, int seq, IInputContextCallback callback) {
@@ -88,6 +96,14 @@
         dispatchMessage(obtainMessageO(DO_COMMIT_COMPLETION, text));
     }
 
+    public void setSelection(int start, int end) {
+        dispatchMessage(obtainMessageII(DO_SET_SELECTION, start, end));
+    }
+
+    public void performContextMenuAction(int id) {
+        dispatchMessage(obtainMessageII(DO_PERFORM_CONTEXT_MENU_ACTION, id, 0));
+    }
+    
     public void setComposingText(CharSequence text, int newCursorPosition) {
         dispatchMessage(obtainMessageIO(DO_SET_COMPOSING_TEXT, newCursorPosition, text));
     }
@@ -147,8 +163,14 @@
             case DO_GET_TEXT_AFTER_CURSOR: {
                 SomeArgs args = (SomeArgs)msg.obj;
                 try {
-                    args.callback.setTextAfterCursor(mInputConnection.getTextAfterCursor(msg.arg1),
-                            args.seq);
+                    InputConnection ic = mInputConnection.get();
+                    if (ic == null || !isActive()) {
+                        Log.w(TAG, "getTextAfterCursor on inactive InputConnection");
+                        args.callback.setTextAfterCursor(null, args.seq);
+                        return;
+                    }
+                    args.callback.setTextAfterCursor(ic.getTextAfterCursor(
+                            msg.arg1, msg.arg2), args.seq);
                 } catch (RemoteException e) {
                     Log.w(TAG, "Got RemoteException calling setTextAfterCursor", e);
                 }
@@ -157,8 +179,14 @@
             case DO_GET_TEXT_BEFORE_CURSOR: {
                 SomeArgs args = (SomeArgs)msg.obj;
                 try {
-                    args.callback.setTextBeforeCursor(mInputConnection.getTextBeforeCursor(msg.arg1),
-                            args.seq);
+                    InputConnection ic = mInputConnection.get();
+                    if (ic == null || !isActive()) {
+                        Log.w(TAG, "getTextBeforeCursor on inactive InputConnection");
+                        args.callback.setTextBeforeCursor(null, args.seq);
+                        return;
+                    }
+                    args.callback.setTextBeforeCursor(ic.getTextBeforeCursor(
+                            msg.arg1, msg.arg2), args.seq);
                 } catch (RemoteException e) {
                     Log.w(TAG, "Got RemoteException calling setTextBeforeCursor", e);
                 }
@@ -167,7 +195,13 @@
             case DO_GET_CURSOR_CAPS_MODE: {
                 SomeArgs args = (SomeArgs)msg.obj;
                 try {
-                    args.callback.setCursorCapsMode(mInputConnection.getCursorCapsMode(msg.arg1),
+                    InputConnection ic = mInputConnection.get();
+                    if (ic == null || !isActive()) {
+                        Log.w(TAG, "getCursorCapsMode on inactive InputConnection");
+                        args.callback.setCursorCapsMode(0, args.seq);
+                        return;
+                    }
+                    args.callback.setCursorCapsMode(ic.getCursorCapsMode(msg.arg1),
                             args.seq);
                 } catch (RemoteException e) {
                     Log.w(TAG, "Got RemoteException calling setCursorCapsMode", e);
@@ -177,7 +211,13 @@
             case DO_GET_EXTRACTED_TEXT: {
                 SomeArgs args = (SomeArgs)msg.obj;
                 try {
-                    args.callback.setExtractedText(mInputConnection.getExtractedText(
+                    InputConnection ic = mInputConnection.get();
+                    if (ic == null || !isActive()) {
+                        Log.w(TAG, "getExtractedText on inactive InputConnection");
+                        args.callback.setExtractedText(null, args.seq);
+                        return;
+                    }
+                    args.callback.setExtractedText(ic.getExtractedText(
                             (ExtractedTextRequest)args.arg1, msg.arg1), args.seq);
                 } catch (RemoteException e) {
                     Log.w(TAG, "Got RemoteException calling setExtractedText", e);
@@ -185,52 +225,130 @@
                 return;
             }
             case DO_COMMIT_TEXT: {
-                mInputConnection.commitText((CharSequence)msg.obj, msg.arg1);
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "commitText on inactive InputConnection");
+                    return;
+                }
+                ic.commitText((CharSequence)msg.obj, msg.arg1);
+                return;
+            }
+            case DO_SET_SELECTION: {
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "setSelection on inactive InputConnection");
+                    return;
+                }
+                ic.setSelection(msg.arg1, msg.arg2);
+                return;
+            }
+            case DO_PERFORM_CONTEXT_MENU_ACTION: {
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "performContextMenuAction on inactive InputConnection");
+                    return;
+                }
+                ic.performContextMenuAction(msg.arg1);
                 return;
             }
             case DO_COMMIT_COMPLETION: {
-                mInputConnection.commitCompletion((CompletionInfo)msg.obj);
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "commitCompletion on inactive InputConnection");
+                    return;
+                }
+                ic.commitCompletion((CompletionInfo)msg.obj);
                 return;
             }
             case DO_SET_COMPOSING_TEXT: {
-                mInputConnection.setComposingText((CharSequence)msg.obj, msg.arg1);
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "setComposingText on inactive InputConnection");
+                    return;
+                }
+                ic.setComposingText((CharSequence)msg.obj, msg.arg1);
                 return;
             }
             case DO_FINISH_COMPOSING_TEXT: {
-                mInputConnection.finishComposingText();
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "finishComposingText on inactive InputConnection");
+                    return;
+                }
+                ic.finishComposingText();
                 return;
             }
             case DO_SEND_KEY_EVENT: {
-                mInputConnection.sendKeyEvent((KeyEvent)msg.obj);
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "sendKeyEvent on inactive InputConnection");
+                    return;
+                }
+                ic.sendKeyEvent((KeyEvent)msg.obj);
                 return;
             }
             case DO_CLEAR_META_KEY_STATES: {
-                mInputConnection.clearMetaKeyStates(msg.arg1);
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "clearMetaKeyStates on inactive InputConnection");
+                    return;
+                }
+                ic.clearMetaKeyStates(msg.arg1);
                 return;
             }
             case DO_DELETE_SURROUNDING_TEXT: {
-                mInputConnection.deleteSurroundingText(msg.arg1, msg.arg2);
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "deleteSurroundingText on inactive InputConnection");
+                    return;
+                }
+                ic.deleteSurroundingText(msg.arg1, msg.arg2);
                 return;
             }
             case DO_BEGIN_BATCH_EDIT: {
-                mInputConnection.beginBatchEdit();
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "beginBatchEdit on inactive InputConnection");
+                    return;
+                }
+                ic.beginBatchEdit();
                 return;
             }
             case DO_END_BATCH_EDIT: {
-                mInputConnection.beginBatchEdit();
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "endBatchEdit on inactive InputConnection");
+                    return;
+                }
+                ic.endBatchEdit();
                 return;
             }
             case DO_HIDE_STATUS_ICON: {
-                mInputConnection.hideStatusIcon();
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "hideStatusIcon on inactive InputConnection");
+                    return;
+                }
+                ic.hideStatusIcon();
                 return;
             }
             case DO_SHOW_STATUS_ICON: {
-                mInputConnection.showStatusIcon((String)msg.obj, msg.arg1);
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "showStatusIcon on inactive InputConnection");
+                    return;
+                }
+                ic.showStatusIcon((String)msg.obj, msg.arg1);
                 return;
             }
             case DO_PERFORM_PRIVATE_COMMAND: {
+                InputConnection ic = mInputConnection.get();
+                if (ic == null || !isActive()) {
+                    Log.w(TAG, "performPrivateCommand on inactive InputConnection");
+                    return;
+                }
                 SomeArgs args = (SomeArgs)msg.obj;
-                mInputConnection.performPrivateCommand((String)args.arg1,
+                ic.performPrivateCommand((String)args.arg1,
                         (Bundle)args.arg2);
                 return;
             }
@@ -257,6 +375,13 @@
         return mH.obtainMessage(what, arg1, 0, args);
     }
     
+    Message obtainMessageIISC(int what, int arg1, int arg2, int seq, IInputContextCallback callback) {
+        SomeArgs args = new SomeArgs();
+        args.callback = callback;
+        args.seq = seq;
+        return mH.obtainMessage(what, arg1, arg2, args);
+    }
+    
     Message obtainMessageIOSC(int what, int arg1, Object arg2, int seq,
             IInputContextCallback callback) {
         SomeArgs args = new SomeArgs();
diff --git a/core/java/com/android/internal/view/IInputContext.aidl b/core/java/com/android/internal/view/IInputContext.aidl
index b048ce2..7cc8ada 100644
--- a/core/java/com/android/internal/view/IInputContext.aidl
+++ b/core/java/com/android/internal/view/IInputContext.aidl
@@ -29,9 +29,9 @@
  * {@hide}
  */
  oneway interface IInputContext {
-    void getTextBeforeCursor(int length, int seq, IInputContextCallback callback); 
+    void getTextBeforeCursor(int length, int flags, int seq, IInputContextCallback callback); 
 
-    void getTextAfterCursor(int length, int seq, IInputContextCallback callback);
+    void getTextAfterCursor(int length, int flags, int seq, IInputContextCallback callback);
     
     void getCursorCapsMode(int reqModes, int seq, IInputContextCallback callback);
     
@@ -48,6 +48,10 @@
 
     void commitCompletion(in CompletionInfo completion);
 
+    void setSelection(int start, int end);
+    
+    void performContextMenuAction(int id);
+    
     void beginBatchEdit();
     
     void endBatchEdit();
diff --git a/core/java/com/android/internal/view/IInputMethod.aidl b/core/java/com/android/internal/view/IInputMethod.aidl
index f650713..9b00402 100644
--- a/core/java/com/android/internal/view/IInputMethod.aidl
+++ b/core/java/com/android/internal/view/IInputMethod.aidl
@@ -38,9 +38,9 @@
     
     void unbindInput();
 
-    void startInput(in EditorInfo attribute);
+    void startInput(in IInputContext inputContext, in EditorInfo attribute);
 
-    void restartInput(in EditorInfo attribute);
+    void restartInput(in IInputContext inputContext, in EditorInfo attribute);
 
     void createSession(IInputMethodCallback callback);
     
@@ -48,7 +48,7 @@
     
     void revokeSession(IInputMethodSession session);
     
-    void showSoftInput(boolean explicit);
+    void showSoftInput(int flags);
     
     void hideSoftInput();
 }
diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl
index 2a15bdb..2f5cd14 100644
--- a/core/java/com/android/internal/view/IInputMethodManager.aidl
+++ b/core/java/com/android/internal/view/IInputMethodManager.aidl
@@ -35,7 +35,8 @@
     void removeClient(in IInputMethodClient client);
             
     InputBindResult startInput(in IInputMethodClient client,
-            in EditorInfo attribute, boolean initial, boolean needResult);
+            IInputContext inputContext, in EditorInfo attribute,
+            boolean initial, boolean needResult);
     void finishInput(in IInputMethodClient client);
     void showSoftInput(in IInputMethodClient client, int flags);
     void hideSoftInput(in IInputMethodClient client, int flags);
diff --git a/core/java/com/android/internal/view/InputConnectionWrapper.java b/core/java/com/android/internal/view/InputConnectionWrapper.java
index a9ba5f6..af4ad25 100644
--- a/core/java/com/android/internal/view/InputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/InputConnectionWrapper.java
@@ -151,11 +151,11 @@
         mIInputContext = inputContext;
     }
 
-    public CharSequence getTextAfterCursor(int length) {
+    public CharSequence getTextAfterCursor(int length, int flags) {
         CharSequence value = null;
         try {
             InputContextCallback callback = InputContextCallback.getInstance();
-            mIInputContext.getTextAfterCursor(length, callback.mSeq, callback);
+            mIInputContext.getTextAfterCursor(length, flags, callback.mSeq, callback);
             synchronized (callback) {
                 callback.waitForResultLocked();
                 if (callback.mHaveValue) {
@@ -169,11 +169,11 @@
         return value;
     }
     
-    public CharSequence getTextBeforeCursor(int length) {
+    public CharSequence getTextBeforeCursor(int length, int flags) {
         CharSequence value = null;
         try {
             InputContextCallback callback = InputContextCallback.getInstance();
-            mIInputContext.getTextBeforeCursor(length, callback.mSeq, callback);
+            mIInputContext.getTextBeforeCursor(length, flags, callback.mSeq, callback);
             synchronized (callback) {
                 callback.waitForResultLocked();
                 if (callback.mHaveValue) {
@@ -241,6 +241,24 @@
         }
     }
 
+    public boolean setSelection(int start, int end) {
+        try {
+            mIInputContext.setSelection(start, end);
+            return true;
+        } catch (RemoteException e) {
+            return false;
+        }
+    }
+    
+    public boolean performContextMenuAction(int id) {
+        try {
+            mIInputContext.performContextMenuAction(id);
+            return true;
+        } catch (RemoteException e) {
+            return false;
+        }
+    }
+    
     public boolean setComposingText(CharSequence text, int newCursorPosition) {
         try {
             mIInputContext.setComposingText(text, newCursorPosition);
diff --git a/core/java/com/android/internal/view/menu/IconMenuItemView.java b/core/java/com/android/internal/view/menu/IconMenuItemView.java
index 558a4c3..9e1f2ae 100644
--- a/core/java/com/android/internal/view/menu/IconMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/IconMenuItemView.java
@@ -142,9 +142,6 @@
     }
     
     void setCaptionMode(boolean shortcut) {
-
-        mShortcutCaptionMode = shortcut && (mItemData.shouldShowShortcut());
-        
         /*
          * If there is no item model, don't do any of the below (for example,
          * the 'More' item doesn't have a model)
@@ -153,6 +150,8 @@
             return;
         }
         
+        mShortcutCaptionMode = shortcut && (mItemData.shouldShowShortcut());
+        
         CharSequence text = mItemData.getTitleForItemView(this);
         
         if (mShortcutCaptionMode) {
diff --git a/core/java/com/android/internal/view/menu/ListMenuItemView.java b/core/java/com/android/internal/view/menu/ListMenuItemView.java
index 32513cd..e155875 100644
--- a/core/java/com/android/internal/view/menu/ListMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ListMenuItemView.java
@@ -220,7 +220,7 @@
         mRadioButton =
                 (RadioButton) inflater.inflate(com.android.internal.R.layout.list_menu_item_radio,
                 this, false);
-        addView(mRadioButton, 0);
+        addView(mRadioButton);
     }
     
     private void insertCheckBox() {
@@ -228,7 +228,7 @@
         mCheckBox =
                 (CheckBox) inflater.inflate(com.android.internal.R.layout.list_menu_item_checkbox,
                 this, false);
-        addView(mCheckBox, 0);
+        addView(mCheckBox);
     }
 
     public boolean prefersCondensedTitle() {
diff --git a/core/java/com/android/internal/widget/EditableInputConnection.java b/core/java/com/android/internal/widget/EditableInputConnection.java
index a2673a5..648d944 100644
--- a/core/java/com/android/internal/widget/EditableInputConnection.java
+++ b/core/java/com/android/internal/widget/EditableInputConnection.java
@@ -16,241 +16,42 @@
 
 package com.android.internal.widget;
 
-import android.content.res.TypedArray;
 import android.os.Bundle;
-import android.os.Handler;
 import android.text.Editable;
-import android.text.Selection;
-import android.text.Spannable;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.TextUtils;
 import android.text.method.KeyListener;
 import android.util.Log;
-import android.util.LogPrinter;
 import android.view.inputmethod.BaseInputConnection;
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.ExtractedText;
 import android.view.inputmethod.ExtractedTextRequest;
 import android.widget.TextView;
 
-class ComposingText {
-}
-
 public class EditableInputConnection extends BaseInputConnection {
     private static final boolean DEBUG = false;
     private static final String TAG = "EditableInputConnection";
 
-    public static final Object COMPOSING = new ComposingText();
-    
     private final TextView mTextView;
 
-    private Object[] mDefaultComposingSpans;
-    
     public EditableInputConnection(TextView textview) {
-        super(textview);
+        super(textview, false);
         mTextView = textview;
     }
 
-    public static final void removeComposingSpans(Spannable text) {
-        text.removeSpan(COMPOSING);
-        Object[] sps = text.getSpans(0, text.length(), Object.class);
-        if (sps != null) {
-            for (int i=sps.length-1; i>=0; i--) {
-                Object o = sps[i];
-                if ((text.getSpanFlags(o)&Spanned.SPAN_COMPOSING) != 0) {
-                    text.removeSpan(o);
-                }
-            }
-        }
-    }
-    
-    public static void setComposingSpans(Spannable text) {
-        final Object[] sps = text.getSpans(0, text.length(), Object.class);
-        if (sps != null) {
-            for (int i=sps.length-1; i>=0; i--) {
-                final Object o = sps[i];
-                if (o == COMPOSING) {
-                    text.removeSpan(o);
-                    continue;
-                }
-                final int fl = text.getSpanFlags(o);
-                if ((fl&(Spanned.SPAN_COMPOSING|Spanned.SPAN_POINT_MARK_MASK)) 
-                        != (Spanned.SPAN_COMPOSING|Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)) {
-                    text.setSpan(o, text.getSpanStart(o), text.getSpanEnd(o),
-                            (fl&Spanned.SPAN_POINT_MARK_MASK)
-                                    | Spanned.SPAN_COMPOSING
-                                    | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-                }
-            }
-        }
-        
-        text.setSpan(COMPOSING, 0, text.length(),
-                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
-    }
-    
-    public static int getComposingSpanStart(Spannable text) {
-        return text.getSpanStart(COMPOSING);
-    }
-    
-    public static int getComposingSpanEnd(Spannable text) {
-        return text.getSpanEnd(COMPOSING);
-    }
-    
-    public boolean setComposingText(CharSequence text, int newCursorPosition) {
-        if (DEBUG) Log.v(TAG, "setComposingText " + text);
-        replaceText(text, newCursorPosition, true);
-        return true;
-    }
-
-    public boolean finishComposingText() {
-        if (DEBUG) Log.v(TAG, "finishComposingText");
-        final Editable content = getEditable();
-        if (content != null) {
-            removeComposingSpans(content);
-        }
-        return true;
-    }
-    
-    public boolean commitText(CharSequence text, int newCursorPosition) {
-        if (DEBUG) Log.v(TAG, "commitText " + text);
-        replaceText(text, newCursorPosition, false);
-        return true;
-    }
-
-    public boolean commitCompletion(CompletionInfo text) {
-        if (DEBUG) Log.v(TAG, "commitCompletion " + text);
-        mTextView.onCommitCompletion(text);
-        return true;
-    }
-
-    public CharSequence getTextBeforeCursor(int length) {
-        final Editable content = getEditable();
-        if (content == null) return null;
-
-        int a = Selection.getSelectionStart(content);
-        int b = Selection.getSelectionEnd(content);
-
-        if (a > b) {
-            int tmp = a;
-            a = b;
-            b = tmp;
-        }
-
-        if (length > a) {
-            length = a;
-        }
-
-        return content.subSequence(a - length, a);
-    }
-
-    public CharSequence getTextAfterCursor(int length) {
-        final Editable content = getEditable();
-        if (content == null) return null;
-
-        int a = Selection.getSelectionStart(content);
-        int b = Selection.getSelectionEnd(content);
-
-        if (a > b) {
-            int tmp = a;
-            a = b;
-            b = tmp;
-        }
-
-        if (b + length > content.length()) {
-            length = content.length() - b;
-        }
-
-        return content.subSequence(b, b + length);
-    }
-
-    public int getCursorCapsMode(int reqModes) {
-        final Editable content = getEditable();
-        if (content == null) return 0;
-        
-        int a = Selection.getSelectionStart(content);
-        int b = Selection.getSelectionEnd(content);
-
-        if (a > b) {
-            int tmp = a;
-            a = b;
-            b = tmp;
-        }
-
-        return TextUtils.getCapsMode(content, a, reqModes);
-    }
-    
-    public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
-        if (mTextView != null) {
-            ExtractedText et = new ExtractedText();
-            if (mTextView.extractText(request, et)) {
-                if ((flags&EXTRACTED_TEXT_MONITOR) != 0) {
-                    mTextView.setExtracting(request);
-                }
-                return et;
-            }
+    public Editable getEditable() {
+        TextView tv = mTextView;
+        if (tv != null) {
+            return tv.getEditableText();
         }
         return null;
     }
     
-    public boolean deleteSurroundingText(int leftLength, int rightLength) {
-        if (DEBUG) Log.v(TAG, "deleteSurroundingText " + leftLength
-                + " / " + rightLength);
-        final Editable content = getEditable();
-        if (content == null) return false;
-
-        int a = Selection.getSelectionStart(content);
-        int b = Selection.getSelectionEnd(content);
-
-        if (a > b) {
-            int tmp = a;
-            a = b;
-            b = tmp;
-        }
-
-        // ignore the composing text.
-        int ca = content.getSpanStart(COMPOSING);
-        int cb = content.getSpanEnd(COMPOSING);
-        if (cb < ca) {
-            int tmp = ca;
-            ca = cb;
-            cb = tmp;
-        }
-        if (ca != -1 && cb != -1) {
-            if (ca < a) a = ca;
-            if (cb > b) b = cb;
-        }
-
-        int deleted = 0;
-
-        if (leftLength > 0) {
-            int start = a - leftLength;
-            if (start < 0) start = 0;
-            content.delete(start, a);
-            deleted = a - start;
-        }
-
-        if (rightLength > 0) {
-            b = b - deleted;
-
-            int end = b + rightLength;
-            if (end > content.length()) end = content.length();
-
-            content.delete(b, end);
-        }
-        
-        return true;
-    }
-
     public boolean beginBatchEdit() {
-        if (mTextView == null) return false;
-        mTextView.onBeginBatchEdit();
+        mTextView.beginBatchEdit();
         return true;
     }
     
     public boolean endBatchEdit() {
-        if (mTextView == null) return false;
-        mTextView.onEndBatchEdit();
+        mTextView.endBatchEdit();
         return true;
     }
     
@@ -262,104 +63,37 @@
         return true;
     }
     
-    public boolean performPrivateCommand(String action, Bundle data) {
-        if (mTextView == null) return false;
-        mTextView.onPrivateIMECommand(action, data);
+    public boolean commitCompletion(CompletionInfo text) {
+        if (DEBUG) Log.v(TAG, "commitCompletion " + text);
+        mTextView.beginBatchEdit();
+        mTextView.onCommitCompletion(text);
+        mTextView.endBatchEdit();
+        return true;
+    }
+
+    public boolean performContextMenuAction(int id) {
+        if (DEBUG) Log.v(TAG, "performContextMenuAction " + id);
+        mTextView.beginBatchEdit();
+        mTextView.onTextContextMenuItem(id);
+        mTextView.endBatchEdit();
         return true;
     }
     
-    private Editable getEditable() {
-        TextView tv = mTextView;
-        if (tv != null) {
-            return tv.getEditableText();
+    public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
+        if (mTextView != null) {
+            ExtractedText et = new ExtractedText();
+            if (mTextView.extractText(request, et)) {
+                if ((flags&GET_EXTRACTED_TEXT_MONITOR) != 0) {
+                    mTextView.setExtracting(request);
+                }
+                return et;
+            }
         }
         return null;
     }
     
-    private void replaceText(CharSequence text, int newCursorPosition,
-            boolean composing) {
-        final Editable content = getEditable();
-        
-        // delete composing text set previously.
-        int a = content.getSpanStart(COMPOSING);
-        int b = content.getSpanEnd(COMPOSING);
-
-        if (DEBUG) Log.v(TAG, "Composing span: " + a + " to " + b);
-        
-        if (b < a) {
-            int tmp = a;
-            a = b;
-            b = tmp;
-        }
-
-        if (a != -1 && b != -1) {
-            removeComposingSpans(content);
-        } else {
-            a = Selection.getSelectionStart(content);
-            b = Selection.getSelectionEnd(content);
-            if (a >=0 && b>= 0 && a != b) {
-                if (b < a) {
-                    int tmp = a;
-                    a = b;
-                    b = tmp;
-                }
-            }
-        }
-
-        if (composing) {
-            Spannable sp = null;
-            if (!(text instanceof Spannable)) {
-                sp = new SpannableStringBuilder(text);
-                text = sp;
-                if (mDefaultComposingSpans == null) {
-                    TypedArray ta = mTextView.getContext().getTheme()
-                            .obtainStyledAttributes(new int[] {
-                                    com.android.internal.R.attr.candidatesTextStyleSpans
-                            });
-                    CharSequence style = ta.getText(0);
-                    ta.recycle();
-                    if (style != null && style instanceof Spanned) {
-                        mDefaultComposingSpans = ((Spanned)style).getSpans(
-                                0, style.length(), Object.class);
-                    }
-                }
-                if (mDefaultComposingSpans != null) {
-                    for (int i = 0; i < mDefaultComposingSpans.length; ++i) {
-                        sp.setSpan(mDefaultComposingSpans[i], 0, sp.length(),
-                                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-                    }
-                }
-            } else {
-                sp = (Spannable)text;
-            }
-            setComposingSpans(sp);
-        }
-        
-        // Adjust newCursorPosition to be relative the start of the text.
-        newCursorPosition += a;
-
-        if (DEBUG) Log.v(TAG, "Replacing from " + a + " to " + b + " with \""
-                + text + "\", composing=" + composing
-                + ", type=" + text.getClass().getCanonicalName());
-        
-        if (DEBUG) {
-            LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
-            lp.println("Current text:");
-            TextUtils.dumpSpans(content, lp, "  ");
-            lp.println("Composing text:");
-            TextUtils.dumpSpans(text, lp, "  ");
-        }
-        
-        content.replace(a, b, text);
-        if (newCursorPosition < 0) newCursorPosition = 0;
-        if (newCursorPosition > content.length())
-            newCursorPosition = content.length();
-        Selection.setSelection(content, newCursorPosition);
-        
-        if (DEBUG) {
-            LogPrinter lp = new LogPrinter(Log.VERBOSE, TAG);
-            lp.println("Final text:");
-            TextUtils.dumpSpans(content, lp, "  ");
-        }
+    public boolean performPrivateCommand(String action, Bundle data) {
+        mTextView.onPrivateIMECommand(action, data);
+        return true;
     }
 }
diff --git a/core/java/com/google/android/net/GoogleHttpClient.java b/core/java/com/google/android/net/GoogleHttpClient.java
index 4656aff..2fcb0c3 100644
--- a/core/java/com/google/android/net/GoogleHttpClient.java
+++ b/core/java/com/google/android/net/GoogleHttpClient.java
@@ -16,18 +16,28 @@
 
 package com.google.android.net;
 
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.net.http.AndroidHttpClient;
+import android.os.Build;
+import android.os.NetStat;
+import android.os.SystemClock;
+import android.provider.Checkin;
+import android.util.Config;
+import android.util.Log;
+import org.apache.http.HttpEntity;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.ProtocolException;
-import org.apache.http.impl.client.RequestWrapper;
-import org.apache.http.impl.client.EntityEnclosingRequestWrapper;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
 import org.apache.http.client.ResponseHandler;
 import org.apache.http.client.methods.HttpUriRequest;
 import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.impl.client.EntityEnclosingRequestWrapper;
+import org.apache.http.impl.client.RequestWrapper;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.HttpContext;
 
@@ -35,25 +45,13 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.os.SystemClock;
-import android.os.Build;
-import android.net.http.AndroidHttpClient;
-import android.provider.Checkin;
-import android.util.Config;
-import android.util.Log;
-
 /**
  * {@link AndroidHttpClient} wrapper that uses {@link UrlRules} to rewrite URLs
  * and otherwise tweak HTTP requests.
  */
 public class GoogleHttpClient implements HttpClient {
-    private static final String TAG = "GoogleHttpClient";
 
-    private final AndroidHttpClient mClient;
-    private final ContentResolver mResolver;
-    private final String mUserAgent;
+    private static final String TAG = "GoogleHttpClient";    
 
     /** Exception thrown when a request is blocked by the URL rules. */
     public static class BlockedRequestException extends IOException {
@@ -63,6 +61,10 @@
             mRule = rule;
         }
     }
+    
+    private final AndroidHttpClient mClient;
+    private final ContentResolver mResolver;
+    private final String mUserAgent;
 
     /**
      * Create an HTTP client.  Normally one client is shared throughout an app.
@@ -120,8 +122,37 @@
         String code = "Error";
         long start = SystemClock.elapsedRealtime();
         try {
-            HttpResponse response = mClient.execute(request, context);
-            code = Integer.toString(response.getStatusLine().getStatusCode());
+            HttpResponse response;
+            // TODO: if we're logging network stats, and if the apache library is configured
+            // to follow redirects, count each redirect as an additional round trip.
+
+            // see if we're logging network stats.
+            boolean logNetworkStats = NetworkStatsEntity.shouldLogNetworkStats();
+
+            if (logNetworkStats) {
+                int uid = android.os.Process.myUid();
+                long startTx = NetStat.getUidTxBytes(uid);
+                long startRx = NetStat.getUidRxBytes(uid);
+
+                response = mClient.execute(request, context);
+                code = Integer.toString(response.getStatusLine().getStatusCode());
+
+                HttpEntity origEntity = response == null ? null : response.getEntity();
+                if (origEntity != null) {
+                    // yeah, we compute the same thing below.  we do need to compute this here
+                    // so we can wrap the HttpEntity in the response.
+                    long now = SystemClock.elapsedRealtime();
+                    long elapsed = now - start;
+                    NetworkStatsEntity entity = new NetworkStatsEntity(origEntity,
+                            mUserAgent, uid, startTx, startRx,
+                            elapsed /* response latency */, now /* processing start time */);
+                    response.setEntity(entity);
+                }
+            } else {
+                response = mClient.execute(request, context);
+                code = Integer.toString(response.getStatusLine().getStatusCode());
+            }
+
             return response;
         } catch (IOException e) {
             code = "IOException";
diff --git a/core/java/com/google/android/net/NetStats.java b/core/java/com/google/android/net/NetStats.java
deleted file mode 100644
index fee8219..0000000
--- a/core/java/com/google/android/net/NetStats.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.google.android.net;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-/**
- * Gets network send/receive statistics for this process.
- * The statistics come from /proc/pid/stat, using the ATOP kernel modification.
- */
-public class NetStats {
-    private static String statsFile = "/proc/" + android.os.Process.myPid() + "/stat";
-
-    private static String TAG = "netstat";
-
-    /**
-     * Returns network stats for this process.
-     * Returns stats of 0 if problem encountered.
-     *
-     * @return [bytes sent, bytes received]
-     */
-    public static long[] getStats() {
-        long result[] = new long[2];
-
-        try {
-            BufferedReader br = new BufferedReader(new FileReader(statsFile), 512);
-            String line = br.readLine(); // Skip first line
-            line = br.readLine();
-            StringTokenizer st = new StringTokenizer(line);
-            st.nextToken(); // disk read
-            st.nextToken(); // disk sectors
-            st.nextToken(); // disk write
-            st.nextToken(); // disk sectors
-            st.nextToken(); // tcp send
-            result[0] = Long.parseLong(st.nextToken()); // tcp bytes sent
-            st.nextToken(); //tcp recv
-            result[1] = Long.parseLong(st.nextToken()); // tcp bytes recv
-        } catch (IOException e) {
-            // Probably wrong kernel; no point logging exception
-        } catch (NoSuchElementException e) {
-        } catch (NullPointerException e) {
-        }
-        return result;
-    }
-}
diff --git a/core/java/com/google/android/net/NetworkStatsEntity.java b/core/java/com/google/android/net/NetworkStatsEntity.java
new file mode 100644
index 0000000..f5d2349
--- /dev/null
+++ b/core/java/com/google/android/net/NetworkStatsEntity.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.android.net;
+
+import android.os.NetStat;
+import android.os.SystemClock;
+import android.os.SystemProperties;
+import android.util.EventLog;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.HttpEntityWrapper;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+
+public class NetworkStatsEntity extends HttpEntityWrapper {
+
+    private static final int HTTP_STATS_EVENT = 52001;
+
+    private class NetworkStatsInputStream extends FilterInputStream {
+
+        public NetworkStatsInputStream(InputStream wrapped) {
+            super(wrapped);
+        }
+
+        @Override
+        public void close() throws IOException {
+            try {
+                super.close();
+            } finally {
+                long processingTime = SystemClock.elapsedRealtime() - mProcessingStartTime;
+                long tx = NetStat.getUidTxBytes(mUid);
+                long rx = NetStat.getUidRxBytes(mUid);
+
+                EventLog.writeEvent(HTTP_STATS_EVENT, mUa, mResponseLatency, processingTime,
+                        tx - mStartTx, rx - mStartRx);
+            }
+        }
+    }
+
+    private final String mUa;
+    private final int mUid;
+    private final long mStartTx;
+    private final long mStartRx;
+    private final long mResponseLatency;
+    private final long mProcessingStartTime;
+
+    public NetworkStatsEntity(HttpEntity orig, String ua,
+            int uid, long startTx, long startRx, long responseLatency,
+            long processingStartTime) {
+        super(orig);
+        this.mUa = ua;
+        this.mUid = uid;
+        this.mStartTx = startTx;
+        this.mStartRx = startRx;
+        this.mResponseLatency = responseLatency;
+        this.mProcessingStartTime = processingStartTime;
+    }
+
+    public static boolean shouldLogNetworkStats() {
+      return "1".equals(SystemProperties.get("googlehttpclient.logstats"));
+    }
+
+    @Override
+    public InputStream getContent() throws IOException {
+        InputStream orig = super.getContent();
+        return new NetworkStatsInputStream(orig);
+    }
+}
diff --git a/core/java/com/google/android/util/SimplePullParser.java b/core/java/com/google/android/util/SimplePullParser.java
index 95f2ddb..031790b 100644
--- a/core/java/com/google/android/util/SimplePullParser.java
+++ b/core/java/com/google/android/util/SimplePullParser.java
@@ -23,6 +23,7 @@
 import java.io.InputStream;
 import java.io.StringReader;
 import java.io.Reader;
+import java.io.Closeable;
 
 import android.util.Xml;
 import android.util.Log;
@@ -41,6 +42,7 @@
 
     private String mLogTag = null;
     private final XmlPullParser mParser;
+    private Closeable source;
     private String mCurrentStartTag;
 
     /**
@@ -56,6 +58,7 @@
             moveToStartDocument(parser);
             mParser = parser;
             mCurrentStartTag = null;
+            source = stream;
         } catch (XmlPullParserException e) {
             throw new ParseException(e);
         }
@@ -68,6 +71,7 @@
     public SimplePullParser(XmlPullParser parser) {
         mParser = parser;
         mCurrentStartTag = null;
+        source = null;
     }
 
     /**
@@ -89,6 +93,7 @@
             moveToStartDocument(parser);
             mParser = parser;
             mCurrentStartTag = null;
+            source = reader;
         } catch (XmlPullParserException e) {
             throw new ParseException(e);
         }
@@ -171,6 +176,12 @@
             }
 
             if (eventType == XmlPullParser.END_DOCUMENT && parentDepth == 0) {
+                // we could just rely on the caller calling close(), which it should, but try
+                // to auto-close for clients that might have missed doing so.
+                if (source != null) {
+                    source.close();
+                    source = null;
+                }
                 return null;
             }
 
@@ -333,6 +344,20 @@
     }
 
     /**
+     * Close this SimplePullParser and any underlying resources (e.g., its InputStream or
+     * Reader source) used by this SimplePullParser.
+     */
+    public void close() {
+        if (source != null) {
+            try {
+                source.close();
+            } catch (IOException ioe) {
+                // ignore
+            }
+        }
+    }
+
+    /**
      * Returns the string value of the named attribute. An exception will
      * be thrown if the attribute is not present or is not a valid long.
      *
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 32c3a54..6e5c4e0 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -42,7 +42,6 @@
 	android_os_SystemClock.cpp \
 	android_os_SystemProperties.cpp \
 	android_os_UEventObserver.cpp \
-	android_os_NetStat.cpp \
 	android_os_Hardware.cpp \
 	android_net_LocalSocketImpl.cpp \
 	android_net_NetUtils.cpp \
@@ -146,7 +145,8 @@
 	libcorecg \
 	libsqlite \
 	libdvm \
-	libGLES_CM \
+	libEGL \
+	libGLESv1_CM \
 	libhardware \
 	libhardware_legacy \
 	libsonivox \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 097ffac..40dc2a1 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -129,7 +129,6 @@
 extern int register_android_os_FileObserver(JNIEnv *env);
 extern int register_android_os_FileUtils(JNIEnv *env);
 extern int register_android_os_UEventObserver(JNIEnv* env);
-extern int register_android_os_NetStat(JNIEnv* env);
 extern int register_android_os_MemoryFile(JNIEnv* env);
 extern int register_android_net_LocalSocketImpl(JNIEnv* env);
 extern int register_android_net_NetworkUtils(JNIEnv* env);
@@ -502,6 +501,7 @@
     JavaVMOption opt;
     char propBuf[PROPERTY_VALUE_MAX];
     char stackTraceFileBuf[PROPERTY_VALUE_MAX];
+    char dexoptFlagsBuf[PROPERTY_VALUE_MAX];
     char enableAssertBuf[sizeof("-ea:")-1 + PROPERTY_VALUE_MAX];
     char jniOptsBuf[sizeof("-Xjniopts:")-1 + PROPERTY_VALUE_MAX];
     char* stackTraceFile = NULL;
@@ -509,7 +509,6 @@
     char* cp;
     bool checkJni = false;
     bool logStdio = false;
-    bool verifyJava = true;
     enum { kEMDefault, kEMIntPortable, kEMIntFast } executionMode = kEMDefault;
 
     blockSigpipe();
@@ -536,15 +535,6 @@
         }
     }
 
-    property_get("dalvik.vm.verify-bytecode", propBuf, "");
-    if (strcmp(propBuf, "true") == 0) {
-        verifyJava = true;
-    } else if (strcmp(propBuf, "false") == 0) {
-        verifyJava = false;
-    } else {
-        /* bad value or not defined; use default */
-    }
-
     property_get("dalvik.vm.execution-mode", propBuf, "");
     if (strcmp(propBuf, "int:portable") == 0) {
         executionMode = kEMIntPortable;
@@ -609,21 +599,49 @@
     mOptions.add(opt);
 
     /*
-     * Enable or disable bytecode verification.
-     *
-     * We don't optimize classes that haven't been verified, but that only
-     * matters if we do "just-in-time" DEX optimization.
+     * Enable or disable dexopt features, such as bytecode verification and
+     * calculation of register maps for precise GC.
      */
-    if (verifyJava) {
-        opt.optionString = "-Xverify:all";
-        mOptions.add(opt);
-        opt.optionString = "-Xdexopt:verified";
-        mOptions.add(opt);
-    } else {
-        opt.optionString = "-Xverify:none";
-        mOptions.add(opt);
-        opt.optionString = "-Xdexopt:verified";
-        mOptions.add(opt);
+    property_get("dalvik.vm.dexopt-flags", dexoptFlagsBuf, "");
+    if (dexoptFlagsBuf[0] != '\0') {
+        const char* opc;
+        const char* val;
+
+        opc = strstr(dexoptFlagsBuf, "v=");     /* verification */
+        if (opc != NULL) {
+            switch (*(opc+2)) {
+            case 'n':   val = "-Xverify:none";      break;
+            case 'r':   val = "-Xverify:remote";    break;
+            case 'a':   val = "-Xverify:all";       break;
+            default:    val = NULL;                 break;
+            }
+
+            if (val != NULL) {
+                opt.optionString = val;
+                mOptions.add(opt);
+            }
+        }
+
+        opc = strstr(dexoptFlagsBuf, "o=");     /* optimization */
+        if (opc != NULL) {
+            switch (*(opc+2)) {
+            case 'n':   val = "-Xdexopt:none";      break;
+            case 'v':   val = "-Xdexopt:verified";  break;
+            case 'a':   val = "-Xdexopt:all";       break;
+            default:    val = NULL;                 break;
+            }
+
+            if (val != NULL) {
+                opt.optionString = val;
+                mOptions.add(opt);
+            }
+        }
+
+        opc = strstr(dexoptFlagsBuf, "m=y");    /* register map */
+        if (opc != NULL) {
+            opt.optionString = "-Xgenregmap";
+            mOptions.add(opt);
+        }
     }
 
     /* enable debugging; set suspend=y to pause during VM init */
@@ -1066,7 +1084,6 @@
     REG_JNI(register_android_net_LocalSocketImpl),
     REG_JNI(register_android_net_NetworkUtils),
     REG_JNI(register_android_net_wifi_WifiManager),
-    REG_JNI(register_android_os_NetStat),
     REG_JNI(register_android_os_MemoryFile),
     REG_JNI(register_com_android_internal_os_ZygoteInit),
     REG_JNI(register_android_hardware_Camera),
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index be8526d..332b01c 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -1,3 +1,5 @@
+#define LOG_TAG "BitmapFactory"
+
 #include "SkImageDecoder.h"
 #include "SkPixelRef.h"
 #include "SkStream.h"
@@ -481,6 +483,48 @@
     (void)AutoDecoderCancel::RequestCancel(joptions);
 }
 
+static jbyteArray nativeScaleNinePatch(JNIEnv* env, jobject, jbyteArray chunkObject, jfloat scale,
+        jobject padding) {
+
+    jbyte* array = env->GetByteArrayElements(chunkObject, 0);
+    if (array != NULL) {
+        size_t chunkSize = env->GetArrayLength(chunkObject);
+        void* storage = alloca(chunkSize);
+        android::Res_png_9patch* chunk = static_cast<android::Res_png_9patch*>(storage);
+        memcpy(chunk, array, chunkSize);
+        android::Res_png_9patch::deserialize(chunk);
+
+        chunk->paddingLeft = int(chunk->paddingLeft * scale + 0.5f);
+        chunk->paddingTop = int(chunk->paddingTop * scale + 0.5f);
+        chunk->paddingRight = int(chunk->paddingRight * scale + 0.5f);
+        chunk->paddingBottom = int(chunk->paddingBottom * scale + 0.5f);
+
+        for (int i = 0; i < chunk->numXDivs; i++) {
+            chunk->xDivs[i] = int(chunk->xDivs[i] * scale + 0.5f);
+            if (i > 0 && chunk->xDivs[i] == chunk->xDivs[i - 1]) {
+                chunk->xDivs[i]++;
+            }
+        }
+
+        for (int i = 0; i < chunk->numYDivs; i++) {
+            chunk->yDivs[i] = int(chunk->yDivs[i] * scale + 0.5f);            
+            if (i > 0 && chunk->yDivs[i] == chunk->yDivs[i - 1]) {
+                chunk->yDivs[i]++;
+            }
+        }
+
+        memcpy(array, chunk, chunkSize);
+
+        if (padding) {
+            GraphicsJNI::set_jrect(env, padding, chunk->paddingLeft, chunk->paddingTop,
+                    chunk->paddingRight, chunk->paddingBottom);
+        }
+
+        env->ReleaseByteArrayElements(chunkObject, array, 0);
+    }
+    return chunkObject;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 
 static JNINativeMethod gMethods[] = {
@@ -502,7 +546,13 @@
     {   "nativeDecodeByteArray",
         "([BIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;",
         (void*)nativeDecodeByteArray
+    },
+
+    {   "nativeScaleNinePatch",
+        "([BFLandroid/graphics/Rect;)[B",
+        (void*)nativeScaleNinePatch
     }
+
 };
 
 static JNINativeMethod gOptionsMethods[] = {
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index b9e5f67..605e4b8 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -93,7 +93,7 @@
         SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, jcanvas);
         return canvas->getDevice()->accessBitmap(false).height();
     }
-    
+
     static void setViewport(JNIEnv* env, jobject, SkCanvas* canvas,
                             int width, int height) {
         canvas->setViewport(width, height);
@@ -454,13 +454,32 @@
 #endif
     }
 
-    static void drawBitmap__BitmapFFPaint(JNIEnv* env, jobject,
+    static void drawBitmap__BitmapFFPaint(JNIEnv* env, jobject jcanvas,
                                           SkCanvas* canvas, SkBitmap* bitmap,
                                           jfloat left, jfloat top,
-                                          SkPaint* paint) {
+                                          SkPaint* paint,
+                                          jboolean autoScale, jfloat densityScale) {
         SkScalar left_ = SkFloatToScalar(left);
         SkScalar top_ = SkFloatToScalar(top);
-        canvas->drawBitmap(*bitmap, left_, top_, paint);
+
+        if (!autoScale || densityScale <= 0.0f) {
+            canvas->drawBitmap(*bitmap, left_, top_, paint);
+        } else {
+            canvas->save();
+            SkScalar canvasScale = GraphicsJNI::getCanvasDensityScale(env, jcanvas);
+            SkScalar scale = canvasScale / SkFloatToScalar(densityScale);
+            canvas->scale(scale, scale);
+
+            SkPaint filteredPaint;
+            if (paint) {
+                filteredPaint = *paint;
+            }
+            filteredPaint.setFilterBitmap(true);
+
+            canvas->drawBitmap(*bitmap, left_, top_, &filteredPaint);
+
+            canvas->restore();
+        }
     }
 
     static void doDrawBitmap(JNIEnv* env, SkCanvas* canvas, SkBitmap* bitmap,
@@ -492,7 +511,7 @@
     
     static void drawBitmapArray(JNIEnv* env, jobject, SkCanvas* canvas,
                                 jintArray jcolors, int offset, int stride,
-                                int x, int y, int width, int height,
+                                jfloat x, jfloat y, int width, int height,
                                 jboolean hasAlpha, SkPaint* paint)
     {
         SkBitmap    bitmap;
@@ -508,7 +527,8 @@
             return;
         }
         
-        canvas->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y), paint);
+        canvas->drawBitmap(bitmap, SkFloatToScalar(x), SkFloatToScalar(y),
+                           paint);
     }
     
     static void drawBitmapMatrix(JNIEnv* env, jobject, SkCanvas* canvas,
@@ -882,13 +902,13 @@
     {"native_drawRoundRect","(ILandroid/graphics/RectF;FFI)V",
         (void*) SkCanvasGlue::drawRoundRect},
     {"native_drawPath","(III)V", (void*) SkCanvasGlue::drawPath},
-    {"native_drawBitmap","(IIFFI)V",
+    {"native_drawBitmap","(IIFFIZF)V",
         (void*) SkCanvasGlue::drawBitmap__BitmapFFPaint},
     {"native_drawBitmap","(IILandroid/graphics/Rect;Landroid/graphics/RectF;I)V",
         (void*) SkCanvasGlue::drawBitmapRF},
     {"native_drawBitmap","(IILandroid/graphics/Rect;Landroid/graphics/Rect;I)V",
         (void*) SkCanvasGlue::drawBitmapRR},
-    {"native_drawBitmap", "(I[IIIIIIIZI)V",
+    {"native_drawBitmap", "(I[IIIFFIIZI)V",
     (void*)SkCanvasGlue::drawBitmapArray},
     
     {"nativeDrawBitmapMatrix", "(IIII)V",
diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
index 65c2326..a285def 100644
--- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
+++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
@@ -56,11 +56,14 @@
                 break;  // eof
             }
             
-            const jbyte* array = env->GetByteArrayElements(fJavaByteArray,
-                                                           NULL);
-            memcpy(buffer, array, n);
-            env->ReleaseByteArrayElements(fJavaByteArray,
-                                          const_cast<jbyte*>(array), JNI_ABORT);
+            env->GetByteArrayRegion(fJavaByteArray, 0, n,
+                                    reinterpret_cast<jbyte*>(buffer));
+            if (env->ExceptionCheck()) {
+                env->ExceptionDescribe();
+                env->ExceptionClear();
+                SkDebugf("---- read:GetByteArrayRegion threw an exception\n");
+                return 0;
+            }
             
             buffer = (void*)((char*)buffer + n);
             bytesRead += n;
@@ -189,10 +192,15 @@
                 requested = fCapacity;
             }
 
-            jbyte* array = env->GetByteArrayElements(storage, NULL);
-            memcpy(array, buffer, requested);
-            env->ReleaseByteArrayElements(storage, array, 0);
-
+            env->SetByteArrayRegion(storage, 0, requested,
+                                    reinterpret_cast<const jbyte*>(buffer));
+            if (env->ExceptionCheck()) {
+                env->ExceptionDescribe();
+                env->ExceptionClear();
+                SkDebugf("--- write:SetByteArrayElements threw an exception\n");
+                return false;
+            }
+            
             fEnv->CallVoidMethod(fJavaOutputStream, gOutputStream_writeMethodID,
                                  storage, 0, requested);
             if (env->ExceptionCheck()) {
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 44113e5..6eebbdc 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -162,6 +162,7 @@
 
 static jclass   gCanvas_class;
 static jfieldID gCanvas_nativeInstanceID;
+static jfieldID gCanvas_densityScaleID;
 
 static jclass   gPaint_class;
 static jfieldID gPaint_nativeInstanceID;
@@ -318,6 +319,13 @@
     return c;
 }
 
+SkScalar GraphicsJNI::getCanvasDensityScale(JNIEnv* env, jobject canvas) {
+    SkASSERT(env);
+    SkASSERT(canvas);
+    SkASSERT(env->IsInstanceOf(canvas, gCanvas_class));
+    return SkFloatToScalar(env->GetFloatField(canvas, gCanvas_densityScaleID));
+}
+
 SkPaint* GraphicsJNI::getNativePaint(JNIEnv* env, jobject paint) {
     SkASSERT(env);
     SkASSERT(paint);
@@ -543,7 +551,8 @@
 
     gCanvas_class = make_globalref(env, "android/graphics/Canvas");
     gCanvas_nativeInstanceID = getFieldIDCheck(env, gCanvas_class, "mNativeCanvas", "I");
-    
+    gCanvas_densityScaleID = getFieldIDCheck(env, gCanvas_class, "mDensityScale", "F");
+
     gPaint_class = make_globalref(env, "android/graphics/Paint");
     gPaint_nativeInstanceID = getFieldIDCheck(env, gPaint_class, "mNativePaint", "I");
     
diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h
index e67b20b..e2dc9ac 100644
--- a/core/jni/android/graphics/GraphicsJNI.h
+++ b/core/jni/android/graphics/GraphicsJNI.h
@@ -38,6 +38,7 @@
     static SkBitmap* getNativeBitmap(JNIEnv*, jobject bitmap);
     static SkPicture* getNativePicture(JNIEnv*, jobject picture);
     static SkRegion* getNativeRegion(JNIEnv*, jobject region);
+    static SkScalar getCanvasDensityScale(JNIEnv*, jobject canvas);
     
     /** Return the corresponding native config from the java Config enum,
         or kNo_Config if the java object is null.
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index 9e943f3..b11edfc 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -47,19 +47,17 @@
     static void draw(JNIEnv* env, SkCanvas* canvas, SkRect& bounds,
                       const SkBitmap* bitmap, jbyteArray chunkObj, const SkPaint* paint)
     {
-        const jbyte* array = env->GetByteArrayElements(chunkObj, 0);
-        if (array != NULL) {
-            size_t chunkSize = env->GetArrayLength(chunkObj);
+        size_t chunkSize = env->GetArrayLength(chunkObj);
+        void* storage = alloca(chunkSize);
+        env->GetByteArrayRegion(chunkObj, 0, chunkSize,
+                                reinterpret_cast<jbyte*>(storage));
+        if (!env->ExceptionCheck()) {
             // need to deserialize the chunk
-            void* storage = alloca(chunkSize);
             Res_png_9patch* chunk = static_cast<Res_png_9patch*>(storage);
-            memcpy(chunk, array, chunkSize);
             assert(chunkSize == chunk->serializedSize());
             // this relies on deserialization being done in place
             Res_png_9patch::deserialize(chunk);            
             NinePatch_Draw(canvas, bounds, *bitmap, *chunk, paint, NULL);
-            env->ReleaseByteArrayElements(chunkObj, const_cast<jbyte*>(array),
-                                          JNI_ABORT);
         }
     } 
 
@@ -102,23 +100,20 @@
         
         SkRect      bounds;
         GraphicsJNI::jrect_to_rect(env, boundsRect, &bounds);
-        const jbyte* array = (jbyte*)env->GetByteArrayElements(chunkObj, 0);
-        if (array != NULL) {
-            size_t chunkSize = env->GetArrayLength(chunkObj);
+        size_t chunkSize = env->GetArrayLength(chunkObj);
+        void* storage = alloca(chunkSize);
+        env->GetByteArrayRegion(chunkObj, 0, chunkSize,
+                                reinterpret_cast<jbyte*>(storage));
+        if (!env->ExceptionCheck()) {
             // need to deserialize the chunk
-            void* storage = alloca(chunkSize);
             Res_png_9patch* chunk = static_cast<Res_png_9patch*>(storage);
-            memcpy(chunk, array, chunkSize);
             assert(chunkSize == chunk->serializedSize());
             // this relies on deserialization being done in place
             Res_png_9patch::deserialize(chunk);
             SkRegion* region = NULL;
             NinePatch_Draw(NULL, bounds, *bitmap, *chunk, NULL, &region);
-            env->ReleaseByteArrayElements(chunkObj, const_cast<jbyte*>(array),
-                                          JNI_ABORT);
             return (jint)region;
         }
-        
         return 0;
     }
 
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp
index a81f252..79965b9 100644
--- a/core/jni/android_hardware_Camera.cpp
+++ b/core/jni/android_hardware_Camera.cpp
@@ -259,7 +259,7 @@
     } else {
         callback_flag = FRAME_CALLBACK_FLAG_NOOP;
     }
-    c->setFrameCallback(installed ? preview_callback : NULL, cookie, callback_flag);
+    c->setPreviewCallback(installed ? preview_callback : NULL, cookie, callback_flag);
 }
 
 static void autofocus_callback_impl(bool success, void *cookie)
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index e4586d9..307c6fd 100644
--- a/core/jni/android_media_AudioRecord.cpp
+++ b/core/jni/android_media_AudioRecord.cpp
@@ -63,11 +63,11 @@
 #define AUDIORECORD_ERROR                           -1
 #define AUDIORECORD_ERROR_BAD_VALUE                 -2
 #define AUDIORECORD_ERROR_INVALID_OPERATION         -3
-#define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT      -4
-#define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -5
-#define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT       -6
-#define AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE   -7
-#define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED    -8
+#define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT      -16
+#define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17
+#define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT       -18
+#define AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE   -19
+#define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED    -20
 
 jint android_media_translateRecorderErrorCode(int code) {
     switch(code) {
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 99785a2..6bd3655 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -55,6 +55,8 @@
     LOGV("setVolume(%d)", int(volume));
     if (int(type) == AudioTrack::VOICE_CALL) {
         return check_AudioSystem_Command(AudioSystem::setStreamVolume(type, float(volume) / 100.0));
+    } else if (int(type) == AudioTrack::BLUETOOTH_SCO) {
+        return check_AudioSystem_Command(AudioSystem::setStreamVolume(type, float(1.0)));
     } else {
         return check_AudioSystem_Command(AudioSystem::setStreamVolume(type, AudioSystem::linearToLog(volume)));
     }
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 6bbcaee..bbecc1b 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -53,6 +53,7 @@
     int       STREAM_MUSIC;          //...  stream type constants
     int       STREAM_ALARM;          //...  stream type constants
     int       STREAM_NOTIFICATION;   //...  stream type constants
+    int       STREAM_BLUETOOTH_SCO;   //...  stream type constants
     int       MODE_STREAM;           //...  memory mode
     int       MODE_STATIC;           //...  memory mode
     jfieldID  nativeTrackInJavaObj; // stores in Java the native AudioTrack object
@@ -95,13 +96,13 @@
 
 #define AUDIOTRACK_SUCCESS                         0
 #define AUDIOTRACK_ERROR                           -1
-#define AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM         -2
-#define AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELCOUNT -3
-#define AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT       -4
-#define AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE   -5
-#define AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED    -6
-#define AUDIOTRACK_ERROR_BAD_VALUE                 -7
-#define AUDIOTRACK_ERROR_INVALID_OPERATION         -8
+#define AUDIOTRACK_ERROR_BAD_VALUE                 -2
+#define AUDIOTRACK_ERROR_INVALID_OPERATION         -3
+#define AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM         -16
+#define AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELCOUNT -17
+#define AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT       -18
+#define AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE   -19
+#define AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED    -20
 
 
 jint android_media_translateErrorCode(int code) {
@@ -195,10 +196,12 @@
         atStreamType = AudioTrack::ALARM;
     } else if (streamType == javaAudioTrackFields.STREAM_NOTIFICATION) {
         atStreamType = AudioTrack::NOTIFICATION;
+    } else if (streamType == javaAudioTrackFields.STREAM_BLUETOOTH_SCO) {
+        atStreamType = AudioTrack::BLUETOOTH_SCO;
     } else {
         LOGE("Error creating AudioTrack: unknown stream type.");
         return AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
-     }
+    }
 
     // check the format.
     // This function was called from Java, so we compare the format against the Java constants
@@ -663,6 +666,35 @@
 
 
 // ----------------------------------------------------------------------------
+// returns the minimum required size for the successful creation of a streaming AudioTrack
+static jint android_media_AudioTrack_get_min_buff_size(JNIEnv *env,  jobject thiz,
+    jint sampleRateInHertz, jint nbChannels, jint audioFormat) {
+    int afSamplingRate;
+    int afFrameCount;
+    uint32_t afLatency;
+    
+    if (AudioSystem::getOutputSamplingRate(&afSamplingRate) != NO_ERROR) {
+        return -1;
+    }
+    if (AudioSystem::getOutputFrameCount(&afFrameCount) != NO_ERROR) {
+        return -1;
+    }
+    
+    if (AudioSystem::getOutputLatency(&afLatency) != NO_ERROR) {
+        return -1;
+    }
+    
+    // Ensure that buffer depth covers at least audio hardware latency
+    uint32_t minBufCount = afLatency / ((1000 * afFrameCount)/afSamplingRate);
+    uint32_t minFrameCount = (afFrameCount*sampleRateInHertz*minBufCount)/afSamplingRate;
+    int minBuffSize = minFrameCount 
+            * (audioFormat == javaAudioTrackFields.PCM16 ? 2 : 1)
+            * nbChannels;
+    return minBuffSize;
+}
+
+
+// ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 static JNINativeMethod gMethods[] = {
     // name,              signature,     funcPtr
@@ -695,24 +727,27 @@
     {"native_reload_static", "()I",      (void *)android_media_AudioTrack_reload},
     {"native_get_output_sample_rate",
                              "()I",      (void *)android_media_AudioTrack_get_output_sample_rate},
+    {"native_get_min_buff_size",
+                             "(III)I",   (void *)android_media_AudioTrack_get_min_buff_size},
 };
 
 
 // field names found in android/media/AudioTrack.java
-#define JAVA_POSTEVENT_CALLBACK_NAME            "postEventFromNative"
-#define JAVA_CONST_PCM16_NAME                   "ENCODING_PCM_16BIT"
-#define JAVA_CONST_PCM8_NAME                    "ENCODING_PCM_8BIT"
-#define JAVA_CONST_BUFFER_COUNT_NAME            "BUFFER_COUNT"
-#define JAVA_CONST_STREAM_VOICE_CALL_NAME       "STREAM_VOICE_CALL"
-#define JAVA_CONST_STREAM_SYSTEM_NAME           "STREAM_SYSTEM"
-#define JAVA_CONST_STREAM_RING_NAME             "STREAM_RING"
-#define JAVA_CONST_STREAM_MUSIC_NAME            "STREAM_MUSIC"
-#define JAVA_CONST_STREAM_ALARM_NAME            "STREAM_ALARM"
-#define JAVA_CONST_STREAM_NOTIFICATION_NAME     "STREAM_NOTIFICATION"
-#define JAVA_CONST_MODE_STREAM_NAME             "MODE_STREAM"
-#define JAVA_CONST_MODE_STATIC_NAME             "MODE_STATIC"
-#define JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME    "mNativeTrackInJavaObj"
-#define JAVA_JNIDATA_FIELD_NAME                 "mJniData"
+#define JAVA_POSTEVENT_CALLBACK_NAME                    "postEventFromNative"
+#define JAVA_CONST_PCM16_NAME                           "ENCODING_PCM_16BIT"
+#define JAVA_CONST_PCM8_NAME                            "ENCODING_PCM_8BIT"
+#define JAVA_CONST_BUFFER_COUNT_NAME                    "BUFFER_COUNT"
+#define JAVA_CONST_STREAM_VOICE_CALL_NAME               "STREAM_VOICE_CALL"
+#define JAVA_CONST_STREAM_SYSTEM_NAME                   "STREAM_SYSTEM"
+#define JAVA_CONST_STREAM_RING_NAME                     "STREAM_RING"
+#define JAVA_CONST_STREAM_MUSIC_NAME                    "STREAM_MUSIC"
+#define JAVA_CONST_STREAM_ALARM_NAME                    "STREAM_ALARM"
+#define JAVA_CONST_STREAM_NOTIFICATION_NAME             "STREAM_NOTIFICATION"
+#define JAVA_CONST_STREAM_BLUETOOTH_SCO_NAME            "STREAM_BLUETOOTH_SCO"
+#define JAVA_CONST_MODE_STREAM_NAME                     "MODE_STREAM"
+#define JAVA_CONST_MODE_STATIC_NAME                     "MODE_STATIC"
+#define JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME            "mNativeTrackInJavaObj"
+#define JAVA_JNIDATA_FIELD_NAME                         "mJniData"
 
 #define JAVA_AUDIOFORMAT_CLASS_NAME             "android/media/AudioFormat"
 #define JAVA_AUDIOMANAGER_CLASS_NAME            "android/media/AudioManager"
@@ -810,28 +845,32 @@
        LOGE("Can't find %s", JAVA_AUDIOMANAGER_CLASS_NAME);
        return -1;
     }
-    if ( !android_media_getIntConstantFromClass(env, audioManagerClass, 
-               JAVA_AUDIOMANAGER_CLASS_NAME, 
+    if ( !android_media_getIntConstantFromClass(env, audioManagerClass,
+               JAVA_AUDIOMANAGER_CLASS_NAME,
                JAVA_CONST_STREAM_VOICE_CALL_NAME, &(javaAudioTrackFields.STREAM_VOICE_CALL))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass, 
-               JAVA_AUDIOMANAGER_CLASS_NAME, 
+          || !android_media_getIntConstantFromClass(env, audioManagerClass,
+               JAVA_AUDIOMANAGER_CLASS_NAME,
                JAVA_CONST_STREAM_MUSIC_NAME, &(javaAudioTrackFields.STREAM_MUSIC))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass, 
-               JAVA_AUDIOMANAGER_CLASS_NAME, 
+          || !android_media_getIntConstantFromClass(env, audioManagerClass,
+               JAVA_AUDIOMANAGER_CLASS_NAME,
                JAVA_CONST_STREAM_SYSTEM_NAME, &(javaAudioTrackFields.STREAM_SYSTEM))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass, 
-               JAVA_AUDIOMANAGER_CLASS_NAME, 
+          || !android_media_getIntConstantFromClass(env, audioManagerClass,
+               JAVA_AUDIOMANAGER_CLASS_NAME,
                JAVA_CONST_STREAM_RING_NAME, &(javaAudioTrackFields.STREAM_RING))
           || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME, 
+               JAVA_AUDIOMANAGER_CLASS_NAME,
                JAVA_CONST_STREAM_ALARM_NAME, &(javaAudioTrackFields.STREAM_ALARM))
           || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME, 
-               JAVA_CONST_STREAM_NOTIFICATION_NAME, &(javaAudioTrackFields.STREAM_NOTIFICATION)) ) {
+               JAVA_AUDIOMANAGER_CLASS_NAME,
+               JAVA_CONST_STREAM_NOTIFICATION_NAME, &(javaAudioTrackFields.STREAM_NOTIFICATION))
+          || !android_media_getIntConstantFromClass(env, audioManagerClass,
+               JAVA_AUDIOMANAGER_CLASS_NAME,
+               JAVA_CONST_STREAM_BLUETOOTH_SCO_NAME,
+               &(javaAudioTrackFields.STREAM_BLUETOOTH_SCO))) {
        // error log performed in android_media_getIntConstantFromClass()
        return -1;
     }
- 
+
     return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
 }
 
diff --git a/core/jni/android_media_JetPlayer.cpp b/core/jni/android_media_JetPlayer.cpp
index 994f161..fe60943 100644
--- a/core/jni/android_media_JetPlayer.cpp
+++ b/core/jni/android_media_JetPlayer.cpp
@@ -127,7 +127,7 @@
 
 // ----------------------------------------------------------------------------
 static jboolean
-android_media_JetPlayer_openFile(JNIEnv *env, jobject thiz, jstring path)
+android_media_JetPlayer_loadFromFile(JNIEnv *env, jobject thiz, jstring path)
 {
     JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
@@ -139,7 +139,6 @@
     // set up event callback function
     lpJet->setEventCallback(jetPlayerEventCallback);
 
-
     const char *pathStr = env->GetStringUTFChars(path, NULL);
     if (pathStr == NULL) {  // Out of memory
         LOGE("android_media_JetPlayer_openFile(): aborting, out of memory");
@@ -148,7 +147,7 @@
     }
 
     LOGV("android_media_JetPlayer_openFile(): trying to open %s", pathStr );
-    EAS_RESULT result = lpJet->openFile(pathStr);
+    EAS_RESULT result = lpJet->loadFromFile(pathStr);
     env->ReleaseStringUTFChars(path, pathStr);
 
     if(result==EAS_SUCCESS) {
@@ -164,7 +163,8 @@
 
 // ----------------------------------------------------------------------------
 static jboolean
-android_media_JetPlayer_closeFile(JNIEnv *env, jobject thiz)
+android_media_JetPlayer_loadFromFileD(JNIEnv *env, jobject thiz,
+    jobject fileDescriptor, jlong offset, jlong length)
 {
     JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
@@ -173,6 +173,35 @@
             "Unable to retrieve JetPlayer pointer for openFile()");
     }
     
+    // set up event callback function
+    lpJet->setEventCallback(jetPlayerEventCallback);
+    
+    LOGV("android_media_JetPlayer_openFileDescr(): trying to load JET file through its fd" );
+    EAS_RESULT result = lpJet->loadFromFD(getParcelFileDescriptorFD(env, fileDescriptor),
+        (long long)offset, (long long)length); // cast params to types used by EAS_FILE
+    
+    if(result==EAS_SUCCESS) {
+        LOGV("android_media_JetPlayer_openFileDescr(): file successfully opened");
+        return JNI_TRUE;
+    } else {
+        LOGE("android_media_JetPlayer_openFileDescr(): failed to open file with EAS error %d",
+            (int)result);
+        return JNI_FALSE;
+    }
+}
+
+
+// ----------------------------------------------------------------------------
+static jboolean
+android_media_JetPlayer_closeFile(JNIEnv *env, jobject thiz)
+{
+    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+        thiz, javaJetPlayerFields.nativePlayerInJavaObj);
+    if (lpJet == NULL ) {
+        jniThrowException(env, "java/lang/IllegalStateException",
+            "Unable to retrieve JetPlayer pointer for closeFile()");
+    }
+    
     if( lpJet->closeFile()==EAS_SUCCESS) {
         //LOGV("android_media_JetPlayer_closeFile(): file successfully closed");
         return JNI_TRUE;
@@ -191,7 +220,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for play()");
     }
     
     EAS_RESULT result = lpJet->play();
@@ -214,7 +243,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for pause()");
     }
     
     EAS_RESULT result = lpJet->pause();
@@ -243,7 +272,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for queueSegment()");
     }
     
     EAS_RESULT result
@@ -269,7 +298,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for queueSegmentMuteArray()");
     }
     
     EAS_RESULT result=EAS_FAILURE;
@@ -314,7 +343,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for setMuteFlags()");
     }
     
     EAS_RESULT result;
@@ -338,7 +367,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for setMuteArray()");
     }
     
     EAS_RESULT result=EAS_FAILURE;
@@ -367,7 +396,8 @@
         //LOGV("android_media_JetPlayer_setMuteArray(): mute flags successfully updated");
         return JNI_TRUE;
     } else {
-        LOGE("android_media_JetPlayer_setMuteArray(): failed to update mute flags with EAS error code %ld", result);
+        LOGE("android_media_JetPlayer_setMuteArray(): \
+            failed to update mute flags with EAS error code %ld", result);
         return JNI_FALSE;
     }
 }
@@ -382,7 +412,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for setMuteFlag()");
     }
     
     EAS_RESULT result;
@@ -407,7 +437,7 @@
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException",
-            "Unable to retrieve JetPlayer pointer for openFile()");
+            "Unable to retrieve JetPlayer pointer for triggerClip()");
     }
     
     EAS_RESULT result;
@@ -424,13 +454,39 @@
 
 
 // ----------------------------------------------------------------------------
+static jboolean
+android_media_JetPlayer_clearQueue(JNIEnv *env, jobject thiz)
+{
+    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+        thiz, javaJetPlayerFields.nativePlayerInJavaObj);
+    if (lpJet == NULL ) {
+        jniThrowException(env, "java/lang/IllegalStateException",
+            "Unable to retrieve JetPlayer pointer for clearQueue()");
+    }
+    
+    EAS_RESULT result = lpJet->clearQueue();
+    if(result==EAS_SUCCESS) {
+        //LOGV("android_media_JetPlayer_clearQueue(): clearQueue successful");
+        return JNI_TRUE;
+    } else {
+        LOGE("android_media_JetPlayer_clearQueue(): clearQueue failed with EAS error code %ld",
+                result);
+        return JNI_FALSE;
+    }
+}
+
+
+// ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 static JNINativeMethod gMethods[] = {
     // name,               signature,               funcPtr
     {"native_setup",       "(Ljava/lang/Object;II)Z", (void *)android_media_JetPlayer_setup},
     {"native_finalize",    "()V",                   (void *)android_media_JetPlayer_finalize},
     {"native_release",     "()V",                   (void *)android_media_JetPlayer_release},
-    {"native_openJetFile", "(Ljava/lang/String;)Z", (void *)android_media_JetPlayer_openFile},
+    {"native_loadJetFromFile", 
+                           "(Ljava/lang/String;)Z", (void *)android_media_JetPlayer_loadFromFile},
+    {"native_loadJetFromFileD", "(Ljava/io/FileDescriptor;JJ)Z",
+                                                    (void *)android_media_JetPlayer_loadFromFileD},
     {"native_closeJetFile","()Z",                   (void *)android_media_JetPlayer_closeFile},
     {"native_playJet",     "()Z",                   (void *)android_media_JetPlayer_play},
     {"native_pauseJet",    "()Z",                   (void *)android_media_JetPlayer_pause},
@@ -442,6 +498,7 @@
     {"native_setMuteArray","([ZZ)Z",                (void *)android_media_JetPlayer_setMuteArray},
     {"native_setMuteFlag", "(IZZ)Z",                (void *)android_media_JetPlayer_setMuteFlag},
     {"native_triggerClip", "(I)Z",                  (void *)android_media_JetPlayer_triggerClip},
+    {"native_clearQueue",  "()Z",                   (void *)android_media_JetPlayer_clearQueue},
 };
 
 #define JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME "mNativePlayerInJavaObj"
diff --git a/core/jni/android_net_wifi_Wifi.cpp b/core/jni/android_net_wifi_Wifi.cpp
index 722b5b8..c98207a 100644
--- a/core/jni/android_net_wifi_Wifi.cpp
+++ b/core/jni/android_net_wifi_Wifi.cpp
@@ -287,6 +287,24 @@
     return doBooleanCommand("DRIVER STOP", "OK");
 }
 
+static jboolean android_net_wifi_startPacketFiltering(JNIEnv* env, jobject clazz)
+{
+    return doBooleanCommand("DRIVER RXFILTER-ADD 0", "OK")
+	&& doBooleanCommand("DRIVER RXFILTER-ADD 1", "OK")
+	&& doBooleanCommand("DRIVER RXFILTER-START", "OK");
+}
+
+static jboolean android_net_wifi_stopPacketFiltering(JNIEnv* env, jobject clazz)
+{
+    jboolean result = doBooleanCommand("DRIVER RXFILTER-STOP", "OK");
+    if (result) {
+	(void)doBooleanCommand("DRIVER RXFILTER-REMOVE 1", "OK");
+	(void)doBooleanCommand("DRIVER RXFILTER-REMOVE 0", "OK");
+    }
+
+    return result;
+}
+
 static jint android_net_wifi_getRssiCommand(JNIEnv* env, jobject clazz)
 {
     char reply[256];
@@ -478,6 +496,8 @@
     { "setScanModeCommand", "(Z)Z", (void*) android_net_wifi_setScanModeCommand },
     { "startDriverCommand", "()Z", (void*) android_net_wifi_startDriverCommand },
     { "stopDriverCommand", "()Z", (void*) android_net_wifi_stopDriverCommand },
+    { "startPacketFiltering", "()Z", (void*) android_net_wifi_startPacketFiltering },
+    { "stopPacketFiltering", "()Z", (void*) android_net_wifi_stopPacketFiltering },
     { "setPowerModeCommand", "(I)Z", (void*) android_net_wifi_setPowerModeCommand },
     { "setNumAllowedChannelsCommand", "(I)Z", (void*) android_net_wifi_setNumAllowedChannelsCommand },
     { "getNumAllowedChannelsCommand", "()I", (void*) android_net_wifi_getNumAllowedChannelsCommand },
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp
index 6ba949c..a7a0428a 100644
--- a/core/jni/android_os_Debug.cpp
+++ b/core/jni/android_os_Debug.cpp
@@ -88,93 +88,98 @@
 #endif
 }
 
-static int read_mapinfo(FILE *fp, stats_t* stats)
+static void read_mapinfo(FILE *fp, stats_t* stats)
 {
     char line[1024];
     int len;
-    int skip;
+    bool skip, done = false;
 
     unsigned start = 0, size = 0, resident = 0, pss = 0;
     unsigned shared_clean = 0, shared_dirty = 0;
     unsigned private_clean = 0, private_dirty = 0;
     unsigned referenced = 0;
+    unsigned temp;
 
     int isNativeHeap;
     int isDalvikHeap;
     int isSqliteHeap;
 
-again:
-    isNativeHeap = 0;
-    isDalvikHeap = 0;
-    isSqliteHeap = 0;
-    skip = 0;
-    
-    if(fgets(line, 1024, fp) == 0) return 0;
+    if(fgets(line, 1024, fp) == 0) return;
 
-    len = strlen(line);
-    if (len < 1) return 0;
-    line[--len] = 0;
+    while (!done) {
+        isNativeHeap = 0;
+        isDalvikHeap = 0;
+        isSqliteHeap = 0;
+        skip = false;
 
-    /* ignore guard pages */
-    if (line[18] == '-') skip = 1;
+        len = strlen(line);
+        if (len < 1) return;
+        line[--len] = 0;
 
-    start = strtoul(line, 0, 16);
+        /* ignore guard pages */
+        if (len > 18 && line[18] == '-') skip = true;
 
-    if (len >= 50) {
-        if (!strcmp(line + 49, "[heap]")) {
+        start = strtoul(line, 0, 16);
+
+        if (strstr("[heap]", line)) {
             isNativeHeap = 1;
-        } else if (!strncmp(line + 49, "/dalvik-LinearAlloc", strlen("/dalvik-LinearAlloc"))) {
+        } else if (strstr("/dalvik-LinearAlloc", line)) {
             isDalvikHeap = 1;
-        } else if (!strncmp(line + 49, "/mspace/dalvik-heap", strlen("/mspace/dalvik-heap"))) {
+        } else if (strstr("/mspace/dalvik-heap", line)) {
             isDalvikHeap = 1;
-        } else if (!strncmp(line + 49, "/dalvik-heap-bitmap/", strlen("/dalvik-heap-bitmap/"))) {
+        } else if (strstr("/dalvik-heap-bitmap/", line)) {
             isDalvikHeap = 1;    
-        } else if (!strncmp(line + 49, "/tmp/sqlite-heap", strlen("/tmp/sqlite-heap"))) {
+        } else if (strstr("/tmp/sqlite-heap", line)) {
             isSqliteHeap = 1;
         }
-    }
 
-    // TODO: This needs to be fixed to be less fragile. If the order of this file changes or a new
-    // line is add, this method will return without filling out any of the information.
+        while (true) {
+            if (fgets(line, 1024, fp) == 0) {
+                done = true;
+                break;
+            }
 
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Size: %d kB", &size) != 1) return 0;
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Rss: %d kB", &resident) != 1) return 0;
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Pss: %d kB", &pss) != 1) return 0;
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Shared_Clean: %d kB", &shared_clean) != 1) return 0;
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Shared_Dirty: %d kB", &shared_dirty) != 1) return 0;
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Private_Clean: %d kB", &private_clean) != 1) return 0;
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Private_Dirty: %d kB", &private_dirty) != 1) return 0;
-    if (fgets(line, 1024, fp) == 0) return 0;
-    if (sscanf(line, "Referenced: %d kB", &referenced) != 1) return 0;
-    
-    if (skip) {
-        goto again;
-    }
+            if (sscanf(line, "Size: %d kB", &temp) == 1) {
+                size = temp;
+            } else if (sscanf(line, "Rss: %d kB", &temp) == 1) {
+                resident = temp;
+            } else if (sscanf(line, "Pss: %d kB", &temp) == 1) {
+                pss = temp;
+            } else if (sscanf(line, "Shared_Clean: %d kB", &temp) == 1) {
+                shared_clean = temp;
+            } else if (sscanf(line, "Shared_Dirty: %d kB", &temp) == 1) {
+                shared_dirty = temp;
+            } else if (sscanf(line, "Private_Clean: %d kB", &temp) == 1) {
+                private_clean = temp;
+            } else if (sscanf(line, "Private_Dirty: %d kB", &temp) == 1) {
+                private_dirty = temp;
+            } else if (sscanf(line, "Referenced: %d kB", &temp) == 1) {
+                referenced = temp;
+            } else if (strlen(line) > 40 && line[8] == '-' && line[17] == ' ') {
+                // looks like a new mapping
+                // example: "0000a000-00232000 rwxp 0000a000 00:00 0          [heap]"
+                break;
+            }
+        }
 
-    if (isNativeHeap) {
-        stats->nativePss += pss;
-        stats->nativePrivateDirty += private_dirty;
-        stats->nativeSharedDirty += shared_dirty;
-    } else if (isDalvikHeap) {
-        stats->dalvikPss += pss;
-        stats->dalvikPrivateDirty += private_dirty;
-        stats->dalvikSharedDirty += shared_dirty;
-    } else if (isSqliteHeap) {
-        // ignore
-    } else {
-        stats->otherPss += pss;
-        stats->otherPrivateDirty += shared_dirty;
-        stats->otherSharedDirty += private_dirty;
+        if (!skip) {
+            if (isNativeHeap) {
+                stats->nativePss += pss;
+                stats->nativePrivateDirty += private_dirty;
+                stats->nativeSharedDirty += shared_dirty;
+            } else if (isDalvikHeap) {
+                stats->dalvikPss += pss;
+                stats->dalvikPrivateDirty += private_dirty;
+                stats->dalvikSharedDirty += shared_dirty;
+            } else if ( isSqliteHeap) {
+                // ignore
+            } else {
+                stats->otherPss += pss;
+                stats->otherPrivateDirty += shared_dirty;
+                stats->otherSharedDirty += private_dirty;
+            }
+        }
     }
-    
-    return 1;
 }
 
 static void load_maps(int pid, stats_t* stats)
@@ -185,10 +190,8 @@
     sprintf(tmp, "/proc/%d/smaps", pid);
     fp = fopen(tmp, "r");
     if (fp == 0) return;
-    
-    while (read_mapinfo(fp, stats) != 0) {
-        // Do nothing
-    }
+
+    read_mapinfo(fp, stats);
     fclose(fp);
 }
 
diff --git a/core/jni/android_os_NetStat.cpp b/core/jni/android_os_NetStat.cpp
deleted file mode 100644
index 983f719..0000000
--- a/core/jni/android_os_NetStat.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/* //device/libs/android_runtime/android_os_Wifi.cpp
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
-**
-**     http://www.apache.org/licenses/LICENSE-2.0 
-**
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
-** limitations under the License.
-*/
-
-#define LOG_TAG "NetStat"
-
-#include "jni.h"
-#include <utils/misc.h>
-#include <android_runtime/AndroidRuntime.h>
-#include <utils/Log.h>
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#if HAVE_ANDROID_OS
-#include <utils/Atomic.h>
-#endif
-
-namespace android {
-
-static jint android_os_netStatGetTxPkts(JNIEnv* env, jobject clazz)
-{
-  int ret = 0;
-  int fd = -1;
-  char input[50];
-  
-  fd = open("/sys/class/net/rmnet0/statistics/tx_packets", O_RDONLY);
-  if (fd <= 0) {
-    fd = open("/sys/class/net/ppp0/statistics/tx_packets", O_RDONLY);
-  }
-  
-  if (fd > 0) {
-    int size = read(fd, input, 50);
-    if (size > 0) {
-      ret = atoi(input);
-    }
-    close(fd);
-  }
-  
-  return (jint)ret;
-}
-
-static jint android_os_netStatGetRxPkts(JNIEnv* env, jobject clazz)
-{
-  int ret = 0;
-  int fd = -1;
-  char input[50];
-  
-  fd = open("/sys/class/net/rmnet0/statistics/rx_packets", O_RDONLY);
-  if (fd <= 0) {
-    fd = open("/sys/class/net/ppp0/statistics/rx_packets", O_RDONLY);
-  }
-  
-  if (fd > 0) {
-    int size = read(fd, input, 50);
-    if (size > 0) {
-      ret = atoi(input);
-    }
-    close(fd);
-  }
-  
-  return (jint)ret;
-}
-
-static jint android_os_netStatGetRxBytes(JNIEnv* env, jobject clazz)
-{
-  int ret = 0;
-  int fd = -1;
-  char input[50];
-  
-  fd = open("/sys/class/net/rmnet0/statistics/rx_bytes", O_RDONLY);
-  if (fd <= 0) {
-    fd = open("/sys/class/net/ppp0/statistics/rx_bytes", O_RDONLY);
-  }
-  
-  if (fd > 0) {
-    int size = read(fd, input, 50);
-    if (size > 0) {
-      ret = atoi(input);
-    }
-    close(fd);
-  }
-  
-  return (jint)ret;
-}
-
-
-static jint android_os_netStatGetTxBytes(JNIEnv* env, jobject clazz)
-{
-  int ret = 0;
-  int fd = -1;
-  char input[50];
-  
-  fd = open("/sys/class/net/rmnet0/statistics/tx_bytes", O_RDONLY);
-  if (fd <= 0) {
-    fd = open("/sys/class/net/ppp0/statistics/tx_bytes", O_RDONLY);
-  }
-  
-  if (fd > 0) {
-    int size = read(fd, input, 50);
-    if (size > 0) {
-      ret = atoi(input);
-    }
-    close(fd);
-  }
-  
-  return (jint)ret;
-}
-
-// ----------------------------------------------------------------------------
-
-/*
- * JNI registration.
- */
-static JNINativeMethod gMethods[] = {
-    /* name, signature, funcPtr */
-
-    { "netStatGetTxPkts", "()I",
-      (void*) android_os_netStatGetTxPkts },
-
-    { "netStatGetRxPkts", "()I",
-      (void*) android_os_netStatGetRxPkts },
-
-    { "netStatGetTxBytes", "()I",
-      (void*) android_os_netStatGetTxBytes },
-
-    { "netStatGetRxBytes", "()I",
-      (void*) android_os_netStatGetRxBytes },
-
-};
-
-int register_android_os_NetStat(JNIEnv* env)
-{
-    jclass netStat = env->FindClass("android/os/NetStat");
-    LOG_FATAL_IF(netStat == NULL, "Unable to find class android/os/NetStat");
-
-    return AndroidRuntime::registerNativeMethods(env,
-            "android/os/NetStat", gMethods, NELEM(gMethods));
-}
-
-}; // namespace android
-
diff --git a/core/jni/android_server_BluetoothDeviceService.cpp b/core/jni/android_server_BluetoothDeviceService.cpp
index 61a4a26..0936310 100644
--- a/core/jni/android_server_BluetoothDeviceService.cpp
+++ b/core/jni/android_server_BluetoothDeviceService.cpp
@@ -428,36 +428,6 @@
 #endif
 }
 
-static jboolean isConnectableNative(JNIEnv *env, jobject object) {
-#ifdef HAVE_BLUETOOTH
-    LOGV(__FUNCTION__);
-    native_data_t *nat = get_native_data(env, object);
-    if (nat) {
-        DBusMessage *reply =
-            dbus_func_args(env, nat->conn, nat->adapter,
-                           DBUS_CLASS_NAME, "IsConnectable",
-                           DBUS_TYPE_INVALID);
-        return reply ? dbus_returns_boolean(env, reply) : JNI_FALSE;
-    }
-#endif
-    return JNI_FALSE;
-}
-
-static jboolean isDiscoverableNative(JNIEnv *env, jobject object) {
-#ifdef HAVE_BLUETOOTH
-    LOGV(__FUNCTION__);
-    native_data_t *nat = get_native_data(env, object);
-    if (nat) {
-        DBusMessage *reply =
-            dbus_func_args(env, nat->conn, nat->adapter,
-                           DBUS_CLASS_NAME, "IsDiscoverable",
-                           DBUS_TYPE_INVALID);
-        return reply ? dbus_returns_boolean(env, reply) : JNI_FALSE;
-    }
-#endif
-    return JNI_FALSE;
-}
-
 static jstring getModeNative(JNIEnv *env, jobject object) {
 #ifdef HAVE_BLUETOOTH
     LOGV(__FUNCTION__);
@@ -495,26 +465,6 @@
     return JNI_FALSE;
 }
 
-static void common_Bonding(JNIEnv *env, jobject object, int timeout_ms,
-                           const char *func, jstring address) {
-#ifdef HAVE_BLUETOOTH
-    native_data_t *nat = get_native_data(env, object);
-    if (nat) {
-        const char *c_address = env->GetStringUTFChars(address, NULL);
-        LOGV("... address = %s", c_address);
-        DBusMessage *reply =
-            dbus_func_args_timeout(env, nat->conn, timeout_ms, nat->adapter,
-                                   DBUS_CLASS_NAME, func,
-                                   DBUS_TYPE_STRING, &c_address,
-                                   DBUS_TYPE_INVALID);
-        env->ReleaseStringUTFChars(address, c_address);
-        if (reply) {
-            dbus_message_unref(reply);
-        }
-    }
-#endif
-}
-
 static jboolean createBondingNative(JNIEnv *env, jobject object,
                                     jstring address, jint timeout_ms) {
     LOGV(__FUNCTION__);
@@ -540,15 +490,49 @@
     return JNI_FALSE;
 }
 
-static void cancelBondingProcessNative(JNIEnv *env, jobject object,
+static jboolean cancelBondingProcessNative(JNIEnv *env, jobject object,
                                        jstring address) {
     LOGV(__FUNCTION__);
-    common_Bonding(env, object, -1, "CancelBondingProcess", address);
+#ifdef HAVE_BLUETOOTH
+    native_data_t *nat = get_native_data(env, object);
+    if (nat) {
+        const char *c_address = env->GetStringUTFChars(address, NULL);
+        LOGV("... address = %s", c_address);
+        DBusMessage *reply =
+            dbus_func_args_timeout(env, nat->conn, -1, nat->adapter,
+                                   DBUS_CLASS_NAME, "CancelBondingProcess",
+                                   DBUS_TYPE_STRING, &c_address,
+                                   DBUS_TYPE_INVALID);
+        env->ReleaseStringUTFChars(address, c_address);
+        if (reply) {
+            dbus_message_unref(reply);
+        }
+        return JNI_TRUE;
+    }
+#endif
+    return JNI_FALSE;
 }
 
-static void removeBondingNative(JNIEnv *env, jobject object, jstring address) {
+static jboolean removeBondingNative(JNIEnv *env, jobject object, jstring address) {
     LOGV(__FUNCTION__);
-    common_Bonding(env, object, -1, "RemoveBonding", address);
+#ifdef HAVE_BLUETOOTH
+    native_data_t *nat = get_native_data(env, object);
+    if (nat) {
+        const char *c_address = env->GetStringUTFChars(address, NULL);
+        LOGV("... address = %s", c_address);
+        DBusMessage *reply =
+            dbus_func_args_timeout(env, nat->conn, -1, nat->adapter,
+                                   DBUS_CLASS_NAME, "RemoveBonding",
+                                   DBUS_TYPE_STRING, &c_address,
+                                   DBUS_TYPE_INVALID);
+        env->ReleaseStringUTFChars(address, c_address);
+        if (reply) {
+            dbus_message_unref(reply);
+        }
+        return JNI_TRUE;
+    }
+#endif
+    return JNI_FALSE;
 }
 
 static jobjectArray listBondingsNative(JNIEnv *env, jobject object) {
@@ -660,14 +644,6 @@
     return JNI_FALSE;
 }
 
-static jstring getMajorClassNative(JNIEnv *env, jobject obj) {
-    return common_Get(env, obj, "GetMajorClass");
-}
-
-static jstring getMinorClassNative(JNIEnv *env, jobject obj) {
-    return common_Get(env, obj, "GetMinorClass");
-}
-
 static jstring common_getRemote(JNIEnv *env, jobject object, const char *func,
                                 jstring address) {
     LOGV("%s:%s", __FUNCTION__, func);
@@ -704,66 +680,6 @@
     return NULL;
 }
 
-static jstring getRemoteAliasNative(JNIEnv *env, jobject obj, jstring address) {
-    return common_getRemote(env, obj, "GetRemoteAlias", address);
-}
-
-static jboolean setRemoteAliasNative(JNIEnv *env, jobject obj,
-                                     jstring address, jstring alias) {
-#ifdef HAVE_BLUETOOTH
-    LOGV(__FUNCTION__);
-    native_data_t *nat = get_native_data(env, obj);
-    if (nat) {
-        const char *c_address = env->GetStringUTFChars(address, NULL);
-        const char *c_alias = env->GetStringUTFChars(alias, NULL);
-
-        LOGV("... address = %s alias = %s", c_address, c_alias);
-
-        DBusMessage *reply = dbus_func_args(env, nat->conn, nat->adapter,
-                                            DBUS_CLASS_NAME, "SetRemoteAlias",
-                                            DBUS_TYPE_STRING, &c_address,
-                                            DBUS_TYPE_STRING, &c_alias,
-                                            DBUS_TYPE_INVALID);
-
-        env->ReleaseStringUTFChars(address, c_address);
-        env->ReleaseStringUTFChars(alias, c_alias);
-        if (reply)
-        {
-            dbus_message_unref(reply);
-            return JNI_TRUE;
-        }
-        return JNI_FALSE;
-    }
-#endif
-    return JNI_FALSE;
-}
-
-static jboolean clearRemoteAliasNative(JNIEnv *env, jobject obj, jstring address) {
-#ifdef HAVE_BLUETOOTH
-    LOGV(__FUNCTION__);
-    native_data_t *nat = get_native_data(env, obj);
-    if (nat) {
-        const char *c_address = env->GetStringUTFChars(address, NULL);
-
-        LOGV("... address = %s", c_address);
-
-        DBusMessage *reply = dbus_func_args(env, nat->conn, nat->adapter,
-                                            DBUS_CLASS_NAME, "ClearRemoteAlias",
-                                            DBUS_TYPE_STRING, &c_address,
-                                            DBUS_TYPE_INVALID);
-
-        env->ReleaseStringUTFChars(address, c_address);
-        if (reply)
-        {
-            dbus_message_unref(reply);
-            return JNI_TRUE;
-        }
-        return JNI_FALSE;
-    }
-#endif
-    return JNI_FALSE;
-}
-
 static jstring getRemoteVersionNative(JNIEnv *env, jobject obj, jstring address) {
     return common_getRemote(env, obj, "GetRemoteVersion", address);
 }
@@ -780,14 +696,6 @@
     return common_getRemote(env, obj, "GetRemoteCompany", address);
 }
 
-static jstring getRemoteMajorClassNative(JNIEnv *env, jobject obj, jstring address) {
-    return common_getRemote(env, obj, "GetRemoteMajorClass", address);
-}
-
-static jstring getRemoteMinorClassNative(JNIEnv *env, jobject obj, jstring address) {
-    return common_getRemote(env, obj, "GetRemoteMinorClass", address);
-}
-
 static jstring getRemoteNameNative(JNIEnv *env, jobject obj, jstring address) {
     return common_getRemote(env, obj, "GetRemoteName", address);
 }
@@ -800,28 +708,6 @@
     return common_getRemote(env, obj, "LastUsed", address);
 }
 
-static jobjectArray getRemoteServiceClassesNative(JNIEnv *env, jobject object,
-                                                   jstring address) {
-#ifdef HAVE_BLUETOOTH
-    LOGV(__FUNCTION__);
-    native_data_t *nat = get_native_data(env, object);
-    if (nat) {
-        const char *c_address = env->GetStringUTFChars(address, NULL);
-
-        LOGV("... address = %s", c_address);
-
-        DBusMessage *reply =
-            dbus_func_args(env, nat->conn, nat->adapter,
-                           DBUS_CLASS_NAME, "GetRemoteServiceClasses",
-                           DBUS_TYPE_STRING, &c_address,
-                           DBUS_TYPE_INVALID);
-        env->ReleaseStringUTFChars(address, c_address);
-        return reply ? dbus_returns_array_of_strings(env, reply) : NULL;
-    }
-#endif
-    return NULL;
-}
-
 static jint getRemoteClassNative(JNIEnv *env, jobject object, jstring address) {
 #ifdef HAVE_BLUETOOTH
     LOGV(__FUNCTION__);
@@ -1070,8 +956,6 @@
     {"getAddressNative", "()Ljava/lang/String;", (void *)getAddressNative},
     {"getNameNative", "()Ljava/lang/String;", (void*)getNameNative},
     {"setNameNative", "(Ljava/lang/String;)Z", (void *)setNameNative},
-    {"getMajorClassNative", "()Ljava/lang/String;", (void *)getMajorClassNative},
-    {"getMinorClassNative", "()Ljava/lang/String;", (void *)getMinorClassNative},
     {"getVersionNative", "()Ljava/lang/String;", (void *)getVersionNative},
     {"getRevisionNative", "()Ljava/lang/String;", (void *)getRevisionNative},
     {"getManufacturerNative", "()Ljava/lang/String;", (void *)getManufacturerNative},
@@ -1100,17 +984,11 @@
     {"removeBondingNative", "(Ljava/lang/String;)Z", (void *)removeBondingNative},
 
     {"getRemoteNameNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteNameNative},
-    {"getRemoteAliasNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteAliasNative},
-    {"setRemoteAliasNative", "(Ljava/lang/String;Ljava/lang/String;)Z", (void *)setRemoteAliasNative},
-    {"clearRemoteAliasNative", "(Ljava/lang/String;)Z", (void *)clearRemoteAliasNative},
     {"getRemoteVersionNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteVersionNative},
     {"getRemoteRevisionNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteRevisionNative},
     {"getRemoteClassNative", "(Ljava/lang/String;)I", (void *)getRemoteClassNative},
     {"getRemoteManufacturerNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteManufacturerNative},
     {"getRemoteCompanyNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteCompanyNative},
-    {"getRemoteMajorClassNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteMajorClassNative},
-    {"getRemoteMinorClassNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)getRemoteMinorClassNative},
-    {"getRemoteServiceClassesNative", "(Ljava/lang/String;)[Ljava/lang/String;", (void *)getRemoteServiceClassesNative},
     {"getRemoteServiceChannelNative", "(Ljava/lang/String;S)Z", (void *)getRemoteServiceChannelNative},
     {"getRemoteFeaturesNative", "(Ljava/lang/String;)[B", (void *)getRemoteFeaturesNative},
     {"lastSeenNative", "(Ljava/lang/String;)Ljava/lang/String;", (void *)lastSeenNative},
diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp
index 3468265..75a0fbee 100644
--- a/core/jni/android_server_BluetoothEventLoop.cpp
+++ b/core/jni/android_server_BluetoothEventLoop.cpp
@@ -47,8 +47,6 @@
 static jmethodID method_onRemoteClassUpdated;
 static jmethodID method_onRemoteNameUpdated;
 static jmethodID method_onRemoteNameFailed;
-static jmethodID method_onRemoteAliasChanged;
-static jmethodID method_onRemoteAliasCleared;
 static jmethodID method_onRemoteDeviceConnected;
 static jmethodID method_onRemoteDeviceDisconnectRequested;
 static jmethodID method_onRemoteDeviceDisconnected;
@@ -60,6 +58,8 @@
 
 static jmethodID method_onPasskeyAgentRequest;
 static jmethodID method_onPasskeyAgentCancel;
+static jmethodID method_onAuthAgentAuthorize;
+static jmethodID method_onAuthAgentCancel;
 
 typedef event_loop_native_data_t native_data_t;
 
@@ -85,7 +85,6 @@
     method_onRemoteClassUpdated = env->GetMethodID(clazz, "onRemoteClassUpdated", "(Ljava/lang/String;I)V");
     method_onRemoteNameUpdated = env->GetMethodID(clazz, "onRemoteNameUpdated", "(Ljava/lang/String;Ljava/lang/String;)V");
     method_onRemoteNameFailed = env->GetMethodID(clazz, "onRemoteNameFailed", "(Ljava/lang/String;)V");
-    method_onRemoteAliasChanged = env->GetMethodID(clazz, "onRemoteAliasChanged", "(Ljava/lang/String;Ljava/lang/String;)V");
     method_onRemoteDeviceConnected = env->GetMethodID(clazz, "onRemoteDeviceConnected", "(Ljava/lang/String;)V");
     method_onRemoteDeviceDisconnectRequested = env->GetMethodID(clazz, "onRemoteDeviceDisconnectRequested", "(Ljava/lang/String;)V");
     method_onRemoteDeviceDisconnected = env->GetMethodID(clazz, "onRemoteDeviceDisconnected", "(Ljava/lang/String;)V");
@@ -96,6 +95,8 @@
 
     method_onPasskeyAgentRequest = env->GetMethodID(clazz, "onPasskeyAgentRequest", "(Ljava/lang/String;I)V");
     method_onPasskeyAgentCancel = env->GetMethodID(clazz, "onPasskeyAgentCancel", "(Ljava/lang/String;)V");
+    method_onAuthAgentAuthorize = env->GetMethodID(clazz, "onAuthAgentAuthorize", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z");
+    method_onAuthAgentCancel = env->GetMethodID(clazz, "onAuthAgentCancel", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
     method_onGetRemoteServiceChannelResult = env->GetMethodID(clazz, "onGetRemoteServiceChannelResult", "(Ljava/lang/String;I)V");
 
     field_mNativeData = env->GetFieldID(clazz, "mNativeData", "I");
@@ -139,12 +140,12 @@
 #ifdef HAVE_BLUETOOTH
 static DBusHandlerResult event_filter(DBusConnection *conn, DBusMessage *msg,
                                       void *data);
-static DBusHandlerResult passkey_agent_event_filter(DBusConnection *conn,
-                                                    DBusMessage *msg,
-                                                    void *data);
+static DBusHandlerResult agent_event_filter(DBusConnection *conn,
+                                            DBusMessage *msg,
+                                            void *data);
 
-static const DBusObjectPathVTable passkey_agent_vtable = {
-    NULL, passkey_agent_event_filter, NULL, NULL, NULL, NULL
+static const DBusObjectPathVTable agent_vtable = {
+    NULL, agent_event_filter, NULL, NULL, NULL, NULL
 };
 #endif
 
@@ -193,9 +194,9 @@
         }
 
         // Add an object handler for passkey agent method calls
-        const char *path = "/android/bluetooth/PasskeyAgent";
+        const char *path = "/android/bluetooth/Agent";
         if (!dbus_connection_register_object_path(nat->conn, path,
-                                                  &passkey_agent_vtable, NULL)) {
+                &agent_vtable, NULL)) {
             LOGE("%s: Can't register object path %s for agent!",
                  __FUNCTION__, path);
             return JNI_FALSE;
@@ -204,7 +205,7 @@
         // RegisterDefaultPasskeyAgent() will fail until hcid is up, so keep
         // trying for 10 seconds.
         int attempt;
-        for (attempt = 1000; attempt > 0; attempt--) {
+        for (attempt = 0; attempt < 1000; attempt++) {
             DBusMessage *reply = dbus_func_args_error(env, nat->conn, &err,
                     BLUEZ_DBUS_BASE_PATH,
                     "org.bluez.Security", "RegisterDefaultPasskeyAgent",
@@ -213,7 +214,8 @@
             if (reply) {
                 // Success
                 dbus_message_unref(reply);
-                return JNI_TRUE;
+                LOGV("Registered agent on attempt %d of 1000\n", attempt);
+                break;
             } else if (dbus_error_has_name(&err,
                     "org.freedesktop.DBus.Error.ServiceUnknown")) {
                 // hcid is still down, retry
@@ -225,9 +227,25 @@
                 return JNI_FALSE;
             }
         }
-        LOGE("Time-out trying to call RegisterDefaultPasskeyAgent(), "
-             "is hcid running?");
-        return JNI_FALSE;
+        if (attempt == 1000) {
+            LOGE("Time-out trying to call RegisterDefaultPasskeyAgent(), "
+                 "is hcid running?");
+            return JNI_FALSE;
+        }
+
+        // Now register the Auth agent
+        DBusMessage *reply = dbus_func_args_error(env, nat->conn, &err,
+                BLUEZ_DBUS_BASE_PATH,
+                "org.bluez.Security", "RegisterDefaultAuthorizationAgent",
+                DBUS_TYPE_STRING, &path,
+                DBUS_TYPE_INVALID);
+        if (!reply) {
+            LOG_AND_FREE_DBUS_ERROR(&err);
+            return JNI_FALSE;
+        }
+
+        dbus_message_unref(reply);
+        return JNI_TRUE;
     }
 
 #endif
@@ -243,12 +261,19 @@
         DBusError err;
         dbus_error_init(&err);
 
-        const char *path = "/android/bluetooth/PasskeyAgent";
+        const char *path = "/android/bluetooth/Agent";
         DBusMessage *reply =
             dbus_func_args(env, nat->conn, BLUEZ_DBUS_BASE_PATH,
-                           "org.bluez.Security", "UnregisterDefaultPasskeyAgent",
-                           DBUS_TYPE_STRING, &path,
-                           DBUS_TYPE_INVALID);
+                    "org.bluez.Security", "UnregisterDefaultPasskeyAgent",
+                    DBUS_TYPE_STRING, &path,
+                    DBUS_TYPE_INVALID);
+        if (reply) dbus_message_unref(reply);
+
+        reply =
+            dbus_func_args(env, nat->conn, BLUEZ_DBUS_BASE_PATH,
+                    "org.bluez.Security", "UnregisterDefaultAuthorizationAgent",
+                    DBUS_TYPE_STRING, &path,
+                    DBUS_TYPE_INVALID);
         if (reply) dbus_message_unref(reply);
 
         dbus_connection_unregister_object_path(nat->conn, path);
@@ -395,34 +420,6 @@
         return DBUS_HANDLER_RESULT_HANDLED;
     } else if (dbus_message_is_signal(msg,
                                       "org.bluez.Adapter",
-                                      "RemoteAliasChanged")) {
-        char *c_address, *c_alias;
-        if (dbus_message_get_args(msg, &err,
-                                  DBUS_TYPE_STRING, &c_address,
-                                  DBUS_TYPE_STRING, &c_alias,
-                                  DBUS_TYPE_INVALID)) {
-            LOGV("... address = %s, alias = %s", c_address, c_alias);
-            env->CallVoidMethod(nat->me,
-                                method_onRemoteAliasChanged,
-                                env->NewStringUTF(c_address),
-                                env->NewStringUTF(c_alias));
-        } else LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, msg);
-        return DBUS_HANDLER_RESULT_HANDLED;
-    } else if (dbus_message_is_signal(msg,
-                                      "org.bluez.Adapter",
-                                      "RemoteAliasCleared")) {
-        char *c_address;
-        if (dbus_message_get_args(msg, &err,
-                                  DBUS_TYPE_STRING, &c_address,
-                                  DBUS_TYPE_INVALID)) {
-            LOGV("... address = %s", c_address);
-            env->CallVoidMethod(nat->me,
-                                method_onRemoteAliasCleared,
-                                env->NewStringUTF(c_address));
-        } else LOG_AND_FREE_DBUS_ERROR_WITH_MSG(&err, msg);
-        return DBUS_HANDLER_RESULT_HANDLED;
-    } else if (dbus_message_is_signal(msg,
-                                      "org.bluez.Adapter",
                                       "RemoteDeviceConnected")) {
         char *c_address;
         if (dbus_message_get_args(msg, &err,
@@ -518,9 +515,8 @@
 }
 
 // Called by dbus during WaitForAndDispatchEventNative()
-static DBusHandlerResult passkey_agent_event_filter(DBusConnection *conn,
-                                                    DBusMessage *msg,
-                                                    void *data) {
+static DBusHandlerResult agent_event_filter(DBusConnection *conn,
+                                            DBusMessage *msg, void *data) {
     native_data_t *nat = event_loop_nat;
     JNIEnv *env;
 
@@ -573,11 +569,120 @@
         env->CallVoidMethod(nat->me, method_onPasskeyAgentCancel,
                             env->NewStringUTF(address));
 
+        // reply
+        DBusMessage *reply = dbus_message_new_method_return(msg);
+        if (!reply) {
+            LOGE("%s: Cannot create message reply\n", __FUNCTION__);
+            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+        }
+        dbus_connection_send(nat->conn, reply, NULL);
+        dbus_message_unref(reply);
         return DBUS_HANDLER_RESULT_HANDLED;
 
     } else if (dbus_message_is_method_call(msg,
             "org.bluez.PasskeyAgent", "Release")) {
-        LOGE("We are no longer the passkey agent!");
+        LOGW("We are no longer the passkey agent!");
+
+        // reply
+        DBusMessage *reply = dbus_message_new_method_return(msg);
+        if (!reply) {
+            LOGE("%s: Cannot create message reply\n", __FUNCTION__);
+            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+        }
+        dbus_connection_send(nat->conn, reply, NULL);
+        dbus_message_unref(reply);
+        return DBUS_HANDLER_RESULT_HANDLED;
+    } else if (dbus_message_is_method_call(msg,
+            "org.bluez.AuthorizationAgent", "Authorize")) {
+        const char *adapter;
+        const char *address;
+        const char *service;
+        const char *uuid;
+        if (!dbus_message_get_args(msg, NULL,
+                                   DBUS_TYPE_STRING, &adapter,
+                                   DBUS_TYPE_STRING, &address,
+                                   DBUS_TYPE_STRING, &service,
+                                   DBUS_TYPE_STRING, &uuid,
+                                   DBUS_TYPE_INVALID)) {
+            LOGE("%s: Invalid arguments for Authorize() method", __FUNCTION__);
+            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+        }
+
+        LOGV("... address = %s", address);
+        LOGV("... service = %s", service);
+        LOGV("... uuid = %s", uuid);
+
+        bool auth_granted = env->CallBooleanMethod(nat->me,
+                method_onAuthAgentAuthorize, env->NewStringUTF(address),
+                env->NewStringUTF(service), env->NewStringUTF(uuid));
+
+        // reply
+        if (auth_granted) {
+            DBusMessage *reply = dbus_message_new_method_return(msg);
+            if (!reply) {
+                LOGE("%s: Cannot create message reply\n", __FUNCTION__);
+                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+            }
+            dbus_connection_send(nat->conn, reply, NULL);
+            dbus_message_unref(reply);
+        } else {
+            DBusMessage *reply = dbus_message_new_error(msg,
+                    "org.bluez.Error.Rejected", "Authorization rejected");
+            if (!reply) {
+                LOGE("%s: Cannot create message reply\n", __FUNCTION__);
+                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+            }
+            dbus_connection_send(nat->conn, reply, NULL);
+            dbus_message_unref(reply);
+        }
+        return DBUS_HANDLER_RESULT_HANDLED;
+    } else if (dbus_message_is_method_call(msg,
+            "org.bluez.AuthorizationAgent", "Cancel")) {
+        const char *adapter;
+        const char *address;
+        const char *service;
+        const char *uuid;
+        if (!dbus_message_get_args(msg, NULL,
+                                   DBUS_TYPE_STRING, &adapter,
+                                   DBUS_TYPE_STRING, &address,
+                                   DBUS_TYPE_STRING, &service,
+                                   DBUS_TYPE_STRING, &uuid,
+                                   DBUS_TYPE_INVALID)) {
+            LOGE("%s: Invalid arguments for Cancel() method", __FUNCTION__);
+            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+        }
+
+        LOGV("... address = %s", address);
+        LOGV("... service = %s", service);
+        LOGV("... uuid = %s", uuid);
+
+        env->CallVoidMethod(nat->me,
+                method_onAuthAgentCancel, env->NewStringUTF(address),
+                env->NewStringUTF(service), env->NewStringUTF(uuid));
+
+        // reply
+        DBusMessage *reply = dbus_message_new_method_return(msg);
+        if (!reply) {
+            LOGE("%s: Cannot create message reply\n", __FUNCTION__);
+            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+        }
+        dbus_connection_send(nat->conn, reply, NULL);
+        dbus_message_unref(reply);
+        return DBUS_HANDLER_RESULT_HANDLED;
+
+    } else if (dbus_message_is_method_call(msg,
+            "org.bluez.AuthorizationAgent", "Release")) {
+        LOGW("We are no longer the auth agent!");
+
+        // reply
+        DBusMessage *reply = dbus_message_new_method_return(msg);
+        if (!reply) {
+            LOGE("%s: Cannot create message reply\n", __FUNCTION__);
+            return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+        }
+        dbus_connection_send(nat->conn, reply, NULL);
+        dbus_message_unref(reply);
+        return DBUS_HANDLER_RESULT_HANDLED;
     } else {
         LOGV("... ignored");
     }
@@ -614,7 +719,8 @@
 #define BOND_RESULT_SUCCESS 0
 #define BOND_RESULT_AUTH_FAILED 1
 #define BOND_RESULT_AUTH_REJECTED 2
-#define BOND_RESULT_REMOTE_DEVICE_DOWN 3
+#define BOND_RESULT_AUTH_CANCELED 3
+#define BOND_RESULT_REMOTE_DEVICE_DOWN 4
 void onCreateBondingResult(DBusMessage *msg, void *user) {
     LOGV(__FUNCTION__);
 
@@ -637,7 +743,11 @@
             // happens if either side presses 'cancel' at the pairing dialog.
             LOGV("... error = %s (%s)\n", err.name, err.message);
             result = BOND_RESULT_AUTH_REJECTED;
-        } else if (!strcmp(err.name, BLUEZ_DBUS_BASE_IFC ".ConnectionAttemptFailed")) {
+        } else if (!strcmp(err.name, BLUEZ_DBUS_BASE_IFC ".Error.AuthenticationCanceled")) {
+            // Not sure if this happens
+            LOGV("... error = %s (%s)\n", err.name, err.message);
+            result = BOND_RESULT_AUTH_CANCELED;
+        } else if (!strcmp(err.name, BLUEZ_DBUS_BASE_IFC ".Error.ConnectionAttemptFailed")) {
             // Other device is not responding at all
             LOGV("... error = %s (%s)\n", err.name, err.message);
             result = BOND_RESULT_REMOTE_DEVICE_DOWN;
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index add1080..d147bcc 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -44,6 +44,7 @@
     jfieldID mAssetCookie;
     jfieldID mResourceId;
     jfieldID mChangingConfigurations;
+    jfieldID mDensity;
 } gTypedValueOffsets;
 
 static struct assetfiledescriptor_offsets_t
@@ -83,7 +84,11 @@
 
 static jint copyValue(JNIEnv* env, jobject outValue, const ResTable* table,
                       const Res_value& value, uint32_t ref, ssize_t block,
-                      uint32_t typeSpecFlags)
+                      uint32_t typeSpecFlags, ResTable_config* config = NULL);
+
+jint copyValue(JNIEnv* env, jobject outValue, const ResTable* table,
+               const Res_value& value, uint32_t ref, ssize_t block,
+               uint32_t typeSpecFlags, ResTable_config* config)
 {
     env->SetIntField(outValue, gTypedValueOffsets.mType, value.dataType);
     env->SetIntField(outValue, gTypedValueOffsets.mAssetCookie,
@@ -93,6 +98,9 @@
     env->SetIntField(outValue, gTypedValueOffsets.mResourceId, ref);
     env->SetIntField(outValue, gTypedValueOffsets.mChangingConfigurations,
             typeSpecFlags);
+    if (config != NULL) {
+        env->SetIntField(outValue, gTypedValueOffsets.mDensity, config->density);
+    }
     return block;
 }
 
@@ -703,13 +711,14 @@
     const ResTable& res(am->getResources());
 
     Res_value value;
+    ResTable_config config;
     uint32_t typeSpecFlags;
-    ssize_t block = res.getResource(ident, &value, false, &typeSpecFlags);
+    ssize_t block = res.getResource(ident, &value, false, &typeSpecFlags, &config);
     uint32_t ref = ident;
     if (resolve) {
         block = res.resolveReference(&value, block, &ref);
     }
-    return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags) : block;
+    return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags, &config) : block;
 }
 
 static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobject clazz,
@@ -1648,6 +1657,8 @@
     gTypedValueOffsets.mChangingConfigurations
         = env->GetFieldID(typedValue, "changingConfigurations", "I");
     LOG_FATAL_IF(gTypedValueOffsets.mChangingConfigurations == NULL, "Unable to find TypedValue.changingConfigurations");
+    gTypedValueOffsets.mDensity = env->GetFieldID(typedValue, "density", "I");
+    LOG_FATAL_IF(gTypedValueOffsets.mDensity == NULL, "Unable to find TypedValue.density");
 
     jclass assetFd = env->FindClass("android/content/res/AssetFileDescriptor");
     LOG_FATAL_IF(assetFd == NULL, "Unable to find class android/content/res/AssetFileDescriptor");
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index 8bacc74..fbbd852 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -18,7 +18,7 @@
 #include <android_runtime/AndroidRuntime.h>
 #include <utils/misc.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
 #include <GLES/gl.h>
 
 #include <ui/EGLNativeWindowSurface.h>
diff --git a/core/jni/server/com_android_server_HardwareService.cpp b/core/jni/server/com_android_server_HardwareService.cpp
index 224ab18..ac36348 100644
--- a/core/jni/server/com_android_server_HardwareService.cpp
+++ b/core/jni/server/com_android_server_HardwareService.cpp
@@ -28,21 +28,21 @@
 namespace android
 {
 
-static void on(JNIEnv *env, jobject clazz)
+static void vibratorOn(JNIEnv *env, jobject clazz, jlong timeout_ms)
 {
-    // LOGI("on\n");
-    vibrator_on();
+    // LOGI("vibratorOn\n");
+    vibrator_on(timeout_ms);
 }
 
-static void off(JNIEnv *env, jobject clazz)
+static void vibratorOff(JNIEnv *env, jobject clazz)
 {
-    // LOGI("off\n");
+    // LOGI("vibratorOff\n");
     vibrator_off();
 }
 
 static JNINativeMethod method_table[] = {
-    { "on", "()V", (void*)on },
-    { "off", "()V", (void*)off }
+    { "vibratorOn", "(J)V", (void*)vibratorOn },
+    { "vibratorOff", "()V", (void*)vibratorOff }
 };
 
 int register_android_os_Vibrator(JNIEnv *env)
diff --git a/core/jni/server/com_android_server_KeyInputQueue.cpp b/core/jni/server/com_android_server_KeyInputQueue.cpp
index 4e9ffb1..63830d5 100644
--- a/core/jni/server/com_android_server_KeyInputQueue.cpp
+++ b/core/jni/server/com_android_server_KeyInputQueue.cpp
@@ -205,6 +205,25 @@
     return st;
 }
 
+static jboolean
+android_server_KeyInputQueue_hasKeys(JNIEnv* env, jobject clazz,
+                                     jintArray keyCodes, jbooleanArray outFlags)
+{
+    jboolean ret = JNI_FALSE;
+
+    int32_t* codes = env->GetIntArrayElements(keyCodes, NULL);
+    uint8_t* flags = env->GetBooleanArrayElements(outFlags, NULL);
+    size_t numCodes = env->GetArrayLength(keyCodes);
+    if (numCodes == env->GetArrayLength(outFlags)) {
+        gLock.lock();
+        if (gHub != NULL) ret = gHub->hasKeys(numCodes, codes, flags);
+        gLock.unlock();
+    }
+
+    env->ReleaseBooleanArrayElements(outFlags, flags, 0);
+    env->ReleaseIntArrayElements(keyCodes, codes, 0);
+    return ret;
+}
 
 // ----------------------------------------------------------------------------
 
@@ -233,6 +252,8 @@
         (void*) android_server_KeyInputQueue_getKeycodeState },
     { "getKeycodeState", "(II)I",
         (void*) android_server_KeyInputQueue_getKeycodeStateDevice },
+    { "hasKeys", "([I[Z)Z",
+        (void*) android_server_KeyInputQueue_hasKeys },
 };
 
 int register_android_server_KeyInputQueue(JNIEnv* env)
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index ded909f..0e8d3fd 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -549,6 +549,13 @@
         android:label="@string/permlab_mount_unmount_filesystems"
         android:description="@string/permdesc_mount_unmount_filesystems" />
 
+    <!-- Allows formatting file systems for removable storage. -->
+    <permission android:name="android.permission.MOUNT_FORMAT_FILESYSTEMS"
+        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
+        android:protectionLevel="dangerous"
+        android:label="@string/permlab_mount_format_filesystems"
+        android:description="@string/permdesc_mount_format_filesystems" />
+
     <!-- Allows applications to disable the keyguard -->
     <permission android:name="android.permission.DISABLE_KEYGUARD"
         android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
@@ -725,8 +732,9 @@
         android:description="@string/permdesc_fotaUpdate"
         android:protectionLevel="signature" />
 
-    <!-- Allows an application to update the collected battery statistics -->
-    <permission android:name="android.permission.BATTERY_STATS"
+    <!-- Allows an application to update device statistics. Not for
+         use by third party apps. -->
+    <permission android:name="android.permission.UPDATE_DEVICE_STATS"
         android:label="@string/permlab_batteryStats"
         android:description="@string/permdesc_batteryStats"
         android:protectionLevel="signature" />
@@ -902,6 +910,39 @@
         android:description="@string/permdesc_checkinProperties"
         android:protectionLevel="signature" />
 
+    <!-- Allows an application to collect component usage
+         statistics -->
+    <permission android:name="android.permission.PACKAGE_USAGE_STATS"
+        android:label="@string/permlab_pkgUsageStats"
+        android:description="@string/permdesc_pkgUsageStats"
+        android:protectionLevel="normal" />
+
+    <!-- Allows an application to collect battery statistics -->
+    <permission android:name="android.permission.BATTERY_STATS"
+        android:label="@string/permlab_batteryStats"
+        android:description="@string/permdesc_batteryStats"
+        android:protectionLevel="normal" />
+
+    <!-- Allows an application to tell the gadget service which application
+         can access gadget's data.  The normal user flow is that a user
+         picks a gadget to go into a particular host, thereby giving that
+         host application access to the private data from the gadget app.
+         An application that has this permission should honor that contract.
+         Very few applications should need to use this permission. -->
+    <permission android:name="android.permission.BIND_GADGET"
+        android:permissionGroup="android.permission-group.PERSONAL_INFO"
+        android:label="@string/permlab_bindGadget"
+        android:description="@string/permdesc_bindGadget"
+        android:protectionLevel="signature" />
+
+    <!-- Allows applications to change the background data setting
+         @hide pending API council -->
+    <permission android:name="android.permission.CHANGE_BACKGROUND_DATA_SETTING"
+        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
+        android:protectionLevel="signature"
+        android:description="@string/permdesc_changeBackgroundDataSetting"
+        android:label="@string/permlab_changeBackgroundDataSetting" />
+
     <application android:process="system"
                  android:persistent="true"
                  android:hasCode="false"
@@ -930,43 +971,27 @@
                 android:theme="@style/Theme.Dialog.Alert"
                 android:excludeFromRecents="true">
         </activity>
-        <provider android:name=".server.checkin.CheckinProvider"
-                android:authorities="android.server.checkin"
-                android:multiprocess="false" />
+        <activity android:name="com.android.internal.app.UsbStorageStopActivity"
+                android:theme="@style/Theme.Dialog.Alert"
+                android:excludeFromRecents="true">
+        </activity>
+        <activity android:name="com.android.internal.app.ExternalMediaFormatActivity"
+                android:theme="@style/Theme.Dialog.Alert"
+                android:excludeFromRecents="true">
+        </activity>
+
         <provider android:name=".content.SyncProvider"
                 android:authorities="sync" android:multiprocess="false" />
 
         <service android:name="com.android.server.LoadAverageService"
             android:exported="true" />
-        <receiver
-            android:name=".server.checkin.UpdateReceiver$DownloadCompletedBroadcastReceiver"
-            android:exported="true" />
-
-          <receiver android:name="com.google.android.server.checkin.SecretCodeReceiver">
-            <intent-filter>
-                <action android:name="android.provider.Telephony.SECRET_CODE" />
-                <data android:scheme="android_secret_code"
-                        android:host="682" />  <!-- 682 = "OTA" on dialpad -->
-                <data android:scheme="android_secret_code"
-                        android:host="682364" />  <!-- 682364 = "OTAENG" -->
-                <data android:scheme="android_secret_code"
-                        android:host="682226" />  <!-- 682226 = "OTACAN" -->
-                <data android:scheme="android_secret_code"
-                        android:host="682668" />  <!-- 682668 = "OTANOT" -->
-            </intent-filter>
-        </receiver>
 
         <receiver android:name="com.android.server.BootReceiver" >
             <intent-filter>
                 <action android:name="android.intent.action.BOOT_COMPLETED" />
             </intent-filter>
         </receiver>
-        <receiver android:name="com.android.server.BrickReceiver"
-            android:permission="android.permission.BRICK" >
-            <intent-filter>
-                <action android:name="android.intent.action.BRICK" />
-            </intent-filter>
-        </receiver>
+
         <receiver android:name="com.android.server.MasterClearReceiver"
             android:permission="android.permission.MASTER_CLEAR" >
             <intent-filter>
diff --git a/core/res/res/anim/dialog_enter.xml b/core/res/res/anim/dialog_enter.xml
index fd08cd0..f48dd37 100644
--- a/core/res/res/anim/dialog_enter.xml
+++ b/core/res/res/anim/dialog_enter.xml
@@ -20,10 +20,10 @@
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator">
-    <scale android:fromXScale="0.5" android:toXScale="1.0"
-           android:fromYScale="0.5" android:toYScale="1.0"
+    <scale android:fromXScale="0.9" android:toXScale="1.0"
+           android:fromYScale="0.9" android:toYScale="1.0"
            android:pivotX="50%" android:pivotY="50%"
-           android:duration="200" />
+           android:duration="75" />
     <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
-            android:duration="200" />
+            android:duration="75" />
 </set>
diff --git a/core/res/res/anim/dialog_exit.xml b/core/res/res/anim/dialog_exit.xml
index e1b7a77..24de6e7 100644
--- a/core/res/res/anim/dialog_exit.xml
+++ b/core/res/res/anim/dialog_exit.xml
@@ -19,10 +19,10 @@
 -->
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/accelerate_interpolator">
-    <scale android:fromXScale="1.0" android:toXScale="0.5"
-           android:fromYScale="1.0" android:toYScale="0.5"
+    <scale android:fromXScale="1.0" android:toXScale="0.9"
+           android:fromYScale="1.0" android:toYScale="0.9"
            android:pivotX="50%" android:pivotY="50%"
-           android:duration="200" />
+           android:duration="75" />
     <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
-            android:duration="200"/>
+            android:duration="75"/>
 </set>
diff --git a/core/res/res/anim/input_method_enter.xml b/core/res/res/anim/input_method_enter.xml
index 572a266..6263c37649 100644
--- a/core/res/res/anim/input_method_enter.xml
+++ b/core/res/res/anim/input_method_enter.xml
@@ -20,12 +20,6 @@
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator">
-    <!--
-    <scale android:fromXScale="2.0" android:toXScale="1.0"
-           android:fromYScale="2.0" android:toYScale="1.0"
-           android:pivotX="50%" android:pivotY="50%"
-           android:duration="100" />
-    -->
     <translate android:fromYDelta="20%" android:toYDelta="0" android:duration="100"/>
     <alpha android:fromAlpha="0.5" android:toAlpha="1.0"
             android:duration="100" />
diff --git a/core/res/res/anim/input_method_exit.xml b/core/res/res/anim/input_method_exit.xml
index d28313a..af9382c 100644
--- a/core/res/res/anim/input_method_exit.xml
+++ b/core/res/res/anim/input_method_exit.xml
@@ -19,12 +19,6 @@
 -->
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/accelerate_interpolator">
-    <!-- 
-    <scale android:fromXScale="1.0" android:toXScale="2.0"
-           android:fromYScale="1.0" android:toYScale="2.0"
-           android:pivotX="50%" android:pivotY="50%"
-           android:duration="100" />
-    -->
     <translate android:fromYDelta="0" android:toYDelta="20%" android:duration="100"/>
     <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
             android:duration="100"/>
diff --git a/core/res/res/anim/input_method_fancy_enter.xml b/core/res/res/anim/input_method_fancy_enter.xml
new file mode 100644
index 0000000..15f5ad7
--- /dev/null
+++ b/core/res/res/anim/input_method_fancy_enter.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/fade_in.xml
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+        android:interpolator="@anim/decelerate_interpolator">
+    <scale android:fromXScale="2.0" android:toXScale="1.0"
+           android:fromYScale="2.0" android:toYScale="1.0"
+           android:pivotX="50%" android:pivotY="50%"
+           android:duration="100" />
+    <translate android:fromYDelta="100%" android:toYDelta="0" android:duration="100"/>
+</set>
diff --git a/core/res/res/anim/input_method_fancy_exit.xml b/core/res/res/anim/input_method_fancy_exit.xml
new file mode 100644
index 0000000..ecc5de3
--- /dev/null
+++ b/core/res/res/anim/input_method_fancy_exit.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/apps/common/res/anim/fade_out.xml
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+-->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+        android:interpolator="@anim/accelerate_interpolator">
+    <scale android:fromXScale="1.0" android:toXScale="2.0"
+           android:fromYScale="1.0" android:toYScale="2.0"
+           android:pivotX="50%" android:pivotY="50%"
+           android:duration="100" />
+    <translate android:fromYDelta="0" android:toYDelta="100%" android:duration="100"/>
+</set>
diff --git a/core/res/res/drawable/checkbox_background.xml b/core/res/res/anim/lock_screen_exit.xml
similarity index 71%
rename from core/res/res/drawable/checkbox_background.xml
rename to core/res/res/anim/lock_screen_exit.xml
index 68bb178..54d8e93 100644
--- a/core/res/res/drawable/checkbox_background.xml
+++ b/core/res/res/anim/lock_screen_exit.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-/* //device/apps/common/res/drawable/checkbox_background.xml
+/* //device/apps/common/res/anim/options_panel_exit.xml
 **
 ** Copyright 2007, The Android Open Source Project
 **
@@ -18,6 +18,6 @@
 */
 -->
 
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:drawable="@drawable/checkbox_label_background" />
-</selector>
+<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@anim/accelerate_interpolator">
+	<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="200" />
+</set>
diff --git a/core/res/res/anim/status_bar_enter.xml b/core/res/res/anim/status_bar_enter.xml
index 2df1af4..b57d8e7 100644
--- a/core/res/res/anim/status_bar_enter.xml
+++ b/core/res/res/anim/status_bar_enter.xml
@@ -19,6 +19,8 @@
 -->
 
 <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@anim/decelerate_interpolator">
-	<translate android:fromYDelta="-100%" android:toYDelta="0" android:duration="400"/>
-	<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="400" />
+	<translate android:fromYDelta="-75%" android:toYDelta="0"
+        android:duration="200"/>
+	<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
+        android:duration="200" />
 </set>
diff --git a/core/res/res/anim/status_bar_exit.xml b/core/res/res/anim/status_bar_exit.xml
index c72d014..8c6dc1c 100644
--- a/core/res/res/anim/status_bar_exit.xml
+++ b/core/res/res/anim/status_bar_exit.xml
@@ -19,6 +19,8 @@
 -->
 
 <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@anim/accelerate_interpolator">
-	<translate android:fromYDelta="0" android:toYDelta="-100%" android:duration="400"/>
-	<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="400" />
+	<translate android:fromYDelta="0" android:toYDelta="-75%"
+        android:startOffset="100" android:duration="200"/>
+	<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
+        android:startOffset="100" android:duration="200" />
 </set>
diff --git a/core/res/res/drawable-land/statusbar_background.png b/core/res/res/drawable-land/statusbar_background.png
index 9e82f75..8ecc24c 100644
--- a/core/res/res/drawable-land/statusbar_background.png
+++ b/core/res/res/drawable-land/statusbar_background.png
Binary files differ
diff --git a/core/res/res/drawable-land/title_bar.9.png b/core/res/res/drawable-land/title_bar.9.png
new file mode 100644
index 0000000..63ad916
--- /dev/null
+++ b/core/res/res/drawable-land/title_bar.9.png
Binary files differ
diff --git a/core/res/res/drawable-land/title_bar_tall.png b/core/res/res/drawable-land/title_bar_tall.png
new file mode 100644
index 0000000..670decc
--- /dev/null
+++ b/core/res/res/drawable-land/title_bar_tall.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_off.png b/core/res/res/drawable/btn_check_off.png
index 56d3861..3a137d9 100644
--- a/core/res/res/drawable/btn_check_off.png
+++ b/core/res/res/drawable/btn_check_off.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_off_disable.png b/core/res/res/drawable/btn_check_off_disable.png
index 6c065bd..e012afd 100644
--- a/core/res/res/drawable/btn_check_off_disable.png
+++ b/core/res/res/drawable/btn_check_off_disable.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_off_disable_focused.png b/core/res/res/drawable/btn_check_off_disable_focused.png
index cf23690..47d225d 100644
--- a/core/res/res/drawable/btn_check_off_disable_focused.png
+++ b/core/res/res/drawable/btn_check_off_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_off_pressed.png b/core/res/res/drawable/btn_check_off_pressed.png
index 47c1a46..984dfd7 100644
--- a/core/res/res/drawable/btn_check_off_pressed.png
+++ b/core/res/res/drawable/btn_check_off_pressed.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_off_selected.png b/core/res/res/drawable/btn_check_off_selected.png
index cf53075..6854550 100644
--- a/core/res/res/drawable/btn_check_off_selected.png
+++ b/core/res/res/drawable/btn_check_off_selected.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_on_disable.png b/core/res/res/drawable/btn_check_on_disable.png
index 8e9f633..6cb02f3 100644
--- a/core/res/res/drawable/btn_check_on_disable.png
+++ b/core/res/res/drawable/btn_check_on_disable.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_on_disable_focused.png b/core/res/res/drawable/btn_check_on_disable_focused.png
index 0abb051..4b6064d 100644
--- a/core/res/res/drawable/btn_check_on_disable_focused.png
+++ b/core/res/res/drawable/btn_check_on_disable_focused.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_on_pressed.png b/core/res/res/drawable/btn_check_on_pressed.png
index ee2175d..300d64a 100644
--- a/core/res/res/drawable/btn_check_on_pressed.png
+++ b/core/res/res/drawable/btn_check_on_pressed.png
Binary files differ
diff --git a/core/res/res/drawable/btn_check_on_selected.png b/core/res/res/drawable/btn_check_on_selected.png
index 9356456..0b36adb 100644
--- a/core/res/res/drawable/btn_check_on_selected.png
+++ b/core/res/res/drawable/btn_check_on_selected.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_normal.9.png b/core/res/res/drawable/btn_default_normal.9.png
index ad1634a..a337eb5 100644
--- a/core/res/res/drawable/btn_default_normal.9.png
+++ b/core/res/res/drawable/btn_default_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_normal_disable.9.png b/core/res/res/drawable/btn_default_normal_disable.9.png
index a89f37d..e414d76 100644
--- a/core/res/res/drawable/btn_default_normal_disable.9.png
+++ b/core/res/res/drawable/btn_default_normal_disable.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_normal_disable_focused.9.png b/core/res/res/drawable/btn_default_normal_disable_focused.9.png
index b71dae9..b2d45e5 100644
--- a/core/res/res/drawable/btn_default_normal_disable_focused.9.png
+++ b/core/res/res/drawable/btn_default_normal_disable_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_pressed.9.png b/core/res/res/drawable/btn_default_pressed.9.png
index f496a86..92d5ab5 100644
--- a/core/res/res/drawable/btn_default_pressed.9.png
+++ b/core/res/res/drawable/btn_default_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_selected.9.png b/core/res/res/drawable/btn_default_selected.9.png
index c9e7e64..5405fa0 100644
--- a/core/res/res/drawable/btn_default_selected.9.png
+++ b/core/res/res/drawable/btn_default_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_small_normal.9.png b/core/res/res/drawable/btn_default_small_normal.9.png
index faac205..963ecb3 100644
--- a/core/res/res/drawable/btn_default_small_normal.9.png
+++ b/core/res/res/drawable/btn_default_small_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_small_normal_disable.9.png b/core/res/res/drawable/btn_default_small_normal_disable.9.png
index ce4fd28..15bb123 100644
--- a/core/res/res/drawable/btn_default_small_normal_disable.9.png
+++ b/core/res/res/drawable/btn_default_small_normal_disable.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_small_normal_disable_focused.9.png b/core/res/res/drawable/btn_default_small_normal_disable_focused.9.png
index 1f04c18..a343515 100644
--- a/core/res/res/drawable/btn_default_small_normal_disable_focused.9.png
+++ b/core/res/res/drawable/btn_default_small_normal_disable_focused.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_small_pressed.9.png b/core/res/res/drawable/btn_default_small_pressed.9.png
index dab005b..8476e122 100644
--- a/core/res/res/drawable/btn_default_small_pressed.9.png
+++ b/core/res/res/drawable/btn_default_small_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_default_small_selected.9.png b/core/res/res/drawable/btn_default_small_selected.9.png
index 5dec504..8ab8d63 100644
--- a/core/res/res/drawable/btn_default_small_selected.9.png
+++ b/core/res/res/drawable/btn_default_small_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_keyboard_key_normal.9.png b/core/res/res/drawable/btn_keyboard_key_normal.9.png
index 5c8a945..7ba18dd 100644
--- a/core/res/res/drawable/btn_keyboard_key_normal.9.png
+++ b/core/res/res/drawable/btn_keyboard_key_normal.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_keyboard_key_normal_off.9.png b/core/res/res/drawable/btn_keyboard_key_normal_off.9.png
index e6e640a..bda9b83 100644
--- a/core/res/res/drawable/btn_keyboard_key_normal_off.9.png
+++ b/core/res/res/drawable/btn_keyboard_key_normal_off.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_keyboard_key_normal_on.9.png b/core/res/res/drawable/btn_keyboard_key_normal_on.9.png
index ce97a44..0c16ed5 100644
--- a/core/res/res/drawable/btn_keyboard_key_normal_on.9.png
+++ b/core/res/res/drawable/btn_keyboard_key_normal_on.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_keyboard_key_pressed.9.png b/core/res/res/drawable/btn_keyboard_key_pressed.9.png
index f2e9f04..39b9314 100755
--- a/core/res/res/drawable/btn_keyboard_key_pressed.9.png
+++ b/core/res/res/drawable/btn_keyboard_key_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_keyboard_key_pressed_off.9.png b/core/res/res/drawable/btn_keyboard_key_pressed_off.9.png
index d541f95..bdcf06e 100644
--- a/core/res/res/drawable/btn_keyboard_key_pressed_off.9.png
+++ b/core/res/res/drawable/btn_keyboard_key_pressed_off.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_keyboard_key_pressed_on.9.png b/core/res/res/drawable/btn_keyboard_key_pressed_on.9.png
index 1cd6d45..79621a9 100644
--- a/core/res/res/drawable/btn_keyboard_key_pressed_on.9.png
+++ b/core/res/res/drawable/btn_keyboard_key_pressed_on.9.png
Binary files differ
diff --git a/core/res/res/drawable/btn_radio_off_pressed.png b/core/res/res/drawable/btn_radio_off_pressed.png
index 41120ae..d6d8a9d 100644
--- a/core/res/res/drawable/btn_radio_off_pressed.png
+++ b/core/res/res/drawable/btn_radio_off_pressed.png
Binary files differ
diff --git a/core/res/res/drawable/btn_radio_off_selected.png b/core/res/res/drawable/btn_radio_off_selected.png
index 8b5535d..53f3e87 100644
--- a/core/res/res/drawable/btn_radio_off_selected.png
+++ b/core/res/res/drawable/btn_radio_off_selected.png
Binary files differ
diff --git a/core/res/res/drawable/btn_radio_on.png b/core/res/res/drawable/btn_radio_on.png
index 7286b31..7bf696d 100644
--- a/core/res/res/drawable/btn_radio_on.png
+++ b/core/res/res/drawable/btn_radio_on.png
Binary files differ
diff --git a/core/res/res/drawable/btn_radio_on_pressed.png b/core/res/res/drawable/btn_radio_on_pressed.png
index 20ce0ec..c904a35 100644
--- a/core/res/res/drawable/btn_radio_on_pressed.png
+++ b/core/res/res/drawable/btn_radio_on_pressed.png
Binary files differ
diff --git a/core/res/res/drawable/btn_radio_on_selected.png b/core/res/res/drawable/btn_radio_on_selected.png
index ed53dc7..78e1fc0 100644
--- a/core/res/res/drawable/btn_radio_on_selected.png
+++ b/core/res/res/drawable/btn_radio_on_selected.png
Binary files differ
diff --git a/core/res/res/drawable/checkbox.xml b/core/res/res/drawable/checkbox.xml
deleted file mode 100644
index 7a22185..0000000
--- a/core/res/res/drawable/checkbox.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/common/res/drawable/checkbox.xml
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
-**
-**     http://www.apache.org/licenses/LICENSE-2.0 
-**
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
-** limitations under the License.
-*/
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_checked="true" android:state_focused="true"
-          android:drawable="@drawable/checkbox_on_background_focus_yellow" />
-    <item android:state_checked="false" android:state_focused="true"
-          android:drawable="@drawable/checkbox_off_background_focus_yellow" />
-    <item android:state_checked="false" android:drawable="@drawable/checkbox_off_background" />
-    <item android:state_checked="true" android:drawable="@drawable/checkbox_on_background" />
-</selector>
-
diff --git a/core/res/res/drawable/checkbox_label_background.9.png b/core/res/res/drawable/checkbox_label_background.9.png
deleted file mode 100644
index e6af4b07..0000000
--- a/core/res/res/drawable/checkbox_label_background.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/checkbox_off_background_focus_yellow.png b/core/res/res/drawable/checkbox_off_background_focus_yellow.png
deleted file mode 100644
index ffde6f8..0000000
--- a/core/res/res/drawable/checkbox_off_background_focus_yellow.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/checkbox_on_background_focus_yellow.png b/core/res/res/drawable/checkbox_on_background_focus_yellow.png
deleted file mode 100644
index 3018009..0000000
--- a/core/res/res/drawable/checkbox_on_background_focus_yellow.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/dark_header.9.png b/core/res/res/drawable/dark_header.9.png
new file mode 100644
index 0000000..8fa5f09
--- /dev/null
+++ b/core/res/res/drawable/dark_header.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_bright.9.png b/core/res/res/drawable/divider_horizontal_bright.9.png
index a1ba2d3..144fc22 100644
--- a/core/res/res/drawable/divider_horizontal_bright.9.png
+++ b/core/res/res/drawable/divider_horizontal_bright.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_dark.9.png b/core/res/res/drawable/divider_horizontal_dark.9.png
index 7b32381..08838ca 100644
--- a/core/res/res/drawable/divider_horizontal_dark.9.png
+++ b/core/res/res/drawable/divider_horizontal_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable/divider_horizontal_dim_dark.9.png b/core/res/res/drawable/divider_horizontal_dim_dark.9.png
index 20bc4dc..08838ca 100644
--- a/core/res/res/drawable/divider_horizontal_dim_dark.9.png
+++ b/core/res/res/drawable/divider_horizontal_dim_dark.9.png
Binary files differ
diff --git a/tests/GadgetHost/res/values/strings.xml b/core/res/res/drawable/extract_edit_text.xml
similarity index 65%
copy from tests/GadgetHost/res/values/strings.xml
copy to core/res/res/drawable/extract_edit_text.xml
index d94cfbd..9c6c4ba 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/core/res/res/drawable/extract_edit_text.xml
@@ -14,9 +14,9 @@
      limitations under the License.
 -->
 
-<resources>
-    <string name="gadget_view_title">Gadget Test</string>
-    <string name="add_gadget">Add Gadget</string>
-    <string name="oh_hai">Oh hai.</string>
-</resources>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:drawable="@drawable/keyboard_textfield_pressed" />
+    <item android:state_focused="true" android:drawable="@drawable/keyboard_textfield_selected" />
+    <item android:drawable="@drawable/textfield_disabled" />
+</selector>
 
diff --git a/core/res/res/drawable/ic_btn_speak_now.png b/core/res/res/drawable/ic_btn_speak_now.png
new file mode 100644
index 0000000..83ee68b
--- /dev/null
+++ b/core/res/res/drawable/ic_btn_speak_now.png
Binary files differ
diff --git a/core/res/res/drawable/keyboard_background.9.png b/core/res/res/drawable/keyboard_background.9.png
index 595acc5..1d3ce05 100644
--- a/core/res/res/drawable/keyboard_background.9.png
+++ b/core/res/res/drawable/keyboard_background.9.png
Binary files differ
diff --git a/core/res/res/drawable/keyboard_suggest_strip_shadow.9.png b/core/res/res/drawable/keyboard_suggest_strip_shadow.9.png
new file mode 100644
index 0000000..d231ae6
--- /dev/null
+++ b/core/res/res/drawable/keyboard_suggest_strip_shadow.9.png
Binary files differ
diff --git a/core/res/res/drawable/keyboard_textfield_pressed.9.png b/core/res/res/drawable/keyboard_textfield_pressed.9.png
new file mode 100644
index 0000000..f4e3f10
--- /dev/null
+++ b/core/res/res/drawable/keyboard_textfield_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable/keyboard_textfield_selected.9.png b/core/res/res/drawable/keyboard_textfield_selected.9.png
new file mode 100644
index 0000000..6e703af
--- /dev/null
+++ b/core/res/res/drawable/keyboard_textfield_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/menu_background.9.png b/core/res/res/drawable/menu_background.9.png
index e7266b2..ee995835 100644
--- a/core/res/res/drawable/menu_background.9.png
+++ b/core/res/res/drawable/menu_background.9.png
Binary files differ
diff --git a/core/res/res/drawable/radiobutton.xml b/core/res/res/drawable/radiobutton.xml
deleted file mode 100644
index a72c825..0000000
--- a/core/res/res/drawable/radiobutton.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/common/res/drawable/radiobutton.xml
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
-**
-**     http://www.apache.org/licenses/LICENSE-2.0 
-**
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
-** limitations under the License.
-*/
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_checked="false" android:state_focused="true"
-          android:drawable="@drawable/radiobutton_off_background_focus_yellow" />
-    <item android:state_checked="true" android:state_focused="true"
-          android:drawable="@drawable/radiobutton_on_background_focus_yellow" />
-    <item android:state_checked="false" android:drawable="@drawable/radiobutton_off_background" />
-    <item android:state_checked="true" android:drawable="@drawable/radiobutton_on_background" />
-</selector>
diff --git a/core/res/res/drawable/radiobutton_background.xml b/core/res/res/drawable/radiobutton_background.xml
deleted file mode 100644
index 948a141..0000000
--- a/core/res/res/drawable/radiobutton_background.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/* //device/apps/common/res/drawable/radiobutton_background.xml
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License"); 
-** you may not use this file except in compliance with the License. 
-** You may obtain a copy of the License at 
-**
-**     http://www.apache.org/licenses/LICENSE-2.0 
-**
-** Unless required by applicable law or agreed to in writing, software 
-** distributed under the License is distributed on an "AS IS" BASIS, 
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
-** See the License for the specific language governing permissions and 
-** limitations under the License.
-*/
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:drawable="@drawable/radiobutton_label_background" />
-</selector>
diff --git a/core/res/res/drawable/radiobutton_label_background.9.png b/core/res/res/drawable/radiobutton_label_background.9.png
deleted file mode 100644
index e6af4b07..0000000
--- a/core/res/res/drawable/radiobutton_label_background.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/radiobutton_off_background_focus_yellow.png b/core/res/res/drawable/radiobutton_off_background_focus_yellow.png
deleted file mode 100644
index 1a092e3..0000000
--- a/core/res/res/drawable/radiobutton_off_background_focus_yellow.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/radiobutton_on_background_focus_yellow.png b/core/res/res/drawable/radiobutton_on_background_focus_yellow.png
deleted file mode 100644
index aa59771..0000000
--- a/core/res/res/drawable/radiobutton_on_background_focus_yellow.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/scrollbar_handle_horizontal.9.png b/core/res/res/drawable/scrollbar_handle_horizontal.9.png
index f333733..324b4bd 100755
--- a/core/res/res/drawable/scrollbar_handle_horizontal.9.png
+++ b/core/res/res/drawable/scrollbar_handle_horizontal.9.png
Binary files differ
diff --git a/core/res/res/drawable/scrollbar_handle_vertical.9.png b/core/res/res/drawable/scrollbar_handle_vertical.9.png
index ff08295..3519d68 100755
--- a/core/res/res/drawable/scrollbar_handle_vertical.9.png
+++ b/core/res/res/drawable/scrollbar_handle_vertical.9.png
Binary files differ
diff --git a/core/res/res/drawable/statusbar_background.png b/core/res/res/drawable/statusbar_background.png
index 6af7329..945ad92 100644
--- a/core/res/res/drawable/statusbar_background.png
+++ b/core/res/res/drawable/statusbar_background.png
Binary files differ
diff --git a/core/res/res/drawable/textfield_default.9.png b/core/res/res/drawable/textfield_default.9.png
index ab99aeb..12cdd4c 100644
--- a/core/res/res/drawable/textfield_default.9.png
+++ b/core/res/res/drawable/textfield_default.9.png
Binary files differ
diff --git a/core/res/res/drawable/textfield_disabled.9.png b/core/res/res/drawable/textfield_disabled.9.png
index 0070158..ad8ba70 100644
--- a/core/res/res/drawable/textfield_disabled.9.png
+++ b/core/res/res/drawable/textfield_disabled.9.png
Binary files differ
diff --git a/core/res/res/drawable/textfield_disabled_selected.9.png b/core/res/res/drawable/textfield_disabled_selected.9.png
old mode 100755
new mode 100644
index 139d606..04b6b6b
--- a/core/res/res/drawable/textfield_disabled_selected.9.png
+++ b/core/res/res/drawable/textfield_disabled_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/textfield_pressed.9.png b/core/res/res/drawable/textfield_pressed.9.png
index 7b1350f..bcc0152 100644
--- a/core/res/res/drawable/textfield_pressed.9.png
+++ b/core/res/res/drawable/textfield_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable/textfield_selected.9.png b/core/res/res/drawable/textfield_selected.9.png
index 7286ba5..47115b6 100644
--- a/core/res/res/drawable/textfield_selected.9.png
+++ b/core/res/res/drawable/textfield_selected.9.png
Binary files differ
diff --git a/core/res/res/drawable/title_bar.9.png b/core/res/res/drawable/title_bar.9.png
index 8d18339..44c3179a5 100644
--- a/core/res/res/drawable/title_bar.9.png
+++ b/core/res/res/drawable/title_bar.9.png
Binary files differ
diff --git a/core/res/res/drawable/title_bar_shadow.9.png b/core/res/res/drawable/title_bar_shadow.9.png
new file mode 100644
index 0000000..08723665
--- /dev/null
+++ b/core/res/res/drawable/title_bar_shadow.9.png
Binary files differ
diff --git a/core/res/res/drawable/title_bar_shadow.png b/core/res/res/drawable/title_bar_shadow.png
deleted file mode 100644
index a717814..0000000
--- a/core/res/res/drawable/title_bar_shadow.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/title_bar_tall.png b/core/res/res/drawable/title_bar_tall.png
new file mode 100644
index 0000000..09f5447
--- /dev/null
+++ b/core/res/res/drawable/title_bar_tall.png
Binary files differ
diff --git a/core/res/res/drawable/zoom_ring_arrows.png b/core/res/res/drawable/zoom_ring_arrows.png
new file mode 100644
index 0000000..e443de7
--- /dev/null
+++ b/core/res/res/drawable/zoom_ring_arrows.png
Binary files differ
diff --git a/core/res/res/drawable/zoom_ring_thumb.png b/core/res/res/drawable/zoom_ring_thumb.png
new file mode 100644
index 0000000..4cc5f6f
--- /dev/null
+++ b/core/res/res/drawable/zoom_ring_thumb.png
Binary files differ
diff --git a/core/res/res/drawable/zoom_ring_track.png b/core/res/res/drawable/zoom_ring_track.png
new file mode 100644
index 0000000..91d91f4
--- /dev/null
+++ b/core/res/res/drawable/zoom_ring_track.png
Binary files differ
diff --git a/core/res/res/layout/activity_list.xml b/core/res/res/layout/activity_list.xml
new file mode 100644
index 0000000..2967f0f
--- /dev/null
+++ b/core/res/res/layout/activity_list.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+  
+          http://www.apache.org/licenses/LICENSE-2.0
+  
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    >
+
+    <ListView
+        android:id="@android:id/list"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        />
+
+    <TextView
+        android:id="@android:id/empty"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:gravity="center"
+        android:text="@string/activity_list_empty"
+        android:visibility="gone"
+        android:textAppearance="?android:attr/textAppearanceMedium"
+        />
+
+</FrameLayout>
diff --git a/tests/GadgetHost/res/layout/test_gadget.xml b/core/res/res/layout/activity_list_item_2.xml
similarity index 66%
copy from tests/GadgetHost/res/layout/test_gadget.xml
copy to core/res/res/layout/activity_list_item_2.xml
index 0fb7929..78eca02 100644
--- a/tests/GadgetHost/res/layout/test_gadget.xml
+++ b/core/res/res/layout/activity_list_item_2.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2006 The Android Open Source Project
+<!-- Copyright (C) 2009 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
@@ -15,8 +15,11 @@
 -->
 
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
+    android:layout_width="fill_parent"
     android:layout_height="wrap_content"
-    android:text="@string/oh_hai"
-/>
-
+    android:minHeight="?android:attr/listPreferredItemHeight"
+    android:textAppearance="?android:attr/textAppearanceLarge"
+    android:gravity="center_vertical"
+    android:drawablePadding="14dip"
+    android:paddingLeft="15dip"
+    android:paddingRight="15dip" />
diff --git a/core/res/res/layout/expanded_menu_layout.xml b/core/res/res/layout/expanded_menu_layout.xml
index cd4ea12..5d98773 100644
--- a/core/res/res/layout/expanded_menu_layout.xml
+++ b/core/res/res/layout/expanded_menu_layout.xml
@@ -16,5 +16,5 @@
 
 <com.android.internal.view.menu.ExpandedMenuView xmlns:android="http://schemas.android.com/apk/res/android"
 	android:id="@+android:id/expanded_menu" 
-	android:layout_width="320dip"
+	android:layout_width="296dip"
 	android:layout_height="wrap_content" />
diff --git a/core/res/res/layout/input_method.xml b/core/res/res/layout/input_method.xml
index ec75cf1..a21bbe8 100644
--- a/core/res/res/layout/input_method.xml
+++ b/core/res/res/layout/input_method.xml
@@ -27,7 +27,7 @@
 
     <FrameLayout android:id="@android:id/extractArea"
         android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="0px"
         android:layout_weight="1"
         android:visibility="gone">
     </FrameLayout>
diff --git a/core/res/res/layout/input_method_extract_view.xml b/core/res/res/layout/input_method_extract_view.xml
index f8a4bde..3f68bd3 100644
--- a/core/res/res/layout/input_method_extract_view.xml
+++ b/core/res/res/layout/input_method_extract_view.xml
@@ -21,8 +21,10 @@
 <android.inputmethodservice.ExtractEditText
         xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/inputExtractEditText"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
+        android:scrollbars="vertical"
+        android:gravity="top"
+        android:minLines="1"
         android:inputType="text"
+        android:background="@android:drawable/extract_edit_text"
     >
 </android.inputmethodservice.ExtractEditText>
diff --git a/core/res/res/layout/js_prompt.xml b/core/res/res/layout/js_prompt.xml
index 9ab9d09..86974ba 100644
--- a/core/res/res/layout/js_prompt.xml
+++ b/core/res/res/layout/js_prompt.xml
@@ -20,16 +20,17 @@
         android:layout_height="wrap_content"
         android:gravity="center_horizontal"
         >
-    
+
     <TextView android:id="@+id/message"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             />
-            
+
 	<EditText android:id="@+id/value"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:textStyle="bold"
+            android:inputType="text"
             android:selectAllOnFocus="true"
             android:scrollHorizontally="true"
             android:layout_marginTop="6dip"
diff --git a/core/res/res/layout/keyguard_screen_glogin_unlock.xml b/core/res/res/layout/keyguard_screen_glogin_unlock.xml
index 9f306cc1..beaa926 100644
--- a/core/res/res/layout/keyguard_screen_glogin_unlock.xml
+++ b/core/res/res/layout/keyguard_screen_glogin_unlock.xml
@@ -16,87 +16,100 @@
 ** limitations under the License.
 */
 -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
+    android:orientation="vertical"
     android:background="#FF000000"
         >
-
-    <TextView 
-        android:id="@+id/topHeader"
+    <ScrollView
         android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:textSize="24sp"
-        android:layout_marginTop="8dip"
-        android:drawableLeft="@drawable/ic_lock_idle_lock"
-        android:drawablePadding="5dip"
-        android:text="@android:string/lockscreen_glogin_too_many_attempts"
-        />
-
-    <!-- spacer below header -->
-    <View
-        android:id="@+id/spacerTop"
-        android:layout_width="fill_parent"
-        android:layout_height="1dip"
-        android:layout_below="@id/topHeader"
-        android:layout_marginTop="8dip"
-        android:background="@android:drawable/divider_horizontal_bright"/>
-
-    <TextView
-        android:id="@+id/instructions"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@+id/spacerTop"
-        android:layout_marginTop="8dip"
-        android:gravity="center"
-        android:textSize="18sp"
-        android:text="@android:string/lockscreen_glogin_instructions"
-        />
-
-    <EditText
-        android:id="@+id/login"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/instructions"
-        android:layout_marginTop="8dip"
-        android:hint="@android:string/lockscreen_glogin_username_hint"
-        android:singleLine="true"
-        />
-
-    <EditText
-        android:id="@+id/password"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/login"
-        android:layout_marginTop="8dip"
-        android:password="true"
-        android:hint="@android:string/lockscreen_glogin_password_hint"
-        android:singleLine="true"
-        android:nextFocusRight="@+id/ok"
-        android:nextFocusDown="@+id/ok"
-        />
-
-    <!-- ok below password, aligned to right of screen -->
-    <Button
-        android:id="@+id/ok"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/password"
-        android:layout_marginTop="8dip"
-        android:layout_alignParentRight="true"
-        android:textSize="18sp"
-        android:text="@android:string/lockscreen_glogin_submit_button"
-        />
-
+        android:layout_height="0px"
+        android:layout_weight="1"
+        android:layout_above="@+id/emergencyCall">
+        <RelativeLayout 
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+                >
+        
+            <TextView 
+                android:id="@+id/topHeader"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_alignParentTop="true"
+                android:textSize="24sp"
+                android:layout_marginTop="8dip"
+                android:drawableLeft="@drawable/ic_lock_idle_lock"
+                android:drawablePadding="5dip"
+                android:text="@android:string/lockscreen_glogin_too_many_attempts"
+                />
+        
+            <!-- spacer below header -->
+            <View
+                android:id="@+id/spacerTop"
+                android:layout_width="fill_parent"
+                android:layout_height="1dip"
+                android:layout_below="@id/topHeader"
+                android:layout_marginTop="8dip"
+                android:background="@android:drawable/divider_horizontal_bright"/>
+        
+            <TextView
+                android:id="@+id/instructions"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@+id/spacerTop"
+                android:layout_marginTop="8dip"
+                android:gravity="center"
+                android:textSize="18sp"
+                android:text="@android:string/lockscreen_glogin_instructions"
+                />
+        
+            <EditText
+                android:id="@+id/login"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/instructions"
+                android:layout_marginTop="8dip"
+                android:hint="@android:string/lockscreen_glogin_username_hint"
+                android:inputType="textEmailAddress"
+                />
+        
+            <EditText
+                android:id="@+id/password"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/login"
+                android:layout_marginTop="8dip"
+                android:inputType="textPassword"
+                android:hint="@android:string/lockscreen_glogin_password_hint"
+                android:nextFocusRight="@+id/ok"
+                android:nextFocusDown="@+id/ok"
+                />
+        
+            <!-- ok below password, aligned to right of screen -->
+            <Button
+                android:id="@+id/ok"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/password"
+                android:layout_marginTop="8dip"
+                android:layout_alignParentRight="true"
+                android:textSize="18sp"
+                android:text="@android:string/lockscreen_glogin_submit_button"
+                />
+        
+        </RelativeLayout>
+    </ScrollView>
+    
+    <View android:layout_width="1dp" android:layout_height="3dp" />
+    
     <!-- emergency call button at bottom center -->
     <Button
         android:id="@+id/emergencyCall"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_alignParentBottom="true"
-        android:layout_marginBottom="8dip"
-        android:layout_centerHorizontal="true"
+        android:layout_gravity="center"
+        android:layout_weight="0"
         android:textSize="18sp"
         android:drawableLeft="@drawable/ic_emergency"
         android:drawablePadding="3dip"
@@ -110,6 +123,4 @@
         android:layout_above="@id/emergencyCall"
         android:layout_marginBottom="8dip"
         android:background="@android:drawable/divider_horizontal_bright"/-->
-
-
-</RelativeLayout>
+</LinearLayout>
diff --git a/core/res/res/layout/keyguard_screen_lock.xml b/core/res/res/layout/keyguard_screen_lock.xml
index f5c850a..907859a 100644
--- a/core/res/res/layout/keyguard_screen_lock.xml
+++ b/core/res/res/layout/keyguard_screen_lock.xml
@@ -71,7 +71,7 @@
             android:layout_width="fill_parent"
             android:layout_height="1dip"
             android:layout_marginTop="8dip"
-            android:background="@android:drawable/divider_horizontal_bright"/>
+            android:background="@android:drawable/divider_horizontal_dark"/>
 
         <!-- time and date -->
         <TextView android:id="@+id/time"
@@ -91,7 +91,7 @@
             android:layout_width="fill_parent"
             android:layout_height="1dip"
             android:layout_marginBottom="8dip"
-            android:background="@android:drawable/divider_horizontal_bright"
+            android:background="@android:drawable/divider_horizontal_dark"
                 />
 
         <!-- battery info -->
@@ -125,7 +125,7 @@
             android:layout_height="1dip"
             android:layout_marginTop="8dip"
             android:layout_marginBottom="8dip"
-            android:background="@android:drawable/divider_horizontal_bright"
+            android:background="@android:drawable/divider_horizontal_dark"
                 />
 
         <!-- next alarm info -->
@@ -160,7 +160,7 @@
             android:layout_height="1dip"
             android:layout_marginTop="8dip"
             android:layout_marginBottom="8dip"
-            android:background="@android:drawable/divider_horizontal_bright"/>
+            android:background="@android:drawable/divider_horizontal_dark"/>
 
         <!-- lock icon with 'screen locked' message
              (shown when SIM card is present) -->
@@ -194,6 +194,7 @@
         <TextView android:id="@+id/lockInstructions"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
+                  android:layout_marginBottom="5dip"
                   android:gravity="center"
                   android:textSize="14sp"/>
 
@@ -206,7 +207,6 @@
             android:layout_marginLeft="5dip"
             android:layout_marginRight="5dip"
             android:layout_marginBottom="5dip"
-            android:layout_marginTop="5dip"
             android:drawableTop="@drawable/ic_emergency"
             android:drawablePadding="3dip"
             android:text="@android:string/lockscreen_emergency_call"
diff --git a/core/res/res/layout/keyguard_screen_sim_pin_landscape.xml b/core/res/res/layout/keyguard_screen_sim_pin_landscape.xml
index fd70f50..00a6487 100644
--- a/core/res/res/layout/keyguard_screen_sim_pin_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_sim_pin_landscape.xml
@@ -45,7 +45,7 @@
             android:maxLines="1"
             android:background="@null"
             android:textSize="32sp"
-            android:password="true"
+            android:inputType="textPassword"
             />
 
         <ImageButton android:id="@+id/backspace"
diff --git a/core/res/res/layout/keyguard_screen_sim_pin_portrait.xml b/core/res/res/layout/keyguard_screen_sim_pin_portrait.xml
index 566da21..d47ca5f 100644
--- a/core/res/res/layout/keyguard_screen_sim_pin_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_sim_pin_portrait.xml
@@ -54,7 +54,7 @@
             android:layout_height="fill_parent"
             android:maxLines="1"
             android:background="@null"
-            android:password="true"
+            android:inputType="textPassword"
             />
 
         <ImageButton android:id="@+id/backspace"
diff --git a/core/res/res/layout/list_menu_item_layout.xml b/core/res/res/layout/list_menu_item_layout.xml
index 20c46a7..df4958f 100644
--- a/core/res/res/layout/list_menu_item_layout.xml
+++ b/core/res/res/layout/list_menu_item_layout.xml
@@ -18,7 +18,7 @@
     android:layout_width="fill_parent"
     android:layout_height="?android:attr/listPreferredItemHeight">
     
-    <!-- Icon, checkbox, and/or radio button will be inserted here. -->
+    <!-- Icon will be inserted here. -->
     
     <!-- The title and summary have some gap between them, and this 'group' should be centered vertically. -->
     <RelativeLayout
@@ -54,4 +54,6 @@
 
     </RelativeLayout>
 
+    <!-- Checkbox, and/or radio button will be inserted here. -->
+    
 </com.android.internal.view.menu.ListMenuItemView>
diff --git a/core/res/res/layout/preference.xml b/core/res/res/layout/preference.xml
index ac6dd76..00745b4 100644
--- a/core/res/res/layout/preference.xml
+++ b/core/res/res/layout/preference.xml
@@ -27,10 +27,10 @@
     <RelativeLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginLeft="16sp"
-        android:layout_marginRight="6sp"
-        android:layout_marginTop="6sp"
-        android:layout_marginBottom="6sp"
+        android:layout_marginLeft="15dip"
+        android:layout_marginRight="6dip"
+        android:layout_marginTop="6dip"
+        android:layout_marginBottom="6dip"
         android:layout_weight="1">
     
         <TextView android:id="@+android:id/title"
diff --git a/core/res/res/layout/preference_child.xml b/core/res/res/layout/preference_child.xml
index 1d626b9..5f8ddd4 100644
--- a/core/res/res/layout/preference_child.xml
+++ b/core/res/res/layout/preference_child.xml
@@ -17,29 +17,35 @@
 <!-- Layout for a visually child-like Preference in a PreferenceActivity. -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent"
-    android:layout_height="?android:attr/listPreferredItemHeight"
+    android:layout_height="wrap_content"
+    android:minHeight="?android:attr/listPreferredItemHeight"
     android:gravity="center_vertical"
     android:paddingRight="?android:attr/scrollbarSize">
     
     <RelativeLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_marginLeft="20sp"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="6dip"
+        android:layout_marginTop="6dip"
+        android:layout_marginBottom="6dip"
         android:layout_weight="1">
     
         <TextView android:id="@+android:id/title"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceLarge" />
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:ellipsize="marquee"
+            android:fadingEdge="horizontal" />
             
         <TextView android:id="@+android:id/summary"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_below="@android:id/title"
             android:layout_alignLeft="@android:id/title"
-            android:maxLines="2"
             android:textAppearance="?android:attr/textAppearanceSmall"
+            android:maxLines="2"
             android:textColor="?android:attr/textColorSecondary" />
 
     </RelativeLayout>
@@ -48,6 +54,7 @@
     <LinearLayout android:id="@+android:id/widget_frame"
         android:layout_width="wrap_content"
         android:layout_height="fill_parent"
-         />
+        android:gravity="center_vertical"
+        android:orientation="vertical" />
 
 </LinearLayout>
diff --git a/core/res/res/layout/resolve_list_item.xml b/core/res/res/layout/resolve_list_item.xml
index da35e97..5e296c5 100644
--- a/core/res/res/layout/resolve_list_item.xml
+++ b/core/res/res/layout/resolve_list_item.xml
@@ -17,37 +17,38 @@
 ** limitations under the License.
 */
 -->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:layout_gravity="center_vertical"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:gravity="center_vertical"
+    android:orientation="horizontal"
     android:minHeight="?android:attr/listPreferredItemHeight"
+    android:layout_height="wrap_content"
+    android:layout_width="fill_parent"
     android:paddingLeft="14dip"
     android:paddingRight="15dip">
 
-
     <!-- Activity icon when presenting dialog -->
     <ImageView android:id="@+id/icon"
         android:layout_width="@android:dimen/app_icon_size"
         android:layout_height="@android:dimen/app_icon_size"
-        android:layout_alignParentLeft="true"
         android:scaleType="fitCenter" />
 
-    <!-- Activity name -->
-    <TextView android:id="@android:id/text1"
+    <LinearLayout
+        android:orientation="vertical"
+        android:gravity="center_vertical"
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceLargeInverse"
-        android:layout_toRightOf="@id/icon"
-        android:paddingLeft="6dip" />
-
-    <!-- Extended activity info to distinguish between duplicate activity names -->
-    <TextView android:id="@android:id/text2"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceMediumInverse"
-        android:layout_toRightOf="@id/icon"
-        android:layout_below="@id/text1"
-        android:paddingLeft="6dip" />
-</RelativeLayout>
+        android:layout_height="wrap_content" >
+        <!-- Activity name -->
+        <TextView android:id="@android:id/text1"
+            android:textAppearance="?android:attr/textAppearanceLargeInverse"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingLeft="6dip" />
+        <!-- Extended activity info to distinguish between duplicate activity names -->
+        <TextView android:id="@android:id/text2"
+            android:textAppearance="?android:attr/textAppearanceMediumInverse"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingLeft="6dip" />
+    </LinearLayout>
+</LinearLayout>
 
diff --git a/core/res/res/layout/search_bar.xml b/core/res/res/layout/search_bar.xml
index 6678bc2..657ee1f 100644
--- a/core/res/res/layout/search_bar.xml
+++ b/core/res/res/layout/search_bar.xml
@@ -91,6 +91,11 @@
                 android:drawableLeft="@android:drawable/ic_btn_search"
             />
 
+            <ImageButton android:id="@+id/search_voice_btn"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:src="@android:drawable/ic_btn_speak_now"
+            />
         </LinearLayout>
         
     </LinearLayout>
diff --git a/core/res/res/layout/status_bar.xml b/core/res/res/layout/status_bar.xml
index dfdaf66..9a6b7e8 100644
--- a/core/res/res/layout/status_bar.xml
+++ b/core/res/res/layout/status_bar.xml
@@ -90,7 +90,7 @@
 
     <com.android.server.status.DateView android:id="@+id/date"
         android:layout_width="wrap_content"
-        android:layout_height="25dp"
+        android:layout_height="fill_parent"
         android:singleLine="true"
         android:textSize="16sp"
         android:textStyle="bold"
diff --git a/core/res/res/layout/zoom_magnify.xml b/core/res/res/layout/zoom_magnify.xml
index 08a5f7b6..374819e 100644
--- a/core/res/res/layout/zoom_magnify.xml
+++ b/core/res/res/layout/zoom_magnify.xml
@@ -19,16 +19,14 @@
 -->
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
     <ZoomControls android:id="@+id/zoomControls"
-        android:layout_alignParentBottom="true"
-        android:layout_centerHorizontal="true"
+        android:layout_gravity="bottom|center_horizontal"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         style="@style/ZoomControls"
         />
     <ImageView android:id="@+id/zoomMagnify"
         android:focusable="true"
-        android:layout_alignParentBottom="true"
-        android:layout_alignParentRight="true"
+        android:layout_gravity="bottom|right"
         android:paddingRight="2dip"
         android:src="@drawable/btn_zoom_page"
         android:layout_width="wrap_content"
diff --git a/core/res/res/values-cs/strings.xml b/core/res/res/values-cs/strings.xml
index 76232de..37632f8 100644
--- a/core/res/res/values-cs/strings.xml
+++ b/core/res/res/values-cs/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Umožňuje aplikaci vynutit restartování telefonu."</string>
     <string name="permlab_mount_unmount_filesystems">"připojení a odpojení souborových systémů"</string>
     <string name="permdesc_mount_unmount_filesystems">"Umožňuje aplikaci připojit či odpojit souborové systémy ve vyměnitelných úložištích."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"ovládání vibrací"</string>
     <string name="permdesc_vibrate">"Umožňuje aplikaci ovládat vibrace."</string>
     <string name="permlab_flashlight">"ovládání kontrolky"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Umožňuje povolit či zakázat aktualizace polohy prostřednictvím bezdrátového připojení. Aplikace toto nastavení obvykle nepoužívají."</string>
     <string name="permlab_checkinProperties">"přístup k vlastnostem Checkin"</string>
     <string name="permdesc_checkinProperties">"Umožňuje čtení i zápis vlastností nahraných službou Checkin. Běžné aplikace toto nastavení obvykle nevyužívají."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"změny stavu telefonu"</string>
     <string name="permdesc_modifyPhoneState">"Umožňuje aplikaci ovládat telefonní funkce zařízení. Aplikace s tímto oprávněním může přepínat sítě nebo zapnout či vypnout bezdrátové připojení telefonu bez vašeho svolení."</string>
     <string name="permlab_readPhoneState">"zjistit stav telefonu"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Umožňuje aplikaci změnit nastavení APN, jako je například proxy či port APN."</string>
     <string name="permlab_changeNetworkState">"změna připojení k síti"</string>
     <string name="permdesc_changeNetworkState">"Umožňuje aplikaci změnit stav připojení k síti."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"zobrazení stavu WiFi"</string>
     <string name="permdesc_accessWifiState">"Umožňuje aplikaci zobrazit informace o stavu připojení WiFi."</string>
     <string name="permlab_changeWifiState">"Změnit stav WiFi"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g>. <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="DAY">dd</xliff:g>. <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g>. <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"poledne"</string>
     <string name="Noon">"Poledne"</string>
     <string name="midnight">"půlnoc"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"Vložit"</string>
     <string name="copyUrl">"Kopírovat adresu URL"</string>
     <string name="inputMethod">"Metoda zadávání dat"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Úpravy textu"</string>
     <string name="low_internal_storage_view_title">"Málo paměti"</string>
     <string name="low_internal_storage_view_text">"V telefonu zbývá málo místa pro ukládání dat."</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"Zrušit"</string>
     <string name="yes">"OK"</string>
     <string name="no">"Zrušit"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"ZAPNUTO"</string>
     <string name="capital_off">"VYPNOUT"</string>
     <string name="whichApplication">"Dokončit akci pomocí aplikace"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"Hlasitost médií"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Přehrávání pomocí rozhraní Bluetooth"</string>
     <string name="volume_call">"Hlasitost hovoru"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Přehrávání pomocí rozhraní Bluetooth"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Hlasitost upozornění a budíku"</string>
     <string name="volume_notification">"Hlasitost oznámení"</string>
     <string name="volume_unknown">"Hlasitost"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"Při používání vaší karty SD jako úložiště USB došlo k problému."</string>
     <string name="usb_storage_notification_title">"USB připojeno"</string>
     <string name="usb_storage_notification_message">"Vyberte, chcete-li kopírovat soubory do nebo z počítače."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Výběr metody zadávání dat"</string>
     <string name="fast_scroll_alphabet">"AÁBCČDĎEÉĚFGHCHIÍJKLMNŇOÓPQRŘSŠTŤUÚVWXYÝZŽ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789AÁBCČDĎEÉĚFGHCHIÍJKLMNŇOÓPQRŘSŠTŤUÚVWXYÝZŽ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"kandidáti"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-de/strings.xml b/core/res/res/values-de/strings.xml
index a8115a8..3015957 100644
--- a/core/res/res/values-de/strings.xml
+++ b/core/res/res/values-de/strings.xml
@@ -89,7 +89,7 @@
     <string name="low_memory">"Telefonspeicher ist voll! Löschen Sie Dateien, um Speicherplatz freizugeben."</string>
     <string name="me">"Eigene"</string>
     <string name="power_dialog">"Telefonoptionen"</string>
-    <string name="silent_mode">"Lautlos"</string>
+    <string name="silent_mode">"Lautlos-Modus"</string>
     <string name="turn_on_radio">"Funk einschalten"</string>
     <string name="turn_off_radio">"Funk ausschalten"</string>
     <string name="screen_lock">"Bildschirmsperre"</string>
@@ -101,8 +101,8 @@
     <string name="global_action_lock">"Bildschirmsperre"</string>
     <string name="global_action_power_off">"Ausschalten"</string>
     <string name="global_action_toggle_silent_mode">"Lautlos"</string>
-    <string name="global_action_silent_mode_on_status">"Ton ist ausgeschaltet."</string>
-    <string name="global_action_silent_mode_off_status">"Ton ist EINGESCHALTET"</string>
+    <string name="global_action_silent_mode_on_status">"Ton ist bereits AUS"</string>
+    <string name="global_action_silent_mode_off_status">"Ton ist momentan AN"</string>
     <string name="safeMode">"Abgesicherter Modus"</string>
     <string name="permgrouplab_costMoney">"Kostenpflichtige Dienste"</string>
     <string name="permgroupdesc_costMoney">"Ermöglicht Anwendungen die Ausführung eventuell kostenpflichtiger Aktionen."</string>
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Ermöglicht der Anwendung, einen Neustart des Telefons zu erzwingen."</string>
     <string name="permlab_mount_unmount_filesystems">"Dateisysteme bereitstellen oder Bereitstellung aufheben"</string>
     <string name="permdesc_mount_unmount_filesystems">"Ermöglicht der Anwendung, Dateisysteme für austauschbare Speicherplätze bereitzustellen oder die Bereitstellung aufzuheben."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"Vibrationsalarm steuern"</string>
     <string name="permdesc_vibrate">"Ermöglicht der Anwendung, den Vibrationsalarm zu steuern."</string>
     <string name="permlab_flashlight">"Lichtanzeige steuern"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Ermöglicht die Aktivierung/Deaktivierung der Radio-Benachrichtigungen über Standort-Updates. Nicht für normale Anwendungen vorgesehen."</string>
     <string name="permlab_checkinProperties">"Auf Check-In-Eigenschaften zugreifen"</string>
     <string name="permdesc_checkinProperties">"Ermöglicht den Schreib-/Lesezugriff auf vom Check-In-Service hochgeladene Elemente. Nicht für normale Anwendungen vorgesehen."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"Telefonstatus ändern"</string>
     <string name="permdesc_modifyPhoneState">"Ermöglicht einer Anwendung, die Telefonfunktionen des Gerätes zu steuern. Eine Anwendung mit dieser Berechtigung kann unter anderem das Netzwerk wechseln oder das Radio des Telefons ein- und ausschalten, ohne Sie darüber zu informieren."</string>
     <string name="permlab_readPhoneState">"Telefonstatus lesen"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Ermöglicht einer Anwendung, die APN-Einstellungen wie Proxy und Port eines Zugriffspunkts zu ändern."</string>
     <string name="permlab_changeNetworkState">"Netzwerkkonnektivität ändern"</string>
     <string name="permdesc_changeNetworkState">"Ermöglicht einer Anwendung, den Status der Netzwerkkonnektivität zu ändern."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"WLAN-Status anzeigen"</string>
     <string name="permdesc_accessWifiState">"Ermöglicht einer Anwendung, die Informationen zum WLAN-Status einzusehen."</string>
     <string name="permlab_changeWifiState">"WLAN-Status ändern"</string>
@@ -381,7 +393,7 @@
     <string name="emergency_call_dialog_number_for_display">"Notrufnummer"</string>
     <string name="lockscreen_carrier_default">"(kein Dienst)"</string>
     <string name="lockscreen_screen_locked">"Display gesperrt."</string>
-    <string name="lockscreen_instructions_when_pattern_enabled">"Drücken Sie auf die \"Menü\", um das Telefon zu entsperren oder einen Notruf zu tätigen."</string>
+    <string name="lockscreen_instructions_when_pattern_enabled">"Drücken Sie auf \"Menü\", um das Telefon zu entsperren oder einen Notruf zu tätigen."</string>
     <string name="lockscreen_instructions_when_pattern_disabled">"Drücken Sie zum Entsperren auf \"Menü\"."</string>
     <string name="lockscreen_pattern_instructions">"Schema für Entsperrung zeichnen"</string>
     <string name="lockscreen_emergency_call">"Notruf"</string>
@@ -547,12 +559,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="DAY">dd</xliff:g>. <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g>. <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="DAY">dd</xliff:g>. <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g>. <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"Mittag"</string>
     <string name="Noon">"Mittag"</string>
     <string name="midnight">"Mitternacht"</string>
@@ -680,6 +692,8 @@
     <string name="paste">"Einfügen"</string>
     <string name="copyUrl">"URL kopieren"</string>
     <string name="inputMethod">"Eingabemethode"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Text bearbeiten"</string>
     <string name="low_internal_storage_view_title">"Geringer Speicher"</string>
     <string name="low_internal_storage_view_text">"Kaum noch freier Telefonspeicher verfügbar."</string>
@@ -687,6 +701,8 @@
     <string name="cancel">"Abbrechen"</string>
     <string name="yes">"OK"</string>
     <string name="no">"Abbrechen"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"EIN"</string>
     <string name="capital_off">"AUS"</string>
     <string name="whichApplication">"Aktion beenden mit"</string>
@@ -709,8 +725,9 @@
     <string name="volume_ringtone">"Klingeltonlautstärke"</string>
     <string name="volume_music">"Medienlautstärke"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Wiedergabe durch Bluetooth"</string>
-    <string name="volume_call">"Lautstärke bei eingehendem Anruf"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Wiedergabe durch Bluetooth"</string>
+    <string name="volume_call">"Hörerlautstärke"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Lautstärke für Alarm"</string>
     <string name="volume_notification">"Benachrichtigungslautstärke"</string>
     <string name="volume_unknown">"Lautstärke"</string>
@@ -746,8 +763,61 @@
     <string name="usb_storage_error_message">"Bei der Verwendung Ihrer SD-Karte als USB-Speicher ist ein Problem aufgetreten."</string>
     <string name="usb_storage_notification_title">"USB-Verbindung"</string>
     <string name="usb_storage_notification_message">"Wählen Sie die Dateien aus, die von Ihrem oder auf Ihren Computer kopiert werden sollen."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Eingabemethode auswählen"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"Kandidaten"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/drawable/checkbox_background.xml b/core/res/res/values-en-rSG/arrays.xml
similarity index 61%
copy from core/res/res/drawable/checkbox_background.xml
copy to core/res/res/values-en-rSG/arrays.xml
index 68bb178..ee1e64b 100644
--- a/core/res/res/drawable/checkbox_background.xml
+++ b/core/res/res/values-en-rSG/arrays.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-/* //device/apps/common/res/drawable/checkbox_background.xml
+/* //device/apps/common/assets/res/any/colors.xml
 **
-** Copyright 2007, The Android Open Source Project
+** Copyright 2006, Google Inc.
 **
 ** Licensed under the Apache License, Version 2.0 (the "License"); 
 ** you may not use this file except in compliance with the License. 
@@ -17,7 +17,16 @@
 ** limitations under the License.
 */
 -->
+<resources>
 
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:drawable="@drawable/checkbox_label_background" />
-</selector>
+    <!-- Do not translate. -->
+    <integer-array name="maps_starting_lat_lng">
+        <item>1333333</item>
+        <item>103875000</item>
+    </integer-array>
+    <!-- Do not translate. -->
+    <integer-array name="maps_starting_zoom">
+        <item>4</item>
+    </integer-array>
+
+</resources>
diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml
deleted file mode 100644
index a2fd8d5..0000000
--- a/core/res/res/values-es-rUS/strings.xml
+++ /dev/null
@@ -1,904 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="byteShort">"b"</string>
-    <string name="kilobyteShort">"Kb"</string>
-    <string name="megabyteShort">"Mb"</string>
-    <string name="gigabyteShort">"Gb"</string>
-    <string name="terabyteShort">"Tb"</string>
-    <string name="petabyteShort">"Pb"</string>
-    <string name="untitled">"&lt;sin título&gt;"</string>
-    <string name="ellipsis">"…"</string>
-    <string name="emptyPhoneNumber">"(ningún número de teléfono)"</string>
-    <string name="unknownName">"(desconocido)"</string>
-    <string name="defaultVoiceMailAlphaTag">"Correo de voz"</string>
-    <string name="defaultMsisdnAlphaTag">"Msisdn1"</string>
-    <string name="mmiError">"Error de red o código MMI no válido."</string>
-    <string name="serviceEnabled">"Servicio habilitado"</string>
-    <string name="serviceEnabledFor">"Servicio habilitado para:"</string>
-    <string name="serviceDisabled">"Servicio deshabilitado"</string>
-    <string name="serviceRegistered">"Registro completado"</string>
-    <string name="serviceErased">"Borrado completado"</string>
-    <string name="passwordIncorrect">"Contraseña incorrecta"</string>
-    <string name="mmiComplete">"MMI completo"</string>
-    <!-- no translation found for badPin (5103184589972647739) -->
-    <skip />
-    <!-- no translation found for badPuk (2200634943393540609) -->
-    <skip />
-    <!-- no translation found for mismatchPin (5055729703806180857) -->
-    <skip />
-    <!-- no translation found for invalidPin (6201854814319326475) -->
-    <skip />
-    <!-- no translation found for needPuk (4788728144863892764) -->
-    <skip />
-    <!-- no translation found for needPuk2 (7056908944942451033) -->
-    <skip />
-    <string name="ClipMmi">"ID de llamada entrante"</string>
-    <string name="ClirMmi">"ID de llamada saliente"</string>
-    <string name="CfMmi">"Desvío de llamadas"</string>
-    <string name="CwMmi">"Llamada en espera"</string>
-    <string name="BaMmi">"Bloqueo de llamadas"</string>
-    <string name="PwdMmi">"Cambio de contraseña"</string>
-    <string name="PinMmi">"Cambio de PIN"</string>
-    <string name="CLIRDefaultOnNextCallOn">"El valor predeterminado de la restricción de ID es restringida. Próxima llamada: restringida"</string>
-    <string name="CLIRDefaultOnNextCallOff">"El valor predeterminado de la restricción de ID es restringida. Próxima llamada: no restringida"</string>
-    <string name="CLIRDefaultOffNextCallOn">"El valor predeterminado de la restricción de ID es no restringida. Próxima llamada: restringida"</string>
-    <string name="CLIRDefaultOffNextCallOff">"El valor predeterminado de la restricción de ID es no restringida. Próxima llamada: no restringida"</string>
-    <string name="serviceNotProvisioned">"Servicio no previsto."</string>
-    <string name="CLIRPermanent">"Restricción de ID prevista en el modo permanente."</string>
-    <string name="serviceClassVoice">"Voz"</string>
-    <string name="serviceClassData">"Datos"</string>
-    <string name="serviceClassFAX">"FAX"</string>
-    <string name="serviceClassSMS">"SMS"</string>
-    <string name="serviceClassDataAsync">"Asíncrono"</string>
-    <string name="serviceClassDataSync">"Sincronizar"</string>
-    <string name="serviceClassPacket">"Paquete"</string>
-    <string name="serviceClassPAD">"PAD"</string>
-    <string name="cfTemplateNotForwarded">"{0}: No desviada"</string>
-    <string name="cfTemplateForwarded">"{0}: {1}"</string>
-    <string name="cfTemplateForwardedTime">"{0}: {1} después de {2} segundos"</string>
-    <string name="cfTemplateRegistered">"{0}: No desviada ({1})"</string>
-    <string name="cfTemplateRegisteredTime">"{0}: No desviada ({1} después de {2} segundos)"</string>
-    <string name="httpErrorOk">"Aceptar"</string>
-    <string name="httpError">"Error desconocido"</string>
-    <string name="httpErrorLookup">"Host desconocido"</string>
-    <string name="httpErrorUnsupportedAuthScheme">"Esquema de autenticación no compatible. Fallo al autenticar."</string>
-    <string name="httpErrorAuth">"Error de autenticación"</string>
-    <string name="httpErrorProxyAuth">"Error de autenticación de servidor proxy"</string>
-    <string name="httpErrorConnect">"Fallo al conectar con el servidor"</string>
-    <string name="httpErrorIO">"Fallo al leer o escribir en el servidor"</string>
-    <string name="httpErrorTimeout">"Agotado el tiempo de espera de conexión con el servidor"</string>
-    <string name="httpErrorRedirectLoop">"Demasiadas redirecciones de servidor"</string>
-    <string name="httpErrorUnsupportedScheme">"Protocolo no compatible"</string>
-    <string name="httpErrorFailedSslHandshake">"Fallo al realizar SSL mutuo"</string>
-    <string name="httpErrorBadUrl">"URL no válida"</string>
-    <string name="httpErrorFile">"Error en el archivo"</string>
-    <string name="httpErrorFileNotFound">"Archivo no encontrado"</string>
-    <!-- no translation found for httpErrorTooManyRequests (3764334538393544875) -->
-    <skip />
-    <string name="contentServiceSync">"Sincronizar"</string>
-    <string name="contentServiceSyncNotificationTitle">"Sincronizar"</string>
-    <!-- no translation found for contentServiceTooManyDeletesNotificationDesc (8477597194404210723) -->
-    <skip />
-    <!-- no translation found for low_memory (4191592786596642367) -->
-    <skip />
-    <!-- no translation found for me (4616693653158602117) -->
-    <skip />
-    <string name="power_dialog">"Opciones de energía"</string>
-    <string name="silent_mode">"Modo silencioso"</string>
-    <string name="turn_on_radio">"Encender radio"</string>
-    <string name="turn_off_radio">"Apagar radio"</string>
-    <string name="screen_lock">"Bloquear"</string>
-    <string name="power_off">"Apagado"</string>
-    <!-- no translation found for shutdown_progress (3735034517335251808) -->
-    <skip />
-    <!-- no translation found for shutdown_confirm (699224922526414097) -->
-    <skip />
-    <string name="no_recent_tasks">"Ninguna aplicación reciente"</string>
-    <string name="global_actions">"Acciones globales"</string>
-    <string name="global_action_lock">"Bloquear"</string>
-    <string name="global_action_power_off">"Apagado"</string>
-    <string name="global_action_toggle_silent_mode">"Modo silencioso"</string>
-    <string name="global_action_silent_mode_on_status">"El sonido está desactivado"</string>
-    <string name="global_action_silent_mode_off_status">"El sonido está activado"</string>
-    <string name="safeMode">"Modo seguro"</string>
-    <!-- no translation found for permgrouplab_costMoney (904087853776533085) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_costMoney (4662370555643969515) -->
-    <skip />
-    <!-- no translation found for permgrouplab_messages (2984053976424233925) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_messages (2129093134354989379) -->
-    <skip />
-    <!-- no translation found for permgrouplab_personalInfo (4548406335021507392) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_personalInfo (8499310823817958034) -->
-    <skip />
-    <!-- no translation found for permgrouplab_location (8535677827151907069) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_location (2341662219604651887) -->
-    <skip />
-    <!-- no translation found for permgrouplab_network (3597781730625751831) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_network (8332572695347918340) -->
-    <skip />
-    <!-- no translation found for permgrouplab_accounts (8631201594657951893) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_accounts (443982868906396781) -->
-    <skip />
-    <!-- no translation found for permgrouplab_hardwareControls (5074512938567152139) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_hardwareControls (8772503144945278440) -->
-    <skip />
-    <!-- no translation found for permgrouplab_phoneCalls (7096448531266882376) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_phoneCalls (6703873478653366233) -->
-    <skip />
-    <!-- no translation found for permgrouplab_systemTools (1840847965111633430) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_systemTools (2810337951496685271) -->
-    <skip />
-    <!-- no translation found for permgrouplab_developmentTools (692844635256963358) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_developmentTools (5253915519857796400) -->
-    <skip />
-    <string name="permlab_statusBar">"Controlar la barra de estado"</string>
-    <string name="permdesc_statusBar">"Permite a las aplicaciones abrir, cerrar o deshabilitar la barra de estado y sus iconos."</string>
-    <!-- no translation found for permlab_expandStatusBar (6382500803293284173) -->
-    <skip />
-    <!-- no translation found for permdesc_expandStatusBar (90953162060681436) -->
-    <skip />
-    <!-- no translation found for permlab_processOutgoingCalls (786316295241100144) -->
-    <skip />
-    <!-- no translation found for permdesc_processOutgoingCalls (1655242138991854396) -->
-    <skip />
-    <string name="permlab_receiveSms">"Recibir mensajes SMS"</string>
-    <string name="permdesc_receiveSms">"Permite que la aplicación reciba y procese mensajes de texto. Una aplicación maliciosa puede controlar sus mensajes o eliminarlos sin que usted los vea."</string>
-    <string name="permlab_receiveMms">"Recibir mensajes MMS"</string>
-    <string name="permdesc_receiveMms">"Permite que la aplicación reciba y procese mensajes multimedia. Una aplicación maliciosa puede controlar sus mensajes o eliminarlos sin que usted los vea."</string>
-    <string name="permlab_sendSms">"Enviar mensajes SMS"</string>
-    <string name="permdesc_sendSms">"Permite a la aplicación enviar mensajes de texto. Una aplicación maliciosa puede hacerle gastar dinero enviando mensajes sin su confirmación."</string>
-    <string name="permlab_readSms">"Leer mensajes SMS/MMS"</string>
-    <string name="permdesc_readSms">"Permite que la aplicación lea los mensajes SMS almacenados en su teléfono o tarjeta SIM. Una aplicación maliciosa puede leer sus mensajes confidenciales."</string>
-    <string name="permlab_writeSms">"Escribir mensajes SMS/MMS"</string>
-    <string name="permdesc_writeSms">"Permite a la aplicación escribir mensajes SMS almacenados en su teléfono o tarjeta SIM. Una aplicación maliciosa puede eliminar sus mensajes."</string>
-    <string name="permlab_receiveWapPush">"Recibir mensajes WAP"</string>
-    <string name="permdesc_receiveWapPush">"Permite que la aplicación reciba y procese mensajes WAP. Una aplicación maliciosa puede controlar sus mensajes o eliminarlos sin que usted los vea."</string>
-    <string name="permlab_getTasks">"Obtener información de tareas"</string>
-    <string name="permdesc_getTasks">"Permite a la aplicación recuperar información sobre tareas que se acaban de ejecutar y tareas que se están ejecutando actualmente. Puede permitir que una aplicación maliciosa descubra información privada sobre otras aplicaciones."</string>
-    <string name="permlab_reorderTasks">"Reordenar tareas"</string>
-    <string name="permdesc_reorderTasks">"Permite que una aplicación mueva las tareas a primer plano y a segundo plano. Una aplicación maliciosa puede aparecer en primer plano sin su control."</string>
-    <string name="permlab_setDebugApp">"Establecer aplicación de depuración"</string>
-    <string name="permdesc_setDebugApp">"Permite a una aplicación activar la depuración para otra aplicación. Una aplicación maliciosa puede usar esta función para acabar con otras aplicaciones."</string>
-    <string name="permlab_changeConfiguration">"Cambiar configuración"</string>
-    <string name="permdesc_changeConfiguration">"Permite que una aplicación cambie la configuración actual, como la hora local o el tamaño general de la fuente."</string>
-    <!-- no translation found for permlab_restartPackages (5836367540766044606) -->
-    <skip />
-    <!-- no translation found for permdesc_restartPackages (1764965996765573321) -->
-    <skip />
-    <!-- no translation found for permlab_setProcessForeground (4860990420780868638) -->
-    <skip />
-    <!-- no translation found for permdesc_setProcessForeground (3795477299954784360) -->
-    <skip />
-    <string name="permlab_forceBack">"Restablecer"</string>
-    <string name="permdesc_forceBack">"Permite a la aplicación hacer que cualquier actividad que esté en primer plano se cierre y pase a segundo plano. Esta función no debería ser necesaria para las aplicaciones normales."</string>
-    <string name="permlab_dump">"Volcar estado del sistema"</string>
-    <string name="permdesc_dump">"Permite a la aplicación recuperar el estado interno del sistema. Una aplicación maliciosa puede recuperar una gran variedad de información privada y segura que normalmente no debería necesitar nunca."</string>
-    <string name="permlab_addSystemService">"Agregar servicio del sistema"</string>
-    <string name="permdesc_addSystemService">"Permite que la aplicación publique sus propios servicios de sistema de bajo nivel. Una aplicación maliciosa puede apropiarse del sistema y robar o dañar cualquier dato."</string>
-    <string name="permlab_runSetActivityWatcher">"Establecer vigilante de actividades"</string>
-    <string name="permdesc_runSetActivityWatcher">"Permite que una aplicación controle y supervise el modo en que el sistema inicia las actividades. Una aplicación maliciosa puede comprometer todo el sistema. Este permiso sólo es necesario para el desarrollo, nunca para el uso normal del dispositivo."</string>
-    <string name="permlab_broadcastPackageRemoved">"Paquete de emisión eliminado"</string>
-    <string name="permdesc_broadcastPackageRemoved">"Permite que una aplicación emita una notificación de que se ha eliminado un paquete de la aplicación. Una aplicación maliciosa puede usar esta función para acabar con cualquier otra aplicación que se esté ejecutando."</string>
-    <!-- no translation found for permlab_broadcastSmsReceived (1994692154847312518) -->
-    <skip />
-    <!-- no translation found for permdesc_broadcastSmsReceived (6072362543164841432) -->
-    <skip />
-    <!-- no translation found for permlab_broadcastWapPush (3070023012636951639) -->
-    <skip />
-    <!-- no translation found for permdesc_broadcastWapPush (726912255218924336) -->
-    <skip />
-    <string name="permlab_setProcessLimit">"Establecer límite de procesos"</string>
-    <string name="permdesc_setProcessLimit">"Permite a una aplicación controle el número máximo de procesos que se ejecutarán. Esta función no es necesaria para las aplicaciones normales."</string>
-    <string name="permlab_setAlwaysFinish">"Establecer finalizar siempre"</string>
-    <string name="permdesc_setAlwaysFinish">"Permite a una aplicación controlar si las actividades han acabado en cuanto pasan a segundo plano. Esta función no es necesaria para las aplicaciones normales."</string>
-    <string name="permlab_fotaUpdate">"Instalación de actualización del sistema"</string>
-    <string name="permdesc_fotaUpdate">"Permite a una aplicación recibir notifications about pending system updates and trigger their su instalación. Una aplicación maliciosa puede usar esta función para corromper el sistema con actualizaciones no autorizadas o interferir en el proceso de actualización."</string>
-    <!-- no translation found for permlab_batteryStats (1598947993704535568) -->
-    <skip />
-    <!-- no translation found for permdesc_batteryStats (6247598531831307989) -->
-    <skip />
-    <string name="permlab_internalSystemWindow">"Ventana de sistema interno"</string>
-    <string name="permdesc_internalSystemWindow">"Permite la creación de ventanas destinadas a ser usadas por la interfaz de usuario del sistema interno. No está destinada al uso por aplicaciones normales."</string>
-    <string name="permlab_systemAlertWindow">"Ventana de alerta del sistema"</string>
-    <string name="permdesc_systemAlertWindow">"Permite a una aplicación mostrar ventanas de alerta del sistema. Una aplicación maliciosa puede controlar toda la pantalla del dispositivo."</string>
-    <string name="permlab_setAnimationScale">"Establecer escala de animación"</string>
-    <string name="permdesc_setAnimationScale">"Permite que una aplicación cambie la velocidad de animación global (animaciones más rápidas o más lentas) en cualquier momento."</string>
-    <string name="permlab_manageAppTokens">"Administrar credenciales de aplicación"</string>
-    <string name="permdesc_manageAppTokens">"Permite a las aplicaciones crear y gestionar sus propios credenciales, saltándose su orden Z normal. Esta función no debería ser necesaria para las aplicaciones normales."</string>
-    <string name="permlab_injectEvents">"Introducir eventos de entrada"</string>
-    <string name="permdesc_injectEvents">"Permite a una aplicación ofrecer sus propios eventos de entrada (pulsaciones de teclas, etc.) a otras aplicaciones. Una aplicación maliciosa puede usar esta función para controlar el dispositivo."</string>
-    <string name="permlab_readInputState">"Leer estado de entrada"</string>
-    <string name="permdesc_readInputState">"Permite que las aplicaciones vigilen las teclas que pulsa incluso cuando interactúe con otra aplicación (como al introducir una contraseña). Esta función no debería ser necesaria para las aplicaciones normales."</string>
-    <string name="permlab_setOrientation">"Establecer orientación"</string>
-    <string name="permdesc_setOrientation">"Permite que una aplicación cambie la rotación de la pantalla en cualquier momento. No debería ser necesaria en aplicaciones normales."</string>
-    <string name="permlab_signalPersistentProcesses">"Señalar procesos persistentes"</string>
-    <string name="permdesc_signalPersistentProcesses">"Permite a la aplicación solicitar que la señal suministrada se envíe a todos los procesos persistentes."</string>
-    <string name="permlab_persistentActivity">"Actividades persistentes"</string>
-    <string name="permdesc_persistentActivity">"Permite que una aplicación convierta partes de sí misma en persistentes, de forma que el sistema no pueda usarlas para otras aplicaciones."</string>
-    <string name="permlab_deletePackages">"Borrar paquetes"</string>
-    <string name="permdesc_deletePackages">"Permite que una aplicación elimine paquetes Android. Una aplicación maliciosa puede usar esta función para eliminar importantes aplicaciones."</string>
-    <!-- no translation found for permlab_clearAppUserData (3858185484601410171) -->
-    <skip />
-    <!-- no translation found for permdesc_clearAppUserData (7233537744753081136) -->
-    <skip />
-    <string name="permlab_deleteCacheFiles">"Borrar archivos de caché"</string>
-    <string name="permdesc_deleteCacheFiles">"Permite que una aplicación elimine archivos de la caché."</string>
-    <!-- no translation found for permlab_getPackageSize (6743556676630447973) -->
-    <skip />
-    <!-- no translation found for permdesc_getPackageSize (2893996655828539776) -->
-    <skip />
-    <string name="permlab_installPackages">"Instalar paquetes"</string>
-    <string name="permdesc_installPackages">"Permite a una aplicación instalar paquetes Android nuevos o actualizados. Una aplicación maliciosa puede usar esta función para agregar nuevas aplicaciones con permisos arbitrariamente poderosos."</string>
-    <string name="permlab_clearAppCache">"Borrar datos de la caché de la aplicación"</string>
-    <string name="permdesc_clearAppCache">"Permite que una aplicación libere memoria de almacenamiento del dispositivo eliminando archivos del directorio caché de la aplicación. El acceso suele estar muy restringido al proceso del sistema."</string>
-    <!-- no translation found for permlab_readLogs (6653488552442991707) -->
-    <skip />
-    <!-- no translation found for permdesc_readLogs (356352685800884319) -->
-    <skip />
-    <!-- no translation found for permlab_diagnostic (2955142476313469329) -->
-    <skip />
-    <!-- no translation found for permdesc_diagnostic (1282409892215520166) -->
-    <skip />
-    <string name="permlab_changeComponentState">"Habilitar o deshabilitar componentes de la aplicación"</string>
-    <string name="permdesc_changeComponentState">"Permite que una aplicación cambie si un componente de otra aplicación está habilitado o no. Una aplicación maliciosa puede usar esta función para deshabilitar importantes capacidades del dispositivo. Se debe tener cuidado con el permiso, ya que los componentes de la aplicación se pueden volver inestables o inconsistentes."</string>
-    <string name="permlab_setPreferredApplications">"Establecer aplicaciones preferidas"</string>
-    <string name="permdesc_setPreferredApplications">"Permite que una aplicación modifique sus aplicaciones preferidas. Esta función puede permitir que una aplicación maliciosa cambie silenciosamente las aplicaciones que se están ejecutando y haga que las aplicaciones existentes recopilen datos privados."</string>
-    <string name="permlab_writeSettings">"Escribir configuración del sistema"</string>
-    <string name="permdesc_writeSettings">"Permite a una aplicación modificar los datos de configuración del sistema. Una aplicación maliciosa puede corromper la configuración del sistema."</string>
-    <!-- no translation found for permlab_writeSecureSettings (4851801872124242319) -->
-    <skip />
-    <!-- no translation found for permdesc_writeSecureSettings (2080620249472761366) -->
-    <skip />
-    <!-- no translation found for permlab_writeGservices (296370685945777755) -->
-    <skip />
-    <!-- no translation found for permdesc_writeGservices (2496928471286495053) -->
-    <skip />
-    <string name="permlab_receiveBootCompleted">"Ejecutar al arrancar"</string>
-    <string name="permdesc_receiveBootCompleted">"Permite que una aplicación se inicie en cuanto el sistema haya terminado de arrancar. Esto puede hacer que el dispositivo tarde más en iniciarse y que la aplicación ralentice todo el dispositivo al ejecutarse siempre."</string>
-    <string name="permlab_broadcastSticky">"Intento de emisión permanente"</string>
-    <string name="permdesc_broadcastSticky">"Permite que una aplicación envíe emisiones continuas, que permanecen una vez que termina la emisión. Una aplicación maliciosa puede hacer que el dispositivo sea lento o inestable y use demasiada memoria."</string>
-    <string name="permlab_readContacts">"Leer datos de contacto"</string>
-    <string name="permdesc_readContacts">"Permite que una aplicación lea todos los datos (de dirección) de contacto almacenados en su dispositivo. Una aplicación maliciosa puede usar esta función para enviar sus datos a otras personas."</string>
-    <string name="permlab_writeContacts">"Escribir datos de contactos"</string>
-    <string name="permdesc_writeContacts">"Permite a una aplicación modificar los datos (de dirección) de contacto almacenados en su dispositivo. Una aplicación maliciosa puede usar esta función para borrar o modificar sus datos de contacto."</string>
-    <!-- no translation found for permlab_writeOwnerData (8036840529708535113) -->
-    <skip />
-    <!-- no translation found for permdesc_writeOwnerData (5873447528845878348) -->
-    <skip />
-    <!-- no translation found for permlab_readOwnerData (1847040178513733757) -->
-    <skip />
-    <!-- no translation found for permdesc_readOwnerData (7563299529149214764) -->
-    <skip />
-    <!-- no translation found for permlab_readCalendar (2111238731453410895) -->
-    <skip />
-    <!-- no translation found for permdesc_readCalendar (4408253940601239114) -->
-    <skip />
-    <!-- no translation found for permlab_writeCalendar (7518052789370653396) -->
-    <skip />
-    <!-- no translation found for permdesc_writeCalendar (8057304232140147596) -->
-    <skip />
-    <!-- no translation found for permlab_accessMockLocation (321094551062270213) -->
-    <skip />
-    <!-- no translation found for permdesc_accessMockLocation (3651565866471419739) -->
-    <skip />
-    <!-- no translation found for permlab_accessLocationExtraCommands (8291822077788811687) -->
-    <skip />
-    <!-- no translation found for permdesc_accessLocationExtraCommands (5135782633548630731) -->
-    <skip />
-    <string name="permlab_accessFineLocation">"Acceder a ubicación de GPS"</string>
-    <string name="permdesc_accessFineLocation">"Acceda al sistema de posicionamiento global (GPS) del dispositivo, en caso de que esté disponible. Una aplicación maliciosa puede usar esta función para determinar dónde está y puede consumir batería adicional."</string>
-    <string name="permlab_accessCoarseLocation">"Acceder a ubicación de red"</string>
-    <string name="permdesc_accessCoarseLocation">"Utilice la base de datos de la red para determinar una ubicación aproximada del dispositivo, en caso de que esté disponible. Una aplicación maliciosa puede usar esta opción para determinar aproximadamente dónde está."</string>
-    <string name="permlab_accessSurfaceFlinger">"Acceder a SurfaceFlinger"</string>
-    <string name="permdesc_accessSurfaceFlinger">"Permite que la aplicación use las características de bajo nivel de SurfaceFlinger."</string>
-    <string name="permlab_readFrameBuffer">"Leer búfer de trama"</string>
-    <string name="permdesc_readFrameBuffer">"Permite que la aplicación lea el contenido del búfer de trama."</string>
-    <string name="permlab_modifyAudioSettings">"Modificar configuración de audio"</string>
-    <string name="permdesc_modifyAudioSettings">"Permite que la aplicación modifique la configuración de audio global, como el volumen y el enrutamiento."</string>
-    <string name="permlab_recordAudio">"Grabar audio"</string>
-    <string name="permdesc_recordAudio">"Permite que la aplicación acceda a la ruta de grabación de audio."</string>
-    <string name="permlab_camera">"Cámara"</string>
-    <string name="permdesc_camera">"Permite que la aplicación saque fotos con la cámara. Esto permite que la aplicación capture en cualquier momento imágenes que la cámara esté viendo."</string>
-    <string name="permlab_brick">"Deshabilitar dispositivo"</string>
-    <string name="permdesc_brick">"Permite que la aplicación deshabilite de forma permanente todo el dispositivo. Esto es muy peligroso."</string>
-    <!-- no translation found for permlab_reboot (8844650672567077423) -->
-    <skip />
-    <!-- no translation found for permdesc_reboot (4704919552870918328) -->
-    <skip />
-    <string name="permlab_mount_unmount_filesystems">"Montar y desmontar archivos del sistema"</string>
-    <string name="permdesc_mount_unmount_filesystems">"Permite que la aplicación monte y desmonte archivos del sistema para el almacenamiento extraíble."</string>
-    <string name="permlab_vibrate">"Vibrador"</string>
-    <string name="permdesc_vibrate">"Permite a la aplicación controlar el vibrador."</string>
-    <string name="permlab_flashlight">"Linterna"</string>
-    <string name="permdesc_flashlight">"Permite a la aplicación controlar la linterna."</string>
-    <string name="permlab_hardware_test">"Prueba de hardware"</string>
-    <string name="permdesc_hardware_test">"Permite a la aplicación controlar distintos periféricos para realizar una prueba de hardware."</string>
-    <string name="permlab_callPhone">"Llamar a números de teléfono"</string>
-    <string name="permdesc_callPhone">"Permite que la aplicación llame a los números de teléfono sin que usted intervenga. Una aplicación maliciosa puede hacer que aparezcan llamadas inesperadas en su factura del teléfono."</string>
-    <!-- no translation found for permlab_callPrivileged (2166923597287697159) -->
-    <skip />
-    <!-- no translation found for permdesc_callPrivileged (5109789447971735501) -->
-    <skip />
-    <!-- no translation found for permlab_locationUpdates (4216418293360456836) -->
-    <skip />
-    <!-- no translation found for permdesc_locationUpdates (7635814693478743648) -->
-    <skip />
-    <!-- no translation found for permlab_checkinProperties (2260796787386280708) -->
-    <skip />
-    <!-- no translation found for permdesc_checkinProperties (3508022022841741945) -->
-    <skip />
-    <!-- no translation found for permlab_modifyPhoneState (7791696535097912313) -->
-    <skip />
-    <!-- no translation found for permdesc_modifyPhoneState (6352405226410454770) -->
-    <skip />
-    <!-- no translation found for permlab_readPhoneState (7320082586621086653) -->
-    <skip />
-    <!-- no translation found for permdesc_readPhoneState (8004450067066407969) -->
-    <skip />
-    <!-- no translation found for permlab_wakeLock (1591164750935072136) -->
-    <skip />
-    <!-- no translation found for permdesc_wakeLock (160471538196734936) -->
-    <skip />
-    <string name="permlab_devicePower">"Alimentación del dispositivo"</string>
-    <string name="permdesc_devicePower">"Permite a la aplicación encender o apagar el dispositivo o mantenerlo encendido."</string>
-    <string name="permlab_factoryTest">"Prueba de fábrica"</string>
-    <string name="permdesc_factoryTest">"Se ejecuta como una prueba de fabricante de bajo nivel, permitiendo el acceso completo al hardware del dispositivo. Sólo disponible cuando un dispositivo se ejecuta en el modo de prueba del fabricante."</string>
-    <string name="permlab_setWallpaper">"Establecer fondo de escritorio"</string>
-    <string name="permdesc_setWallpaper">"Permite a la aplicación establecer el fondo de escritorio del sistema."</string>
-    <!-- no translation found for permlab_setWallpaperHints (4192438316932517807) -->
-    <skip />
-    <!-- no translation found for permdesc_setWallpaperHints (738757439960921674) -->
-    <skip />
-    <string name="permlab_masterClear">"Restablecimiento de todo el sistema"</string>
-    <string name="permdesc_masterClear">"Permite que una aplicación restablezca por completo los valores de fábrica del sistema, borrando todos los datos, la configuración y las aplicaciones instaladas."</string>
-    <!-- no translation found for permlab_setTimeZone (477196167239548690) -->
-    <skip />
-    <!-- no translation found for permdesc_setTimeZone (8564892020460841198) -->
-    <skip />
-    <!-- no translation found for permlab_getAccounts (2764070033402295170) -->
-    <skip />
-    <!-- no translation found for permdesc_getAccounts (1203491378748649898) -->
-    <skip />
-    <!-- no translation found for permlab_accessNetworkState (2032916924886010827) -->
-    <skip />
-    <!-- no translation found for permdesc_accessNetworkState (7081329402551195933) -->
-    <skip />
-    <!-- no translation found for permlab_createNetworkSockets (4706698319966917864) -->
-    <skip />
-    <!-- no translation found for permdesc_createNetworkSockets (2580337178778551792) -->
-    <skip />
-    <!-- no translation found for permlab_writeApnSettings (3190585220761979369) -->
-    <skip />
-    <!-- no translation found for permdesc_writeApnSettings (4093875220468761052) -->
-    <skip />
-    <!-- no translation found for permlab_changeNetworkState (2710779001260856872) -->
-    <skip />
-    <!-- no translation found for permdesc_changeNetworkState (8076109230787022270) -->
-    <skip />
-    <!-- no translation found for permlab_accessWifiState (3613679494230374297) -->
-    <skip />
-    <!-- no translation found for permdesc_accessWifiState (8226508433563326925) -->
-    <skip />
-    <!-- no translation found for permlab_changeWifiState (6043889338995432957) -->
-    <skip />
-    <!-- no translation found for permdesc_changeWifiState (7829372845909567994) -->
-    <skip />
-    <!-- no translation found for permlab_bluetoothAdmin (5513286736585647334) -->
-    <skip />
-    <!-- no translation found for permdesc_bluetoothAdmin (1838208497914347365) -->
-    <skip />
-    <!-- no translation found for permlab_bluetooth (6378797624765639115) -->
-    <skip />
-    <!-- no translation found for permdesc_bluetooth (8592386018922265273) -->
-    <skip />
-    <!-- no translation found for permlab_disableKeyguard (4574886811903233903) -->
-    <skip />
-    <!-- no translation found for permdesc_disableKeyguard (815972646344251271) -->
-    <skip />
-    <!-- no translation found for permlab_readSyncSettings (8818819977141505127) -->
-    <skip />
-    <!-- no translation found for permdesc_readSyncSettings (8454705401908767847) -->
-    <skip />
-    <!-- no translation found for permlab_writeSyncSettings (4514911143753152941) -->
-    <skip />
-    <!-- no translation found for permdesc_writeSyncSettings (7630627689635091836) -->
-    <skip />
-    <!-- no translation found for permlab_readSyncStats (5748337739678952863) -->
-    <skip />
-    <!-- no translation found for permdesc_readSyncStats (582551457321957183) -->
-    <skip />
-    <!-- no translation found for permlab_subscribedFeedsRead (2043206814904506589) -->
-    <skip />
-    <!-- no translation found for permdesc_subscribedFeedsRead (6977343942680042449) -->
-    <skip />
-    <!-- no translation found for permlab_subscribedFeedsWrite (2556727307229571556) -->
-    <skip />
-    <!-- no translation found for permdesc_subscribedFeedsWrite (4134783294590266220) -->
-    <skip />
-    <!-- no translation found for phoneTypes:0 (6070018634209800981) -->
-    <!-- no translation found for phoneTypes:1 (1514509689885965711) -->
-    <!-- no translation found for phoneTypes:2 (497473201754095234) -->
-    <!-- no translation found for phoneTypes:3 (5554432614281047787) -->
-    <!-- no translation found for phoneTypes:4 (2222084401110150993) -->
-    <!-- no translation found for phoneTypes:5 (2290007103906353121) -->
-    <!-- no translation found for phoneTypes:6 (6930783706213719251) -->
-    <!-- no translation found for phoneTypes:7 (1326005699931077792) -->
-    <!-- no translation found for emailAddressTypes:0 (1540640638077615417) -->
-    <!-- no translation found for emailAddressTypes:1 (4252853367575831977) -->
-    <!-- no translation found for emailAddressTypes:2 (7158046581744435718) -->
-    <!-- no translation found for emailAddressTypes:3 (3625034471181268169) -->
-    <!-- no translation found for postalAddressTypes:0 (5732960259696659380) -->
-    <!-- no translation found for postalAddressTypes:1 (7132240704786130285) -->
-    <!-- no translation found for postalAddressTypes:2 (1317604357745852817) -->
-    <!-- no translation found for postalAddressTypes:3 (1582953598462826702) -->
-    <!-- no translation found for imAddressTypes:0 (7806620012096518833) -->
-    <!-- no translation found for imAddressTypes:1 (5748846799950672787) -->
-    <!-- no translation found for imAddressTypes:2 (6196536810275073680) -->
-    <!-- no translation found for imAddressTypes:3 (8519128375350623648) -->
-    <!-- no translation found for organizationTypes:0 (1299224825223821142) -->
-    <!-- no translation found for organizationTypes:1 (2455717447227299354) -->
-    <!-- no translation found for organizationTypes:2 (7027570839313438290) -->
-    <!-- no translation found for imProtocols:0 (3318725788774688043) -->
-    <!-- no translation found for imProtocols:1 (1787713387022932886) -->
-    <!-- no translation found for imProtocols:2 (6751174158442316516) -->
-    <!-- no translation found for imProtocols:3 (1151283347465052653) -->
-    <!-- no translation found for imProtocols:4 (2157980008878817934) -->
-    <!-- no translation found for imProtocols:5 (7836237460308230767) -->
-    <!-- no translation found for imProtocols:6 (1180789904462172516) -->
-    <!-- no translation found for imProtocols:7 (21955111672779862) -->
-    <string name="keyguard_password_enter_pin_code">"Introducir código PIN"</string>
-    <string name="keyguard_password_wrong_pin_code">"¡Código PIN incorrecto!"</string>
-    <string name="keyguard_label_text">"Para desbloquear, pulse Menú y luego 0."</string>
-    <string name="emergency_call_dialog_number_for_display">"Número de emergencia"</string>
-    <string name="lockscreen_carrier_default">"(Fuera de servicio)"</string>
-    <string name="lockscreen_screen_locked">"Pantalla bloqueada"</string>
-    <string name="lockscreen_instructions_when_pattern_enabled">"Pulse Menú para desbloquear o realice una llamada de emergencia"</string>
-    <string name="lockscreen_instructions_when_pattern_disabled">"Pulse Menú para desbloquear"</string>
-    <string name="lockscreen_pattern_instructions">"Trazar patrón de desbloqueo"</string>
-    <string name="lockscreen_emergency_call">"Llamada de emergencia"</string>
-    <string name="lockscreen_pattern_correct">"¡Correcto!"</string>
-    <string name="lockscreen_pattern_wrong">"¡Patrón incorrecto! Inténtelo de nuevo"</string>
-    <string name="lockscreen_plugged_in">"Cargando (<xliff:g id="NUMBER">%d%%</xliff:g>)"</string>
-    <string name="lockscreen_low_battery">"Conectar cargador"</string>
-    <!-- no translation found for lockscreen_missing_sim_message_short (5051192587315492957) -->
-    <skip />
-    <string name="lockscreen_missing_sim_message">"No hay ninguna tarjeta SIM en el dispositivo"</string>
-    <string name="lockscreen_missing_sim_instructions">"Inserte una tarjeta SIM"</string>
-    <!-- no translation found for lockscreen_network_locked_message (323609607922245071) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_puk_locked_message (1005803622871256359) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_puk_locked_instructions (5033160098036646955) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_locked_message (7398401200962556379) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_unlock_progress_dialog_message (5939537246164692076) -->
-    <skip />
-    <!-- unknown placeholder BREAK in lockscreen_too_many_failed_attempts_dialog_message -->
-    <skip />
-    <!-- no translation found for lockscreen_failed_attempts_almost_glogin (1569017295989454551) -->
-    <skip />
-    <string name="lockscreen_too_many_failed_attempts_countdown">"Inténtelo de nuevo en <xliff:g id="NUMBER">%d</xliff:g> segundos"</string>
-    <!-- no translation found for lockscreen_forgot_pattern_button_text (4219994639843985488) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_too_many_attempts (7504679498838839295) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_instructions (6542400673357252011) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_username_hint (6378418320242015111) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_password_hint (3224230234042131153) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_submit_button (5562051040043760034) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_invalid_input (4881057177478491580) -->
-    <skip />
-    <!-- unknown placeholder FORMAT in status_bar_time_format -->
-    <skip />
-    <!-- no translation found for hour_minute_ampm (1850330605794978742) -->
-    <skip />
-    <!-- no translation found for hour_minute_cap_ampm (1122840227537374196) -->
-    <skip />
-    <!-- no translation found for hour_ampm (7665432130905376251) -->
-    <skip />
-    <!-- no translation found for hour_cap_ampm (3600295014648400268) -->
-    <skip />
-    <!-- no translation found for status_bar_clear_all_button (2202004591253243750) -->
-    <skip />
-    <string name="status_bar_no_notifications_title">"Notificaciones"</string>
-    <string name="status_bar_ongoing_events_title">"En curso"</string>
-    <string name="status_bar_latest_events_title">"Últimos eventos"</string>
-    <string name="battery_status_text_percent_format">"<xliff:g id="NUMBER">%d</xliff:g>"</string>
-    <string name="battery_status_charging">"Cargando…"</string>
-    <string name="battery_low_title">"Conectar cargador"</string>
-    <string name="battery_low_subtitle">"Batería baja"</string>
-    <string name="battery_low_percent_format">"Menos de <xliff:g id="NUMBER">%d%%</xliff:g> restantes"</string>
-    <string name="factorytest_failed">"Fallo al realizar la prueba de fábrica"</string>
-    <string name="factorytest_not_system">"La acción FACTORY_TEST sólo es compatible con los paquetes instalados en /system/app."</string>
-    <string name="factorytest_no_action">"No se ha encontrado ningún paquete que proporcione la acción FACTORY_TEST."</string>
-    <string name="factorytest_reboot">"Reiniciar"</string>
-    <string name="save_password_label">"Confirmar"</string>
-    <string name="save_password_message">"¿Quiere que el explorador recuerde esta contraseña?"</string>
-    <string name="save_password_notnow">"Ahora no"</string>
-    <string name="save_password_remember">"Recordar"</string>
-    <string name="save_password_never">"Nunca"</string>
-    <string name="open_permission_deny">"No tiene permiso para abrir esta página."</string>
-    <!-- no translation found for text_copied (6106873823411904723) -->
-    <skip />
-    <string name="more_item_label">"Más"</string>
-    <string name="prepend_shortcut_label">"Menú+"</string>
-    <!-- no translation found for menu_space_shortcut_label (194586306440382711) -->
-    <skip />
-    <!-- no translation found for menu_enter_shortcut_label (7214761412193519345) -->
-    <skip />
-    <!-- no translation found for menu_delete_shortcut_label (2854936426194985313) -->
-    <skip />
-    <string name="search_go">"IR"</string>
-    <string name="today">"Hoy"</string>
-    <string name="yesterday">"Ayer"</string>
-    <string name="tomorrow">"Mañana"</string>
-    <!-- no translation found for oneMonthDurationPast (3402179395240209557) -->
-    <skip />
-    <!-- no translation found for beforeOneMonthDurationPast (7578100953282866827) -->
-    <skip />
-    <!-- no translation found for num_seconds_ago:one (7416512229671810725) -->
-    <!-- no translation found for num_seconds_ago:other (8138756910300398447) -->
-    <!-- no translation found for num_minutes_ago:one (8620869479299420562) -->
-    <!-- no translation found for num_minutes_ago:other (5065488162050522741) -->
-    <!-- no translation found for num_hours_ago:one (853404611989669641) -->
-    <!-- no translation found for num_hours_ago:other (3558873784561756849) -->
-    <!-- no translation found for num_days_ago:one (4222479980812128212) -->
-    <!-- no translation found for num_days_ago:other (5445701370433601703) -->
-    <!-- no translation found for in_num_seconds:one (4253290037777327003) -->
-    <!-- no translation found for in_num_seconds:other (1280033870920841404) -->
-    <!-- no translation found for in_num_minutes:one (1487585791027953091) -->
-    <!-- no translation found for in_num_minutes:other (6274204576475209932) -->
-    <!-- no translation found for in_num_hours:one (6501470863235186391) -->
-    <!-- no translation found for in_num_hours:other (4415358752953289251) -->
-    <!-- no translation found for in_num_days:one (5608475533104443893) -->
-    <!-- no translation found for in_num_days:other (3827193006163842267) -->
-    <string name="preposition_for_date">"en %s"</string>
-    <string name="preposition_for_time">"en %s"</string>
-    <string name="preposition_for_year">"en %s"</string>
-    <string name="day">"día"</string>
-    <string name="days">"días"</string>
-    <string name="hour">"hora"</string>
-    <string name="hours">"horas"</string>
-    <string name="minute">"minuto"</string>
-    <string name="minutes">"minutos"</string>
-    <string name="second">"segundo"</string>
-    <string name="seconds">"segundos"</string>
-    <string name="week">"semana"</string>
-    <string name="weeks">"semanas"</string>
-    <!-- no translation found for year (8024790425994085153) -->
-    <skip />
-    <!-- no translation found for years (8592090054773244417) -->
-    <skip />
-    <string name="sunday">"Domingo"</string>
-    <string name="monday">"Lunes"</string>
-    <string name="tuesday">"Martes"</string>
-    <string name="wednesday">"Miércoles"</string>
-    <string name="thursday">"Jueves"</string>
-    <string name="friday">"Viernes"</string>
-    <string name="saturday">"Sábado"</string>
-    <string name="every_weekday">"Todos los días laborables (Lun–Vie)"</string>
-    <string name="daily">"Diario"</string>
-    <string name="weekly">"Semanal en <xliff:g id="DAY">%s</xliff:g>"</string>
-    <string name="monthly">"Mensual"</string>
-    <string name="yearly">"Anual"</string>
-    <string name="VideoView_error_title">"Error de reproducción del vídeo"</string>
-    <string name="VideoView_error_text_unknown">"Se ha producido un error al reproducir el vídeo seleccionado."</string>
-    <string name="VideoView_error_button">"Aceptar"</string>
-    <string name="am">"AM"</string>
-    <string name="pm">"PM"</string>
-    <!-- unknown placeholder FORMAT in numeric_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in wday1_date1_time1_wday2_date2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in wday1_date1_wday2_date2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in date1_time1_date2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in date1_date2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time1_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time_wday_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in wday_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time_wday -->
-    <skip />
-    <!-- no translation found for full_date_month_first (6011143962222283357) -->
-    <skip />
-    <!-- no translation found for full_date_day_first (8621594762705478189) -->
-    <skip />
-    <!-- no translation found for medium_date_month_first (48990963718825728) -->
-    <skip />
-    <!-- no translation found for medium_date_day_first (2898992016440387123) -->
-    <skip />
-    <!-- no translation found for twelve_hour_time_format (6015557937879492156) -->
-    <skip />
-    <!-- no translation found for twenty_four_hour_time_format (5176807998669709535) -->
-    <skip />
-    <string name="noon">"mediodía"</string>
-    <string name="Noon">"Mediodía"</string>
-    <string name="midnight">"media noche"</string>
-    <string name="Midnight">"Media noche"</string>
-    <!-- unknown placeholder FORMAT in month_day -->
-    <skip />
-    <!-- unknown placeholder FORMAT in month -->
-    <skip />
-    <!-- unknown placeholder FORMAT in month_day_year -->
-    <skip />
-    <!-- unknown placeholder FORMAT in month_year -->
-    <skip />
-    <!-- no translation found for time_of_day (8375993139317154157) -->
-    <skip />
-    <!-- no translation found for date_and_time (9197690194373107109) -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_md1_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_md1_wday2_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_mdy1_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_mdy1_wday2_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_md1_time1_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_md1_time1_wday2_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_mdy1_time1_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_mdy1_time1_wday2_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_md1_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_md1_wday2_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_mdy1_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_mdy1_wday2_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_md1_time1_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_md1_time1_wday2_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_mdy1_time1_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_mdy1_time1_wday2_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_md1_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_md1_wday2_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_mdy1_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_mdy1_wday2_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_md1_time1_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_md1_time1_wday2_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_mdy1_time1_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_mdy1_time1_wday2_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month_day_year -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month_year -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month_day -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month -->
-    <skip />
-    <string name="day_of_week_long_sunday">"Domingo"</string>
-    <string name="day_of_week_long_monday">"Lunes"</string>
-    <string name="day_of_week_long_tuesday">"Martes"</string>
-    <string name="day_of_week_long_wednesday">"Miércoles"</string>
-    <string name="day_of_week_long_thursday">"Jueves"</string>
-    <string name="day_of_week_long_friday">"Viernes"</string>
-    <string name="day_of_week_long_saturday">"Sábado"</string>
-    <string name="day_of_week_medium_sunday">"Dom"</string>
-    <string name="day_of_week_medium_monday">"Lun"</string>
-    <string name="day_of_week_medium_tuesday">"Mar"</string>
-    <string name="day_of_week_medium_wednesday">"Mié"</string>
-    <string name="day_of_week_medium_thursday">"Jue"</string>
-    <string name="day_of_week_medium_friday">"Vie"</string>
-    <string name="day_of_week_medium_saturday">"Sáb"</string>
-    <string name="day_of_week_short_sunday">"Do"</string>
-    <string name="day_of_week_short_monday">"Lu"</string>
-    <string name="day_of_week_short_tuesday">"Ma"</string>
-    <string name="day_of_week_short_wednesday">"Mi"</string>
-    <string name="day_of_week_short_thursday">"Ju"</string>
-    <string name="day_of_week_short_friday">"Vi"</string>
-    <string name="day_of_week_short_saturday">"Sá"</string>
-    <string name="day_of_week_shorter_sunday">"D"</string>
-    <string name="day_of_week_shorter_monday">"L"</string>
-    <string name="day_of_week_shorter_tuesday">"M"</string>
-    <string name="day_of_week_shorter_wednesday">"X"</string>
-    <string name="day_of_week_shorter_thursday">"J"</string>
-    <string name="day_of_week_shorter_friday">"V"</string>
-    <string name="day_of_week_shorter_saturday">"S"</string>
-    <string name="day_of_week_shortest_sunday">"D"</string>
-    <string name="day_of_week_shortest_monday">"L"</string>
-    <string name="day_of_week_shortest_tuesday">"M"</string>
-    <string name="day_of_week_shortest_wednesday">"X"</string>
-    <string name="day_of_week_shortest_thursday">"J"</string>
-    <string name="day_of_week_shortest_friday">"V"</string>
-    <string name="day_of_week_shortest_saturday">"S"</string>
-    <string name="month_long_january">"Enero"</string>
-    <string name="month_long_february">"Febrero"</string>
-    <string name="month_long_march">"Marzo"</string>
-    <string name="month_long_april">"Abril"</string>
-    <string name="month_long_may">"Mayo"</string>
-    <string name="month_long_june">"Junio"</string>
-    <string name="month_long_july">"Julio"</string>
-    <string name="month_long_august">"Agosto"</string>
-    <string name="month_long_september">"Septiembre"</string>
-    <string name="month_long_october">"Octubre"</string>
-    <string name="month_long_november">"Noviembre"</string>
-    <string name="month_long_december">"Diciembre"</string>
-    <string name="month_medium_january">"Ene"</string>
-    <string name="month_medium_february">"Feb"</string>
-    <string name="month_medium_march">"Mar"</string>
-    <string name="month_medium_april">"Abr"</string>
-    <string name="month_medium_may">"May"</string>
-    <string name="month_medium_june">"Jun"</string>
-    <string name="month_medium_july">"Jul"</string>
-    <string name="month_medium_august">"Ago"</string>
-    <string name="month_medium_september">"Sep"</string>
-    <string name="month_medium_october">"Oct"</string>
-    <string name="month_medium_november">"Nov"</string>
-    <string name="month_medium_december">"Dic"</string>
-    <string name="month_shortest_january">"E"</string>
-    <string name="month_shortest_february">"F"</string>
-    <string name="month_shortest_march">"M"</string>
-    <string name="month_shortest_april">"A"</string>
-    <string name="month_shortest_may">"M"</string>
-    <string name="month_shortest_june">"E"</string>
-    <string name="month_shortest_july">"E"</string>
-    <string name="month_shortest_august">"A"</string>
-    <string name="month_shortest_september">"S"</string>
-    <string name="month_shortest_october">"O"</string>
-    <string name="month_shortest_november">"N"</string>
-    <string name="month_shortest_december">"D"</string>
-    <!-- unknown placeholder FORMAT in elapsed_time_short_format_mm_ss -->
-    <skip />
-    <!-- unknown placeholder FORMAT in elapsed_time_short_format_h_mm_ss -->
-    <skip />
-    <string name="selectAll">"Seleccionar todo"</string>
-    <string name="cut">"Cortar"</string>
-    <!-- no translation found for cutAll (4474519683293791451) -->
-    <skip />
-    <string name="copy">"Copiar"</string>
-    <!-- no translation found for copyAll (4777548804630476932) -->
-    <skip />
-    <string name="paste">"Pegar"</string>
-    <string name="copyUrl">"Copiar URL"</string>
-    <!-- no translation found for inputMethod (7911866729148111492) -->
-    <skip />
-    <!-- no translation found for editTextMenuTitle (3984253728638788023) -->
-    <skip />
-    <string name="low_internal_storage_view_title">"Espacio de almacenamiento interno bajo"</string>
-    <string name="low_internal_storage_view_text">"El dispositivo se está quedando sin espacio de almacenamiento interno"</string>
-    <string name="ok">"Aceptar"</string>
-    <string name="cancel">"Cancelar"</string>
-    <string name="yes">"Aceptar"</string>
-    <string name="no">"Cancelar"</string>
-    <string name="capital_on">"Activar"</string>
-    <string name="capital_off">"Desactivar"</string>
-    <string name="whichApplication">"¿Qué aplicación desea usar?"</string>
-    <string name="alwaysUse">"Usar siempre esta aplicación para esta actividad"</string>
-    <!-- no translation found for clearDefaultHintMsg (5742432113023174321) -->
-    <skip />
-    <string name="chooseActivity">"Seleccionar una acción"</string>
-    <string name="noApplications">"No hay ninguna aplicación disponible para llevar a cabo la acción"</string>
-    <!-- no translation found for aerr_title (2654390351574026098) -->
-    <skip />
-    <!-- no translation found for aerr_application (4917288809565116720) -->
-    <skip />
-    <!-- no translation found for aerr_process (1273819861108073461) -->
-    <skip />
-    <!-- no translation found for anr_title (3305935690891435915) -->
-    <skip />
-    <!-- no translation found for anr_activity_application (1653036325679156678) -->
-    <skip />
-    <!-- no translation found for anr_activity_process (2674027618362070465) -->
-    <skip />
-    <!-- no translation found for anr_application_process (2163656674970221928) -->
-    <skip />
-    <!-- no translation found for anr_process (7747550780123472160) -->
-    <skip />
-    <!-- no translation found for force_close (9020954128872810669) -->
-    <skip />
-    <!-- no translation found for wait (7973775702304037058) -->
-    <skip />
-    <!-- no translation found for debug (857932504764728770) -->
-    <skip />
-    <string name="sendText">"Seleccionar qué hacer con el texto"</string>
-    <!-- no translation found for volume_ringtone (4121694816346562058) -->
-    <skip />
-    <!-- no translation found for volume_music (4869950240104717493) -->
-    <skip />
-    <!-- no translation found for volume_call (5723421277753250395) -->
-    <skip />
-    <!-- no translation found for volume_alarm (2752102730973081294) -->
-    <skip />
-    <!-- no translation found for volume_unknown (6908187627672375742) -->
-    <skip />
-    <!-- no translation found for ringtone_default (2873893375149093475) -->
-    <skip />
-    <!-- no translation found for ringtone_default_with_actual (5474076151665761913) -->
-    <skip />
-    <!-- no translation found for ringtone_silent (7477159279081654685) -->
-    <skip />
-    <!-- no translation found for ringtone_picker_title (7055241890764367884) -->
-    <skip />
-    <!-- no translation found for ringtone_unknown (6888219771401173795) -->
-    <skip />
-    <!-- no translation found for wifi_available:one (8168012881468888470) -->
-    <!-- no translation found for wifi_available:other (4666122955807117718) -->
-    <!-- no translation found for wifi_available_detailed:one (5107769161192143259) -->
-    <!-- no translation found for wifi_available_detailed:other (853347657960575809) -->
-    <!-- no translation found for select_character (3735110139249491726) -->
-    <skip />
-    <!-- no translation found for sms_control_default_app_name (7522184737840550841) -->
-    <skip />
-    <!-- no translation found for sms_control_title (2742400596989418394) -->
-    <skip />
-    <!-- no translation found for sms_control_message (3447126217666595989) -->
-    <skip />
-    <!-- no translation found for sms_control_yes (8839660939359273650) -->
-    <skip />
-    <!-- no translation found for sms_control_no (909756849988183801) -->
-    <skip />
-    <!-- no translation found for date_time_set (2495199891239480952) -->
-    <skip />
-    <!-- no translation found for default_permission_group (7742780381379652409) -->
-    <skip />
-    <!-- no translation found for no_permissions (85461124044682315) -->
-    <skip />
-    <!-- no translation found for perms_hide (4145325555929151849) -->
-    <skip />
-    <!-- no translation found for perms_show_all (6040194843455403173) -->
-    <skip />
-    <!-- no translation found for googlewebcontenthelper_loading (2140804350507245589) -->
-    <skip />
-    <!-- no translation found for usb_storage_title (8699631567051394409) -->
-    <skip />
-    <!-- no translation found for usb_storage_message (5344039189213308733) -->
-    <skip />
-    <!-- no translation found for usb_storage_button_mount (6700104384375121662) -->
-    <skip />
-    <!-- no translation found for usb_storage_button_unmount (465869657252626688) -->
-    <skip />
-    <!-- no translation found for usb_storage_error_message (3192564550748426087) -->
-    <skip />
-    <!-- no translation found for usb_storage_notification_title (6237028017872246940) -->
-    <skip />
-    <!-- no translation found for usb_storage_notification_message (7371717280517625905) -->
-    <skip />
-    <!-- no translation found for select_input_method (2658280517827502015) -->
-    <skip />
-    <!-- no translation found for fast_scroll_alphabet (1017432309285755759) -->
-    <skip />
-    <!-- no translation found for fast_scroll_numeric_alphabet (3092587363718901074) -->
-    <skip />
-    <!-- no translation found for candidates_style (7738463880139922176) -->
-    <skip />
-</resources>
diff --git a/core/res/res/values-es/strings.xml b/core/res/res/values-es/strings.xml
index 2ceea2c..f8881b6f 100644
--- a/core/res/res/values-es/strings.xml
+++ b/core/res/res/values-es/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Permite que la aplicación fuerce al teléfono a reiniciarse."</string>
     <string name="permlab_mount_unmount_filesystems">"montar y desmontar sistemas de archivos"</string>
     <string name="permdesc_mount_unmount_filesystems">"Permite que las aplicaciones monten y desmonten sistemas de archivos para un almacenamiento extraíble."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"controlar vibración"</string>
     <string name="permdesc_vibrate">"Permite que la aplicación controle la función de vibración."</string>
     <string name="permlab_flashlight">"controlar linterna"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Permite habilitar/inhabilitar las notificaciones de actualización de la ubicación de la radio. No está destinado al uso por parte de aplicaciones normales."</string>
     <string name="permlab_checkinProperties">"acceder a propiedades de registro"</string>
     <string name="permdesc_checkinProperties">"Permite el acceso de lectura/escritura a las propiedades cargadas por el servicio de registro. No está destinado al uso por parte de aplicaciones normales."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"modificar estado del teléfono"</string>
     <string name="permdesc_modifyPhoneState">"Permite que la aplicación controle las funciones de teléfono del dispositivo. Una aplicación con este permiso puede cambiar redes, activar y desactivar la radio, etc., sin necesidad de notificar al usuario."</string>
     <string name="permlab_readPhoneState">"leer el estado del teléfono"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Permite que una aplicación modifique los valores de configuración de un APN como, por ejemplo, el proxy y el puerto de cualquier APN."</string>
     <string name="permlab_changeNetworkState">"cambiar la conectividad de red"</string>
     <string name="permdesc_changeNetworkState">"Permite que una aplicación cambie la conectividad de red de estado."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"ver estado de la conectividad Wi-Fi"</string>
     <string name="permdesc_accessWifiState">"Permite que una aplicación vea la información sobre el estado de la conectividad Wi-Fi."</string>
     <string name="permlab_changeWifiState">"cambiar estado de Wi-Fi"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="DAY">dd</xliff:g> de <xliff:g id="MONTH">MMMM</xliff:g> de <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="MONTH">MMMM</xliff:g> de <xliff:g id="DAY">dd</xliff:g> de <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="DAY">dd</xliff:g> de <xliff:g id="MONTH">MMM</xliff:g> de <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="DAY">d</xliff:g>' de '<xliff:g id="MONTH">MMMM</xliff:g>' de '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="MONTH">MMMM</xliff:g>' de '<xliff:g id="DAY">d</xliff:g>' de '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="DAY">d</xliff:g>' de '<xliff:g id="MONTH">MMM</xliff:g>' de '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"mediodía"</string>
     <string name="Noon">"Mediodía"</string>
     <string name="midnight">"medianoche"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"Pegar"</string>
     <string name="copyUrl">"Copiar URL"</string>
     <string name="inputMethod">"Método de introducción de texto"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Editar texto"</string>
     <string name="low_internal_storage_view_title">"Poco espacio"</string>
     <string name="low_internal_storage_view_text">"Se está agotando el espacio de almacenamiento del teléfono."</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"Cancelar"</string>
     <string name="yes">"Aceptar"</string>
     <string name="no">"Cancelar"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"Activado"</string>
     <string name="capital_off">"Desconectado"</string>
     <string name="whichApplication">"Completar acción utilizando"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"Volumen multimedia"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Reproduciendo a través de Bluetooth"</string>
     <string name="volume_call">"Volumen de la llamada"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Reproduciendo a través de Bluetooth"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Volumen de alarma"</string>
     <string name="volume_notification">"Volumen de notificaciones"</string>
     <string name="volume_unknown">"Volumen"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"Se ha producido un problema al intentar utilizar la tarjeta SD para el almacenamiento USB."</string>
     <string name="usb_storage_notification_title">"Conectado por USB"</string>
     <string name="usb_storage_notification_message">"Seleccionar para copiar archivos al/desde el equipo"</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Seleccionar método de introducción de texto"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"candidatos"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-fr/strings.xml b/core/res/res/values-fr/strings.xml
index ef826cb..47f1bf4 100644
--- a/core/res/res/values-fr/strings.xml
+++ b/core/res/res/values-fr/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Permet à l\'application de forcer le redémarrage du téléphone."</string>
     <string name="permlab_mount_unmount_filesystems">"Monter et démonter des systèmes de fichiers"</string>
     <string name="permdesc_mount_unmount_filesystems">"Permet à l\'application de monter et démonter des systèmes de fichiers pour des périphériques de stockage amovibles."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"Contrôler le vibreur"</string>
     <string name="permdesc_vibrate">"Permet à l\'application de contrôler le vibreur."</string>
     <string name="permlab_flashlight">"Contrôler la lampe de poche"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Permet l\'activation/la désactivation des notifications de mises à jour de la position géographique provenant de la radio. Les applications normales n\'utilisent pas cette fonctionnalité."</string>
     <string name="permlab_checkinProperties">"Accéder aux propriétés d\'enregistrement"</string>
     <string name="permdesc_checkinProperties">"Permet un accès en lecture/écriture à des propriétés envoyées par le service d\'inscription. Les applications normales n\'utilisent pas cette fonctionnalité."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"Modifier l\'état du téléphone"</string>
     <string name="permdesc_modifyPhoneState">"Permet à une application de contrôler les fonctionnalités téléphoniques de l\'appareil. Une application bénéficiant de cette autorisation peut changer de réseau, éteindre et allumer la radio du téléphone, etc., sans vous en notifier."</string>
     <string name="permlab_readPhoneState">"Lire l\'état du téléphone"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Permet à une application de modifier les paramètres APN (Nom des points d\'accès), comme le proxy ou le port de tout APN."</string>
     <string name="permlab_changeNetworkState">"Modifier la connectivité du réseau"</string>
     <string name="permdesc_changeNetworkState">"Permet à une application de modifier la connectivité du réseau."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"Afficher l\'état du Wi-Fi"</string>
     <string name="permdesc_accessWifiState">"Permet à une application d\'afficher des informations concernant l\'état du Wi-Fi."</string>
     <string name="permlab_changeWifiState">"Modifier l\'état du Wi-Fi"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"midi"</string>
     <string name="Noon">"Midi"</string>
     <string name="midnight">"minuit"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"Coller"</string>
     <string name="copyUrl">"Copier l\'URL"</string>
     <string name="inputMethod">"Mode de saisie"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Modifier le texte"</string>
     <string name="low_internal_storage_view_title">"Espace disponible faible"</string>
     <string name="low_internal_storage_view_text">"La mémoire du téléphone commence à être pleine."</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"Annuler"</string>
     <string name="yes">"OK"</string>
     <string name="no">"Annuler"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"ON"</string>
     <string name="capital_off">"OFF"</string>
     <string name="whichApplication">"Terminer l\'action avec"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"Volume des médias"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Lecture via Bluetooth"</string>
     <string name="volume_call">"Volume des appels entrants"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Lecture via Bluetooth"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Volume de l\'alarme"</string>
     <string name="volume_notification">"Volume des notifications"</string>
     <string name="volume_unknown">"Volume"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"Un problème est survenu lors de l\'utilisation de votre carte SD en tant que périphérique de stockage USB."</string>
     <string name="usb_storage_notification_title">"Connecté avec un câble USB"</string>
     <string name="usb_storage_notification_message">"Sélectionnez cette option pour copier des fichiers vers/à partir de votre ordinateur."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Sélectionner un mode de saisie"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"candidats"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-it/strings.xml b/core/res/res/values-it/strings.xml
index caf63c7..710c493 100644
--- a/core/res/res/values-it/strings.xml
+++ b/core/res/res/values-it/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Consente all\'applicazione di imporre il riavvio del telefono."</string>
     <string name="permlab_mount_unmount_filesystems">"montare e smontare filesystem"</string>
     <string name="permdesc_mount_unmount_filesystems">"Consente montaggio e smontaggio da parte dell\'applicazione dei filesystem degli archivi rimovibili."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"controllare la vibrazione"</string>
     <string name="permdesc_vibrate">"Consente all\'applicazione di controllare la vibrazione."</string>
     <string name="permlab_flashlight">"controllare il flash"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Consente l\'attivazione/disattivazione delle notifiche di aggiornamento della posizione. Da non usare per normali applicazioni."</string>
     <string name="permlab_checkinProperties">"accedere a proprietà di archiviazione"</string>
     <string name="permdesc_checkinProperties">"Consente l\'accesso di lettura/scrittura alle proprietà caricate dal servizio di archiviazione. Da non usare per normali applicazioni."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"modificare lo stato del telefono"</string>
     <string name="permdesc_modifyPhoneState">"Consente all\'applicazione di controllare le funzioni telefoniche del dispositivo. Un\'applicazione con questa autorizzazione può cambiare rete, accendere e spegnere il modulo radio del telefono e così via, il tutto automaticamente."</string>
     <string name="permlab_readPhoneState">"leggere lo stato del telefono"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Consente a un\'applicazione di modificare le impostazioni APN, come proxy e porta di qualsiasi APN."</string>
     <string name="permlab_changeNetworkState">"cambiare connettività di rete"</string>
     <string name="permdesc_changeNetworkState">"Consente a un\'applicazione di modificare lo stato di connettività di rete."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"visualizzare lo stato Wi-Fi"</string>
     <string name="permdesc_accessWifiState">"Consente a un\'applicazione di visualizzare le informazioni relative allo stato della connessione Wi-Fi."</string>
     <string name="permlab_changeWifiState">"cambiare stato Wi-Fi"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"mezzogiorno"</string>
     <string name="Noon">"Mezzogiorno"</string>
     <string name="midnight">"mezzanotte"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"Incolla"</string>
     <string name="copyUrl">"Copia URL"</string>
     <string name="inputMethod">"Metodo inserimento"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Modifica testo"</string>
     <string name="low_internal_storage_view_title">"Spazio in esaurimento"</string>
     <string name="low_internal_storage_view_text">"Spazio di archiviazione del telefono in esaurimento."</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"Annulla"</string>
     <string name="yes">"OK"</string>
     <string name="no">"Annulla"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"ON"</string>
     <string name="capital_off">"OFF"</string>
     <string name="whichApplication">"Completa l\'azione con"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"Volume media"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Riproduzione tramite Bluetooth"</string>
     <string name="volume_call">"Volume chiamate"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Riproduzione tramite Bluetooth"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Volume allarme"</string>
     <string name="volume_notification">"Volume notifiche"</string>
     <string name="volume_unknown">"Volume"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"Problema di utilizzo della scheda SD per l\'archiviazione USB."</string>
     <string name="usb_storage_notification_title">"USB collegata"</string>
     <string name="usb_storage_notification_message">"Seleziona per copiare file sul/dal computer in uso."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Seleziona metodo di inserimento"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"candidati"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-ja/strings.xml b/core/res/res/values-ja/strings.xml
index 055a8b1..0eba7f5 100644
--- a/core/res/res/values-ja/strings.xml
+++ b/core/res/res/values-ja/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"携帯電話の強制的な再起動をアプリケーションに許可します。"</string>
     <string name="permlab_mount_unmount_filesystems">"ファイルシステムのマウントとマウント解除"</string>
     <string name="permdesc_mount_unmount_filesystems">"リムーバブルメモリのファイルシステムのマウントとマウント解除をアプリケーションに許可します。"</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"バイブレータの制御"</string>
     <string name="permdesc_vibrate">"バイブレータのコントロールをアプリケーションに許可します。"</string>
     <string name="permlab_flashlight">"ライトのコントロール"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"無線通信からの位置更新通知を有効/無効にすることを許可します。通常のアプリケーションでは使用しません。"</string>
     <string name="permlab_checkinProperties">"チェックインプロパティへのアクセス"</string>
     <string name="permdesc_checkinProperties">"チェックインサービスがアップロードしたプロパティへの読み書きを許可します。通常のアプリケーションでは使用しません。"</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"携帯電話の状態の変更"</string>
     <string name="permdesc_modifyPhoneState">"携帯端末の電話機能のコントロールをアプリケーションに許可します。この許可を受けたアプリケーションは、ネットワークの切り替え、携帯電話の無線通信のオン/オフなどを通知せずに行うことができます。"</string>
     <string name="permlab_readPhoneState">"携帯電話の状態の読み取り"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"APNのプロキシやポートなどのAPN設定の変更をアプリケーションに許可します。"</string>
     <string name="permlab_changeNetworkState">"ネットワーク接続の変更"</string>
     <string name="permdesc_changeNetworkState">"ネットワークの接続状態の変更をアプリケーションに許可します。"</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"Wi-Fi状態の表示"</string>
     <string name="permdesc_accessWifiState">"Wi-Fi状態に関する情報の表示をアプリケーションに許可します。"</string>
     <string name="permlab_changeWifiState">"Wi-Fi状態の変更"</string>
@@ -546,10 +558,10 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="WEEKDAY">%2$s</xliff:g>、<xliff:g id="TIME_RANGE">%1$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMMM</xliff:g><xliff:g id="DAY">dd</xliff:g>\'日\'"</string>
-    <string name="full_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMMM</xliff:g><xliff:g id="DAY">dd</xliff:g>\'日\'"</string>
-    <string name="medium_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMM</xliff:g><xliff:g id="DAY">dd</xliff:g>\'日\'"</string>
-    <string name="medium_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMM</xliff:g><xliff:g id="DAY">dd</xliff:g>\'日\'"</string>
+    <string name="full_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMMM</xliff:g><xliff:g id="DAY">d</xliff:g>\'日\'"</string>
+    <string name="full_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMMM</xliff:g><xliff:g id="DAY">d</xliff:g>\'日\'"</string>
+    <string name="medium_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMM</xliff:g><xliff:g id="DAY">d</xliff:g>\'日\'"</string>
+    <string name="medium_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g>\'年\'<xliff:g id="MONTH">MMM</xliff:g><xliff:g id="DAY">d</xliff:g>\'日\'"</string>
     <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
     <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"正午"</string>
@@ -561,8 +573,7 @@
     <!-- no translation found for month (7026169712234774086) -->
     <skip />
     <string name="month_day_year">"<xliff:g id="YEAR">%Y</xliff:g>年<xliff:g id="MONTH">%B</xliff:g><xliff:g id="DAY">%-d</xliff:g>日"</string>
-    <!-- no translation found for month_year (9219019380312413367) -->
-    <skip />
+    <string name="month_year">"<xliff:g id="YEAR">%Y</xliff:g>年 <xliff:g id="MONTH">%B</xliff:g>"</string>
     <string name="time_of_day">"<xliff:g id="HOUR">%H</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g>:<xliff:g id="SECOND">%S</xliff:g>"</string>
     <string name="date_and_time">"<xliff:g id="YEAR">%Y</xliff:g>年<xliff:g id="MONTH">%B</xliff:g><xliff:g id="DAY">%-d</xliff:g>日<xliff:g id="HOUR">%H</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g>:<xliff:g id="SECOND">%S</xliff:g>"</string>
     <string name="same_year_md1_md2">"<xliff:g id="MONTH1">%2$s</xliff:g><xliff:g id="DAY1">%3$s</xliff:g>日~<xliff:g id="MONTH2">%7$s</xliff:g><xliff:g id="DAY2">%8$s</xliff:g>日"</string>
@@ -679,6 +690,8 @@
     <string name="paste">"貼り付け"</string>
     <string name="copyUrl">"URLをコピー"</string>
     <string name="inputMethod">"入力方法"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"テキストを編集"</string>
     <string name="low_internal_storage_view_title">"空き容量低下"</string>
     <string name="low_internal_storage_view_text">"携帯電話の空き容量が少なくなっています。"</string>
@@ -686,6 +699,8 @@
     <string name="cancel">"キャンセル"</string>
     <string name="yes">"OK"</string>
     <string name="no">"キャンセル"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"オン"</string>
     <string name="capital_off">"オフ"</string>
     <string name="whichApplication">"操作の完了に使用"</string>
@@ -709,7 +724,8 @@
     <string name="volume_music">"メディアの音量"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Bluetooth経由で再生中です"</string>
     <string name="volume_call">"着信音の音量"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Bluetooth経由で再生中です"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"アラームの音量"</string>
     <string name="volume_notification">"通知音の音量"</string>
     <string name="volume_unknown">"音量"</string>
@@ -745,8 +761,61 @@
     <string name="usb_storage_error_message">"USBメモリにSDカードを使用する際に問題が発生しました。"</string>
     <string name="usb_storage_notification_title">"USB接続"</string>
     <string name="usb_storage_notification_message">"パソコンとの間でファイルをコピーします。"</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"入力方法の選択"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"候補"</u></font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-ko/strings.xml b/core/res/res/values-ko/strings.xml
new file mode 100644
index 0000000..4272684
--- /dev/null
+++ b/core/res/res/values-ko/strings.xml
@@ -0,0 +1,822 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="byteShort">"B"</string>
+    <string name="kilobyteShort">"KB"</string>
+    <string name="megabyteShort">"MB"</string>
+    <string name="gigabyteShort">"GB"</string>
+    <string name="terabyteShort">"TB"</string>
+    <string name="petabyteShort">"PB"</string>
+    <string name="untitled">"&lt;제목없음&gt;"</string>
+    <string name="ellipsis">"…"</string>
+    <string name="emptyPhoneNumber">"(전화번호 없음)"</string>
+    <string name="unknownName">"(알 수 없음)"</string>
+    <string name="defaultVoiceMailAlphaTag">"음성메일"</string>
+    <string name="defaultMsisdnAlphaTag">"MSISDN1"</string>
+    <string name="mmiError">"연결에 문제가 있거나 MMI 코드가 잘못되었습니다."</string>
+    <string name="serviceEnabled">"서비스가 활성화되었습니다."</string>
+    <string name="serviceEnabledFor">"사용 설정된 서비스 목록:"</string>
+    <string name="serviceDisabled">"서비스가 비활성화되었습니다."</string>
+    <string name="serviceRegistered">"등록이 완료되었습니다."</string>
+    <string name="serviceErased">"지웠습니다."</string>
+    <string name="passwordIncorrect">"비밀번호가 잘못되었습니다."</string>
+    <string name="mmiComplete">"MMI 완료"</string>
+    <string name="badPin">"이전 PIN이 올바르지 않습니다."</string>
+    <string name="badPuk">"입력한 PUK가 올바르지 않습니다."</string>
+    <string name="mismatchPin">"입력한 PIN이 일치하지 않습니다."</string>
+    <string name="invalidPin">"4~8자리 숫자로 된 PIN을 입력하세요."</string>
+    <string name="needPuk">"SIM 카드의 PUK가 잠겨 있습니다. 잠금해제하려면 PUK 코드를 입력하세요."</string>
+    <string name="needPuk2">"SIM 카드 잠금을 해제하려면 PUK2를 입력하세요."</string>
+    <string name="ClipMmi">"수신 발신자 번호"</string>
+    <string name="ClirMmi">"발신 발신자 번호"</string>
+    <string name="CfMmi">"착신전환"</string>
+    <string name="CwMmi">"통화중 대기"</string>
+    <string name="BaMmi">"착발신 제한"</string>
+    <string name="PwdMmi">"비밀번호 변경"</string>
+    <string name="PinMmi">"PIN 변경"</string>
+    <string name="CLIRDefaultOnNextCallOn">"발신자 번호가 기본적으로 제한됨으로 설정됩니다. 다음 통화: 제한됨"</string>
+    <string name="CLIRDefaultOnNextCallOff">"발신자 번호가 기본적으로 제한됨으로 설정됩니다. 다음 통화: 제한되지 않음"</string>
+    <string name="CLIRDefaultOffNextCallOn">"발신자 번호가 기본적으로 제한되지 않음으로 설정됩니다. 다음 통화: 제한됨"</string>
+    <string name="CLIRDefaultOffNextCallOff">"발신자 번호가 기본적으로 제한되지 않음으로 설정됩니다. 다음 통화: 제한되지 않음"</string>
+    <string name="serviceNotProvisioned">"서비스가 준비되지 않았습니다."</string>
+    <string name="CLIRPermanent">"발신자 번호 설정을 변경할 수 없습니다."</string>
+    <string name="serviceClassVoice">"음성"</string>
+    <string name="serviceClassData">"데이터"</string>
+    <string name="serviceClassFAX">"팩스"</string>
+    <string name="serviceClassSMS">"SMS"</string>
+    <string name="serviceClassDataAsync">"비동기"</string>
+    <string name="serviceClassDataSync">"동기화"</string>
+    <string name="serviceClassPacket">"패킷"</string>
+    <string name="serviceClassPAD">"PAD"</string>
+    <string name="cfTemplateNotForwarded">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: 착신전환 안 됨"</string>
+    <string name="cfTemplateForwarded">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: <xliff:g id="DIALING_NUMBER">{1}</xliff:g>"</string>
+    <string name="cfTemplateForwardedTime">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: <xliff:g id="TIME_DELAY">{2}</xliff:g>초 후 <xliff:g id="DIALING_NUMBER">{1}</xliff:g>"</string>
+    <string name="cfTemplateRegistered">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: 착신전환 안 됨"</string>
+    <string name="cfTemplateRegisteredTime">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: 착신전환 안 됨"</string>
+    <string name="httpErrorOk">"확인"</string>
+    <string name="httpError">"웹페이지에 오류가 있습니다."</string>
+    <string name="httpErrorLookup">"URL을 찾을 수 없습니다."</string>
+    <string name="httpErrorUnsupportedAuthScheme">"사이트 인증 스키마가 지원되지 않습니다."</string>
+    <string name="httpErrorAuth">"인증에 실패했습니다."</string>
+    <string name="httpErrorProxyAuth">"프록시 서버를 통한 인증에 실패했습니다."</string>
+    <string name="httpErrorConnect">"서버에 연결하지 못했습니다."</string>
+    <string name="httpErrorIO">"서버와 통신할 수 없습니다. 나중에 다시 시도하세요."</string>
+    <string name="httpErrorTimeout">"서버 연결 제한시간이 초과되었습니다."</string>
+    <string name="httpErrorRedirectLoop">"페이지에 서버 리디렉션이 너무 많이 포함되어 있습니다."</string>
+    <string name="httpErrorUnsupportedScheme">"지원되지 않는 프로토콜입니다."</string>
+    <string name="httpErrorFailedSslHandshake">"보안 연결을 설정하지 못했습니다."</string>
+    <string name="httpErrorBadUrl">"URL이 올바르지 않아 페이지를 열 수 없습니다."</string>
+    <string name="httpErrorFile">"파일에 액세스할 수 없습니다."</string>
+    <string name="httpErrorFileNotFound">"요청한 파일을 찾을 수 없습니다."</string>
+    <string name="httpErrorTooManyRequests">"처리 중인 요청이 너무 많습니다. 잠시 후에 다시 시도하세요."</string>
+    <string name="contentServiceSync">"동기화"</string>
+    <string name="contentServiceSyncNotificationTitle">"동기화"</string>
+    <string name="contentServiceTooManyDeletesNotificationDesc">"<xliff:g id="CONTENT_TYPE">%s</xliff:g> 삭제가 너무 많습니다."</string>
+    <string name="low_memory">"전화기 저장공간이 꽉 찼습니다. 일부 파일을 삭제하여 저장 여유 공간을 늘리세요."</string>
+    <string name="me">"나"</string>
+    <string name="power_dialog">"전화기 옵션"</string>
+    <string name="silent_mode">"무음 모드"</string>
+    <string name="turn_on_radio">"무선 켜기"</string>
+    <string name="turn_off_radio">"무선 끄기"</string>
+    <string name="screen_lock">"화면 잠금"</string>
+    <string name="power_off">"끄기"</string>
+    <string name="shutdown_progress">"종료 중..."</string>
+    <string name="shutdown_confirm">"전화기가 종료됩니다."</string>
+    <string name="no_recent_tasks">"최신 응용프로그램이 아닙니다."</string>
+    <string name="global_actions">"전화기 옵션"</string>
+    <string name="global_action_lock">"화면 잠금"</string>
+    <string name="global_action_power_off">"끄기"</string>
+    <string name="global_action_toggle_silent_mode">"무음 모드"</string>
+    <string name="global_action_silent_mode_on_status">"소리 꺼짐"</string>
+    <string name="global_action_silent_mode_off_status">"소리 켜짐"</string>
+    <string name="safeMode">"안전 모드"</string>
+    <string name="permgrouplab_costMoney">"요금이 부과되는 서비스"</string>
+    <string name="permgroupdesc_costMoney">"응용프로그램이 요금이 부과될 수 있는 작업을 할 수 있습니다."</string>
+    <string name="permgrouplab_messages">"메시지"</string>
+    <string name="permgroupdesc_messages">"SMS, 이메일 및 기타 메시지를 읽고 씁니다."</string>
+    <string name="permgrouplab_personalInfo">"개인 정보"</string>
+    <string name="permgroupdesc_personalInfo">"전화기에 저장된 연락처 및 캘린더에 직접 액세스합니다."</string>
+    <string name="permgrouplab_location">"위치"</string>
+    <string name="permgroupdesc_location">"물리적 위치 모니터링"</string>
+    <string name="permgrouplab_network">"네트워크 통신"</string>
+    <string name="permgroupdesc_network">"응용프로그램이 다양한 네트워크 기능에 액세스할 수 있습니다."</string>
+    <string name="permgrouplab_accounts">"Google 계정"</string>
+    <string name="permgroupdesc_accounts">"사용가능한 Google 계정에 액세스합니다."</string>
+    <string name="permgrouplab_hardwareControls">"하드웨어 제어"</string>
+    <string name="permgroupdesc_hardwareControls">"핸드셋의 하드웨어에 직접 액세스합니다."</string>
+    <string name="permgrouplab_phoneCalls">"전화 통화"</string>
+    <string name="permgroupdesc_phoneCalls">"전화 통화를 모니터링, 기록 및 처리합니다."</string>
+    <string name="permgrouplab_systemTools">"시스템 도구"</string>
+    <string name="permgroupdesc_systemTools">"하위 수준의 액세스 및 시스템 제어"</string>
+    <string name="permgrouplab_developmentTools">"개발도구"</string>
+    <string name="permgroupdesc_developmentTools">"응용프로그램 개발자에게만 필요한 기능입니다."</string>
+    <string name="permlab_statusBar">"상태 표시줄 사용 안 함 또는 수정"</string>
+    <string name="permdesc_statusBar">"응용프로그램이 상태 표시줄을 비활성화하거나 시스템 아이콘을 추가 및 제거할 수 있습니다."</string>
+    <string name="permlab_expandStatusBar">"상태 표시줄 확장/축소"</string>
+    <string name="permdesc_expandStatusBar">"응용프로그램이 상태 표시줄을 확장하거나 축소할 수 있습니다."</string>
+    <string name="permlab_processOutgoingCalls">"발신전화 가로채기"</string>
+    <string name="permdesc_processOutgoingCalls">"응용프로그램이 발신전화를 처리하고 전화를 걸 번호를 변경할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 발신전화를 모니터링하거나, 다른 방향으로 돌리거나, 중단시킬 수 있습니다."</string>
+    <string name="permlab_receiveSms">"SMS 받기"</string>
+    <string name="permdesc_receiveSms">"응용프로그램이 SMS 메시지를 받고 처리할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 메시지를 모니터링하거나 사용자가 보기 전에 삭제할 수 있습니다."</string>
+    <string name="permlab_receiveMms">"MMS 받기"</string>
+    <string name="permdesc_receiveMms">"응용프로그램이 MMS 메시지를 받고 처리할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 메시지를 모니터링하거나 사용자가 보기 전에 삭제할 수 있습니다."</string>
+    <string name="permlab_sendSms">"SMS 메시지 보내기"</string>
+    <string name="permdesc_sendSms">"응용프로그램이 SMS 메시지를 보낼 수 있습니다. 악성 응용프로그램은 사용자의 확인 없이 메시지를 전송하여 요금을 부과할 수 있습니다."</string>
+    <string name="permlab_readSms">"SMS 또는 MMS 읽기"</string>
+    <string name="permdesc_readSms">"응용프로그램이 전화기 또는 SIM 카드에 저장된 SMS 메시지를 읽을 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 기밀 메시지를 읽을 수 있습니다."</string>
+    <string name="permlab_writeSms">"SMS 또는 MMS 편집"</string>
+    <string name="permdesc_writeSms">"응용프로그램이 전화기 또는 SIM 카드에 저장된 SMS 메시지에 쓸 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 메시지를 삭제할 수 있습니다."</string>
+    <string name="permlab_receiveWapPush">"WAP 받기"</string>
+    <string name="permdesc_receiveWapPush">"응용프로그램이 WAP 메시지를 받고 처리할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 메시지를 모니터링하거나 사용자가 보기 전에 삭제할 수 있습니다."</string>
+    <string name="permlab_getTasks">"실행 중인 응용프로그램 검색"</string>
+    <string name="permdesc_getTasks">"응용프로그램이 현재 실행 중이거나 최근에 실행된 작업에 대한 정보를 검색할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 다른 응용프로그램에 대한 개인 정보를 검색할 수 있습니다."</string>
+    <string name="permlab_reorderTasks">"실행 중인 응용프로그램 순서 재지정"</string>
+    <string name="permdesc_reorderTasks">"응용프로그램이 작업을 포그라운드나 백그라운드로 이동할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 사용자의 조작 없이 작업을 강제로 앞으로 이동할 수 있습니다."</string>
+    <string name="permlab_setDebugApp">"응용프로그램 디버깅 사용"</string>
+    <string name="permdesc_setDebugApp">"응용프로그램이 다른 응용프로그램에 대한 디버깅을 설정할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 다른 응용프로그램을 중지시킬 수 있습니다."</string>
+    <string name="permlab_changeConfiguration">"UI 설정 변경"</string>
+    <string name="permdesc_changeConfiguration">"응용프로그램이 로케일 또는 전체 글꼴 크기 같은 현재 구성을 변경할 수 있습니다."</string>
+    <string name="permlab_restartPackages">"다른 응용프로그램 다시 시작"</string>
+    <string name="permdesc_restartPackages">"응용프로그램이 다른 응용프로그램을 강제로 다시 시작할 수 있습니다."</string>
+    <string name="permlab_setProcessForeground">"중지되지 않도록 하기"</string>
+    <string name="permdesc_setProcessForeground">"응용프로그램이 프로세스를 포그라운드에서 실행되도록 하여 프로세스를 중지할 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_forceBack">"강제로 응용프로그램 닫기"</string>
+    <string name="permdesc_forceBack">"응용프로그램이 포그라운드에 있는 활동을 강제로 닫을 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_dump">"시스템 내부 상태 검색"</string>
+    <string name="permdesc_dump">"응용프로그램이 시스템의 내부 상태를 검색할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 일반적으로 필요하지 않은 다양한 개인 정보와 보안 정보를 검색할 수 있습니다."</string>
+    <string name="permlab_addSystemService">"하위 수준 서비스 게시"</string>
+    <string name="permdesc_addSystemService">"응용프로그램이 자체 하위 수준 시스템 서비스를 게시할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 시스템을 하이재킹하거나 시스템의 데이터를 도용 또는 손상시킬 수 있습니다."</string>
+    <string name="permlab_runSetActivityWatcher">"실행 중인 모든 응용프로그램 모니터링 및 제어"</string>
+    <string name="permdesc_runSetActivityWatcher">"응용프로그램이 시스템에서 활동이 시작되는 방식을 모니터링하고 제어할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 시스템을 완전히 손상시킬 수 있습니다. 이 권한은 개발 과정에만 필요하며 일반 전화기 사용 시에는 필요하지 않습니다."</string>
+    <string name="permlab_broadcastPackageRemoved">"패키지 제거 브로드캐스트 보내기"</string>
+    <string name="permdesc_broadcastPackageRemoved">"응용프로그램이 응용프로그램 패키지가 제거되었다는 알림을 브로드캐스트할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 실행 중인 다른 응용프로그램을 중지시킬 수 있습니다."</string>
+    <string name="permlab_broadcastSmsReceived">"SMS 수신 브로드캐스트 보내기"</string>
+    <string name="permdesc_broadcastSmsReceived">"응용프로그램이 SMS 메시지를 받았다는 알림을 브로드캐스트할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 들어오는 SMS 메시지처럼 위장할 수 있습니다."</string>
+    <string name="permlab_broadcastWapPush">"WAP-PUSH-수신 브로드캐스트 보내기"</string>
+    <string name="permdesc_broadcastWapPush">"응용프로그램이 WAP PUSH 메시지를 받았다는 알림을 브로드캐스트할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 MMS 메시지를 받은 것처럼 위장하거나 웹페이지의 콘텐츠를 악성 변종으로 바꿀 수 있습니다."</string>
+    <string name="permlab_setProcessLimit">"실행 중인 프로세스 수 제한"</string>
+    <string name="permdesc_setProcessLimit">"응용프로그램이 실행할 최대 프로세스 수를 제어할 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_setAlwaysFinish">"모든 백그라운드 응용프로그램이 닫히도록 하기"</string>
+    <string name="permdesc_setAlwaysFinish">"응용프로그램이 백그라운드로 이동한 활동을 항상 바로 마칠지 여부를 제어할 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_fotaUpdate">"시스템 업데이트 자동으로 설치"</string>
+    <string name="permdesc_fotaUpdate">"응용프로그램이 대기 중인 시스템 업데이트에 대한 알림을 받고 설치를 트리거할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 인증되지 않은 업데이트로 시스템을 손상시키거나 업데이트 절차를 방해할 수 있습니다."</string>
+    <string name="permlab_batteryStats">"배터리 통계 수정"</string>
+    <string name="permdesc_batteryStats">"수집된 배터리 통계를 수정할 수 있습니다. 일반 응용프로그램에서는 사용하지 않습니다."</string>
+    <string name="permlab_internalSystemWindow">"인증되지 않은 창 표시"</string>
+    <string name="permdesc_internalSystemWindow">"내부 시스템 사용자 인터페이스에서 사용하는 창을 만들 수 있습니다. 일반 응용프로그램에서는 사용하지 않습니다."</string>
+    <string name="permlab_systemAlertWindow">"시스템 수준 경고 표시"</string>
+    <string name="permdesc_systemAlertWindow">"응용프로그램이 시스템 경고 창을 표시할 수 있습니다. 악성 응용프로그램은 전화기 화면 전체를 차지할 수 있습니다."</string>
+    <string name="permlab_setAnimationScale">"전체 애니메이션 속도 수정"</string>
+    <string name="permdesc_setAnimationScale">"응용프로그램이 언제든지 전체 애니메이션 속도를 빠르게 또는 느리게 변경할 수 있습니다."</string>
+    <string name="permlab_manageAppTokens">"응용프로그램 토큰 관리"</string>
+    <string name="permdesc_manageAppTokens">"응용프로그램이 일반적인 Z-순서를 무시하여 자체 토큰을 만들고 관리할 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_injectEvents">"키 및 컨트롤 버튼 누르기"</string>
+    <string name="permdesc_injectEvents">"응용프로그램이 입력 이벤트(예: 키 누름)를 다른 응용프로그램에 전달할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 전화기를 완전히 제어할 수 있습니다."</string>
+    <string name="permlab_readInputState">"사용자가 입력한 내용 및 수행한 작업 기록"</string>
+    <string name="permdesc_readInputState">"응용프로그램이 다른 응용프로그램과 상호작용할 때에도 사용자가 누르는 키(예: 비밀번호 입력)를 볼 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_bindInputMethod">"입력 방법에 고정"</string>
+    <string name="permdesc_bindInputMethod">"보유자가 입력 방법의 최상위 인터페이스에 고정할 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_setOrientation">"화면 방향 변경"</string>
+    <string name="permdesc_setOrientation">"응용프로그램이 언제든지 화면 회전을 변경할 수 있습니다. 일반 응용프로그램에는 필요하지 않습니다."</string>
+    <string name="permlab_signalPersistentProcesses">"응용프로그램에 Linux 신호 보내기"</string>
+    <string name="permdesc_signalPersistentProcesses">"응용프로그램이 제공된 신호를 모든 영구 프로세스로 보내도록 요청할 수 있습니다."</string>
+    <string name="permlab_persistentActivity">"응용프로그램이 항상 실행되도록 설정"</string>
+    <string name="permdesc_persistentActivity">"응용프로그램이 연결된 일부 구성요소를 지속하여 다른 응용프로그램에 사용할 수 없도록 합니다."</string>
+    <string name="permlab_deletePackages">"응용프로그램 삭제"</string>
+    <string name="permdesc_deletePackages">"응용프로그램이 Android 패키지를 삭제할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 중요한 응용프로그램을 삭제할 수 있습니다."</string>
+    <string name="permlab_clearAppUserData">"다른 응용프로그램의 데이터 삭제"</string>
+    <string name="permdesc_clearAppUserData">"응용프로그램이 사용자 데이터를 지울 수 있습니다."</string>
+    <string name="permlab_deleteCacheFiles">"다른 응용프로그램의 캐시 삭제"</string>
+    <string name="permdesc_deleteCacheFiles">"응용프로그램이 캐시 파일을 삭제할 수 있습니다."</string>
+    <string name="permlab_getPackageSize">"응용프로그램 저장공간 계산"</string>
+    <string name="permdesc_getPackageSize">"응용프로그램이 해당 코드, 데이터 및 캐시 크기를 검색할 수 있습니다."</string>
+    <string name="permlab_installPackages">"응용프로그램 직접 설치"</string>
+    <string name="permdesc_installPackages">"응용프로그램이 새로운 또는 업데이트된 Android 패키지를 설치할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 임의의 강력한 권한으로 새 응용프로그램을 추가할 수 있습니다."</string>
+    <string name="permlab_clearAppCache">"모든 응용프로그램 캐시 데이터 삭제"</string>
+    <string name="permdesc_clearAppCache">"응용프로그램이 응용프로그램 캐시 디렉토리에 있는 파일을 삭제하여 전화기의 저장공간을 늘릴 수 있습니다. 액세스는 일반적으로 시스템 프로세스로 제한됩니다."</string>
+    <string name="permlab_readLogs">"시스템 로그 파일 읽기"</string>
+    <string name="permdesc_readLogs">"응용프로그램이 시스템의 다양한 로그 파일을 읽을 수 있습니다. 이 경우 응용프로그램은 사용자가 전화기로 수행하는 작업에 대한 일반적인 정보를 검색할 수 있지만 여기에 개인 정보는 포함되어서는 안 됩니다."</string>
+    <string name="permlab_diagnostic">"진단 그룹 소유의 리소스 읽기/작성"</string>
+    <string name="permdesc_diagnostic">"응용프로그램이 진단 그룹 소유의 리소스(예: /dev에 있는 파일)를 읽고 쓸 수 있습니다. 이 기능은 시스템 안정성 및 보안에 영향을 미칠 수 있으므로, 제조업체 또는 사업자가 하드웨어 관련 진단을 수행하는 경우에만 사용해야 합니다."</string>
+    <string name="permlab_changeComponentState">"응용프로그램 구성요소 사용 또는 사용 안 함"</string>
+    <string name="permdesc_changeComponentState">"응용프로그램이 다른 응용프로그램 구성요소의 사용 여부를 변경할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 중요한 전화기 기능을 사용하지 않도록 설정할 수 있습니다. 응용프로그램 구성요소가 쓸모없게 되거나, 일관성이 없어지거나, 불안정해질 수 있으므로 이 권한을 설정할 때는 주의해야 합니다."</string>
+    <string name="permlab_setPreferredApplications">"기본 응용프로그램 설정"</string>
+    <string name="permdesc_setPreferredApplications">"응용프로그램이 기본 응용프로그램을 수정할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 기존 응용프로그램이 사용자의 개인 데이터를 수집하도록 스푸핑하여 실행되는 응용프로그램을 변경할 수 있습니다."</string>
+    <string name="permlab_writeSettings">"전체 시스템 설정 수정"</string>
+    <string name="permdesc_writeSettings">"응용프로그램이 시스템의 설정 데이터를 수정할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 시스템 구성을 손상시킬 수 있습니다."</string>
+    <string name="permlab_writeSecureSettings">"보안 시스템 설정 수정"</string>
+    <string name="permdesc_writeSecureSettings">"응용프로그램이 시스템 보안 설정값 데이터를 수정할 수 있습니다. 일반 응용프로그램에서는 사용하지 않습니다."</string>
+    <string name="permlab_writeGservices">"Google 서비스 지도 수정"</string>
+    <string name="permdesc_writeGservices">"응용프로그램이 Google 서비스 지도를 수정할 수 있습니다. 일반 응용프로그램에서는 사용하지 않습니다."</string>
+    <string name="permlab_receiveBootCompleted">"부팅할 때 자동 시작"</string>
+    <string name="permdesc_receiveBootCompleted">"응용프로그램이 시스템 부팅이 끝난 후 바로 시작할 수 있습니다. 이 경우 전화기가 시작하는 데 시간이 오래 걸리고 응용프로그램이 항상 실행되어 전체 전화기 속도가 느려질 수 있습니다."</string>
+    <string name="permlab_broadcastSticky">"남은 브로드캐스트 보내기"</string>
+    <string name="permdesc_broadcastSticky">"응용프로그램이 브로드캐스트가 끝난 후에 남은 브로드캐스트를 보낼 수 있습니다. 악성 응용프로그램은 전화기가 메모리를 너무 많이 사용하도록 하여 속도를 저하시키거나 불안정하게 만들 수 있습니다."</string>
+    <string name="permlab_readContacts">"연락처 데이터 읽기"</string>
+    <string name="permdesc_readContacts">"응용프로그램이 전화기에 저장된 모든 연락처(주소) 데이터를 읽을 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 데이터를 다른 사람에게 보낼 수 있습니다."</string>
+    <string name="permlab_writeContacts">"연락처 데이터 작성"</string>
+    <string name="permdesc_writeContacts">"응용프로그램이 전화기에 저장된 연락처(주소) 데이터를 수정할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 연락처 데이터를 지우거나 수정할 수 있습니다."</string>
+    <string name="permlab_writeOwnerData">"소유자 데이터 작성"</string>
+    <string name="permdesc_writeOwnerData">"응용프로그램이 전화기에 저장된 전화기 소유자 데이터를 수정할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 소유자 데이터를 지우거나 수정할 수 있습니다."</string>
+    <string name="permlab_readOwnerData">"소유자 데이터 읽기"</string>
+    <string name="permdesc_readOwnerData">"응용프로그램이 전화기에 저장된 전화기 소유자 데이터를 읽을 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 전화기 소유자 데이터를 읽을 수 있습니다."</string>
+    <string name="permlab_readCalendar">"캘린더 데이터 읽기"</string>
+    <string name="permdesc_readCalendar">"응용프로그램이 전화기에 저장된 모든 캘린더 일정을 읽을 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 캘린더 일정을 다른 사람에게 보낼 수 있습니다."</string>
+    <string name="permlab_writeCalendar">"캘린더 데이터 작성"</string>
+    <string name="permdesc_writeCalendar">"응용프로그램이 전화기에 저장된 캘린더 일정을 수정할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 캘린더 데이터를 지우거나 수정할 수 있습니다."</string>
+    <string name="permlab_accessMockLocation">"테스트를 위해 위치 소스로 가장"</string>
+    <string name="permdesc_accessMockLocation">"테스트용 가짜 위치 소스를 만듭니다. 악성 응용프로그램은 이 기능을 이용하여 GPS, 네트워크 제공업체 같은 실제 위치 소스에서 반환한 위치 및/또는 상태를 덮어쓸 수 있습니다."</string>
+    <string name="permlab_accessLocationExtraCommands">"추가 위치 제공업체 명령 액세스"</string>
+    <string name="permdesc_accessLocationExtraCommands">"추가 위치 제공업체 명령에 액세스합니다. 악성 응용프로그램은 이 기능을 이용하여 GPS 또는 기타 위치 소스의 작동을 방해할 수 있습니다."</string>
+    <string name="permlab_accessFineLocation">"자세한 (GPS) 위치"</string>
+    <string name="permdesc_accessFineLocation">"가능한 경우 전화기에서 GPS(범지구 위치 측정 시스템) 등의 자세한 위치 소스에 액세스합니다. 악성 응용프로그램은 이 기능을 이용하여 사용자의 위치를 측정하고 추가 배터리 전원을 소비할 수 있습니다."</string>
+    <string name="permlab_accessCoarseLocation">"광범위한 네트워크 기반 위치"</string>
+    <string name="permdesc_accessCoarseLocation">"전화기의 대략적인 위치를 측정하기 위해 셀룰러 네트워크 데이터베이스와 같은 광범위한 위치 소스에 액세스합니다. 악성 응용프로그램은 이 기능을 이용하여 사용자의 위치를 대략적으로 측정할 수 있습니다."</string>
+    <string name="permlab_accessSurfaceFlinger">"SurfaceFlinger 액세스"</string>
+    <string name="permdesc_accessSurfaceFlinger">"응용프로그램이 SurfaceFlinger의 하위 수준 기능을 사용할 수 있습니다."</string>
+    <string name="permlab_readFrameBuffer">"프레임 버퍼 읽기"</string>
+    <string name="permdesc_readFrameBuffer">"응용프로그램이 프레임 버퍼의 콘텐츠를 읽을 수 있습니다."</string>
+    <string name="permlab_modifyAudioSettings">"오디오 설정 변경"</string>
+    <string name="permdesc_modifyAudioSettings">"응용프로그램이 볼륨 및 경로 지정 같은 전체 오디오 설정을 수정할 수 있습니다."</string>
+    <string name="permlab_recordAudio">"오디오 녹음"</string>
+    <string name="permdesc_recordAudio">"응용프로그램이 오디오 레코드 경로에 액세스할 수 있습니다."</string>
+    <string name="permlab_camera">"사진 촬영"</string>
+    <string name="permdesc_camera">"응용프로그램이 카메라로 사진을 찍을 수 있습니다. 이 경우 응용프로그램은 카메라에 표시되는 이미지를 언제든지 수집할 수 있습니다."</string>
+    <string name="permlab_brick">"전화기를 영구적으로 비활성화"</string>
+    <string name="permdesc_brick">"응용프로그램이 전화기를 영구적으로 사용하지 않도록 설정할 수 있습니다. 이 기능은 매우 위험합니다."</string>
+    <string name="permlab_reboot">"전화기 강제로 다시 부팅"</string>
+    <string name="permdesc_reboot">"응용프로그램이 전화기를 강제로 다시 부팅할 수 있습니다."</string>
+    <string name="permlab_mount_unmount_filesystems">"파일시스템 마운트 및 마운트 해제"</string>
+    <string name="permdesc_mount_unmount_filesystems">"응용프로그램이 이동식 저장소의 파일시스템을 마운트하고 마운트 해제할 수 있습니다."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
+    <string name="permlab_vibrate">"진동 제어"</string>
+    <string name="permdesc_vibrate">"응용프로그램이 진동을 제어할 수 있습니다."</string>
+    <string name="permlab_flashlight">"손전등 제어"</string>
+    <string name="permdesc_flashlight">"응용프로그램이 손전등을 제어할 수 있습니다."</string>
+    <string name="permlab_hardware_test">"하드웨어 테스트"</string>
+    <string name="permdesc_hardware_test">"응용프로그램이 하드웨어를 테스트할 목적으로 다양한 주변장치를 제어할 수 있습니다."</string>
+    <string name="permlab_callPhone">"전화번호로 직접 전화걸기"</string>
+    <string name="permdesc_callPhone">"응용프로그램이 사용자의 조작 없이 전화번호로 전화를 걸 수 있습니다. 악성 응용프로그램은 전화요금 청구서에 예상치 못한 통화 요금이 부과되도록 할 수 있습니다. 이 권한으로 응용프로그램은 비상 전화를 걸 수 없습니다."</string>
+    <string name="permlab_callPrivileged">"전화번호로 직접 전화걸기"</string>
+    <string name="permdesc_callPrivileged">"응용프로그램이 사용자의 조작 없이 비상 번호를 포함한 전화번호로 전화를 걸 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 응급 서비스를 불필요하거나 불법적으로 호출할 수 있습니다."</string>
+    <string name="permlab_locationUpdates">"위치 업데이트 알림 제어"</string>
+    <string name="permdesc_locationUpdates">"무선의 위치 업데이트 알림을 활성화하거나 비활성화할 수 있습니다. 일반 응용프로그램에서는 사용하지 않습니다."</string>
+    <string name="permlab_checkinProperties">"체크인 속성 액세스"</string>
+    <string name="permdesc_checkinProperties">"체크인 서비스에서 업로드한 속성에 대한 읽기/쓰기 액세스를 허용합니다. 일반 응용프로그램에서는 사용하지 않습니다."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
+    <string name="permlab_modifyPhoneState">"전화기 상태 수정"</string>
+    <string name="permdesc_modifyPhoneState">"응용프로그램이 장치의 전화 기능을 제어할 수 있습니다. 이 권한을 갖는 응용프로그램은 사용자에게 알리지 않고 네트워크를 전환하거나, 전화 무선 기능을 켜고 끌 수 있습니다."</string>
+    <string name="permlab_readPhoneState">"전화기 상태 읽기"</string>
+    <string name="permdesc_readPhoneState">"응용프로그램이 장치의 전화 기능에 액세스할 수 있습니다. 이 권한을 갖는 응용프로그램은 전화기의 전화번호, 통화가 활성인지 여부, 통화가 연결된 번호 등을 확인할 수 있습니다."</string>
+    <string name="permlab_wakeLock">"전화기가 절전 모드로 전환되지 않도록 설정"</string>
+    <string name="permdesc_wakeLock">"응용프로그램이 전화기가 절전 모드로 전환되지 않도록 할 수 있습니다."</string>
+    <string name="permlab_devicePower">"전화기 전원 켜고 끄기"</string>
+    <string name="permdesc_devicePower">"응용프로그램이 전화기를 켜거나 끌 수 있습니다."</string>
+    <string name="permlab_factoryTest">"출고 테스트 모드로 실행"</string>
+    <string name="permdesc_factoryTest">"전화기 하드웨어에 대한 완전한 액세스를 허용하는 하위 수준의 제조업체 테스트로 실행됩니다. 전화기가 제조업체 테스트 모드로 실행 중일 때만 사용할 수 있습니다."</string>
+    <string name="permlab_setWallpaper">"배경화면 설정"</string>
+    <string name="permdesc_setWallpaper">"응용프로그램이 시스템 배경화면을 설정할 수 있습니다."</string>
+    <string name="permlab_setWallpaperHints">"배경화면 크기 힌트 설정"</string>
+    <string name="permdesc_setWallpaperHints">"응용프로그램이 시스템 배경화면 크기 힌트를 설정할 수 있습니다."</string>
+    <string name="permlab_masterClear">"시스템을 공장 기본값으로 재설정"</string>
+    <string name="permdesc_masterClear">"응용프로그램이 모든 데이터, 구성 및 설치된 응용프로그램을 지워서 시스템을 공장 기본값으로 완전히 재설정할 수 있습니다."</string>
+    <string name="permlab_setTimeZone">"표준시간대 설정"</string>
+    <string name="permdesc_setTimeZone">"응용프로그램이 전화기의 표준시간대를 변경할 수 있습니다."</string>
+    <string name="permlab_getAccounts">"알려진 계정 검색"</string>
+    <string name="permdesc_getAccounts">"응용프로그램이 전화기에 알려진 계정 목록을 가져올 수 있습니다."</string>
+    <string name="permlab_accessNetworkState">"네트워크 상태 보기"</string>
+    <string name="permdesc_accessNetworkState">"응용프로그램이 모든 네트워크의 상태를 볼 수 있습니다."</string>
+    <string name="permlab_createNetworkSockets">"인터넷에 완전히 액세스"</string>
+    <string name="permdesc_createNetworkSockets">"응용프로그램이 네트워크 소켓을 만들 수 있습니다."</string>
+    <string name="permlab_writeApnSettings">"액세스포인트 이름 설정 쓰기"</string>
+    <string name="permdesc_writeApnSettings">"응용프로그램이 APN의 프록시 및 포트 같은 APN 설정을 수정할 수 있습니다."</string>
+    <string name="permlab_changeNetworkState">"네트워크 연결 변경"</string>
+    <string name="permdesc_changeNetworkState">"응용프로그램이 네트워크 연결 상태를 변경할 수 있습니다."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
+    <string name="permlab_accessWifiState">"Wi-Fi 상태 보기"</string>
+    <string name="permdesc_accessWifiState">"응용프로그램이 Wi-Fi의 상태에 대한 정보를 볼 수 있습니다."</string>
+    <string name="permlab_changeWifiState">"Wi-Fi 상태 변경"</string>
+    <string name="permdesc_changeWifiState">"응용프로그램이 Wi-Fi 액세스포인트에 연결하거나 연결을 끊고, 구성된 Wi-Fi 네트워크를 변경할 수 있습니다."</string>
+    <string name="permlab_bluetoothAdmin">"Bluetooth 관리"</string>
+    <string name="permdesc_bluetoothAdmin">"응용프로그램이 로컬 Bluetooth 전화를 구성한 다음 원격 장치를 검색하여 페어링할 수 있습니다."</string>
+    <string name="permlab_bluetooth">"Bluetooth 연결 만들기"</string>
+    <string name="permdesc_bluetooth">"응용프로그램이 로컬 Bluetooth 전화의 구성을 보고 페어링된 장치에 연결하거나 연결을 수락할 수 있습니다."</string>
+    <string name="permlab_disableKeyguard">"키 잠금 사용 안 함"</string>
+    <string name="permdesc_disableKeyguard">"응용프로그램이 키 잠금 및 연결된 비밀번호 보안을 비활성화할 수 있습니다. 예를 들어, 전화기가 수신전화를 받을 때 키 잠금을 비활성화했다가 통화가 끝나면 키 잠금을 다시 활성화할 수 있습니다."</string>
+    <string name="permlab_readSyncSettings">"동기화 설정 읽기"</string>
+    <string name="permdesc_readSyncSettings">"응용프로그램이 연락처에 대해 동기화를 활성화할지 여부 같은 동기화 설정을 읽을 수 있습니다."</string>
+    <string name="permlab_writeSyncSettings">"동기화 설정 쓰기"</string>
+    <string name="permdesc_writeSyncSettings">"응용프로그램이 연락처에 대해 동기화를 활성화할지 여부 같은 동기화 설정을 수정할 수 있습니다."</string>
+    <string name="permlab_readSyncStats">"동기화 통계 읽기"</string>
+    <string name="permdesc_readSyncStats">"응용프로그램이 동기화 통계(예: 실행된 동기화 기록)을 읽을 수 있습니다."</string>
+    <string name="permlab_subscribedFeedsRead">"가입된 피드 읽기"</string>
+    <string name="permdesc_subscribedFeedsRead">"응용프로그램이 현재 동기화된 피드에 대한 상세정보를 가져올 수 있습니다."</string>
+    <string name="permlab_subscribedFeedsWrite">"가입 피드 작성"</string>
+    <string name="permdesc_subscribedFeedsWrite">"응용프로그램이 현재 동기화된 피드를 수정할 수 있습니다. 악성 응용프로그램은 이 기능을 이용하여 동기화된 피드를 변경할 수 있습니다."</string>
+    <!-- no translation found for permlab_readDictionary (432535716804748781) -->
+    <skip />
+    <!-- no translation found for permdesc_readDictionary (1082972603576360690) -->
+    <skip />
+    <!-- no translation found for permlab_writeDictionary (6703109511836343341) -->
+    <skip />
+    <!-- no translation found for permdesc_writeDictionary (2241256206524082880) -->
+    <skip />
+  <string-array name="phoneTypes">
+    <item>"집"</item>
+    <item>"휴대전화"</item>
+    <item>"회사"</item>
+    <item>"회사 팩스"</item>
+    <item>"집(팩스)"</item>
+    <item>"호출기"</item>
+    <item>"기타"</item>
+    <item>"사용자설정"</item>
+  </string-array>
+  <string-array name="emailAddressTypes">
+    <item>"집"</item>
+    <item>"회사"</item>
+    <item>"기타"</item>
+    <item>"사용자설정"</item>
+  </string-array>
+  <string-array name="postalAddressTypes">
+    <item>"집"</item>
+    <item>"회사"</item>
+    <item>"기타"</item>
+    <item>"사용자설정"</item>
+  </string-array>
+  <string-array name="imAddressTypes">
+    <item>"집"</item>
+    <item>"회사"</item>
+    <item>"기타"</item>
+    <item>"사용자설정"</item>
+  </string-array>
+  <string-array name="organizationTypes">
+    <item>"회사"</item>
+    <item>"기타"</item>
+    <item>"사용자설정"</item>
+  </string-array>
+  <string-array name="imProtocols">
+    <item>"AIM"</item>
+    <item>"Windows Live"</item>
+    <item>"Yahoo"</item>
+    <item>"Skype"</item>
+    <item>"QQ"</item>
+    <item>"Google 토크"</item>
+    <item>"ICQ"</item>
+    <item>"Jabber"</item>
+  </string-array>
+    <string name="keyguard_password_enter_pin_code">"PIN 코드 입력"</string>
+    <string name="keyguard_password_wrong_pin_code">"PIN 코드가 잘못되었습니다."</string>
+    <string name="keyguard_label_text">"잠금해제하려면 메뉴를 누른 다음 0을 누릅니다."</string>
+    <string name="emergency_call_dialog_number_for_display">"비상 전화번호"</string>
+    <string name="lockscreen_carrier_default">"(서비스 안 됨)"</string>
+    <string name="lockscreen_screen_locked">"화면 잠김"</string>
+    <string name="lockscreen_instructions_when_pattern_enabled">"비상 전화를 걸거나 잠금해제하려면 메뉴를 누르세요."</string>
+    <string name="lockscreen_instructions_when_pattern_disabled">"잠금해제하려면 메뉴를 누르세요."</string>
+    <string name="lockscreen_pattern_instructions">"잠금해제를 위해 패턴 그리기"</string>
+    <string name="lockscreen_emergency_call">"비상 전화"</string>
+    <string name="lockscreen_pattern_correct">"맞습니다."</string>
+    <string name="lockscreen_pattern_wrong">"죄송합니다. 다시 시도하세요."</string>
+    <string name="lockscreen_plugged_in">"충전 중(<xliff:g id="NUMBER">%d%%</xliff:g>)"</string>
+    <string name="lockscreen_low_battery">"충전기를 연결하세요."</string>
+    <string name="lockscreen_missing_sim_message_short">"SIM 카드가 없습니다."</string>
+    <string name="lockscreen_missing_sim_message">"전화기에 SIM 카드가 없습니다."</string>
+    <string name="lockscreen_missing_sim_instructions">"SIM 카드를 삽입하세요."</string>
+    <string name="lockscreen_network_locked_message">"네트워크 잠김"</string>
+    <string name="lockscreen_sim_puk_locked_message">"SIM 카드의 PUK가 잠겨 있습니다."</string>
+    <string name="lockscreen_sim_puk_locked_instructions">"고객지원팀에 문의하세요."</string>
+    <string name="lockscreen_sim_locked_message">"SIM 카드가 잠겨 있습니다."</string>
+    <string name="lockscreen_sim_unlock_progress_dialog_message">"SIM 카드 잠금해제 중..."</string>
+    <string name="lockscreen_too_many_failed_attempts_dialog_message">"잠금해제 패턴을 <xliff:g id="NUMBER_0">%d</xliff:g>회 잘못 가져왔습니다. "\n\n"<xliff:g id="NUMBER_1">%d</xliff:g>초 후에 다시 시도하세요."</string>
+    <string name="lockscreen_failed_attempts_almost_glogin">"잠금해제 패턴을 <xliff:g id="NUMBER_0">%d</xliff:g>회 잘못 그렸습니다. <xliff:g id="NUMBER_1">%d</xliff:g>회 더 실패하면 Google 로그인을 통해 전화기를 잠금해제하도록 요청됩니다."\n\n" <xliff:g id="NUMBER_2">%d</xliff:g>초 후에 다시 시도하세요."</string>
+    <string name="lockscreen_too_many_failed_attempts_countdown">"<xliff:g id="NUMBER">%d</xliff:g>초 후에 다시 입력하세요."</string>
+    <string name="lockscreen_forgot_pattern_button_text">"패턴을 잊으셨나요?"</string>
+    <string name="lockscreen_glogin_too_many_attempts">"패턴을 너무 많이 시도했습니다."</string>
+    <string name="lockscreen_glogin_instructions">"잠금해제하려면"\n"Google 계정으로 로그인하세요."</string>
+    <string name="lockscreen_glogin_username_hint">"사용자 이름(이메일)"</string>
+    <string name="lockscreen_glogin_password_hint">"비밀번호"</string>
+    <string name="lockscreen_glogin_submit_button">"로그인"</string>
+    <string name="lockscreen_glogin_invalid_input">"사용자 이름 또는 비밀번호가 잘못되었습니다."</string>
+    <string name="status_bar_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">AA</xliff:g>"</string>
+    <string name="hour_minute_ampm">"<xliff:g id="HOUR">%-l</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g><xliff:g id="AMPM">%P</xliff:g>"</string>
+    <string name="hour_minute_cap_ampm">"<xliff:g id="HOUR">%-l</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g><xliff:g id="AMPM">%p</xliff:g>"</string>
+    <!-- no translation found for hour_ampm (7618670480400517084) -->
+    <skip />
+    <!-- no translation found for hour_cap_ampm (5117798389811605468) -->
+    <skip />
+    <string name="status_bar_clear_all_button">"알림 지우기"</string>
+    <string name="status_bar_no_notifications_title">"알림 없음"</string>
+    <string name="status_bar_ongoing_events_title">"사용 중"</string>
+    <string name="status_bar_latest_events_title">"알림"</string>
+    <!-- no translation found for battery_status_text_percent_format (8818848472818880005) -->
+    <skip />
+    <string name="battery_status_charging">"충전 중..."</string>
+    <string name="battery_low_title">"충전기를 연결하세요."</string>
+    <string name="battery_low_subtitle">"배터리 전원이 부족합니다."</string>
+    <string name="battery_low_percent_format">"<xliff:g id="NUMBER">%d%%</xliff:g> 미만 남음"</string>
+    <string name="factorytest_failed">"출고 테스트 불합격"</string>
+    <string name="factorytest_not_system">"FACTORY_TEST 작업은 /system/app 디렉토리에 설치된 패키지에 대해서만 지원됩니다."</string>
+    <string name="factorytest_no_action">"FACTORY_TEST 작업을 제공하는 패키지가 없습니다."</string>
+    <string name="factorytest_reboot">"다시 부팅"</string>
+    <!-- no translation found for js_dialog_title (8143918455087008109) -->
+    <skip />
+    <!-- no translation found for js_dialog_title_default (6961903213729667573) -->
+    <skip />
+    <!-- no translation found for js_dialog_before_unload (1901675448179653089) -->
+    <skip />
+    <string name="save_password_label">"확인"</string>
+    <string name="save_password_message">"브라우저에 이 비밀번호를 저장하시겠습니까?"</string>
+    <string name="save_password_notnow">"나중에"</string>
+    <string name="save_password_remember">"저장"</string>
+    <string name="save_password_never">"저장 안 함"</string>
+    <string name="open_permission_deny">"페이지를 열 수 있는 권한이 없습니다."</string>
+    <string name="text_copied">"텍스트가 클립보드에 복사되었습니다."</string>
+    <string name="more_item_label">"자세히"</string>
+    <string name="prepend_shortcut_label">"Menu+"</string>
+    <string name="menu_space_shortcut_label">"스페이스바"</string>
+    <string name="menu_enter_shortcut_label">"입력"</string>
+    <string name="menu_delete_shortcut_label">"삭제"</string>
+    <string name="search_go">"검색"</string>
+    <string name="today">"오늘"</string>
+    <string name="yesterday">"어제"</string>
+    <string name="tomorrow">"내일"</string>
+    <string name="oneMonthDurationPast">"한 달 전"</string>
+    <string name="beforeOneMonthDurationPast">"한 달 전"</string>
+  <plurals name="num_seconds_ago">
+    <item quantity="one">"1초 전"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>초 전"</item>
+  </plurals>
+  <plurals name="num_minutes_ago">
+    <item quantity="one">"1분 전"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>분 전"</item>
+  </plurals>
+  <plurals name="num_hours_ago">
+    <item quantity="one">"1시간 전"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>시간 전"</item>
+  </plurals>
+  <plurals name="num_days_ago">
+    <item quantity="one">"어제"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>일 전"</item>
+  </plurals>
+  <plurals name="in_num_seconds">
+    <item quantity="one">"1초 내"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>초 후"</item>
+  </plurals>
+  <plurals name="in_num_minutes">
+    <item quantity="one">"1분 내"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>분 후"</item>
+  </plurals>
+  <plurals name="in_num_hours">
+    <item quantity="one">"1시간 내"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>시간 후"</item>
+  </plurals>
+  <plurals name="in_num_days">
+    <item quantity="one">"내일"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g>일 후"</item>
+  </plurals>
+    <!-- no translation found for abbrev_num_seconds_ago:one (1849036840200069118) -->
+    <!-- no translation found for abbrev_num_seconds_ago:other (3699169366650930415) -->
+    <!-- no translation found for abbrev_num_minutes_ago:one (6361490147113871545) -->
+    <!-- no translation found for abbrev_num_minutes_ago:other (851164968597150710) -->
+    <!-- no translation found for abbrev_num_hours_ago:one (4796212039724722116) -->
+    <!-- no translation found for abbrev_num_hours_ago:other (6889970745748538901) -->
+    <!-- no translation found for abbrev_num_days_ago:one (8463161711492680309) -->
+    <!-- no translation found for abbrev_num_days_ago:other (3453342639616481191) -->
+    <!-- no translation found for abbrev_in_num_seconds:one (5842225370795066299) -->
+    <!-- no translation found for abbrev_in_num_seconds:other (5495880108825805108) -->
+    <!-- no translation found for abbrev_in_num_minutes:one (562786149928284878) -->
+    <!-- no translation found for abbrev_in_num_minutes:other (4216113292706568726) -->
+    <!-- no translation found for abbrev_in_num_hours:one (3274708118124045246) -->
+    <!-- no translation found for abbrev_in_num_hours:other (3705373766798013406) -->
+    <!-- no translation found for abbrev_in_num_days:one (2178576254385739855) -->
+    <!-- no translation found for abbrev_in_num_days:other (2973062968038355991) -->
+    <string name="preposition_for_date">"%s"</string>
+    <string name="preposition_for_time">"%s"</string>
+    <string name="preposition_for_year">"%s년"</string>
+    <string name="day">"일"</string>
+    <string name="days">"일"</string>
+    <string name="hour">"시간"</string>
+    <string name="hours">"시간"</string>
+    <string name="minute">"분"</string>
+    <string name="minutes">"분"</string>
+    <string name="second">"초"</string>
+    <string name="seconds">"초"</string>
+    <string name="week">"주"</string>
+    <string name="weeks">"주"</string>
+    <string name="year">"년"</string>
+    <string name="years">"년"</string>
+    <string name="sunday">"일요일"</string>
+    <string name="monday">"월요일"</string>
+    <string name="tuesday">"화요일"</string>
+    <string name="wednesday">"수요일"</string>
+    <string name="thursday">"목요일"</string>
+    <string name="friday">"금요일"</string>
+    <string name="saturday">"토요일"</string>
+    <string name="every_weekday">"주중 매일(월-금)"</string>
+    <string name="daily">"매일"</string>
+    <string name="weekly">"매주 <xliff:g id="DAY">%s</xliff:g>"</string>
+    <string name="monthly">"매월"</string>
+    <string name="yearly">"매년"</string>
+    <string name="VideoView_error_title">"동영상 재생 안 됨"</string>
+    <string name="VideoView_error_text_unknown">"죄송합니다. 동영상을 재생할 수 없습니다."</string>
+    <string name="VideoView_error_button">"확인"</string>
+    <string name="am">"AM"</string>
+    <string name="pm">"PM"</string>
+    <string name="numeric_date">"<xliff:g id="MONTH">%m</xliff:g>/<xliff:g id="DAY">%d</xliff:g>/<xliff:g id="YEAR">%Y</xliff:g>"</string>
+    <string name="wday1_date1_time1_wday2_date2_time2">"<xliff:g id="DATE1">%2$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g>, <xliff:g id="TIME1">%3$s</xliff:g> – <xliff:g id="DATE2">%5$s</xliff:g>, <xliff:g id="WEEKDAY2">%4$s</xliff:g>, <xliff:g id="TIME2">%6$s</xliff:g>"</string>
+    <string name="wday1_date1_wday2_date2">"<xliff:g id="DATE1">%2$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g> – <xliff:g id="DATE2">%5$s</xliff:g>, <xliff:g id="WEEKDAY2">%4$s</xliff:g>"</string>
+    <string name="date1_time1_date2_time2">"<xliff:g id="DATE1">%2$s</xliff:g>, <xliff:g id="TIME1">%3$s</xliff:g> – <xliff:g id="DATE2">%5$s</xliff:g>, <xliff:g id="TIME2">%6$s</xliff:g>"</string>
+    <string name="date1_date2">"<xliff:g id="DATE1">%2$s</xliff:g> – <xliff:g id="DATE2">%5$s</xliff:g>"</string>
+    <string name="time1_time2">"<xliff:g id="TIME1">%1$s</xliff:g> – <xliff:g id="TIME2">%2$s</xliff:g>"</string>
+    <string name="time_wday_date">"<xliff:g id="DATE">%3$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>, <xliff:g id="TIME_RANGE">%1$s</xliff:g>"</string>
+    <string name="wday_date">"<xliff:g id="WEEKDAY">%2$s</xliff:g>, <xliff:g id="DATE">%3$s</xliff:g>"</string>
+    <string name="time_date">"<xliff:g id="DATE">%3$s</xliff:g>, <xliff:g id="TIME_RANGE">%1$s</xliff:g>"</string>
+    <!-- no translation found for date_time (6104442718633642836) -->
+    <skip />
+    <!-- no translation found for relative_time (1818557177829411417) -->
+    <skip />
+    <string name="time_wday">"<xliff:g id="WEEKDAY">%2$s</xliff:g>, <xliff:g id="TIME_RANGE">%1$s</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>', '<xliff:g id="DAY">d</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>', '<xliff:g id="DAY">d</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="noon">"정오"</string>
+    <string name="Noon">"정오"</string>
+    <string name="midnight">"자정"</string>
+    <string name="Midnight">"자정"</string>
+    <!-- no translation found for month_day (5565829181417740906) -->
+    <skip />
+    <!-- no translation found for month (7026169712234774086) -->
+    <skip />
+    <string name="month_day_year">"<xliff:g id="YEAR">%Y</xliff:g>, <xliff:g id="MONTH">%B</xliff:g> <xliff:g id="DAY">%-d</xliff:g>"</string>
+    <!-- no translation found for month_year (9219019380312413367) -->
+    <skip />
+    <string name="time_of_day">"<xliff:g id="HOUR">%H</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g>:<xliff:g id="SECOND">%S</xliff:g>"</string>
+    <string name="date_and_time">"<xliff:g id="YEAR">%Y</xliff:g>, <xliff:g id="MONTH">%B</xliff:g> <xliff:g id="DAY">%-d</xliff:g>, <xliff:g id="HOUR">%H</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g>:<xliff:g id="SECOND">%S</xliff:g>"</string>
+    <string name="same_year_md1_md2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2">%8$s</xliff:g>"</string>
+    <string name="same_year_wday1_md1_wday2_md2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>"</string>
+    <string name="same_year_mdy1_mdy2">"<xliff:g id="YEAR">%9$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2">%8$s</xliff:g>"</string>
+    <string name="same_year_wday1_mdy1_wday2_mdy2">"<xliff:g id="YEAR">%9$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>"</string>
+    <string name="same_year_md1_time1_md2_time2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2">%8$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_year_wday1_md1_time1_wday2_md2_time2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_year_mdy1_time1_mdy2_time2">"<xliff:g id="YEAR1">%4$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2">%8$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_year_wday1_mdy1_time1_wday2_mdy2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="YEAR1">%4$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g>, <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="numeric_md1_md2">"<xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1">%3$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2">%8$s</xliff:g>"</string>
+    <string name="numeric_wday1_md1_wday2_md2">"<xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>"</string>
+    <string name="numeric_mdy1_mdy2">"<xliff:g id="YEAR1">%4$s</xliff:g>/<xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1">%3$s</xliff:g> – <xliff:g id="YEAR2">%9$s</xliff:g>/<xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2">%8$s</xliff:g>/"</string>
+    <string name="numeric_wday1_mdy1_wday2_mdy2">"<xliff:g id="YEAR1">%4$s</xliff:g>/<xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g> – <xliff:g id="YEAR2">%9$s</xliff:g>/<xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>"</string>
+    <string name="numeric_md1_time1_md2_time2">"<xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1">%3$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2">%8$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="numeric_wday1_md1_time1_wday2_md2_time2">"<xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="numeric_mdy1_time1_mdy2_time2">"<xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1">%3$s</xliff:g>/<xliff:g id="YEAR1">%4$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2">%8$s</xliff:g>/<xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="numeric_wday1_mdy1_time1_wday2_mdy2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g>/<xliff:g id="DAY1_0">%3$s</xliff:g>/<xliff:g id="YEAR1">%4$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g>, <xliff:g id="MONTH2">%7$s</xliff:g>/<xliff:g id="DAY2_1">%8$s</xliff:g>/<xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_md1_md2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>"</string>
+    <string name="same_month_wday1_md1_wday2_md2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>"</string>
+    <string name="same_month_mdy1_mdy2">"<xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>"</string>
+    <string name="same_month_wday1_mdy1_wday2_mdy2">"<xliff:g id="YEAR1">%4$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g> – <xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>"</string>
+    <string name="same_month_md1_time1_md2_time2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2">%8$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_wday1_md1_time1_wday2_md2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g>, <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_mdy1_time1_mdy2_time2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g>, <xliff:g id="YEAR1">%4$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2">%8$s</xliff:g>, <xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_wday1_mdy1_time1_wday2_mdy2_time2">"<xliff:g id="YEAR1">%4$s</xliff:g>, <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>, <xliff:g id="WEEKDAY1">%1$s</xliff:g>, <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="YEAR2">%9$s</xliff:g>, <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>, <xliff:g id="WEEKDAY2">%6$s</xliff:g>, <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="abbrev_month_day_year">"<xliff:g id="YEAR">%Y</xliff:g> <xliff:g id="MONTH">%b</xliff:g>, <xliff:g id="DAY">%-d</xliff:g>"</string>
+    <!-- no translation found for abbrev_month_year (3856424847226891943) -->
+    <skip />
+    <!-- no translation found for abbrev_month_day (5028815883653985933) -->
+    <skip />
+    <!-- no translation found for abbrev_month (3131032032850777433) -->
+    <skip />
+    <string name="day_of_week_long_sunday">"일요일"</string>
+    <string name="day_of_week_long_monday">"월요일"</string>
+    <string name="day_of_week_long_tuesday">"화요일"</string>
+    <string name="day_of_week_long_wednesday">"수요일"</string>
+    <string name="day_of_week_long_thursday">"목요일"</string>
+    <string name="day_of_week_long_friday">"금요일"</string>
+    <string name="day_of_week_long_saturday">"토요일"</string>
+    <string name="day_of_week_medium_sunday">"일요일"</string>
+    <string name="day_of_week_medium_monday">"월"</string>
+    <string name="day_of_week_medium_tuesday">"화"</string>
+    <string name="day_of_week_medium_wednesday">"수"</string>
+    <string name="day_of_week_medium_thursday">"목"</string>
+    <string name="day_of_week_medium_friday">"금"</string>
+    <string name="day_of_week_medium_saturday">"토"</string>
+    <string name="day_of_week_short_sunday">"일"</string>
+    <string name="day_of_week_short_monday">"월"</string>
+    <string name="day_of_week_short_tuesday">"화"</string>
+    <string name="day_of_week_short_wednesday">"수"</string>
+    <string name="day_of_week_short_thursday">"목"</string>
+    <string name="day_of_week_short_friday">"금"</string>
+    <string name="day_of_week_short_saturday">"토"</string>
+    <string name="day_of_week_shorter_sunday">"일"</string>
+    <string name="day_of_week_shorter_monday">"월"</string>
+    <string name="day_of_week_shorter_tuesday">"화"</string>
+    <string name="day_of_week_shorter_wednesday">"수"</string>
+    <string name="day_of_week_shorter_thursday">"목"</string>
+    <string name="day_of_week_shorter_friday">"금"</string>
+    <string name="day_of_week_shorter_saturday">"토"</string>
+    <string name="day_of_week_shortest_sunday">"일"</string>
+    <string name="day_of_week_shortest_monday">"3월"</string>
+    <string name="day_of_week_shortest_tuesday">"목"</string>
+    <string name="day_of_week_shortest_wednesday">"수"</string>
+    <string name="day_of_week_shortest_thursday">"목"</string>
+    <string name="day_of_week_shortest_friday">"금"</string>
+    <string name="day_of_week_shortest_saturday">"토"</string>
+    <string name="month_long_january">"1월"</string>
+    <string name="month_long_february">"2월"</string>
+    <string name="month_long_march">"3월"</string>
+    <string name="month_long_april">"4월"</string>
+    <string name="month_long_may">"5월"</string>
+    <string name="month_long_june">"6월"</string>
+    <string name="month_long_july">"7월"</string>
+    <string name="month_long_august">"8월"</string>
+    <string name="month_long_september">"9월"</string>
+    <string name="month_long_october">"10월"</string>
+    <string name="month_long_november">"11월"</string>
+    <string name="month_long_december">"12월"</string>
+    <string name="month_medium_january">"1월"</string>
+    <string name="month_medium_february">"2월"</string>
+    <string name="month_medium_march">"3월"</string>
+    <string name="month_medium_april">"4월"</string>
+    <string name="month_medium_may">"5월"</string>
+    <string name="month_medium_june">"6월"</string>
+    <string name="month_medium_july">"7월"</string>
+    <string name="month_medium_august">"8월"</string>
+    <string name="month_medium_september">"9월"</string>
+    <string name="month_medium_october">"10월"</string>
+    <string name="month_medium_november">"11월"</string>
+    <string name="month_medium_december">"12월"</string>
+    <string name="month_shortest_january">"1월"</string>
+    <string name="month_shortest_february">"금"</string>
+    <string name="month_shortest_march">"3월"</string>
+    <string name="month_shortest_april">"4월"</string>
+    <string name="month_shortest_may">"5월"</string>
+    <string name="month_shortest_june">"6월"</string>
+    <string name="month_shortest_july">"7월"</string>
+    <string name="month_shortest_august">"8월"</string>
+    <string name="month_shortest_september">"9월"</string>
+    <string name="month_shortest_october">"10월"</string>
+    <string name="month_shortest_november">"11월"</string>
+    <string name="month_shortest_december">"12월"</string>
+    <string name="elapsed_time_short_format_mm_ss">"<xliff:g id="MINUTES">%1$02d</xliff:g>:<xliff:g id="SECONDS">%2$02d</xliff:g>"</string>
+    <string name="elapsed_time_short_format_h_mm_ss">"<xliff:g id="HOURS">%1$d</xliff:g>:<xliff:g id="MINUTES">%2$02d</xliff:g>:<xliff:g id="SECONDS">%3$02d</xliff:g>"</string>
+    <string name="selectAll">"모두 선택"</string>
+    <string name="selectText">"텍스트 선택"</string>
+    <string name="stopSelectingText">"텍스트 선택 중지"</string>
+    <string name="cut">"잘라내기"</string>
+    <string name="cutAll">"모두 잘라내기"</string>
+    <string name="copy">"복사"</string>
+    <string name="copyAll">"모두 복사"</string>
+    <string name="paste">"붙여넣기"</string>
+    <string name="copyUrl">"URL 복사"</string>
+    <string name="inputMethod">"입력 방법"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
+    <string name="editTextMenuTitle">"텍스트 수정"</string>
+    <string name="low_internal_storage_view_title">"저장공간 부족"</string>
+    <string name="low_internal_storage_view_text">"전화기 저장공간이 부족합니다."</string>
+    <string name="ok">"확인"</string>
+    <string name="cancel">"취소"</string>
+    <string name="yes">"확인"</string>
+    <string name="no">"취소"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
+    <string name="capital_on">"켜짐"</string>
+    <string name="capital_off">"끄기"</string>
+    <string name="whichApplication">"작업을 수행할 때 사용하는 권한"</string>
+    <string name="alwaysUse">"이 작업에 대해 기본값으로 사용"</string>
+    <string name="clearDefaultHintMsg">"홈 설정 &gt; 응용프로그램 &gt; 응용프로그램 관리에서 기본값을 지웁니다."</string>
+    <string name="chooseActivity">"작업 선택"</string>
+    <string name="noApplications">"작업을 수행할 수 있는 응용프로그램이 없습니다."</string>
+    <string name="aerr_title">"죄송합니다."</string>
+    <string name="aerr_application">"<xliff:g id="APPLICATION">%1$s</xliff:g> 응용프로그램(<xliff:g id="PROCESS">%2$s</xliff:g> 프로세스)이 예상치 않게 중지되었습니다. 다시 시도하세요."</string>
+    <string name="aerr_process">"<xliff:g id="PROCESS">%1$s</xliff:g> 프로세스가 예상치 않게 중지되었습니다. 다시 시도하세요."</string>
+    <string name="anr_title">"죄송합니다."</string>
+    <string name="anr_activity_application">"<xliff:g id="ACTIVITY">%1$s</xliff:g> 활동(<xliff:g id="APPLICATION">%2$s</xliff:g> 응용프로그램)이 응답하지 않습니다."</string>
+    <string name="anr_activity_process">"<xliff:g id="ACTIVITY">%1$s</xliff:g> 활동(<xliff:g id="PROCESS">%2$s</xliff:g> 프로세스)이 응답하지 않습니다."</string>
+    <string name="anr_application_process">"<xliff:g id="APPLICATION">%1$s</xliff:g> 응용프로그램(<xliff:g id="PROCESS">%2$s</xliff:g> 프로세스)이 응답하지 않습니다."</string>
+    <string name="anr_process">"<xliff:g id="PROCESS">%1$s</xliff:g> 프로세스가 응답하지 않습니다."</string>
+    <string name="force_close">"강제로 닫기"</string>
+    <string name="wait">"대기"</string>
+    <string name="debug">"디버깅"</string>
+    <string name="sendText">"텍스트에 대한 작업 선택"</string>
+    <string name="volume_ringtone">"벨소리 볼륨"</string>
+    <string name="volume_music">"미디어 볼륨"</string>
+    <string name="volume_music_hint_playing_through_bluetooth">"Bluetooth를 통해 재생"</string>
+    <string name="volume_call">"통화볼륨"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
+    <string name="volume_alarm">"알람 볼륨"</string>
+    <string name="volume_notification">"알림 볼륨"</string>
+    <string name="volume_unknown">"볼륨"</string>
+    <string name="ringtone_default">"기본 벨소리"</string>
+    <string name="ringtone_default_with_actual">"기본 벨소리(<xliff:g id="ACTUAL_RINGTONE">%1$s</xliff:g>)"</string>
+    <string name="ringtone_silent">"무음"</string>
+    <string name="ringtone_picker_title">"벨소리"</string>
+    <string name="ringtone_unknown">"알 수 없는 벨소리"</string>
+  <plurals name="wifi_available">
+    <item quantity="one">"Wi-Fi 네트워크 사용가능"</item>
+    <item quantity="other">"Wi-Fi 네트워크 사용가능"</item>
+  </plurals>
+  <plurals name="wifi_available_detailed">
+    <item quantity="one">"개방형 Wi-Fi 네트워크 사용가능"</item>
+    <item quantity="other">"개방형 Wi-Fi 네트워크 사용가능"</item>
+  </plurals>
+    <string name="select_character">"문자 삽입"</string>
+    <string name="sms_control_default_app_name">"알 수 없는 응용프로그램"</string>
+    <string name="sms_control_title">"SMS 메시지를 보내는 중"</string>
+    <string name="sms_control_message">"여러 개의 SMS 메시지를 보내는 중입니다. 계속하려면 \'확인\'을 선택하고 전송을 중지하려면 \'취소\'를 선택하세요."</string>
+    <string name="sms_control_yes">"확인"</string>
+    <string name="sms_control_no">"취소"</string>
+    <string name="date_time_set">"설정"</string>
+    <string name="default_permission_group">"기본값"</string>
+    <string name="no_permissions">"권한이 필요하지 않음"</string>
+    <string name="perms_hide"><b>"숨기기"</b></string>
+    <string name="perms_show_all"><b>"모두 표시"</b></string>
+    <string name="googlewebcontenthelper_loading">"로드 중..."</string>
+    <string name="usb_storage_title">"USB 연결됨"</string>
+    <string name="usb_storage_message">"USB를 통해 전화기를 컴퓨터에 연결했습니다. 컴퓨터와 전화기 SD 카드 간에 파일을 복사하려면 \'마운트\'를 선택하세요."</string>
+    <string name="usb_storage_button_mount">"마운트"</string>
+    <string name="usb_storage_button_unmount">"마운트 안 함"</string>
+    <string name="usb_storage_error_message">"USB 저장소에 SD 카드를 사용하는 동안 문제가 발생했습니다."</string>
+    <string name="usb_storage_notification_title">"USB 연결됨"</string>
+    <string name="usb_storage_notification_message">"컴퓨터에 파일을 복사하거나 컴퓨터의 파일을 복사하려면 선택합니다."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
+    <string name="select_input_method">"입력 방법 선택"</string>
+    <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
+    <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
+</resources>
diff --git a/tests/GadgetHost/res/values/strings.xml b/core/res/res/values-mcc204-ko/strings.xml
similarity index 67%
copy from tests/GadgetHost/res/values/strings.xml
copy to core/res/res/values-mcc204-ko/strings.xml
index d94cfbd..7d96230 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/core/res/res/values-mcc204-ko/strings.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<resources>
-    <string name="gadget_view_title">Gadget Test</string>
-    <string name="add_gadget">Add Gadget</string>
-    <string name="oh_hai">Oh hai.</string>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="locale_replacement">"nl_nl"</string>
 </resources>
-
diff --git a/tests/GadgetHost/res/values/strings.xml b/core/res/res/values-mcc230-ko/strings.xml
similarity index 67%
copy from tests/GadgetHost/res/values/strings.xml
copy to core/res/res/values-mcc230-ko/strings.xml
index d94cfbd..d3ecdbb 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/core/res/res/values-mcc230-ko/strings.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<resources>
-    <string name="gadget_view_title">Gadget Test</string>
-    <string name="add_gadget">Add Gadget</string>
-    <string name="oh_hai">Oh hai.</string>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="locale_replacement">"cs_cz"</string>
 </resources>
-
diff --git a/tests/GadgetHost/res/values/strings.xml b/core/res/res/values-mcc232-ko/strings.xml
similarity index 67%
copy from tests/GadgetHost/res/values/strings.xml
copy to core/res/res/values-mcc232-ko/strings.xml
index d94cfbd..4773838 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/core/res/res/values-mcc232-ko/strings.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<resources>
-    <string name="gadget_view_title">Gadget Test</string>
-    <string name="add_gadget">Add Gadget</string>
-    <string name="oh_hai">Oh hai.</string>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="locale_replacement">"de_at"</string>
 </resources>
-
diff --git a/tests/GadgetHost/res/values/strings.xml b/core/res/res/values-mcc234-ko/strings.xml
similarity index 67%
copy from tests/GadgetHost/res/values/strings.xml
copy to core/res/res/values-mcc234-ko/strings.xml
index d94cfbd..2538b73 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/core/res/res/values-mcc234-ko/strings.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<resources>
-    <string name="gadget_view_title">Gadget Test</string>
-    <string name="add_gadget">Add Gadget</string>
-    <string name="oh_hai">Oh hai.</string>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="locale_replacement">"en_gb"</string>
 </resources>
-
diff --git a/tests/GadgetHost/res/values/strings.xml b/core/res/res/values-mcc260-ko/strings.xml
similarity index 67%
copy from tests/GadgetHost/res/values/strings.xml
copy to core/res/res/values-mcc260-ko/strings.xml
index d94cfbd..1161f9a 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/core/res/res/values-mcc260-ko/strings.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<resources>
-    <string name="gadget_view_title">Gadget Test</string>
-    <string name="add_gadget">Add Gadget</string>
-    <string name="oh_hai">Oh hai.</string>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="locale_replacement">"pl_pl"</string>
 </resources>
-
diff --git a/tests/GadgetHost/res/values/strings.xml b/core/res/res/values-mcc262-ko/strings.xml
similarity index 67%
copy from tests/GadgetHost/res/values/strings.xml
copy to core/res/res/values-mcc262-ko/strings.xml
index d94cfbd..9505cf4 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/core/res/res/values-mcc262-ko/strings.xml
@@ -1,22 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
-  
+
           http://www.apache.org/licenses/LICENSE-2.0
-  
+
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<resources>
-    <string name="gadget_view_title">Gadget Test</string>
-    <string name="add_gadget">Add Gadget</string>
-    <string name="oh_hai">Oh hai.</string>
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="locale_replacement">"de_de"</string>
 </resources>
-
diff --git a/core/res/res/values-nb/strings.xml b/core/res/res/values-nb/strings.xml
new file mode 100644
index 0000000..9f49557
--- /dev/null
+++ b/core/res/res/values-nb/strings.xml
@@ -0,0 +1,842 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="byteShort">"B"</string>
+    <string name="kilobyteShort">"kB"</string>
+    <string name="megabyteShort">"MB"</string>
+    <string name="gigabyteShort">"GB"</string>
+    <string name="terabyteShort">"TB"</string>
+    <string name="petabyteShort">"PB"</string>
+    <string name="untitled">"&lt;uten navn&gt;"</string>
+    <string name="ellipsis">"…"</string>
+    <string name="emptyPhoneNumber">"(Mangler telefonnummer)"</string>
+    <string name="unknownName">"(Ukjent)"</string>
+    <string name="defaultVoiceMailAlphaTag">"Telefonsvarer"</string>
+    <string name="defaultMsisdnAlphaTag">"MSISDN1"</string>
+    <string name="mmiError">"Tilkoblingsproblem eller ugyldig MMI-kode."</string>
+    <string name="serviceEnabled">"Tjenesten ble aktivert."</string>
+    <string name="serviceEnabledFor">"Tjenesten ble aktivert for:"</string>
+    <string name="serviceDisabled">"Tjenesten ble deaktivert."</string>
+    <string name="serviceRegistered">"Registreringen er vellykket."</string>
+    <string name="serviceErased">"Registreringen ble fjernet."</string>
+    <string name="passwordIncorrect">"Ugyldig passord."</string>
+    <string name="mmiComplete">"MMI utført."</string>
+    <string name="badPin">"Den gamle PIN-koden du skrev inn er feil."</string>
+    <string name="badPuk">"PUK-koden du skrev inn er feil."</string>
+    <string name="mismatchPin">"PIN-kodene stemmer ikke overens."</string>
+    <string name="invalidPin">"PIN-koden må være mellom fire og åtte siffer."</string>
+    <string name="needPuk">"SIM-kortet ditt er PUK-låst. Skriv inn PUK-koden for å låse det opp."</string>
+    <string name="needPuk2">"Skriv inn PUK2 for å låse opp SIM-kortet."</string>
+    <string name="ClipMmi">"Inngående nummervisning"</string>
+    <string name="ClirMmi">"Utgående nummervisning"</string>
+    <string name="CfMmi">"Viderekobling"</string>
+    <string name="CwMmi">"Samtale venter"</string>
+    <string name="BaMmi">"Samtaleblokkering"</string>
+    <string name="PwdMmi">"Passordbytte"</string>
+    <string name="PinMmi">"PIN-kode-bytte"</string>
+    <string name="CLIRDefaultOnNextCallOn">"Nummervisning er begrenset som standard. Neste anrop: Begrenset"</string>
+    <string name="CLIRDefaultOnNextCallOff">"Nummervisning er begrenset som standard. Neste anrop: Ikke begrenset"</string>
+    <string name="CLIRDefaultOffNextCallOn">"Nummervisning er ikke begrenset som standard. Neste anrop: Begrenset"</string>
+    <string name="CLIRDefaultOffNextCallOff">"Nummervisning er ikke begrenset som standard. Neste anrop: Ikke begrenset"</string>
+    <string name="serviceNotProvisioned">"SIM-kortet er ikke tilrettelagt for tjenesten."</string>
+    <string name="CLIRPermanent">"Kunne ikke endre innstilling for nummervisning."</string>
+    <string name="serviceClassVoice">"Tale"</string>
+    <string name="serviceClassData">"Data"</string>
+    <string name="serviceClassFAX">"Fax"</string>
+    <string name="serviceClassSMS">"SMS"</string>
+    <string name="serviceClassDataAsync">"Asynkron"</string>
+    <string name="serviceClassDataSync">"Synkron"</string>
+    <string name="serviceClassPacket">"Pakkedata"</string>
+    <string name="serviceClassPAD">"PAD"</string>
+    <string name="cfTemplateNotForwarded">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: Ikke viderekoblet"</string>
+    <string name="cfTemplateForwarded">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: <xliff:g id="DIALING_NUMBER">{1}</xliff:g>"</string>
+    <string name="cfTemplateForwardedTime">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: <xliff:g id="DIALING_NUMBER">{1}</xliff:g> etter <xliff:g id="TIME_DELAY">{2}</xliff:g> sekunder"</string>
+    <string name="cfTemplateRegistered">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: Ikke viderekoblet"</string>
+    <string name="cfTemplateRegisteredTime">"<xliff:g id="BEARER_SERVICE_CODE">{0}</xliff:g>: Ikke viderekoblet"</string>
+    <string name="httpErrorOk">"OK"</string>
+    <string name="httpError">"Nettsiden inneholder en feil."</string>
+    <string name="httpErrorLookup">"Kunne ikke finne adressen."</string>
+    <string name="httpErrorUnsupportedAuthScheme">"Støtter ikke sidens autentiseringsmetode."</string>
+    <string name="httpErrorAuth">"Autentiseringen feilet."</string>
+    <string name="httpErrorProxyAuth">"Autentisering via mellomtjeneren feilet."</string>
+    <string name="httpErrorConnect">"Kunne ikke koble til tjeneren."</string>
+    <string name="httpErrorIO">"Klarte ikke å kommunisere med tjeneren. Prøv igjen senere."</string>
+    <string name="httpErrorTimeout">"Det oppsto et tidsavbrudd under tilkobling til tjeneren."</string>
+    <string name="httpErrorRedirectLoop">"Siden inneholder for mange videresendinger."</string>
+    <string name="httpErrorUnsupportedScheme">"Protokollen er ikke støttet."</string>
+    <string name="httpErrorFailedSslHandshake">"Kunne ikke opprette en sikker tilkobling."</string>
+    <string name="httpErrorBadUrl">"Kunne ikke åpne siden, siden adressen er ugyldig."</string>
+    <string name="httpErrorFile">"Kunne ikke åpne filen."</string>
+    <string name="httpErrorFileNotFound">"Fant ikke den forespurte filen."</string>
+    <string name="httpErrorTooManyRequests">"For mange forespørsler blir behandlet. Prøv igjen senere."</string>
+    <string name="contentServiceSync">"Synkronisering"</string>
+    <string name="contentServiceSyncNotificationTitle">"Synkronisering"</string>
+    <string name="contentServiceTooManyDeletesNotificationDesc">"For mange slettinger av <xliff:g id="CONTENT_TYPE">%s</xliff:g>."</string>
+    <string name="low_memory">"Telefonens lagringsminne er fullt! Slett noen filer for å frigjøre plass."</string>
+    <string name="me">"Meg"</string>
+    <string name="power_dialog">"Telefoninnstillinger"</string>
+    <string name="silent_mode">"Stillemodus"</string>
+    <string name="turn_on_radio">"Slå på trådløst nett"</string>
+    <string name="turn_off_radio">"Slå av trådløst nett"</string>
+    <string name="screen_lock">"Lås skjermen"</string>
+    <string name="power_off">"Slå av"</string>
+    <string name="shutdown_progress">"Avslutter…"</string>
+    <string name="shutdown_confirm">"Telefonen vil bli slått av."</string>
+    <string name="no_recent_tasks">"Ingen nylig brukte applikasjoner."</string>
+    <string name="global_actions">"Telefoninnstillinger"</string>
+    <string name="global_action_lock">"Lås skjermen"</string>
+    <string name="global_action_power_off">"Slå av"</string>
+    <string name="global_action_toggle_silent_mode">"Stillemodus"</string>
+    <string name="global_action_silent_mode_on_status">"Lyden er av"</string>
+    <string name="global_action_silent_mode_off_status">"Lyden er på"</string>
+    <string name="safeMode">"Sikkermodus"</string>
+    <string name="permgrouplab_costMoney">"Betaltjenester"</string>
+    <string name="permgroupdesc_costMoney">"Lar applikasjoner utføre operasjoner som kan koste deg penger."</string>
+    <string name="permgrouplab_messages">"Meldinger"</string>
+    <string name="permgroupdesc_messages">"Lese og skrive SMS, e-post og andre meldinger på telefonen."</string>
+    <string name="permgrouplab_personalInfo">"Personlig informasjon"</string>
+    <string name="permgroupdesc_personalInfo">"Direkte tilgang til kontakter og kalendre lagret på telefonen."</string>
+    <string name="permgrouplab_location">"Plassering"</string>
+    <string name="permgroupdesc_location">"Overvåking av telefonens fysiske plassering"</string>
+    <string name="permgrouplab_network">"Nettverkstilgang"</string>
+    <string name="permgroupdesc_network">"Gir applikasjoner tilgang til diverse nettverksfunksjoner."</string>
+    <string name="permgrouplab_accounts">"Google-kontoer"</string>
+    <string name="permgroupdesc_accounts">"Tilgang til tilgjengelige Google-kontoer."</string>
+    <string name="permgrouplab_hardwareControls">"Maskinvarekontroll"</string>
+    <string name="permgroupdesc_hardwareControls">"Direkte tilgang til maskinvaren på telefonen."</string>
+    <string name="permgrouplab_phoneCalls">"Telefonsamtaler"</string>
+    <string name="permgroupdesc_phoneCalls">"Overvåk, ta opp, og behandle telefonsamtaler."</string>
+    <string name="permgrouplab_systemTools">"Systemverktøy"</string>
+    <string name="permgroupdesc_systemTools">"Lavnivå tilgang og kontroll over systemet."</string>
+    <string name="permgrouplab_developmentTools">"Utviklingsverktøy"</string>
+    <string name="permgroupdesc_developmentTools">"Funksjonalitet kun utviklere trenger."</string>
+    <string name="permlab_statusBar">"deaktivere eller endre statusfeltet"</string>
+    <string name="permdesc_statusBar">"Lar applikasjonen deaktivere statusfeltet, samt legge til og fjerne systemikoner."</string>
+    <string name="permlab_expandStatusBar">"utvide/slå sammen statusfeltet"</string>
+    <string name="permdesc_expandStatusBar">"Lar applikasjonen utvide eller slå sammen statusfeltet."</string>
+    <string name="permlab_processOutgoingCalls">"avskjære utgående anrop"</string>
+    <string name="permdesc_processOutgoingCalls">"Lar applikasjonen behandle utgående anrop og endre nummeret som ringes. Ondsinnede applikasjoner kan overvåke, videresende, eller hindre utgående anrop."</string>
+    <string name="permlab_receiveSms">"motta SMS"</string>
+    <string name="permdesc_receiveSms">"Lar applikasjonen motta og behandle SMS-meldinger. Ondsinnede applikasjoner kan overvåke meldinger eller slette dem uten at de vises."</string>
+    <string name="permlab_receiveMms">"motta MMS"</string>
+    <string name="permdesc_receiveMms">"Lar applikasjonen motta og behandle MMS-meldinger. Ondsinnede applikasjoner kan overvåke meldinger eller slette dem uten at de vises."</string>
+    <string name="permlab_sendSms">"sende SMS-meldinger"</string>
+    <string name="permdesc_sendSms">"Lar applikasjonen sende SMS-meldinger. Ondsinnede applikasjoner kan koste deg penger ved å sende meldinger uten bekreftelse."</string>
+    <string name="permlab_readSms">"lese SMS- og MMS-meldinger"</string>
+    <string name="permdesc_readSms">"Lar applikasjonen lese SMS-meldinger lagret i telefonen eller på SIM-kortet. Ondsinnede applikasjoner kan lese private meldinger."</string>
+    <string name="permlab_writeSms">"redigere SMS- og MMS-meldinger"</string>
+    <string name="permdesc_writeSms">"Lar applikasjonen skrive til SMS-meldinger lagret i telefonen eller på SIM-kortet. Ondsinnede applikasjoner kan slette meldinger."</string>
+    <string name="permlab_receiveWapPush">"motta WAP"</string>
+    <string name="permdesc_receiveWapPush">"Lar applikasjonen motta og behandle WAP-meldinger. Ondsinnede applikasjoner kan overvåke meldinger eller slette dem uten at de vises."</string>
+    <string name="permlab_getTasks">"se kjørende applikasjoner"</string>
+    <string name="permdesc_getTasks">"Tillater applikasjonen å hente informasjon om aktive og nylig kjørte programmer. Kan tillate ondsinnede applikasjoner å oppdage privat informasjon om andre applikasjoner."</string>
+    <string name="permlab_reorderTasks">"omordne kjørende applikasjoner"</string>
+    <string name="permdesc_reorderTasks">"Tillater applikasjonen å flytte programmer til forgrunnen eller bakgrunnen. Ondsinnede applikasjoner kan tvinge seg selv til fronten."</string>
+    <string name="permlab_setDebugApp">"aktiver applikasjonsdebugging"</string>
+    <string name="permdesc_setDebugApp">"Lar applikasjonen skru på debugging for en annen applikasjon. Ondsinnede applikasjoner kan bruke dette til å drepe andre applikasjoner."</string>
+    <string name="permlab_changeConfiguration">"endre innstillingene for brukergrensesnitt"</string>
+    <string name="permdesc_changeConfiguration">"Tillater applikasjonen å endre gjeldende innstillinger, slik som språk eller skriftstørrelse."</string>
+    <string name="permlab_restartPackages">"omstarte andre applikasjoner"</string>
+    <string name="permdesc_restartPackages">"Lar applikasjonen tvinge andre applikasjoner til å starte på nytt."</string>
+    <string name="permlab_setProcessForeground">"unngå å bli stoppet"</string>
+    <string name="permdesc_setProcessForeground">"Lar applikasjonen sette en vilkårlig prosess i forgrunnen, så den ikke kan bli drept. Vanlige applikasjoner bør aldri trenge dette."</string>
+    <string name="permlab_forceBack">"tvinge applikasjoner til å lukkes"</string>
+    <string name="permdesc_forceBack">"Lar applikasjonen tvinge enhver aktivitet som er i forgrunnen til å lukkes og gå tilbake. Vanlige applikasjoner bør aldri trenge dette."</string>
+    <string name="permlab_dump">"hente intern systemtilstand"</string>
+    <string name="permdesc_dump">"Lar applikasjonen hente intern tilstand fra systemet. Onsdinnede applikasjoner kan hente et bredt spekter av privat og sikker informasjon som de vanligvis aldri burde ha behov for."</string>
+    <string name="permlab_addSystemService">"publisere lavnivåtjenester"</string>
+    <string name="permdesc_addSystemService">"Lar applikasjonen publisere sine egne lavnivås systemtjenester. Ondsinnede applikasjoner kan kapre systemet, og stjele eller ødelegge alle data på det."</string>
+    <string name="permlab_runSetActivityWatcher">"overvåke og kontrollere all applikasjonsoppstart"</string>
+    <string name="permdesc_runSetActivityWatcher">"Lar applikasjonen overvåke og kontrollere hvordan systemet starter applikasjoner. Ondsinnede applikasjoner kan ta over systemet helt. Denne rettigheten behøves bare for utvikling, aldri for vanlig bruk av telefonen."</string>
+    <string name="permlab_broadcastPackageRemoved">"kringkaste melding om fjernet pakke"</string>
+    <string name="permdesc_broadcastPackageRemoved">"Lar applikasjonen kringkaste en melding om at en applikasjonspakke er blitt fjernet. Ondsinnede applikasjoner kan bruke dette til å drepe vilkårlige andre kjørende applikasjoner."</string>
+    <string name="permlab_broadcastSmsReceived">"kringkaste melding om mottatt SMS"</string>
+    <string name="permdesc_broadcastSmsReceived">"Lar applikasjonen kringkaste en melding om at en SMS-melding er mottatt. Ondsinnede applikasjoner kan bruke dette til å forfalske innkommende SMS-meldinger."</string>
+    <string name="permlab_broadcastWapPush">"kringkaste melding om mottatt WAP-PUSH"</string>
+    <string name="permdesc_broadcastWapPush">"Lar applikasjonen kringkaste en melding om at en WAP-PUSH-melding er blitt mottatt. Ondsinnede applikasjoner kan bruke dette for å forfalske MMS-kvitteringer eller i det stille erstatte innholdet av vilkårlige nettsider med ondsinnede varianter."</string>
+    <string name="permlab_setProcessLimit">"begrense antallet kjørende prosesser"</string>
+    <string name="permdesc_setProcessLimit">"Lar applikasjonen kontrollere maksimalt antall kjørende prosesser. Behøves aldri for vanlige applikasjoner."</string>
+    <string name="permlab_setAlwaysFinish">"få alle bakgrunnsapplikasjoner til å lukkes"</string>
+    <string name="permdesc_setAlwaysFinish">"Lar applikasjonen kontrollere om aktiviteter alltid avsluttes når de sendes til bakgrunnen. Behøves aldri for vanlige applikasjoner."</string>
+    <string name="permlab_fotaUpdate">"installere systemoppdateringer automatisk"</string>
+    <string name="permdesc_fotaUpdate">"Lar applikasjonen motta meldinger om pågående systemoppdateringer, og starte installeringen av dem. Ondsinnede applikasjoner kan bruke dette for å skade systemet med uautoriserte oppdateringer, eller generelt forstyrre oppdateringsprosessen."</string>
+    <string name="permlab_batteryStats">"endre batteristatistikk"</string>
+    <string name="permdesc_batteryStats">"Lar applikasjonen endre på innsamlet batteristatistikk. Ikke ment for vanlige applikasjoner."</string>
+    <string name="permlab_internalSystemWindow">"vis uautoriserte vinduer"</string>
+    <string name="permdesc_internalSystemWindow">"Tillater at det opprettes vinduer ment for bruk av systemets interne brukergrensesnitt. Ikke ment for vanlige applikasjoner."</string>
+    <string name="permlab_systemAlertWindow">"vise advarsler på systemnivå"</string>
+    <string name="permdesc_systemAlertWindow">"Lar applikasjonen vise systemadvarselvinduer. Ondsinnede applikasjoner kan ta over hele skjermen."</string>
+    <string name="permlab_setAnimationScale">"endre global animasjonshastighet"</string>
+    <string name="permdesc_setAnimationScale">"Lar applikasjonen endre den globale animasjonshastigheten (raskere eller tregere animasjoner) når som helst."</string>
+    <string name="permlab_manageAppTokens">"styre applikasjonssymboler"</string>
+    <string name="permdesc_manageAppTokens">"Lar applikasjoner lage og vedlikeholde sine egne symboler, noe som lar dem overstyre den vanlige Z-ordningen. Vanlige applikasjoner bør aldri trenge dette."</string>
+    <string name="permlab_injectEvents">"trykke taster og kontrolknapper"</string>
+    <string name="permdesc_injectEvents">"Lar applikasjonen levere sine egne inndatahendelser (tastetrykk osv.) til andre applikasjoner. Ondsinnede applikasjoner kan bruke dette for å ta over telefonen."</string>
+    <string name="permlab_readInputState">"ta opp hva som skrives og gjøres"</string>
+    <string name="permdesc_readInputState">"Lar applikasjonen overvåke tastetrykk selv når interaksjonen er med et annet program (som å skrive inn et passord). Vanlige applikasjoner bør aldri trenge dette."</string>
+    <string name="permlab_bindInputMethod">"binde til en inndatametode"</string>
+    <string name="permdesc_bindInputMethod">"Lar applikasjonen binde til toppnivågrensesnittet for en inndatametode. Vanlige applikasjoner bør aldri trenge dette."</string>
+    <string name="permlab_setOrientation">"snu skjermen"</string>
+    <string name="permdesc_setOrientation">"Lar applikasjonen rotere skjermen når som helst. Vanlige applikasjoner bør aldri trenge dette."</string>
+    <string name="permlab_signalPersistentProcesses">"sende Linux-signaler til applikasjoner"</string>
+    <string name="permdesc_signalPersistentProcesses">"Lar applikasjonen spørre om at et gitt signal blir sendt til alle varige prosesser."</string>
+    <string name="permlab_persistentActivity">"forbli kjørende"</string>
+    <string name="permdesc_persistentActivity">"Lar applikasjonen gjøre deler av seg selv varig, så systemet ikke kan bruke det til andre applikasjoner."</string>
+    <string name="permlab_deletePackages">"slette applikasjoner"</string>
+    <string name="permdesc_deletePackages">"Lar applikasjonen slette Android-pakker. Ondsinnede applikasjoner kan bruke dette for å slette viktige applikasjoner."</string>
+    <string name="permlab_clearAppUserData">"slette andre applikasjoners data"</string>
+    <string name="permdesc_clearAppUserData">"Lar applikasjonen fjerne brukerdata."</string>
+    <string name="permlab_deleteCacheFiles">"slette andre applikasjoners hurtigbuffer"</string>
+    <string name="permdesc_deleteCacheFiles">"Lar applikasjonen to slette hurtigbufferfiler."</string>
+    <string name="permlab_getPackageSize">"måle lagringsplass for applikasjon"</string>
+    <string name="permdesc_getPackageSize">"Lar applikasjonen hente kode-, data- og hurtigbufferstørrelser"</string>
+    <string name="permlab_installPackages">"installere applikasjoner direkte"</string>
+    <string name="permdesc_installPackages">"Lar applikasjonen installere nye eller oppdaterte Android-pakker. Ondsinnede applikasjoner kan bruke dette for å legge til nye applikasjoner med vilkårlig kraftige rettigheter."</string>
+    <string name="permlab_clearAppCache">"slette hurtigbufferdata for alle applikasjoner"</string>
+    <string name="permdesc_clearAppCache">"Lar applikasjonen frigjøre lagringsplass ved å slette filer i applikasjoners hurtigbufferkatalog. Tilgangen er vanligvis sterkt begrenset, til systemprosesser."</string>
+    <string name="permlab_readLogs">"lese systemets loggfiler"</string>
+    <string name="permdesc_readLogs">"Lar applikasjonen to lese fra diverse loggfiler på systemet. Disse inneholder generell informasjon om hva som gjøres med telefonen, men skal ikke inneholde personlig eller privat informasjon."</string>
+    <string name="permlab_diagnostic">"lese/skrive ressurser eid av diag"</string>
+    <string name="permdesc_diagnostic">"Lar applikasjonen to lese og skrive enhver ressurs eid av gruppen diag; for eksempel, filer i /dev. Dette kan potensielt påvirke systemets sikkerhet og stabilitet. Dette bør KUN brukes for maskinvarespesifikke diagnoseverktøy laget av operatøren eller produsenten."</string>
+    <string name="permlab_changeComponentState">"aktivere eller deaktigere applikasjonskomponenter"</string>
+    <string name="permdesc_changeComponentState">"Lar applikasjonen endre om en komponent i en annen applikasjon er aktivert eller ikke. Ondsinnede applikasjoner kan bruke dette for å deaktivere viktige telefonfunksjoner. Denne rettigheten må brukes med forsiktighet, ettersom det er mulig å få applikasjonskomponenter inn i en ubrukelig, inkonsistent eller ustabil tilstand."</string>
+    <string name="permlab_setPreferredApplications">"velge foretrukne applikasjoner"</string>
+    <string name="permdesc_setPreferredApplications">"Lar applikasjonen endre valgene for foretrukne applikasjoner. Dette kan gi ondsinnede applikasjoner tilgang til i det stille å endre hvilke applikasjoner som kjøres, og slik gi seg ut for å være en eksisterende applikasjon og samle private data."</string>
+    <string name="permlab_writeSettings">"endre globale systeminnstillinger"</string>
+    <string name="permdesc_writeSettings">"Lar applikasjonen endre systemets innstillingsdata. Ondsinnede applikasjoner kan skade systemets innstillinger."</string>
+    <string name="permlab_writeSecureSettings">"endre sikre systeminnstillinger"</string>
+    <string name="permdesc_writeSecureSettings">"Lar applikasjonen endre systemets sikre innstillingsdata. Ikke ment for bruk av vanlige applikasjoner."</string>
+    <string name="permlab_writeGservices">"redigere Google-tjenestekartet"</string>
+    <string name="permdesc_writeGservices">"Lar applikasjonen redigere Google-tjenestekartet. Ikke ment for bruk av vanlige applikasjoner."</string>
+    <string name="permlab_receiveBootCompleted">"starte automatisk sammen med systemet"</string>
+    <string name="permdesc_receiveBootCompleted">"Lar applikasjonen sette opp at den selv skal starte så fort systemet er ferdig med å slå seg på. Dette kan gjøre at det tar lengre tid å starte telefonen, og at den kan bli tregere fordi applikasjonen alltid kjører."</string>
+    <string name="permlab_broadcastSticky">"sende varige kringkastinger"</string>
+    <string name="permdesc_broadcastSticky">"Lar applikasjonen sende varige kringkastinger, som forblir på systemet etter at kringkastingen er avsluttet. Ondsinnede applikasjoner kan gjøre telefonen treg eller ustabil ved å få den til å bruke for mye minne."</string>
+    <string name="permlab_readContacts">"lese kontaktinformasjon"</string>
+    <string name="permdesc_readContacts">"Lar applikasjonen lese all kontakt- og adresseinformasjon lagret på telefonen. Ondsinnede applikasjoner kan bruke dette for å sende personlige data til andre."</string>
+    <string name="permlab_writeContacts">"skrive kontaktinformasjon"</string>
+    <string name="permdesc_writeContacts">"Lar applikasjonen endre kontakt- og adresseinformasjon lagret på telefonen. Ondsinnede applikasjoner kan bruke dette for å redigere eller endre kontaktinformasjonen."</string>
+    <string name="permlab_writeOwnerData">"skrive eierinformasjon"</string>
+    <string name="permdesc_writeOwnerData">"Lar applikasjonen endre dataene om telefoneieren. Ondsinnede applikasjoner kan bruke dette til å slette eller redigere telefonens eierdata."</string>
+    <string name="permlab_readOwnerData">"lese eierinformasjon"</string>
+    <string name="permdesc_readOwnerData">"Lar applikasjonen lese dataene om telefoneieren. Ondsinnede applikasjoner kan bruke dette til å lese telefonens eierdata."</string>
+    <string name="permlab_readCalendar">"lese kalenderinformasjon"</string>
+    <string name="permdesc_readCalendar">"Lar applikasjonen lese alle kalenderhendelser lagret på telefonen. Ondsinnede applikasjoner kan bruke dette til å sende kalenderhendelser til andre."</string>
+    <string name="permlab_writeCalendar">"skrive kalenderinformasjon"</string>
+    <string name="permdesc_writeCalendar">"Lar applikasjonen endre kalenderhendelser lagret på telefonen. Ondsinnede applikasjoner kan bruke dette til å slette eller endre kalenderinformasjon."</string>
+    <string name="permlab_accessMockLocation">"lage falske plasseringskilder for testing"</string>
+    <string name="permdesc_accessMockLocation">"Lage falske plassingskilder for testing. Ondsinnede applikasjoner kan bruke dette for å overstyre plasseringen og/eller statusen rapportert av ekte plasseringskilder slik som GPS eller nettverksoperatører."</string>
+    <string name="permlab_accessLocationExtraCommands">"få tilgang til ekstra plasseringskommandoer"</string>
+    <string name="permdesc_accessLocationExtraCommands">"Få tilgang til ekstra kommandoer for plasseringskilder. Ondsinnede applikasjoner kan bruke dette til å forstyrre GPS eller andre plasseringskilder."</string>
+    <string name="permlab_accessFineLocation">"nøyaktig (GPS-) plassering"</string>
+    <string name="permdesc_accessFineLocation">"Få tilgang til nøyaktige plasseringskilder som Global Positioning System (GPS) på telefonen, når det er tilgjengelig. Ondsinnede applikasjoner kan bruke dette for å finne ut hvor du er, og kan bruke mer batteri."</string>
+    <string name="permlab_accessCoarseLocation">"grov (nettverksbasert) plassering"</string>
+    <string name="permdesc_accessCoarseLocation">"Få tilgang til grove plasseringskilder som databasen over basestasjoner for å finne ut omtrent hvor telefonen er, når det er tilgjengelig. Ondsinnede applikasjoner kan bruke dette for å finne ut omtrent hvor du er."</string>
+    <string name="permlab_accessSurfaceFlinger">"få tilgang til SurfaceFlinger"</string>
+    <string name="permdesc_accessSurfaceFlinger">"Lar applikasjonen bruke lavnivåfunksjonalitet i SurfaceFlinger."</string>
+    <string name="permlab_readFrameBuffer">"lese skjermbufferet"</string>
+    <string name="permdesc_readFrameBuffer">"Lar applikasjonen lese innholdet i skjermbufferet."</string>
+    <string name="permlab_modifyAudioSettings">"endre lydinnstillinger"</string>
+    <string name="permdesc_modifyAudioSettings">"Lar applikasjonen endre globale lydinnstillinger som volum og ruting."</string>
+    <string name="permlab_recordAudio">"ta opp lyd"</string>
+    <string name="permdesc_recordAudio">"Gir applikasjonen tilgang til opptaksstien for lyd."</string>
+    <string name="permlab_camera">"ta bilder"</string>
+    <string name="permdesc_camera">"Lar applikasjonen ta bilder med kameraet. Dette gir applikasjonen til når som helst å se og lagre det kameraet ser."</string>
+    <string name="permlab_brick">"deaktivere telefonen permanent"</string>
+    <string name="permdesc_brick">"Lar applikasjonen deaktivere hele telefonen permanent. Dette er svært farlig."</string>
+    <string name="permlab_reboot">"tvinge omstart av telefon"</string>
+    <string name="permdesc_reboot">"Lar applikasjonen tvinge telefonen til å starte på nytt."</string>
+    <string name="permlab_mount_unmount_filesystems">"montere og avmontere filsystemer"</string>
+    <string name="permdesc_mount_unmount_filesystems">"Lar applikasjonen montere og avmontere filsystemer for uttagbar lagring."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
+    <string name="permlab_vibrate">"kontrollere vibratoren"</string>
+    <string name="permdesc_vibrate">"Lar applikasjonen kontrollere vibratoren."</string>
+    <string name="permlab_flashlight">"kontrollere lommelykten"</string>
+    <string name="permdesc_flashlight">"Lar applikasjonen kontrollere lommelykten."</string>
+    <string name="permlab_hardware_test">"teste maskinvare"</string>
+    <string name="permdesc_hardware_test">"Lar applikasjonen styre diverse enheter med det formål å teste maskinvaren."</string>
+    <string name="permlab_callPhone">"ringe telefonnummer direkte"</string>
+    <string name="permdesc_callPhone">"Lar applikasjonen ringe telefonnummer uten inngripen fra brukeren. Ondsinnede applikasjoner kan forårsake uventede oppringinger på telefonregningen. Merk at dette ikke gir applikasjonen lov til å ringe nødnummer."</string>
+    <string name="permlab_callPrivileged">"ringe vilkårlige telefonnummer direkte"</string>
+    <string name="permdesc_callPrivileged">"Lar applikasjonen ringe hvilket som helst telefonnummer, inkludert nødnummer, uten inngripen fra brukeren. Ondsinnede applikasjoner kan forårsake unødvendige og ulovlige samtaler til nødtjenester."</string>
+    <string name="permlab_locationUpdates">"kontrollere varsling for plasseringsendring"</string>
+    <string name="permdesc_locationUpdates">"Lar applikasjonen slå av/på varsling om plasseringsendringer fra radioen. Ikke ment for vanlige applikasjoner."</string>
+    <string name="permlab_checkinProperties">"få tilgang til egenskaper for innsjekking"</string>
+    <string name="permdesc_checkinProperties">"Gir lese- og skrivetilgang til egenskaper lastet opp av innsjekkingstjenesten. Ikke ment for vanlige applikasjoner."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
+    <string name="permlab_modifyPhoneState">"endre telefontilstand"</string>
+    <string name="permdesc_modifyPhoneState">"Lar applikasjonen kontrollere telefonfunksjonaliteten i enheten. En applikasjon med denne rettigheten kan endre nettverk, slå telefonens radio av eller på og lignende uten noensinne å varsle brukeren."</string>
+    <string name="permlab_readPhoneState">"lese telefontilstand"</string>
+    <string name="permdesc_readPhoneState">"Lar applikasjonen få tilgang til telefonfunksjonaliteten i enheten. En applikasjon med denne rettigheten kan få vite enhetens telefonnummer, om en samtale pågår, nummeret samtalen er koblet til og lignende."</string>
+    <string name="permlab_wakeLock">"forhindre telefonen fra å sove"</string>
+    <string name="permdesc_wakeLock">"Lar applikasjonen forhindre telefonen fra å gå i hvilemodus."</string>
+    <string name="permlab_devicePower">"slå telefonen av eller på"</string>
+    <string name="permdesc_devicePower">"Lar applikasjonen skru telefonen av eller på."</string>
+    <string name="permlab_factoryTest">"kjøre i fabrikktestmodus"</string>
+    <string name="permdesc_factoryTest">"Kjøre som en lavnivås produsenttest, med full tilgang til telefonens maskinvare. Kun tilgjengelig når telefonen kjører i produsenttestmodus."</string>
+    <string name="permlab_setWallpaper">"endre bakgrunnsbilde"</string>
+    <string name="permdesc_setWallpaper">"Lar applikasjonen sette systemets bakgrunnsbilde."</string>
+    <string name="permlab_setWallpaperHints">"sette størrelseshint for bakgrunn"</string>
+    <string name="permdesc_setWallpaperHints">"Lar applikasjonen sette størrelseshint for systemets bakgrunnsbilde."</string>
+    <string name="permlab_masterClear">"nullstille systemet til fabrikkinnstillinger"</string>
+    <string name="permdesc_masterClear">"Lar applikasjonen nullstille systemet til fabrikkinnstillinger, noe som vil fjerne alle data, alt oppsett, og alle installerte applikasjoner."</string>
+    <string name="permlab_setTimeZone">"endre tidssone"</string>
+    <string name="permdesc_setTimeZone">"Lar applikasjonen endre telefonens tidssone."</string>
+    <string name="permlab_getAccounts">"oppdage kjente kontoer"</string>
+    <string name="permdesc_getAccounts">"Lar applikasjonen hente listen over kontoer telefonen kjenner til."</string>
+    <string name="permlab_accessNetworkState">"se nettverkstilstand"</string>
+    <string name="permdesc_accessNetworkState">"Lar applikasjonen se tilstanden til alle nettverk."</string>
+    <string name="permlab_createNetworkSockets">"full internett-tilgang"</string>
+    <string name="permdesc_createNetworkSockets">"Lar applikasjonen opprette vilkårlige nettverkstilkoblinger."</string>
+    <string name="permlab_writeApnSettings">"skrive APN-innstillinger"</string>
+    <string name="permdesc_writeApnSettings">"Lar applikasjonen to endre APN-innstillinger slik som mellomtjener eller port for hvilket som helst aksesspunkt."</string>
+    <string name="permlab_changeNetworkState">"endre nettverkskonnektivitet"</string>
+    <string name="permdesc_changeNetworkState">"Lar applikasjonen endre tilstanden til nettverkskonnektivitet."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
+    <string name="permlab_accessWifiState">"se tilstand for trådløse nettverk"</string>
+    <string name="permdesc_accessWifiState">"Lar applikasjonen få se informasjon om tilstanden til de trådløse nettene."</string>
+    <string name="permlab_changeWifiState">"endre tilstand for trådløse nettverk"</string>
+    <string name="permdesc_changeWifiState">"Lar applikasjonen koble til og fra trådløse aksesspunkt, og å gjøre endringer i konfigurerte trådløse nettverk."</string>
+    <string name="permlab_bluetoothAdmin">"Bluetooth-administrasjon"</string>
+    <string name="permdesc_bluetoothAdmin">"Lar applikasjonen konfigurere den lokale Bluetooth-telefonen, og å oppdage og pare med andre enheter."</string>
+    <string name="permlab_bluetooth">"opprette Bluetooth-tilkoblinger"</string>
+    <string name="permdesc_bluetooth">"Lar applikasjonen se konfigurasjonen til den lokale Bluetooth-telefonen, og å opprette og godta tilkoblinger med parede enheter."</string>
+    <string name="permlab_disableKeyguard">"slå av tastaturlås"</string>
+    <string name="permdesc_disableKeyguard">"Lar applikasjonen slå av tastaturlåsen og enhver tilknyttet passordsikkerhet. Et legitimt eksempel på dette er at telefonen slår av tastaturlåsen når den mottar et innkommende anrop, og så slår den på igjen når samtalen er over."</string>
+    <string name="permlab_readSyncSettings">"lese synkroniseringsinnstillinger"</string>
+    <string name="permdesc_readSyncSettings">"Lar applikasjonen lese synkroniseringsinnstillingene, som for eksempel om kontakter blir synkronisert."</string>
+    <string name="permlab_writeSyncSettings">"skrive synkroniseringsinnstillinger"</string>
+    <string name="permdesc_writeSyncSettings">"Lar applikasjonen to endre på synkroniseringsinnstillingene, som for eksempel om kontakter blir synkronisert."</string>
+    <string name="permlab_readSyncStats">"lese synkroniseringsstatistikk"</string>
+    <string name="permdesc_readSyncStats">"Lar applikasjonen lese synkroniseringsstatistikk, som for eksempel historien over alle synkroniseringer utført."</string>
+    <string name="permlab_subscribedFeedsRead">"lese abonnement på nyhetskilder"</string>
+    <string name="permdesc_subscribedFeedsRead">"Lar applikasjonen hente detaljer om hvilke nyhetskilder som synkroniseres."</string>
+    <string name="permlab_subscribedFeedsWrite">"endre abonnement på nyhetskilder"</string>
+    <string name="permdesc_subscribedFeedsWrite">"Lar applikasjonen redigere hvilke nyhetskilder som synkroniseres. Dette kan gi en ondsinnet applikasjon tilgang til å endre hvilke nyhetskilder som synkroniseres."</string>
+    <!-- no translation found for permlab_readDictionary (432535716804748781) -->
+    <skip />
+    <!-- no translation found for permdesc_readDictionary (1082972603576360690) -->
+    <skip />
+    <!-- no translation found for permlab_writeDictionary (6703109511836343341) -->
+    <skip />
+    <!-- no translation found for permdesc_writeDictionary (2241256206524082880) -->
+    <skip />
+  <string-array name="phoneTypes">
+    <item>"Hjemme"</item>
+    <item>"Mobil"</item>
+    <item>"Arbeid"</item>
+    <item>"Faks arbeid"</item>
+    <item>"Faks hjemme"</item>
+    <item>"Personsøker"</item>
+    <item>"Annen"</item>
+    <item>"Egendefinert…"</item>
+  </string-array>
+  <string-array name="emailAddressTypes">
+    <item>"Hjemme"</item>
+    <item>"Arbeid"</item>
+    <item>"Annen"</item>
+    <item>"Egendefinert…"</item>
+  </string-array>
+  <string-array name="postalAddressTypes">
+    <item>"Hjemme"</item>
+    <item>"Arbeid"</item>
+    <item>"Annen"</item>
+    <item>"Egendefinert…"</item>
+  </string-array>
+  <string-array name="imAddressTypes">
+    <item>"Hjemme"</item>
+    <item>"Arbeid"</item>
+    <item>"Annen"</item>
+    <item>"Egendefinert…"</item>
+  </string-array>
+  <string-array name="organizationTypes">
+    <item>"Arbeid"</item>
+    <item>"Annen"</item>
+    <item>"Egendefinert…"</item>
+  </string-array>
+  <string-array name="imProtocols">
+    <item>"AIM"</item>
+    <item>"Windows Live"</item>
+    <item>"Yahoo"</item>
+    <item>"Skype"</item>
+    <item>"QQ"</item>
+    <item>"Google Talk"</item>
+    <item>"ICQ"</item>
+    <item>"Jabber"</item>
+  </string-array>
+    <string name="keyguard_password_enter_pin_code">"Skriv inn PIN-kode:"</string>
+    <string name="keyguard_password_wrong_pin_code">"Gal PIN-kode!"</string>
+    <string name="keyguard_label_text">"For å låse opp, trykk menuknappen fulgt av 0."</string>
+    <string name="emergency_call_dialog_number_for_display">"Nødnummer"</string>
+    <string name="lockscreen_carrier_default">"(Ingen operatør)"</string>
+    <string name="lockscreen_screen_locked">"Skjermen er låst"</string>
+    <string name="lockscreen_instructions_when_pattern_enabled">"Trykk på menyknappen for å låse opp eller ringe et nødnummer."</string>
+    <string name="lockscreen_instructions_when_pattern_disabled">"Trykk på menyknappen for å låse opp."</string>
+    <string name="lockscreen_pattern_instructions">"Tegn mønster for å låse opp"</string>
+    <string name="lockscreen_emergency_call">"Nødanrop"</string>
+    <string name="lockscreen_pattern_correct">"Riktig!"</string>
+    <string name="lockscreen_pattern_wrong">"Beklager, prøv igjen:"</string>
+    <string name="lockscreen_plugged_in">"Lader (<xliff:g id="NUMBER">%d%%</xliff:g>)"</string>
+    <string name="lockscreen_low_battery">"Koble til en batterilader."</string>
+    <string name="lockscreen_missing_sim_message_short">"Mangler SIM-kort."</string>
+    <string name="lockscreen_missing_sim_message">"Ikke noe SIM-kort i telefonen."</string>
+    <string name="lockscreen_missing_sim_instructions">"Sett inn et SIM-kort."</string>
+    <string name="lockscreen_network_locked_message">"Nettverk ikke tillatt"</string>
+    <string name="lockscreen_sim_puk_locked_message">"SIM-kortet er PUK-låst."</string>
+    <string name="lockscreen_sim_puk_locked_instructions">"Vennligst ring kundeservice."</string>
+    <string name="lockscreen_sim_locked_message">"SIM-kortet er låst."</string>
+    <string name="lockscreen_sim_unlock_progress_dialog_message">"Låser opp SIM-kort…"</string>
+    <string name="lockscreen_too_many_failed_attempts_dialog_message">"You have incorrectly drawn your unlock pattern <xliff:g id="NUMBER_0">%d</xliff:g> times. "\n\n"Please try again in <xliff:g id="NUMBER_1">%d</xliff:g> seconds."</string>
+    <string name="lockscreen_failed_attempts_almost_glogin">"You have incorrectly drawn your unlock pattern <xliff:g id="NUMBER_0">%d</xliff:g> times. After <xliff:g id="NUMBER_1">%d</xliff:g> more unsuccessful attempts, you will be asked to unlock your phone using your Google sign-in."\n\n" Please try again in <xliff:g id="NUMBER_2">%d</xliff:g> seconds."</string>
+    <string name="lockscreen_too_many_failed_attempts_countdown">"Prøv igjen om <xliff:g id="NUMBER">%d</xliff:g> sekunder."</string>
+    <string name="lockscreen_forgot_pattern_button_text">"Glemt mønsteret?"</string>
+    <string name="lockscreen_glogin_too_many_attempts">"Too many pattern attempts!"</string>
+    <string name="lockscreen_glogin_instructions">"To unlock,"\n"sign in with your Google account"</string>
+    <string name="lockscreen_glogin_username_hint">"Username (email)"</string>
+    <string name="lockscreen_glogin_password_hint">"Password"</string>
+    <string name="lockscreen_glogin_submit_button">"Sign in"</string>
+    <string name="lockscreen_glogin_invalid_input">"Invalid username or password."</string>
+    <string name="status_bar_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">AA</xliff:g>"</string>
+    <string name="hour_minute_ampm">"<xliff:g id="HOUR">%-l</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g><xliff:g id="AMPM">%P</xliff:g>"</string>
+    <string name="hour_minute_cap_ampm">"<xliff:g id="HOUR">%-l</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g><xliff:g id="AMPM">%p</xliff:g>"</string>
+    <!-- no translation found for hour_ampm (7618670480400517084) -->
+    <skip />
+    <!-- no translation found for hour_cap_ampm (5117798389811605468) -->
+    <skip />
+    <string name="status_bar_clear_all_button">"Fjern varslinger"</string>
+    <string name="status_bar_no_notifications_title">"Ingen varslinger"</string>
+    <string name="status_bar_ongoing_events_title">"Aktiviteter"</string>
+    <string name="status_bar_latest_events_title">"Varslinger"</string>
+    <!-- no translation found for battery_status_text_percent_format (8818848472818880005) -->
+    <skip />
+    <string name="battery_status_charging">"Lader…"</string>
+    <string name="battery_low_title">"Koble til en lader"</string>
+    <string name="battery_low_subtitle">"Batteriet er nesten tomt:"</string>
+    <string name="battery_low_percent_format">"mindre enn <xliff:g id="NUMBER">%d%%</xliff:g> igjen."</string>
+    <string name="factorytest_failed">"Factory test failed"</string>
+    <string name="factorytest_not_system">"The FACTORY_TEST action is only supported for packages installed in /system/app."</string>
+    <string name="factorytest_no_action">"No package was found that provides the FACTORY_TEST action."</string>
+    <string name="factorytest_reboot">"Reboot"</string>
+    <!-- no translation found for js_dialog_title (8143918455087008109) -->
+    <skip />
+    <!-- no translation found for js_dialog_title_default (6961903213729667573) -->
+    <skip />
+    <!-- no translation found for js_dialog_before_unload (1901675448179653089) -->
+    <skip />
+    <string name="save_password_label">"Bekreft"</string>
+    <string name="save_password_message">"Ønsker du at nettleseren skal huske dette passordet?"</string>
+    <string name="save_password_notnow">"Ikke nå"</string>
+    <string name="save_password_remember">"Husk"</string>
+    <string name="save_password_never">"Aldri"</string>
+    <string name="open_permission_deny">"Du har ikke de nødvendige rettighetene til å åpne denne siden."</string>
+    <string name="text_copied">"Kopierte tekst til utklippstavlen."</string>
+    <string name="more_item_label">"Mer"</string>
+    <string name="prepend_shortcut_label">"menyknapp+"</string>
+    <string name="menu_space_shortcut_label">"mellomrom"</string>
+    <string name="menu_enter_shortcut_label">"enter"</string>
+    <string name="menu_delete_shortcut_label">"slett"</string>
+    <string name="search_go">"Søk"</string>
+    <string name="today">"I dag"</string>
+    <string name="yesterday">"I går"</string>
+    <string name="tomorrow">"I morgen"</string>
+    <string name="oneMonthDurationPast">"For en måned siden"</string>
+    <string name="beforeOneMonthDurationPast">"For over en måned siden"</string>
+  <plurals name="num_seconds_ago">
+    <item quantity="one">"for et sekund siden"</item>
+    <item quantity="other">"for <xliff:g id="COUNT">%d</xliff:g> sekunder siden"</item>
+  </plurals>
+  <plurals name="num_minutes_ago">
+    <item quantity="one">"for et minutt siden"</item>
+    <item quantity="other">"for <xliff:g id="COUNT">%d</xliff:g> minutter siden"</item>
+  </plurals>
+  <plurals name="num_hours_ago">
+    <item quantity="one">"for en time siden"</item>
+    <item quantity="other">"for <xliff:g id="COUNT">%d</xliff:g> timer siden"</item>
+  </plurals>
+  <plurals name="num_days_ago">
+    <item quantity="one">"i går"</item>
+    <item quantity="other">"for <xliff:g id="COUNT">%d</xliff:g> dager siden"</item>
+  </plurals>
+  <plurals name="in_num_seconds">
+    <item quantity="one">"om et sekund"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> sekunder"</item>
+  </plurals>
+  <plurals name="in_num_minutes">
+    <item quantity="one">"om et minutt"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> minutter"</item>
+  </plurals>
+  <plurals name="in_num_hours">
+    <item quantity="one">"om et minutt"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> timer"</item>
+  </plurals>
+  <plurals name="in_num_days">
+    <item quantity="one">"i morgen"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> dager"</item>
+  </plurals>
+  <plurals name="abbrev_num_seconds_ago">
+    <item quantity="one">"1 sek siden"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g> sek siden"</item>
+  </plurals>
+  <plurals name="abbrev_num_minutes_ago">
+    <item quantity="one">"1 min siden"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g> min siden"</item>
+  </plurals>
+  <plurals name="abbrev_num_hours_ago">
+    <item quantity="one">"1 t siden"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g> t siden"</item>
+  </plurals>
+  <plurals name="abbrev_num_days_ago">
+    <item quantity="one">"i går"</item>
+    <item quantity="other">"<xliff:g id="COUNT">%d</xliff:g> d siden"</item>
+  </plurals>
+  <plurals name="abbrev_in_num_seconds">
+    <item quantity="one">"om 1 sek"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> sek"</item>
+  </plurals>
+  <plurals name="abbrev_in_num_minutes">
+    <item quantity="one">"om 1 min"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> min"</item>
+  </plurals>
+  <plurals name="abbrev_in_num_hours">
+    <item quantity="one">"om 1 t"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> t"</item>
+  </plurals>
+  <plurals name="abbrev_in_num_days">
+    <item quantity="one">"i morgen"</item>
+    <item quantity="other">"om <xliff:g id="COUNT">%d</xliff:g> d"</item>
+  </plurals>
+    <string name="preposition_for_date">"%s"</string>
+    <string name="preposition_for_time">"%s"</string>
+    <string name="preposition_for_year">"%s"</string>
+    <string name="day">"dag"</string>
+    <string name="days">"dager"</string>
+    <string name="hour">"time"</string>
+    <string name="hours">"timer"</string>
+    <string name="minute">"min"</string>
+    <string name="minutes">"min"</string>
+    <string name="second">"s"</string>
+    <string name="seconds">"s"</string>
+    <string name="week">"uke"</string>
+    <string name="weeks">"uker"</string>
+    <string name="year">"år"</string>
+    <string name="years">"år"</string>
+    <string name="sunday">"søndag"</string>
+    <string name="monday">"mandag"</string>
+    <string name="tuesday">"tirsdag"</string>
+    <string name="wednesday">"onsdag"</string>
+    <string name="thursday">"torsdag"</string>
+    <string name="friday">"fredag"</string>
+    <string name="saturday">"lørdag"</string>
+    <string name="every_weekday">"Hverdager (man–fre)"</string>
+    <string name="daily">"Hver dag"</string>
+    <string name="weekly">"Hver <xliff:g id="DAY">%s</xliff:g>"</string>
+    <string name="monthly">"En gang i måneden"</string>
+    <string name="yearly">"En gang i året"</string>
+    <string name="VideoView_error_title">"Cannot play video"</string>
+    <string name="VideoView_error_text_unknown">"Sorry, this video cannot be played."</string>
+    <string name="VideoView_error_button">"OK"</string>
+    <string name="am">"AM"</string>
+    <string name="pm">"PM"</string>
+    <string name="numeric_date">"<xliff:g id="YEAR">%Y</xliff:g>-<xliff:g id="MONTH">%m</xliff:g>-<xliff:g id="DAY">%d</xliff:g>"</string>
+    <string name="wday1_date1_time1_wday2_date2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DATE1">%2$s</xliff:g> <xliff:g id="TIME1">%3$s</xliff:g> – <xliff:g id="WEEKDAY2">%4$s</xliff:g> <xliff:g id="DATE2">%5$s</xliff:g> <xliff:g id="TIME2">%6$s</xliff:g>"</string>
+    <string name="wday1_date1_wday2_date2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DATE1">%2$s</xliff:g> – <xliff:g id="WEEKDAY2">%4$s</xliff:g> <xliff:g id="DATE2">%5$s</xliff:g>"</string>
+    <string name="date1_time1_date2_time2">"<xliff:g id="DATE1">%2$s</xliff:g> <xliff:g id="TIME1">%3$s</xliff:g> – <xliff:g id="DATE2">%5$s</xliff:g> <xliff:g id="TIME2">%6$s</xliff:g>"</string>
+    <string name="date1_date2">"<xliff:g id="DATE1">%2$s</xliff:g> – <xliff:g id="DATE2">%5$s</xliff:g>"</string>
+    <string name="time1_time2">"<xliff:g id="TIME1">%1$s</xliff:g> – <xliff:g id="TIME2">%2$s</xliff:g>"</string>
+    <string name="time_wday_date">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g> <xliff:g id="DATE">%3$s</xliff:g>"</string>
+    <string name="wday_date">"<xliff:g id="WEEKDAY">%2$s</xliff:g> <xliff:g id="DATE">%3$s</xliff:g>"</string>
+    <string name="time_date">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="DATE">%3$s</xliff:g>"</string>
+    <!-- no translation found for date_time (6104442718633642836) -->
+    <skip />
+    <!-- no translation found for relative_time (1818557177829411417) -->
+    <skip />
+    <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>'., '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>'. '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="noon">"middag"</string>
+    <string name="Noon">"Middag"</string>
+    <string name="midnight">"midnatt"</string>
+    <string name="Midnight">"Midnatt"</string>
+    <!-- no translation found for month_day (5565829181417740906) -->
+    <skip />
+    <!-- no translation found for month (7026169712234774086) -->
+    <skip />
+    <string name="month_day_year">"<xliff:g id="DAY">%-d</xliff:g>. <xliff:g id="MONTH">%B</xliff:g> <xliff:g id="YEAR">%Y</xliff:g>"</string>
+    <!-- no translation found for month_year (9219019380312413367) -->
+    <skip />
+    <string name="time_of_day">"<xliff:g id="HOUR">%H</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g>:<xliff:g id="SECOND">%S</xliff:g>"</string>
+    <string name="date_and_time">"<xliff:g id="HOUR">%H</xliff:g>:<xliff:g id="MINUTE">%M</xliff:g>:<xliff:g id="SECOND">%S</xliff:g> <xliff:g id="DAY">%-d</xliff:g>. <xliff:g id="MONTH">%B</xliff:g> <xliff:g id="YEAR">%Y</xliff:g>"</string>
+    <string name="same_year_md1_md2">"<xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="DAY1">%3$s</xliff:g> – <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="DAY2">%8$s</xliff:g>"</string>
+    <string name="same_year_wday1_md1_wday2_md2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g>"</string>
+    <string name="same_year_mdy1_mdy2">"<xliff:g id="DAY1">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="YEAR">%9$s</xliff:g>"</string>
+    <!-- no translation found for same_year_wday1_mdy1_wday2_mdy2 (1345612987720788874) -->
+    <skip />
+    <string name="same_year_md1_time1_md2_time2">"<xliff:g id="DAY1">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_year_wday1_md1_time1_wday2_md2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <!-- no translation found for same_year_mdy1_time1_mdy2_time2 (2959466512848524124) -->
+    <skip />
+    <!-- no translation found for same_year_wday1_mdy1_time1_wday2_mdy2_time2 (5129735426508861428) -->
+    <skip />
+    <string name="numeric_md1_md2">"<xliff:g id="DAY1">%3$s</xliff:g>.<xliff:g id="MONTH1">%2$s</xliff:g>. – <xliff:g id="DAY2">%8$s</xliff:g>.<xliff:g id="MONTH2">%7$s</xliff:g>."</string>
+    <string name="numeric_wday1_md1_wday2_md2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>.<xliff:g id="MONTH1">%2$s</xliff:g>. – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>.<xliff:g id="MONTH2">%7$s</xliff:g>."</string>
+    <!-- no translation found for numeric_mdy1_mdy2 (3933951218078638018) -->
+    <skip />
+    <string name="numeric_wday1_mdy1_wday2_mdy2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>.<xliff:g id="MONTH1">%2$s</xliff:g>.<xliff:g id="YEAR1">%4$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>.<xliff:g id="MONTH2">%7$s</xliff:g>.<xliff:g id="YEAR2">%9$s</xliff:g>"</string>
+    <string name="numeric_md1_time1_md2_time2">"<xliff:g id="DAY1">%3$s</xliff:g>.<xliff:g id="MONTH1">%2$s</xliff:g>. <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>.<xliff:g id="MONTH2">%7$s</xliff:g>. <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="numeric_wday1_md1_time1_wday2_md2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>.<xliff:g id="MONTH1">%2$s</xliff:g>. <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>.<xliff:g id="MONTH2">%7$s</xliff:g>. <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="numeric_mdy1_time1_mdy2_time2">"<xliff:g id="DAY1">%3$s</xliff:g>.<xliff:g id="MONTH1">%2$s</xliff:g>.<xliff:g id="YEAR1">%4$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>.<xliff:g id="MONTH2">%7$s</xliff:g>.<xliff:g id="YEAR2">%9$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="numeric_wday1_mdy1_time1_wday2_mdy2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>.<xliff:g id="MONTH1">%2$s</xliff:g>.<xliff:g id="YEAR1">%4$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>.<xliff:g id="MONTH2">%7$s</xliff:g>.<xliff:g id="YEAR2">%9$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_md1_md2">"<xliff:g id="DAY1">%3$s</xliff:g>.–<xliff:g id="DAY2">%8$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g>"</string>
+    <string name="same_month_wday1_md1_wday2_md2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g>"</string>
+    <string name="same_month_mdy1_mdy2">"<xliff:g id="DAY1">%3$s</xliff:g>.–<xliff:g id="DAY2">%8$s</xliff:g> <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="YEAR2">%9$s</xliff:g>"</string>
+    <string name="same_month_wday1_mdy1_wday2_mdy2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="YEAR1">%4$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="YEAR2">%9$s</xliff:g>"</string>
+    <string name="same_month_md1_time1_md2_time2">"<xliff:g id="DAY1">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_wday1_md1_time1_wday2_md2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_mdy1_time1_mdy2_time2">"<xliff:g id="DAY1">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="YEAR1">%4$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="DAY2">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="YEAR2">%9$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="same_month_wday1_mdy1_time1_wday2_mdy2_time2">"<xliff:g id="WEEKDAY1">%1$s</xliff:g> <xliff:g id="DAY1_0">%3$s</xliff:g>. <xliff:g id="MONTH1">%2$s</xliff:g> <xliff:g id="YEAR1">%4$s</xliff:g> <xliff:g id="TIME1">%5$s</xliff:g> – <xliff:g id="WEEKDAY2">%6$s</xliff:g> <xliff:g id="DAY2_1">%8$s</xliff:g>. <xliff:g id="MONTH2">%7$s</xliff:g> <xliff:g id="YEAR2">%9$s</xliff:g> <xliff:g id="TIME2">%10$s</xliff:g>"</string>
+    <string name="abbrev_month_day_year">"<xliff:g id="DAY">%-d</xliff:g>. <xliff:g id="MONTH">%b</xliff:g> <xliff:g id="YEAR">%Y</xliff:g>"</string>
+    <!-- no translation found for abbrev_month_year (3856424847226891943) -->
+    <skip />
+    <!-- no translation found for abbrev_month_day (5028815883653985933) -->
+    <skip />
+    <!-- no translation found for abbrev_month (3131032032850777433) -->
+    <skip />
+    <string name="day_of_week_long_sunday">"søndag"</string>
+    <string name="day_of_week_long_monday">"mandag"</string>
+    <string name="day_of_week_long_tuesday">"tirsdag"</string>
+    <string name="day_of_week_long_wednesday">"onsdag"</string>
+    <string name="day_of_week_long_thursday">"torsdag"</string>
+    <string name="day_of_week_long_friday">"fredag"</string>
+    <string name="day_of_week_long_saturday">"lørdag"</string>
+    <string name="day_of_week_medium_sunday">"søn"</string>
+    <string name="day_of_week_medium_monday">"man"</string>
+    <string name="day_of_week_medium_tuesday">"tir"</string>
+    <string name="day_of_week_medium_wednesday">"ons"</string>
+    <string name="day_of_week_medium_thursday">"tor"</string>
+    <string name="day_of_week_medium_friday">"fre"</string>
+    <string name="day_of_week_medium_saturday">"lør"</string>
+    <string name="day_of_week_short_sunday">"sø"</string>
+    <string name="day_of_week_short_monday">"ma"</string>
+    <string name="day_of_week_short_tuesday">"ti"</string>
+    <string name="day_of_week_short_wednesday">"on"</string>
+    <string name="day_of_week_short_thursday">"to"</string>
+    <string name="day_of_week_short_friday">"fr"</string>
+    <string name="day_of_week_short_saturday">"lø"</string>
+    <string name="day_of_week_shorter_sunday">"S"</string>
+    <string name="day_of_week_shorter_monday">"M"</string>
+    <string name="day_of_week_shorter_tuesday">"Ti"</string>
+    <string name="day_of_week_shorter_wednesday">"O"</string>
+    <string name="day_of_week_shorter_thursday">"To"</string>
+    <string name="day_of_week_shorter_friday">"F"</string>
+    <string name="day_of_week_shorter_saturday">"L"</string>
+    <string name="day_of_week_shortest_sunday">"S"</string>
+    <string name="day_of_week_shortest_monday">"M"</string>
+    <string name="day_of_week_shortest_tuesday">"T"</string>
+    <string name="day_of_week_shortest_wednesday">"O"</string>
+    <string name="day_of_week_shortest_thursday">"T"</string>
+    <string name="day_of_week_shortest_friday">"F"</string>
+    <string name="day_of_week_shortest_saturday">"L"</string>
+    <string name="month_long_january">"januar"</string>
+    <string name="month_long_february">"februar"</string>
+    <string name="month_long_march">"mars"</string>
+    <string name="month_long_april">"april"</string>
+    <string name="month_long_may">"mai"</string>
+    <string name="month_long_june">"juni"</string>
+    <string name="month_long_july">"juli"</string>
+    <string name="month_long_august">"august"</string>
+    <string name="month_long_september">"september"</string>
+    <string name="month_long_october">"oktober"</string>
+    <string name="month_long_november">"november"</string>
+    <string name="month_long_december">"desember"</string>
+    <string name="month_medium_january">"jan"</string>
+    <string name="month_medium_february">"feb"</string>
+    <string name="month_medium_march">"mar"</string>
+    <string name="month_medium_april">"apr"</string>
+    <string name="month_medium_may">"mai"</string>
+    <string name="month_medium_june">"jun"</string>
+    <string name="month_medium_july">"jul"</string>
+    <string name="month_medium_august">"aug"</string>
+    <string name="month_medium_september">"sep"</string>
+    <string name="month_medium_october">"okt"</string>
+    <string name="month_medium_november">"nov"</string>
+    <string name="month_medium_december">"des"</string>
+    <string name="month_shortest_january">"J"</string>
+    <string name="month_shortest_february">"F"</string>
+    <string name="month_shortest_march">"M"</string>
+    <string name="month_shortest_april">"A"</string>
+    <string name="month_shortest_may">"M"</string>
+    <string name="month_shortest_june">"J"</string>
+    <string name="month_shortest_july">"J"</string>
+    <string name="month_shortest_august">"A"</string>
+    <string name="month_shortest_september">"S"</string>
+    <string name="month_shortest_october">"O"</string>
+    <string name="month_shortest_november">"N"</string>
+    <string name="month_shortest_december">"D"</string>
+    <string name="elapsed_time_short_format_mm_ss">"<xliff:g id="MINUTES">%1$02d</xliff:g>:<xliff:g id="SECONDS">%2$02d</xliff:g>"</string>
+    <string name="elapsed_time_short_format_h_mm_ss">"<xliff:g id="HOURS">%1$d</xliff:g>:<xliff:g id="MINUTES">%2$02d</xliff:g>:<xliff:g id="SECONDS">%3$02d</xliff:g>"</string>
+    <string name="selectAll">"Merk alt"</string>
+    <string name="selectText">"Merk tekst"</string>
+    <string name="stopSelectingText">"Slutt å merke tekst"</string>
+    <string name="cut">"Klipp ut"</string>
+    <string name="cutAll">"Klipp ut alt"</string>
+    <string name="copy">"Kopier"</string>
+    <string name="copyAll">"Koiper alt"</string>
+    <string name="paste">"Lim inn"</string>
+    <string name="copyUrl">"Kopier URL"</string>
+    <string name="inputMethod">"Inndatametode"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
+    <string name="editTextMenuTitle">"Rediger tekst"</string>
+    <string name="low_internal_storage_view_title">"Lite plass"</string>
+    <string name="low_internal_storage_view_text">"Det begynner å bli lite lagringsplass på telefonen."</string>
+    <string name="ok">"OK"</string>
+    <string name="cancel">"Avbryt"</string>
+    <string name="yes">"OK"</string>
+    <string name="no">"Avbryt"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
+    <string name="capital_on">"På"</string>
+    <string name="capital_off">"Av"</string>
+    <string name="whichApplication">"Complete action using"</string>
+    <string name="alwaysUse">"Use by default for this action."</string>
+    <string name="clearDefaultHintMsg">"Clear default in Home Settings &gt; Applications &gt; Manage applications."</string>
+    <string name="chooseActivity">"Select an action"</string>
+    <string name="noApplications">"No applications can perform this action."</string>
+    <string name="aerr_title">"Sorry!"</string>
+    <string name="aerr_application">"The application <xliff:g id="APPLICATION">%1$s</xliff:g> (process <xliff:g id="PROCESS">%2$s</xliff:g>) has stopped unexpectedly. Please try again."</string>
+    <string name="aerr_process">"The process <xliff:g id="PROCESS">%1$s</xliff:g> has stopped unexpectedly. Please try again."</string>
+    <string name="anr_title">"Sorry!"</string>
+    <string name="anr_activity_application">"Activity <xliff:g id="ACTIVITY">%1$s</xliff:g> (in application <xliff:g id="APPLICATION">%2$s</xliff:g>) is not responding."</string>
+    <string name="anr_activity_process">"Activity <xliff:g id="ACTIVITY">%1$s</xliff:g> (in process <xliff:g id="PROCESS">%2$s</xliff:g>) is not responding."</string>
+    <string name="anr_application_process">"Application <xliff:g id="APPLICATION">%1$s</xliff:g> (in process <xliff:g id="PROCESS">%2$s</xliff:g>) is not responding."</string>
+    <string name="anr_process">"Process <xliff:g id="PROCESS">%1$s</xliff:g> is not responding."</string>
+    <string name="force_close">"Force close"</string>
+    <string name="wait">"Wait"</string>
+    <string name="debug">"Debug"</string>
+    <string name="sendText">"Select an action for text"</string>
+    <string name="volume_ringtone">"Ringetonevolum"</string>
+    <string name="volume_music">"Medievolum"</string>
+    <string name="volume_music_hint_playing_through_bluetooth">"Spiller over Bluetooth"</string>
+    <string name="volume_call">"Samtalevolum"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
+    <string name="volume_alarm">"Alarmvolum"</string>
+    <string name="volume_notification">"Varslingsvolum"</string>
+    <string name="volume_unknown">"Volum"</string>
+    <string name="ringtone_default">"Standard ringetone"</string>
+    <string name="ringtone_default_with_actual">"Standard ringetone (<xliff:g id="ACTUAL_RINGTONE">%1$s</xliff:g>)"</string>
+    <string name="ringtone_silent">"Stille"</string>
+    <string name="ringtone_picker_title">"Ringetoner"</string>
+    <string name="ringtone_unknown">"Ukjent ringetone"</string>
+  <plurals name="wifi_available">
+    <item quantity="one">"Trådløsnett i nærheten"</item>
+    <item quantity="other">"Trådløsnett i nærheten"</item>
+  </plurals>
+  <plurals name="wifi_available_detailed">
+    <item quantity="one">"Åpent trådløsnett i nærheten"</item>
+    <item quantity="other">"Åpne trådløsnett i nærheten"</item>
+  </plurals>
+    <string name="select_character">"Sett inn tegn"</string>
+    <string name="sms_control_default_app_name">"Ukjent applikasjon"</string>
+    <string name="sms_control_title">"Sending SMS messages"</string>
+    <string name="sms_control_message">"A large number of SMS messages are being sent. Select \\\"OK\\\" to continue, or \\\"Cancel\\\" to stop sending."</string>
+    <string name="sms_control_yes">"OK"</string>
+    <string name="sms_control_no">"Avbryt"</string>
+    <string name="date_time_set">"Lagre"</string>
+    <string name="default_permission_group">"Standard"</string>
+    <string name="no_permissions">"Trenger ingen rettigheter"</string>
+    <string name="perms_hide"><b>"Skjul"</b></string>
+    <string name="perms_show_all"><b>"Vis alle"</b></string>
+    <string name="googlewebcontenthelper_loading">"Laster inn…"</string>
+    <string name="usb_storage_title">"USB koblet til"</string>
+    <string name="usb_storage_message">"Du har koblet telefonen til en datamaskin via USB. Velg \\\"Monter\\\" dersom du ønsker å kopiere filer mellom datmaskinen og minnekortet i telefonen."</string>
+    <string name="usb_storage_button_mount">"Monter"</string>
+    <string name="usb_storage_button_unmount">"Ikke monter"</string>
+    <string name="usb_storage_error_message">"Det oppsto et problem med å bruke minnekortet ditt for USB-lagring."</string>
+    <string name="usb_storage_notification_title">"USB tilkoblet"</string>
+    <string name="usb_storage_notification_message">"Velg om du ønsker å kopiere filer til/fra en datamaskin."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
+    <string name="select_input_method">"Velg inndatametode"</string>
+    <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ"</string>
+    <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ"</string>
+    <!-- unknown quoting pattern: original -1, translation 1 -->
+    <string name="candidates_style">"TAG_FONT"<u>"kandidater"</u>"u&amp;gt;CLOSE_FONT"</string>
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
+</resources>
diff --git a/core/res/res/values-nl-rNL/strings.xml b/core/res/res/values-nl-rNL/strings.xml
deleted file mode 100644
index 1dc48bb..0000000
--- a/core/res/res/values-nl-rNL/strings.xml
+++ /dev/null
@@ -1,905 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="byteShort">"b"</string>
-    <string name="kilobyteShort">"Kb"</string>
-    <string name="megabyteShort">"Mb"</string>
-    <string name="gigabyteShort">"Gb"</string>
-    <string name="terabyteShort">"Tb"</string>
-    <string name="petabyteShort">"Pb"</string>
-    <string name="untitled">"&lt;Naamloos&gt;"</string>
-    <string name="ellipsis">"…"</string>
-    <string name="emptyPhoneNumber">"(geen telefoonnummer)"</string>
-    <string name="unknownName">"(onbekend)"</string>
-    <string name="defaultVoiceMailAlphaTag">"Voicemail"</string>
-    <string name="defaultMsisdnAlphaTag">"Msisdn1"</string>
-    <string name="mmiError">"Netwerkfout of onjuiste MMI-code."</string>
-    <string name="serviceEnabled">"Service ingeschakeld"</string>
-    <string name="serviceEnabledFor">"Service ingeschakeld voor:"</string>
-    <string name="serviceDisabled">"Service uitgeschakeld"</string>
-    <string name="serviceRegistered">"Registratie gelukt"</string>
-    <string name="serviceErased">"Wissen gelukt"</string>
-    <string name="passwordIncorrect">"Ongeldig wachtwoord"</string>
-    <string name="mmiComplete">"MMI voltooid"</string>
-    <!-- no translation found for badPin (5103184589972647739) -->
-    <skip />
-    <!-- no translation found for badPuk (2200634943393540609) -->
-    <skip />
-    <!-- no translation found for mismatchPin (5055729703806180857) -->
-    <skip />
-    <!-- no translation found for invalidPin (6201854814319326475) -->
-    <skip />
-    <!-- no translation found for needPuk (4788728144863892764) -->
-    <skip />
-    <!-- no translation found for needPuk2 (7056908944942451033) -->
-    <skip />
-    <string name="ClipMmi">"Nummerweergave inkomend gesprek"</string>
-    <string name="ClirMmi">"Nummerweergave uitgaand gesprek"</string>
-    <string name="CfMmi">"Oproep doorschakelen"</string>
-    <string name="CwMmi">"Gesprek in wachtstand"</string>
-    <string name="BaMmi">"Oproep blokkeren"</string>
-    <string name="PwdMmi">"Wachtwoord wijzigen"</string>
-    <string name="PinMmi">"Pincode wijzigen"</string>
-    <string name="CLIRDefaultOnNextCallOn">"ID-beperkingsstandaarden op beperkt. Volgend gesprek: beperkt"</string>
-    <string name="CLIRDefaultOnNextCallOff">"ID-beperkingsstandaarden op beperkt. Volgend gesprek: niet beperkt"</string>
-    <string name="CLIRDefaultOffNextCallOn">"ID-beperkingsstandaarden op onbeperkt. Volgend gesprek: beperkt"</string>
-    <string name="CLIRDefaultOffNextCallOff">"ID-beperkingsstandaarden op onbeperkt. Volgend gesprek: niet beperkt"</string>
-    <string name="serviceNotProvisioned">"Service niet opgenomen."</string>
-    <string name="CLIRPermanent">"ID-beperking ingesteld op permanente modus."</string>
-    <string name="serviceClassVoice">"Spraak"</string>
-    <string name="serviceClassData">"Gegevens"</string>
-    <string name="serviceClassFAX">"FAX"</string>
-    <string name="serviceClassSMS">"SMS"</string>
-    <string name="serviceClassDataAsync">"Async"</string>
-    <string name="serviceClassDataSync">"Sync"</string>
-    <string name="serviceClassPacket">"Pakket"</string>
-    <string name="serviceClassPAD">"PAD"</string>
-    <string name="cfTemplateNotForwarded">"{0}: Niet doorgestuurd"</string>
-    <string name="cfTemplateForwarded">"{0}: {1}"</string>
-    <string name="cfTemplateForwardedTime">"{0}: {1} na {2} seconden"</string>
-    <string name="cfTemplateRegistered">"{0}: Niet doorgestuurd ({1})"</string>
-    <string name="cfTemplateRegisteredTime">"{0}: Niet doorgestuurd ({1} na {2} seconden)"</string>
-    <string name="httpErrorOk">"OK"</string>
-    <string name="httpError">"Onbekende fout"</string>
-    <string name="httpErrorLookup">"Onbekende host"</string>
-    <string name="httpErrorUnsupportedAuthScheme">"Niet-ondersteund verificatieschema. Verificeren mislukt."</string>
-    <string name="httpErrorAuth">"Verificatie mislukt"</string>
-    <string name="httpErrorProxyAuth">"Verificeren van proxyserver mislukt"</string>
-    <string name="httpErrorConnect">"Verbinding maken met server mislukt"</string>
-    <string name="httpErrorIO">"Lezen van of schrijven naar server mislukt"</string>
-    <string name="httpErrorTimeout">"Time-out bij serververbinding"</string>
-    <string name="httpErrorRedirectLoop">"Te veel omleidingen door server"</string>
-    <string name="httpErrorUnsupportedScheme">"Protocol wordt niet ondersteund"</string>
-    <string name="httpErrorFailedSslHandshake">"Uitvoeren van ssl-handshake mislukt"</string>
-    <string name="httpErrorBadUrl">"Ongeldige url"</string>
-    <string name="httpErrorFile">"Bestandfout"</string>
-    <string name="httpErrorFileNotFound">"Bestand niet gevonden"</string>
-    <!-- no translation found for httpErrorTooManyRequests (3764334538393544875) -->
-    <skip />
-    <string name="contentServiceSync">"Sync"</string>
-    <string name="contentServiceSyncNotificationTitle">"Sync"</string>
-    <!-- no translation found for contentServiceTooManyDeletesNotificationDesc (8477597194404210723) -->
-    <skip />
-    <!-- no translation found for low_memory (4191592786596642367) -->
-    <skip />
-    <!-- no translation found for me (4616693653158602117) -->
-    <skip />
-    <string name="power_dialog">"Energieopties"</string>
-    <string name="silent_mode">"Stille modus"</string>
-    <string name="turn_on_radio">"Radio uitschakelen"</string>
-    <string name="turn_off_radio">"Radio uitschakelen"</string>
-    <string name="screen_lock">"Vergrendeling"</string>
-    <string name="power_off">"Uitschakelen"</string>
-    <!-- no translation found for shutdown_progress (3735034517335251808) -->
-    <skip />
-    <!-- no translation found for shutdown_confirm (699224922526414097) -->
-    <skip />
-    <string name="no_recent_tasks">"Geen recente toepassingen"</string>
-    <string name="global_actions">"Globale handelingen"</string>
-    <string name="global_action_lock">"Vergrendeling"</string>
-    <string name="global_action_power_off">"Uitschakelen"</string>
-    <string name="global_action_toggle_silent_mode">"Stille modus"</string>
-    <string name="global_action_silent_mode_on_status">"Geluid staat UIT"</string>
-    <string name="global_action_silent_mode_off_status">"Geluid staat AAN"</string>
-    <string name="safeMode">"Veilige modus"</string>
-    <!-- no translation found for permgrouplab_costMoney (904087853776533085) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_costMoney (4662370555643969515) -->
-    <skip />
-    <!-- no translation found for permgrouplab_messages (2984053976424233925) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_messages (2129093134354989379) -->
-    <skip />
-    <!-- no translation found for permgrouplab_personalInfo (4548406335021507392) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_personalInfo (8499310823817958034) -->
-    <skip />
-    <!-- no translation found for permgrouplab_location (8535677827151907069) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_location (2341662219604651887) -->
-    <skip />
-    <!-- no translation found for permgrouplab_network (3597781730625751831) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_network (8332572695347918340) -->
-    <skip />
-    <!-- no translation found for permgrouplab_accounts (8631201594657951893) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_accounts (443982868906396781) -->
-    <skip />
-    <!-- no translation found for permgrouplab_hardwareControls (5074512938567152139) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_hardwareControls (8772503144945278440) -->
-    <skip />
-    <!-- no translation found for permgrouplab_phoneCalls (7096448531266882376) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_phoneCalls (6703873478653366233) -->
-    <skip />
-    <!-- no translation found for permgrouplab_systemTools (1840847965111633430) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_systemTools (2810337951496685271) -->
-    <skip />
-    <!-- no translation found for permgrouplab_developmentTools (692844635256963358) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_developmentTools (5253915519857796400) -->
-    <skip />
-    <string name="permlab_statusBar">"Statusbalk besturen"</string>
-    <string name="permdesc_statusBar">"Hiermee kan een toepassing de statusbalk en pictogrammen openen, sluiten of uitschakelen."</string>
-    <!-- no translation found for permlab_expandStatusBar (6382500803293284173) -->
-    <skip />
-    <!-- no translation found for permdesc_expandStatusBar (90953162060681436) -->
-    <skip />
-    <!-- no translation found for permlab_processOutgoingCalls (786316295241100144) -->
-    <skip />
-    <!-- no translation found for permdesc_processOutgoingCalls (1655242138991854396) -->
-    <skip />
-    <string name="permlab_receiveSms">"Sms-berichten ontvangen"</string>
-    <string name="permdesc_receiveSms">"Hiermee kan een toepassing tekstberichten ontvangen en verwerken. Slechte toepassingen kunnen uw berichten in de gaten houden of verwijderen zonder dat dit wordt aangegeven."</string>
-    <string name="permlab_receiveMms">"Mms-berichten ontvangen"</string>
-    <string name="permdesc_receiveMms">"Hiermee kan een toepassing multimediaberichten ontvangen en verwerken. Slechte toepassingen kunnen uw berichten in de gaten houden of verwijderen zonder dat dit wordt aangegeven."</string>
-    <string name="permlab_sendSms">"Sms-berichten verzenden"</string>
-    <string name="permdesc_sendSms">"Hiermee kan een toepassing tekstberichten verzenden. Slechte toepassingen kunnen u op kosten jagen door zonder toestemming berichten te verzenden."</string>
-    <string name="permlab_readSms">"Sms/mms-berichten lezen"</string>
-    <string name="permdesc_readSms">"Hiermee kan een toepassing sms-berichten op telefoon of SIM-kaart lezen. Slechte toepassingen kunnen vertrouwelijke berichten lezen."</string>
-    <string name="permlab_writeSms">"Sms/mms-berichten schrijven"</string>
-    <string name="permdesc_writeSms">"Hiermee kan een toepassing sms-berichten op telefoon of SIM-kaart schrijven. Slechte toepassingen kunnen berichten verwijderen."</string>
-    <string name="permlab_receiveWapPush">"Wap-berichten ontvangen"</string>
-    <string name="permdesc_receiveWapPush">"Hiermee kan een toepassing wap-berichten ontvangen en verwerken. Slechte toepassingen kunnen uw berichten in de gaten houden of verwijderen zonder dat dit wordt aangegeven."</string>
-    <string name="permlab_getTasks">"Taakinformatie verkrijgen"</string>
-    <string name="permdesc_getTasks">"Hiermee kan een toepassing informatie ophalen over geactiveerde en recent geactiveerde taken. Verkeerde toepassingen kunnen hierdoor toegang krijgen tot privé-informatie over andere toepassingen."</string>
-    <string name="permlab_reorderTasks">"Taken herschikken"</string>
-    <string name="permdesc_reorderTasks">"Hiermee kan een toepassing taken naar de voorgrond en achtergrond verplaatsen. Slechte toepassingen kunnen zichzelf zonder tussenkomst naar de voorgrond forceren."</string>
-    <string name="permlab_setDebugApp">"Foutopsporing instellen"</string>
-    <string name="permdesc_setDebugApp">"Hiermee kan een toepassing foutopsporing voor andere toepassingen inschakelen. Slechte toepassingen kunnen dit misbruiken om andere toepassingen te stoppen."</string>
-    <string name="permlab_changeConfiguration">"Configuratie wijzigen"</string>
-    <string name="permdesc_changeConfiguration">"Hiermee kan een toepassing de actuele configuratie veranderen, zoals de locatie of algemene tekengrootte."</string>
-    <!-- no translation found for permlab_restartPackages (5836367540766044606) -->
-    <skip />
-    <!-- no translation found for permdesc_restartPackages (1764965996765573321) -->
-    <skip />
-    <!-- no translation found for permlab_setProcessForeground (4860990420780868638) -->
-    <skip />
-    <!-- no translation found for permdesc_setProcessForeground (3795477299954784360) -->
-    <skip />
-    <string name="permlab_forceBack">"Terug forceren"</string>
-    <string name="permdesc_forceBack">"Hiermee kan een toepassing elke activiteit die op de voorgrond staat sluiten en terugkeren. Is bij normale toepassingen nooit nodig."</string>
-    <string name="permlab_dump">"Systeemstatus dumpen"</string>
-    <string name="permdesc_dump">"Hiermee kan een toepassingen de interne toestand van het systeem opvragen. Verkeerde toepassingen kunnen een diverse privé- en veiligheidsinformatie verkrijgen die ze normaal gesproken niet nodig hebben."</string>
-    <string name="permlab_addSystemService">"Systeemservice toevoegen"</string>
-    <string name="permdesc_addSystemService">"Toepassingen mogen hun eigen systeemdiensten van laag-niveau publiceren. Verkeerde toepassingen kunnen het systeem kapen en gegevens erop beschadigen of stelen."</string>
-    <string name="permlab_runSetActivityWatcher">"Activiteitenmonitor instellen"</string>
-    <string name="permdesc_runSetActivityWatcher">"Hiermee kan een toepassing de wijze waarop het systeem activiteiten start in de gaten houden en besturen. Slechte toepassingen kunnen zo het systeem in gevaar brengen. Deze toepassing is alleen nodig voor ontwikkelingsdoeleinden, nooit voor normaal gebruik van het toestel."</string>
-    <string name="permlab_broadcastPackageRemoved">"Uitzendpakket verwijderd"</string>
-    <string name="permdesc_broadcastPackageRemoved">"Hiermee kan een toepassing een melding uitzenden met de mededeling dat een toepassingspakket is verwijderd. Verkeerde toepassingen kunnen dit gebruiken om andere actieve toepassingen te stoppen."</string>
-    <!-- no translation found for permlab_broadcastSmsReceived (1994692154847312518) -->
-    <skip />
-    <!-- no translation found for permdesc_broadcastSmsReceived (6072362543164841432) -->
-    <skip />
-    <!-- no translation found for permlab_broadcastWapPush (3070023012636951639) -->
-    <skip />
-    <!-- no translation found for permdesc_broadcastWapPush (726912255218924336) -->
-    <skip />
-    <string name="permlab_setProcessLimit">"Proceslimiet instellen"</string>
-    <string name="permdesc_setProcessLimit">"Hiermee kan een toepassing het maximumaantal geactiveerde processen besturen. Nooit nodig voor normale toepassingen."</string>
-    <string name="permlab_setAlwaysFinish">"Altijd voltooien instellen"</string>
-    <string name="permdesc_setAlwaysFinish">"Hiermee kan een toepassing besturen of activiteiten altijd voltooid moeten zijn als ze naar de achtergrond gaan. Nooit nodig voor normale toepassingen."</string>
-    <string name="permlab_fotaUpdate">"Installatie van systeemupdate"</string>
-    <string name="permdesc_fotaUpdate">"Hiermee kan een toepassing meldingen ontvangen over systeemupdates die in behandeling zijn en hun installatie in gang zetten. Slechte toepassingen kunnen dit misbruiken om het te beschadigen met niet toegestane updates, of algemeen het updaten te verstoren."</string>
-    <!-- no translation found for permlab_batteryStats (1598947993704535568) -->
-    <skip />
-    <!-- no translation found for permdesc_batteryStats (6247598531831307989) -->
-    <skip />
-    <string name="permlab_internalSystemWindow">"Intern systeemvenster"</string>
-    <string name="permdesc_internalSystemWindow">"Hiermee kunnen vensters worden gemaakt die bedoeld zijn voor gebruik door het interne systeem van de gebruikersinterface. Niet bedoeld voor normale toepassingen."</string>
-    <string name="permlab_systemAlertWindow">"Systeemmeldingen"</string>
-    <string name="permdesc_systemAlertWindow">"Hiermee kan een toepassing systeemmeldingen weergeven. Slechte toepassingen kunnen het volledige toestelscherm overnemen."</string>
-    <string name="permlab_setAnimationScale">"Animatieschaal instellen"</string>
-    <string name="permdesc_setAnimationScale">"Hiermee kan een toepassing op elk moment de globale animatiesnelheid (snellere of tragere animaties) veranderen."</string>
-    <string name="permlab_manageAppTokens">"Toepassingstokens beheren"</string>
-    <string name="permdesc_manageAppTokens">"Hiermee kunnen toepassingen hun eigen tokens maken, en zo de normale Z-ordening buiten spel zetten. Is bij normale toepassingen nooit nodig."</string>
-    <string name="permlab_injectEvents">"Invoergebeurtenissen invoegen"</string>
-    <string name="permdesc_injectEvents">"Hiermee kan een toepassing zijn eigen invoergebeurtenissen (toetsindrukken enz.) naar andere toepassingen sturen. Slechte toepassingen kunnen dit misbruiken om controle over het toestel te krijgen."</string>
-    <string name="permlab_readInputState">"Invoerstatus lezen"</string>
-    <string name="permdesc_readInputState">"Hiermee kunnen toepassingen de toetsen zien die u indrukt, ook bij interactie met een andere toepassing (zoals het invoeren van een wachtwoord). Is bij normale toepassingen nooit nodig."</string>
-    <string name="permlab_setOrientation">"Ligging instellen"</string>
-    <string name="permdesc_setOrientation">"Hiermee kan een toepassing op elk moment de schermligging veranderen. Is bij normale toepassingen nooit nodig."</string>
-    <string name="permlab_signalPersistentProcesses">"Signaal naar aanhoudende processen"</string>
-    <string name="permdesc_signalPersistentProcesses">"Hiermee kan een toepassing verzoeken dat het meegeleverde signaal naar alle aanhoudende processen wordt gestuurd."</string>
-    <string name="permlab_persistentActivity">"Aanhoudende handelingen"</string>
-    <string name="permdesc_persistentActivity">"Hiermee kan een toepassing gedeeltes van zichzelf fixeren, zodat het systeem deze niet meer kan gebruiken voor andere toepassingen."</string>
-    <string name="permlab_deletePackages">"Pakketten verwijderen"</string>
-    <string name="permdesc_deletePackages">"Hiermee kan een toepassing Android-pakketten verwijderen. Slechte toepassingen kunnen dit misbruiken om belangrijke toepassingen te wissen."</string>
-    <!-- no translation found for permlab_clearAppUserData (3858185484601410171) -->
-    <skip />
-    <!-- no translation found for permdesc_clearAppUserData (7233537744753081136) -->
-    <skip />
-    <string name="permlab_deleteCacheFiles">"Cachebestanden wissen"</string>
-    <string name="permdesc_deleteCacheFiles">"Hiermee kan een toepassing cachebestanden verwijderen."</string>
-    <!-- no translation found for permlab_getPackageSize (6743556676630447973) -->
-    <skip />
-    <!-- no translation found for permdesc_getPackageSize (2893996655828539776) -->
-    <skip />
-    <string name="permlab_installPackages">"Pakketten installeren"</string>
-    <string name="permdesc_installPackages">"Hiermee kan een toepassing nieuwe Android- pakketten installeren of updaten. Slechte toepassingen kunnen dit misbruiken om nieuwe toepassingen met twijfelachtig verstrekkende rechten toe te voegen."</string>
-    <string name="permlab_clearAppCache">"Cachegegevens van toepassing wissen"</string>
-    <string name="permdesc_clearAppCache">"Hiermee kan een toepassing toestelgeheugen vrijmaken door bestanden uit de cachemap te verwijderen. Toegang wordt meestal beperkt tot systeemprocessen."</string>
-    <!-- no translation found for permlab_readLogs (6653488552442991707) -->
-    <skip />
-    <!-- no translation found for permdesc_readLogs (356352685800884319) -->
-    <skip />
-    <!-- no translation found for permlab_diagnostic (2955142476313469329) -->
-    <skip />
-    <!-- no translation found for permdesc_diagnostic (1282409892215520166) -->
-    <skip />
-    <string name="permlab_changeComponentState">"Toepassingscomponenten in- of uitschakelen"</string>
-    <string name="permdesc_changeComponentState">"Hiermee kan een toepassing veranderen of een component van een andere toepassing wordt ingeschakeld of niet. Slechte toepassingen kunnen dit gebruiken om belangrijke toestelfuncties uit te schakelen. Wees voorzichtig met het verlenen van toestemmingen, omdat het mogelijk is dat toepassingscomponenten in een onbruikbare, inconsistente of instabiele toestand geraken."</string>
-    <string name="permlab_setPreferredApplications">"Voorkeurstoepassingen instellen"</string>
-    <string name="permdesc_setPreferredApplications">"Hiermee kan een toepassing uw voorkeurstoepassingen veranderen. Slechte toepassingen kunnen zo stilletjes veranderen welke toepassingen gestart moeten worden, zodat bestaande toepassingen privégegevens over u verzamelen."</string>
-    <string name="permlab_writeSettings">"Systeeminstellingen schrijven"</string>
-    <string name="permdesc_writeSettings">"Hiermee kan een toepassing de instellingsgegevens van het systeem aanpassen. Slechte toepassingen kunnen de configuratie van het systeem beschadigen."</string>
-    <!-- no translation found for permlab_writeSecureSettings (4851801872124242319) -->
-    <skip />
-    <!-- no translation found for permdesc_writeSecureSettings (2080620249472761366) -->
-    <skip />
-    <!-- no translation found for permlab_writeGservices (296370685945777755) -->
-    <skip />
-    <!-- no translation found for permdesc_writeGservices (2496928471286495053) -->
-    <skip />
-    <string name="permlab_receiveBootCompleted">"Uitvoeren bij opstarten"</string>
-    <string name="permdesc_receiveBootCompleted">"Hiermee kan een toepassing zichzelf starten zodra het systeem is opgestart. Hierdoor kan het opstarten van het toestel langer duren en de toepassing het toestel afremmen omdat het altijd is geactiveerd."</string>
-    <string name="permlab_broadcastSticky">"Belangrijke uitzending"</string>
-    <string name="permdesc_broadcastSticky">"Hiermee kan een toepassing plakuitzendingen versturen, die blijven hangen als de uitzending stopt. Verkeerde toepassingen kunnen het toestel traag of instabiel maken door te veel geheugengebruik te veroorzaken."</string>
-    <string name="permlab_readContacts">"Contactgegevens lezen"</string>
-    <string name="permdesc_readContacts">"Hiermee kan een toepassing alle contactgegevens (adres) op het toestel lezen. Slechte toepassingen kunnen dit misbruiken om uw gegevens naar andere personen te sturen."</string>
-    <string name="permlab_writeContacts">"Contactgegevens schrijven"</string>
-    <string name="permdesc_writeContacts">"Hiermee kan een toepassing alle contactgegevens (adres) op het toestel aanpassen. Slechte toepassingen kunnen dit misbruiken om contactgegevens te wissen of wijzigen."</string>
-    <!-- no translation found for permlab_writeOwnerData (8036840529708535113) -->
-    <skip />
-    <!-- no translation found for permdesc_writeOwnerData (5873447528845878348) -->
-    <skip />
-    <!-- no translation found for permlab_readOwnerData (1847040178513733757) -->
-    <skip />
-    <!-- no translation found for permdesc_readOwnerData (7563299529149214764) -->
-    <skip />
-    <!-- no translation found for permlab_readCalendar (2111238731453410895) -->
-    <skip />
-    <!-- no translation found for permdesc_readCalendar (4408253940601239114) -->
-    <skip />
-    <!-- no translation found for permlab_writeCalendar (7518052789370653396) -->
-    <skip />
-    <!-- no translation found for permdesc_writeCalendar (8057304232140147596) -->
-    <skip />
-    <!-- no translation found for permlab_accessMockLocation (321094551062270213) -->
-    <skip />
-    <!-- no translation found for permdesc_accessMockLocation (3651565866471419739) -->
-    <skip />
-    <!-- no translation found for permlab_accessLocationExtraCommands (8291822077788811687) -->
-    <skip />
-    <!-- no translation found for permdesc_accessLocationExtraCommands (5135782633548630731) -->
-    <skip />
-    <string name="permlab_accessFineLocation">"Toegang tot gps-locatie"</string>
-    <string name="permdesc_accessFineLocation">"Open, indien beschikbaar, het Global Positioning System op het toestel. Verkeerde toepassingen kunnen dit gebruiken om te bepalen waar u zich bevindt en extra batterijstroom verbruiken."</string>
-    <string name="permlab_accessCoarseLocation">"Toegang tot netwerklocatie"</string>
-    <string name="permdesc_accessCoarseLocation">"Gebruik, indien beschikbaar, een netwerkdatabank om de locatie van het toestel te schatten. Verkeerde toepassingen kunnen dit gebruiken om te schatten waar u zich bevindt."</string>
-    <string name="permlab_accessSurfaceFlinger">"Toegang tot SurfaceFlinger"</string>
-    <string name="permdesc_accessSurfaceFlinger">"Toepassingen mogen de functies op laag niveau van SurfaceFlinger gebruiken."</string>
-    <string name="permlab_readFrameBuffer">"Framebuffer lezen"</string>
-    <string name="permdesc_readFrameBuffer">"Hiermee kan een toepassing de gegevens van de framebuffer lezen."</string>
-    <string name="permlab_modifyAudioSettings">"Audioinstellingen wijzigen"</string>
-    <string name="permdesc_modifyAudioSettings">"Hiermee kan een toepassing globale audioinstellingen aanpassen, zoals volume en route."</string>
-    <string name="permlab_recordAudio">"Audio opnemen"</string>
-    <string name="permdesc_recordAudio">"Hierdoor kan een toepassing het opnamepad voor audio openen."</string>
-    <string name="permlab_camera">"Camera"</string>
-    <!-- unknown placeholder BREAK in permdesc_camera -->
-    <skip />
-    <string name="permlab_brick">"Toestel uitschakelen"</string>
-    <string name="permdesc_brick">"Hiermee kan de toepassing de gehele dienst permanent uitschakelen. Dit is erg gevaarlijk."</string>
-    <!-- no translation found for permlab_reboot (8844650672567077423) -->
-    <skip />
-    <!-- no translation found for permdesc_reboot (4704919552870918328) -->
-    <skip />
-    <string name="permlab_mount_unmount_filesystems">"Bestandssystemen koppelen en losmaken"</string>
-    <string name="permdesc_mount_unmount_filesystems">"Hiermee kan de toepassing bestandssystemen voor verwisselbaar geheugen koppelen en loskoppelen."</string>
-    <string name="permlab_vibrate">"Triller"</string>
-    <string name="permdesc_vibrate">"Hiermee kan de toepassing de triller besturen."</string>
-    <string name="permlab_flashlight">"Flitser"</string>
-    <string name="permdesc_flashlight">"Hiermee kan de toepassing de flitser besturen."</string>
-    <string name="permlab_hardware_test">"Hardwaretest"</string>
-    <string name="permdesc_hardware_test">"Hiermee kan de toepassing diverse randapparaten besturen met als doel het testen van de hardware."</string>
-    <string name="permlab_callPhone">"Telefoonnummers bellen"</string>
-    <string name="permdesc_callPhone">"Hiermee kunnen toepassingen telefoonnummers bellen zonder uw tussenkomst. Verkeerde toepassingen kunnen ongewilde gesprekken op uw telefoonrekening veroorzaken."</string>
-    <!-- no translation found for permlab_callPrivileged (2166923597287697159) -->
-    <skip />
-    <!-- no translation found for permdesc_callPrivileged (5109789447971735501) -->
-    <skip />
-    <!-- no translation found for permlab_locationUpdates (4216418293360456836) -->
-    <skip />
-    <!-- no translation found for permdesc_locationUpdates (7635814693478743648) -->
-    <skip />
-    <!-- no translation found for permlab_checkinProperties (2260796787386280708) -->
-    <skip />
-    <!-- no translation found for permdesc_checkinProperties (3508022022841741945) -->
-    <skip />
-    <!-- no translation found for permlab_modifyPhoneState (7791696535097912313) -->
-    <skip />
-    <!-- no translation found for permdesc_modifyPhoneState (6352405226410454770) -->
-    <skip />
-    <!-- no translation found for permlab_readPhoneState (7320082586621086653) -->
-    <skip />
-    <!-- no translation found for permdesc_readPhoneState (8004450067066407969) -->
-    <skip />
-    <!-- no translation found for permlab_wakeLock (1591164750935072136) -->
-    <skip />
-    <!-- no translation found for permdesc_wakeLock (160471538196734936) -->
-    <skip />
-    <string name="permlab_devicePower">"Toestel inschakelen"</string>
-    <string name="permdesc_devicePower">"Hiermee kan de toepassing het toestel in- of uitschakelen, of ingeschakeld laten."</string>
-    <string name="permlab_factoryTest">"Fabriekstest"</string>
-    <string name="permdesc_factoryTest">"Uitvoeren als een fabriekstest op laag niveau, waardoor volledige toegang tot de toestelhardware gegeven is. Alleen beschikbaar als een toestel in de fabriekstestmodus staat."</string>
-    <string name="permlab_setWallpaper">"Achtergrond instellen"</string>
-    <string name="permdesc_setWallpaper">"Hiermee kan de toepassing de systeemachtergrond instellen."</string>
-    <!-- no translation found for permlab_setWallpaperHints (4192438316932517807) -->
-    <skip />
-    <!-- no translation found for permdesc_setWallpaperHints (738757439960921674) -->
-    <skip />
-    <string name="permlab_masterClear">"Volledige systeemreset"</string>
-    <string name="permdesc_masterClear">"Hiermee kan een toepassing het systeem volledig opnieuw instellen op fabrieksinstellingen, waardoor alle gegevens, configuratie en geïnstalleerde toepassingen worden gewist."</string>
-    <!-- no translation found for permlab_setTimeZone (477196167239548690) -->
-    <skip />
-    <!-- no translation found for permdesc_setTimeZone (8564892020460841198) -->
-    <skip />
-    <!-- no translation found for permlab_getAccounts (2764070033402295170) -->
-    <skip />
-    <!-- no translation found for permdesc_getAccounts (1203491378748649898) -->
-    <skip />
-    <!-- no translation found for permlab_accessNetworkState (2032916924886010827) -->
-    <skip />
-    <!-- no translation found for permdesc_accessNetworkState (7081329402551195933) -->
-    <skip />
-    <!-- no translation found for permlab_createNetworkSockets (4706698319966917864) -->
-    <skip />
-    <!-- no translation found for permdesc_createNetworkSockets (2580337178778551792) -->
-    <skip />
-    <!-- no translation found for permlab_writeApnSettings (3190585220761979369) -->
-    <skip />
-    <!-- no translation found for permdesc_writeApnSettings (4093875220468761052) -->
-    <skip />
-    <!-- no translation found for permlab_changeNetworkState (2710779001260856872) -->
-    <skip />
-    <!-- no translation found for permdesc_changeNetworkState (8076109230787022270) -->
-    <skip />
-    <!-- no translation found for permlab_accessWifiState (3613679494230374297) -->
-    <skip />
-    <!-- no translation found for permdesc_accessWifiState (8226508433563326925) -->
-    <skip />
-    <!-- no translation found for permlab_changeWifiState (6043889338995432957) -->
-    <skip />
-    <!-- no translation found for permdesc_changeWifiState (7829372845909567994) -->
-    <skip />
-    <!-- no translation found for permlab_bluetoothAdmin (5513286736585647334) -->
-    <skip />
-    <!-- no translation found for permdesc_bluetoothAdmin (1838208497914347365) -->
-    <skip />
-    <!-- no translation found for permlab_bluetooth (6378797624765639115) -->
-    <skip />
-    <!-- no translation found for permdesc_bluetooth (8592386018922265273) -->
-    <skip />
-    <!-- no translation found for permlab_disableKeyguard (4574886811903233903) -->
-    <skip />
-    <!-- no translation found for permdesc_disableKeyguard (815972646344251271) -->
-    <skip />
-    <!-- no translation found for permlab_readSyncSettings (8818819977141505127) -->
-    <skip />
-    <!-- no translation found for permdesc_readSyncSettings (8454705401908767847) -->
-    <skip />
-    <!-- no translation found for permlab_writeSyncSettings (4514911143753152941) -->
-    <skip />
-    <!-- no translation found for permdesc_writeSyncSettings (7630627689635091836) -->
-    <skip />
-    <!-- no translation found for permlab_readSyncStats (5748337739678952863) -->
-    <skip />
-    <!-- no translation found for permdesc_readSyncStats (582551457321957183) -->
-    <skip />
-    <!-- no translation found for permlab_subscribedFeedsRead (2043206814904506589) -->
-    <skip />
-    <!-- no translation found for permdesc_subscribedFeedsRead (6977343942680042449) -->
-    <skip />
-    <!-- no translation found for permlab_subscribedFeedsWrite (2556727307229571556) -->
-    <skip />
-    <!-- no translation found for permdesc_subscribedFeedsWrite (4134783294590266220) -->
-    <skip />
-    <!-- no translation found for phoneTypes:0 (6070018634209800981) -->
-    <!-- no translation found for phoneTypes:1 (1514509689885965711) -->
-    <!-- no translation found for phoneTypes:2 (497473201754095234) -->
-    <!-- no translation found for phoneTypes:3 (5554432614281047787) -->
-    <!-- no translation found for phoneTypes:4 (2222084401110150993) -->
-    <!-- no translation found for phoneTypes:5 (2290007103906353121) -->
-    <!-- no translation found for phoneTypes:6 (6930783706213719251) -->
-    <!-- no translation found for phoneTypes:7 (1326005699931077792) -->
-    <!-- no translation found for emailAddressTypes:0 (1540640638077615417) -->
-    <!-- no translation found for emailAddressTypes:1 (4252853367575831977) -->
-    <!-- no translation found for emailAddressTypes:2 (7158046581744435718) -->
-    <!-- no translation found for emailAddressTypes:3 (3625034471181268169) -->
-    <!-- no translation found for postalAddressTypes:0 (5732960259696659380) -->
-    <!-- no translation found for postalAddressTypes:1 (7132240704786130285) -->
-    <!-- no translation found for postalAddressTypes:2 (1317604357745852817) -->
-    <!-- no translation found for postalAddressTypes:3 (1582953598462826702) -->
-    <!-- no translation found for imAddressTypes:0 (7806620012096518833) -->
-    <!-- no translation found for imAddressTypes:1 (5748846799950672787) -->
-    <!-- no translation found for imAddressTypes:2 (6196536810275073680) -->
-    <!-- no translation found for imAddressTypes:3 (8519128375350623648) -->
-    <!-- no translation found for organizationTypes:0 (1299224825223821142) -->
-    <!-- no translation found for organizationTypes:1 (2455717447227299354) -->
-    <!-- no translation found for organizationTypes:2 (7027570839313438290) -->
-    <!-- no translation found for imProtocols:0 (3318725788774688043) -->
-    <!-- no translation found for imProtocols:1 (1787713387022932886) -->
-    <!-- no translation found for imProtocols:2 (6751174158442316516) -->
-    <!-- no translation found for imProtocols:3 (1151283347465052653) -->
-    <!-- no translation found for imProtocols:4 (2157980008878817934) -->
-    <!-- no translation found for imProtocols:5 (7836237460308230767) -->
-    <!-- no translation found for imProtocols:6 (1180789904462172516) -->
-    <!-- no translation found for imProtocols:7 (21955111672779862) -->
-    <string name="keyguard_password_enter_pin_code">"Pincode invoeren"</string>
-    <string name="keyguard_password_wrong_pin_code">"Onjuiste pincode!"</string>
-    <string name="keyguard_label_text">"Om vrij te geven drukt u op Menu en vervolgens op 0."</string>
-    <string name="emergency_call_dialog_number_for_display">"Alarmnummers"</string>
-    <string name="lockscreen_carrier_default">"(Geen service)"</string>
-    <string name="lockscreen_screen_locked">"Schermblokkering"</string>
-    <string name="lockscreen_instructions_when_pattern_enabled">"Druk op Menu om vrij te geven of bel een alarmnummer"</string>
-    <string name="lockscreen_instructions_when_pattern_disabled">"Druk op Menu om vrij te geven"</string>
-    <string name="lockscreen_pattern_instructions">"Patroon tekenen om vrij te geven"</string>
-    <string name="lockscreen_emergency_call">"Noodoproep"</string>
-    <string name="lockscreen_pattern_correct">"Juist!"</string>
-    <string name="lockscreen_pattern_wrong">"Verkeerd patroon! Nogmaals proberen"</string>
-    <string name="lockscreen_plugged_in">"Bezig met opladen (<xliff:g id="NUMBER">%d%%</xliff:g>)"</string>
-    <string name="lockscreen_low_battery">"Oplader verbinden"</string>
-    <!-- no translation found for lockscreen_missing_sim_message_short (5051192587315492957) -->
-    <skip />
-    <string name="lockscreen_missing_sim_message">"Geen SIM in toestel"</string>
-    <string name="lockscreen_missing_sim_instructions">"Voer een SIM-kaart in"</string>
-    <!-- no translation found for lockscreen_network_locked_message (323609607922245071) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_puk_locked_message (1005803622871256359) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_puk_locked_instructions (5033160098036646955) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_locked_message (7398401200962556379) -->
-    <skip />
-    <!-- no translation found for lockscreen_sim_unlock_progress_dialog_message (5939537246164692076) -->
-    <skip />
-    <!-- unknown placeholder BREAK in lockscreen_too_many_failed_attempts_dialog_message -->
-    <skip />
-    <!-- no translation found for lockscreen_failed_attempts_almost_glogin (1569017295989454551) -->
-    <skip />
-    <string name="lockscreen_too_many_failed_attempts_countdown">"Probeer opnieuw over <xliff:g id="NUMBER">%d</xliff:g> seconden"</string>
-    <!-- no translation found for lockscreen_forgot_pattern_button_text (4219994639843985488) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_too_many_attempts (7504679498838839295) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_instructions (6542400673357252011) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_username_hint (6378418320242015111) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_password_hint (3224230234042131153) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_submit_button (5562051040043760034) -->
-    <skip />
-    <!-- no translation found for lockscreen_glogin_invalid_input (4881057177478491580) -->
-    <skip />
-    <!-- unknown placeholder FORMAT in status_bar_time_format -->
-    <skip />
-    <!-- no translation found for hour_minute_ampm (1850330605794978742) -->
-    <skip />
-    <!-- no translation found for hour_minute_cap_ampm (1122840227537374196) -->
-    <skip />
-    <!-- no translation found for hour_ampm (7665432130905376251) -->
-    <skip />
-    <!-- no translation found for hour_cap_ampm (3600295014648400268) -->
-    <skip />
-    <!-- no translation found for status_bar_clear_all_button (2202004591253243750) -->
-    <skip />
-    <string name="status_bar_no_notifications_title">"Meldingen"</string>
-    <string name="status_bar_ongoing_events_title">"Actueel"</string>
-    <string name="status_bar_latest_events_title">"Nieuwste gebeurtenissen"</string>
-    <string name="battery_status_text_percent_format">"<xliff:g id="NUMBER">%d</xliff:g>"</string>
-    <string name="battery_status_charging">"Bezig met opladen…"</string>
-    <string name="battery_low_title">"Oplader verbinden"</string>
-    <string name="battery_low_subtitle">"Lage batterijstroom"</string>
-    <string name="battery_low_percent_format">"Minder dan <xliff:g id="NUMBER">%d%%</xliff:g> resterend"</string>
-    <string name="factorytest_failed">"Fabriekstest mislukt"</string>
-    <string name="factorytest_not_system">"De handeling FACTORY_TEST wordt alleen ondersteund voor pakketten die geïnstalleerd zijn in /system/app."</string>
-    <string name="factorytest_no_action">"Geen pakket gevonden dat de handeling FACTORY_TEST levert."</string>
-    <string name="factorytest_reboot">"Opnieuw opstarten"</string>
-    <string name="save_password_label">"Bevestigen"</string>
-    <string name="save_password_message">"Wilt u dat de browser dit wachtwoord onthoudt?"</string>
-    <string name="save_password_notnow">"Niet nu"</string>
-    <string name="save_password_remember">"Onthouden"</string>
-    <string name="save_password_never">"Nooit"</string>
-    <string name="open_permission_deny">"U hebt geen toestemming om deze pagina te openen."</string>
-    <!-- no translation found for text_copied (6106873823411904723) -->
-    <skip />
-    <string name="more_item_label">"Meer"</string>
-    <string name="prepend_shortcut_label">"Menu+"</string>
-    <!-- no translation found for menu_space_shortcut_label (194586306440382711) -->
-    <skip />
-    <!-- no translation found for menu_enter_shortcut_label (7214761412193519345) -->
-    <skip />
-    <!-- no translation found for menu_delete_shortcut_label (2854936426194985313) -->
-    <skip />
-    <string name="search_go">"Ga naar"</string>
-    <string name="today">"Vandaag"</string>
-    <string name="yesterday">"Gisteren"</string>
-    <string name="tomorrow">"Morgen"</string>
-    <!-- no translation found for oneMonthDurationPast (3402179395240209557) -->
-    <skip />
-    <!-- no translation found for beforeOneMonthDurationPast (7578100953282866827) -->
-    <skip />
-    <!-- no translation found for num_seconds_ago:one (7416512229671810725) -->
-    <!-- no translation found for num_seconds_ago:other (8138756910300398447) -->
-    <!-- no translation found for num_minutes_ago:one (8620869479299420562) -->
-    <!-- no translation found for num_minutes_ago:other (5065488162050522741) -->
-    <!-- no translation found for num_hours_ago:one (853404611989669641) -->
-    <!-- no translation found for num_hours_ago:other (3558873784561756849) -->
-    <!-- no translation found for num_days_ago:one (4222479980812128212) -->
-    <!-- no translation found for num_days_ago:other (5445701370433601703) -->
-    <!-- no translation found for in_num_seconds:one (4253290037777327003) -->
-    <!-- no translation found for in_num_seconds:other (1280033870920841404) -->
-    <!-- no translation found for in_num_minutes:one (1487585791027953091) -->
-    <!-- no translation found for in_num_minutes:other (6274204576475209932) -->
-    <!-- no translation found for in_num_hours:one (6501470863235186391) -->
-    <!-- no translation found for in_num_hours:other (4415358752953289251) -->
-    <!-- no translation found for in_num_days:one (5608475533104443893) -->
-    <!-- no translation found for in_num_days:other (3827193006163842267) -->
-    <string name="preposition_for_date">"op %s"</string>
-    <string name="preposition_for_time">"bij %s"</string>
-    <string name="preposition_for_year">"in %s"</string>
-    <string name="day">"dag"</string>
-    <string name="days">"dagen"</string>
-    <string name="hour">"uur"</string>
-    <string name="hours">"uur"</string>
-    <string name="minute">"minuut"</string>
-    <string name="minutes">"minuten"</string>
-    <string name="second">"seconde"</string>
-    <string name="seconds">"seconden"</string>
-    <string name="week">"week"</string>
-    <string name="weeks">"weken"</string>
-    <!-- no translation found for year (8024790425994085153) -->
-    <skip />
-    <!-- no translation found for years (8592090054773244417) -->
-    <skip />
-    <string name="sunday">"Zondag"</string>
-    <string name="monday">"Maandag"</string>
-    <string name="tuesday">"Dinsdag"</string>
-    <string name="wednesday">"Woensdag"</string>
-    <string name="thursday">"Donderdag"</string>
-    <string name="friday">"Vrijdag"</string>
-    <string name="saturday">"Zaterdag"</string>
-    <string name="every_weekday">"Elke werkdag (Maa–vri)"</string>
-    <string name="daily">"Elke dag"</string>
-    <string name="weekly">"Wekelijks op <xliff:g id="DAY">%s</xliff:g>"</string>
-    <string name="monthly">"Elke mnd"</string>
-    <string name="yearly">"Elk jaar"</string>
-    <string name="VideoView_error_title">"Videoafspeelfout"</string>
-    <string name="VideoView_error_text_unknown">"Fout opgetreden bij afspelen van geselecteerde video."</string>
-    <string name="VideoView_error_button">"OK"</string>
-    <string name="am">"AM"</string>
-    <string name="pm">"PM"</string>
-    <!-- unknown placeholder FORMAT in numeric_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in wday1_date1_time1_wday2_date2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in wday1_date1_wday2_date2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in date1_time1_date2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in date1_date2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time1_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time_wday_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in wday_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time_date -->
-    <skip />
-    <!-- unknown placeholder FORMAT in time_wday -->
-    <skip />
-    <!-- no translation found for full_date_month_first (6011143962222283357) -->
-    <skip />
-    <!-- no translation found for full_date_day_first (8621594762705478189) -->
-    <skip />
-    <!-- no translation found for medium_date_month_first (48990963718825728) -->
-    <skip />
-    <!-- no translation found for medium_date_day_first (2898992016440387123) -->
-    <skip />
-    <!-- no translation found for twelve_hour_time_format (6015557937879492156) -->
-    <skip />
-    <!-- no translation found for twenty_four_hour_time_format (5176807998669709535) -->
-    <skip />
-    <string name="noon">"12 uur \'smiddags"</string>
-    <string name="Noon">"12 uur \'smiddags"</string>
-    <string name="midnight">"middernacht"</string>
-    <string name="Midnight">"Middernacht"</string>
-    <!-- unknown placeholder FORMAT in month_day -->
-    <skip />
-    <!-- unknown placeholder FORMAT in month -->
-    <skip />
-    <!-- unknown placeholder FORMAT in month_day_year -->
-    <skip />
-    <!-- unknown placeholder FORMAT in month_year -->
-    <skip />
-    <!-- no translation found for time_of_day (8375993139317154157) -->
-    <skip />
-    <!-- no translation found for date_and_time (9197690194373107109) -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_md1_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_md1_wday2_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_mdy1_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_mdy1_wday2_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_md1_time1_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_md1_time1_wday2_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_mdy1_time1_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_year_wday1_mdy1_time1_wday2_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_md1_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_md1_wday2_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_mdy1_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_mdy1_wday2_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_md1_time1_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_md1_time1_wday2_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_mdy1_time1_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in numeric_wday1_mdy1_time1_wday2_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_md1_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_md1_wday2_md2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_mdy1_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_mdy1_wday2_mdy2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_md1_time1_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_md1_time1_wday2_md2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_mdy1_time1_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in same_month_wday1_mdy1_time1_wday2_mdy2_time2 -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month_day_year -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month_year -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month_day -->
-    <skip />
-    <!-- unknown placeholder FORMAT in abbrev_month -->
-    <skip />
-    <string name="day_of_week_long_sunday">"Zondag"</string>
-    <string name="day_of_week_long_monday">"Maandag"</string>
-    <string name="day_of_week_long_tuesday">"Dinsdag"</string>
-    <string name="day_of_week_long_wednesday">"Woensdag"</string>
-    <string name="day_of_week_long_thursday">"Donderdag"</string>
-    <string name="day_of_week_long_friday">"Vrijdag"</string>
-    <string name="day_of_week_long_saturday">"Zaterdag"</string>
-    <string name="day_of_week_medium_sunday">"Zon"</string>
-    <string name="day_of_week_medium_monday">"Maa"</string>
-    <string name="day_of_week_medium_tuesday">"Din"</string>
-    <string name="day_of_week_medium_wednesday">"Woe"</string>
-    <string name="day_of_week_medium_thursday">"Don"</string>
-    <string name="day_of_week_medium_friday">"Vri"</string>
-    <string name="day_of_week_medium_saturday">"Zat"</string>
-    <string name="day_of_week_short_sunday">"Zo"</string>
-    <string name="day_of_week_short_monday">"Ma"</string>
-    <string name="day_of_week_short_tuesday">"Di"</string>
-    <string name="day_of_week_short_wednesday">"Wo"</string>
-    <string name="day_of_week_short_thursday">"Do"</string>
-    <string name="day_of_week_short_friday">"Vr"</string>
-    <string name="day_of_week_short_saturday">"Za"</string>
-    <string name="day_of_week_shorter_sunday">"Zo"</string>
-    <string name="day_of_week_shorter_monday">"M"</string>
-    <string name="day_of_week_shorter_tuesday">"Di"</string>
-    <string name="day_of_week_shorter_wednesday">"W"</string>
-    <string name="day_of_week_shorter_thursday">"Do"</string>
-    <string name="day_of_week_shorter_friday">"V"</string>
-    <string name="day_of_week_shorter_saturday">"Za"</string>
-    <string name="day_of_week_shortest_sunday">"Z"</string>
-    <string name="day_of_week_shortest_monday">"M"</string>
-    <string name="day_of_week_shortest_tuesday">"Di"</string>
-    <string name="day_of_week_shortest_wednesday">"W"</string>
-    <string name="day_of_week_shortest_thursday">"Do"</string>
-    <string name="day_of_week_shortest_friday">"V"</string>
-    <string name="day_of_week_shortest_saturday">"Z"</string>
-    <string name="month_long_january">"Januari"</string>
-    <string name="month_long_february">"Februari"</string>
-    <string name="month_long_march">"Maart"</string>
-    <string name="month_long_april">"April"</string>
-    <string name="month_long_may">"Mei"</string>
-    <string name="month_long_june">"Juni"</string>
-    <string name="month_long_july">"Juli"</string>
-    <string name="month_long_august">"Augustus"</string>
-    <string name="month_long_september">"September"</string>
-    <string name="month_long_october">"Oktober"</string>
-    <string name="month_long_november">"November"</string>
-    <string name="month_long_december">"December"</string>
-    <string name="month_medium_january">"jan"</string>
-    <string name="month_medium_february">"feb"</string>
-    <string name="month_medium_march">"mrt"</string>
-    <string name="month_medium_april">"apr"</string>
-    <string name="month_medium_may">"mei"</string>
-    <string name="month_medium_june">"jun"</string>
-    <string name="month_medium_july">"jul"</string>
-    <string name="month_medium_august">"aug"</string>
-    <string name="month_medium_september">"sep"</string>
-    <string name="month_medium_october">"okt"</string>
-    <string name="month_medium_november">"nov"</string>
-    <string name="month_medium_december">"dec"</string>
-    <string name="month_shortest_january">"J"</string>
-    <string name="month_shortest_february">"F"</string>
-    <string name="month_shortest_march">"M"</string>
-    <string name="month_shortest_april">"A"</string>
-    <string name="month_shortest_may">"M"</string>
-    <string name="month_shortest_june">"J"</string>
-    <string name="month_shortest_july">"J"</string>
-    <string name="month_shortest_august">"A"</string>
-    <string name="month_shortest_september">"S"</string>
-    <string name="month_shortest_october">"O"</string>
-    <string name="month_shortest_november">"N"</string>
-    <string name="month_shortest_december">"D"</string>
-    <!-- unknown placeholder FORMAT in elapsed_time_short_format_mm_ss -->
-    <skip />
-    <!-- unknown placeholder FORMAT in elapsed_time_short_format_h_mm_ss -->
-    <skip />
-    <string name="selectAll">"Alles selecteren"</string>
-    <string name="cut">"Knippen"</string>
-    <!-- no translation found for cutAll (4474519683293791451) -->
-    <skip />
-    <string name="copy">"Kopiëren"</string>
-    <!-- no translation found for copyAll (4777548804630476932) -->
-    <skip />
-    <string name="paste">"Plakken"</string>
-    <string name="copyUrl">"URL kopiëren"</string>
-    <!-- no translation found for inputMethod (7911866729148111492) -->
-    <skip />
-    <!-- no translation found for editTextMenuTitle (3984253728638788023) -->
-    <skip />
-    <string name="low_internal_storage_view_title">"Weinig intern geheugen"</string>
-    <string name="low_internal_storage_view_text">"Toestel heeft weinig intern geheugen"</string>
-    <string name="ok">"OK"</string>
-    <string name="cancel">"Annuleren"</string>
-    <string name="yes">"OK"</string>
-    <string name="no">"Annuleren"</string>
-    <string name="capital_on">"AAN"</string>
-    <string name="capital_off">"UIT"</string>
-    <string name="whichApplication">"Welke toepassing wilt u gebruiken?"</string>
-    <string name="alwaysUse">"Deze toepassing altijd gebruiken voor deze toepassing"</string>
-    <!-- no translation found for clearDefaultHintMsg (5742432113023174321) -->
-    <skip />
-    <string name="chooseActivity">"Een actie selecteren"</string>
-    <string name="noApplications">"Geen toepassingen beschikbaar om de handeling uit te voeren"</string>
-    <!-- no translation found for aerr_title (2654390351574026098) -->
-    <skip />
-    <!-- no translation found for aerr_application (4917288809565116720) -->
-    <skip />
-    <!-- no translation found for aerr_process (1273819861108073461) -->
-    <skip />
-    <!-- no translation found for anr_title (3305935690891435915) -->
-    <skip />
-    <!-- no translation found for anr_activity_application (1653036325679156678) -->
-    <skip />
-    <!-- no translation found for anr_activity_process (2674027618362070465) -->
-    <skip />
-    <!-- no translation found for anr_application_process (2163656674970221928) -->
-    <skip />
-    <!-- no translation found for anr_process (7747550780123472160) -->
-    <skip />
-    <!-- no translation found for force_close (9020954128872810669) -->
-    <skip />
-    <!-- no translation found for wait (7973775702304037058) -->
-    <skip />
-    <!-- no translation found for debug (857932504764728770) -->
-    <skip />
-    <string name="sendText">"Kiezen wat met de tekst gebeurt"</string>
-    <!-- no translation found for volume_ringtone (4121694816346562058) -->
-    <skip />
-    <!-- no translation found for volume_music (4869950240104717493) -->
-    <skip />
-    <!-- no translation found for volume_call (5723421277753250395) -->
-    <skip />
-    <!-- no translation found for volume_alarm (2752102730973081294) -->
-    <skip />
-    <!-- no translation found for volume_unknown (6908187627672375742) -->
-    <skip />
-    <!-- no translation found for ringtone_default (2873893375149093475) -->
-    <skip />
-    <!-- no translation found for ringtone_default_with_actual (5474076151665761913) -->
-    <skip />
-    <!-- no translation found for ringtone_silent (7477159279081654685) -->
-    <skip />
-    <!-- no translation found for ringtone_picker_title (7055241890764367884) -->
-    <skip />
-    <!-- no translation found for ringtone_unknown (6888219771401173795) -->
-    <skip />
-    <!-- no translation found for wifi_available:one (8168012881468888470) -->
-    <!-- no translation found for wifi_available:other (4666122955807117718) -->
-    <!-- no translation found for wifi_available_detailed:one (5107769161192143259) -->
-    <!-- no translation found for wifi_available_detailed:other (853347657960575809) -->
-    <!-- no translation found for select_character (3735110139249491726) -->
-    <skip />
-    <!-- no translation found for sms_control_default_app_name (7522184737840550841) -->
-    <skip />
-    <!-- no translation found for sms_control_title (2742400596989418394) -->
-    <skip />
-    <!-- no translation found for sms_control_message (3447126217666595989) -->
-    <skip />
-    <!-- no translation found for sms_control_yes (8839660939359273650) -->
-    <skip />
-    <!-- no translation found for sms_control_no (909756849988183801) -->
-    <skip />
-    <!-- no translation found for date_time_set (2495199891239480952) -->
-    <skip />
-    <!-- no translation found for default_permission_group (7742780381379652409) -->
-    <skip />
-    <!-- no translation found for no_permissions (85461124044682315) -->
-    <skip />
-    <!-- no translation found for perms_hide (4145325555929151849) -->
-    <skip />
-    <!-- no translation found for perms_show_all (6040194843455403173) -->
-    <skip />
-    <!-- no translation found for googlewebcontenthelper_loading (2140804350507245589) -->
-    <skip />
-    <!-- no translation found for usb_storage_title (8699631567051394409) -->
-    <skip />
-    <!-- no translation found for usb_storage_message (5344039189213308733) -->
-    <skip />
-    <!-- no translation found for usb_storage_button_mount (6700104384375121662) -->
-    <skip />
-    <!-- no translation found for usb_storage_button_unmount (465869657252626688) -->
-    <skip />
-    <!-- no translation found for usb_storage_error_message (3192564550748426087) -->
-    <skip />
-    <!-- no translation found for usb_storage_notification_title (6237028017872246940) -->
-    <skip />
-    <!-- no translation found for usb_storage_notification_message (7371717280517625905) -->
-    <skip />
-    <!-- no translation found for select_input_method (2658280517827502015) -->
-    <skip />
-    <!-- no translation found for fast_scroll_alphabet (1017432309285755759) -->
-    <skip />
-    <!-- no translation found for fast_scroll_numeric_alphabet (3092587363718901074) -->
-    <skip />
-    <!-- no translation found for candidates_style (7738463880139922176) -->
-    <skip />
-</resources>
diff --git a/core/res/res/values-nl/strings.xml b/core/res/res/values-nl/strings.xml
index 5c54226..7ce4c66 100644
--- a/core/res/res/values-nl/strings.xml
+++ b/core/res/res/values-nl/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Hiermee kan de toepassing de telefoon gedwongen opnieuw opstarten."</string>
     <string name="permlab_mount_unmount_filesystems">"bestandssystemen koppelen en ontkoppelen"</string>
     <string name="permdesc_mount_unmount_filesystems">"Hiermee kan de toepassing bestandssystemen koppelen en ontkoppelen voor verwisselbare opslagruimte."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"trilstand beheren"</string>
     <string name="permdesc_vibrate">"Hiermee kan de toepassing de trilstand beheren."</string>
     <string name="permlab_flashlight">"zaklamp bedienen"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Hiermee kunnen updatemeldingen voor locaties van de radio worden ingeschakeld/uitgeschakeld. Niet voor gebruik door normale toepassingen."</string>
     <string name="permlab_checkinProperties">"toegang tot checkin-eigenschappen"</string>
     <string name="permdesc_checkinProperties">"Hiermee wordt lees-/schrijftoegang gegeven tot eigenschappen die door de checkin-service zijn geüpload. Niet voor gebruik door normale toepassingen."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"telefoonstatus wijzigen"</string>
     <string name="permdesc_modifyPhoneState">"Hiermee kan de toepassing de telefoonfuncties van het apparaat beheren. Een toepassing met deze machtiging kan schakelen tussen netwerken, de radio van de telefoon in- of uitschakelen en dergelijke zonder dat u hiervan op de hoogte wordt gesteld."</string>
     <string name="permlab_readPhoneState">"telefoonstatus lezen"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Hiermee kan een toepassing de APN-instellingen, zoals proxy en poort, van elke APN wijzigen."</string>
     <string name="permlab_changeNetworkState">"netwerkverbinding wijzigen"</string>
     <string name="permdesc_changeNetworkState">"Hiermee kan een toepassing de verbindingsstatus van het netwerk wijzigen."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"Wi-Fi-status bekijken"</string>
     <string name="permdesc_accessWifiState">"Hiermee kan een toepassing informatie over de Wi-Fi-status bekijken."</string>
     <string name="permlab_changeWifiState">"Wi-Fi-status wijzigen"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"twaalf uur \'s middags"</string>
     <string name="Noon">"Twaalf uur \'s middags"</string>
     <string name="midnight">"middernacht"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"Plakken"</string>
     <string name="copyUrl">"URL kopiëren"</string>
     <string name="inputMethod">"Invoermethode"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Tekst bewerken"</string>
     <string name="low_internal_storage_view_title">"Weinig ruimte"</string>
     <string name="low_internal_storage_view_text">"Opslagruimte van telefoon raakt op."</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"Annuleren"</string>
     <string name="yes">"OK"</string>
     <string name="no">"Annuleren"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"AAN"</string>
     <string name="capital_off">"UIT"</string>
     <string name="whichApplication">"Actie voltooien met"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"Mediavolume"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Afspelen via Bluetooth"</string>
     <string name="volume_call">"Volume inkomende oproep"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Afspelen via Bluetooth"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Alarmvolume"</string>
     <string name="volume_notification">"Meldingsvolume"</string>
     <string name="volume_unknown">"Volume"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"Er is een probleem bij het gebruik van uw SD-kaart voor USB-opslag."</string>
     <string name="usb_storage_notification_title">"USB-verbinding"</string>
     <string name="usb_storage_notification_message">"Selecteer dit om bestanden naar/van uw computer te kopiëren."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Invoermethode selecteren"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"kandidaten"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-pl/strings.xml b/core/res/res/values-pl/strings.xml
index c3e3a46..03c4f8b 100644
--- a/core/res/res/values-pl/strings.xml
+++ b/core/res/res/values-pl/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Pozwala aplikacji na wymuszenie ponownego uruchomienia telefonu."</string>
     <string name="permlab_mount_unmount_filesystems">"montowanie i odmontowanie systemów plików"</string>
     <string name="permdesc_mount_unmount_filesystems">"Pozwala aplikacjom na podłączanie i odłączanie systemów plików w pamięciach przenośnych."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"kontrolowanie wibracji"</string>
     <string name="permdesc_vibrate">"Pozwala aplikacjom na kontrolowanie wibracji."</string>
     <string name="permlab_flashlight">"kontrolowanie latarki"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Pozwala włączyć/wyłączyć powiadomienia o aktualizacji położenia przez radio. Nie wykorzystywane przez normalne aplikacje."</string>
     <string name="permlab_checkinProperties">"dostęp do właściwości usługi rezerwacji"</string>
     <string name="permdesc_checkinProperties">"Pozwala na dostęp z uprawnieniami do odczytu/zapisu do właściwości przesłanych przez usługę rezerwacji. Nie wykorzystywane przez normalne aplikacje."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"zmiana stanu telefonu"</string>
     <string name="permdesc_modifyPhoneState">"Pozwala aplikacji na kontrolowanie funkcji telefonu w urządzeniu. Aplikacja z tymi uprawnieniami może przełączać sieci, włączać i wyłączać radio itp. bez informowania użytkownika."</string>
     <string name="permlab_readPhoneState">"czytanie stanu telefonu"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Pozwala aplikacji na zmianę ustawień APN, takich jak serwer proxy oraz port dowolnego APN."</string>
     <string name="permlab_changeNetworkState">"zmienianie połączeń sieci"</string>
     <string name="permdesc_changeNetworkState">"Pozwala aplikacji na zmianę stanu połączeń sieciowych."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"wyświetlanie stanu Wi-Fi"</string>
     <string name="permdesc_accessWifiState">"Pozwala aplikacji na wyświetlanie informacji o stanie Wi-Fi."</string>
     <string name="permlab_changeWifiState">"zmiana stanu Wi-Fi"</string>
@@ -333,7 +345,7 @@
     <!-- no translation found for permdesc_writeDictionary (2241256206524082880) -->
     <skip />
   <string-array name="phoneTypes">
-    <item>"Strona główna"</item>
+    <item>"Dom"</item>
     <item>"Komórka"</item>
     <item>"Praca"</item>
     <item>"Faks w pracy"</item>
@@ -343,19 +355,19 @@
     <item>"Niestandardowy"</item>
   </string-array>
   <string-array name="emailAddressTypes">
-    <item>"Strona główna"</item>
+    <item>"Dom"</item>
     <item>"Praca"</item>
     <item>"Inne"</item>
     <item>"Niestandardowy"</item>
   </string-array>
   <string-array name="postalAddressTypes">
-    <item>"Strona główna"</item>
+    <item>"Dom"</item>
     <item>"Praca"</item>
     <item>"Inny"</item>
     <item>"Niestandardowy"</item>
   </string-array>
   <string-array name="imAddressTypes">
-    <item>"Strona główna"</item>
+    <item>"Dom"</item>
     <item>"Praca"</item>
     <item>"Inne"</item>
     <item>"Niestandardowy"</item>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g>, <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>', '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"południe"</string>
     <string name="Noon">"Południe"</string>
     <string name="midnight">"północ"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"Wklej"</string>
     <string name="copyUrl">"Kopiuj adres URL"</string>
     <string name="inputMethod">"Metoda wejściowa"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Edytuj tekst"</string>
     <string name="low_internal_storage_view_title">"Mało miejsca"</string>
     <string name="low_internal_storage_view_text">"Maleje ilość dostępnej pamięci telefonu."</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"Anuluj"</string>
     <string name="yes">"OK"</string>
     <string name="no">"Anuluj"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"Włącz"</string>
     <string name="capital_off">"Wyłącz"</string>
     <string name="whichApplication">"Zakończ działanie, korzystając z"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"Głośność multimediów"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Odtwarzanie przez Bluetooth"</string>
     <string name="volume_call">"Głośność podczas połączenia"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Odtwarzanie przez Bluetooth"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Głośność alarmu"</string>
     <string name="volume_notification">"Głośność powiadomienia"</string>
     <string name="volume_unknown">"Głośność"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"Wystąpił problem z wykorzystaniem karty SD dla pamięci USB."</string>
     <string name="usb_storage_notification_title">"Połączenie przez USB"</string>
     <string name="usb_storage_notification_message">"Wybierz, aby skopiować pliki do/z komputera"</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Wybierz metodę wejściową"</string>
     <string name="fast_scroll_alphabet">"AĄBCĆDEĘFGHIJKLŁMNŃOÓPQRSŚTUVWXYZŹŻ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"kandydaci"</u></font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-ru/strings.xml b/core/res/res/values-ru/strings.xml
index 33efbf6..d25ab8d 100644
--- a/core/res/res/values-ru/strings.xml
+++ b/core/res/res/values-ru/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"Разрешает приложению принудительно перезагружать телефон."</string>
     <string name="permlab_mount_unmount_filesystems">"подключаться и отключаться от файловых систем"</string>
     <string name="permdesc_mount_unmount_filesystems">"Разрешает приложению подключаться и отключаться от файловых систем съемных устройств хранения."</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"управлять вибрацией"</string>
     <string name="permdesc_vibrate">"Разрешает приложению управлять вибровызовом."</string>
     <string name="permlab_flashlight">"управлять фонарем"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"Разрешает включение/отключение уведомлений о местоположении по радиосвязи. Не используется обычными приложениями."</string>
     <string name="permlab_checkinProperties">"открывать свойства проверки"</string>
     <string name="permdesc_checkinProperties">"Разрешает доступ на чтение и запись к свойствам, загруженным службой проверки. Не используется обычными приложениями."</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"изменять состояние телефона"</string>
     <string name="permdesc_modifyPhoneState">"Позволяет приложению управлять телефонными функциями устройства. Приложение с такими полномочиями может переключать сети, включать и выключать радиосвязь и т.д., не сообщая вам об этом."</string>
     <string name="permlab_readPhoneState">"считывать состояние телефона"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"Разрешает приложению изменять настройки APN, например прокси и порт любого APN."</string>
     <string name="permlab_changeNetworkState">"изменять подключение к сети"</string>
     <string name="permdesc_changeNetworkState">"Позволяет приложению изменять подключение к сети."</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"просматривать состояние Wi-Fi"</string>
     <string name="permdesc_accessWifiState">"Разрешает приложению просматривать сведения о состоянии Wi-Fi."</string>
     <string name="permlab_changeWifiState">"изменять состояние Wi-Fi"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>, <xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"полдень"</string>
     <string name="Noon">"Полдень"</string>
     <string name="midnight">"полночь"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"Вставить"</string>
     <string name="copyUrl">"Копировать URL"</string>
     <string name="inputMethod">"Способ ввода"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"Правка текста"</string>
     <string name="low_internal_storage_view_title">"Недостаточно места"</string>
     <string name="low_internal_storage_view_text">"В памяти телефона осталось мало места."</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"Отмена"</string>
     <string name="yes">"ОК"</string>
     <string name="no">"Отмена"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"ВКЛ"</string>
     <string name="capital_off">"ВЫКЛ"</string>
     <string name="whichApplication">"Выполнить действие с помощью"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"Громкость звука мультимедиа"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"Воспроизводится через Bluetooth"</string>
     <string name="volume_call">"Громкость звонка"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"Воспроизводится через Bluetooth"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"Громкость будильника"</string>
     <string name="volume_notification">"Громкость уведомления"</string>
     <string name="volume_unknown">"Громкость"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"Не удается использовать карту SD в качестве USB-хранилища."</string>
     <string name="usb_storage_notification_title">"Подключение через USB"</string>
     <string name="usb_storage_notification_message">"Выберите для копирования файлов на/с компьютера."</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"Выбор способа ввода"</string>
     <string name="fast_scroll_alphabet">"АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЫЭЮЯ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЫЭЮЯ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"кандидаты"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-zh-rCN/strings.xml b/core/res/res/values-zh-rCN/strings.xml
index cb13390..447fccd 100644
--- a/core/res/res/values-zh-rCN/strings.xml
+++ b/core/res/res/values-zh-rCN/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"允许应用程序强制手机重新引导。"</string>
     <string name="permlab_mount_unmount_filesystems">"装载和卸载文件系统"</string>
     <string name="permdesc_mount_unmount_filesystems">"允许应用程序装载和卸载文件系统以进行可移动存储。"</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"控制振动器"</string>
     <string name="permdesc_vibrate">"允许应用程序控制振动器。"</string>
     <string name="permlab_flashlight">"控制闪光灯"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"允许启用/禁用来自收音机的位置更新通知。普通应用程序不能使用此权限。"</string>
     <string name="permlab_checkinProperties">"访问检入属性"</string>
     <string name="permdesc_checkinProperties">"允许对检入服务上传的属性进行读/写访问。普通应用程序不能使用此权限。"</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"修改手机状态"</string>
     <string name="permdesc_modifyPhoneState">"允许应用程序控制设备的手机功能。具有此权限的应用程序可能会切换网络,打开和关闭手机收音机以及类似操作,而不会通知您。"</string>
     <string name="permlab_readPhoneState">"读取手机状态"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"允许应用程序修改 APN 设置,例如任何 APN 的代理和端口。"</string>
     <string name="permlab_changeNetworkState">"更改网络连接性"</string>
     <string name="permdesc_changeNetworkState">"允许应用程序更改状态网络连接性。"</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"查看 Wi-Fi 状态"</string>
     <string name="permdesc_accessWifiState">"允许应用程序查看有关 Wi-Fi 状态的信息。"</string>
     <string name="permlab_changeWifiState">"更改 Wi-Fi 状态"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="WEEKDAY">%2$s</xliff:g> <xliff:g id="TIME_RANGE">%1$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g> 年 <xliff:g id="MONTH">MMMM</xliff:g> 月 <xliff:g id="DAY">dd</xliff:g> 日"</string>
-    <string name="full_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g> 年 <xliff:g id="MONTH">MMMM</xliff:g> 月 <xliff:g id="DAY">dd</xliff:g> 日"</string>
-    <string name="medium_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g> 年 <xliff:g id="MONTH">MMM</xliff:g> 月 <xliff:g id="DAY">dd</xliff:g> 日"</string>
-    <string name="medium_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g> 年 <xliff:g id="DAY">dd</xliff:g> 月 <xliff:g id="MONTH">MMM</xliff:g> 日"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g>' 年 '<xliff:g id="MONTH">MMMM</xliff:g>' 月 '<xliff:g id="DAY">d</xliff:g>' 日'"</string>
+    <string name="full_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g>' 年 '<xliff:g id="MONTH">MMMM</xliff:g>' 月 '<xliff:g id="DAY">d</xliff:g>' 日'"</string>
+    <string name="medium_date_month_first">"<xliff:g id="YEAR">yyyy</xliff:g>' 年 '<xliff:g id="MONTH">MMM</xliff:g>' 月 '<xliff:g id="DAY">d</xliff:g>' 日'"</string>
+    <string name="medium_date_day_first">"<xliff:g id="YEAR">yyyy</xliff:g>' 年 '<xliff:g id="DAY">d</xliff:g>' 月 '<xliff:g id="MONTH">MMM</xliff:g>' 日'"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"中午"</string>
     <string name="Noon">"中午"</string>
     <string name="midnight">"午夜"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"粘贴"</string>
     <string name="copyUrl">"复制网址"</string>
     <string name="inputMethod">"输入方法"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"编辑文本"</string>
     <string name="low_internal_storage_view_title">"存储空间不足"</string>
     <string name="low_internal_storage_view_text">"手机存储空间在减少。"</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"取消"</string>
     <string name="yes">"正常"</string>
     <string name="no">"取消"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"开启"</string>
     <string name="capital_off">"关闭"</string>
     <string name="whichApplication">"使用以下内容完成操作"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"媒体音量"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"正通过蓝牙播放"</string>
     <string name="volume_call">"来电音量"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"正通过蓝牙播放"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"警告音量"</string>
     <string name="volume_notification">"通知音量"</string>
     <string name="volume_unknown">"音量"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"使用 SD 卡进行 USB 存储时出现问题。"</string>
     <string name="usb_storage_notification_title">"USB 已连接"</string>
     <string name="usb_storage_notification_message">"选择以将文件复制到计算机或从计算机复制文件。"</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"选择输入方法"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"候选人"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values-zh-rTW/strings.xml b/core/res/res/values-zh-rTW/strings.xml
index 758bf82..e97c142 100644
--- a/core/res/res/values-zh-rTW/strings.xml
+++ b/core/res/res/values-zh-rTW/strings.xml
@@ -262,6 +262,10 @@
     <string name="permdesc_reboot">"允許應用程式強制重開機。"</string>
     <string name="permlab_mount_unmount_filesystems">"掛載/卸載檔案系統"</string>
     <string name="permdesc_mount_unmount_filesystems">"允許應用程式掛載/卸載抽取式儲存設備的檔案系統。"</string>
+    <!-- no translation found for permlab_mount_format_filesystems (5523285143576718981) -->
+    <skip />
+    <!-- no translation found for permdesc_mount_format_filesystems (574060044906047386) -->
+    <skip />
     <string name="permlab_vibrate">"控制震動器"</string>
     <string name="permdesc_vibrate">"允許應用程式控制震動器。"</string>
     <string name="permlab_flashlight">"控制閃光燈"</string>
@@ -276,6 +280,10 @@
     <string name="permdesc_locationUpdates">"允許啟用/停用無線通訊位置更新通知。一般應用程式不會使用此功能。"</string>
     <string name="permlab_checkinProperties">"存取登機選項"</string>
     <string name="permdesc_checkinProperties">"允許讀寫登機服務上傳的資料。一般應用程式不會使用此功能。"</string>
+    <!-- no translation found for permlab_bindGadget (2519859363977647275) -->
+    <skip />
+    <!-- no translation found for permdesc_bindGadget (7865866514555126333) -->
+    <skip />
     <string name="permlab_modifyPhoneState">"修改手機狀態"</string>
     <string name="permdesc_modifyPhoneState">"允許應用程式控制電話功能。擁有此權限的程式可自行切換網路、開關無線通訊功能。"</string>
     <string name="permlab_readPhoneState">"讀取手機狀態"</string>
@@ -304,6 +312,10 @@
     <string name="permdesc_writeApnSettings">"允許應用程式修改 APN 設定,例如:Proxy 及 APN 的連接埠。"</string>
     <string name="permlab_changeNetworkState">"變更網路連線"</string>
     <string name="permdesc_changeNetworkState">"允許應用程式變更網路連線狀態。"</string>
+    <!-- no translation found for permlab_changeBackgroundDataSetting (1400666012671648741) -->
+    <skip />
+    <!-- no translation found for permdesc_changeBackgroundDataSetting (1001482853266638864) -->
+    <skip />
     <string name="permlab_accessWifiState">"檢視 Wi-Fi 狀態"</string>
     <string name="permdesc_accessWifiState">"允許應用程式檢視 Wi-Fi 狀態資訊。"</string>
     <string name="permlab_changeWifiState">"變更 Wi-Fi 狀態"</string>
@@ -546,12 +558,12 @@
     <!-- no translation found for relative_time (1818557177829411417) -->
     <skip />
     <string name="time_wday">"<xliff:g id="TIME_RANGE">%1$s</xliff:g>,<xliff:g id="WEEKDAY">%2$s</xliff:g>"</string>
-    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>,<xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="full_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMMM</xliff:g>,<xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g> <xliff:g id="DAY">dd</xliff:g>,<xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="medium_date_day_first">"<xliff:g id="DAY">dd</xliff:g> <xliff:g id="MONTH">MMM</xliff:g>,<xliff:g id="YEAR">yyyy</xliff:g>"</string>
-    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g> <xliff:g id="AMPM">a</xliff:g>"</string>
-    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>:<xliff:g id="MINUTE">mm</xliff:g>"</string>
+    <string name="full_date_month_first">"<xliff:g id="MONTH">MMMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>','<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="full_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMMM</xliff:g>','<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_month_first">"<xliff:g id="MONTH">MMM</xliff:g>' '<xliff:g id="DAY">d</xliff:g>','<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="medium_date_day_first">"<xliff:g id="DAY">d</xliff:g>' '<xliff:g id="MONTH">MMM</xliff:g>','<xliff:g id="YEAR">yyyy</xliff:g>"</string>
+    <string name="twelve_hour_time_format">"<xliff:g id="HOUR">h</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>' '<xliff:g id="AMPM">a</xliff:g>"</string>
+    <string name="twenty_four_hour_time_format">"<xliff:g id="HOUR">H</xliff:g>':'<xliff:g id="MINUTE">mm</xliff:g>"</string>
     <string name="noon">"中午"</string>
     <string name="Noon">"中午"</string>
     <string name="midnight">"午夜"</string>
@@ -679,6 +691,8 @@
     <string name="paste">"貼上"</string>
     <string name="copyUrl">"複製網址"</string>
     <string name="inputMethod">"輸入法"</string>
+    <!-- no translation found for addToDictionary (726256909274177272) -->
+    <skip />
     <string name="editTextMenuTitle">"編輯文字"</string>
     <string name="low_internal_storage_view_title">"儲存空間太少"</string>
     <string name="low_internal_storage_view_text">"手機儲存空間即將不足。"</string>
@@ -686,6 +700,8 @@
     <string name="cancel">"取消"</string>
     <string name="yes">"確定"</string>
     <string name="no">"取消"</string>
+    <!-- no translation found for dialog_alert_title (2049658708609043103) -->
+    <skip />
     <string name="capital_on">"開啟"</string>
     <string name="capital_off">"關閉"</string>
     <string name="whichApplication">"選取...完成動作"</string>
@@ -709,7 +725,8 @@
     <string name="volume_music">"媒體音量"</string>
     <string name="volume_music_hint_playing_through_bluetooth">"透過藍牙播放"</string>
     <string name="volume_call">"來電音量"</string>
-    <string name="volume_call_hint_playing_through_bluetooth">"透過藍牙播放"</string>
+    <!-- no translation found for volume_bluetooth_call (2002891926351151534) -->
+    <skip />
     <string name="volume_alarm">"鬧鐘音量"</string>
     <string name="volume_notification">"通知音量"</string>
     <string name="volume_unknown">"音量"</string>
@@ -745,8 +762,61 @@
     <string name="usb_storage_error_message">"把 SD 卡當成 USB 儲存裝置時發生問題。"</string>
     <string name="usb_storage_notification_title">"USB 已連接"</string>
     <string name="usb_storage_notification_message">"選取此項將檔案複製到電腦,或從電腦複製。"</string>
+    <!-- no translation found for usb_storage_stop_notification_title (2336058396663516017) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_notification_message (2591813490269841539) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_title (6014127947456185321) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_message (2390958966725232848) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_mount (1181858854166273345) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_button_unmount (3774611918660582898) -->
+    <skip />
+    <!-- no translation found for usb_storage_stop_error_message (3917317248440072084) -->
+    <skip />
+    <!-- no translation found for extmedia_format_title (8663247929551095854) -->
+    <skip />
+    <!-- no translation found for extmedia_format_message (3621369962433523619) -->
+    <skip />
+    <!-- no translation found for extmedia_format_button_format (4131064560127478695) -->
+    <skip />
     <string name="select_input_method">"選取輸入法"</string>
     <string name="fast_scroll_alphabet">"ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
     <string name="fast_scroll_numeric_alphabet">"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"</string>
-    <string name="candidates_style"><font fgcolor="#ff000000" bgcolor="#ff8080ff"><u>"candidates"</u>"u&gt;"</font></string>
+    <!-- no translation found for candidates_style (4333913089637062257) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_title (5457603418970994050) -->
+    <skip />
+    <!-- no translation found for ext_media_checking_notification_message (4747432538578886744) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_title (780477838241212997) -->
+    <skip />
+    <!-- no translation found for ext_media_nofs_notification_message (1312266820092958014) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_title (6410723906019100189) -->
+    <skip />
+    <!-- no translation found for ext_media_unmountable_notification_message (2679412884290061775) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_title (6872152882604407837) -->
+    <skip />
+    <!-- no translation found for ext_media_badremoval_notification_message (7260183293747448241) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_title (6729801130790616200) -->
+    <skip />
+    <!-- no translation found for ext_media_safe_unmount_notification_message (7613960686747592770) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_title (8902518030404381318) -->
+    <skip />
+    <!-- no translation found for ext_media_nomedia_notification_message (4205117227342822275) -->
+    <skip />
+    <!-- no translation found for activity_list_empty (4168820609403385789) -->
+    <skip />
+    <!-- no translation found for permlab_pkgUsageStats (8787352074326748892) -->
+    <skip />
+    <!-- no translation found for permdesc_pkgUsageStats (891553695716752835) -->
+    <skip />
+    <!-- no translation found for tutorial_double_tap_to_zoom_message (9111326385548696308) -->
+    <skip />
 </resources>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 5477538..3f21303 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -261,6 +261,14 @@
              actual instance is shown to the user. -->
         <attr name="windowDisablePreview" format="boolean" />
         
+        <!-- Flag indicating that this window should not be displayed at all.
+             The default value is false; if set to true, and this window is
+             the main window of an Activity, then it will never actually
+             be added to the window manager.  This means that your activity
+             must immediately quit without waiting for user interaction,
+             because there will be no such interaction coming. -->
+        <attr name="windowNoDisplay" format="boolean" />
+        
         <!-- ============ -->
         <!-- Alert Dialog styles -->
         <!-- ============ -->
@@ -336,6 +344,8 @@
         <attr name="radioButtonStyle" format="reference" />
         <!-- Default ScrollView style. -->
         <attr name="scrollViewStyle" format="reference" />
+        <!-- Default HorizontalScrollView style. -->
+        <attr name="horizontalScrollViewStyle" format="reference" />
         <!-- Default Spinner style. -->
         <attr name="spinnerStyle" format="reference" />
         <!-- Default Star style. -->
@@ -466,13 +476,19 @@
              {@link android.text.InputType#TYPE_TEXT_FLAG_AUTO_COMPLETE}. -->
         <flag name="textAutoComplete" value="0x00010001" />
         <!-- Can be combined with <var>text</var> and its variations to
-             allow multiple lines of text in the field.  Corresponds to
+             allow multiple lines of text in the field.  If this flag is not set,
+             the text field will be constrained to a single line.  Corresponds to
              {@link android.text.InputType#TYPE_TEXT_FLAG_MULTI_LINE}. -->
         <flag name="textMultiLine" value="0x00020001" />
         <!-- Can be combined with <var>text</var> and its variations to
+             indicate that though the regular text view should not be multiple
+             lines, and IME should provide multiple lines if it can.  Corresponds to
+             {@link android.text.InputType#TYPE_TEXT_FLAG_IME_MULTI_LINE}. -->
+        <flag name="textImeMultiLine" value="0x00040001" />
+        <!-- Can be combined with <var>text</var> and its variations to
              indicate that a search string is being entered.  Corresponds to
              {@link android.text.InputType#TYPE_TEXT_FLAG_SEARCH}. -->
-        <flag name="textSearch" value="0x00040001" />
+        <flag name="textSearch" value="0x00080001" />
         <!-- Text that will be used as a URI.  Corresponds to
              {@link android.text.InputType#TYPE_CLASS_TEXT} |
              {@link android.text.InputType#TYPE_TEXT_VARIATION_URI}. -->
@@ -485,27 +501,26 @@
              {@link android.text.InputType#TYPE_CLASS_TEXT} |
              {@link android.text.InputType#TYPE_TEXT_VARIATION_EMAIL_SUBJECT}. -->
         <flag name="textEmailSubject" value="0x00000031" />
-        <!-- Text that is being supplied as the content of an e-mail.  Corresponds to
+        <!-- Text that is the content of a short message.  Corresponds to
              {@link android.text.InputType#TYPE_CLASS_TEXT} |
-             {@link android.text.InputType#TYPE_TEXT_VARIATION_EMAIL_CONTENT}. -->
-        <flag name="textEmailContent" value="0x00000041" />
+             {@link android.text.InputType#TYPE_TEXT_VARIATION_SHORT_MESSAGE}. -->
+        <flag name="textShortMessage" value="0x00000041" />
+        <!-- Text that is the content of a long message.  Corresponds to
+             {@link android.text.InputType#TYPE_CLASS_TEXT} |
+             {@link android.text.InputType#TYPE_TEXT_VARIATION_LONG_MESSAGE}. -->
+        <flag name="textLongMessage" value="0x00000051" />
         <!-- Text that is the name of a person.  Corresponds to
              {@link android.text.InputType#TYPE_CLASS_TEXT} |
              {@link android.text.InputType#TYPE_TEXT_VARIATION_PERSON_NAME}. -->
-        <flag name="textPersonName" value="0x00000051" />
+        <flag name="textPersonName" value="0x00000061" />
         <!-- Text that is being supplied as a postal mailing address.  Corresponds to
              {@link android.text.InputType#TYPE_CLASS_TEXT} |
              {@link android.text.InputType#TYPE_TEXT_VARIATION_POSTAL_ADDRESS}. -->
-        <flag name="textPostalAddress" value="0x00000061" />
+        <flag name="textPostalAddress" value="0x00000071" />
         <!-- Text that is a password.  Corresponds to
              {@link android.text.InputType#TYPE_CLASS_TEXT} |
              {@link android.text.InputType#TYPE_TEXT_VARIATION_PASSWORD}. -->
-        <flag name="textPassword" value="0x00000071" />
-        <!-- Text that will be used for free form search strings.  Corresponds to
-             {@link android.text.InputType#TYPE_CLASS_TEXT} |
-             {@link android.text.InputType#TYPE_TEXT_VARIATION_SEARCH_STRING} |
-             {@link android.text.InputType#TYPE_TEXT_FLAG_SEARCH}. -->
-        <flag name="textSearchString" value="0x00040081" />
+        <flag name="textPassword" value="0x00000081" />
         <!-- Text that is being supplied as text in a web form.  Corresponds to
              {@link android.text.InputType#TYPE_CLASS_TEXT} |
              {@link android.text.InputType#TYPE_TEXT_VARIATION_WEB_EDIT_TEXT}. -->
@@ -767,6 +782,7 @@
         <attr name="windowAnimationStyle" />
         <attr name="windowSoftInputMode" />
         <attr name="windowDisablePreview" />
+        <attr name="windowNoDisplay" />
         <attr name="textColor" />
         <attr name="backgroundDimEnabled" />
         <attr name="backgroundDimAmount" />
@@ -1673,9 +1689,15 @@
              instead of letting it wrap onto multiple lines, and advances
              focus instead of inserting a newline when you press the
              enter key.  Note: for editable text views, it is better
-             to set this using the textMultiLine flag in inputType;
-             if both this and inputType are supplied, the input
-             type overrides the value here. -->
+             to control this using the textMultiLine flag in the inputType
+             attribute.  (If both singleLine and inputType are supplied,
+             the inputType flags will override the value of singleLine.)
+             {@deprecated This attribute is deprecated and is replaced by the textMultiLine flag
+             in the inputType attribute.  Use caution when altering existing layouts, as the 
+             default value of singeLine is false (multi-line mode), but if you specify any 
+             value for inputType, the default is single-line mode.  (If both singleLine and 
+             inputType attributes are found,  the inputType flags will override the value of 
+             singleLine.) } -->
         <attr name="singleLine" format="boolean" />
         <!-- {@deprecated Use state_enabled instead.} -->
         <attr name="enabled" format="boolean" />
@@ -1839,6 +1861,10 @@
         <!-- Defines whether the scrollview should stretch its content to fill the viewport. -->
         <attr name="fillViewport" format="boolean" />
     </declare-styleable>
+    <declare-styleable name="HorizontalScrollView">
+        <!-- Defines whether the scrollview should stretch its content to fill the viewport. -->
+        <attr name="fillViewport" />
+    </declare-styleable>
     <declare-styleable name="Spinner">
         <!-- The prompt to display when the spinner's dialog is shown. -->
         <attr name="prompt" format="reference" />
@@ -1936,10 +1962,10 @@
             Accommodates top margin. -->
         <attr name="layout_alignParentTop" format="boolean" />
         <!-- If true, makes the right edge of this view match the right edge of the parent.
-            Accommodates top margin. -->
+            Accommodates right margin. -->
         <attr name="layout_alignParentRight" format="boolean" />
-        <!-- f true, makes the bottom edge of this view match the bottom edge of the parent.
-            Accommodates top margin. -->
+        <!-- If true, makes the bottom edge of this view match the bottom edge of the parent.
+            Accommodates bottom margin. -->
         <attr name="layout_alignParentBottom" format="boolean" />
         <!-- If true, centers this child horizontally and vertically within its parent. -->
         <attr name="layout_centerInParent" format="boolean" />
@@ -2513,6 +2539,43 @@
                values are not suitable for user inspection and editing. -->
           <flag name="queryRewriteFromText" value="0x20" />
         </attr>
+        
+        <!-- Voice search features are controlled by mode bits in this field.  Omitting
+            this field, or setting to zero, provides default behavior.
+            If showVoiceSearchButton is set, then launchWebSearch or launchRecognizer must
+            also be set.  <i>Optional attribute.</i> 
+        -->
+        <attr name="voiceSearchMode">
+          <!-- If set, display a voice search button.  This only takes effect if voice search is
+               available on the device. -->
+          <flag name="showVoiceSearchButton" value="0x01" />
+          <!-- If set, the voice search button will take the user directly to a built-in
+               voice web search activity.  Most applications will not use this flag, as it
+               will take the user away from your searchable activity. -->
+          <flag name="launchWebSearch" value="0x02" />
+          <!-- If set, the voice search button will take the user directly to a built-in
+               voice recording activity.  This activity will prompt the user to speak,
+               transcribe the spoke text, and forward the resulting query text to your
+               searchable activity, just as if the user had typed it into the search UI. -->
+          <flag name="launchRecognizer" value="0x04" />
+        </attr>
+
+        <!-- If provided, this specifies the language model that should be used by the
+             voice recognition system.  See 
+             {@link android.speech.RecognizerIntent#EXTRA_LANGUAGE_MODEL } for more information. 
+             If not provided, the default value 
+             {@link android.speech.RecognizerIntent#LANGUAGE_MODEL_FREE_FORM } will be used. -->
+        <attr name="voiceLanguageModel" format="string" />
+        <!-- If provided, this specifies a prompt that will be displayed during voice input. -->
+        <attr name="voicePromptText" format="string" />
+        <!-- If provided, this specifies the spoken language to be expected, and that it will be
+             different than the one set in the {@link java.util.Locale#getDefault()}. -->
+        <attr name="voiceLanguage" format="string" />
+        <!-- If provided, enforces the maximum number of results to return, including the "best"
+             result which will always be provided as the SEARCH intent's primary query.  Must be one
+             or greater.  If not provided, the recognizer will choose how many results to return. 
+             -->
+        <attr name="voiceMaxResults" format="integer" />
 
         <!-- If provided, this is the trigger indicating that the searchable activity
             provides suggestions as well.  The value must be a fully-qualified content provider
@@ -2948,6 +3011,7 @@
         <attr name="minHeight"/>
         <attr name="updatePeriodMillis" format="integer" />
         <attr name="initialLayout" format="reference" />
+        <attr name="configure" format="string" />
     </declare-styleable>
     
     
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index e2151410..f717196 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -87,19 +87,19 @@
     <!-- Specify a permission that a client is required to have in order to
     	 use the associated object.  If the client does not hold the named
     	 permission, its request will fail.  See the
-         <a href="{@docRoot}devel/security.html">Security Model</a>
+         <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions. -->
     <attr name="permission" format="string" />
     
     <!-- A specific {@link android.R.attr#permission} name for read-only
          access to a {@link android.content.ContentProvider}.  See the
-         <a href="{@docRoot}devel/security.html">Security Model</a>
+         <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions. -->
     <attr name="readPermission" format="string" />
     
     <!-- A specific {@link android.R.attr#permission} name for write
          access to a {@link android.content.ContentProvider}.  See the
-         <a href="{@docRoot}devel/security.html">Security Model</a>
+         <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions. -->
     <attr name="writePermission" format="string" />
     
@@ -376,7 +376,7 @@
     <attr name="priority" format="integer" />
     
     <!-- Specify how an activity should be launched.  See the
-         <a href="{@docRoot}intro/appmodel.html">Application Model</a>
+         <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals</a>
          documentation for important information on how these options impact
          the behavior of your application.
          
@@ -413,7 +413,7 @@
             of the activity being started at the top of the stack, it will
             receive the Intent as described there (without the
             FLAG_ACTIVITY_BROUGHT_TO_FRONT flag set).  See the
-            <a href="{@docRoot}intro/appmodel.html">Application Model</a>
+            <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals</a>
             documentation for more details on tasks.-->
         <enum name="singleTask" value="2" />
         <!-- Only allow one instance of this activity to ever be 
@@ -424,7 +424,7 @@
             method called.  If this 
             activity tries to start a new activity, that new activity will be 
             launched in a separate task.  See the
-            <a href="{@docRoot}intro/appmodel.html">Application Model</a>
+            <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals</a>
             documentation for more details on tasks. -->
         <enum name="singleInstance" value="3" />
     </attr>
@@ -633,7 +633,7 @@
     <!-- The <code>permission</code> tag declares a security permission that can be
          used to control access from other packages to specific components or
          features in your package (or other packages).  See the
-         <a href="{@docRoot}devel/security.html">Security Model</a>
+         <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions.
          
          <p>This appears as a child tag of the root
@@ -705,7 +705,7 @@
     <!-- The <code>uses-permission</code> tag requests a
          {@link #AndroidManifestPermission &lt;permission&gt;} that the containing
          package must be granted in order for it to operate correctly.
-         See the <a href="{@docRoot}devel/security.html">Security Model</a>
+         See the <a href="{@docRoot}guide/topics/security/security.html">Security and Permissions</a>
          document for more information on permissions.  Also available is a
          {@link android.Manifest.permission list of permissions} included
          with the base platform.
diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml
index 59f3a8f..3fb7e86 100644
--- a/core/res/res/values/colors.xml
+++ b/core/res/res/values/colors.xml
@@ -19,7 +19,7 @@
 -->
 <resources>
 	<drawable name="screen_background_light">#ffffffff</drawable>
-	<drawable name="screen_background_dark">#ff191919</drawable>
+	<drawable name="screen_background_dark">#ff262626</drawable>
     <drawable name="status_bar_closed_default_background">#ff000000</drawable>
     <drawable name="status_bar_opened_default_background">#ff000000</drawable>
     <drawable name="search_bar_default_color">#ff000000</drawable>
@@ -28,7 +28,7 @@
     <color name="white">#ffffffff</color>
     <color name="black">#ff000000</color>
     <color name="transparent">#00000000</color>
-    <color name="background_dark">#ff191919</color>
+    <color name="background_dark">#ff262626</color>
     <color name="bright_foreground_dark">#ffffffff</color>
     <color name="bright_foreground_dark_disabled">#80ffffff</color>
     <color name="bright_foreground_dark_inverse">#ff000000</color>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
new file mode 100644
index 0000000..f370151
--- /dev/null
+++ b/core/res/res/values/config.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2009, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+-->
+
+<!-- These resources are around just to allow their values to be customized
+     for different hardware and product builds. -->
+<resources>
+    <!-- Flag indicating whether the surface flinger has limited
+         alpha compositing functionality in hardware.  If set, the window
+         manager will disable alpha trasformation in animations where not
+         strictly needed. -->
+    <bool name="config_sf_limitedAlpha">false</bool>
+</resources>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 2abb26f..6461460a 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -26,4 +26,6 @@
          will be displayed in the app launcher and elsewhere. -->
     <dimen name="app_icon_size">48dip</dimen>
     <dimen name="toast_y_offset">64dip</dimen>
+    <!-- Height of the status bar -->
+    <dimen name="status_bar_height">25dip</dimen>
 </resources>
diff --git a/core/res/res/values/ids.xml b/core/res/res/values/ids.xml
index c5dbfd8..7e9b7ea 100644
--- a/core/res/res/values/ids.xml
+++ b/core/res/res/values/ids.xml
@@ -59,9 +59,10 @@
   <item type="id" name="copy" />
   <item type="id" name="paste" />
   <item type="id" name="copyUrl" />
-  <item type="id" name="inputMethod" />
+  <item type="id" name="switchInputMethod" />
   <item type="id" name="keyboardView" />
   <item type="id" name="button_close" />
-  <item type="id" name="selectText" />
+  <item type="id" name="startSelectingText" />
   <item type="id" name="stopSelectingText" />
+  <item type="id" name="addToDictionary" />
 </resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index c757c56..1031585 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -937,6 +937,7 @@
      =============================================================== -->
   <eat-comment />
 
+  <public type="attr" name="windowNoDisplay" id="0x0101021e" />
   <public type="attr" name="backgroundDimEnabled" id="0x0101021f" />
   <public type="attr" name="inputType" id="0x01010220" />
   <public type="attr" name="isDefault" id="0x01010221" />
@@ -964,30 +965,42 @@
   <public type="attr" name="keyPreviewLayout" id="0x01010237" />
   <public type="attr" name="keyPreviewOffset" id="0x01010238" />
   <public type="attr" name="keyPreviewHeight" id="0x01010239" />
-  <public type="attr" name="verticalCorrection" id="0x01010240" />
-  <public type="attr" name="popupLayout" id="0x01010241" />
-  <public type="attr" name="state_long_pressable" id="0x01010242" />
-  <public type="attr" name="keyWidth" id="0x01010243" />
-  <public type="attr" name="keyHeight" id="0x01010244" />
-  <public type="attr" name="horizontalGap" id="0x01010245" />
-  <public type="attr" name="verticalGap" id="0x01010246" />
-  <public type="attr" name="rowEdgeFlags" id="0x01010247" />
-  <public type="attr" name="codes" id="0x01010248" />
-  <public type="attr" name="popupKeyboard" id="0x01010249" />
-  <public type="attr" name="popupCharacters" id="0x0101024a" />
-  <public type="attr" name="keyEdgeFlags" id="0x0101024b" />
-  <public type="attr" name="isModifier" id="0x0101024c" />
-  <public type="attr" name="isSticky" id="0x0101024d" />
-  <public type="attr" name="isRepeatable" id="0x0101024e" />
-  <public type="attr" name="iconPreview" id="0x0101024f" />
-  <public type="attr" name="keyOutputText" id="0x01010250" />
-  <public type="attr" name="keyLabel" id="0x01010251" />
-  <public type="attr" name="keyIcon" id="0x01010252" />
-  <public type="attr" name="keyboardMode" id="0x01010253" />
-  <public type="attr" name="isScrollContainer" id="0x01010254" />
-  <public type="attr" name="fillEnabled" id="0x01010255" />
-  <public type="attr" name="updatePeriodMillis" id="0x01010256" />
-  <public type="attr" name="initialLayout" id="0x01010257" />
+  <public type="attr" name="verticalCorrection" id="0x0101023a" />
+  <public type="attr" name="popupLayout" id="0x0101023b" />
+  <public type="attr" name="state_long_pressable" id="0x0101023c" />
+  <public type="attr" name="keyWidth" id="0x0101023d" />
+  <public type="attr" name="keyHeight" id="0x0101023e" />
+  <public type="attr" name="horizontalGap" id="0x0101023f" />
+  <public type="attr" name="verticalGap" id="0x01010240" />
+  <public type="attr" name="rowEdgeFlags" id="0x01010241" />
+  <public type="attr" name="codes" id="0x01010242" />
+  <public type="attr" name="popupKeyboard" id="0x01010243" />
+  <public type="attr" name="popupCharacters" id="0x01010244" />
+  <public type="attr" name="keyEdgeFlags" id="0x01010245" />
+  <public type="attr" name="isModifier" id="0x01010246" />
+  <public type="attr" name="isSticky" id="0x01010247" />
+  <public type="attr" name="isRepeatable" id="0x01010248" />
+  <public type="attr" name="iconPreview" id="0x01010249" />
+  <public type="attr" name="keyOutputText" id="0x0101024a" />
+  <public type="attr" name="keyLabel" id="0x0101024b" />
+  <public type="attr" name="keyIcon" id="0x0101024c" />
+  <public type="attr" name="keyboardMode" id="0x0101024d" />
+  <public type="attr" name="isScrollContainer" id="0x0101024e" />
+  <public type="attr" name="fillEnabled" id="0x0101024f" />
+  <public type="attr" name="updatePeriodMillis" id="0x01010250" />
+  <public type="attr" name="initialLayout" id="0x01010251" />
+  <public type="attr" name="voiceSearchMode" id="0x01010252" />
+  <public type="attr" name="voiceLanguageModel" id="0x01010253" />
+  <public type="attr" name="voicePromptText" id="0x01010254" />
+  <public type="attr" name="voiceLanguage" id="0x01010255" />
+  <public type="attr" name="voiceMaxResults" id="0x01010256" />
+  <public type="attr" name="bottomOffset" id="0x01010257" />
+  <public type="attr" name="topOffset" id="0x01010258" />
+  <public type="attr" name="allowSingleTap" id="0x01010259" />
+  <public type="attr" name="handle" id="0x0101025a" />
+  <public type="attr" name="content" id="0x0101025b" />
+  <public type="attr" name="animateOnClick" id="0x0101025c" />
+  <public type="attr" name="configure" id="0x0101025d" />
 
   <!-- The part of the UI shown by an
        {@link android.inputmethodservice.InputMethodService} that contains the
@@ -1022,7 +1035,7 @@
   <!-- Context menu ID for the "Input Method" menu item to being up the
        input method picker dialog, allowing the user to switch to another
        input method. -->
-  <public type="id" name="inputMethod" id="0x01020024" />
+  <public type="id" name="switchInputMethod" id="0x01020024" />
   <!-- View ID of the text editor inside of an extracted text layout. -->
   <public type="id" name="inputExtractEditText" id="0x01020025" />
 
@@ -1032,10 +1045,20 @@
   <!-- View ID of a {@link android.view.View} to close a popup keyboard -->
   <public type="id" name="button_close" id="0x01020027" />
 
+  <!-- Menu ID to perform a "start selecting text" operation. -->
+  <public type="id" name="startSelectingText" id="0x01020028" />
+  <!-- Menu ID to perform a "stop selecting text" operation. -->
+  <public type="id" name="stopSelectingText" id="0x01020029" />
+  <!-- Menu ID to perform a "add to dictionary" operation. -->
+  <public type="id" name="addToDictionary" id="0x0102002a" />
+  
   <public type="style" name="Theme.InputMethod" id="0x01030054" />
   <public type="style" name="Theme.NoDisplay" id="0x01030055" />
   <public type="style" name="Animation.InputMethod" id="0x01030056" />
   <public type="style" name="Widget.KeyboardView" id="0x01030057" />
+  <public type="style" name="ButtonBar" id="0x01030058" />
+  
+  <public type="string" name="dialog_alert_title" id="0x01040014" />
 
   <public type="drawable" name="emo_im_angel"               id="0x010800a4" />
   <public type="drawable" name="emo_im_cool"                id="0x010800a5" />
@@ -1054,4 +1077,12 @@
   <public type="drawable" name="emo_im_winking"             id="0x010800b2" />
   <public type="drawable" name="emo_im_wtf"                 id="0x010800b3" />
   <public type="drawable" name="emo_im_yelling"             id="0x010800b4" />
+  
+  <public type="drawable" name="ic_btn_speak_now" id="0x010800b5" />
+
+  <!--  Drawable to use as a background for separators on a list with a dark background -->
+  <public type="drawable" name="dark_header" id="0x010800b6" />
+
+  <!--  Drawable to use as a background for a taller version of the titlebar -->
+  <public type="drawable" name="title_bar_tall" id="0x010800b7" />
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 978a024..4700b93 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -778,6 +778,11 @@
         unmount filesystems for removable storage.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permlab_mount_format_filesystems">format external storage</string>
+    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permdesc_mount_format_filesystems">Allows the application to format removable storage.</string>
+
+    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_vibrate">control vibrator</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permdesc_vibrate">Allows the application to control
@@ -824,6 +829,15 @@
         properties uploaded by the checkin service.  Not for use by normal
         applications.</string>
 
+
+    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permlab_bindGadget">choose gadgets</string>
+    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permdesc_bindGadget">Allows the application to tell the system
+        which gadgets can be used by which application.  With this permission,
+        applications can give access to personal data to other applications.
+        Not for use by normal applications.</string>
+
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_modifyPhoneState">modify phone state</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
@@ -915,6 +929,12 @@
       the state network connectivity.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permlab_changeBackgroundDataSetting">change background data usage setting</string>
+    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permdesc_changeBackgroundDataSetting">Allows an application to change
+      the background data usage setting.</string>
+
+    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_accessWifiState">view Wi-Fi state</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permdesc_accessWifiState">Allows an application to view
@@ -1502,50 +1522,38 @@
     <!-- Date format string used in contexts where the user has said they
          want the month first, as used in the USA, with the month fully
          spelled out.  You can remove the comma or add a period,
-         or make other punctuation changes appropriate for your locale.
-         If you need to add letters, put apostrophes around them to keep
-         them from being interpreted as format characters. -->
-    <string name="full_date_month_first"><xliff:g id="month" example="December">MMMM</xliff:g> <xliff:g id="day" example="31">dd</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
+         or make other punctuation changes appropriate for your locale. -->
+    <string name="full_date_month_first" format="date"><xliff:g id="month" example="December">MMMM</xliff:g> <xliff:g id="day" example="31">d</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
 
     <!-- Date format string used in contexts where the user has said they
          want the day of the month first, as used in Europe, with the month
          fully spelled out.  You can remove the comma or add a period,
-         or make other punctuation changes appropriate for your locale.
-         If you need to add letters, put apostrophes around them to keep
-         them from being interpreted as format characters. -->
-    <string name="full_date_day_first"><xliff:g id="day" example="31">dd</xliff:g> <xliff:g id="month" example="December">MMMM</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
+         or make other punctuation changes appropriate for your locale. -->
+    <string name="full_date_day_first" format="date"><xliff:g id="day" example="31">d</xliff:g> <xliff:g id="month" example="December">MMMM</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
 
     <!-- Date format string used in contexts where the user has said they
          want the month first, as used in the USA, with the month
          abbreviated.  You can remove the comma or add a period,
-         or make other punctuation changes appropriate for your locale.
-         If you need to add letters, put apostrophes around them to keep
-         them from being interpreted as format characters. -->
-    <string name="medium_date_month_first"><xliff:g id="month" example="Dec.">MMM</xliff:g> <xliff:g id="day" example="31">dd</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
+         or make other punctuation changes appropriate for your locale. -->
+    <string name="medium_date_month_first" format="date"><xliff:g id="month" example="Dec.">MMM</xliff:g> <xliff:g id="day" example="31">d</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
 
     <!-- Date format string used in contexts where the user has said they
          want the day of the month first, as used in Europe, with the month
          abbreviated.  You can remove the comma or add a period,
-         or make other punctuation changes appropriate for your locale.
-         If you need to add letters, put apostrophes around them to keep
-         them from being interpreted as format characters. -->
-    <string name="medium_date_day_first"><xliff:g id="day" example="31">dd</xliff:g> <xliff:g id="month" example="December">MMM</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
+         or make other punctuation changes appropriate for your locale. -->
+    <string name="medium_date_day_first" format="date"><xliff:g id="day" example="31">d</xliff:g> <xliff:g id="month" example="December">MMM</xliff:g>, <xliff:g id="year" example="1972">yyyy</xliff:g></string>
 
     <!-- Time format string used in the status bar when the user has said they
          want a 12-hour clock with AM and PM.
          You can remove the colon
-         or make other punctuation changes appropriate for your locale.
-         If you need to add letters, put apostrophes around them to keep
-         them from being interpreted as format characters. -->
-    <string name="twelve_hour_time_format"><xliff:g id="hour" example="11">h</xliff:g>:<xliff:g id="minute" example="59">mm</xliff:g> <xliff:g id="ampm" example="AM">a</xliff:g></string>
+         or make other punctuation changes appropriate for your locale. -->
+    <string name="twelve_hour_time_format" format="date"><xliff:g id="hour" example="11">h</xliff:g>:<xliff:g id="minute" example="59">mm</xliff:g> <xliff:g id="ampm" example="AM">a</xliff:g></string>
 
     <!-- Time format string used in the status bar when the user has said they
          want a 24-hour clock.
          You can remove the colon
-         or make other punctuation changes appropriate for your locale.
-         If you need to add letters, put apostrophes around them to keep
-         them from being interpreted as format characters. -->
-    <string name="twenty_four_hour_time_format"><xliff:g id="hour" example="23">H</xliff:g>:<xliff:g id="minute" example="59">mm</xliff:g></string>
+         or make other punctuation changes appropriate for your locale. -->
+    <string name="twenty_four_hour_time_format" format="date"><xliff:g id="hour" example="23">H</xliff:g>:<xliff:g id="minute" example="59">mm</xliff:g></string>
 
     <!-- Quoted name for 12pm, lowercase -->
     <string name="noon">"noon"</string>
@@ -2020,6 +2028,10 @@
     <!-- EditText context menu -->
     <string name="inputMethod">Input Method</string>
 
+    <!-- Item on EditText context menu, used to add a word to the
+         input method dictionary. -->
+    <string name="addToDictionary">"Add \"%s\" to dictionary</string>
+
     <!-- Title for EditText context menu -->
     <string name="editTextMenuTitle">Edit text</string>
 
@@ -2036,6 +2048,9 @@
     <string name="yes">OK</string>
     <!-- Preference framework strings. -->
     <string name="no">Cancel</string>
+    <!-- This is the generic "attention" string to be used in attention dialogs.  Typically
+         combined with setIcon(android.R.drawable.ic_dialog_alert) -->
+    <string name="dialog_alert_title">Attention</string>
 
     <!-- Default text for a button that can be toggled on and off. -->
     <string name="capital_on">ON</string>
@@ -2090,8 +2105,8 @@
     <string name="volume_music_hint_playing_through_bluetooth">Playing through Bluetooth</string>
     <!-- Title of the dialog where the user is adjusting the phone call volume -->
     <string name="volume_call">In-call volume</string>
-    <!-- Hint shown in the volume toast to inform the user that the in-call audio is playing through Bluetooth. -->
-    <string name="volume_call_hint_playing_through_bluetooth">Playing through Bluetooth</string>
+    <!-- Title of the dialog where the user is adjusting the phone call volume when connected on bluetooth-->
+    <string name="volume_bluetooth_call">Bluetooth in-call volume</string>
     <!-- Title of the dialog where the user is adjusting the audio volume for alarms -->
     <string name="volume_alarm">Alarm volume</string>
     <!-- Title of the dialog where the user is adjusting the audio volume for notifications -->
@@ -2165,12 +2180,38 @@
     <string name="usb_storage_button_mount">Mount</string>
     <!-- See USB_STORAGE.   This is the button text to ignore the plugging in of the phone.. -->
     <string name="usb_storage_button_unmount">Don\'t mount</string>
-    <!-- See USB_STORAGE_DIALOG.  IF there was an error mounting, this is hte text. --> 
+    <!-- See USB_STORAGE_DIALOG.  If there was an error mounting, this is the text. --> 
     <string name="usb_storage_error_message">There is a problem using your SD card for USB storage.</string>
-    <!-- USB_STORAGE: When the user connects the phone to a computer via USB, we show a notification asking if he wnats to share files across.  This is the title -->
+    <!-- USB_STORAGE: When the user connects the phone to a computer via USB, we show a notification asking if he wants to share files across.  This is the title -->
     <string name="usb_storage_notification_title">USB connected</string>
     <!-- See USB_STORAGE. This is the message. -->
     <string name="usb_storage_notification_message">Select to copy files to/from your computer.</string>
+    <!-- USB_STORAGE_STOP: While USB storage is enabled, we show a notification dialog asking if he wants to stop. This is the title -->
+    <string name="usb_storage_stop_notification_title">Turn off USB storage</string>
+    <!-- See USB_STORAGE. This is the message. -->
+    <string name="usb_storage_stop_notification_message">Select to turn off USB storage.</string>
+
+    <!-- USB storage stop dialog strings -->
+    <!-- This is the label for the activity, and should never be visible to the user. -->
+    <!-- See USB_STORAGE_STOP.  USB_STORAGE_STOP_DIALOG:  After the user selects the notification, a dialog is shown asking if he wants to stop usb storage.  This is the title. -->
+    <string name="usb_storage_stop_title">Turn off USB storage</string>
+    <!-- See USB_STORAGE_STOP.    This is the message. -->
+    <string name="usb_storage_stop_message">Before turning off USB storage, make sure you have unmounted on the USB host. Select \"Turn Off\" to turn off USB storage.</string>
+    <!-- See USB_STORAGE_STOP.    This is the button text to stop usb storage. -->
+    <string name="usb_storage_stop_button_mount">Turn Off</string>
+    <!-- See USB_STORAGE_STOP.   This is the button text to cancel stoping usb storage. -->
+    <string name="usb_storage_stop_button_unmount">Cancel</string>
+    <!-- See USB_STORAGE_STOP_DIALOG.  If there was an error stopping, this is the text. --> 
+    <string name="usb_storage_stop_error_message">We've encountered a problem turning off USB storage. Check to make sure you have unmounted the USB host, then try again.</string>
+
+    <!-- External media format dialog strings -->
+    <!-- This is the label for the activity, and should never be visible to the user. -->
+    <!-- See EXTMEDIA_FORMAT.  EXTMEDIA_FORMAT_DIALOG:  After the user selects the notification, a dialog is shown asking if he wants to format the SD card.  This is the title. -->
+    <string name="extmedia_format_title">Format SD card</string>
+    <!-- See EXTMEDIA_FORMAT.   This is the message. -->
+    <string name="extmedia_format_message">Are you sure you want to format the SD card? All data on your card will be lost.</string>
+    <!-- See EXTMEDIA_FORMAT.    This is the button text to format the sd card. -->
+    <string name="extmedia_format_button_format">Format</string>
 
     <!-- Used to replace %s in urls retreived from the signin server with locales.  For Some        -->
     <!-- devices we don't support all the locales we ship to and need to replace the '%s' with a    -->
@@ -2185,8 +2226,45 @@
     <string name="fast_scroll_alphabet">\u0020ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
     <string name="fast_scroll_numeric_alphabet">\u00200123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ</string>
     
-    <string name="candidates_style"><font fgcolor="#ff000000"
-            bgcolor="#ff8080ff"><u>candidates</u>u></font></string>
+    <string name="candidates_style"><u>candidates</u></string>
+
+    <!-- External media notification strings -->
+    <!-- Shown when external media is being checked -->
+    <string name="ext_media_checking_notification_title">Preparing SD card</string>
+    <string name="ext_media_checking_notification_message">Checking for errors</string>
+
+    <!-- Shown when external media is blank (or unsupported filesystem) -->
+    <string name="ext_media_nofs_notification_title">Blank SD card</string>
+    <string name="ext_media_nofs_notification_message">The SD card is blank or using an unsupported filesystem.</string>
+
+    <!-- Shown when external media is unmountable (corrupt)) -->
+    <string name="ext_media_unmountable_notification_title">Damaged SD card</string>
+    <string name="ext_media_unmountable_notification_message">The SD card is damaged. You may have to reformat your card.</string>
+
+    <!-- Shown when external media is unsafely removed -->
+    <string name="ext_media_badremoval_notification_title">SD card unexpectedly removed</string>
+    <string name="ext_media_badremoval_notification_message">Unmount SD card before removing to avoid data loss.</string>
+
+    <!-- Shown when external media has been safely removed -->
+    <string name="ext_media_safe_unmount_notification_title">SD card safe to remove</string>
+    <string name="ext_media_safe_unmount_notification_message">The SD card can now be safely removed.</string>
+
+    <!-- Shown when external media is missing -->
+    <string name="ext_media_nomedia_notification_title">Removed SD card</string>
+    <string name="ext_media_nomedia_notification_message">The SD has been removed. Insert a new SD card to increase your device storage.</string>
+
+    <!-- Shown in LauncherActivity when the requested target Intent didn't return any matching Activities, leaving the list empty. -->
+    <string name="activity_list_empty">No matching activities found</string>
+
+    <!-- permission attributes related to package usage statistics -->
+    <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permlab_pkgUsageStats">update component usage statistics</string>
+    <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permdesc_pkgUsageStats">Allows the modification of collected component usage statistics. Not for use by normal applications.</string>
+
+    <!-- Shown in the tutorial for double tap to zoom. -->
+    <string name="tutorial_double_tap_to_zoom_message">Congratulations on downloading the Android software update.  This update includes a number of great new features for you to enjoy.  One major improvement we've made is to how you zoom.  Now, when you want to zoom, just double tap on the screen.  This will bring up a zoom widget.  Drag the widget's handle clockwise to zoom in, and counter-clockwise to zoom out.</string>
+
 </resources>
 
 
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 41d3a81..6ed2d8d 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -84,6 +84,11 @@
     <style name="Animation.Translucent">
     </style>
 
+    <!-- Standard animations for a non-full-screen window or activity. -->
+    <style name="Animation.LockScreen">
+        <item name="windowExitAnimation">@anim/lock_screen_exit</item>
+    </style>
+
     <style name="Animation.OptionsPanel">
         <item name="windowEnterAnimation">@anim/options_panel_enter</item>
         <item name="windowExitAnimation">@anim/options_panel_exit</item>
@@ -126,6 +131,12 @@
         <item name="windowExitAnimation">@anim/input_method_exit</item>
     </style>
 
+    <!-- Special optional fancy IM animations. @hide -->
+    <style name="Animation.InputMethodFancy">
+        <item name="windowEnterAnimation">@anim/input_method_fancy_enter</item>
+        <item name="windowExitAnimation">@anim/input_method_fancy_exit</item>
+    </style>
+
     <!-- Window animations that are applied to the search bar overlay window.
          {@hide Pending API council approval} -->
     <style name="Animation.SearchBar">
@@ -289,13 +300,14 @@
     </style>
     
     <style name="Widget.TextView.ListSeparator">
-        <item name="android:background">@android:drawable/settings_header</item>
+        <item name="android:background">@android:drawable/dark_header</item>
         <item name="android:layout_width">fill_parent</item>
-        <item name="android:layout_height">27dip</item>
-        <item name="android:textSize">18sp</item>
-        <item name="android:textColor">#FF000000</item>
+        <item name="android:layout_height">25dip</item>
+        <item name="android:textStyle">bold</item>
+        <item name="android:textColor">?textColorSecondary</item>
+        <item name="android:textSize">14sp</item>
         <item name="android:gravity">center_vertical</item>
-        <item name="android:paddingLeft">5sp</item>         
+        <item name="android:paddingLeft">5sp</item>
     </style>
 
     <style name="Widget.EditText">
@@ -338,7 +350,7 @@
         <item name="android:dropDownSelector">@android:drawable/list_selector_background</item>
         <item name="android:popupBackground">@android:drawable/spinner_dropdown_background</item>
         <item name="android:dropDownVerticalOffset">-8px</item>
-        <item name="android:dropDownHorizontalOffset">2px</item>
+        <item name="android:dropDownHorizontalOffset">0px</item>
     </style>
 
     <style name="Widget.Spinner">
@@ -371,6 +383,11 @@
         <item name="android:fadingEdge">vertical</item>
     </style>
 
+    <style name="Widget.HorizontalScrollView">
+        <item name="android:scrollbars">horizontal</item>
+        <item name="android:fadingEdge">horizontal</item>
+    </style>
+
     <style name="Widget.ListView" parent="Widget.AbsListView">
         <item name="android:listSelector">@android:drawable/list_selector_background</item>
         <item name="android:cacheColorHint">?android:attr/colorBackground</item>
@@ -423,12 +440,27 @@
         <item name="android:popupBackground">@android:drawable/editbox_dropdown_background_dark</item>
     </style>
 
+    <style name="Widget.KeyboardView" parent="android:Widget">
+        <item name="android:background">@android:drawable/keyboard_background</item>
+        <item name="android:keyBackground">@android:drawable/btn_keyboard_key</item>
+        <item name="android:keyTextSize">22sp</item>
+        <item name="android:keyTextColor">#FFFFFFFF</item>
+        <item name="android:keyPreviewLayout">@android:layout/keyboard_key_preview</item>
+        <item name="android:keyPreviewOffset">-12dp</item>
+        <item name="android:keyPreviewHeight">80dp</item>
+        <item name="android:labelTextSize">14sp</item>
+        <item name="android:popupLayout">@android:layout/keyboard_popup_keyboard</item>
+        <item name="android:verticalCorrection">-10dip</item>
+        <item name="android:shadowColor">#BB000000</item>
+        <item name="android:shadowRadius">2.75</item>
+    </style>
+
     <!-- Text Appearances -->
     <eat-comment />
 
     <style name="TextAppearance">
         <item name="android:textColor">?textColorPrimary</item>
-        <item name="android:textColorHighlight">#FF1B82EB</item>
+        <item name="android:textColorHighlight">#FFFF9200</item>
         <item name="android:textColorHint">?textColorHint</item>
         <item name="android:textColorLink">#5C5CFF</item>
         <item name="android:textSize">16sp</item>
@@ -542,36 +574,6 @@
         <item name="android:textStyle">bold</item>
     </style>
 
-    <style name="MediaButton">
-        <item name="android:background">@android:drawable/media_button_background</item>
-        <item name="android:layout_width">71px</item>
-        <item name="android:layout_height">52px</item>
-    </style>
-
-    <style name="MediaButton.Previous">
-        <item name="android:src">@android:drawable/ic_media_previous</item>
-    </style>
-
-    <style name="MediaButton.Next">
-        <item name="android:src">@android:drawable/ic_media_next</item>
-    </style>
-
-    <style name="MediaButton.Play">
-        <item name="android:src">@android:drawable/ic_media_play</item>
-    </style>
-
-    <style name="MediaButton.Ffwd">
-        <item name="android:src">@android:drawable/ic_media_ff</item>
-    </style>
-
-    <style name="MediaButton.Rew">
-        <item name="android:src">@android:drawable/ic_media_rew</item>
-    </style>
-
-    <style name="MediaButton.Pause">
-        <item name="android:src">@android:drawable/ic_media_pause</item>
-    </style>
-
     <!-- Preference Styles -->
 
     <style name="Preference">
@@ -619,19 +621,37 @@
         <item name="android:showDefault">true</item>
     </style>
 
-    <style name="Widget.KeyboardView" parent="android:Widget">
-        <item name="android:background">@android:drawable/keyboard_background</item>
-        <item name="android:keyBackground">@android:drawable/btn_keyboard_key</item>
-        <item name="android:keyTextSize">22sp</item>
-        <item name="android:keyTextColor">#FFFFFFFF</item>
-        <item name="android:keyPreviewLayout">@android:layout/keyboard_key_preview</item>
-        <item name="android:keyPreviewOffset">-12dp</item>
-        <item name="android:keyPreviewHeight">80dp</item>
-        <item name="android:labelTextSize">14sp</item>
-        <item name="android:popupLayout">@android:layout/keyboard_popup_keyboard</item>
-        <item name="android:verticalCorrection">-10dip</item>
-        <item name="android:shadowColor">#BB000000</item>
-        <item name="android:shadowRadius">2.75</item>
+    <!-- Other Misc Styles -->
+    <eat-comment />
+
+    <style name="MediaButton">
+        <item name="android:background">@android:drawable/media_button_background</item>
+        <item name="android:layout_width">71px</item>
+        <item name="android:layout_height">52px</item>
+    </style>
+
+    <style name="MediaButton.Previous">
+        <item name="android:src">@android:drawable/ic_media_previous</item>
+    </style>
+
+    <style name="MediaButton.Next">
+        <item name="android:src">@android:drawable/ic_media_next</item>
+    </style>
+
+    <style name="MediaButton.Play">
+        <item name="android:src">@android:drawable/ic_media_play</item>
+    </style>
+
+    <style name="MediaButton.Ffwd">
+        <item name="android:src">@android:drawable/ic_media_ff</item>
+    </style>
+
+    <style name="MediaButton.Rew">
+        <item name="android:src">@android:drawable/ic_media_rew</item>
+    </style>
+
+    <style name="MediaButton.Pause">
+        <item name="android:src">@android:drawable/ic_media_pause</item>
     </style>
 
     <style name="ZoomControls">
@@ -640,4 +660,15 @@
         <item name="android:paddingLeft">15dip</item>
         <item name="android:paddingRight">15dip</item>
     </style>
+    
+    <!-- Style you can use with a container (typically a horizontal
+         LinearLayout) to get the standard "button bar" background and
+         spacing. @hide -->
+    <style name="ButtonBar">
+        <item name="android:paddingTop">5dip</item>
+        <item name="android:paddingLeft">4dip</item>
+        <item name="android:paddingRight">4dip</item>
+        <item name="android:paddingBottom">1dip</item>
+        <item name="android:background">@android:drawable/bottom_bar</item>
+    </style>
 </resources>
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index 3f07e70..01c46de 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -74,7 +74,7 @@
         <item name="buttonStyleToggle">@android:style/Widget.Button.Toggle</item>
 
         <!-- List attributes -->
-        <item name="listPreferredItemHeight">64px</item>
+        <item name="listPreferredItemHeight">64dip</item>
         <item name="listDivider">@drawable/divider_horizontal_dark</item>
         <item name="listSeparatorTextViewStyle">@android:style/Widget.TextView.ListSeparator</item>   
         
@@ -122,8 +122,8 @@
         <item name="scrollbarSize">10dip</item>
         <item name="scrollbarThumbHorizontal">@android:drawable/scrollbar_handle_horizontal</item>
         <item name="scrollbarThumbVertical">@android:drawable/scrollbar_handle_vertical</item>
-        <item name="scrollbarTrackHorizontal">@android:drawable/scrollbar_horizontal</item>
-        <item name="scrollbarTrackVertical">@android:drawable/scrollbar_vertical</item>
+        <item name="scrollbarTrackHorizontal">@null</item>
+        <item name="scrollbarTrackVertical">@null</item>
 
         <!-- Widget styles -->
         <item name="absListViewStyle">@android:style/Widget.AbsListView</item>
@@ -150,6 +150,7 @@
         <item name="ratingBarStyleSmall">@android:style/Widget.RatingBar.Small</item>
         <item name="radioButtonStyle">@android:style/Widget.CompoundButton.RadioButton</item>
         <item name="scrollViewStyle">@android:style/Widget.ScrollView</item>
+        <item name="horizontalScrollViewStyle">@android:style/Widget.HorizontalScrollView</item>
         <item name="spinnerStyle">@android:style/Widget.Spinner</item>
         <item name="starStyle">@android:style/Widget.CompoundButton.Star</item>
         <item name="starStyleButtonless">@android:style/Widget.CompoundButton.StarButtonless</item>
@@ -276,7 +277,8 @@
         <item name="android:windowBackground">@null</item>
         <item name="android:windowIsTranslucent">false</item>
         <item name="android:windowAnimationStyle">@null</item>
-        <item name="android:windowDisablePreview">@null</item>
+        <item name="android:windowDisablePreview">true</item>
+        <item name="android:windowNoDisplay">true</item>
     </style>
 
     <!-- Default theme for dialog windows and activities, which is used by the
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 21e452e..b13a292 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -113,6 +113,7 @@
 
     <assign-permission name="android.permission.MODIFY_AUDIO_SETTINGS" uid="media" />
     <assign-permission name="android.permission.ACCESS_DRM" uid="media" />
+    <assign-permission name="android.permission.ACCESS_SURFACE_FLINGER" uid="media" />
 
     <!-- This is a list of all the libraries available for application
          code to link against. -->
diff --git a/data/localization/export-to-xlb b/data/localization/export-to-xlb
deleted file mode 100755
index 323f6b7..0000000
--- a/data/localization/export-to-xlb
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-
-mkdir -p /tmp/Maps/res/values
-
-P4PORT=perforce3:3666 p4 print -q //depot/branches/gmm_android_1_1_release_branch/googleclient/wireless/android/Maps/res/values/strings.xml > /tmp/Maps/res/values/strings.xml
-
-extract()
-{
-    module=$1
-    xlb=$2
-    map=""
-
-    shift; shift
-
-    while [ "$1" = '-m' ]
-    do
-        map="$map $1 $2 $3"
-        shift; shift; shift
-    done
-
-    files=$(
-        for i in $*
-        do
-            find $i -name '*.xml' -print0 |
-            xargs -0 grep -l '<string' |
-            grep -v -e '-[a-z][a-z]/' |
-            grep -v -e '-[a-z][a-z]-' |
-            grep -v -e '-r[A-Z][A-Z]/' |
-            grep -v -e '-r[A-Z][A-Z]-'
-        done
-    )
-
-    ../../../../out/host/linux-x86/bin/transconsole $map -p $module $files > ${xlb}.xlb
-}
-
-. ./tc-files
diff --git a/data/localization/import-from-xtb b/data/localization/import-from-xtb
deleted file mode 100755
index f0a0b7d..0000000
--- a/data/localization/import-from-xtb
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/sh
-
-extract()
-{
-    module=$1
-    shift
-
-    P4PORT=perforce1:1666 p4 print -q //depot/google3/googledata/transconsole/xtb/$module/$locale.xtb > $module-$locale.xtb
-
-    files=$(
-        for i in $3
-        do
-            find $i -name '*.xml' -print0 |
-            xargs -0 grep -l '<string' |
-            grep -v -e '-[a-z][a-z]/' |
-            grep -v -e '-[a-z][a-z]-' |
-            grep -v -e '-r[A-Z][A-Z]/' |
-            grep -v -e '-r[A-Z][A-Z]-'
-        done
-    )
-
-    for i in $files
-    do
-        out=$(
-            perl -e '
-                $file = $ARGV[0];
-                $locale = $ARGV[1];
-
-                $locale =~ s/([a-z][a-z])-([A-Z][A-Z])/$1-r$2/;
-
-                $file =~ /^(.*)\/values([^\/]*)\/(.*)/;
-                $prefix = $1;
-                $values = $2;
-                $suffix = $3;
-
-                if ($values =~ /^(-mcc[^-]*)*(-mnc[^-]*)*(.*)$/) {
-                    print "$prefix/values$1$2-$locale$3/$suffix\n";
-                } else {
-                    print "$prefix/values-$locale$values/$suffix\n";
-                }
-            ' $i $locale
-        )
-
-        p4 edit $out
-        p4 add $out
-        mkdir -p `dirname $out`
-        if ../../../../out/host/linux-x86/bin/transconsole -m $1 $2 -p $module -i $module-$locale.xtb $i > $out
-        then :
-        else
-            p4 revert $out
-            p4 delete $out
-        fi
-    done
-}
-
-for locale in fr it es de nl cs pl ja zh-TW zh-CN ru
-do
-
-extract AndroidAlarmClock ../../../../packages/apps/AlarmClock ../../apps/AlarmClock ../../../../packages/apps/AlarmClock
-extract AndroidBrowser ../../../../packages/apps/Browser ../../apps/Browser ../../../../packages/apps/Browser
-extract AndroidCalculator ../../../../packages/apps/Calculator ../../apps/Calculator ../../../../packages/apps/Calculator
-extract AndroidCalendar ../../../../packages/apps/Calendar ../../apps/Calendar ../../../../packages/apps/Calendar
-extract AndroidCamera ../../../../packages/apps/Camera ../../apps/Camera ../../../../packages/apps/Camera
-extract AndroidContacts ../../../../packages/apps/Contacts ../../apps/Contacts ../../../../packages/apps/Contacts
-extract AndroidDownloads ../../../../packages/providers/DownloadProvider ../../content/providers/downloads ../../../../packages/providers/DownloadProvider
-extract AndroidDrm ../../../../packages/providers/DrmProvider ../../content/providers/drm ../../../../packages/providers/DrmProvider
-extract AndroidEmail ../../../../packages/apps/Email ../../apps/Email ../../../../packages/apps/Email
-extract AndroidFallback ../../../../development/apps/Fallback ../../apps/Fallback ../../../../development/apps/Fallback
-extract AndroidGmail ../../../../vendor ../../partner ../../../../vendor/google/providers/gmail
-extract AndroidGmail ../../../../vendor ../../partner ../../../../vendor/google/apps/Gmail
-extract AndroidGoogleApps ../../../../vendor ../../partner ../../../../vendor/google/apps/GoogleApps
-extract AndroidGoogleSearch ../../../../packages/apps/GoogleSearch ../../apps/GoogleSearch ../../../../packages/apps/GoogleSearch
-extract AndroidHome ../../../../packages/apps/Launcher ../../apps/Home ../../../../packages/apps/Launcher
-extract AndroidIM ../../../../packages/apps/IM ../../apps/IM ../../../../packages/apps/IM
-extract AndroidMaps ../../../../vendor ../../partner ../../../../vendor/google/apps/Maps
-extract AndroidMaps ../../../../vendor ../../partner ../../../../vendor/google/apps/Street
-extract AndroidMms ../../../../packages/apps/Mms ../../apps/Mms ../../../../packages/apps/Mms
-extract AndroidMusic ../../../../packages/apps/Music ../../apps/Music ../../../../packages/apps/Music
-extract AndroidPhone ../../../../packages/apps/Phone ../../apps/Phone ../../../../packages/apps/Phone
-extract AndroidPlatform ../../../../frameworks/base/core/res ../../apps/common ../../../../frameworks/base/core/res
-extract AndroidSettings ../../../../packages/apps/Settings ../../apps/Settings ../../../../packages/apps/Settings
-extract AndroidSetupWizard ../../../../vendor ../../partner ../../../../vendor/google/apps/SetupWizard
-extract AndroidSoundRecorder ../../../../packages/apps/SoundRecorder ../../apps/SoundRecorder ../../../../packages/apps/SoundRecorder
-extract AndroidStk ../../../../packages/apps/Stk ../../apps/Stk ../../../../packages/apps/Stk
-extract AndroidSync ../../../../packages/apps/Sync ../../apps/Sync ../../../../packages/apps/Sync
-extract AndroidTalk ../../../../vendor ../../partner ../../../../vendor/google/apps/Talk
-extract AndroidUpdater ../../../../packages/apps/Updater ../../apps/Updater ../../../../packages/apps/Updater
-extract AndroidVending ../../../../vendor ../../partner ../../../../vendor/google/apps/Vending
-extract AndroidVoiceDialer ../../../../packages/apps/VoiceDialer ../../apps/VoiceDialer ../../../../packages/apps/VoiceDialer
-extract AndroidYoutube ../../../../vendor ../../partner ../../../../vendor/google/apps/YouTube
-
-done
-
-exit 0
diff --git a/data/localization/tc-files b/data/localization/tc-files
deleted file mode 100644
index 5b32cb4..0000000
--- a/data/localization/tc-files
+++ /dev/null
@@ -1,33 +0,0 @@
-# TC-project XLB-file Newmap Oldmap Name...
-
-extract AndroidAlarmClock AlarmClock -m ../../../../packages/apps/AlarmClock ../../apps/AlarmClock ../../../../packages/apps/AlarmClock
-extract AndroidBrowser Browser -m ../../../../packages/apps/Browser ../../apps/Browser ../../../../packages/apps/Browser
-extract AndroidCalculator Calculator -m ../../../../packages/apps/Calculator ../../apps/Calculator ../../../../packages/apps/Calculator
-extract AndroidCalendar Calendar -m ../../../../packages/apps/Calendar ../../apps/Calendar ../../../../packages/apps/Calendar
-extract AndroidCamera Camera -m ../../../../packages/apps/Camera ../../apps/Camera ../../../../packages/apps/Camera
-extract AndroidContacts Contacts -m ../../../../packages/apps/Contacts ../../apps/Contacts ../../../../packages/apps/Contacts
-extract AndroidDownloads Downloads -m ../../../../packages/providers/DownloadProvider ../../content/providers/downloads ../../../../packages/providers/DownloadProvider
-extract AndroidDrm Drm -m ../../../../packages/providers/DrmProvider ../../content/providers/drm ../../../../packages/providers/DrmProvider
-extract AndroidEmail Email -m ../../../../packages/apps/Email ../../apps/Email ../../../../packages/apps/Email
-extract AndroidFallback Fallback -m ../../../../development/apps/Fallback ../../apps/Fallback ../../../../development/apps/Fallback
-extract AndroidGmail Gmail -m ../../../../vendor ../../partner ../../../../vendor/google/providers/gmail ../../../../vendor/google/apps/Gmail
-extract AndroidGoogleApps GoogleApps -m ../../../../vendor ../../partner ../../../../vendor/google/apps/GoogleApps
-extract AndroidGoogleSearch GoogleSearch -m ../../../../packages/apps/GoogleSearch ../../apps/GoogleSearch ../../../../packages/apps/GoogleSearch
-extract AndroidHome Home -m ../../../../packages/apps/Launcher ../../apps/Home ../../../../packages/apps/Launcher
-extract AndroidIM IM -m ../../../../packages/apps/IM ../../apps/IM ../../../../packages/apps/IM
-#extract AndroidMaps Maps -m ../../../../vendor ../../partner -m /home/build/googleclient/wireless/android ../../partner/google/apps /home/build/googleclient/wireless/android/Maps ../../../../vendor/google/apps/Street
-extract AndroidMaps Maps -m ../../../../vendor ../../partner -m /tmp/Maps ../../partner/google/apps/Maps /tmp/Maps ../../../../vendor/google/apps/Street
-extract AndroidMms Mms -m ../../../../packages/apps/Mms ../../apps/Mms ../../../../packages/apps/Mms
-extract AndroidMusic Music -m ../../../../packages/apps/Music ../../apps/Music ../../../../packages/apps/Music
-extract AndroidPhone Phone -m ../../../../packages/apps/Phone ../../apps/Phone ../../../../packages/apps/Phone
-extract AndroidPlatform AndroidSystem -m ../../../../frameworks/base/core/res ../../apps/common ../../../../frameworks/base/core/res
-extract AndroidSettings Settings -m ../../../../packages/apps/Settings ../../apps/Settings ../../../../packages/apps/Settings
-extract AndroidSetupWizard SetupWizard -m ../../../../vendor ../../partner ../../../../vendor/google/apps/SetupWizard
-extract AndroidSoundRecorder SoundRecorder -m ../../../../packages/apps/SoundRecorder ../../apps/SoundRecorder ../../../../packages/apps/SoundRecorder
-extract AndroidStk Stk -m ../../../../packages/apps/Stk ../../apps/Stk ../../../../packages/apps/Stk
-extract AndroidSync Sync -m ../../../../packages/apps/Sync ../../apps/Sync ../../../../packages/apps/Sync
-extract AndroidTalk Talk -m ../../../../vendor ../../partner ../../../../vendor/google/apps/Talk
-extract AndroidUpdater Updater -m ../../../../packages/apps/Updater ../../apps/Updater ../../../../packages/apps/Updater
-extract AndroidVending Vending -m ../../../../vendor ../../partner ../../../../vendor/google/apps/Vending
-extract AndroidVoiceDialer VoiceDialer -m ../../../../packages/apps/VoiceDialer ../../apps/VoiceDialer ../../../../packages/apps/VoiceDialer
-extract AndroidYoutube YouTube -m ../../../../vendor ../../partner ../../../../vendor/google/apps/YouTube
diff --git a/data/localization/xlb-merge b/data/localization/xlb-merge
deleted file mode 100755
index d62ca58..0000000
--- a/data/localization/xlb-merge
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-for i in *.xlb
-do
-    perl -e '
-        print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-        print "<localizationbundle locale=\"en\">\n";
-
-        while (<>) {
-            if (/<msg/) {
-                $content = $_;
-            } else {
-                $content .= $_;
-            }
-
-            if (/<\/msg>/) {
-                $content1 = $content;
-                $content1 =~ s/desc="[^"]*"//;
-
-                unless ($seen{$content1}) {
-                    print "$content";
-                }
-
-                $seen{$content1} = 1;
-                $content = "";
-            }
-        }
-
-        print "</localizationbundle>\n";
-    ' $i ../../../../../../platform-1_0/device/data/localization/$i > /android/depot/googleclient/wireless/data/Android/$i
-done
diff --git a/data/sounds/Android.mk b/data/sounds/Android.mk
index 94e7670..dd0dcaa 100644
--- a/data/sounds/Android.mk
+++ b/data/sounds/Android.mk
@@ -86,18 +86,10 @@
 $(TARGET_OUT)/media/audio/ringtones/CaribbeanIce.ogg : $(LOCAL_PATH)/newwavelabs/CaribbeanIce.ogg | $(ACP)
 	$(transform-prebuilt-to-target)
 
-ALL_PREBUILT += $(TARGET_OUT)/media/audio/ringtones/CrazyDream.ogg
-$(TARGET_OUT)/media/audio/ringtones/CrazyDream.ogg : $(LOCAL_PATH)/newwavelabs/CrazyDream.ogg | $(ACP)
-	$(transform-prebuilt-to-target)
-
 ALL_PREBUILT += $(TARGET_OUT)/media/audio/ringtones/CurveBall.ogg
 $(TARGET_OUT)/media/audio/ringtones/CurveBall.ogg : $(LOCAL_PATH)/newwavelabs/CurveBall.ogg | $(ACP)
 	$(transform-prebuilt-to-target)
 
-ALL_PREBUILT += $(TARGET_OUT)/media/audio/ringtones/DreamTheme.ogg
-$(TARGET_OUT)/media/audio/ringtones/DreamTheme.ogg : $(LOCAL_PATH)/newwavelabs/DreamTheme.ogg | $(ACP)
-	$(transform-prebuilt-to-target)
-
 ALL_PREBUILT += $(TARGET_OUT)/media/audio/ringtones/EtherShake.ogg
 $(TARGET_OUT)/media/audio/ringtones/EtherShake.ogg : $(LOCAL_PATH)/newwavelabs/EtherShake.ogg | $(ACP)
 	$(transform-prebuilt-to-target)
diff --git a/data/sounds/newwavelabs/BeatPlucker.ogg b/data/sounds/newwavelabs/BeatPlucker.ogg
index 347b5aa..f1bcef0 100644
--- a/data/sounds/newwavelabs/BeatPlucker.ogg
+++ b/data/sounds/newwavelabs/BeatPlucker.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/BentleyDubs.ogg b/data/sounds/newwavelabs/BentleyDubs.ogg
index 5bb082d..44c0631 100644
--- a/data/sounds/newwavelabs/BentleyDubs.ogg
+++ b/data/sounds/newwavelabs/BentleyDubs.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/BirdLoop.ogg b/data/sounds/newwavelabs/BirdLoop.ogg
index ed1074b..b484582 100644
--- a/data/sounds/newwavelabs/BirdLoop.ogg
+++ b/data/sounds/newwavelabs/BirdLoop.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/CaribbeanIce.ogg b/data/sounds/newwavelabs/CaribbeanIce.ogg
index bb150b5..7525123 100644
--- a/data/sounds/newwavelabs/CaribbeanIce.ogg
+++ b/data/sounds/newwavelabs/CaribbeanIce.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/CrazyDream.ogg b/data/sounds/newwavelabs/CrazyDream.ogg
index 907316a..5fa47b9 100644
--- a/data/sounds/newwavelabs/CrazyDream.ogg
+++ b/data/sounds/newwavelabs/CrazyDream.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/CurveBall.ogg b/data/sounds/newwavelabs/CurveBall.ogg
index e3d3fdf..733a004 100644
--- a/data/sounds/newwavelabs/CurveBall.ogg
+++ b/data/sounds/newwavelabs/CurveBall.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/DreamTheme.ogg b/data/sounds/newwavelabs/DreamTheme.ogg
index 2729f07..e602a38 100644
--- a/data/sounds/newwavelabs/DreamTheme.ogg
+++ b/data/sounds/newwavelabs/DreamTheme.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/EtherShake.ogg b/data/sounds/newwavelabs/EtherShake.ogg
index f1d645a..178aa21 100644
--- a/data/sounds/newwavelabs/EtherShake.ogg
+++ b/data/sounds/newwavelabs/EtherShake.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/FriendlyGhost.ogg b/data/sounds/newwavelabs/FriendlyGhost.ogg
index f250560..d993880 100644
--- a/data/sounds/newwavelabs/FriendlyGhost.ogg
+++ b/data/sounds/newwavelabs/FriendlyGhost.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/GameOverGuitar.ogg b/data/sounds/newwavelabs/GameOverGuitar.ogg
index 7c5c1d5..2adb0a8 100644
--- a/data/sounds/newwavelabs/GameOverGuitar.ogg
+++ b/data/sounds/newwavelabs/GameOverGuitar.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/Growl.ogg b/data/sounds/newwavelabs/Growl.ogg
index 5361b3f..c54bde0 100644
--- a/data/sounds/newwavelabs/Growl.ogg
+++ b/data/sounds/newwavelabs/Growl.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/InsertCoin.ogg b/data/sounds/newwavelabs/InsertCoin.ogg
index f5a4a38..8737da5 100644
--- a/data/sounds/newwavelabs/InsertCoin.ogg
+++ b/data/sounds/newwavelabs/InsertCoin.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/LoopyLounge.ogg b/data/sounds/newwavelabs/LoopyLounge.ogg
index ce559ec..6d168cd 100644
--- a/data/sounds/newwavelabs/LoopyLounge.ogg
+++ b/data/sounds/newwavelabs/LoopyLounge.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/LoveFlute.ogg b/data/sounds/newwavelabs/LoveFlute.ogg
index 35904b51..16cf413 100644
--- a/data/sounds/newwavelabs/LoveFlute.ogg
+++ b/data/sounds/newwavelabs/LoveFlute.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/MidEvilJaunt.ogg b/data/sounds/newwavelabs/MidEvilJaunt.ogg
index e4273a9..66d7fad 100644
--- a/data/sounds/newwavelabs/MidEvilJaunt.ogg
+++ b/data/sounds/newwavelabs/MidEvilJaunt.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/MildlyAlarming.ogg b/data/sounds/newwavelabs/MildlyAlarming.ogg
index 9f03f3b..9025b18 100644
--- a/data/sounds/newwavelabs/MildlyAlarming.ogg
+++ b/data/sounds/newwavelabs/MildlyAlarming.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/NewPlayer.ogg b/data/sounds/newwavelabs/NewPlayer.ogg
index 997aac1..c2df5d8 100644
--- a/data/sounds/newwavelabs/NewPlayer.ogg
+++ b/data/sounds/newwavelabs/NewPlayer.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/Noises1.ogg b/data/sounds/newwavelabs/Noises1.ogg
index 2950c6d..829b4fa 100644
--- a/data/sounds/newwavelabs/Noises1.ogg
+++ b/data/sounds/newwavelabs/Noises1.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/Noises2.ogg b/data/sounds/newwavelabs/Noises2.ogg
index 3f17526..69a3d72 100644
--- a/data/sounds/newwavelabs/Noises2.ogg
+++ b/data/sounds/newwavelabs/Noises2.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/Noises3.ogg b/data/sounds/newwavelabs/Noises3.ogg
index 788508e..3607c2a 100644
--- a/data/sounds/newwavelabs/Noises3.ogg
+++ b/data/sounds/newwavelabs/Noises3.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/OrganDub.ogg b/data/sounds/newwavelabs/OrganDub.ogg
index e18bbe0..c0a22f4 100644
--- a/data/sounds/newwavelabs/OrganDub.ogg
+++ b/data/sounds/newwavelabs/OrganDub.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/RomancingTheTone.ogg b/data/sounds/newwavelabs/RomancingTheTone.ogg
index aac4cb2..ebe54e5 100644
--- a/data/sounds/newwavelabs/RomancingTheTone.ogg
+++ b/data/sounds/newwavelabs/RomancingTheTone.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/SitarVsSitar.ogg b/data/sounds/newwavelabs/SitarVsSitar.ogg
index 0b421b8..cfe9c80 100644
--- a/data/sounds/newwavelabs/SitarVsSitar.ogg
+++ b/data/sounds/newwavelabs/SitarVsSitar.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/SpringyJalopy.ogg b/data/sounds/newwavelabs/SpringyJalopy.ogg
index d4c596e..b837aff 100644
--- a/data/sounds/newwavelabs/SpringyJalopy.ogg
+++ b/data/sounds/newwavelabs/SpringyJalopy.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/Terminated.ogg b/data/sounds/newwavelabs/Terminated.ogg
index 1b780b9..b980053 100644
--- a/data/sounds/newwavelabs/Terminated.ogg
+++ b/data/sounds/newwavelabs/Terminated.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/TwirlAway.ogg b/data/sounds/newwavelabs/TwirlAway.ogg
index faa685d..eeff7f0 100644
--- a/data/sounds/newwavelabs/TwirlAway.ogg
+++ b/data/sounds/newwavelabs/TwirlAway.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/VeryAlarmed.ogg b/data/sounds/newwavelabs/VeryAlarmed.ogg
index 22b3ae1..bfb63f4 100644
--- a/data/sounds/newwavelabs/VeryAlarmed.ogg
+++ b/data/sounds/newwavelabs/VeryAlarmed.ogg
Binary files differ
diff --git a/data/sounds/newwavelabs/World.ogg b/data/sounds/newwavelabs/World.ogg
index 03cafe6..e226166 100644
--- a/data/sounds/newwavelabs/World.ogg
+++ b/data/sounds/newwavelabs/World.ogg
Binary files differ
diff --git a/docs/docs-redirect.html b/docs/docs-redirect.html
index 3d2b8a0..4e0743e 100644
--- a/docs/docs-redirect.html
+++ b/docs/docs-redirect.html
@@ -1,8 +1,8 @@
 <html>

 <head>

-<meta http-equiv="refresh" content="0;url=docs/index.html">

+<meta http-equiv="refresh" content="0;url=docs/offline.html">

 </head>

 <body>

-<a href="docs/index.html">click here if you are not redirected</a>

+<a href="docs/offline.html">click here if you are not redirected</a>

 </body>

 </html>

diff --git a/docs/html/community/index.jd b/docs/html/community/index.jd
index 284afe3..4dc5503 100644
--- a/docs/html/community/index.jd
+++ b/docs/html/community/index.jd
@@ -4,53 +4,115 @@
 
 	<div id="mainBodyFluid">
 			<h1>Community</h1>
-			<p>Welcome to the Android community! We're glad you're here and invite you to participate in these discussions. Before posting, please red the <a href="#">Groups Charter</a> that covers the community guidelines.</p>
-			<p>To get the most out of this group, please do the following before you post:</p>
-			<ol>
-				<li><a href="{@docRoot}guide/appendix/faq/index.html">Read the FAQs</a> The most common questions are addressed in this frequently updated list.</li>
-				<li><strong>Type in keywords of your questions in the main Android site's search bar</strong> (such as the one above). This search encompasses all previous discussions, across all groups, as well as the full contents of the site, documentation, and blogs. Chances are good that somebody has run into the same issue before.</li>
-				<li><strong>Be very clear</strong> about your question in the subject - it helps everyone, both those trying to answer your question as well as those who may be looking for information in the future. Also <strong>give plenty of details</strong> in your post to help others understand your problem. Code or log snippets, as well as pointers to screenshots, may also be helpful.</li>
-                        </ol>
-			<p>For a great guide to phrasing your questions, please read: <a href="#">How to Ask Questions The Smart Way</a>.</p>
+			<p>Welcome to the Android developers community! We're glad you're here and invite you to participate in these discussions. Before posting, please red the <a href="#">Groups Charter</a> that covers the community guidelines.</p>
 
-<h2>Subscribe to a Group</h2>
-<p>You can subscribe to these groups in one of two ways:</p>
-  <ul>
-    <li>Follow the web access link (in the first column below) and then click "Join this group" on the right-side of the Groups page. If you'd rather read posts via email, sign in to Groups and click "edit my membership" on the right hand side. Select "email" under "How do you want to read this group?".</li>
-    <li>Or simply subscribe via email by clicking the subscribe link (in the last column below).</li>
-  </ul>
+<p class="note"><strong>Note:</strong> If you are seeking discussion about Android source code (not application development),
+then please refer to the <a href="http://source.android.com/discuss">Open Source Project Mailing lists</a>.</p>
 
-<h3 class="green">Available Groups</h3>
-			<table class="groupTable">
-				<tr>
-					<th>Group - Web Access</th>
-					<th>Description</th>
-					<th>Subscribe by email</th>
-				</tr>
-				<tr class="oddRow">
-					<td><a href="http://groups.google.com/group/android-beginners">android-beginners</a></td>
-					<td>Discuss developing Android applications using the Android framework. Get help with troubleshooting apps, advice on implementation, and strategies for improving your app's speed and user experience.</td>
-					<td><a href="mailto:android-beginners-subscribe@googlegroups.com">android-beginners-subscribe@googlegroups.com</a></td>
-				</tr>
-				<tr class="evenRow">
-					<td><a href="http://groups.google.com/group/android-developers">android-developers</a></td>
-					<td>New to ANdroid development? Start here. Open to any discussion around beginner-type questions; this is a great way to get up and running with your new App on the Android platform.</td>
-					<td><a href="mailto:android-developers-subscribe@googlegroups.com">android-developers-subscribe@googlegroups.com</a></td>
-				</tr>
-				<tr class="oddRow">
-					<td><a href="http://groups.google.com/group/android-discuss">android-discuss</a></td>
-					<td>The "water cooler" of Android discussion. Free-wheeling discussion from ideas about the Android platform to your announcements on other Android resources.</td>
-					<td><a href="mailto:android-discuss-subscribe@googlegroups.com">android-discuss-subscribe@googlegroups.com</a></td>
-				</tr>
-				<tr class="evenRow">
-					<td><a href="http://groups.google.com/group/android-security-discuss">android-security-discuss</a></td>
-					<td>A place for open discussion on secure development, emerging security concerns, and best practices for and by android developers.</td>
-					<td><a href="mailto:android-security-discuss-subscribe@googlegroups.com">android-security-discuss-subscribe@googlegroups.com</a></td>
-				</tr>
-				<tr class="oddRow">
-					<td><nobr><a href="http://groups.google.com/group/android-security-announce">android-security-announce</a></nobr></td>
-					<td>A low-volume group for security-related announcements by the Android Security Team.</td>
-					<td><a href="mailto:android-security-announce-subscribe@googlegroups.com">android-security-announce-subscribe@googlegroups.com</a></td>
-				</tr>
-			</table>
+<p style="margin-bottom".5em"><strong>Contents</strong></p>
+<ol class="toc">
+  <li><a href="#BeforeYouPost">Before you post</a></li>
+  <li><a href="#ApplicationDeveloperLists">Application developer mailing lists</a></li>
+  <li><a href="#UsingEmail">Using email with the mailing lists</a></li>
+  <li><a href="#UsingIRC">Using IRC</a></li>
+</ol>
+
+<h2 id="BeforeYouPost">Before you post</h2>
+<p>Before writing a post, please try the following:</p>
+
+<ol>
+<li><a href="{@docRoot}guide/appendix/faq/index.html">Read the FAQs</a> The most common questions about developing Android applications are addressed in this frequently updated list.</li>
+<li><strong>Type in keywords of your questions in the main Android site's search bar</strong> (such as the one above). This search encompasses all previous discussions, across all groups, as well as the full contents of the site, documentation, and blogs. Chances are good that somebody has run into the same issue before.</li>
+<li><b>Search the mailing list archives</b> to see whether your questions have already been discussed.
+  </li>
+</ol>
+
+<p>If you can't find your answer, then we encourage you to address the community.
+As you write your post, please do the following:
+<ol>
+<li><b>Read
+the <a href="http://sites.google.com/a/android.com/opensource/discuss/android-discussion-groups-charter">mailing list charter</a></b> that covers the community guidelines. 
+</li>
+<li><b>Select the most appropriate mailing list for your question</b>. There are several different lists for 
+developers, described below.</li>
+<li>
+    <b>Be very clear</b> about your question
+in the subject -- it helps everyone, both those trying to answer your
+question as well as those who may be looking for information in the
+future.</li>
+<li><b>Give plenty of details</b> in your post to
+help others understand your problem. Code or log snippets, as well as
+pointers to screenshots, may also be helpful. For a great guide to
+phrasing your questions, read <a href="http://www.catb.org/%7Eesr/faqs/smart-questions.html">How To Ask Questions The Smart Way</a>.
+  </li>
+</ol>
+
+
+<h3 id="ApplicationDeveloperLists">Application developer mailing lists</h3>
+<ul>
+<li><b>Android beginners</b> - You're new to Android application development. You want to figure out how to get started with the Android SDK and the basic Android APIs? Start here. This list is open to any discussion around beginner-type questions for developers using the SDK; this is a great way to get up and running with your new application on the Android platform. Ask about getting your development environment set up, get help with the first steps of Android development (your first User Interface, your first permission, your first file on the Android filesystem, your first app on the Android Market...). Be sure to check the archives first before asking new questions. Please avoid advanced subjects, which belong on android-developers, and user questions, which will get a better reception on android-discuss.
+<ul>
+<li>Subscribe using Google Groups:&nbsp;<a href="http://groups.google.com/group/android-beginners">android-beginners</a></li>
+<li>Subscribe via email:&nbsp;<a href="mailto:android-beginners-subscribe@googlegroups.com">android-beginners-subscribe@googlegroups.com</a><a href="mailto:android-platform-subscribe@googlegroups.com">
+</a></li>
+</ul>
+</li>
+
+<li><b>Android developers</b> - You're now an experienced Android application developer. You've grasped the basics of Android app development, you're comfortable using the SDK, now you want to move to advanced topics. Get help here with troubleshooting applications, advice on implementation, and strategies for improving your application's performance and user experience. This is the not the right place to discuss user issues (use android-discuss for that) or beginner questions with the Android SDK (use android-beginners for that).
+<ul>
+<li>Subscribe using Google Groups:&nbsp;<a href="http://groups.google.com/group/android-developers">android-developers</a></li>
+<li>Subscribe via email:&nbsp;<a href="mailto:android-developers-subscribe@googlegroups.com">android-developers-subscribe@googlegroups.com</a><a href="mailto:android-platform-subscribe@googlegroups.com">
+</a></li>
+</ul>
+</li>
+
+<li><b>Android discuss</b> - The "water cooler" of Android discussion. You can discuss just about anything Android-related here, ideas for the Android platform, announcements about your applications, discussions about Android devices, community resources... As long as your discussion is related to Android, it's on-topic here. However, if you have a discussion here that could belong on another list, you are probably not reaching all of your target audience here and may want to consider shifting to a more targeted list.
+<ul>
+<li>Subscribe using Google Groups:&nbsp;<a href="http://groups.google.com/group/android-discuss">android-discuss</a></li>
+<li>Subscribe via email:&nbsp;<a href="mailto:android-discuss-subscribe@googlegroups.com">android-discuss-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>
+<li>Subscribe via email:&nbsp;<a href="mailto:android-security-discuss@googlegroups.com">android-secuirty-discuss@googlegroups.com</a><a href="mailto:android-platform-subscribe@googlegroups.com">
+    </a></li>
+</ul>
+</li>
+
+<li><b>Android security announce</b> - A low-volume group for security-related announcements by the Android Security Team.
+<ul>
+<li>Subscribe using Google Groups:&nbsp;<a href="http://groups.google.com/group/android-security-announce">android-security-announce</a></li>
+<li>Subscribe via email:&nbsp;<a href="mailto:android-security-announce-subscribe@googlegroups.com">android-security-announce-subscribe@googlegroups.com</a>
+<a href="mailto:android-platform-subscribe@googlegroups.com">    </a></li>
+</ul>
+</li>
+</ul>
+
+
+
+<h2 id="UsingEmail">Using email with the mailing lists</h2>
+<p>Instead of using the <a href="http://groups.google.com/">Google Groups</a> site, you can use your email client of choice to participate in the mailing lists.</p>
+<p>To subscribe to a group without using the Google Groups site, use the link under "subscribe via email" in the lists above.</p>
+<p>To set up how you receive mailing list postings by email:</p>
+
+<ol><li>Sign into the group via the Google Groups site. For example, for the android-framework group you would visit <a href="http://groups.google.com/group/android-framework">http://groups.google.com/group/android-framework</a>.</li>
+<li>Click "Edit
+my membership" on the right side.</li>
+<li>Under "How do
+you want to read this group?" select one of the email options. </li>
+</ol>
+
+<h2 id="UsingIRC">Using IRC</h2>
+<p>The Android community is using the #android channel on the irc.freenode.net server.
+</p>
+
+
+
+
+
+
+
 </div>
\ No newline at end of file
diff --git a/docs/html/favicon.ico b/docs/html/favicon.ico
new file mode 100644
index 0000000..d8884b7
--- /dev/null
+++ b/docs/html/favicon.ico
Binary files differ
diff --git a/docs/html/guide/appendix/faq/commontasks.jd b/docs/html/guide/appendix/faq/commontasks.jd
index 69fddd3..9c79bdd 100644
--- a/docs/html/guide/appendix/faq/commontasks.jd
+++ b/docs/html/guide/appendix/faq/commontasks.jd
@@ -1,4 +1,6 @@
 page.title=Common Tasks and How to Do Them in Android
+parent.title=FAQs, Tips, and How-to
+parent.link=index.html
 @jd:body
 
 <ul>
@@ -81,7 +83,7 @@
         and required files and syntax details for each is given in <a href="#filelist">File
         List for an Android Application</a>. </li>
     <li><strong>Design your user interface</strong> &nbsp;&nbsp;See <a
-    href="{@docRoot}guide/topics/views/index.html">Implementing a UI</a> for
+    href="{@docRoot}guide/topics/ui/index.html">User Interface</a> for
     details on elements of the Android screen. </li>
     <li><strong>Implement your Activity </strong>(this page)<strong>&nbsp;&nbsp; </strong> You
         will create one class/file for each screen in your application. Screens will
@@ -200,7 +202,7 @@
 <p>Android defines a number of standard values, for instance the action constants
     defined by {@link android.content.Intent}. You can define custom values, but
     both the caller and handler must use them. See the &lt;intent-filter&gt;
-    tag description in <a href="{@docRoot}guide/topics/manifest/manifest.html">The AndroidManifest.xml
+    tag description in <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml
     File</a> for more information on the manifest syntax for the handling
     application. </p>
 <a name="returningaresult" id="returningaresult"></a><h3>Returning a Result from a Screen</h3>
@@ -267,7 +269,7 @@
     {@link android.app.Activity#finishActivity(int) Activity.finishActivity()}
     on any screens that it opens to close them. </p>
 <a name="listening" id="listening"></a><h2>Listening for Button Clicks</h2>
-<p>Button click and other UI event capturing are covered in <a href="{@docRoot}guide/topics/views/ui-events.html">Handling UI Events</a> on the UI Design page.</p>
+<p>Button click and other UI event capturing are covered in <a href="{@docRoot}guide/topics/ui/ui-events.html">Handling UI Events</a> on the UI Design page.</p>
 <a name="configurewindowproperties" id="configurewindowproperties"></a><h2>Configuring General Window Properties</h2>
 <p>You can set a number of general window properties, such as whether to display
     a title, whether the window is floating, and whether it displays an icon, by
@@ -527,174 +529,8 @@
     which enables a  dialog box with an embedded progress bar to send a &quot;I'm working
     on it&quot; notification to the user. </p>
 <a name="addmenuitems" id="addmenuitems"></a><h2>Adding Items to the Screen Menu</h2>
-<p>Every Android screen has a default menu with default options, such as adding the
-    activity to the favorites menu. You can add your own menu entries to the default
-    menu options by implementing {@link android.app.Activity#onCreateOptionsMenu(android.view.Menu)
-    Activity.onCreateOptionsMenu} or {@link android.app.Activity#onPrepareOptionsMenu(android.view.Menu)
-    Activity.onPrepareOptionsMenu()}, and adding {@link android.view.MenuItem Item}
-    objects to the {@link android.view.Menu Menu} passed in. To handle clicks
-    implement {@link android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
-    Activity.onOptionsItemSelected()} to handle the click in your Activity class.
-    You may also pass the Item object a handler class that implements the 
-    Runnable class (a handler) but this is less efficient and discouraged.</p>
-<p>An application receives a callback at startup time to enable it to populate its
-    menu. Additionally, it receives callbacks each time the user displays the options
-    menu to let you perform some contextual modifications on the menu. To populate
-    the menu on startup, override {@link android.app.Activity#onCreateOptionsMenu(android.view.Menu)
-    Activity.onCreateOptionsMenu}; to populate it when the menu is called (somewhat
-    less efficient), you can override {@link android.app.Activity#onPrepareOptionsMenu(android.view.Menu)
-    Activity.onPrepareOptionsMenu()}. Each Activity has its own menu list.</p>
-<p>Menu items are displayed in the order added, though you can group them as described
-    in the {@link android.view.Menu#add Menu.add} documentation.
-    The following code snippet adds three items to the default menu options and handles
-    them through the overridden Activity.onOptionsItemSelected() method. 
-    You can show or hide menu items by calling {@link android.view.MenuItem#setVisible(
-    boolean) setVisible()} or {@link android.view.Menu#setGroupVisible(int,
-    boolean) setGroupVisible()}. 
-</p>
-</p>
-<pre>// Called only the first time the options menu is displayed.
-// Create the menu entries.
-// Menu adds items in the order shown.
-&#064;Override
-public boolean onCreateOptionsMenu(Menu menu) {
-    super.onCreateOptionsMenu(menu);
-    
-    // Parameters for menu.add are:
-    // group -- Not used here.
-    // id -- Used only when you want to handle and identify the click yourself.
-    // title
-    menu.add(0, 0, &quot;Zoom&quot;);
-    menu.add(0, 1, &quot;Settings&quot;);
-    menu.add(0, 2, &quot;Other&quot;);
-    return true;
-}
+<p>See <a href="{@docRoot}guide/topics/ui/menus.html">Creating Menus</a>.</p>
 
-// Activity callback that lets your handle the selection in the class.
-// Return true to indicate that you&#39;ve got it, false to indicate
-// that it should be handled by a declared handler object for that
-// item (handler objects are discouraged for reasons of efficiency).
-&#064;Override
-public boolean onOptionsItemSelected(MenuItem item){
-    switch (item.getId()) {
-    case 0:
-        showAlert(&quot;Menu Item Clicked&quot;, &quot;Zoom&quot;, &quot;ok&quot;, null, false, null);
-        return true;
-    case 1:
-        showAlert(&quot;Menu Item Clicked&quot;, &quot;Settings&quot;, &quot;ok&quot;, null, false, null);
-        return true;
-    case 2:
-        showAlert(&quot;Menu Item Clicked&quot;, &quot;Other&quot;, &quot;ok&quot;, null, false, null);
-        return true;
-    }
-    return false;
-}
-</pre>
-<a name="menukeyshortcuts" id="menukeyshortcuts"></a>
-<p>You can add key shortcuts by calling the 
-    MenuItem.setAlphabeticShortcut() or 
-    MenuItem.setNumericShortcut() methods, as demonstrated here to add a &quot;c&quot; shortcut
-    to a menu item:</p>
-<pre>thisItem.setAlphabeticShortcut('c'); </pre>
-<h3>Adding Submenus<a name="submenus" id="submenus"></a></h3>
-<p>Add a submenu by calling {@link android.view.Menu#addSubMenu
-    Menu.addSubMenu()}, which returns a SubMenu object. You can then add additional
-    items to this menu. Menus can only be one level deep, and you can customize the
-    appearance of the submenu menu item. </p>
-<pre>
-&#64;Override
-public boolean onCreateOptionsMenu(Menu menu) {
-    super.onCreateOptionsMenu(menu);
-        
-    // Parameters for menu.add are:
-    // group -- Not used here.
-    // id -- Used only when you want to handle and identify the click yourself.
-    // title
-    menu.add(0, 0, "Send message");
-    menu.add(0, 1, "Settings");
-    menu.add(0, 2, "Local handler");
-    menu.add(0, 3, "Launch contact picker");
-
-    // Add our submenu.
-    SubMenu sub = menu.addSubMenu(1, 4, "Days of the week");
-    sub.add(0, 5, "Monday");
-    sub.add(0, 6, "Tuesday");
-    sub.add(0, 7, "Wednesday");
-    sub.add(0, 8, "Thursday");
-    sub.add(0, 9, "Friday");
-    sub.add(0, 10, "Saturday");
-    sub.add(0, 11, "Sunday");
-    return true;
-}
-</pre>
-<h3><strong>Adding yourself to menus on other applications</strong></h3>
-<a name="addingtoothermenus" id="addingtoothermenus"></a>
-<p>You can also advertise your Activity's services so that other Activities can add
-    your activity to their own option menu. For example, suppose you implement a
-    new image handling tool that shrinks an image to a smaller size 
-    and you would like to offer this as a menu option to any other Activity that
-    handles pictures. To do this, you would exposes your capabilities inside an intent
-    filter in your manifest. If another application that handles photos asks Android
-    for any Activities that can perform actions on pictures, Android will perform
-    intent resolution, find your Activity, and add it to the other Activity's options
-    menu. </p>
-<h4><strong>The offering application </strong></h4>
-<p>The application offering the service must include an <code>&lt;intent-filter&gt;</code> element
-    in the manifest, inside the <code>&lt;activity&gt;</code> tag of the offering
-    Activity. The intent filter includes all the details describing what it can do,
-    such as a <code>&lt;type&gt;</code> element that describes the MIME type of data
-    that it can handle, a custom <code>&lt;action&gt;</code> value that describes
-    what your handling application can do (this is so that when it receives the Intent
-    on opening it knows what it is expected to do), and most important, include a <code>&lt;category&gt;</code> filter
-    with the value <code>android.intent.category.ALTERNATIVE </code>and/or <code>android.intent.category.SELECTED_ALTERNATIVE</code> (SELECTED_ALTERNATIVE
-    is used to handle only the currently selected element on the screen, rather than
-    the whole Activity intent.</p>
-<p>Here's an example of a snip of a manifest that advertises picture shrinking technology
-    for both selected items and the whole screen. </p>
-<pre>&lt;activity class=&quot;PictureShrink&quot;&gt;                 &lt;!-- Handling class --&gt;
-    &lt;intent-filter label=&quot;Shrink picture&quot;&gt;      &lt;!-- Menu label to display --&gt;
-        &lt;action android:name=&quot;com.example.sampleapp.SHRINK_IT&quot; /&gt;
-        &lt;data android:name=&quot;image/*&quot; /&gt;                 &lt;!-- MIME type for generic images --&gt;
-        &lt;category android:name=&quot;android.intent.category.ALTERNATIVE &quot; /&gt;
-        &lt;category android:name=&quot;android.intent.category.SELECTED_ALTERNATIVE&quot; /&gt;
-    &lt;/intent-filter&gt;
-&lt;/activity&gt;</pre>
-<h4><strong>The menu-displaying application</strong></h4>
-<p>An application that wants to display a menu that includes any additional external
-    services must, first of all, handle its menu creation callback. As part of that
-    callback it creates an intent with the category Intent.ALTERNATIVE_CATEGORY and/or
-    Intent.SELECTED_ALTERNATIVE, the MIME type currently selected, and any other
-    requirements, the same way as it would satisfy an intent filter to open a new
-    Activity. It then calls menu.addIntentOptions() to have Android search for and
-    add any services meeting those requirements. It can optionally add additional
-    custom menu items of its own. </p>
-<p>You should implement SELECTED_ALTERNATIVE in onPrepareOptionsMenu() rather than
-    onCreateOptionsMenu(), because the user's selection can change after the application
-    is launched. </p>
-<p>Here's a code snippet demonstrating how a picture application would search for
-    additional services to display on its menu.</p>
-<pre>&#064;Override public boolean
-onCreateOptionsMenu(Menu menu){
-    super.onCreateOptionsMenu(menu);
-
-    // Create an Intent that describes the requirements to fulfill to be included
-    // in our menu. The offering app must include a category value of Intent.ALTERNATIVE_CATEGORY. 
-    Intent intent = new Intent(null, getIntent().getData());
-    intent.addCategory(Intent.ALTERNATIVE_CATEGORY);
-        
-    // Search for, and populate the menu with, acceptable offering applications.
-    menu.addIntentOptions(
-         0,      // Group
-         0,      // Any unique IDs we might care to add.
-         MySampleClass.class.getName(),  // Name of the class displaying the menu--here, its this class. 
-         null,   // No specifics.
-         intent, // Previously created intent that describes our requirements.
-         0,      // No flags.
-         null);  // No specifics.
-
-    return true;
-}</pre>
-<p>&nbsp;</p>
 <a name="webpage" id="webpage"></a><h2>Display a Web Page</h2>
 <p>Use the {@link android.webkit.WebView webkit.WebView} object. </p>
 <a name="binding" id="binding"></a><h2>Binding to Data</h2>
@@ -878,7 +714,7 @@
             where they can be launched (from the main program menu or elsewhere),
             any content providers it implements and what kind of data they handle,
             where the implementation classes are, and other application-wide
-            information. Syntax details for this file are described in <a href="{@docRoot}guide/topics/manifest/manifest.html">The AndroidManifest.xml File</a>.</td>
+            information. Syntax details for this file are described in <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml File</a>.</td>
     </tr>
     <tr>
         <td valign="top">&nbsp;&nbsp;&nbsp;&nbsp;src/<br />
@@ -922,7 +758,7 @@
         <td valign="top">(<em>optional</em>) Holds all the XML files describing screens or parts
             of screens. Although you could create a screen in Java, defining them
             in XML files is typically easier. A layout file is similar in concept
-            to an HTML file that describes the screen layout and components. See <a href="{@docRoot}guide/topics/views/index.html">Views and Layout</a> for more information about designing screens, and <a href="{@docRoot}guide/topics/resources/available-resources.html#layoutresources">Available Resource Types</a> for the syntax of these files.</td>
+            to an HTML file that describes the screen layout and components. See <a href="{@docRoot}guide/topics/ui/index.html">User Interface</a> for more information about designing screens, and <a href="{@docRoot}guide/topics/resources/available-resources.html#layoutresources">Available Resource Types</a> for the syntax of these files.</td>
     </tr>
     <tr>
         <td valign="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;values/<br />
diff --git a/docs/html/guide/appendix/faq/framework.jd b/docs/html/guide/appendix/faq/framework.jd
index c5cfcf1..76a19c5 100644
--- a/docs/html/guide/appendix/faq/framework.jd
+++ b/docs/html/guide/appendix/faq/framework.jd
@@ -1,4 +1,6 @@
 page.title=Android Application Framework FAQ
+parent.title=FAQs, Tips, and How-to
+parent.link=index.html
 @jd:body
 
 <ul>
diff --git a/docs/html/guide/appendix/faq/licensingandoss.jd b/docs/html/guide/appendix/faq/licensingandoss.jd
index 98be91c..c267fe81 100644
--- a/docs/html/guide/appendix/faq/licensingandoss.jd
+++ b/docs/html/guide/appendix/faq/licensingandoss.jd
@@ -1,4 +1,6 @@
 page.title=Android Open Source Licensing FAQ
+parent.title=FAQs, Tips, and How-to
+parent.link=index.html
 @jd:body
 
 <ul>
diff --git a/docs/html/guide/appendix/faq/security.jd b/docs/html/guide/appendix/faq/security.jd
index 1c66f95..b0d832b 100644
--- a/docs/html/guide/appendix/faq/security.jd
+++ b/docs/html/guide/appendix/faq/security.jd
@@ -1,4 +1,6 @@
 page.title=Android Security FAQ
+parent.title=FAQs, Tips, and How-to
+parent.link=index.html
 @jd:body
 
 <ul>
diff --git a/docs/html/guide/appendix/faq/troubleshooting.jd b/docs/html/guide/appendix/faq/troubleshooting.jd
index e10f661..7c703e6 100644
--- a/docs/html/guide/appendix/faq/troubleshooting.jd
+++ b/docs/html/guide/appendix/faq/troubleshooting.jd
@@ -1,4 +1,6 @@
 page.title=Troubleshooting
+parent.title=FAQs, Tips, and How-to
+parent.link=index.html
 @jd:body
 
 
@@ -28,9 +30,14 @@
 <p>
 The "Android Editors" feature of the ADT Plugin requires specific Eclipse components, such as WST. If you
 encounter this error message during ADT installation, you need to install the
-required Eclipse components and then try the ADT installation again. The easiest way to install the required components for the 
-Android Editors feature of ADT is the following:
-<ul>
+required Eclipse components and then try the ADT installation again. Follow the steps below to install the required components for the 
+Android Editors feature, based on the version of Eclipse that you are using.</p>
+
+<table style="font-size:100%">
+<tr><th>Eclipse 3.3 (Europa)</th><th>Eclipse 3.4 (Ganymede)</th></tr>
+<tr>
+<td width="50%">
+<ol>
 <li>From the dialog where you select the <strong>Update sites to visit</strong>, select the checkboxes for both the
 ADT site, and the Callisto/Europa/Ganymede Discovery Site (you may want to
 check <strong>Automatically select mirrors</strong> at the bottom).</li>
@@ -41,6 +48,19 @@
 <li>On the right, click <strong>Select required</strong>. This will select all the components
 that are required to install the Android plugin (wst, emf, etc...).</li>
 <li>Click <strong>Next</strong>, accept the agreement, click <strong>Install All</strong>, and restart Eclipse.</li>
+</ol>
+</td>
+<td>
+<ol>
+    <li>Select <strong>Help</strong> &gt; <strong>Software Updates...</strong></li>
+    <li>Select the <strong>Installed Software</strong> tab.</li>
+    <li>Click <strong>Update...</strong></li>
+    <li>If an update for ADT is available, select it and click <strong>Finish</strong>.</li>
+</ol>
+</td>
+</tr>
+</table>
+
 
 </p>
 <a name="nodevice"></a><h2>ADB reports &quot;no device&quot; when an emulator is running</h2>
diff --git a/docs/html/guide/appendix/glossary.jd b/docs/html/guide/appendix/glossary.jd
index 7059643..ef81631 100644
--- a/docs/html/guide/appendix/glossary.jd
+++ b/docs/html/guide/appendix/glossary.jd
@@ -168,7 +168,7 @@
     application's package name, version, components (activities, intent
     filters, services), imported libraries, and describes the various
     activies, and so on. See <a
-    href="{@docRoot}guide/topics/manifest/manifest.html">The
+    href="{@docRoot}guide/topics/manifest/manifest-intro.html">The
     AndroidManifest.xml File</a> for complete information.</dd>
 
     <dt id="ninepatch">Nine-patch / 9-patch / Ninepatch image</dt>
diff --git a/docs/html/guide/appendix/media-formats.jd b/docs/html/guide/appendix/media-formats.jd
index 41dfd63..5419ad6 100644
--- a/docs/html/guide/appendix/media-formats.jd
+++ b/docs/html/guide/appendix/media-formats.jd
@@ -20,7 +20,7 @@
 </tr>
 
 <tr>
-<td rowspan="8">Audio</td>
+<td rowspan="9">Audio</td>
 <td>AAC LC/LTP</td>
 <td>&nbsp;</td>
 <td style="text-align: center;">X</td>
@@ -83,6 +83,14 @@
 </tr>
 
 <tr>
+<td>PCM/WAVE</td>
+<td>&nbsp;</td>
+<td style="text-align: center;">X</td>
+<td>8- and 16-bit linear PCM (rates up to limit of hardware)</td>
+<td>WAVE (.wav)</td>
+</tr>
+
+<tr>
 <td rowspan="4">Image</td>
 <td>JPEG</td>
 <td style="text-align: center;">X</td>
diff --git a/docs/html/guide/basics/anatomy.jd b/docs/html/guide/basics/anatomy.jd
deleted file mode 100755
index f4b2ad0..0000000
--- a/docs/html/guide/basics/anatomy.jd
+++ /dev/null
@@ -1,134 +0,0 @@
-page.title=Anatomy of an Android Application
-@jd:body
-<h1>Anatomy of an Android Application</h1>
-
-<p>
-There are four building blocks to an Android application:
-</p>
-
-<ul>
-  <li>Activity</li>
-  <li>Broadcast Receiver</li>
-  <li>Service</li>
-  <li>Content Provider</li>
-</ul>
-
-<p>
-Not every application needs to have all four, but your application will be written with some
-combination of these.
-</p>
-
-<p>
-Once you have decided what components you need for your application, you should list them in a file 
-called AndroidManifest.xml. This is an XML file where you declare the components of your application
-and what their capabilities and requirements are. See the 
-<a href="{@docRoot}devel/bblocks-manifest.html">Android manifest file documentation</a>
-for complete details.
-</p>
-
-<h2>Activity</h2>
-<p>
-Activities are the most common of the four Android building blocks. An activity is usually a single 
-screen in your application. Each activity is implemented as a single class that extends the 
-{@link android.app.Activity Activity} base class. Your class will display a user interface composed 
-of {@link android.view.View Views} and respond to events. Most applications consist of multiple 
-screens. For example, a text messaging application might have one screen that shows a list of 
-contacts to send messages to, a second screen to write the message to the chosen contact, and other 
-screens to review old messages or change settings. Each of these screens would be implemented as an
-activity. Moving to another screen is accomplished by a starting a new activity. In some cases an
-activity may return a value to the previous activity -- for example an activity that lets the user 
-pick a photo would return the chosen photo to the caller.
-</p>
-
-<p>
-When a new screen opens, the previous screen is paused and put onto a history stack. The user can 
-navigate backward through previously opened screens in the history. Screens can also choose to be 
-removed from the history stack when it would be inappropriate for them to remain. Android retains 
-history stacks for each application launched from the home screen.
-</p>
-
-<h3>Intent and Intent Filters</h3>
-
-<p>
-Android uses a special class called an {@link android.content.Intent Intent} to move from screen to
-screen. An intent describes what an application wants done. The two most important parts of the 
-intent data structure are the action and the data to act upon. Typical values for action are MAIN
-(the front door of the application), VIEW, PICK, EDIT, etc.  The data is expressed as a URI. 
-For example, to view contact information for a person, you would create an intent with the VIEW 
-action and the data set to a URI representing that person.
-</p>
-
-<p>
-There is a related class called an {@link android.content.IntentFilter IntentFilter}. While an 
-intent is effectively a request to do something, an intent filter is a description of what intents
- an activity (or broadcast receiver, see below) is capable of handling. An activity that is able to 
- display contact information for a person would publish an IntentFilter that said that it knows 
- how to handle the action VIEW when applied to data representing a person. 
- Activities publish their IntentFilters in the AndroidManifest.xml file.
-</p>
-
-<p>
-Navigating from screen to screen is accomplished by resolving intents. To navigate forward, an 
-activity calls <code>{@link android.app.Activity#startActivity startActivity(myIntent)}</code>. 
-The system then looks at the intent filters for all installed applications and picks the activity 
-whose intent filters best matches <code>myIntent</code>. The new activity is informed of the intent, which causes
-it to be launched. The process of resolving intents happens at run time when startActivity is 
-called, which offers two key benefits:
-</p>
-
-<ul>
-  <li>Activities can reuse functionality from other components simply by making a request in the form of an Intent</li>
-  <li>Activities can be replaced at any time by a new Activity with an equivalent IntentFilter</li>
-</ul>
-
-
-<h2>Broadcast Receiver</h2>
-
-<p>
-You can use a {@link android.content.BroadcastReceiver BroadcastReceiver} when you want code in your 
-application to execute in reaction to an external event, for example, when the phone rings, or when 
-the data network is available, or when it's midnight. Broadcast receivers do not display a UI, although 
-they may use the {@link android.app.NotificationManager NotificationManager} to alert the user if
-something interesting has happened. Broadcast receivers are registered in AndroidManifest.xml, but you 
-can also register them from code using 
-<code>{@link android.content.Context#registerReceiver Context.registerReceiver()}</code>. 
-Your application does not have to be running for its broadcast receivers to be called; the system will 
-start your application, if necessary, when a broadcast receiver is triggered. Applications can also send
-their own intent broadcasts to others with 
-<code>{@link android.content.Context#sendBroadcast Context.sendBroadcast()}</code>.
-</p>
-
-<h2>Service</h2>
-
-<p>
-A {@link android.app.Service Service} is code that is long-lived and runs without a UI. A good 
-example of this is a media player playing songs from a play list. In a media player application, 
-there would probably be one or more activities that allow the user to choose songs and start 
-playing them. However, the music playback itself should not be handled by an activity because the 
-user will expect the music to keep playing even after navigating to a new screen. In this case, the 
-media player activity could start a service using 
-<code>{@link android.content.Context#startService Context.startService()}</code> 
-to run in the background to keep the music going. The system will then keep the music playback 
-service running until it has finished.  (You can learn more about the priority given to services in 
-the system by reading 
-<a href="{@docRoot}intro/lifecycle.html">Life Cycle of an Android Application</a>.) 
-Note that you can connect to a
-service (and start it if it's not already running) with the 
-<code>{@link android.content.Context#bindService Context.bindService() }</code> method. 
-When connected to a service, you can communicate with it through an interface exposed by the 
-service. For the music service, this might allow you to pause, rewind, etc.
-</p>
-
-<h2>Content Provider</h2>
-<p>
-Applications can store their data in files, an SQLite database, or any other mechanism that makes 
-sense. A content provider, however, is useful if you want your application's data to be shared with
-other applications. A content provider is a class that implements a standard set of methods to let
-other applications store and retrieve the type of data that is handled by that content provider.
-</p>
-
-<p>
-To get more details on content providers, see
-<a href="{@docRoot}devel/data/contentproviders.html">Accessing Content Providers</a>.
-</p>
-
diff --git a/docs/html/guide/basics/android-sdk.jd b/docs/html/guide/basics/android-sdk.jd
deleted file mode 100644
index d1f3437..0000000
--- a/docs/html/guide/basics/android-sdk.jd
+++ /dev/null
@@ -1,11 +0,0 @@
-page.title=The Android SDK
-@jd:body
-
-<p>FIXME</p>
-
-<p>The downloadable Android SDK includes the Android API libraries, sample code, documentation,
-and a collection of Android development tools, like the emulator and debugger.</p>
-
-<p>The SDK supports developing on Linux, Mac OS X, and Windows (XP and Vista).</p>
-
-<p>The Java Development Kit is required.</p>
\ No newline at end of file
diff --git a/docs/html/guide/basics/app-framework.jd b/docs/html/guide/basics/app-framework.jd
deleted file mode 100644
index 8513884..0000000
--- a/docs/html/guide/basics/app-framework.jd
+++ /dev/null
@@ -1,4 +0,0 @@
-page.title=The Application Framework
-@jd:body
-
-TODO
\ No newline at end of file
diff --git a/docs/html/guide/basics/what-is-android.jd b/docs/html/guide/basics/what-is-android.jd
index 9e2801a..b75321b 100644
--- a/docs/html/guide/basics/what-is-android.jd
+++ b/docs/html/guide/basics/what-is-android.jd
@@ -2,7 +2,7 @@
 @jd:body
 
 <p>Android is a software stack for mobile devices that includes an operating
-system, middleware and key applications. This beta version of the <a
+system, middleware and key applications. The <a
 href="http://code.google.com/android/download.html">Android SDK</a>
 provides the tools and APIs necessary to begin developing applications on the
 Android platform using the Java programming language.</p>
diff --git a/docs/html/guide/developing/debug-tasks.jd b/docs/html/guide/developing/debug-tasks.jd
index a604df2..6b7c27a 100644
--- a/docs/html/guide/developing/debug-tasks.jd
+++ b/docs/html/guide/developing/debug-tasks.jd
@@ -53,7 +53,7 @@
         graphical reader called Traceview. See the linked topic for more information. </li>
 </ul>
 <ul>
-    <li><a href="#developingwitheclipse"><strong>Eclipse plugin</strong></a> - The ADT Plugin
+    <li><a href="{@docRoot}guide/developing/eclipse-adt.html"><strong>Eclipse plugin</strong></a> - The ADT Plugin
         for Eclipse integrates a number of these tools (ADB, DDMS, logcat output,
     and other functionality). See the linked topic for more information. </li>
     <li><strong>Debug and Test Device Settings</strong> - Android exposes several settings
diff --git a/docs/html/guide/developing/device.jd b/docs/html/guide/developing/device.jd
index b723797..034f707 100644
--- a/docs/html/guide/developing/device.jd
+++ b/docs/html/guide/developing/device.jd
@@ -7,8 +7,8 @@
   <ol>
     <li><a href="#devices">Available Devices</a>
       <ol>
-        <li><a href="g1">T-Mobile G1</a></li>
-        <li><a href="dev-phone-1">Android Dev Phone 1</a></li>
+        <li><a href="#g1">T-Mobile G1</a></li>
+        <li><a href="#dev-phone-1">Android Dev Phone 1</a></li>
       </ol>
     </li>
     <li><a href="#setting-up">Setting up a Device for Development</a></li>
@@ -41,8 +41,9 @@
 
 <h3 id="dev-phone-1">Android Dev Phone 1</h3>
 
+<div class="sidebox-wrapper">
 <div class="sidebox">
-<p>Selected specs for Android Dev Phone 1: </p>
+<p>Selected specs for Android Dev Phone 1:</p>
 <ul>
 <li>Touch screen</li>
 <li>Trackball</li>
@@ -58,7 +59,7 @@
 <li>Includes 1GB MicroSD card (can be replaced with up to 16GB card)</li>
 </ul>
 </div> 
-
+</div>
 <p>The Android Dev Phone 1 is a SIM-unlocked and hardware-unlocked device that
 is designed for advanced developers. The device ships with a system image that
 is fully compatible with Android 1.0, so you can rely on it when developing your
@@ -71,19 +72,19 @@
 <p>To purchase an Android Dev Phone 1 device, you must first register as an
 Android developer on the Android Market site, if you haven't done so already.
 Once you've logged into your developer account on Android Market, you can
-purchase the device by clicking the "Purchase" link. To accommodate demand,
+purchase the device by following the link to "Development phones." To accommodate demand,
 there is a limit of 1 device per developer account, for now.</p>
 
 <p>The device currently costs $399 (USD) (including free shipping in the US),
-and will be available for purchase in 18 international markets, including the
+and is available for purchase in 18 international markets, including the
 US, UK, Germany, Japan, India, Canada, France, Taiwan, Spain, Australia,
 Singapore, Switzerland, Netherlands, Austria, Sweden, Finland, Poland, and
 Hungary.  We will continue to expand this program into new geographies over
 time.  Check this page for updated information.</p>
 
 <p>Note that Android Dev Phone 1 devices are <em>not</em> intended for
-non-developer end users. Since the devices can be configured with system
-software not provided by or supported by Google or any other company, end users
+non-developer end-users. Because the device can be configured with system
+software not provided by or supported by Google or any other company, end-users
 operate these devices at their own risk.</p>
 
 <p>For full device specs and more information about obtaining an Android Dev 
@@ -109,17 +110,28 @@
   </li>
   <li>Setup your system to detect your device.
     <ul>
-      <li>If you're developing on Windows (32-bit only), you need to install the USB driver for adb:
+      <li>If you're developing on 32-bit Windows, you need to install the 32-bit USB driver for adb. 
+      The USB driver is included in the SDK package. To install it, follow these steps:</p>
         <ol>
-          <li>Download the driver ZIP file 
-          (<a href="http://dl.google.com/android/android_usb_windows.zip">android_usb_windows.zip</a>)
-          and unzip it.</li>
-          <li>Connect your Android device via USB. When the <em>Found New Hardware Wizard</em> appears, you'll be asked if you'd like Windows Update to search for software, select <em>No, not this time</em> and click <b>Next</b>.</li>
+          <li>Connect your Android device via USB. When the <em>Found New Hardware Wizard</em> appears, 
+          you'll be asked if you'd like Windows Update to search for software. Select <em>No, not this 
+          time</em> and click <b>Next</b>.</li>
 
           <li>Select <em>Install from a list or specified location</em> and click <b>Next</b>.</li>
-          <li>Select <em>Search for the best driver in these locations</em>. Browse and select the unzipped file.</li>
-          <li>Click <b>Finish</b>. You're all set.</li>
+          <li>Select <em>Search for the best driver in these locations</em>. Browse to the <code>usb_driver/x86</code> in the SDK package (<code>&lt;sdk&gt;\usb_driver\x86</code>).</li>
+          <li>Click <b>Finish</b>. The system should install the driver files as necessary. Your machine may require a reboot.</li>
+        </ol>
+      </li>
+      <li>If you're developing on 64-bit Windows Vista, you need to install the 64-bit USB driver for adb. 
+      The USB driver is included in the SDK package. To install it, follow these steps:</p>
+        <ol>
+          <li>Connect your Android device via USB. When the <em>Found New Hardware Wizard</em> appears, 
+          you'll be asked if you'd like Windows Update to search for software. Select <em>No, not this 
+          time</em> and click <b>Next</b>.</li>
 
+          <li>Select <em>Install from a list or specified location</em> and click <b>Next</b>.</li>
+          <li>Select <em>Search for the best driver in these locations</em>. Browse to the <code>usb_driver/amd64</code> in the SDK package (<code>&lt;sdk&gt;\usb_driver\amd64</code>).</li>
+          <li>Click <b>Finish</b>. The system should install the driver files as necessary. Your machine may require a reboot.</li>
         </ol>
       </li>
       <li>If you're developing on Mac OS X, it just works. Skip this step.</li>
diff --git a/docs/html/guide/developing/eclipse-adt.jd b/docs/html/guide/developing/eclipse-adt.jd
index 7177395..8c482ee 100644
--- a/docs/html/guide/developing/eclipse-adt.jd
+++ b/docs/html/guide/developing/eclipse-adt.jd
@@ -1,17 +1,28 @@
 page.title=In Eclipse, with ADT
 @jd:body
 
-<p>To begin developing Android applications in the Eclipse IDE with ADT, you first create an Android 
+<p>The Android Development Tools (ADT) plugin for Eclipse adds powerful extensions to the Eclipse integrated development environment. It allows you to create and debug Android applications easier and faster. If you use Eclipse, the ADT plugin gives you an incredible boost in developing Android applications:</p>
+
+<ul>
+  <li>It gives you access to other Android development tools from inside the Eclipse IDE. For example, ADT lets you access the many capabilities of the DDMS tool: take screenshots, manage port-forwarding, set breakpoints, and view thread and process informationd irectly from Eclipse.</li>
+  <li>It provides a New Project Wizard, which helps you quickly create and set up all of the basic files you'll need for a new Android application.</li>
+  <li>It automates and simplifies the process of building your Android application.</li>
+  <li>It provides an Android code editor that helps you write valid XML for your Android manifest and resource files.</li>
+</ul>
+
+<p>To begin developing Android applications in the Eclipse IDE with ADT, you first need to download the Eclipse IDE and then download and install the ADT plugin. To do so, follow the steps given in <a href="{@docRoot}sdk/1.1_r1/installing.html#installingplugin">Installing the ADT Plugin</a>, in the installation documentation included with your SDK package. </p>
+
+<p>Once you've installed the ADT plugin, you begin by creating an Android 
 project and then set up a launch configuration. After that, you can write, run, and debug 
 your application.  </p>
 
 <p>The sections below provide instructions assuming that you have installed the ADT plugin 
 in your Eclipse environment. If you haven't installed the ADT plugin, you should do that 
-before using the instructions below. For complete information, see the installation documentation included in your SDK package. </p>
+before using the instructions below. </p>
 
 <a name="creatingaproject" id="creatingaproject"></a>
 
-<h3>Creating an Android Project</h3>
+<h2>Creating an Android Project</h2>
 
 <p>The ADT plugin provides a New Project Wizard that you can use to quickly create an 
 Eclipse project for new or existing code. To create the project, follow these steps:</p>
@@ -49,7 +60,7 @@
 
 <a name="launchconfig" id="launchconfig"></a>
 
-<h3>Creating a Launch Configuration </h3>
+<h2>Creating a Launch Configuration </h2>
 
 <p>Before you can run and debug your application in Eclipse, you must create a launch configuration for it. A launch configuration specifies the project to launch, the Activity to start, the emulator options to use, and so on. </p>
 
@@ -78,9 +89,45 @@
 
 </ol>
 
+
+<h2 id="sign_in_adt">Setting Up Application Signing</h2>
+
+<p>As you begin developing Android applications, you should understand that all
+Android applications must be digitally signed before the system will install
+them on the emulator or an actual device. </p>
+
+<p>The ADT plugin helps you get started quickly by signing your .apk files with
+a debug key, prior to installing them on the emulator. This means that you can
+compile your application and install it on the emulator without having to
+generate your own private key. However, please note that if you intend to
+publish your application, you <em>must</em> sign the application with your own
+private key, rather than the debug key generated by the SDK tools. </p>
+
+<p>To sign your applications, the ADT plugin requires the Keytool utility
+included in the JDK. To set up your development environment for
+signing, you need to make sure that Keytool is available on your
+machine that the ADT plugin knows how to find it. </p>
+
+<p>In most cases, you can tell the SDK build tools how to find Keytool by making
+sure that your JAVA_HOME environment variable is set and that it references a 
+suitable JDK. Alternatively, you can add the JDK version of Keytool to your 
+PATH variable.</p>
+
+<p>If you are developing on a version of Linux that originally came with Gnu
+Compiler for Java, make sure that the system is using the JDK version of
+Keytool, rather than the gcj version. If keytool is already in your PATH, it
+might be pointing to a symlink at /usr/bin/keytool. In this case, check the
+symlink target to make sure that it points to the keytool in the JDK.</p>
+
+<p>In all cases, please read and understand <a
+href="{@docRoot}guide/publishing/app-signing.html">Signing Your
+Applications</a>, which provides an overview of application signing on Android
+and what it means to you as an Android application developer. </p>
+
+
 <a name="installingrunningdebugging" id="installingrunningdebugging"></a>
 
-<h3>Running and Debugging an Application</h3>
+<h2>Running and Debugging an Application</h2>
 
 <p>Once you've set up the project and launch configuration for your application, you can run or debug it as described below.</p>
 
@@ -98,7 +145,8 @@
 
         </ul>
 
-	<h2 id="tips">Eclipse Tips </h2>
+
+<h2 id="tips">Eclipse Tips </h2>
 	<h3>Executing arbitrary Java expressions in Eclipse<a name="arbitraryexpressions" id="arbitraryexpressions"></a></h3>
 	<p>You can execute arbitrary code when paused at a breakpoint in Eclipse. For example,
 	    when in a function with a String argument called &quot;zip&quot;, you can get
diff --git a/docs/html/guide/developing/instrumentation/index.jd b/docs/html/guide/developing/instrumentation/index.jd
deleted file mode 100644
index 7ebd72e..0000000
--- a/docs/html/guide/developing/instrumentation/index.jd
+++ /dev/null
@@ -1,54 +0,0 @@
-page.title=Instrumentation
-@jd:body
-
-<dl>
-    <dt><a href="inst-framework.html">Instrumentation Framework</a></dt>
-    <dt><a href="inst-testing.html">Instrumentation Testing</a></dt>
-</dl>
-
-<!--
-<p>Android provides an instrumentation framework that lets you create a bundle of instrumentation tests and attach them to your application. When you run the instrumentation from the command line, the Android system d
-
- through an <code>&lt;instrumentation&gt;</code> element in its manifest file. You write your instrumentation tests in a subclass of {@link android.app.Instrumentation}, from which you have access to a variety of methods for managing the state of the application, from within the application's process. For example, you can write instrumentation to
-<ul>
-<li>Instantiate the process's Application object
-<li>Instantiate an Activity and change it's lifecycle state
-<li>Send keypad events to the currently focused window
-<li>Execute a menu item
-<li>Take a performance snapshot, and
-<li>Attach an 
-
-When running with instrumentation turned on, the system instantiates class will be instantiated for you before any of the application code, allowing you to monitor all of the interaction the system has with the application. An Instrumentation implementation is described to the system through an AndroidManifest.xml's &lt;instrumentation> tag.
-
-
-<ul>
-    <li>
-        <a href="hierarchy.html">IntroducHierarchy of Screen Elements</a> 
-    </li>
-    <li>
-        <a href="layout.html">Common Layout Objects</a>
-    </li>
-    <li>
-        <a href="ui-xml.html">Declaring a UI in XML</a>
-    </li>
-    <li>
-        <a href="binding.html">Binding to Data with AdapterView</a>
-    </li>
-    <li>
-        <a href="ui-events.html">Handling UI Events</a>
-    </li>
-    <li>
-        <a href="themes.html">Applying Styles and Themes to Your Application</a>
-    </li>
-    <li>
-        <a href="custom-views.html">Building Custom Views</a>
-    </li>
-    <li>
-        <a href="glossary.html">UI Elements and Concepts Glossary</a>
-    </li>
-    <li>
-        <a href="{@docRoot}guide/tutorials/views/index.html">Hello Views</a>
-    </li>
-
-</ul>
--->
\ No newline at end of file
diff --git a/docs/html/guide/developing/instrumentation/inst-framework.jd b/docs/html/guide/developing/instrumentation/inst-framework.jd
deleted file mode 100644
index 17eea61..0000000
--- a/docs/html/guide/developing/instrumentation/inst-framework.jd
+++ /dev/null
@@ -1,139 +0,0 @@
-page.title=Instrumentation Framework
-@jd:body
-
-<p>This document describes how to use the Android Instrumentation Framework to write test cases. You should have a working knowledge of the following:</p>
-<ul>
-  <li> Android Application Framework </li>
-  <li> Using <code>adb</code>, <code>am</code> and various logging functionality </li>
-  <li> A brief understanding of the application of interest, that is, he names of the classes which handle the intents etc. </li>
-  <li> Junit testing. </li>
-</ul>
-<p> Each Android application runs in its own process. Instrumentation kills the application process and  restarts the process with Instrumentation. Instrumentation gives a handle to the application context used to poke around the application to validate test assertions, allowing you to write test cases to test applications at a much lower level than UI screen shot tests. Note that Instrumentation cannot catch UI bugs. </p>
-
-<p>This document covers these topics:</p>
-
-<ul>
-<li><a href="#androidInstrumentationFrameworkamCommand">Understanding the am Command</a></li>
-<li><a href="#androidInstrumentationFrameworkWritingRunning">Writing and Running Test Cases</a></li>
-<li><a href="#androidInstrumentationFrameworkTestCase">Exploring a Test Case</a></li>
-<li><a href="#androidInstrumentationFrameworkTroubleshooting">Troubleshooting</a></li>
-</ul>
-
-<a name="androidInstrumentationFrameworkamCommand"></a><h2>Understanding the am Command</h2>
-
-<p><code>am</code> is used to start and instrument activities using the adb shell command, as shown in the snippet below:</p>
-<pre class="prettify">
-&gt; adb shell am
-usage: am [start|instrument]
-       am start [-a &lt;ACTION&gt;] [-d &lt;DATA_URI&gt;] [-t &lt;MIME_TYPE&gt;]
-                [-c &lt;CATEGORY&gt; [-c &lt;CATEGORY&gt;] ...]
-                [-e &lt;EXTRA_KEY&gt; &lt;EXTRA_VALUE&gt; [-e &lt;EXTRA_KEY&gt; &lt;EXTRA_VALUE&gt; ...]
-                [-n &lt;COMPONENT&gt;] [-D] [&lt;URI&gt;]
-       am instrument [-e &lt;ARG_NAME&gt; &lt;ARG_VALUE&gt;] [-p &lt;PROF_FILE&gt;]
-                [-w] &lt;COMPONENT&gt;
-For example, to start the Contacts application you can use
-&gt; adb shell am start -n com.google.android.contacts/.ContactsActivity
-</pre>
-
-
-<a name="androidInstrumentationFrameworkWritingRunning"></a><h2>Writing and Running Test Cases</h2>
-
-<p>Each instrumentation test case is similar to an Android application with the distinction that it starts another application. For example, have a look in the <code>tests/Contacts</code> directory. </p>
-<ul>
-  <li> There should be a Makefile and an Android Manifest file. </li>
-  <li> Tests are located in <code>tests/Contacts/src/com/google/android/contactstests</code>. </li>
-  <li> The Instrumentation Test Runner is located at <code>tests/Contacts/src/com/google/android/contactstests/functional/ContactsInstrumentationTestRunner.java</code>.</li>
-</ul>
-<p>Suppose you have a makefile with <code>Contactstests</code> as the target. </p>
-<ul>
-  <li> <code>make Contactstests</code>: Compiles the test cases. </li>
-  <li> <code>adb install Contactstests.apk</code>: Installs the apk on the device. </li>
-  <li> Use the adb shell <code>am</code> command to run them. </li>
-</ul>
-<p> For options and other details, please see <a href="inst-testing.html">Instrumentation Testing</a>.</p>
-
-
-<a name="androidInstrumentationFrameworkTestCase"></a><h2>Exploring a Test Case</h2>
-
-<p> The test case described in this section adds and tests a new Contact. Note that you can send intents, register broadcast receivers, etc. </p>
-<p><code>Instrumentation.java</code> has helper functions that send key events and string, for example: </p>
-<ul>
-  <li><code>getInstrumentation()</code>: Returns the handle to the instrumentation </li>
-  <li><code>sendCharacterSync</code>: Sends a character. </li>
-  <li><code>sendStringSync</code>: Sends a string to an input box. </li>
-  <li><code>sendKeyDownUpSync</code>: Sends a specific keyevent. </li>
-  <li><code>sendTrackballEventSync</code>: Send a trackball event.</li>
-</ul>
-<p> You can find the test case below at <code>device/tests/Contacts.</code></p>
-<pre class="prettify">
-private void addNewContact(String name, int star, int phoneType, String number, String label,
-		String email, int emailType){
-	ContentValues values = new ContentValues();
-	Uri phoneUri = null;
-	Uri emailUri = null;
-
-	values.put(Contacts.People.NAME, name);
-	values.put(Contacts.People.STARRED, star);
-
-	//Add Phone Numbers
-	Uri uri = mActivity.getContentResolver().insert(Contacts.People.CONTENT_URI, values);
-	phoneUri = Uri.withAppendedPath(uri, Contacts.People.Phones.CONTENT_DIRECTORY);
-
-	values.clear();
-	values.put(Contacts.Phones.TYPE, phoneType);
-	values.put(Contacts.Phones.NUMBER, number);
-	values.put(Contacts.Phones.LABEL, label);
-	mActivity.getContentResolver().insert(phoneUri, values);
-
-	//Add Email
-	emailUri = Uri.withAppendedPath(uri, ContactMethods.CONTENT_DIRECTORY);
-
-	values.clear();
-	values.put(ContactMethods.KIND, Contacts.KIND_EMAIL);
-	values.put(ContactMethods.DATA, email);
-	values.put(ContactMethods.LABEL, "");
-	values.put(ContactMethods.TYPE, emailType);
-	mActivity.getContentResolver().insert(emailUri, values);
-}
-
-
- public void testAddSaveSingleContact(){
-	int previousCount = mActivity.getListView().getCount();
-	String message;
-
-	addNewContact(INPUT_NAME_1 + "1", "5435754532", "1" + INPUT_EMAIL_1, CONFIRM_OPTION);
-
-	message = "Added 1 to initial length=" + previousCount + ", but resulted with a count=" +
-		mActivity.getListView().getCount();
-	assertEquals(message, ++previousCount, mActivity.getListView().getCount());
-
-	// Check Content; Name; Num; Starred
-	assertEquals(INPUT_NAME_1 + "1", getTextFromView(0, android.R.id.text1));
-	assertEquals("5435754532", getTextFromView(0, android.R.id.text2));
-
-	//Check email is saved
-	//cursor = returnEmailCursorAtId("1");
-	Uri uri = Uri.parse("content://contacts/people/1");
-	uri = Uri.withAppendedPath(uri, ContactMethods.CONTENT_DIRECTORY);
-	Cursor cursor = mActivity.getContentResolver().query(uri, CONTACTS_COLUMNS, null, null, null);
-	assertTrue("returnEmailCursorAtId: Moving cursor to first row has failed", cursor.first());
-
-	int dataIndex = cursor.getColumnIndexOrThrow("data");
-	assertEquals("1" + INPUT_EMAIL_1, cursor.getString(dataIndex));
-	cursor.deactivate();
-}
-	</pre>
-
-
-<a name="androidInstrumentationFrameworkTroubleshooting"></a><h2>Troubleshooting</h2>
-
-<p>If you run your test cases and nothing appears to happen, have a look at <code>adb logcat</code>. The following is a common problem:</p>
-<pre class="prettify">
-I/dalvikvm(  688): threadid=11: attached from native, name=Binder Thread #1
-I/dalvikvm(  688): threadid=13: attached from native, name=Binder Thread #2
-W/ActivityManager(  469): Unable to find instrumentation info for: ComponentInfo{com.google.android.browser_instrumentation/com.google.android.browser_instrumentation.BrowserWebkitLayoutInstrumentation}
-D/AndroidRuntime(  688): Shutting down VM
-E/AndroidRuntime(  688): ERROR: thread attach failed
-</pre>		
-<p>It's possible that the instrumentation apk isn't installed on your device or that the package name is incorrect in the Manifest file. </p>
-
diff --git a/docs/html/guide/developing/instrumentation/inst-testing.jd b/docs/html/guide/developing/instrumentation/inst-testing.jd
index 6f69344..2dc4daa 100644
--- a/docs/html/guide/developing/instrumentation/inst-testing.jd
+++ b/docs/html/guide/developing/instrumentation/inst-testing.jd
@@ -142,8 +142,6 @@
 <p> Next, in an appropriate <code>AndroidManifest.xml</code>, define the instrumentation for the derived class with the appropriate <code>android:targetPackage</code> set.  For example, the snippet below defines the instrumentation runner for the framework tests.</p>
 
 <pre>
-&lt;uses-permission android:name="android.permission.RUN_INSTRUMENTATION" /&gt;
-
 &lt;instrumentation android:name="android.tests.FrameworkInstrumentationTestRunner"
                  android:targetPackage="com.google.android.frameworktest"
                  android:label="framework instrumentation test runner" /&gt;
diff --git a/docs/html/guide/developing/other-ide.jd b/docs/html/guide/developing/other-ide.jd
index 78871c5..7bcb509 100644
--- a/docs/html/guide/developing/other-ide.jd
+++ b/docs/html/guide/developing/other-ide.jd
@@ -2,9 +2,9 @@
 @jd:body
 
 <p>The recommended way to develop an Android application is to use 
-        <a href="#developingwitheclipse">Eclipse
-        with the ADT plugin</a>. This plugin provides editing, building,
-        and debugging functionality integrated right into the IDE. </p>
+        <a href="{@docRoot}guide/developing/eclipse-adt.html">Eclipse with the Android
+        Development Tools (ADT) plugin</a>, provided in the SDK. The ADT plugin 
+        provides editing, building,and debugging functionality integrated right into the IDE. </p>
 
 <p>However, if you'd rather develop your application in another IDE, such as IntelliJ, 
         or use Eclipse without the ADT plugin, you can do that instead. The SDK
@@ -82,6 +82,45 @@
   latest version of the application for you to deploy.</li>
 </ol>
 
+<h2 id="sign_in_other">Setting Up Application Signing</h2>
+
+<p>As you begin developing Android applications, you should understand that all
+Android applications must be digitally signed before the system will install
+them on the emulator or an actual device. </p>
+
+<p>The Android build tools help you get started quickly by signing your .apk
+files with a debug key, prior to installing them on the emulator. This means
+that you can compile your application and install it on the emulator without
+having to generate your own private key. However, please note that if you intend
+to publish your application, you <em>must</em> sign the application with your
+own private key, rather than the debug key generated by the SDK tools. </p>
+
+<p>To sign your applications, the ADT plugin requires the Keytool utility
+included in the JDK. To set up your development environment for
+signing, all you need to do is make sure that Keytool is available on your
+machine that the build tools know how to find it. </p>
+
+<p>In most cases, you can tell the SDK build tools how to find Keytool by making
+sure that 
+your JAVA_HOME environment variable is set and that it references a suitable
+JDK. Alternatively, 
+you can add the JDK version of Keytool to your PATH variable.</p>
+
+<p>If you are developing on a version of Linux that originally came with Gnu
+Compiler for Java, 
+make sure that the system is using the JDK version of Keytool, rather than the
+gcj version. 
+If keytool is already in your PATH, it might be pointing to a symlink at
+/usr/bin/keytool. 
+In this case, check the symlink target to make sure that it points to the
+keytool in the JDK.</p>
+
+<p>In all cases, please read and understand <a
+href="{@docRoot}guide/publishing/app-signing.html">Signing Your
+Applications</a>, which provides an overview of application signing on Android
+and what it means to you as an Android application developer. </p>
+
+
 <h2>Running an Android Application</h2>
 <p>To run a compiled
     application, you will upload the .apk file to the <code>/data/app/ </code>directory
@@ -122,7 +161,7 @@
         can be used without DDMS, such as displaying CPU usage or screen refresh
         rate on the emulator.</li>
     <li><strong>Configure your IDE to attach to port 8700 for debugging.</strong> We
-        include information on <a href="#eclipse">how to set up Eclipse to debug
-        your project</a>. </li>
+        include information on <a href="{@docRoot}guide/developing/debug-tasks.html#ide-debug-port">
+        how to set up Eclipse to debug your project</a>. </li>
 
 </ol>
diff --git a/docs/html/guide/developing/tools/adb.jd b/docs/html/guide/developing/tools/adb.jd
index 50fb024..b111047 100644
--- a/docs/html/guide/developing/tools/adb.jd
+++ b/docs/html/guide/developing/tools/adb.jd
@@ -104,7 +104,7 @@
 
     <pre>adb [-d|-e|-s &lt;serialNumber&gt;] &lt;command&gt; </pre>
 
-<p>When you issue a command, the program invokes an adb client. The client is not specifically associated with any emulator instance, so if multiple emulators/devices are running, you need to use the <code>-d</code> option to specify the target instance to which the command should be directed. For more information about using this option, see <a href"#directingcommands">Directing Commands to a Specific Emulator/Device Instance</a>. </p>
+<p>When you issue a command, the program invokes an adb client. The client is not specifically associated with any emulator instance, so if multiple emulators/devices are running, you need to use the <code>-d</code> option to specify the target instance to which the command should be directed. For more information about using this option, see <a href="#directingcommands">Directing Commands to a Specific Emulator/Device Instance</a>. </p>
 
 <a name="devicestatus"></a>
 
diff --git a/docs/html/guide/developing/tools/adt.jd b/docs/html/guide/developing/tools/adt.jd
index c3bd255..f28b24c 100644
--- a/docs/html/guide/developing/tools/adt.jd
+++ b/docs/html/guide/developing/tools/adt.jd
@@ -90,7 +90,7 @@
 If you are still unable to use Eclipse to download the ADT plugin, follow these steps to download and install the plugin from your computer:
 </p>
 <ol>
-<li><a href="adt_download.html">Download the ADT zip file</a> (do not unpack it).
+<li><a href="{@docRoot}sdk/adt_download.html">Download the ADT zip file</a> (do not unpack it).
 <li>Follow steps 1 and 2 in the default install instructions (above).
 <li>In Eclipse 3.3, click <strong>New Archive Site...</strong>. <br/>
     In Eclipse 3.4, click <strong>Add Site...</strong>, then <strong>Archive...</strong>
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 3e01172..ee56ebb 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -3,9 +3,9 @@
 <li><h2>Android Basics</h2>
     <ul>
       <li><a href="<?cs var:toroot ?>guide/basics/what-is-android.html">What Is Android?</a></li>
-<li><a style="color:gray;">The Android SDK</a></li>
-<li><a style="color:gray;">Walkthrough for Developers</a></li>
-      <!--       quick overview of what it's like to develop on Android -->
+<!--  <li><a style="color:gray;">The Android SDK</a></li> -->
+<!--  <li><a style="color:gray;">Walkthrough for Developers</a></li> -->
+      <!-- quick overview of what it's like to develop on Android -->
     </ul>
 </li>
 
@@ -15,15 +15,16 @@
     </ul>
     <ul>
       <li class="toggle-list">
-        <div><a href="<?cs var:toroot ?>guide/topics/views/index.html">Views and Layout</a></div>
+        <div><a href="<?cs var:toroot ?>guide/topics/ui/index.html">User Interface</a></div>
           <ul>
-            <li><a href="<?cs var:toroot ?>guide/topics/views/layout.html">Common Layout Objects</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/views/declaring-layout.html">Declaring Layout</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/views/binding.html">Binding to Data with AdapterView</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/views/ui-events.html">Handling UI Events</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/views/themes.html">Applying Styles and Themes</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/views/custom-components.html">Building Custom Components</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/views/how-android-draws.html">How Android Draws Views</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/declaring-layout.html">Declaring Layout</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/menus.html">Creating Menus</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/layout-objects.html">Common Layout Objects</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/binding.html">Binding to Data with AdapterView</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/ui-events.html">Handling UI Events</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/themes.html">Applying Styles and Themes</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/custom-components.html">Building Custom Components</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/ui/how-android-draws.html">How Android Draws Views</a></li>
           </ul>
       </li>
       <li class="toggle-list">
@@ -36,11 +37,35 @@
       <li><a href="<?cs var:toroot ?>guide/topics/intents/intents-filters.html">Intents and Intent Filtering</a></li>
       <li><a href="<?cs var:toroot ?>guide/topics/data/data-storage.html">Data Storage</a></li>
       <li><a href="<?cs var:toroot ?>guide/topics/providers/content-providers.html">Content Providers</a></li>
-      <li><a style="color:gray;">Notifications</a></li>
+<!--  <li><a style="color:gray;">Notifications</a></li> -->
       <li><a href="<?cs var:toroot ?>guide/topics/security/security.html">Security and Permissions</a></li>
 <!--  <li><a style="color:gray;">Processes and Threads</a></li> -->
 <!--  <li><a style="color:gray;">Interprocess Communication</a></li> -->
-      <li><a href="<?cs var:toroot ?>guide/topics/manifest/manifest.html">The Manifest File</a></li>
+      <li class="toggle-list">
+        <div><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml File</a></div>
+          <ul>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/action-element.html">&lt;action&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/application-element.html">&lt;application&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/category-element.html">&lt;category&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/data-element.html">&lt;data&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/service-element.html">&lt;service&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></li>
+            <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></li>
+          </ul>
+      </li>
     </ul>
     <ul>
       <li class="toggle-list">
@@ -51,22 +76,22 @@
           </ul>
       </li>
       <li><a href="<?cs var:toroot ?>guide/topics/media/index.html">Audio and Video</a></li>
-      <li class="toggle-list">
-        <div><a href="<?cs var:toroot ?>guide/topics/sensors/index.html">Sensors</a></div>
+<!--       <li class="toggle-list">
+        <div><a style="color:gray;">Sensors</a></div>
           <ul>
-            <li><a href="<?cs var:toroot ?>guide/topics/sensors/camera.html">Camera</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/sensors/compass.html">Compass</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/sensors/accelerometer.html">Accelerometer</a></li>
+            <li><a style="color:gray;">Camera</a></li>
+            <li><a style="color:gray;">Compass</a></li>
+            <li><a style="color:gray;">Accelerometer</a></li>
           </ul>
-      </li>
+      </li> -->
       <li><a href="<?cs var:toroot ?>guide/topics/location/index.html">Location</a></li>
-      <li class="toggle-list">
-        <div><a href="<?cs var:toroot ?>guide/topics/wireless/index.html">Wireless Controls</a></div>
+<!--    <li class="toggle-list">
+        <div><a style="color:gray;">Wireless Controls</a></div>
           <ul>
-            <li><a href="<?cs var:toroot ?>guide/topics/wireless/wifi.html">Wi-Fi</a></li>
-            <li><a href="<?cs var:toroot ?>guide/topics/wireless/bluetooth.html">Bluetooth</a></li>
+            <li><a style="color:gray;">Wi-Fi</a></li>
+            <li><a style="color:gray;">Bluetooth</a></li>
           </ul>
-      </li>
+      </li> -->
 <!--  <li><a style="color:gray;">Localization</a></li>  -->
     </ul>
 </li>
@@ -86,7 +111,7 @@
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/aapt.html">aapt</a></li>
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/adb.html">adb</a></li>
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/othertools.html#activitycreator">activitycreator</a></li>
-			<li><a href="<?cs var:toroot ?>guide/developing/tools/adt.html">ADT Plugin</a></li>
+<!--			<li><a href="<?cs var:toroot ?>guide/developing/tools/adt.html">ADT Plugin</a></li>-->
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/aidl.html" >aidl</a></li>
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/ddms.html" >ddms</a></li>
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/othertools.html#dx">dx</a></li>
@@ -98,8 +123,8 @@
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
 			<li><a href="<?cs var:toroot ?>guide/developing/tools/traceview.html" >Traceview</a></li>
 		  </ul></li>
-      <li><a href="<?cs var:toroot ?>guide/developing/instrumentation/index.html">Instrumentation</a></li>
-      <li><a style="color:gray;">JUnit</a></li>
+<!--      <li><a href="<?cs var:toroot ?>guide/developing/instrumentation/index.html">Instrumentation</a></li>
+      <li><a style="color:gray;">JUnit</a></li> -->
    </ul>
 
 </li>
@@ -118,19 +143,10 @@
       <li><a href="<?cs var:toroot ?>guide/practices/design/performance.html">Designing for Performance</a></li>
       <li><a href="<?cs var:toroot ?>guide/practices/design/responsiveness.html">Designing for Responsiveness</a></li>
       <li><a href="<?cs var:toroot ?>guide/practices/design/seamlessness.html">Designing for Seamlessness</a></li>
-      <li><a style="color:gray;">User Interface Guidelines</a></li>
+<!--  <li><a style="color:gray;">User Interface Guidelines</a></li> -->
     </ul>
 </li>
 
-<!-- 
-<li><h2>Best Practices (alt)</h2>
-    <ul>
-      <li><a href="<?cs var:toroot ?>guide/practices/design/index.html">Design Goals</a></li>
-      <li><a style="color:gray;">User Interface Guidelines</a></li>
-    </ul>
-</li>
--->
-
 <li><h2>Tutorials</h2>
     <ul>
       <li><a href="<?cs var:toroot ?>guide/tutorials/hello-world.html">Hello World</a></li>
@@ -155,4 +171,4 @@
 <!--
     buildToggleLists();
 //-->
-</script>
\ No newline at end of file
+</script>
diff --git a/docs/html/guide/index.jd b/docs/html/guide/index.jd
index e723235..ecbf97b 100644
--- a/docs/html/guide/index.jd
+++ b/docs/html/guide/index.jd
@@ -1,62 +1,84 @@
-page.title=Get Started
+page.title=The Developer's Guide
 @jd:body
 
-<p>Welcome to the Android Developer Guide! The <strong>Dev Guide</strong> is your conceptual and practical
-introduction to developing applications for Android. With this guide, you're free to explore 
-which ever topics interest you, based on your goals and experience.</p>
+<p>
+Welcome to the <i>Android Dev Guide</i>! The Dev Guide is 
+a practical introduction to developing applications for Android.  
+It explores the concepts behind Android, the framework for 
+constructing an application, and the tools for developing, 
+testing, and publishing software for the platform.
+</p>
 
-<p>If you're new to Android, you're probably wondering what it takes to 
-write a "Hello, World" application. So here it is:</p>
+<p>
+The Dev Guide holds most of the documentation for the Android
+platform, except for reference material on the framework API.  
+For API specifications, go to the 
+<a href="{@docRoot}reference/packages.html">Reference</a> tab above.
+</p>  
 
-<pre>
-package com.example.hello;
+<p>
+As you can see in the panel on the left, the Dev Guide is 
+divided into a handful of sections.  They are:
+<p>
 
-import android.app.Activity;
-import android.os.Bundle;
-import android.widget.TextView;
+<dl>
+<dt><b>Android Basics</b></dt>
+<dd>An initial orientation to Android &mdash; what it is, 
+what it offers, and how your application fits in.</dd>
 
-public class HelloWorld extends Activity {
+<dt><b>Framework Topics</b></dt>
+<dd>Discussions of particular parts of the Android framework
+and API.  For an overview of the framework, begin with
+<a href="{@docRoot}guide/topics/fundamentals.html">Application
+Fundamentals</a>.  Then explore other topics &mdash; from 
+designing a user interface and setting up resources to storing 
+data and using permissions &mdash; as needed.</dd>
 
-   public void onCreate(Bundle savedInstanceState) {
-       super.onCreate(savedInstanceState);
-       TextView tv = new TextView(this);
-       tv.setText(&quot;Hello, World&quot;);
-       setContentView(tv);
-   }
+<dt><b>Developing</b></dt>
+<dd>Directions for using Android's development and debugging tools, 
+and for testing the results.</dd>
 
-}
-</pre>
+<dt><b>Publishing</b></dt>
+<dd>Instructions on how to prepare your application for deployment
+and how to publish it when it's ready.</dd>
 
-<p>That's the only code you need to write!</p>
+<dt><b>Best Practices</b></dt> 
+<dd>Recommendations on preferred techniques for writing  
+applications that perform efficiently and work well for the
+user.</dd>
 
-<h2 class="small-header">Not convinced?</h2>
-<p>If you're still shouting "Show me the code!" then take a look at
-more Android code in the <a href="{@docRoot}guide/tutorials/hello-world/index.html">Hello World Samples</a>.</p>
+<dt><b>Tutorials and Samples</b></dt> 
+<dd>Step-by-step tutorials and sample code demonstrating how 
+an Android application is constructed.</dd>
 
-<h2 class="small-header">Ready to start?</h2>
-<p>If you're already convinced you want to develop on Android,
-then we'll teach you how to build and run this "Hello, World" application in the
-<a href="{@docRoot}guide/tutorials/hello-world.html">Hello World Introduction</a>.</p>
+<dt><b>Appendix</b></dt>
+<dd>Reference information and specifications, as well as FAQs, 
+a glossary of terms, and other information.</dd>
+</dl>
 
-<h2 class="small-header">Ready for more?</h2>  
-<p>Once you've got your feet wet (or just want to skip to the heart of Android), the following
-sections of the Dev Guide will educate you on the Android ins, outs, idioms and techniques:</p>
-<ul>
-  <li><em>Android Basics</em>:
-    Learn more about what Android is, what it offers, and how your application fits in.</li>
-  <li><em>Framework Topics</em>: 
-    Become well versed in the practical matters of developing on Android &mdash; from drawing a UI, to storing data,
-    to drawing 3D graphics, and much more.</li>
-  <li><em>Developing</em>: 
-    Learn more about developing with IDEs, using Android develop/debug tools, and testing.</li>
-  <li><em>Publishing</em>: 
-    Learn how to get you application out there, for the world to enjoy!</li>
-  <li><em>Best Practices</em>: 
-    Get some recommendations on preferred techniques to write the best applications.</li>
-  <li><em>Tutorials</em>: 
-    Get help doing some of the basics, step by step.</li>
-  <li><em>Appendix</em>: 
-    Flotsam and jetsam. Find some of those spare nuggets of information.</li>
-</ul>
+<p>
+The first step in programming for Android is downloading the SDK
+(software development kit).  For instructions and information about
+the kit, go to the <a href="{@docRoot}sdk/index.html">SDK</a> tab above.
+</p>
 
-<p>For more help, you should consider joining one or more of the Android discussion groups. See the <a href="{@docRoot}community/index.html">Community</a> for more information.</p>
+<p>
+After you have the SDK, begin by looking over the Dev Guide.
+If you want to start by getting a quick look at the code, the short 
+<a href="{@docRoot}guide/tutorials/hello-world.html">Hello World</a>
+tutorial walks you through a standard "Hello, World" application as 
+it would be written for the Android platform.  The 
+<a href="{@docRoot}guide/topics/fundamentals.html">Application
+Fundamentals</a> document is a good place to start for an 
+understanding of the application framework.
+</p>
+
+
+<p>
+For additional help, consider joining one or more of the Android 
+discussion groups.  Go to the 
+<a href="{@docRoot}community/index.html">Community</a> tab above 
+for more information.
+</p>
+
+<p>To return to this page later, just click the "Dev Guide" tab while any Dev Guide page is loaded. </p>
\ No newline at end of file
diff --git a/docs/html/guide/practices/design/seamlessness.jd b/docs/html/guide/practices/design/seamlessness.jd
index caf0d6a..a6c1641 100644
--- a/docs/html/guide/practices/design/seamlessness.jd
+++ b/docs/html/guide/practices/design/seamlessness.jd
@@ -164,7 +164,7 @@
 avoid rolling your own as much as possible. Instead, use a Theme. You
 can override or extend those parts of the theme that you need to, but at least
 you're starting from the same UI base as all the other applications. For all
-the details, read <a href="{@docRoot}guide/topics/views/themes.html">Applying Styles and Themes</a>.</p>
+the details, read <a href="{@docRoot}guide/topics/ui/themes.html">Applying Styles and Themes</a>.</p>
 
 <h2 id="flexui">Design Your UI to Work with Multiple Screen Resolutions</h2>
 
@@ -208,7 +208,6 @@
 
 <h2 id="keyboard">Don't Assume Touchscreen or Keyboard</h2>
 
-Keyboad Different Keystrokes for Different Folks</h2>
 <p>
 Android will support a variety of handset form-factors.  That's a fancy way of
 saying that some Android devices will have full "QWERTY" keyboards, while
@@ -220,8 +219,6 @@
 in restricting your application so that it can only be used on those devices.
 </p>
 
-<h2 id="network">Assume the Network is Slow</h2>
-<h2 id="keyboard">Don't Assume Touchscreen or Keyboard</h2>
 <h2 id="battery">Do Conserve the Device Battery</h2>
 <p>
 A mobile device isn't very mobile if it's constantly plugged into the
diff --git a/docs/html/guide/publishing/preparing.jd b/docs/html/guide/publishing/preparing.jd
index 1f3c624..267cba2 100644
--- a/docs/html/guide/publishing/preparing.jd
+++ b/docs/html/guide/publishing/preparing.jd
@@ -175,7 +175,7 @@
 
 <div class="sidebox" style="margin-bottom:.5em;"><p>For complete information
 about getting a Maps API Key, see <a
-href="{@docRoot}guide/developing/mapkey.html">Obtaining a Maps API
+href="{@docRoot}guide/topics/location/geo/mapkey.html">Obtaining a Maps API
 Key</a>.<br></p></div>
 
 <p>If your application uses one or more 
diff --git a/docs/html/guide/publishing/publishing.jd b/docs/html/guide/publishing/publishing.jd
index 1a022dd..aed244e 100644
--- a/docs/html/guide/publishing/publishing.jd
+++ b/docs/html/guide/publishing/publishing.jd
@@ -21,10 +21,10 @@
     <li><a href="#marketupgrade">Publishing Upgrades on Android Market</a>
     <li><a href="#marketintent">Using Intents to Launch the Market Application</a></li>
     </ol></li>
-
+<!--
 <li><span style="color:ccc">Publishing on Other Hosted Services</a></li>
 <li><span style="color:ccc">Publishing through a Web Server</a></li>
-
+-->
 </ol>
 
 <h2>See also</h2>
diff --git a/docs/html/guide/publishing/versioning.jd b/docs/html/guide/publishing/versioning.jd
index 1f4df0b..d106266 100644
--- a/docs/html/guide/publishing/versioning.jd
+++ b/docs/html/guide/publishing/versioning.jd
@@ -13,12 +13,20 @@
 <li>Determine your versioning strategy early in the development process, including considerations for future releases.</li>
 </ul>
 
+<h2>In this document</h2>
+
+<ol>
+<li><a href="#appversion">Setting Application Version</a></li>
+<li><a href="#minsdkversion">Specifying Minimum System API Version</a>
+</ol>
+
+
 <h2>See also</h2>
 
 <ol>
 <li><a href="{@docRoot}guide/publishing/preparing.html">Preparing to Publish Your Application</a></li>
 <li><a href="{@docRoot}guide/publishing/publishing.html#market">Publishing On Android Market</a></li>
-<li><a href="{@docRoot}guide/topics/manifest/manifest.html">The Manifest File</a></li>
+<li><a href="{@docRoot}guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml File</a></li>
 </ol>
 
 </div>
@@ -40,11 +48,17 @@
 determine compatibility and establish upgrade/downgrade relationships.</li>
 </ul>
 
-<p>The Android system itself <em>does not ever</em> check the version
+<p>The Android system itself <em>does not ever</em> check the application version
 information for an application, such as to enforce restrictions on upgrades,
 compatibility, and so on. Instead, only users or applications themselves are
-responsible for enforcing any version restrictions. </p>
+responsible for enforcing any version restrictions for applications themselves. </p>
 
+<p>The Android system <em>does</em> check any system version compatibility expressed 
+by an application in its manifest, in the <code>minSdkVersion</code> attribute. This
+allows an application to specify the minimum system API with which is compatible. 
+For more information see <a href="#minsdkversion">Specifying Minimum System API Version</a>.
+
+<h2 id="appversioning">Setting Application Version</h2>
 <p>To define the version information for your application, you set attributes in
 the application's manifest file. Two attributes are available, and you should
 always define values for both of them: </p>
@@ -111,8 +125,15 @@
 {@link android.content.pm.PackageManager#getPackageInfo(java.lang.String, int)} 
 method of {@link android.content.pm.PackageManager PackageManager}. </p>
 
+<h2 id="#minsdkversion">Specifying Minimum System API Version</h2>.
+
 <p>If your application requires a specific minimum version of the Android
-platform, you can also specify that in the manifest file: </p>
+platform, you can specify that version as an API Level identifier 
+in the application's manifest file. Doing so ensures that your 
+application can only be installed on devices that
+are running a compatible version of the Android system. </p>
+
+<p>To specify the minimum system version in the manifest, use this attribute: </p>
 
 <ul>
 <li><code>android:minSdkVersion</code> &mdash; An integer value corresponding to
@@ -129,7 +150,6 @@
 <p>To specify a minimum platform version for your application, add a
 <code>&lt;uses-sdk&gt;</code> element as a child of
 <code>&lt;manifest&gt;</code>, then define the
-<code>android:minSdkVersion</code> as an attribute. Currently, only one platform
-version has been released for mobile devices &mdash; that version is "1". For
-this reason, you do not need to define this attribute in your application and,
-at this point, defining it is <em>not recommended</em>.</p>
\ No newline at end of file
+<code>android:minSdkVersion</code> as an attribute. </p>
+
+<p>For more information, also see the <a href="{@docRoot}sdk/android-1.1.html">Android System Image 1.1 Version Notes</a>.</p>
\ No newline at end of file
diff --git a/docs/html/guide/topics/fundamentals.jd b/docs/html/guide/topics/fundamentals.jd
index 7118ceb..3e1501c 100644
--- a/docs/html/guide/topics/fundamentals.jd
+++ b/docs/html/guide/topics/fundamentals.jd
@@ -17,6 +17,7 @@
 <li><a href="#appcomp">Application Components</a>
   <ol>
     <li><a href="#actcomp">Activating components: intents</a></li>
+    <li><a href="#endcomp">Shutting down components</a></li>
     <li><a href="#manfile">The manifest file</a></li>
     <li><a href="#ifilters">Intent filters</a></li>
   </ol></li>
@@ -27,8 +28,14 @@
     <li><a href="#clearstack">Clearing the stack</a></li>
     <li><a href="#starttask">Starting tasks</a></li>
   </ol></li>
-<li><a href="#procthread">Processes and Threads</a></li>
-<li><a href="#lcycles">Lifecycles</a>
+<li><a href="#procthread">Processes and Threads</a>
+  <ol>
+    <li><a href="#procs">Processes</a></li>
+    <li><a href="#threads">Threads</a></li>
+    <li><a href="#rpc">Remote procedure calls</a></li>
+    <li><a href="#tsafe">Thread-safe methods</a></li>
+  </ol></li>
+<li><a href="#lcycles">Component Lifecycles</a>
   <ol>
     <li><a href="#actlife">Activity lifecycle</a></li>
     <li><a href="#servlife">Service lifecycle</a></li>
@@ -40,13 +47,14 @@
 
 <p>
 Android applications are written in the Java programming language. 
-The compiled Java code &mdash; along with data and 
-resource files required by the application and a manifest describing the
-application &mdash; is bundled by the aapt tool into an <i>Android package</i>, 
-an archive file marked by an {@code .apk} suffix.  This file is the vehicle 
-for distributing the application and installing it on mobile devices; it's 
-the file users download to their devices.  All the code in a single 
-{@code .apk} file is considered to be one <i>application</i>.
+The compiled Java code &mdash; along with any data and resource 
+files required by the application &mdash; is bundled by the 
+<a href="{@docRoot}guide/developing/tools/aapt.html"><code>aapt</code> 
+tool</a> into an <i>Android package</i>, an archive file 
+marked by an {@code .apk} suffix.  This file is the vehicle 
+for distributing the application and installing it on mobile devices; 
+it's the file users download to their devices.  All the code in a 
+single {@code .apk} file is considered to be one <i>application</i>.
 </p>
 
 <p>
@@ -76,7 +84,7 @@
 </p>
 
 
-<h2><a name="appcomp"></a>Application Components</h2>
+<h2 id="appcomp">Application Components</h2>
 
 <p>
 A central feature of Android is that one application can make use of elements 
@@ -125,24 +133,31 @@
 Each activity is given a default window to draw in.  Typically, the window 
 fills the screen, but it might be smaller than the screen and float on top 
 of other windows.  An activity can also make use of additional windows &mdash; 
-for example, a window that presents users with vital information when they 
-select a particular item on-screen, or a pop-up dialog that calls for a user 
-response in the midst of the activity.
+for example, a pop-up dialog that calls for a user response in the midst of 
+the activity, or a window that presents users with vital information when they 
+select a particular item on-screen.
 </p>
 
 <p>
 The visual content of the window is provided by a hierarchy of views &mdash; 
 objects derived from the base {@link android.view.View} class.  Each view 
-draws in a particular rectangular space within the window and responds to user 
-actions directed at that space.  Android has a number of ready-made views that 
-you can use &mdash; including buttons, text fields, scroll bars, menu items, 
-check boxes, and more.  A view hierarchy is placed within the activity's 
-window by the <code>{@link android.app.Activity#setContentView 
-Activity.setContentView()}</code> method.  The <i>content view</i> 
-is the View object at the root of the hierarchy.  
-(See <a href="{@docRoot}guide/topics/views/index.html">Views and Layout</a> 
-for more information on views and the heirarchy.)
-</p></dd>
+controls a particular rectangular space within the window.  Parent views 
+contain and organize the layout of their children.  Leaf views (those at the 
+bottom of the hierarchy) draw in the rectangles they control and respond to 
+user actions directed at that space.  Thus, views are where the activity's 
+interaction with the user takes place.  For example, a view might display 
+a small image and initiate an action when the user taps that image.  Android 
+has a number of ready-made views that you can use &mdash; including buttons, 
+text fields, scroll bars, menu items, check boxes, and more.
+</p>
+
+<p>
+A view hierarchy is placed within an activity's window by the 
+<code>{@link android.app.Activity#setContentView Activity.setContentView()}</code> 
+method.  The <i>content view</i> is the View object at the root of the hierarchy.  
+(See the separate <a href="{@docRoot}guide/topics/ui/index.html">User Interface</a> 
+document for more information on views and the hierarchy.)
+</p>
 
 <p><dt><b>Services</b></dt>
 <dd>A <i>service</i> doesn't have a visual user interface, but rather runs in 
@@ -152,13 +167,13 @@
 that need it.  Each service extends the {@link android.app.Service} base class.
 
 <p>
-A good example is a media player playing songs from a play list.  The player 
+A prime example is a media player playing songs from a play list.  The player 
 application would probably have one or more activities that allow the user to 
 choose songs and start playing them.  However, the music playback itself would 
 not be handled by an activity because users will expect the music to keep 
 playing even after they leave the player and begin something different.  
 To keep the music going, the media player activity could start a service to run 
-in the background.  The system will then keep the music playback service running 
+in the background.  The system would then keep the music playback service running 
 even after the activity that started it leaves the screen.
 </p>
 
@@ -180,8 +195,10 @@
 <dd>A <i>broadcast receiver</i> is a component that does nothing but 
 receive and react to broadcast announcements.  Many broadcasts originate in 
 system code &mdash; for example, announcements that the timezone has changed, 
-that the battery is low, that the keyboard has been exposed, or that the user 
-changed a language preference.
+that the battery is low, that a picture has been taken, or that the user 
+changed a language preference.  Applications can also initiate broadcasts
+&mdash; for example, to let other applications know that some data has been
+downloaded to the device and is available for them to use.
 
 <p>
 An application can have any number of broadcast receivers to respond to any 
@@ -227,19 +244,19 @@
 </p>
 
 
-<h3><a name="actcomp"></a>Activating components: intents</h3> 
+<h3 id="actcomp">Activating components: intents</h3> 
 
 <p>
 Content providers are activated when they're targeted by a request from a 
 ContentResolver.  The other three components &mdash; activities, services, 
 and broadcast receivers &mdash; are activated by asynchronous messages 
 called <i>intents</i>.  An intent is an {@link android.content.Intent} 
-object that holds the content of the message.  Among other things, it names 
-the action an activity or service is being requested to take and specifies 
-the URI of the data to act on.  For broadcast receivers, it names the 
-action being announced.  For example, it might convey a request for 
+object that holds the content of the message.  For activities and services,
+it names the action being requested and specifies the URI of the data to 
+act on, among other things. For example, it might convey a request for 
 an activity to present an image to the user or let the user edit some
-text.  Or it might announce to interested broadcast receivers that the 
+text.  For broadcast receivers, the Intent object names the action being 
+announced.  For example, it might announce to interested parties that the 
 camera button has been pressed.
 </p>
 
@@ -281,13 +298,19 @@
 Similarly, an intent can be passed to <code>{@link 
 android.content.Context#bindService Context.bindService()}</code> to 
 establish an ongoing connection between the calling component and a 
-target service.  It initiates the service if it's not already running.  
-The service receives the Intent object in
+target service.  The service receives the Intent object in
 an <code>{@link android.app.Service#onBind onBind()}</code> call.
-For example, an activity might establish a connection with the music 
-playback service mentioned earlier so that it could provide the user 
-with an interface for controlling the playback.  The activity would 
-call {@code bindService()} to set up that connection.
+(If the service is not already running, {@code bindService()} can
+optionally start it.)  For example, an activity might establish a connection 
+with the music playback service mentioned earlier so that it can provide 
+the user with the means (a user interface) for controlling the playback.  
+The activity would call {@code bindService()} to set up that connection, 
+and then call methods defined by the service to affect the playback.
+</p>
+
+<p>
+A later section, <a href="#rpc">Remote procedure calls</a>, has more details 
+about binding to a service.
 </p>
 </li>
 
@@ -304,12 +327,49 @@
 </ul>
 
 <p>
-For more on intent messages, see the separate article, <a 
-href="{@docRoot}guide/topics/intents/intents-filters.html">Intents 
+For more on intent messages, see the separate article, 
+<a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents 
 and Intent Filters</a>.
+</p>
 
 
-<h3><a name="manfile"></a>The manifest file</h3>
+<h3 id="endcomp">Shutting down components</h3>
+
+<p>
+A content provider is active only while it's responding to a request from 
+a ContentResolver.  And a broadcast receiver is active only while it's 
+responding to a broadcast message.  So there's no need to explicitly shut 
+down these components.
+</p>
+
+<p>
+Activities, on the other hand, provide the user interface.  They're 
+in a long-running conversation with the user and may remain active, 
+even when idle, as long as the conversation continues.  Similarly, services 
+may also remain running for a long time.  So Android has methods to shut 
+down activities and services in an orderly way:
+</p>
+
+<ul>
+<li>An activity can be shut down by calling its
+<code>{@link android.app.Activity#finish finish()}</code> method.  One activity can
+shut down another activity (one it started with {@code startActivityForResult()}) by 
+calling <code>{@link android.app.Activity#finishActivity finishActivity()}</code>.</li>
+
+<li>A service can be stopped by calling its
+<code>{@link android.app.Service#stopSelf stopSelf()}</code> method, or by calling 
+<code>{@link android.content.Context#stopService Context.stopService()}</code>.</li>
+</ul>
+
+<p>
+Components might also be shut down by the system when they are no longer being
+used or when Android must reclaim memory for more active components.  A later
+section, <a href="#lcycles">Component Lifecycles</a>, discusses this
+possibility and its ramifications in more detail.
+</p>
+
+
+<h3 id="manfile">The manifest file</h3>
 
 <p>
 Before Android can start an application component, it must learn that 
@@ -344,8 +404,9 @@
 &lt/manifest&gt;</pre>
 
 <p>
-The {@code name} attribute of the {@code &lt;activity&gt;} element 
-names the {@link android.app.Activity} subclass that implements the 
+The {@code name} attribute of the 
+<code><a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code>
+element names the {@link android.app.Activity} subclass that implements the 
 activity.  The {@code icon} and {@code label} attributes point to 
 resource files containing an icon and label that can be displayed 
 to users to represent the activity.
@@ -353,24 +414,28 @@
 
 <p>
 The other components are declared in a similar way &mdash; 
-{@code &lt;service&gt;} elements for services, {@code &lt;receiver&gt;}
-elements for broadcast receivers, and {@code &lt;provider&gt;} elements
-for content providers.  Activities, services, and content providers that 
-are not declared in the manifest are not visible to the system and are 
-consequently never run.  Broadcast receivers can be declared in the 
-manifest, or they can be created dynamically in code (as 
-{@link android.content.BroadcastReceiver} objects) 
-and registered with the system by calling <code>{@link 
-android.content.Context#registerReceiver Context.registerReceiver()}</code>.
+<code><a href="{@docRoot}guide/topics/manifest/service-element.html">&lt;service&gt;</a></code>
+elements for services,
+<code><a href="{@docRoot}guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></code>
+elements for broadcast receivers, and 
+<code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code>
+elements for content providers.  Activities, services, and content providers 
+that are not declared in the manifest are not visible to the system and are 
+consequently never run.  However, broadcast receivers can either be 
+declared in the manifest, or they can be created dynamically in code 
+(as {@link android.content.BroadcastReceiver} objects) 
+and registered with the system by calling 
+<code>{@link android.content.Context#registerReceiver Context.registerReceiver()}</code>.
 </p>
 
 <p>
 For more on how to structure a manifest file for your application, see 
-<a href="{@docRoot}guide/topics/manifest/manifest.html">The Manifest File</a>.
+<a href="{@docRoot}guide/topics/manifest/manifest-intro.html">The 
+AndroidManifest.xml File</a>.
 </p>
 
 
-<h3><a name="ifilters"></a>Intent filters</h3>
+<h3 id="ifilters">Intent filters</h3>
 
 <p>
 An Intent object can explicitly name a target component.  If it does,
@@ -442,7 +507,7 @@
 </p>
 
 
-<h2><a name="acttask"></a>Activities and Tasks</h2>
+<h2 id="acttask">Activities and Tasks</h2>
 
 <p>
 As noted earlier,  one activity can start another, including one defined 
@@ -467,14 +532,14 @@
 the new activity is pushed on the stack; it becomes the running activity.  
 The previous activity remains in the stack.  When the user presses the BACK key, 
 the current activity is popped from the stack, and the previous one resumes as 
-the running activity.  Activities in the stack are never rearranged, only 
-pushed and popped.  
+the running activity.  
 </p>
 
 <p>
 The stack contains objects, so if a task has more than one instance of the same 
 Activity subclass open &mdash; multiple map viewers, for example &mdash; the 
-stack has a separate entry for each instance.
+stack has a separate entry for each instance.  Activities in the stack are never 
+rearranged, only pushed and popped.
 </p>
 
 <p>
@@ -505,7 +570,8 @@
 But there are ways to modify almost all aspects of it.  The association of 
 activities with tasks, and the behavior of an activity within a task, is 
 controlled by the interaction between flags set in the Intent object that
-started the activity and attributes set in the activity's {@code &lt;activity&gt;}
+started the activity and attributes set in the activity's 
+<code><a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code>
 element in the manifest.  Both requester and respondent have a say in what happens.
 </p>
 
@@ -529,19 +595,19 @@
 
 <p>
 The following sections describe what some of these flags and attributes do,
-and how they interact.
+how they interact, and what considerations should govern their use.
 </p>
 
 
-<h3><a name="afftask"></a>Affinities and new tasks</h3>
+<h3 id="afftask">Affinities and new tasks</h3>
 
 <p>
 By default, all the activities in an application have an <i>affinity</i> for each 
 other &mdash; that is, there's a preference for them all to belong to the 
 same task.  However, an individual affinity can be set for each activity 
-with the {@code taskAffinity} attribute.  Activities defined in different 
-applications can share an affinity, or activities defined in the same 
-application can be assigned different affinities.  
+with the {@code taskAffinity} attribute of the {@code &lt;activity&gt;} element. 
+Activities defined in different applications can share an affinity, or activities 
+defined in the same application can be assigned different affinities.  
 The affinity comes into play in two circumstances:  When the Intent object 
 that launches an activity contains the {@code FLAG_ACTIVITY_NEW_TASK} flag, 
 and when an activity has its {@code allowTaskReparenting} attribute set 
@@ -550,26 +616,28 @@
 
 <dl>
 <dt>The <code>{@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK}</code> flag</dt>
-<dd>As mentioned earlier, a new activity is, by default, launched into 
+<dd>As described earlier, a new activity is, by default, launched into 
 the task of the activity that called {@code startActivity()}.  It's pushed
  onto the same stack as the caller.  However, if the Intent object passed 
 to {@code startActivity()} contains the {@code FLAG_ACTIVITY_NEW_TASK} 
 flag, the system looks for a different task to house the new activity.  
 Often, as the name of the flag implies, it's a new task.  However, it 
-doesn't have to be.  If there's an existing task with the same affinity 
-as the new activity, the activity is launched into that task.  If not, 
-it begins a new task.</dd>
+doesn't have to be.  If there's already an existing task with the same 
+affinity as the new activity, the activity is launched into that task.  If 
+not, it begins a new task.</dd>
 
-<dt>The {@code allowTaskReparenting} attribute</dt>
-<dd>If an activity has its {@code allowTaskReparenting} attribute is 
-set to "{@code true}", it can move from the task it starts in to the task 
+<dt>The <code><a 
+href="{@docRoot}guide/topics/manifest/activity-element.html#reparent">allowTaskReparenting</a></code>
+attribute</dt>
+<dd>If an activity has its {@code allowTaskReparenting} attribute set 
+to "{@code true}", it can move from the task it starts in to the task 
 it has an affinity for when that task comes to the fore.  For example, 
 suppose that an activity that reports weather conditions in selected 
 cities is defined as part of a travel application.  It has the same
 affinity as other activities in the same application (the default 
 affinity) and it allows reparenting.  One of your activities 
 starts the weather reporter, so it initially belongs to the same task as 
-your activity.  However, when the travel application, next comes forward, 
+your activity.  However, when the travel application next comes forward, 
 the weather reporter will be reassigned to and displayed with that task.</dd>
 </dl>
 
@@ -580,65 +648,116 @@
 </p>
 
 
-<h3><a name="lmodes"></a>Launch modes</h3>
+<h3 id="lmodes">Launch modes</h3>
 
 <p>
 There are four different launch modes that can be assigned to an {@code
-&lt;activity&gt;} element's {@code launchMode} attribute:
+&lt;activity&gt;} element's 
+<code><a href="{@docRoot}guide/topics/manifest/activity-element.html#lmode">launchMode</a></code> 
+attribute:
 </p>
 
-<p style="margin-left: 2em">"{@code standard}" (the default value)
+<p style="margin-left: 2em">"{@code standard}" (the default mode)
 <br>"{@code singleTop}"
 <br>"{@code singleTask}"
 <br>"{@code singleInstance}"</p>
 
 <p>
-The launch mode determines three things:
+The modes differ from each other on these four points:
 </p>
 
 <ul>
-<li>Whether the activity can belong to a task that includes other
-activities.  The answer is yes for all the modes except 
-"{@code singleInstance}".  A "{@code singleInstance}" activity is always 
-the only activity in its task.  If it tries to launch another activity, 
-that activity is assigned to a different task &mdash; as if {@code
-FLAG_ACTIVITY_NEW_TASK} was in the intent.</li>
 
-<li><p>Whether the activity always begins a task.  For "{@code singleTask}"
-and "{@code singleInstance}" the answer is yes.  They mark activities that
-can only be the root activities of a task; they define a task.  In contrast, 
-"{@code standard}" and "{@code singleTop}" activities can belong to any task.
+<li><b>Which task will hold the activity that responds to the intent</b>.  
+For the "{@code standard}" and "{@code singleTop}" modes, it's the task that 
+originated the intent (and called 
+<code>{@link android.content.Context#startActivity startActivity()}</code>) 
+&mdash; unless the Intent object contains the 
+<code>{@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK}</code> flag.  
+In that case, a different task is chosen as described in the previous 
+section, <a href="#afftask">Affinities and new tasks</a>.  
+
+<p>
+In contrast, the "{@code singleTask}" and "{@code singleInstance}" modes mark 
+activities that are always at the root of a task.  They define a task; they're
+never launched into another task.
+</p>  
+
+<li><p><b>Whether there can be multiple instances of the activity</b>.  
+A "{@code standard}" or "{@code singleTop}" activity can be instantiated
+many times.  They can belong to multiple tasks, and a given task can have 
+multiple instances of the same activity.
+</p> 
+
+<p>
+In contrast, "{@code singleTask}" and "{@code singleInstance}" activities 
+are limited to just one instance.  Since these activities are at the root
+of a task, this limitation means that there is never more than a single
+instance of the task on the device at one time.
+</p>    
+
+<li><p><b>Whether the instance can have other activities in its task</b>.  
+A "{@code singleInstance}" activity stands alone as the only activity in its 
+task.  If it starts another activity, that activity will be launched into a 
+different task regardless of its launch mode &mdash; as if {@code
+FLAG_ACTIVITY_NEW_TASK} was in the intent.  In all other respects, the 
+"{@code singleInstance}" mode is identical to "{@code singleTask}".</p>
+
+<p>
+The other three modes permit multiple activities to belong to the task.
+A "{@code singleTask}" activity will always be the root activity of the task, 
+but it can start other activities that will be assigned to its
+task.  Instances of "{@code standard}" and "{@code singleTop}"
+activities can appear anywhere in a stack.  
 </p></li>
 
-<li><p>Whether an existing instance of the activity can handle new
-intents.  The answer is yes for all the modes except "{@code standard}".
-Existing "{@code singleTask}" and "{@code singleInstance}" activities 
-handle all new intents that come their way; a new instance is never
-created.  In the case of "{@code singleTask}", all other activities in
-the task are popped from the stack, so that the root "{@code singleTask}"
-activity is at the top and in position to respond to the intent. 
+<li><b>Whether a new instance of the class will be launched 
+to handle a new intent</b>.  For the default "{@code standard}" mode, a 
+new instance is created to respond to every new intent.  Each instance 
+handles just one intent.  For the "{@code singleTop}" mode, an existing 
+instance of the class is re-used to handle a new intent if it resides 
+at the top of the activity stack of the target task.  If it does not 
+reside at the top, it is not re-used.  Instead, a new instance 
+is created for the new intent and pushed on the stack.
+
+<p>
+For example, suppose a task's activity stack consists of root activity A with 
+activities B, C, and D on top in that order, so the stack is A-B-C-D.  An intent 
+arrives for an activity of type D.  If D has the default "{@code standard}" launch 
+mode, a new instance of the class is launched and the stack becomes A-B-C-D-D.  
+However, if D's launch mode is "{@code singleTop}", the existing instance is 
+expected to handle the new intent (since it's at the top of the stack) and the 
+stack remains A-B-C-D.  
 </p>
 
 <p>
-If a "{@code singleTop}" activity is at the 
-top of its stack, that object is expected to handle any new intents. 
-However, if it's farther down the stack, a new instance is created for
-the intent and pushed on the stack.  
+If, on the other hand, the arriving intent is for an activity of type B, a new 
+instance of B would be launched no matter whether B's mode is "{@code standard}" 
+or "{@code singleTop}" (since B is not at the top of the stack), so the resulting 
+stack would be A-B-C-D-B.
 </p>
 
 <p>
-In contrast, a new instance of a "{@code standard}" activity is always 
-created for each new intent.
+As noted above, there's never more than one instance of a "{@code singleTask}" 
+or "{@code singleInstance}" activity, so that instance is expected to handle
+all new intents.  A "{@code singleInstance}" activity is always at the top of 
+the stack (since it is the only activity in the task), so it is always in 
+position to handle the intent.  However, a "{@code singleTask}" activity may 
+or may not have other activities above it in the stack.  If it does, it is not 
+in position to handle the intent, and the intent is dropped.  (Even though the 
+intent is dropped, its arrival would have caused the task to come to the 
+foreground, where it would remain.)
 </p>
 </li>
+
 </ul>
 
 <p>
 When an existing activity is asked to handle a new intent, the Intent
-object is passed to the activity in an <code>{@link android.app.Activity#onNewIntent
-onNewIntent()}</code> call.  (The intent object that originally started the
-activity can be retrieved by calling 
-<code>{@link android.app.Activity#getIntent getIntent()}</code>.)
+object is passed to the activity in an 
+<code>{@link android.app.Activity#onNewIntent onNewIntent()}</code> call.  
+(The intent object that originally started the activity can be retrieved by 
+calling <code>{@link android.app.Activity#getIntent getIntent()}</code>.)
 </p>
 
 <p>
@@ -651,12 +770,12 @@
 
 <p>
 For more on launch modes, see 
-<a href="{@docRoot}guide/topics/manifest/manifest.html">The
+<a href="{@docRoot}guide/topics/manifest/manifest-intro.html">The
 AndroidManifest.xml File</a>
 </p>
 
 
-<h3><a name="clearstack"></a>Clearing the stack</h3>
+<h3 id="clearstack">Clearing the stack</h3>
 
 <p>
 If the user leaves a task for a long time, the system clears the task of all
@@ -676,7 +795,7 @@
 <dt>The {@code alwaysRetainTaskState} attribute</dt>
 <dd>If this attribute is set to "{@code true}" in the root activity of a task, 
 the default behavior just described does not happen.  
-Activities are retained in the stack even after a long period.</dd>
+The task retains all activities in its stack even after a long period.</dd>
 
 <dt>The {@code clearTaskOnLaunch} attribute</dt>
 <dd>If this attribute is set to "{@code true}" in the root activity of a task, 
@@ -690,7 +809,7 @@
 single activity, not an entire task.  And it can cause any activity to go
 away, including the root activity.  When it's set to "{@code true}", the 
 activity remains part of the task only for the current session.  If the user 
-leaves and then relaunches the task, it no longer is present.</dd>
+leaves and then returns to the task, it no longer is present.</dd>
 </dl>
 
 <p>
@@ -700,7 +819,11 @@
 flag, and the target task already has an instance of the type of activity that 
 should handle the intent in its stack, all activities above that instance 
 are cleared away so that it stands at the top of the stack and can respond 
-to the intent.
+to the intent. 
+If the launch mode of the designated activity is "{@code standard}", it too 
+will be removed from the stack, and a new instance will be launched to handle 
+the incoming intent.  That's because a new instance is always created for 
+a new intent when the launch mode is "{@code standard}".
 </p>
 
 <p>
@@ -711,7 +834,7 @@
 </p>
 
 
-<h3><a name="starttask"></a>Starting tasks</h3>
+<h3 id="starttask">Starting tasks</h3>
 
 <p>
 An activity is set up as the entry point for a task by giving it 
@@ -731,7 +854,7 @@
 that mark activities as always initiating a task, "{@code singleTask}" 
 and "{@code singleInstance}", should be used only when the activity has 
 a {@code MAIN} and {@code LAUNCHER} filter.  
-Imagine, for example, what could happen if the filter is missing.
+Imagine, for example, what could happen if the filter is missing:
 An intent launches a "{@code singleTask}" activity, initiating a new task, 
 and the user spends some time working in that task.  The user then presses 
 the HOME key.  The task is now ordered behind and obscured by the home 
@@ -760,7 +883,7 @@
 </p>
 
 
-<h2><a name="procthread"></a>Processes and Threads</h2>
+<h2 id="procthread">Processes and Threads</h2>
 
 <p>
 When the first of an application's components needs to be run, Android 
@@ -769,12 +892,15 @@
 </p>
 
 <p>
-However, you can arrange for components to run in other processes as well as
-spawn additional threads:
+However, you can arrange for components to run in other processes, and you 
+can spawn additional threads for any process.
 </p>
 
-<ul>
-<li>The process where a component runs is controlled by the manifest file.  
+
+<h3 id="procs">Processes</h3>
+
+<p>
+The process where a component runs is controlled by the manifest file.  
 The component elements &mdash; {@code &lt;activity&gt;}, 
 {@code &lt;service&gt;}, {@code &lt;receiver&gt;}, and {@code &lt;provider&gt;} 
 &mdash; each have a {@code process} attribute that can specify a process
@@ -784,26 +910,27 @@
 different applications run in the same process &mdash; provided that the 
 applications share the same Linux user ID and are signed by the same authorities.
 The {@code &lt;application&gt;} element also has a {@code process} attribute,
-for setting a default value that applies to all components.</li>
-
-<li><p>Threads are created in code using standard Java {@link java.lang.Thread}
-objects.  Android provides a number of convenience classes for managing threads
-&mdash; {@link android.os.Looper} for running a message loop within a thread, 
-{@link android.os.Handler} for processing messages, and 
-{@link android.os.HandlerThread} for setting up a thread with a message loop.</p>
+for setting a default value that applies to all components.
+</p>
 
 <p>
-Even though you may confine your application to a single process, there may be
-times when you will need to spawn a thread to do some background work.  Since the 
-user interface must always be quick to respond to user actions, the
-thread that hosts an activity should not also host time-consuming operations like
-network downloads, or anything else that may not be completed quickly. 
-</p></li>
-</ul>
+All components are instantiated in the main thread of the specified
+process, and system calls to the component are dispatched from that
+thread.  Separate threads are not created for each instance.  Consequently,
+methods that respond to those calls &mdash; methods like 
+<code>{@link android.view.View#onKeyDown View.onKeyDown()}</code> that report
+user actions and the lifecycle notifications discussed later in the 
+<a href="#lcycles">Component Lifecycles</a> section &mdash; always run in the
+main thread of the process.  This means
+that no component should perform long or blocking operations (such as networking 
+operations or computation loops) when called by the system, since this will block
+any other components also in the process.  You can spawn separate threads for 
+long operations, as discussed under <a href="#threads">Threads</a>, next.
+</p>
 
 <p>
 Android may decide to shut down a process at some point, when memory is 
-low and required by other applications that are more immediately serving 
+low and required by other processes that are more immediately serving 
 the user.  Application components running in the process are consequently 
 destroyed.  A process is restarted for those components when there's again
 work for them to do.
@@ -816,17 +943,176 @@
 visible activities.
 The decision whether to terminate a process, therefore, depends on the state 
 of the components running in that process.  Those states are the subject of
-the next section, <a href="#lcycles">Lifecycles</a>.
+a later section, <a href="#lcycles">Component Lifecycles</a>.
 </p>
 
 
-<h2><a name="lcycles"></a>Lifecycles</h2>
+<h3 id="threads">Threads</h3>
+
+<p>
+Even though you may confine your application to a single process, there will
+likely be times when you will need to spawn a thread to do some background 
+work.  Since the user interface must always be quick to respond to user actions, 
+the thread that hosts an activity should not also host time-consuming operations 
+like network downloads.  Anything that may not be completed quickly should be
+assigned to a different thread. 
+</p>
+
+<p>
+Threads are created in code using standard Java {@link java.lang.Thread}
+objects.  Android provides a number of convenience classes for managing 
+threads &mdash; {@link android.os.Looper} for running a message loop within 
+a thread, {@link android.os.Handler} for processing messages, and 
+{@link android.os.HandlerThread} for setting up a thread with a message loop.
+</p>
+
+
+<h3 id="rpc">Remote procedure calls</h3>
+
+<p>
+Android has a lightweight mechanism for remote procedure calls (RPCs) 
+&mdash; where a method is called locally, but executed remotely (in another
+process), with any result returned back to the caller.
+This entails decomposing the method call and all its attendant data to a 
+level the operating system can understand, transmitting it from the local 
+process and address space to the remote process and address space, and 
+reassembling and reenacting the call there.  Return values have to be 
+transmitted in the opposite direction.  Android provides all the code 
+to do that work, so that you can concentrate on defining and implementing 
+the RPC interface itself.
+</p>
+
+<p>
+An RPC interface can include only methods.
+All methods are executed synchronously (the local method blocks until the 
+remote method finishes), even if there is no return value.
+</p>
+
+<p>
+In brief, the mechanism works as follows:  You'd begin by declaring the
+RPC interface you want to implement using a simple IDL (interface definition 
+language).  From that declaration, the 
+<code><a href="{@docRoot}guide/developing/tools/aidl.html">aidl</a></code> 
+tool generates a Java interface definition that must be made available to 
+both the local and the remote process.  It contains two inner class, as shown 
+in the following diagram:
+</p>
+
+<p style="margin-left: 2em">
+<img src="{@docRoot}images/binder_rpc.png" alt="RPC mechanism." border="0" />
+</p>
+
+<p>
+The inner classes have all the code needed to administer remote procedure
+calls for the interface you declared with the IDL. 
+Both inner classes implement the {@link android.os.IBinder}
+interface.  One of them is used locally and internally by the system;
+the code you write can ignore it.
+The other, called Stub, extends the {@link android.os.Binder}
+class.  In addition to internal code for effectuating the IPC calls, it 
+contains declarations for the methods in the RPC interface you declared.
+You would subclass Stub to implement those methods, as indicated in the 
+diagram.  
+</p>
+
+<p>
+Typically, the remote process would be managed by a service (because a 
+service can inform the system about the process and its connections to 
+other processes).  It would have both the interface file generated by 
+the {@code aidl} tool and the Stub subclass implementing the 
+RPC methods.  Clients of the service would have only the interface file
+generated by the {@code aidl} tool.
+</p>
+
+<p>
+Here's how a connection between a service and its clients is set up:
+</p>
+
+<ul>
+<li>Clients of the service (on the local side) would implement 
+<code>{@link android.content.ServiceConnection#onServiceConnected
+onServiceConnected()}</code> and 
+<code>{@link android.content.ServiceConnection#onServiceDisconnected
+onServiceDisconnected()}</code> methods so they can be notified 
+when a successful connection to the remote service is established, and 
+when it goes away.  They would then call
+<code>{@link android.content.Context#bindService bindService()}</code>
+to set up the connection.
+</li>  
+
+<li> 
+The service's <code>{@link android.app.Service#onBind onBind()}</code> 
+method would be implemented to either accept or reject the connection, 
+depending on the intent it receives (the intent passed to
+{@code bindService()}).  If the connection is accepted, it returns 
+an instance of the Stub subclass.
+</li>
+
+<li>If the service accepts the connection, Android calls the 
+client's {@code onServiceConnected()} method and passes it an IBinder 
+object, a proxy for the Stub subclass managed by the service.  Through
+the proxy, the client can make calls on the remote service.  
+</li>
+</ul>
+
+<p>
+This brief description omits some details of the RPC mechanism.  For more 
+information, see 
+<a href="{@docRoot}guide/developing/tools/aidl.html">Designing a Remote 
+Interface Using AIDL</a> and the {@link android.os.IBinder IBinder} class 
+description.
+</p>  
+
+
+<h3 id="tsafe">Thread-safe methods</h3>
+
+<p>
+In a few contexts, the methods you implement may be called from more 
+than one thread, and therefore must be written to be thread-safe.
+</p>
+
+<p>
+This is primarily true for methods that can be called remotely &mdash;
+as in the RPC mechanism discussed in the previous section.
+When a call on a method implemented in an IBinder object originates
+in the same process as the IBinder, the method is executed in the
+caller's thread.  However, when the call originates in another process, 
+the method is executed in a thread chosen from a pool of threads that 
+Android maintains in the same process as the IBinder; it's not executed 
+in the main thread of the process.  For example, whereas a service's 
+{@code onBind()} method would be called from the main thread of the 
+service's process, methods implemented in the object that {@code onBind()} 
+returns (for example, a Stub subclass that implements RPC methods) would 
+be called from threads in the pool. 
+Since services can have more than one client, more than one pool thread
+can engage the same IBinder method at the same time.  IBinder methods
+must, therefore, be implemented to be thread-safe.
+</p>  
+
+<p>
+Similarly, a content provider can receive data requests that originate in 
+other processes.  Although the ContentResolver and ContentProvider classes 
+hide the details of how the interprocess communication is managed, 
+ContentProvider methods that respond to those requests &mdash; the methods
+<code>{@link android.content.ContentProvider#query query()}</code>, 
+<code>{@link android.content.ContentProvider#insert insert()}</code>, 
+<code>{@link android.content.ContentProvider#delete delete()}</code>, 
+<code>{@link android.content.ContentProvider#update update()}</code>, and
+<code>{@link android.content.ContentProvider#getType getType()}</code>
+&mdash; are called from a pool of threads in the content provider's
+process, not the main thread of the process.  Since these methods
+may be called from any number of threads at the same time, they too must
+be implemented to be thread-safe.
+</p> 
+
+
+<h2 id="lcycles">Component Lifecycles</h2>
 
 <p>
 Application components have a lifecycle &mdash; a beginning when 
 Android instantiates them to respond to intents through to an end when 
 the instances are destroyed.  In between, they may sometimes be active 
-or inactive, or, in the case of activities, visible to the user or
+or inactive,or, in the case of activities, visible to the user or
 invisible.  This section discusses the lifecycles of activities,
 services, and broadcast receivers &mdash; including the states that they 
 can be in during their lifetimes, the methods that notify you of transitions
@@ -835,7 +1121,7 @@
 </p> 
 
 
-<h3><a name="actlife"></a>Activity lifecycle</h3>
+<h3 id="actlife">Activity lifecycle</h3>
 
 <p>An activity has essentially three states:</p>
 
@@ -864,12 +1150,10 @@
 to the user, it must be completely restarted and restored to its previous state.
 </p>
 
-
-<h4>Lifecycle methods</h4>
-
 <p>
 As an activity transitions from state to state, it is notified of the change 
 by calls to the following protected methods:
+</p>
 
 <p style="margin-left: 2em">{@code void onCreate(Bundle <i>savedInstanceState</i>)}
 <br/>{@code void onStart()}
@@ -881,9 +1165,9 @@
 
 <p>
 All of these methods are hooks that you can override to do appropriate work 
-when the state changes.
-All activities must implement <code>{@link android.app.Activity#onCreate 
-onCreate()}</code> to do initial setup when the activity is first instantiated.  
+when the state changes.  All activities must implement 
+<code>{@link android.app.Activity#onCreate onCreate()}</code> to do the 
+initial setup when the object is first instantiated.  
 Many will also implement <code>{@link android.app.Activity#onPause onPause()}</code> 
 to commit data changes and otherwise prepare to stop interacting with the user.
 </p>
@@ -950,7 +1234,7 @@
 to perform operations when the activity transitions between states.
 <p>
 
-<p><img src="{@docRoot}images/activity_lifecycle.png"
+<p style="margin-left: 2em"><img src="{@docRoot}images/activity_lifecycle.png"
 alt="State diagram for an Android activity lifecycle." border="0" /></p>  
   
 <p>
@@ -1084,7 +1368,7 @@
 </p>
 
 
-<h4><a name="actstate"></a>Saving activity state</h4>
+<h4 id="actstate">Saving activity state</h4>
 
 <p>
 When the system, rather than the user, shuts down an activity to conserve 
@@ -1118,14 +1402,38 @@
 </p>
 
 <p>
-Because {@code onSaveInstanceState()} is not always called, you
-should use it only to record the transient state of the activity, 
-not to store persistent data.  Use {@code onPause()} for that purpose 
-instead.
+Because {@code onSaveInstanceState()} is not always called, you should 
+use it only to record the transient state of the activity, not to store 
+persistent data.  Use {@code onPause()} for that purpose instead.
 </p>
 
 
-<h3><a name="servlife"></a>Service lifecycle</h3>
+<h4 id="coordact">Coordinating activities</h4>
+
+<p>
+When one activity starts another, they both experience lifecycle
+transitions.  One pauses and may stop, while the other starts up.
+On occasion, you may need to coordinate these activities, one with
+the other.
+</p>
+
+<p>
+The order of lifecycle callbacks is well defined,
+particularly when the two activities are in the same process:
+</p>
+
+<ol>
+<li>The current activity's {@code onPause()} method is called.</li>
+
+<li>Next, the starting activity's {@code onCreate()}, {@code onStart()},
+and {@code onResume()} methods are called in sequence.</li>
+
+<li>Then, if the starting activity is no longer visible
+on screen, its {@code onStop()} method is called.</li>
+</ol>
+
+
+<h3 id="servlife">Service lifecycle</h3>
 
 <p>
 A service can be used in two ways:
@@ -1243,11 +1551,11 @@
 so any service may receive {@code onBind()} and {@code onUnbind()} calls.
 </p>
 
-<p><img src="{@docRoot}images/service_lifecycle.png"
+<p style="margin-left: 2em"><img src="{@docRoot}images/service_lifecycle.png"
 alt="State diagram for Service callbacks." border="0" /></p>
 
 
-<h3><a name="broadlife"></a>Broadcast receiver lifecycle</h3>
+<h3 id="broadlife">Broadcast receiver lifecycle</h3>
 
 <p>
 A broadcast receiver has single callback method:
@@ -1286,15 +1594,16 @@
 </p>
 
 
-<h3><a name="proclife"></a>Processes and lifecycles</h3>
+<h3 id="proclife">Processes and lifecycles</h3>
 
 <p>The Android system tries to maintain an application process for as
 long as possible, but eventually it will need to remove old processes when
 memory runs low.  To determine which processes to keep and which to kill, 
 Android places each process into an "importance hierarchy" based on the 
-components running in it and the state of those components.  There are 
-five levels in the hierarchy.  The following list presents them in order 
-of importance:
+components running in it and the state of those components.  Processes 
+with the lowest importance are eliminated first, then those with the next
+lowest, and so on.  There are five levels in the hierarchy.  The following 
+list presents them in order of importance:
 </p>
 
 <ol>
@@ -1348,16 +1657,15 @@
 unless doing so is required to keep all foreground processes running.
 </p></li>
 
-<li><p>A <b>service process</b> is one that is running a service that has 
-been started with the 
+<li><p>A <b>service process</b> is one that is running a service that 
+has been started with the 
 <code>{@link android.content.Context#startService startService()}</code>
-method.  Although service processes are not directly tied to anything the 
+method and that does not fall into either of the two higher categories.  
+Although service processes are not directly tied to anything the 
 user sees, they are generally doing things that the user cares about (such 
 as playing an mp3 in the background or downloading  data on the network), 
 so the system keeps them running unless there's not enough 
-memory to retain them along with all foreground and visible processes.
-(Note that a service can be ranked higher than this by virtue of being 
-bound to a visible or foreground activity).  
+memory to retain them along with all foreground and visible processes.  
 </p></li>
 
 <li><p>A <b>background process</b> is one holding an activity
@@ -1365,8 +1673,8 @@
 <code>{@link android.app.Activity#onStop onStop()}</code> method has been called).  
 These processes have no direct impact on the user experience, and can be killed 
 at any time to reclaim memory for a foreground, visible, or service process.  
-Usually there are many background processes running,
-so they are kept in an LRU list to ensure that the process with the activity that 
+Usually there are many background processes running, so they are kept in an 
+LRU (least recently used) list to ensure that the process with the activity that 
 was most recently seen by the user is the last to be killed.
 If an activity implements its lifecycle methods correctly, and captures its current 
 state, killing its process will not have a deleterious effect on the user experience. 
diff --git a/docs/html/guide/topics/graphics/2d-graphics.jd b/docs/html/guide/topics/graphics/2d-graphics.jd
index 822c66f..a72962e 100644
--- a/docs/html/guide/topics/graphics/2d-graphics.jd
+++ b/docs/html/guide/topics/graphics/2d-graphics.jd
@@ -87,6 +87,13 @@
 To do so, create a Drawable from the resource like so:
 <pre>Drawable myImage = Resources.getDrawable(R.drawable.my_image);</pre>
 
+<p class="caution"><strong>Caution:</strong> Each unique resource in your project can maintain only one
+state, no matter how many different objects you may instantiate for it. For example, if you instantiate two
+Drawable objects from the same image resource, then change a property (such as the alpha) for one of the 
+Drawables, then it will also affect the other. So when dealing with multiple instances of an image resource, 
+instead of directly transforming the Drawable, you should perform a <a href="#tween-animation">tween animation</a>.</p>
+
+
 <h4>Example XML</h4>
 <p>The XML snippet below shows how to add a resource Drawable to an 
 {@link android.widget.ImageView} in the XML layout (with some red tint just for fun).
@@ -103,8 +110,8 @@
 
 <h3 id="drawables-from-xml">Creating from resource XML</h3>
 
-<p>By now, you should be familiar with Android's principles of 
-<a href="{@docRoot}guide/topics/views/index.html">Views and Layout</a>. Hence, you understand the power
+<p>By now, you should be familiar with Android's principles of developing a
+<a href="{@docRoot}guide/topics/ui/index.html">User Interface</a>. Hence, you understand the power
 and flexibility inherent in defining objects in XML. This philosophy caries over from Views to Drawables.
 If there is a Drawable object that you'd like to create, which is not initially dependent on variables defined by
 your applicaton code or user interaction, then defining the Drawable in XML is a good option.
@@ -309,15 +316,28 @@
 
 <h2 id="tween-animation">Tween Animation</h2>
 
-<p>A tweened animation can perform a series of simple transformations (position, size, rotation, and transparency) on
+<p>A tween animation can perform a series of simple transformations (position, size, rotation, and transparency) on
 the contents of a View object. So, if you have a TextView object, you can move, rotate, grow, or shrink the text. 
-If it has a background image, the background image will be transformed along with the text.</p>
+If it has a background image, the background image will be transformed along with the text.
+The {@link android.view.animation animation package} provides all the classes used in a tween animation.</p>
 
-<p>The animation is achieved with a sequence of animation instructions, defined in either XML or code.
+<p>A sequence of animation instructions defines the twen animation, defined by either XML or Android code.
 Like defining a layout, an XML file is recommended because it's more readable, reusable, and swappable 
-than hard-coding it. In the example below, we use XML. (To define an animation in code, refer to the 
+than hard-coding the animation. In the example below, we use XML. (To learn more about defining an animation 
+in your application code, instead of XML, refer to the 
 {@link android.view.animation.AnimationSet} class and other {@link android.view.animation.Animation} subclasses.)</p>
 
+<p>The animation instructions define the transformations that you want to occur, when they will occur, 
+and how long they should take to apply. Transformations can be sequential or simultaneous &mdash;
+for example, you can have the contents of a TextView move from left to right, and then 
+rotate 180 degrees, or you can have the text move and rotate simultaneously. Each transformation 
+takes a set of parameters specific for that transformation (starting size and ending size
+for size change, starting angle and ending angle for rotation, and so on), and
+also a set of common parameters (for instance, start time and duration). To make
+several transformations happen simultaneously, give them the same start time;
+to make them sequential, calculate the start time plus the duration of the preceding transformation.
+</p>
+
 <p>The animation XML file belongs in the <code>res/anim/</code> directory of your Android project.
 The file must have a single root element: this will be either a single <code>&lt;alpha&gt;</code>,
 <code>&lt;scale&gt;</code>, <code>&lt;translate&gt;</code>, <code>&lt;rotate&gt;</code>, interpolator element, 
@@ -389,22 +409,23 @@
 <p>As an alternative to <code>startAnimation()</code>, you can define a starting time for the animation with
 <code>{@link android.view.animation.Animation#setStartTime(long) Animation.setStartTime()}</code>, 
 then assign the animation to the View with
-<code>{@link android.view.View#setAnimation(android.view.animation.Animation) View.setAnimation()}</code>.</p>
+<code>{@link android.view.View#setAnimation(android.view.animation.Animation) View.setAnimation()}</code>.
+</p>
 
 <p>For more information on the XML syntax, available tags and attributes, see the discussion on animation 
 in the <a href="{@docRoot}guide/topics/resources/available-resources.html#animation">Available Resources</a>.</p>
 
-<p class="note"><strong>Note:</strong> Animations are drawn in the area designated for the View at the start of 
-the animation; this area does not change to accommodate size or movement, so if your animation moves or expands 
-outside the original boundaries of your object, it will be clipped to the size of the original View, even if 
-the object's LayoutParams are set to WRAP_CONTENT (the object will not resize to accommodate moving or 
-expanding/shrinking animations).</p>
+<p class="note"><strong>Note:</strong> Regardless of how your animation may move or resize, the bounds of the 
+View that holds your animation will not automatically adjust to accomodate it. Even so, the animation will still
+be drawn beyond the bounds of its View and will not be clipped. However, clipping <em>will occur</em>
+if the animation exceeds the bounds of the parent View.</p>
 
 
 <h2 id="frame-animation">Frame Animation</h2>
 
 <p>This is a traditional animation in the sense that it is created with a sequence of different
-images, played in order, like a roll of film.</p>
+images, played in order, like a roll of film. The {@link android.graphics.drawable.AnimationDrawable}
+class is the basis for frame animations.</p>
 
 <p>While you can define the frames of an animation in your code, using the 
 {@link android.graphics.drawable.AnimationDrawable} class API, it's more simply accomplished with a single XML 
@@ -454,6 +475,6 @@
 to the window. If you want to play the animation immediately, without
 requiring interaction, then you might want to call it from the 
 <code>{@link android.app.Activity#onWindowFocusChanged(boolean) onWindowFocusChanged()}</code> method in 
-your Activity, which will get called when Android brings your window into focus.</p>
+your Activity, which will get called when Android brings your window into focus.</p> 
 
 
diff --git a/docs/html/guide/topics/graphics/index.jd b/docs/html/guide/topics/graphics/index.jd
index 388acc9..bc2a8bf 100644
--- a/docs/html/guide/topics/graphics/index.jd
+++ b/docs/html/guide/topics/graphics/index.jd
@@ -1,21 +1,203 @@
-page.title=2D and 3D Graphics
+page.title=Graphics
 @jd:body
 
-
+<div id="qv-wrapper">
+  <div id="qv">
+  <h2>In this document</h2>
+  <ol>
+    <li><a href="#options">Consider your Options</a></li>
+    <li><a href="#draw-to-view">Simple Graphics Inside a View</a></li>
+    <li><a href="#draw-with-canvas">Draw with a Canvas</a>
+    <ol>
+      <li><a href="#on-view">On a View</a></li>
+      <li><a href="#on-surfaceview">On a SurfaceView</a></li>
+    </ol>
+    </li>
+  </ol>
+  </div>
+</div>
 <p>Android graphics are powered by a custom 2D graphics library and OpenGL ES 1.0
-for 3D graphics.</p>
+for high performance 3D graphics. The most common 2D graphics APIs can be found in the 
+{@link android.graphics.drawable drawable package}. OpenGL APIs are available
+from the Khronos {@link javax.microedition.khronos.opengles OpenGL ES package},
+plus some Android {@link android.opengl OpenGL utilities}.</p>
 
-<h2>2D Graphics</h2>
-<p>Android offers a custom 2D graphics library for drawing shapes and images.</p>
-<p>The {@link android.graphics} and {@link android.graphics.drawable} 
-packages are where you'll find the classes used for drawing in two-dimensions.
-For common drawing tasks, though, the {@link android.graphics.drawable} package 
-is where you'll find what you need.</p>
-<p>For an introduction to drawing shapes and images, read the 
-<a href="2d-graphics.html">2D Graphics</a> document.</p>
+<p>When starting a project, it's important to consider exactly what your graphical demands will be. 
+Varying graphical tasks are best accomplished with varying techniques. For example, graphics and animations
+for a rather static application should be implemented much differently than graphics and animations
+for an interactive game or 3D rendering.</p>
+
+<p>Here, we'll discuss a few of the options you have for drawing graphics on Android, 
+and which tasks they're best suited for.</p>
+
+<p>If you're specifically looking for information on drawing 3D graphics, this page won't
+help a lot. However, the information below, on <a href="#drawing-with-canvas">Drawing with a Canvas</a>
+(and the section on SurfaceView), 
+will give you a quick idea of how you should draw to the View hierarchy. For more information
+on Android's 3D graphic utilities (provided by the OpenGL ES API), 
+read <a href="opengl.html">3D with OpenGL</a> and refer to other OpenGL documentation.</p>
 
 
-<h2>3D with OpenGL</h2>
-<p>High performance 3D graphic utilities are provided on Android with the OpenGL ES API.
-You'll find the OpenGL APIs in the {@link android.opengl} package.
-Read more about <a href="opengl.html">3D with OpenGL</a>.</p>
\ No newline at end of file
+<h2 id="options">Consider your Options</h2>
+
+<p>When drawing 2D graphics, you'll typically do so in one of two ways:</p>
+<ol type="a">
+  <li>Draw your graphics or animations into a View object from your layout. In this manner, 
+  the drawing (and any animation) of your graphics is handled by the system's 
+  normal View hierarchy drawing process &mdash; you simply define the graphics to go inside the View.</li>
+  <li>Draw your graphics directly to a Canvas. This way, you personally call the appropriate class's 
+  <code>draw()</code> method (passing it your Canvas), or one of the Canvas <code>draw...()</code> methods (like 
+  <code>{@link android.graphics.Canvas#drawPicture(Picture,Rect) drawPicture()}</code>). In doing so, you are also in
+  control of any animation.</li>
+</ol>
+
+<p>Option "a," drawing to a View, is your best choice when you want to draw simple graphics that do not
+need to change dynamically and are not part of a performance-intensive game. For example, you should
+draw your graphics into a View when you want to display a static graphic or predefined animation, within 
+an otherwise static application. Read <a href="#draw-to-view">Simple Graphics Inside a View</a>.</li>
+
+<p>Option "b," drawing to a Canvas, is better when you're application needs to regularly re-draw itself.
+Basically, any video game should be drawing to the Canvas on its own. However, there's more than 
+one way to do this: </p>
+<ul>
+  <li>In the same thread as your UI Activity, wherein you create a custom View component in
+  your layout, call <code>{@link android.view.View#invalidate()}</code> and then handle the 
+  <code>{@link android.view.View#onDraw(Canvas) onDraw()}</code> callback..</li>
+  <li>Or, in a separate thread, wherein you manage a {@link android.view.SurfaceView} and 
+  perform draws to the Canvas as fast as your thread is capable 
+  (you do not need to request <code>invalidate()</code>).</li>
+</ul>
+<p>...Begin by reading <a href="#draw-with-canvas">Draw with a Canvas</a>.</p>
+
+<h2 id="draw-to-view">Simple Graphics Inside a View</h2>
+
+<p>If you'll be drawing some simple graphics (images, shapes, colors, pre-defined animations, etc.),
+then you should probably just draw to the background of a View or
+to the content of an {@link android.widget.ImageView} in your layout.
+In this case, you can skip the rest of this document and learn how to
+draw graphics and animations in the <a href="2d-graphics.html">2D Graphics</a> document.
+</p>
+
+
+<h2 id="draw-with-canvas">Draw with a Canvas</h2>
+
+<p>When you're writing an application in which you would like to perform specialized drawing
+and/or control the animation of graphics,
+you should do so by drawing through a {@link android.graphics.Canvas}. A Canvas works for you as
+a pretense, or interface, to the actual surface upon which your graphics will be drawn &mdash; it
+holds all of your "draw" calls. Via the Canvas, your drawing is actually performed upon an 
+underlying {@link android.graphics.Bitmap}, which is placed into the window.</p>
+
+<p>In the event that you're drawing within the <code>{@link android.view.View#onDraw(Canvas) onDraw()}</code>
+callback method, the Canvas is provided for you and you need only place your drawing calls upon it.
+You can also acquire a Canvas from <code>{@link android.view.SurfaceHolder#lockCanvas() SurfaceHolder.lockCanvas()}</code>,
+when dealing with a SurfaceView object. (Both of these scenarios are discussed in the following sections.)
+However, if you need to create a new Canvas, then you must define the {@link android.graphics.Bitmap} 
+upon which drawing will actually be performed. The Bitmap is always required for a Canvas. You can set up
+a new Canvas like this:</p>
+<pre>
+Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
+Canvas c = new Canvas(b);
+</pre>
+
+<p>Now your Canvas will draw onto the defined Bitmap. After drawing upon it with the Canvas, you can then carry your 
+Bitmap to another Canvas with one of the <code>{@link android.graphics.Canvas#drawBitmap(Bitmap,Matrix,Paint)
+Canvas.drawBitmap(Bitmap,...)}</code> methods. It's recommended that you ultimately draw your final
+graphics through a Canvas offered to you
+by <code>{@link android.view.View#onDraw(Canvas) View.onDraw()}</code> or 
+<code>{@link android.view.SurfaceHolder#lockCanvas() SurfaceHolder.lockCanvas()}</code> (see the following sections).</p>
+
+<p>The {@link android.graphics.Canvas} class has its own set of drawing methods that you can use, 
+like <code>drawBitmap(...)</code>, <code>drawRect(...)</code>, <code>drawText(...)</code>, and many more.
+Other classes that you might use also have <code>draw()</code> methods. For example, you'll probably
+have some {@link android.graphics.drawable.Drawable} objects that you want to put on the Canvas. Drawable
+has its own <code>{@link android.graphics.drawable.Drawable#draw(Canvas) draw()}</code> method 
+that takes your Canvas as an arguement.</p>
+
+
+<h3 id="on-view">On a View</h3>
+
+<p>If you're application does not require a significant amount of processing or 
+frame-rate speed (perhaps for a chess game, a snake game, 
+or another slowly-animated application), then you should consider creating a custom View component
+and drawing with a Canvas in <code>{@link android.view.View#onDraw(Canvas) View.onDraw()}</code>. 
+The most convenient aspect of doing so is that the Android framework will
+provide you with a pre-defined Canvas to which you will place your drawing calls.</p>
+
+<p>To start, extend the {@link android.view.View} class (or descendent thereof) and define
+the <code>{@link android.view.View#onDraw(Canvas) onDraw()}</code> callback method. This method will be called by the Android 
+framework to request that your View draw itself. This is where you will perform all your calls
+to draw through the {@link android.graphics.Canvas}, which is passed to you through the <code>onDraw()</code> callback.</p>
+
+<p>The Android framework will only call <code>onDraw()</code> as necessary. Each time that 
+your application is prepared to be drawn, you must request your View be invalidated by calling
+<code>{@link android.view.View#invalidate()}</code>. This indicates that you'd like your View to be drawn and
+Android will then call your <code>onDraw()</code> method (though is not guaranteed that the callback will
+be instantaneous). </p>
+
+<p>Inside your View component's <code>onDraw()</code>, use the Canvas given to you for all your drawing,
+using various <code>Canvas.draw...()</code> methods, or other class <code>draw()</code> methods that
+take your Canvas as an argument. Once your <code>onDraw()</code> is complete, the Android framework will 
+use your Canvas to draw a Bitmap handled by the system.</p>
+
+<p class="note"><strong>Note: </strong> In order to request an invalidate from a thread other than your main
+Activity's thread, you must call <code>{@link android.view.View#postInvalidate()}</code>.</p>
+
+<p>Also read <a href="{@docRoot}guide/topics/ui/custom-components.html">Building Custom Components</a>
+for a guide to extending a View class, and <a href="2d-graphics.html">2D Graphics: Drawables</a> for
+information on using Drawable objects like images from your resources and other primitive shapes.</p>
+
+<p>For a sample application, see the Snake game, in the SDK samples folder:
+<code>&lt;your-sdk-directory>/samples/Snake/</code>.</p>
+
+<h3 id="on-surfaceview">On a SurfaceView</h3>
+
+<p>The {@link android.view.SurfaceView} is a special subclass of View that offers a dedicated
+drawing surface within the View hierarchy. The aim is to offer this drawing surface to
+an application's secondary thread, so that the application isn't required
+to wait until the system's View hierarchy is ready to draw. Instead, a secondary thread
+that has reference to a SurfaceView can draw to its own Canvas at its own pace.</p>
+
+<p>To begin, you need to create a new class that extends {@link android.view.SurfaceView}. The class should also 
+implement {@link android.view.SurfaceHolder.Callback}. This subclass is an interface that will notify you
+with information about the underlying {@link android.view.Surface}, such as when it is created, changed, or destroyed. 
+These events  are important so that you know when you can start drawing, whether you need 
+to make adjustments based on new surface properties, and when to stop drawing and potentially 
+kill some tasks. Inside your SurfaceView class is also a good place to define your secondary Thread class, which will
+perform all the drawing procedures to your Canvas.</p>
+
+<p>Instead of handling the Surface object directly, you should handle it via
+a {@link android.view.SurfaceHolder}. So, when your SurfaceView is initialized, get the SurfaceHolder by calling 
+<code>{@link android.view.SurfaceView#getHolder()}</code>. You should then notify the SurfaceHolder that you'd
+like to receive SurfaceHolder callbacks (from {@link android.view.SurfaceHolder.Callback}) by calling 
+{@link android.view.SurfaceHolder#addCallback(SurfaceHolder.Callback) addCallback()} 
+(pass it <var>this</var>). Then override each of the 
+{@link android.view.SurfaceHolder.Callback} methods inside your SurfaceView class.</p>
+
+<p>In order to draw to the Surface Canvas from within your second thread, you must pass the thread your SurfaceHandler
+and retrieve the Canvas with <code>{@link android.view.SurfaceHolder#lockCanvas() lockCanvas()}</code>. 
+You can now take the Canvas given to you by the SurfaceHolder and do your necessary drawing upon it. 
+Once you're done drawing with the Canvas, call 
+<code>{@link android.view.SurfaceHolder#unlockCanvasAndPost(Canvas) unlockCanvasAndPost()}</code>, passing it
+your Canvas object. The Surface will now draw the Canvas as you left it. Perform this sequence of locking and 
+unlocking the canvas each time you want to redraw.</p>
+
+<p class="note"><strong>Note:</strong> On each pass you retrieve the Canvas from the SurfaceHolder, 
+the previous state of the Canvas will be retained. In order to properly animate your graphics, you must re-paint the 
+entire surface. For example, you can clear the previous state of the Canvas by filling in a color
+with <code>{@link android.graphics.Canvas#drawColor(int) drawColor()}</code> or setting a background image
+with <code>{@link android.graphics.Canvas#drawBitmap(Bitmap,Rect,RectF,Paint) drawBitmap()}</code>. Otherwise,
+you will see traces of the drawings you previously performed.</p>
+
+
+<p>For a sample application, see the Lunar Landar game, in the SDK samples folder:
+<code>&lt;your-sdk-directory>/samples/LunarLander/</code>. Or,
+browse the source in the <a href="{@docRoot}guide/samples/index.html">Sample Code</a> section.</p>
+
+
+
+
+
+
+
+
diff --git a/docs/html/guide/topics/location/geo/mapkey.jd b/docs/html/guide/topics/location/geo/mapkey.jd
index 110876f..9aa824c 100644
--- a/docs/html/guide/topics/location/geo/mapkey.jd
+++ b/docs/html/guide/topics/location/geo/mapkey.jd
@@ -1,28 +1,210 @@
-page.title=Obtaining a MapView API Key
+page.title=Obtaining a Maps API Key
 @jd:body
 
-<p>{@link-fixme com.google.android.maps.MapView} is a very useful class that lets you easily integrate Google Maps into your application. It provides built-in map downloading, rendering, and caching, as well as a variety of display options and controls. It provides a wrapper around the Google Maps API that lets your application request and manipulate Google Maps data through class methods, and it lets you work with Maps data as you would other types of Views. </p>
+<div class="sidebox"><p>To register for a Maps API Key, read this document and then go to the <a href="http://code.google.com/android/maps-api-signup.html">Android Maps API Key Signup</a> page.</p>
 
-<p>Because MapView gives you access to Google Maps data, you need to register your application with the Google Maps service and agree to the applicable Terms of Service, before your MapView will be able to obtain data from Google Maps. This will apply whether you are developing your application on the emulator or preparing your application for deployment to mobile devices. </p>
+</div>
 
-<p>Registering your application is simple, and has two parts: </p>
+<p>com.google.android.maps.MapView is a very useful class that lets you easily integrate Google Maps into your application. It provides built-in map downloading, rendering, and caching of Maps tiles, as well as a variety of display options and controls. It provides a wrapper around the Google Maps API that lets your application request and manipulate Google Maps data through class methods, and it lets you work with Maps data as you would other types of Views. </p>
+
+<p>Because MapView gives you access to Google Maps data, you need to register with the Google Maps service and agree to the applicable Terms of Service before your MapView will be able to obtain data from Google Maps. This will apply whether you are developing your application on the emulator or preparing your application for deployment to mobile devices. </p>
+
+<p>Registering for a Maps API Key is simple, free, and has two parts: </p>
 
 <ol>
-<li>Registering a public key fingerprint from the certificate that you will use to sign the .apk. The registration service then provides you a Maps API Key that is associated with your application's signer certificate. </li>
-<li>Adding the Maps API Key to a special attribute of the MapView element &mdash; <code>android:apiKey</code>. You can use the same Maps API Key for any MapView in any application, provided that the application's .apk is signed with the certificate whose fingerprint you registered with the service. </li>
+<li>Registering the MD5 fingerprint of the certificate that you will use to sign your application. The Maps registration service then provides you a Maps API Key that is associated with your application's signer certificate. </li>
+<li>Adding a reference to the Maps API Key in each MapView, whether declared in XML or instantiated directly from code. You can use the same Maps API Key for any MapView in any Android application, provided that the application is signed with the certificate whose fingerprint you registered with the service. </li>
 </ol>
 
-<p>Once you have registered your application as described above, your MapView will be able to retrieve data from the Google Maps servers. </p>
+<p>During registration, you also need to agree to the Maps API Terms of Service, which describe how your application can use the Maps data. In general, the terms of service are permissive and place few restrictions on how you can use the data. For example, the terms allow you to build "friend finder" type applications. </p>
 
-<div class="special">
-<p>The MapView registration service is not yet active and Google Maps is not yet enforcing the Maps API Key requirement. The registration service will be activated soon, so that MapViews in any application deployed to a mobile device will require registration and a valid Maps API Key.</p>
+<p>The sections below describe how to obtain your Maps API Key and how to reference it from your MapView elements. </p>
 
-<p>As soon as the registration service becomes available, this page (<a href="http://code.google.com/android/toolbox/apis/mapkey.html">http://code.google.com/android/toolbox/apis/mapkey.html</a>) will be updated with details about how and where to register and how to add your Maps API Key to your application. </p>
+<ul>
+<li><a href="#overview">Overview</a></li>
+<li><a href="#getfingerprint">Getting the MD5 Fingerprint of Your Signing Certificate</a></li>
+<li><a href="#getdebugfingerprint">Getting the MD5 Fingerprint of the SDK Debug Certificate</a></li>
+<li><a href="#registering">Registering the Certificate Fingerprint with the Google Maps Service</a></li>
+<li><a href="#addingkey">Adding the Maps API Key to your Application</a></li>
+<li><a href="#finalsteps">Final Steps to Enable MapView Elements</a></li>
+</ul>
 
-<p>In the meantime, you can continue developing your MapView without registration, provided that you:</p>
-<ol type="a">
-<li>Add the attribute "android:apiKey" to the MapView element in your layout XML, with any value. Or</li>
-<li>Include an arbitrary string in the <code>apikey</code> parameter of the MapView constructor, if creating the MapView programmatically. </li>
+<h2 id="overview">Overview</h2>
+
+<p>MapView objects are views that display Maps tiles downloaded from the Google Maps service. To ensure that applications use Maps data in an appropriate manner, the Google Maps service requires application developers to register with the service, agreeing to the Terms of Service and supplying an MD5 fingerprint of the certificate(s) that they will use to sign applications. For each registered certificate fingerprint, the service then provides the developer with a Maps API Key &mdash; an alphanumeric string that uniquely identifies the certificate and developer registered with the service.  </p>
+
+<p>The Google Maps service also requires that each MapView identify itself to the service using a Maps API Key. Before providing Maps tiles to a MapView, the service checks the Maps API Key supplied by the MapView to ensure that it:</p>
+<ul>
+<li>References a certificate/developer registered with the service, and </li>
+<li>References a certificate that matches the certificate with which the application (containing the MapView) was signed. </li>
+</ul>
+
+<p>Unless both conditions are met, the service does not provide Maps tiles to the MapView. </p>
+
+<p>Each MapView object in your application must reference a Maps API Key. Since the Key is associated with a certificate, all Mapview elements in an application should reference the same Key. Going a step further, all MapView elements in all applications that you sign with the same certificate should reference the same Key. </p>
+
+<p>On the other hand, you can register for multiple Maps API Keys, each being associated with a specific certificate. You would want to do this if, for example, you were developing several independent applications that you will sign using different certificates. In this case, note that all MapView elements in a given application can reference the same Maps API Key, but <em>must</em> reference the Key that is associated with the certificate used to sign the application. </p>
+
+<p>Because MapView elements must refer to a Maps API Key, you need to register your certificate and receive a Key before you can make use of MapView elements in your application. To make it easier for you to get started using MapView elements, you are welcome to register the debug certificate generated by the SDK tools and receive a temporary Maps API Key. The details of how to do that are given below. </p>
+
+<p>When you are preparing to release your application, however, note that you <em>must</em> sign your application with a suitable cryptographic key, rather than the SDK debug key. That means that you will also need to register your application's release certificate with the Google Maps service. After you've done so, you will receive a new Maps API Key that is uniquely associated with your release certificate. To enable the MapView elements in your application to work after release, you must remember to change the Maps API Key for all MapViews in your application so that they refer to the Key associated with your release certificate (rather than your debug certificate). </p>
+
+<p>To summarize, the important points to understand about MapViews and the Maps API Key are: </p>
+
+<ul>
+<li>To display Maps data in a MapView, you need to register for a Maps API Key</li>
+<li>Each Maps API Key is uniquely associated with a specific certificate, based on an MD5 fingerprint of the certificate </li>
+<li>Each MapView must reference a Maps API Key, and the Key referenced must be registered to the certificate used to sign the application</li>
+<li>All MapView elements in an application can reference the same Maps API Key</li>
+<li>You can register multiple certificates under your developer identity</li>
+<li>You can get a temporary Maps API Key based on your debug certificate, but before you publish your application, you must register for a new Key based on your release certificate and update references in your MapViews accordingly</li>
+</ul>
+
+<h2 id="getfingerprint">Getting the MD5 Fingerprint of Your Signing Certificate</h2>
+
+<div class="sidebox">
+For more information about using Keytool and Jarsigner to sign your application, see <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>.
+</div>
+
+<p>To register for a Maps API Key, you need to provide an MD5 fingerprint of the certificate that you will use to sign your application. </p>
+
+<p>Before you visit the registration page, use Keytool to generate the fingerprint of the appropriate certificate. 
+
+<p>First, determine which key you will use to sign your application at release and make sure of the path to the keystore that contains it.</p>
+
+<p>Next, run Keytool with the <code>-list</code> option, against the target keystore and key alias. The table below lists the options you should use.</p>
+
+<table>
+<tr>
+<th>Keytool Option</th>
+<th>Description</th>
+</tr>
+<tr>
+<td><code>-list</code></td><td>Print an MD5 fingerprint of a certificate.</td>
+</tr>
+<tr>
+<td><code>-keystore&nbsp;&lt;keystore-name&gt;.keystore</code></td><td>The name of the keystore containing the target key.</td>
+</tr>
+<tr>
+<td><code>-storepass &lt;password&gt;</code></td><td><p>A password for the
+keystore.</p><p>As a security precaution, do not include this option 
+in your command line unless you are working at a secure computer.
+If not supplied, Keytool prompts you to enter the password. In this 
+way, your password is not stored in your shell history.</p></td>
+</tr>
+<tr>
+<td><code>-alias &lt;alias_name&gt;</code></td><td>The alias for the key for which to generate the MD5 certificate fingerprint.</td>
+</tr>
+<tr>
+<td><code>-keypass &lt;password&gt;</code></td><td><p>The password for the key.</p>
+<p>As a security precaution, do not include this option 
+in your command line unless you are working at a secure computer.
+If not supplied, Keytool prompts you to enter the password. In this 
+way, your password is not stored in your shell history.</p></td>
+</tr>
+</table>
+
+<p>Here's an example of a Keytool command that generates an MD5 certificate fingerprint for the key <code>alias_name</code> in the keystore <code>my-release-key.keystore</code>:</p>
+
+<pre>$ keytool -list -alias alias_name -keystore my-release-key.keystore</pre>
+
+<p>Keytool will prompt you to enter passwords for the keystore and key. As output of the command, Keytool prints the fingerprint to the shell. For example:</p>
+
+<pre>Certificate fingerprint (MD5): 94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98</pre>
+
+<p>Note that, if you happen to forget your Maps API Key, you can repeat the process described above and register the fingerprint again. The server will give you the same key for the specified certificate fingerprint.</p>
+
+<p>Once you have the fingerprint, you can go to the Maps API registration site, described next.</p>
+
+<h2 id="getdebugfingerprint">Getting the MD5 Fingerprint of the SDK Debug Certificate</h2>
+
+<p>While you are developing and debugging your application, you will likely be
+sigining your application in debug mode &mdash; that is, the SDK build tools
+will automatically sign your application using the debug certificate. To let
+your MapView elements properly display Maps data during this period, you should
+obtain a temporary Maps API Key registered to the debug certificate. To do so,
+you first need to get the MD5 fingerprint of the debug certificate. When
+you are ready to release your application, you must register your release
+certificate with the Google Maps service and obtain a new Maps API Key. You must
+then change the MapView elements in your application to reference the new API
+key. </p>
+
+<p>To generate an MD5 fingerprint of the debug certificate, first locate the debug keystore. The location at which the SDK tools create the default debug keystore varies by platform: </p>
+
+<ul>
+<li>Windows Vista: <code>C:\Users\&lt;user&gt;\AppData\Local\Android\debug.keystore</code></li>
+<li>Windows XP: <code>C:\Documents and Settings\&lt;user&gt;\Local Settings\Application&nbsp;Data\Android\debug.keystore</code></li>
+<li>OS X and Linux: <code>~/.android/debug.keystore</code></li>
+</ul>
+
+<p>If you are using Eclipse/ADT and are unsure where the debug keystore is located, you can select <strong>Windows</strong> &gt; <strong>Prefs</strong> &gt; <strong>Android</strong> &gt; <strong>Build</strong> to check the full path, which you can then paste into a file explorer to locate the directory containing the keystore.</p>
+
+<p>Once you have located the keystore, use this Keytool command to get the MD5 fingerprint of the debug certificate:</p>
+
+<pre>$ keytool -list -alias androiddebugkey \
+-keystore &lt;path_to_debug_keystore&gt;.keystore \
+-storepass android -keypass android</pre>
+
+<h2 id="registering">Registering the Certificate Fingerprint with the Google Maps Service</h2>
+
+<p>When you are ready to register for a Maps API Key, load this page in a browser: </p>
+
+<p><a href="http://code.google.com/android/maps-api-signup.html">http://code.google.com/android/maps-api-signup.html</a></p>
+
+<p>To register for a Maps API Key, follow these steps:</p>
+
+<ol>
+<li>If you don't have a Google account, use the link on the page to set one up. </li>
+<li>Read the Android Maps API Terms of Service carefully. If you agree to the terms, indicate so using the checkbox on the screen. </li>
+<li>Paste the MD5 certificate fingerprint of the certificate that you are registering into the appropriate form field.</li>
+<li>Click "Generate API Key"</li>
 </ol>
 
-<p>When the Maps API Key checking is activated in the service, any MapViews that do not have a properly registered apiKey will stop working.  The map data (tile images) of the MapView will never load (even if the device is on the network). In this case, go to the page linked above and read about how to register your certificate fingerprint and obtain a Maps API Key. </p>
+<p>The server will handle your request, associating the fingerprint with your developer identity and generating a unique Maps API Key, then returning a results page that gives you your Key string. </p>
+
+<p>To use the Maps API Key string, copy and paste it into your code as described in the next section.</p>
+
+<h2 id="addingkey">Adding the Maps API Key to your Application</h2>
+
+<p>Once you've registered with the Google Maps service and have obtained a Maps API Key, you must add it to your application's MapView objects, so that the Maps server will allow them to download Maps tiles. </p>
+
+<p>For <code>&lt;MapView&gt;</code> elements declared in XML layout files, add the Maps API Key as the value of a special attribute &mdash; <code>android:apiKey</code>. For example: </li>
+
+<pre>&lt;com.google.android.maps.MapView
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:enabled="true"
+ android:clickable="true"
+ android:apiKey="example_Maps_ApiKey_String"
+ /&gt;</pre>
+</li>
+
+<p>For MapView objects instantiated directly from code, pass the Maps API Key string as a parameter in the constructor. For example: </p>
+
+<pre>mMapView = new MapView(this, "example_Maps_ApiKey_String");</pre> 
+
+<p>For more information about MapView, see the MapView class Documentation. </p>
+
+<h2 id="finalsteps">Final Steps to Enable MapView Elements</h2>
+
+<p>If you've added the Maps API Key to the MapViews in your application, here are the final steps to enable the MapView elements to run properly:</p>
+
+<ul>
+<li>Make sure that you added a <code>&lt;uses-library&gt;</code> element referencing the external <code>com.google.android.maps</code> library. The element must be a child of the <code>&lt;application&gt;</code> element in the application's manifest. For example: 
+
+<p><pre>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.package.name"&gt;
+ ...
+ &lt;application android:name="MyApplication" &gt;
+   &lt;uses-library android:name="com.google.android.maps" /&gt;
+ ...
+ &lt;/application&gt;</pre></p></li>
+
+<li>Sign your application with the certificate that corresponds to the Maps API Key referenced in your MapView elements. </li>
+
+</ul>
+
+<div class="special"><p>Note that, when you are ready to publish your application, you must get a Maps API Key that is based on the certificate that you will use to sign the application for release. You must then change the Maps API Key string referenced by all of your MapView elements, so that they reference the new Key. </p></div>
+
+
+
diff --git a/docs/html/guide/topics/location/index.jd b/docs/html/guide/topics/location/index.jd
index eeaab39..53f1d29 100644
--- a/docs/html/guide/topics/location/index.jd
+++ b/docs/html/guide/topics/location/index.jd
@@ -95,7 +95,7 @@
 
 <p>Also note that you must obtain a MapView API Key from the Google Maps
 service, before your MapView can load maps data. For more information, see 
-<a href="{@docRoot}guide/developing/mapkey.html">Obtaining a MapView API Key</a>.</p>
+<a href="{@docRoot}guide/topics/location/geo/mapkey.html">Obtaining a MapView API Key</a>.</p>
 
 <p>Once you've created a MapView, you'll probably want to use 
 {@link-fixme com.google.android.maps.MapView#getController()} to 
diff --git a/docs/html/guide/topics/resources/available-resources.jd b/docs/html/guide/topics/resources/available-resources.jd
index 7ba9e52..2a6a6ac 100644
--- a/docs/html/guide/topics/resources/available-resources.jd
+++ b/docs/html/guide/topics/resources/available-resources.jd
@@ -853,7 +853,7 @@
 </dl>
 
 <p>For more discussion on how to create menus in XML and inflate them in your application, 
-read <a href="{@docRoot}guide/topics/views/menus.html">Creating Menus</a>.</p>
+read <a href="{@docRoot}guide/topics/ui/menus.html">Creating Menus</a>.</p>
 
 
 
@@ -877,7 +877,7 @@
 the root element.</p>
 
 <p>For a complete discussion on creating layouts, see the 
-<a href="{@docRoot}guide/topics/views/index.html">Views and Layout</a> topic.</p>
+<a href="{@docRoot}guide/topics/ui/index.html">User Interface</a> topic.</p>
 
 <p> <strong>Source file format:</strong> XML file
 requiring a <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code>
@@ -971,7 +971,7 @@
         <strong>Attributes exposed by all the superclasses of that element.</strong> For example, the TextView class extends the View class, so the <code>&lt;TextView&gt;</code> element supports all the attributes that the <code>&lt;View&gt;</code> element exposes &mdash; a long list, including <code>View_paddingBottom</code> and <code>View_scrollbars</code>. These too are used without the class name: <code>&lt;TextView android:paddingBottom="20" android:scrollbars="horizontal" /&gt;</code>.
     </li>
     <li>
-        <strong>Attributes of the object's {@link android.view.ViewGroup.LayoutParams} subclass.</strong> All View objects support a LayoutParams member (see <a href="{@docRoot}guide/topics/views/layout.html">LayoutParams in Implementing a UI</a>). To set properties on an element's LayoutParams member, the attribute to use is "android:layout_<em>layoutParamsProperty</em>". For example: <code>android:layout_gravity</code> for an object wrapped by a <code>&lt;LinearLayout&gt;</code> element. Remember that each LayoutParams subclass also supports inherited attributes. Attributes exposed by each subclass are given in the format <em>someLayoutParamsSubclass</em>_Layout_layout_<em>someproperty</em>. This defines an attribute "android:layout_<em>someproperty</em>". Here is an example of how Android documentation lists the properties of the {@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams} class:
+        <strong>Attributes of the object's {@link android.view.ViewGroup.LayoutParams} subclass.</strong> All View objects support a LayoutParams member (see <a href="{@docRoot}guide/topics/ui/declaring-layout.html#layout-params">Declaring Layout</a>). To set properties on an element's LayoutParams member, the attribute to use is "android:layout_<em>layoutParamsProperty</em>". For example: <code>android:layout_gravity</code> for an object wrapped by a <code>&lt;LinearLayout&gt;</code> element. Remember that each LayoutParams subclass also supports inherited attributes. Attributes exposed by each subclass are given in the format <em>someLayoutParamsSubclass</em>_Layout_layout_<em>someproperty</em>. This defines an attribute "android:layout_<em>someproperty</em>". Here is an example of how Android documentation lists the properties of the {@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams} class:
     </li>
 </ul>
 <ul>
@@ -1032,7 +1032,7 @@
     However, layout elements can also represent repeating elements used as templates.
 </p>
 
-<p>Also see <a href="{@docRoot}guide/topics/views/index.html">Views and Layout</a> for more information on layouts.</p>
+<p>Also see <a href="{@docRoot}guide/topics/ui/index.html">User Interface</a> for more information on layouts.</p>
 
 
 
@@ -1078,7 +1078,7 @@
 </p>
 
 <p>For a complete discussion on styles and themes, read 
-<a href="{@docRoot}guide/topics/views/themes.html">Applying Styles and Themes</a>.</p>
+<a href="{@docRoot}guide/topics/ui/themes.html">Applying Styles and Themes</a>.</p>
 
 <p>
     <strong>Source file format:</strong> XML file requiring a <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code> declaration, and a root <code>&lt;resources&gt;</code> element containing one or more <code>&lt;style&gt;</code> tags.
@@ -1132,4 +1132,4 @@
 </dl>
 
 <p>For examples of how to declare and apply styles and themes, read 
-<a href="{@docRoot}guide/topics/views/themes.html">Applying Styles and Themes</a>.</p>
+<a href="{@docRoot}guide/topics/ui/themes.html">Applying Styles and Themes</a>.</p>
diff --git a/docs/html/guide/topics/resources/resources-i18n.jd b/docs/html/guide/topics/resources/resources-i18n.jd
index 8a9bd43..b1da4cd 100644
--- a/docs/html/guide/topics/resources/resources-i18n.jd
+++ b/docs/html/guide/topics/resources/resources-i18n.jd
@@ -120,7 +120,7 @@
     <tr>
         <td><code>res/layout/</code></td>
         <td>XML files that are compiled into screen layouts (or part of a screen).
-            See <a href="{@docRoot}guide/topics/views/declaring-layout.html">Declaring Layout</a></td>
+            See <a href="{@docRoot}guide/topics/ui/declaring-layout.html">Declaring Layout</a></td>
     </tr>
     <tr>
         <td><code>res/values/</code></td>
diff --git a/docs/html/guide/topics/views/binding.jd b/docs/html/guide/topics/ui/binding.jd
similarity index 99%
rename from docs/html/guide/topics/views/binding.jd
rename to docs/html/guide/topics/ui/binding.jd
index ce57ac4..f9afbc5 100644
--- a/docs/html/guide/topics/views/binding.jd
+++ b/docs/html/guide/topics/ui/binding.jd
@@ -1,5 +1,5 @@
 page.title=Binding to Data with AdapterView
-parent.title=Views and Layout
+parent.title=User Interface
 parent.link=index.html
 @jd:body
 
diff --git a/docs/html/guide/topics/views/custom-components.jd b/docs/html/guide/topics/ui/custom-components.jd
similarity index 99%
rename from docs/html/guide/topics/views/custom-components.jd
rename to docs/html/guide/topics/ui/custom-components.jd
index 9e7943b..eccc2ca 100644
--- a/docs/html/guide/topics/views/custom-components.jd
+++ b/docs/html/guide/topics/ui/custom-components.jd
@@ -1,5 +1,5 @@
 page.title=Building Custom Components
-parent.title=Views and Layout
+parent.title=User Interface
 parent.link=index.html
 @jd:body
 
@@ -35,7 +35,7 @@
 
 <p>Among the layouts available are {@link android.widget.LinearLayout LinearLayout}, 
 {@link android.widget.FrameLayout FrameLayout}, {@link android.widget.AbsoluteLayout AbsoluteLayout}, 
-and others. For more examples, see <a href="layout.html">Common Layout Objects</a>.</p>
+and others. For more examples, see <a href="layout-objects.html">Common Layout Objects</a>.</p>
 
 <p>If none of the prebuilt widgets or layouts meets your needs, you can create your own View subclass. 
 If you only need to make small adjustments to an existing widget or layout, you can simply subclass 
diff --git a/docs/html/guide/topics/ui/declaring-layout.jd b/docs/html/guide/topics/ui/declaring-layout.jd
new file mode 100644
index 0000000..dd0b7de
--- /dev/null
+++ b/docs/html/guide/topics/ui/declaring-layout.jd
@@ -0,0 +1,269 @@
+page.title=Declaring Layout
+parent.title=User Interface
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+  <h2>In this document</h2>
+  <ol>
+    <li><a href="#write">Write the XML</a></li>
+    <li><a href="#load">Load the XML Resource</a></li>
+    <li><a href="#attributes">Attributes</a>
+      <ol>
+        <li><a href="#id">ID</a></li>
+        <li><a href="#layout-params">Layout Parameters</a></li>
+      </ol>
+    </li>
+    <li><a href="#Position">Position</a></li>
+    <li><a href="#SizePaddingMargin">Size, Padding and Margins</a></li>
+    <li><a href="#example">Example Layout</a></li>
+  </ol>
+</div>
+</div>
+
+<p>Your layout is the architecture for the user interface in an Activity.
+It defines the layout structure and holds all the elements that appear to the user. 
+You can declare your layout in two ways:</p>
+<ul>
+<li><strong>Declare UI elements in XML</strong>. Android provides a straightforward XML 
+vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.</li>
+<li><strong>Instantiate layout elements at runtime</strong>. Your 
+application can create View and ViewGroup objects (and manipulate their properties) programmatically. </li>
+</ul>
+
+<p>The Android framework gives you the flexibility to use either or both of these methods for declaring and managing your application's UI. For example, you could declare your application's default layouts in XML, including the screen elements that will appear in them and their properties. You could then add code in your application that would modify the state of the screen objects, including those declared in XML, at run time. </p>
+
+<div class="sidebox">
+  <p>The <a href="{@docRoot}guide/developing/tools/adt.html">Android Development Tools</a> 
+  (ADT) plugin for Eclipse offers a layout preview of your XML &mdash; 
+  with the XML file opened, select the <strong>Layout</strong> tab.</p>
+  <p>You should also try the 
+  <a href="{@docRoot}guide/developing/tools/hierarchy-viewer.html">Hierarchy Viewer</a> tool, 
+  for debugging layouts &mdash; it reveals layout property values, 
+  draws wireframes with padding/margin indicators, and full rendered views while 
+  you debug on the emulator or device.</p>
+</div>
+
+<p>The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems. As such, this document focuses on teaching you how to declare your layout in XML. If you're
+interested in instantiating View objects at runtime, refer to the {@link android.view.ViewGroup} and 
+{@link android.view.View} class references.</p>
+
+<p>In general, the XML vocabulary for declaring UI elements closely follows the structure and naming of the classes and methods, where element names correspond to class names and attribute names correspond to methods. In fact, the correspondence is often so direct that you can guess what XML attribute corresponds to a class method, or guess what class corresponds to a given xml element. However, note that not all vocabulary is identical. In some cases, there are slight naming differences. For
+example, the EditText element has a <code>text</code> attribute that corresponds to
+<code>EditText.setText()</code>. </p>
+
+<p class="note"><strong>Tip:</strong> Learn more about different layout types in <a href="{@docRoot}guide/topics/ui/layout-objects.html">Common
+Layout Objects</a>. There are also a collection of tutorials on building various layouts in the
+<a href="{@docRoot}guide/tutorials/views/index.html">Hello Views</a> tutorial guide.</p>
+
+<h2 id="write">Write the XML</h2>
+
+<div class="sidebox"><p>For your convenience, the API reference documentation for UI related classes lists the available XML attributes that correspond to the class methods, including inherited attributes.</p>
+<p>To learn more about the available XML elements and attributes, as well as the format of the XML file, see <a
+href="{@docRoot}guide/topics/resources/available-resources.html#layoutresources">Layout Resources</a>.</p>
+ </div>
+
+<p>Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create web pages in HTML &mdash; with a series of nested elements. </p>
+
+<p>Each layout file must contain exactly one root element, which must be a View or ViewGroup object. Once you've defined the root element, you can add additional layout objects or widgets as child elements to gradually build a View hierarchy that defines your layout. For example, here's an XML layout that uses a vertical {@link android.widget.LinearLayout}
+to hold a {@link android.widget.TextView} and a {@link android.widget.Button}:</p>
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?>
+&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="fill_parent" 
+              android:layout_height="fill_parent" 
+              android:orientation="vertical" >
+    &lt;TextView android:id="@+id/text"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:text="Hello, I am a TextView" />
+    &lt;Button android:id="@+id/button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="Hello, I am a Button" />
+&lt;/LinearLayout>
+</pre>
+
+<p>After you've declared your layout in XML, save the file with the <code>.xml</code> extension, 
+in your Android project's <code>res/layout/</code> directory, so it will properly compile. </p>
+
+<p>We'll discuss each of the attributes shown here a little later.</p>
+
+<h2 id="load">Load the XML Resource</h2>
+
+<p>When you compile your application, each XML layout file is compiled into a
+{@link android.view.View} resource. You should load the layout resource from your application code, in your 
+{@link android.app.Activity#onCreate(android.os.Bundle) Activity.onCreate()} callback implementation.
+Do so by calling <code>{@link android.app.Activity#setContentView(int) setContentView()}</code>, 
+passing it the reference to your layout resource in the form of: 
+<code>R.layout.<em>layout_file_name</em></code>  
+For example, if your XML layout is saved as <code>main_layout.xml</code>, you would load it
+for your Activity like so:</p>
+<pre>
+public void onCreate(Bundle savedInstanceState) {
+    super.onCreate(savedInstanceState);
+    setContentView.(R.layout.main_layout);
+}
+</pre>
+
+<p>The <code>onCreate()</code> callback method in your Activity is called by the Android framework when
+your Activity is launched (see the discussion on Lifecycles, in the 
+<a href="{@docRoot}guide/topics/fundamentals.html#lcycles">Application Fundamantals</a>, for more on this).</p>
+
+
+<h2 id="attributes">Attributes</h2>
+
+<p>Every View and ViewGroup object supports their own variety of XML attributes.
+Some attributes are specific to a View object (for example, TextView supports the <code>textSize</code>
+attribute), but these attributes are also inherited by any View objects that may extend this class.
+Some are common to all View objects, because they are inherited from the root View class (like 
+the <code>id</code> attribute). And, other attributes are considered "layout parameters," which are 
+attributes that describe certain layout orientations of the View object, as defined by that object's
+parent ViewGroup object.</p>
+
+<h3 id="id">ID</h3>
+
+<p>Any View object may have an integer ID associated with it, to uniquely identify the View within the tree.
+When the application is compiled, this ID is referenced as an integer, but the ID is typically 
+assigned in the layout XML file as a string, in the <code>id</code> attribute.
+This is an XML attribute common to all View objects
+(defined by the {@link android.view.View} class) and you will use it very often. 
+The syntax for an ID, inside an XML tag is:</p>
+<pre>android:id="&#64;+id/my_button"</pre>
+
+<p>The  at-symbol (&#64;) at the beginning of the string indicates that the XML parser should parse and expand the rest
+of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must
+be created and added to our resources (in the <code>R.java</code> file). There are a number of other ID resources that
+are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol,
+but must add the <code>android</code> package namespace, like so:</p>
+<pre>android:id="&#64;android:id/empty"</pre>
+<p>With the <code>android</code> package namespace in place, we're now referencing an ID from the <code>android.R</code>
+resources class, rather than the local resources class.</p>
+
+<p>In order to create views and reference them from the application, a common pattern is to:</p>
+<ol>
+  <li>Define a view/widget in the layout file and assign it a unique ID:
+<pre>
+&lt;Button android:id="&#64;+id/my_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="&#64;string/my_button_text"/>
+</pre>
+  </li>
+  <li>Then create an instance of the view object and capture it from the layout 
+(typically in the <code>{@link android.app.Activity#onCreate(Bundle) onCreate()}</code> method):
+<pre>
+Button myButton = (Button) findViewById(R.id.my_button);
+</pre>
+  </li>
+</ol>
+<p>Defining IDs for view objects is important when creating a {@link android.widget.RelativeLayout}.
+In a relative layout, sibling views can define their layout relative to another sibling view, 
+which is referenced by the unique ID.</p>
+<p>An ID need not be unique throughout the entire tree, but it should be
+unique within the part of the tree you are searching (which may often be the entire tree, so it's best 
+to be completely unique when possible).</p>
+
+
+<h3 id="layout-params">Layout Parameters</h3>
+
+<p>XML layout attributes named <code>layout_<em>something</em></code> define 
+layout parameters for the View that are appropriate for the ViewGroup in which it resides.</p>
+
+<p>Every ViewGroup class implements a nested class that extends {@link
+android.view.ViewGroup.LayoutParams}. This subclass
+contains property types that define the size and position for each child view, as
+appropriate for the view group. As you can see in the figure below, the parent
+view group defines layout parameters for each child view (including the child view group).</p>
+
+<img src="{@docRoot}images/layoutparams.png" alt="" height="300" align="center"/>
+
+<p>Note that every LayoutParams subclass has its own syntax for setting
+values. Each child element must define LayoutParams that are appropriate for its parent, 
+though it may also define different LayoutParams for its own children. </p>
+
+<p>All view groups include a width and height (<code>layout_width</code> and <code>layout_height</code>), 
+and each view is required to define them. 
+Many LayoutParams also include optional margins and
+borders. You can specify width and height with exact measurements, though you probably won't want
+to do this often. More often, you will tell your view to size itself either to
+the dimensions required by its content, or to become as big as its parent view group
+will allow (with the <var>wrap_content</var> and <var>fill_parent</var> values, respectively).
+The accepted measurement types are defined in the 
+<a href="{@docRoot}guide/topics/resources/available-resources.html#dimension">Available Resources</a> document.</p>
+
+
+<h2 id="Position">Layout Position</h2>
+   <p>
+   The geometry of a view is that of a rectangle. A view has a location,
+   expressed as a pair of <em>left</em> and <em>top</em> coordinates, and
+   two dimensions, expressed as a width and a height. The unit for location
+   and dimensions is the pixel.
+   </p>
+  
+   <p>
+   It is possible to retrieve the location of a view by invoking the methods
+   {@link android.view.View#getLeft()} and {@link android.view.View#getTop()}. The former returns the left, or X,
+   coordinate of the rectangle representing the view. The latter returns the
+   top, or Y, coordinate of the rectangle representing the view. These methods
+   both return the location of the view relative to its parent. For instance,
+   when getLeft() returns 20, that means the view is located 20 pixels to the
+   right of the left edge of its direct parent.
+   </p>
+  
+   <p>
+   In addition, several convenience methods are offered to avoid unnecessary
+   computations, namely {@link android.view.View#getRight()} and {@link android.view.View#getBottom()}.
+   These methods return the coordinates of the right and bottom edges of the
+   rectangle representing the view. For instance, calling {@link android.view.View#getRight()}
+   is similar to the following computation: <code>getLeft() + getWidth()</code>.
+   </p>
+   
+
+<h2 id="SizePaddingMargins">Size, Padding and Margins</h2>
+   <p>
+   The size of a view is expressed with a width and a height. A view actually
+   possess two pairs of width and height values.
+   </p>
+  
+   <p>
+   The first pair is known as <em>measured width</em> and
+   <em>measured height</em>. These dimensions define how big a view wants to be
+   within its parent. The
+   measured dimensions can be obtained by calling {@link android.view.View#getMeasuredWidth()}
+   and {@link android.view.View#getMeasuredHeight()}.
+   </p>
+  
+   <p>
+   The second pair is simply known as <em>width</em> and <em>height</em>, or
+   sometimes <em>drawing width</em> and <em>drawing height</em>. These
+   dimensions define the actual size of the view on screen, at drawing time and
+   after layout. These values may, but do not have to, be different from the
+   measured width and height. The width and height can be obtained by calling
+   {@link android.view.View#getWidth()} and {@link android.view.View#getHeight()}. 
+   </p>
+  
+   <p>
+   To measure its dimensions, a view takes into account its padding. The padding
+   is expressed in pixels for the left, top, right and bottom parts of the view.
+   Padding can be used to offset the content of the view by a specific amount of
+   pixels. For instance, a left padding of 2 will push the view's content by
+   2 pixels to the right of the left edge. Padding can be set using the
+   {@link android.view.View#setPadding(int, int, int, int)} method and queried by calling
+   {@link android.view.View#getPaddingLeft()}, {@link android.view.View#getPaddingTop()},
+   {@link android.view.View#getPaddingRight()} and {@link android.view.View#getPaddingBottom()}.  
+   </p>
+  
+   <p>
+   Even though a view can define a padding, it does not provide any support for
+   margins. However, view groups provide such a support. Refer to
+   {@link android.view.ViewGroup} and
+   {@link android.view.ViewGroup.MarginLayoutParams} for further information.
+   </p>
+
+<p>For more information about dimensions, see <a href="{@docRoot}guide/topics/resources/available-resources.html#dimension">Dimension Values</a>.</p>
+   
+
+
+
diff --git a/docs/html/guide/topics/ui/how-android-draws.jd b/docs/html/guide/topics/ui/how-android-draws.jd
new file mode 100644
index 0000000..a511005
--- /dev/null
+++ b/docs/html/guide/topics/ui/how-android-draws.jd
@@ -0,0 +1,94 @@
+page.title=How Android Draws Views
+parent.title=User Interface
+parent.link=index.html
+@jd:body
+
+
+<p>When an Activity receives focus, it will be requested to draw its layout.
+The Android framework will handle the procedure for drawing, but the Activity must provide
+the root node of its layout hierarchy.</p>
+
+<p>Drawing begins with the root node of the layout. It is requested to measure and 
+draw the layout tree. Drawing is handled by walking the tree and rendering each View that
+   intersects the invalid region. In turn, each View group is responsible for requesting
+each of its children to be drawn (with the <code>{@link android.view.View#draw(Canvas) draw()}</code> method) 
+and each View is responsible for drawing itself.
+ Because the tree is traversed in-order,
+   this means that parents will be drawn before (i.e., behind) their children, with
+   siblings drawn in the order they appear in the tree.
+   </p>
+
+<div class="sidebox">
+  <p>The framework will not draw Views that are not in the invalid region, and also 
+   will take care of drawing the Views background for you.</p>
+   <p>You can force a View to draw, by calling <code>{@link android.view.View#invalidate()}</code>.
+   </p>
+</div>
+
+<p>
+   Drawing the layout is a two pass process: a measure pass and a layout pass. The measuring
+   pass is implemented in <code>{@link android.view.View#measure(int, int)}</code> and is a top-down traversal
+   of the View tree. Each View pushes dimension specifications down the tree
+   during the recursion. At the end of the measure pass, every View has stored
+   its measurements. The second pass happens in
+   <code>{@link android.view.View#layout(int,int,int,int)}</code> and is also top-down. During
+   this pass each parent is responsible for positioning all of its children
+   using the sizes computed in the measure pass.
+   </p>
+   
+   <p>
+   When a View's <code>measure()</code> method returns, its <code>{@link android.view.View#getMeasuredWidth()}</code> and
+   <code>{@link android.view.View#getMeasuredHeight()}</code> values must be set, along with those for all of
+   that View's descendants. A View's measured width and measured height values
+   must respect the constraints imposed by the View's parents. This guarantees
+   that at the end of the measure pass, all parents accept all of their
+   children's measurements. A parent View may call <code>measure()</code> more than once on
+   its children. For example, the parent may measure each child once with
+   unspecified dimensions to find out how big they want to be, then call
+   <code>measure()</code> on them again with actual numbers if the sum of all the children's
+   unconstrained sizes is too big or too small (i.e., if the children don't agree among themselves
+  as to how much space they each get, the parent will intervene and set the rules on the second pass).
+   </p>
+   
+   <div class="sidebox"><p>
+   To intiate a layout, call <code>{@link android.view.View#requestLayout}</code>. This method is typically
+   called by a View on itself when it believes that is can no longer fit within
+   its current bounds.</p>
+   </div>
+
+   <p>
+   The measure pass uses two classes to communicate dimensions. The
+   {@link android.view.View.MeasureSpec} class is used by Views to tell their parents how they
+   want to be measured and positioned. The base LayoutParams class just
+   describes how big the View wants to be for both width and height. For each
+   dimension, it can specify one of:</p>
+   <ul>
+    <li> an exact number
+    <li><var>FILL_PARENT</var>, which means the View wants to be as big as its parent
+    (minus padding)</li>
+    <li><var>WRAP_CONTENT</var>, which means that the View wants to be just big enough to
+    enclose its content (plus padding).</li>
+   </ul>
+  <p>There are subclasses of LayoutParams for different subclasses of ViewGroup.
+   For example, AbsoluteLayout has its own subclass of LayoutParams which adds
+   an X and Y value.
+   </p>
+   
+   <p>
+   MeasureSpecs are used to push requirements down the tree from parent to
+   child. A MeasureSpec can be in one of three modes:</p>
+   <ul>
+    <li><var>UNSPECIFIED</var>: This is used by a parent to determine the desired dimension
+    of a child View. For example, a LinearLayout may call <code>measure()</code> on its child
+    with the height set to <var>UNSPECIFIED</var> and a width of <var>EXACTLY</var> 240 to find out how
+    tall the child View wants to be given a width of 240 pixels.</li>
+    <li><var>EXACTLY</var>: This is used by the parent to impose an exact size on the
+    child. The child must use this size, and guarantee that all of its
+    descendants will fit within this size.</li>
+    <li><var>AT_MOST</var>: This is used by the parent to impose a maximum size on the
+    child. The child must gurantee that it and all of its descendants will fit
+    within this size.</li>
+   </ul>
+   
+
+
diff --git a/docs/html/guide/topics/ui/index.jd b/docs/html/guide/topics/ui/index.jd
new file mode 100644
index 0000000..ccc8ff6
--- /dev/null
+++ b/docs/html/guide/topics/ui/index.jd
@@ -0,0 +1,235 @@
+page.title=User Interface
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+
+  <h2>Key classes and packages</h2>
+  <ol>
+    <li>{@link android.view.View}</li>
+    <li>{@link android.view.ViewGroup}</li>
+    <li>{@link android.widget}</li>
+  </ol>
+
+  <h2>In this document</h2>
+  <ol>
+    <li><a href="#ViewHierarchy">View Hierarchy</a></li>
+    <li><a href="#Layout">Layout</a></li>
+    <li><a href="#Widgets">Widgets</a></li>
+    <li><a href="#Events">UI Events</a></li>
+    <li><a href="#Menus">Menus</a></li>
+    <li><a href="#Advanced">Advanced Topics</a>
+      <ol>
+        <li><a href="#Adapters">Adapters</a></li>
+        <li><a href="#StylesAndThemes">Styles and Themes</a></li>
+      </ol>
+    </li>
+  </ol>
+</div>
+</div>
+
+<p>In an Android application, the user interface is built using {@link android.view.View} and 
+{@link android.view.ViewGroup} objects. There are many types of views and view groups, each of which 
+is a descendant of the {@link android.view.View} class.</p>
+
+<p>View objects are the basic units of user interface expression on the Android platform. 
+The View class serves as the base for subclasses called "widgets," which offer fully implemented
+UI objects, like text fields and buttons. The ViewGroup class serves as the base for subclasses called "layouts,"
+which offer different kinds of layout architecture, like linear, tabular and relative.</p>
+
+<p>A View object is a data structure whose properties store the layout parameters and content for a specific 
+rectangular area of the screen. A View object handles its own measurement, layout, drawing, focus change, 
+scrolling, and key/gesture interactions for the rectangular area of the screen in which it resides. As an
+object in the user interface, a View is also a point of interaction for the user and the receiver
+of the interaction events.</p>
+
+
+<h2 id="ViewHierarchy">View Hierarchy</h2>
+
+<p>On the Android platform, you define an Activity's UI using a hierarchy of View and ViewGroup nodes, 
+as shown in the diagram below. This hierarchy tree can be as simple or complex as you need it to be, and you 
+can build it up using Android's set of predefined widgets and layouts, or with custom Views that you 
+create yourself.</p>
+
+<img src="{@docRoot}images/viewgroup.png" alt="" width="312" height="211" align="center"/>
+
+<p>
+In order to attach the view hierarchy tree to the screen for rendering, your Activity must call the
+<code>{@link android.app.Activity#setContentView(int) setContentView()}</code> 
+method and pass a reference to the root node object. The Android system
+receives this reference and uses it to invalidate, measure, and draw the tree. The root node of the hierarchy requests 
+that its child nodes draw themselves &mdash; in turn, each view group node is responsible for calling 
+upon each of its own child views to draw themselves.
+The children may request a size and location within the parent, but the parent object has the final 
+decision on where how big each child can be.  Android parses 
+the elements of your layout in-order (from the top of the hierarchy tree), instantiating the Views and 
+adding them to their parent(s). Because these are drawn in-order, if there are elements that
+overlap positions, the last one to be drawn will lie on top of others previously drawn to that space.</p>
+
+<p>For a more detailed discussion on how view hierarchies are measured
+and drawn, read <a href="how-android-draws.html">How Android Draws Views</a>.</p>
+
+
+<h2 id="Layout">Layout</h2>
+
+<p>The most common way to define your layout and express the view hierarchy is with an XML layout file.
+XML offers a human-readable structure for the layout, much like HTML. Each element in XML is 
+either a View or ViewGroup object (or descendent thereof). View objects are leaves in the tree, 
+ViewGroup objects are branches in the tree (see the View Hierarchy figure above).</p>
+<p>The name of an XML element
+is respective to the Java class that it represents. So a <code>&lt;TextView></code> element creates
+a {@link android.widget.TextView} in your UI, and a <code>&lt;LinearLayout></code> element creates
+a {@link android.widget.LinearLayout} view group. When you load a layout resource, 
+the Android system initializes these run-time objects, corresponding to the elements in your layout.</p>
+
+<p>For example, a simple vertical layout with a text view and a button looks like this:</p>
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?>
+&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="fill_parent" 
+              android:layout_height="fill_parent"
+              android:orientation="vertical" >
+    &lt;TextView android:id="@+id/text"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:text="Hello, I am a TextView" />
+    &lt;Button android:id="@+id/button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="Hello, I am a Button" />
+&lt;/LinearLayout>
+</pre>
+
+<p>Notice that the LinearLayout element contains both the TextView and the Button. You can nest
+another LinearLayout (or other type of view group) inside here, to lengthen the view hierarchy and create a more
+complex layout.</p>
+
+<p>For more on building a UI layout, read <a href="declaring-layout.html">Declaring Layout</a>.
+
+<div class="sidebox-wrapper">
+<div class="sidebox">
+  <p><b>Tip:</b> You can also draw View and ViewGroups objects in Java code, 
+  using the <code>{@link android.view.ViewGroup#addView(View)}</code> methods 
+  to dynamically insert new View and ViewGroup objects.</p>
+</div>
+</div>
+
+<p>There are a variety of ways in which you can layout your views. Using more and different kinds of view groups,
+you can structure child views and view groups in an infinite number of ways.
+Some pre-defined view groups offered by Android (called layouts) include LinearLayout, RelativeLayout, AbsoluteLayout,
+TableLayout, GridLayout and others. Each offers a unique set of layout parameters that are used to define the
+positions of child views and layout structure.</p>
+<p>To learn about some of the different kinds of view groups used for a layout, 
+read <a href="layout-objects.html">Common Layout Objects</a>.</p>
+
+
+<h2 id="Widgets">Widgets</h2>
+
+<p>A widget is a View object that serves as an interface for interaction with the user. 
+Android provides a set of fully implemented 
+widgets, like buttons, checkboxes, and text-entry fields, so you can quickly build your UI. 
+Some widgets provided by Android are more complex, like a date picker, a clock, and zoom controls.
+But you're not limited to the kinds of widgets provided by the Android platform. If you'd
+like to do something more customized and create your own actionable elements, you can, by defining your own 
+View object or by extending and combining existing widgets.</p>
+<p>Read more in <a href="custom-components.html">Building Custom Components</a>.</p>
+
+<p>For a list of the widgets provided by Android, see the {@link android.widget} package.</p>
+
+
+<h2 id="Events">UI Events</h2>
+
+<p>Once you've added some Views/widgets to the UI, you probably want to know about the 
+user's interaction with them, so you can perform actions. To be informed of UI events, you need to 
+do one of two things:</p>
+<ul>
+  <li><strong>Define an event listener and register it with the View.</strong> More often than not,
+this is how you'll listen for events. The View class contains a collection of nested interfaces named
+On<em>&lt;something></em>Listener, each with a callback method called <code>On<em>&lt;something></em>()</code>.
+For example, {@link android.view.View.OnClickListener} (for handling "clicks" on a View),
+{@link android.view.View.OnTouchListener} (for handling touch screen events in a View), and
+{@link android.view.View.OnKeyListener} (for handling device key presses within a View). So if you want your View
+to be notified when it is "clicked" (such as when a button is selected), implement OnClickListener and define
+its <code>onClick()</code> callback method (where you perform the action upon click), and register it
+to the View with <code>{@link android.view.View#setOnClickListener(View.OnClickListener) setOnClickListener()}</code>.
+</li>
+  <li><strong>Override an existing callback method for the View.</strong> This is
+what you should do when you've implemented your own View class and want to listen for specific events 
+that occur within it. Example events you can handle include when the
+screen is touched (<code>{@link android.view.View#onTouchEvent(MotionEvent) onTouchEvent()}</code>), when
+the trackball is moved (<code>{@link android.view.View#onTrackballEvent(MotionEvent) onTrackballEvent()}</code>), 
+or when a key on the device is pressed (<code>{@link android.view.View#onKeyDown(int, KeyEvent)
+onKeyDown()}</code>). This allows you to define the default behavior for each event inside your custom View and determine
+whether the event should be passed on to some other child View. Again, these are callbacks to the View class,
+so your only chance to define them is when you 
+<a href="{@docRoot}guide/topics/ui/custom-components.html">build a custom component</a>.
+</li>
+</ul>
+
+<p>Continue reading about handling user interaction with Views in the <a href="ui-events.html">Handling UI Events</a>
+document.</p>
+
+
+<h2 id="Menus">Menus</h2>
+
+<p>Application menus are another important part of an application's UI. Menus offers a reliable interface that reveals
+application functions and settings. The most common application menu is revealed by pressing
+the MENU key on the device. However, you can also add Context Menus, which may be revealed when the user presses
+and holds down on an item.</p>
+
+<p>Menus are also structured using a View hierarchy, but you don't define this structure yourself. Instead,
+you define the <code>{@link android.app.Activity#onCreateOptionsMenu(Menu) onCreateOptionsMenu()}</code> or 
+<code>{@link android.app.Activity#onCreateContextMenu(ContextMenu,View,ContextMenu.ContextMenuInfo) onCreateContextMenu()}</code> 
+callback methods for your Activity and declare the items that you want to include in your menu. 
+At the appropriate time, Android will automatically create the necessary View hierarchy for the menu and 
+draw each of your menu items in it.</p>
+
+<p>Menus also handle their own events, so there's no need to register event listeners on the items in your menu.
+When an item in your menu is selected, the <code>{@link android.app.Activity#onOptionsItemSelected(MenuItem) 
+onOptionsItemSelected()}</code> or 
+<code>{@link android.app.Activity#onContextItemSelected(MenuItem) onContextItemSelected()}</code>
+method will be called by the framework.</p>
+
+<p>And just like your application layout, you have the option to declare the items for you menu in an XML file.</p>
+
+<p>Read <a href="{@docRoot}guide/topics/ui/menus.html">Creating Menus</a> to learn more.</p>
+
+
+<h2 id="Advanced">Advanced Topics</h2>
+
+<p>Once you've grappled the fundamentals of creating a user interface, you can explore
+some advanced features for creating a more complex application interface.</p>
+
+<h3 id="Adapters">Adapters</h3>
+
+<p>Sometimes you'll want to populate a view group with some information that can't be hard-coded, instead, 
+you want to bind your view to an external source of data. To do this, you use an AdapterView as
+your view group and each child View is initialized and populated with data from the Adapter.</p>
+<p>The AdapterView object is an implementation of ViewGroup that determines its child views
+based on a given Adapter object. The Adapter acts like a courier between your data source (perhaps an
+array of external strings) and the AdapterView, which displays it. There are several implementations
+of the Adapter class, for specific tasks, such as the CursorAdapter for reading database data from a Cursor,
+or an ArrayAdapter for reading from an arbitrary array.</p>
+<p>To learn more about using an Adapter to populate your views, read 
+<a href="binding.html">Binding to Data with AdapterView</a>.</p>
+
+
+<h3 id="StylesAndThemes">Styles and Themes</h3>
+
+<p>Perhaps you're not satisfied with the look of the standard widgets. To revise them, you can create some 
+of your own styles and themes.</p>
+
+<ul>
+  <li>A style is a set of one or more formatting attributes that you can apply as a unit to individual elements 
+in your layout. For example, you could define a style that specifies a certain text size and color, then 
+apply it to only specific View elements.</li>
+  <li>A theme is a set of one or more formatting attributes that you can apply as a unit to all activities in 
+an application, or just a single activity. For example, you could define a theme that sets specific colors for 
+the window frame and the panel background, and sets text sizes and colors for menus. This theme can then be 
+applied to specific activities or the entire application.</li>
+</ul>
+
+<p>Styles and themes are resources. Android provides some default style and theme resources that you can use, 
+or you can declare your own custom style and theme resources.</p>
+<p>Learn more about using styles and themes in the
+<a href="themes.html">Applying Styles and Themes</a> document.</p>
diff --git a/docs/html/guide/topics/views/layout.jd b/docs/html/guide/topics/ui/layout-objects.jd
similarity index 76%
rename from docs/html/guide/topics/views/layout.jd
rename to docs/html/guide/topics/ui/layout-objects.jd
index a6fec35..cf85fd6 100644
--- a/docs/html/guide/topics/views/layout.jd
+++ b/docs/html/guide/topics/ui/layout-objects.jd
@@ -1,5 +1,5 @@
 page.title=Common Layout Objects
-parent.title=Views and Layout
+parent.title=User Interface
 parent.link=index.html
 @jd:body
 
@@ -20,6 +20,8 @@
 <p>This section describes some of the more common types of layout objects
 to use in your applications. Like all layouts, they are subclasses of {@link android.view.ViewGroup ViewGroup}.</p>
 
+<p>Also see the <a href="{@docRoot}guide/tutorials/views/index.html">Hello Views</a> tutorials for
+some guidance on using more Android View layouts.</p>
 
 <h2 id="framelayout">FrameLayout</h2>
 <p>{@link android.widget.FrameLayout FrameLayout} is the simplest type of layout
@@ -95,9 +97,42 @@
 Each row has zero or more cells, each of which is defined by any kind of other View. So, the cells of a row may be
 composed of a variety of View objects, like ImageView or TextView objects.
 A cell may also be a ViewGroup object (for example, you can nest another TableLayout as a cell).</p>
-<p>The following image shows a table layout, with the invisible cell borders displayed as dotted lines. </p>
+<p>The following sample layout has two rows and two cells in each. The accompanying screenshot shows the 
+result, with cell borders displayed as dotted lines (added for visual effect). </p>
 
-<img src="{@docRoot}images/table_layout.png" alt="" />
+<table class="columns">
+    <tr>
+        <td>
+        <pre>
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:stretchColumns="1">
+    &lt;TableRow>
+        &lt;TextView
+            android:text="@string/table_layout_4_open"
+            android:padding="3dip" />
+        &lt;TextView
+            android:text="@string/table_layout_4_open_shortcut"
+            android:gravity="right"
+            android:padding="3dip" />
+    &lt;/TableRow>
+
+    &lt;TableRow>
+        &lt;TextView
+            android:text="@string/table_layout_4_save"
+            android:padding="3dip" />
+        &lt;TextView
+            android:text="@string/table_layout_4_save_shortcut"
+            android:gravity="right"
+            android:padding="3dip" />
+    &lt;/TableRow>
+&lt;/TableLayout>
+</pre></td>
+        <td><img src="{@docRoot}images/table_layout.png" alt="" style="margin:0" /></td>
+    </tr>
+</table>
 
 <p>Columns can be hidden, marked to stretch and fill the available screen space,
     or can be marked as shrinkable to force the column to shrink until the table
@@ -127,13 +162,54 @@
     will be aligned relative to screen center. Also, because of this ordering, if using XML to specify this layout, 
     the element that you will reference (in order to position other view objects) must be listed in the XML 
 file before you refer to it from the other views via its reference ID. </p>
-<p>Here is an example relative layout with the visible and invisible elements outlined.
-    The root screen layout object is a RelativeLayout object. </p>
+<p>The example below shows an XML file and the resulting screen in the UI. 
+Note that the attributes that refer to relative elements (e.g., <var>layout_toLeft</var>)
+refer to the ID using the syntax of a relative resource
+(<var>@id/<em>id</em></var>). </p>
 
-<img src="{@docRoot}images/designing_ui_relative_layout.png" alt="" />
+<table class="columns">
+    <tr>
+        <td>
+        <pre>
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android
+                android:layout_width=&quot;fill_parent&quot; 
+                android:layout_height=&quot;wrap_content&quot;
+                android:background=&quot;@drawable/blue&quot;
+                android:padding=&quot;10px&quot; &gt;
 
-<p>This diagram shows the class names of the screen elements, followed by a list
-    of the properties of each. Some of these properties are supported directly by
+    &lt;TextView android:id=&quot;@+id/label&quot; 
+              android:layout_width=&quot;fill_parent&quot; 
+              android:layout_height=&quot;wrap_content&quot; 
+              android:text=&quot;Type here:&quot; /&gt;
+
+    &lt;EditText android:id=&quot;@+id/entry&quot; 
+              android:layout_width=&quot;fill_parent&quot; 
+              android:layout_height=&quot;wrap_content&quot; 
+              android:background=&quot;@android:drawable/editbox_background&quot;
+              android:layout_below=&quot;@id/label&quot; /&gt;
+  
+    &lt;Button android:id=&quot;@+id/ok&quot; 
+            android:layout_width=&quot;wrap_content&quot; 
+            android:layout_height=&quot;wrap_content&quot; 
+            android:layout_below=&quot;@id/entry&quot;
+            android:layout_alignParentRight=&quot;true&quot;
+            android:layout_marginLeft=&quot;10px&quot;
+            android:text=&quot;OK&quot; /&gt;
+
+    &lt;Button android:layout_width=&quot;wrap_content&quot; 
+            android:layout_height=&quot;wrap_content&quot;
+            android:layout_toLeftOf=&quot;@id/ok&quot;
+            android:layout_alignTop=&quot;@id/ok&quot;
+            android:text=&quot;Cancel&quot; /&gt;
+&lt;/RelativeLayout&gt;
+</pre></td>
+        <td><img src="{@docRoot}images/designing_ui_layout_example.png" alt="" style="margin:0"  /></td>
+    </tr>
+</table>
+
+
+<p>Some of these properties are supported directly by
     the element, and some are supported by its LayoutParams member (subclass RelativeLayout
     for all the elements in this screen, because all elements are children of a RelativeLayout
     parent object). The defined RelativeLayout parameters are: <code>width</code>, <code>height</code>, 
diff --git a/docs/html/guide/topics/views/menus.jd b/docs/html/guide/topics/ui/menus.jd
similarity index 96%
rename from docs/html/guide/topics/views/menus.jd
rename to docs/html/guide/topics/ui/menus.jd
index 489cd07..ed796ee 100644
--- a/docs/html/guide/topics/views/menus.jd
+++ b/docs/html/guide/topics/ui/menus.jd
@@ -9,7 +9,7 @@
   <ol>
     <li><a href="#options-menu">Options Menu</a></li>
     <li><a href="#context-menu">Context Menu</a></li>
-    <li><a href="#sub-menu">Sub Menu</a></li>
+    <li><a href="#submenu">Submenu</a></li>
     <li><a href="#xml">Define Menus in XML</a></li>
     <li><a href="#features">Menu Features</a>
       <ol>
@@ -20,6 +20,12 @@
       </ol>
     </li>
   </ol>
+  <h2>Key classes</h2>
+  <ol>
+    <li>{@link android.view.Menu}</li>
+    <li>{@link android.view.ContextMenu}</li>
+    <li>{@link android.view.SubMenu}</li>
+  </ol>
 </div>
 </div>
 
@@ -47,9 +53,9 @@
   <dt><strong>Context Menu</strong></dt>
     <dd>This is a floating list of menu items that may appear when you perform a long-press on a View 
     (such as a list item). </dd>
-  <dt><strong>Sub Menu</strong></dt>
+  <dt><strong>Submenu</strong></dt>
     <dd>This is a floating list of menu items that is revealed by an item in the Options Menu
-    or a Context Menu. A Sub Menu item cannot support nested Sub Menus. </dd>
+    or a Context Menu. A Submenu item cannot support nested Submenus. </dd>
 </dl>
 
 
@@ -63,7 +69,7 @@
 
 <p>The Options Menu is where you should include basic application functions
 and any necessary navigation items (e.g., to a home screen or application settings).
-You can also add <a href="#sub-menu">Sub Menus</a> for organizing topics 
+You can also add <a href="#submenu">Submenus</a> for organizing topics 
 and including extra menu functionality.</p>
 
 <p>When this menu is opened for the first time, 
@@ -127,7 +133,7 @@
 
 <p class="note"><strong>Tip:</strong>
 If you have several menu items that can be grouped together with a title, 
-consider organizing them into a <a href="#sub-menu">Sub Menu</a>.</p>
+consider organizing them into a <a href="#submenu">Submenu</a>.</p>
 
 <h3>Adding icons</h3>
 <p>Icons can also be added to items that appears in the Icon Menu with
@@ -136,8 +142,8 @@
 menu.add(0, MENU_QUIT, 0, "Quit")
     .setIcon(R.drawable.menu_quit_icon);</pre>
 
-<h3>Modifying the options menu</h3>
-<p>If you want to sometimes re-write the options menu as it is opened, override the 
+<h3>Modifying the menu</h3>
+<p>If you want to sometimes re-write the Options Menu as it is opened, override the 
 <code>{@link android.app.Activity#onPrepareOptionsMenu(Menu) onPrepareOptionsMenu()}</code> method, which is
 called each time the menu is opened. This will pass you the Menu object, just like the 
 <code>onCreateOptionsMenu()</code> callback. This is useful if you'd like to add or remove
@@ -225,7 +231,7 @@
 
 
 
-<h2 id="sub-menu">Sub Menus</h2>
+<h2 id="submenu">Submenus</h2>
 <p>A sub menu can be added within any menu, except another sub menu.
 These are very useful when your application has a lot of functions that may be
 organized in topics, like the items in a PC application's menu bar (File, Edit, View, etc.).</p>
@@ -254,7 +260,7 @@
 <p>Callbacks for items selected in a sub menu are made to the parent menu's callback method. 
 For the example above, selections in the sub menu will be handled by the 
 <code>onOptionsItemSelected()</code> callback.</p>
-<p>You can also add Sub Menus when you <a href="#xml">define the parent menu in XML</a>.</p>
+<p>You can also add Submenus when you <a href="#xml">define the parent menu in XML</a>.</p>
 
 
 <h2 id="xml">Define Menus in XML</h2>
@@ -269,7 +275,7 @@
 three valid elements: <code>&lt;menu></code>, <code>&lt;group></code> and <code>&lt;item></code>. The
 <code>item</code> and <code>group</code> elements must be children of a <code>menu</code>, but <code>item</code>
 elements may also be the children of a <code>group</code>, and another <code>menu</code> element may be the child
-of an <code>item</code> (to create a Sub Menu). Of course, the root node of any file
+of an <code>item</code> (to create a Submenu). Of course, the root node of any file
 must be a <code>menu</code> element.</p>
 
 <p>As an example, we'll define the same menu created in the <a href="#options-menu">Options Menu</a> section, 
@@ -302,7 +308,7 @@
 and it keeps your application code clean.</p>
 
 <p>You can define <a href="#groups">menu groups</a> by wrapping <code>item</code> elements in a <code>group</code>
-element, and create Sub Menus by nesting another <code>menu</code> inside an <code>item</code>.
+element, and create Submenus by nesting another <code>menu</code> inside an <code>item</code>.
 Each element also supports all the necessary attributes to control features like shortcut keys,
 checkboxes, icons, and more. To learn about these attributes and more about the XML syntax, see the Menus
 topic in the <a href="{@docRoot}guide/topics/resources/available-resources.html#menus">Available 
@@ -367,7 +373,7 @@
 and call <code>{@link android.view.Menu#setGroupCheckable(int,boolean,boolean) 
 setGroupCheckable()}</code>. In this case, you don't need to call <code>setCheckable()</code>
 on each menu items, because the group as a whole is set checkable. Here's an example of
-two mutually exclusive options in a sub-menu:</p>
+two mutually exclusive options in a Submenu:</p>
 <pre>
 SubMenu subMenu = menu.addSubMenu("Color");
 subMenu.add(COLOR_MENU_GROUP, COLOR_RED_ID, 0, "Red");
diff --git a/docs/html/guide/topics/views/themes.jd b/docs/html/guide/topics/ui/themes.jd
similarity index 99%
rename from docs/html/guide/topics/views/themes.jd
rename to docs/html/guide/topics/ui/themes.jd
index a206a4b..d684512 100644
--- a/docs/html/guide/topics/views/themes.jd
+++ b/docs/html/guide/topics/ui/themes.jd
@@ -1,5 +1,5 @@
 page.title=Applying Styles and Themes
-parent.title=Views and Layout
+parent.title=User Interface
 parent.link=index.html
 @jd:body
 
diff --git a/docs/html/guide/topics/ui/ui-events.jd b/docs/html/guide/topics/ui/ui-events.jd
new file mode 100644
index 0000000..f4d114a
--- /dev/null
+++ b/docs/html/guide/topics/ui/ui-events.jd
@@ -0,0 +1,283 @@
+page.title=Handling UI Events
+parent.title=User Interface
+parent.link=index.html
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+  <h2>In this document</h2>
+  <ol>
+    <li><a href="#EventListeners">Event Listeners</a></li>
+    <li><a href="#EventHandlers">Event Handlers</a></li>
+    <li><a href="#TouchMode">Touch Mode</a></li>
+    <li><a href="#HandlingFocus">Handling Focus</a></li>
+  </ol>
+
+  <h2>See also</h2>
+  <ol>
+    <li><a href="{@docRoot}guide/tutorials/views/hello-formstuff.html">Hello Form Stuff tutorial</a></li>
+  </ol>
+</div>
+</div>
+
+<p>On Android, there's more than one way to intercept the events from a user's interaction with your application.
+When considering events within your user interface, the approach is to capture the events from
+the specific View object that the user interacts with. The View class provides the means to do so.</p>
+
+<p>Within the various View classes that you'll use to compose your layout, you may notice several public callback 
+methods that look useful for UI events. These methods are called by the Android framework when the 
+respective action occurs on that object. For instance, when a View (such as a Button) is touched,
+the <code>onTouchEvent()</code> method is called on that object. However, in order to intercept this, you must extend
+the class and override the method. Obviously, extending every View object
+you want to use (just to handle an event) would be obsurd. This is why the View class also contains
+a collection of nested interfaces with callbacks that you can much more easily define. These interfaces,
+called <a href="#EventListeners">event listeners</a>, are your ticket to capturing the user interaction with your UI.</p>
+
+<p>While you will more commonly use the event listeners to listen for user interaction, there may
+come a time when you do want to extend a View class, in order to build a custom component. 
+Perhaps you want to extend the {@link android.widget.Button}
+class to make something more fancy. In this case, you'll be able to define the default event behaviors for your
+class using the class <a href="#EventHandlers">event handlers</a>.</p>
+
+
+<h2 id="EventListeners">Event Listeners</h2>
+
+<p>An event listener is an interface in the {@link android.view.View} class that contains a single 
+callback method. These methods will be called by the Android framework when the View to which the listener has
+been registered is triggered by user interaction with the item in the UI.</p>
+
+<p>Included in the event listener interfaces are the following callback methods:</p>
+
+<dl>
+  <dt><code>onClick()</code></dt>
+    <dd>From {@link android.view.View.OnClickListener}. 
+    This is called when the user either touches the item 
+    (when in touch mode), or focuses upon the item with the navigation-keys or trackball and
+    presses the suitable "enter" key or presses down on the trackball.</dd>
+  <dt><code>onLongClick()</code></dt>
+    <dd>From {@link android.view.View.OnLongClickListener}. 
+    This is called when the user either touches and holds the item (when in touch mode), or 
+    focuses upon the item with the navigation-keys or trackball and
+    presses and holds the suitable "enter" key or presses and holds down on the trackball (for one second).</dd>
+  <dt><code>onFocusChange()</code></dt>
+    <dd>From {@link android.view.View.OnFocusChangeListener}. 
+    This is called when the user navigates onto or away from the item, using the navigation-keys or trackball.</dd>
+  <dt><code>onKey()</code></dt>
+    <dd>From {@link android.view.View.OnKeyListener}. 
+    This is called when the user is focused on the item and presses or releases a key on the device.</dd>
+  <dt><code>onTouch()</code></dt>
+    <dd>From {@link android.view.View.OnTouchListener}. 
+    This is called when the user performs an action qualified as a touch event, including a press, a release,
+    or any movement gesture on the screen (within the bounds of the item).</dd>
+  <dt><code>onCreateContextMenu()</code></dt>
+    <dd>From {@link android.view.View.OnCreateContextMenuListener}. 
+    This is called when a Context Menu is being built (as the result of a sustained "long click"). See the discussion
+    on context menus in <a href="{@docRoot}guide/topics/ui/menus.html#context-menu">Creating Menus</a> for more information.</dd>
+</dl>
+
+<p>These methods are the sole inhabitants of their respective interface. To define one of these methods
+and handle your events, implement the nested interface in your Activity or define it as an anonymous class.
+Then, pass an instance of your implementation
+to the respective <code>View.set...Listener()</code> method. (E.g., call 
+<code>{@link android.view.View#setOnClickListener(View.OnClickListener) setOnClickListener()}</code> 
+and pass it your implementation of the {@link android.view.View.OnClickListener OnClickListener}.)</p>
+
+<p>The example below shows how to register an on-click listener for a Button. </p>
+
+<pre>
+// Create an anonymous implementation of OnClickListener
+private OnClickListener mCorkyListener = new OnClickListener() {
+    public void onClick(View v) {
+      // do something when the button is clicked
+    }
+};
+
+protected void onCreate(Bundle savedValues) {
+    ...
+    // Capture our button from layout
+    Button button = (Button)findViewById(R.id.corky);
+    // Register the onClick listener with the implementation above
+    button.setOnClickListener(mCorkyListener);
+    ...
+}
+</pre>
+
+<p>You may also find it more conventient to implement OnClickListener as a part of your Activity.
+This will avoid the extra class load and object allocation. For example:</p>
+<pre>
+public class ExampleActivity extends Activity implements OnClickListener {
+    protected void onCreate(Bundle savedValues) {
+        ...
+        Button button = (Button)findViewById(R.id.corky);
+        button.setOnClickListener(this);
+    }
+
+    // Implement the OnClickListener callback
+    public void onClick(View v) {
+      // do something when the button is clicked
+    }
+    ...
+}
+</pre>
+
+<p>Notice that the <code>onClick()</code> callback in the above example has
+no return value, but some other event listener methods must return a boolean. The reason
+depends on the event. For the few that do, here's why:</p>
+<ul>
+  <li><code>{@link android.view.View.OnLongClickListener#onLongClick(View) onLongClick()}</code> - 
+    This returns a boolean to indicate whether you have consumed the event and it should not be carried further. 
+    That is, return <em>true</em> to indicate that you have handled the event and it should stop here; 
+    return <em>false</em> if you have not handled it and/or the event should continue to any other
+    on-click listeners.</li>
+  <li><code>{@link android.view.View.OnKeyListener#onKey(View,int,KeyEvent) onKey()}</code> - 
+    This returns a boolean to indicate whether you have consumed the event and it should not be carried further.
+    That is, return <em>true</em> to indicate that you have handled the event and it should stop here; 
+    return <em>false</em> if you have not handled it and/or the event should continue to any other
+    on-key listeners.</li>
+  <li><code>{@link android.view.View.OnTouchListener#onTouch(View,MotionEvent) onTouch()}</code> - 
+    This returns a boolean to indicate whether your listener consumes this event. The important thing is that
+    this event can have multiple actions that follow each other. So, if you return <em>false</em> when the
+    down action event is received, you indicate that you have not consumed the event and are also
+    not interested in subsequent actions from this event. Thus, you will not be called for any other actions
+    within the event, such as a fingure gesture, or the eventual up action event.</li>
+</ul>
+
+<p>Remember that key events are always delivered to the View currently in focus. They are dispatched starting from the top
+of the View hierarchy, and then down, until they reach the appropriate destination. If your View (or a child of your View)
+currently has focus, then you can see the event travel through the <code>{@link android.view.View#dispatchKeyEvent(KeyEvent)
+dispatchKeyEvent()}</code> method. As an alternative to capturing key events through your View, you can also receive 
+all of the events inside your Activity with <code>{@link android.app.Activity#onKeyDown(int,KeyEvent) onKeyDown()}</code>
+and <code>{@link android.app.Activity#onKeyUp(int,KeyEvent) onKeyUp()}</code>.</p>
+
+<p class="note"><strong>Note:</strong> Android will call event handlers first and then the appropriate default
+handlers from the class definition second. As such, returning <em>true</em> from these event listeners will stop
+the propagation of the event to other event listeners and will also block the callback to the
+default event handler in the View. So be certain that you want to terminate the event when you return <em>true</em>.</p>
+
+
+<h2 id="EventHandlers">Event Handlers</h2>
+
+<p>If you're building a custom component from  View, then you'll be able to define several callback methods
+used as default event handlers.
+In the document on <a href="{@docRoot}guide/topics/ui/custom-components.html">Building Custom Components</a>,
+you'll learn see some of the common callbacks used for event handling, including:</p>
+<ul>
+  <li><code>{@link  android.view.View#onKeyDown}</code> - Called when a new key event occurs.</li>
+  <li><code>{@link  android.view.View#onKeyUp}</code> - Called when a key up event occurs.</li>
+  <li><code>{@link  android.view.View#onTrackballEvent}</code> - Called when a trackball motion event occurs.</li>
+  <li><code>{@link  android.view.View#onTouchEvent}</code> - Called when a touch screen motion event occurs.</li>
+  <li><code>{@link  android.view.View#onFocusChanged}</code> - Called when the view gains or loses focus.</li>
+</ul>
+<p>There are some other methods that you should be awere of, which are not part of the View class, 
+but can directly impact the way you're able to handle events. So, when managing more complex events inside 
+a layout, consider these other methods:</p>
+<ul>
+  <li><code>{@link  android.app.Activity#dispatchTouchEvent(MotionEvent)
+    Activity.dispatchTouchEvent(MotionEvent)}</code> - This allows your {@link 
+    android.app.Activity} to intercept all touch events before they are dispatched to the window.</li>
+  <li><code>{@link  android.view.ViewGroup#onInterceptTouchEvent(MotionEvent)
+    ViewGroup.onInterceptTouchEvent(MotionEvent)}</code> - This allows a {@link
+    android.view.ViewGroup} to watch events as they are dispatched to child Views.</li>
+  <li><code>{@link  android.view.ViewParent#requestDisallowInterceptTouchEvent(boolean)
+    ViewParent.requestDisallowInterceptTouchEvent(boolean)}</code> - Call this
+    upon a parent View to indicate that it should not intercept touch events with <code>{@link 
+    android.view.ViewGroup#onInterceptTouchEvent(MotionEvent)}</code>.</li>
+</ul>
+
+<h2 id="TouchMode">Touch Mode</h2>
+<p>
+When a user is navigating a user interface with directional keys or a trackball, it is
+necessary to give focus to actionable items (like buttons) so the user can see
+what will accept input.  If the device has touch capabilities, however, and the user
+begins interacting with the interface by touching it, then it is no longer necessary to
+highlight items, or give focus to a particular View.  Thus, there is a mode
+for interaction named "touch mode." 
+</p>
+<p>
+For a touch-capable device, once the user touches the screen, the device
+will enter touch mode.  From this point onward, only Views for which
+{@link android.view.View#isFocusableInTouchMode} is true will be focusable, such as text editing widgets.
+Other Views that are touchable, like buttons, will not take focus when touched; they will
+simply fire their on-click listeners when pressed.
+</p>
+<p>
+Any time a user hits a directional key or scrolls with a trackball, the device will
+exit touch mode, and find a view to take focus. Now, the user may resume interacting
+with the user interface without touching the screen.
+</p>
+<p>
+The touch mode state is maintained throughout the entire system (all windows and activities). 
+To query the current state, you can call
+{@link android.view.View#isInTouchMode} to see whether the device is currently in touch mode.
+</p>
+
+
+<h2 id="HandlingFocus">Handling Focus</h2>
+
+<p>The framework will handle routine focus movement in response to user input.
+This includes changing the focus as Views are removed or hidden, or as new
+Views become available. Views indicate their willingness to take focus
+through the <code>{@link android.view.View#isFocusable()}</code> method. To change whether a View can take
+focus, call <code>{@link android.view.View#setFocusable(boolean) setFocusable()}</code>.  When in touch mode,
+you may query whether a View allows focus with <code>{@link android.view.View#isFocusableInTouchMode()}</code>.
+You can change this with <code>{@link android.view.View#setFocusableInTouchMode(boolean) setFocusableInTouchMode()}</code>.
+</p>
+
+<p>Focus movement is based on an algorithm which finds the nearest neighbor in a
+given direction. In rare cases, the default algorithm may not match the
+intended behavior of the developer. In these situations, you can provide
+explicit overrides with the following XML attributes in the layout file:
+<var>nextFocusDown</var>, <var>nextFocusLeft</var>, <var>nextFocusRight</var>, and
+<var>nextFocusUp</var>. Add one of these attributes to the View <em>from</em> which
+the focus is leaving. Define the value of the attribute to be the id of the View
+<em>to</em> which focus should be given. For example:</p>
+<pre>
+&lt;LinearLayout
+    android:orientation="vertical"
+    ... >
+  &lt;Button android:id="@+id/top"
+          android:nextFocusUp="@+id/bottom"
+          ... />
+  &lt;Button android:id="@+id/bottom"
+          android:nextFocusDown="@+id/top"
+          ... />
+&lt;/LinearLayout>
+</pre>
+
+<p>Ordinarily, in this vertical layout, navigating up from the first Button would not go
+anywhere, nor would navigating down from the second Button. Now that the top Button has
+defined the bottom one as the <var>nextFocusUp</var> (and vice versa), the navigation focus will 
+cycle from top-to-bottom and bottom-to-top.</p>
+
+<p>If you'd like to declare a View as focusable in your UI (when it is traditionally not), 
+add the <code>android:focusable</code> XML attribute to the View, in your layout declaration.
+Set the value <var>true</var>. You can also declare a View
+as focusable while in Touch Mode with <code>android:focusableInTouchMode</code>.</p>
+<p>To request a particular View to take focus, call <code>{@link android.view.View#requestFocus()}</code>.</p>
+<p>To listen for focus events (be notified when a View receives or looses focus), use
+<code>{@link android.view.View.OnFocusChangeListener#onFocusChange(View,boolean) onFocusChange()}</code>,
+as discussed in the <a href="#EventListeners">Event Listeners</a> section, above.</p>
+
+
+
+<!--
+<h2 is="EventCycle">Event Cycle</h2>
+   <p>The basic cycle of a View is as follows:</p>
+   <ol>
+    <li>An event comes in and is dispatched to the appropriate View. The View
+    handles the event and notifies any listeners.</li>
+    <li>If, in the course of processing the event, the View's bounds may need
+    to be changed, the View will call {@link android.view.View#requestLayout()}.</li>
+    <li>Similarly, if in the course of processing the event the View's appearance
+    may need to be changed, the View will call {@link android.view.View#invalidate()}.</li>
+    <li>If either {@link android.view.View#requestLayout()} or {@link android.view.View#invalidate()} were called,
+    the framework will take care of measuring, laying out, and drawing the tree
+    as appropriate.</li>
+   </ol>
+   
+   <p class="note"><strong>Note:</strong> The entire View tree is single threaded. You must always be on
+   the UI thread when calling any method on any View.
+   If you are doing work on other threads and want to update the state of a View
+   from that thread, you should use a {@link android.os.Handler}.
+   </p>
+-->
diff --git a/docs/html/guide/topics/views/declaring-layout.jd b/docs/html/guide/topics/views/declaring-layout.jd
deleted file mode 100644
index 43afdf7..0000000
--- a/docs/html/guide/topics/views/declaring-layout.jd
+++ /dev/null
@@ -1,228 +0,0 @@
-page.title=Declaring Layout
-parent.title=Views and Layout
-parent.link=index.html
-@jd:body
-
-<div id="qv-wrapper">
-<div id="qv">
-  <h2>In this document</h2>
-  <ol>
-    <li><a href="#LoadingTheResource">Loading the XML Resource</a></li>
-    <li><a href="#Position">Position</a></li>
-    <li><a href="#SizePaddingMargin">Size, Padding and Margins</a></li>
-  </ol>
-</div>
-</div>
-
-<p>You can create your application's user interface in two ways: 
-<ul>
-<li><strong>Declare UI elements statically, in XML</strong>. Android provides a straightforward XML 
-vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. </li>
-<li><strong>Instantiate screen elements at runtime</strong>. Your 
-application can refer to or create View or other class objects and manipulate their properties programmatically. </li>
-</ul>
-
-<p>One advantage of declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls it's behavior. Your UI description is external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations and for a variety of device screen sizes or languages. Additionally, declaring in XML makes it easier to see the elements and structure of your UI, so it's easier to debug problems. </p>
-
-<div class="sidebox">
-  <p>The <a href="{@docRoot}guide/developing/tools/adt.html">Android Development Tools</a> 
-  (ADT) plugin for Eclipse offers a layout preview of your XML &mdash; 
-  with the XML file opened, select the <strong>Layout</strong> tab.</p>
-  <p>You should also try the 
-  <a href="{@docRoot}guide/developing/tools/hierarchy-viewer.html">Hierarchy Viewer</a> tool, 
-  for debugging layouts &mdash; it reveals layout property values, 
-  draws wireframes with padding/margin indicators, and full rendered views while 
-  you debug on the emulator or device.</p>
-</div>
-
-<p>The Android framework gives you the flexibility to use either or both of these ways of declaring and managing your application's UI. For example, you could declare your application's default layouts in XML, including the screen elements that will appear in them and their properties. You could then add code in your application that would modify the state of the screen objects, including those declared in XML, at run time. </p>
-
-<p>You build your application's UI in approximately the same way, whether you are declaring it in XML or programmatically. In both cases, your UI will be a tree structure that may include multiple View or Viewgroup subclasses. </p>
-
-<p>In general, the XML vocabulary for declaring UI elements closely follows the structure and naming of the framework's UI-related classes and methods, where element names correspond to class names and attribute names correspond to methods. In fact, the correspondence is often so direct that you can guess what XML attribute corresponds to a class method, or guess what class corresponds to a given xml element. </p>
-
-<p>However, note that the XML vocabulary for defining UI is not entirely identical to the framework's classes and methods. In some cases, there are slight naming differences. For
-example, the EditText element has a <code>text</code> attribute that corresponds to
-<code>EditText.setText()</code>. </p>
-
-<div class="sidebox"><p>For your convenience, the API reference documentation for UI related classes lists the available XML attributes that correspond to the class methods, including inherited attributes.</p>
-
-<p>To learn more about the available XML elements and attributes, as well as the format of the XML file, see <a
-href="{@docRoot}guide/topics/resources/available-resources.html#layoutresources">Layout Resources</a>.</p>
- </div>
-
-<p>Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create HTML files &mdash; as a series of nested tags. </p>
-
-<p>Each layout file must contain exactly one root element, and the root element must be a View or ViewGroup object. Once you've defined the root element, you can add additional layout objects or controls as child elements of the root element, if needed. In the example below, the tree of XML elements evaluates to the outermost LinearLayout object.
-
-<p>After you've declared your layout in XML, you must save the file, with the <code>.xml</code> extension, 
-in your application's <code>res/layout/</code> directory, so it will properly compile. </p>
-
-<p>When you compile your application, each XML layout file is compiled into an
-android.view.View resource. You can then load the layout resource from your application code, by calling <code>setContentView(R.layout.<em>layout_file_name</em>)</code> in your {@link android.app.Activity#onCreate(android.os.Bundle) Activity.onCreate()} 
-implementation.</p>
-
-<p>When you load a layout resource, the Android system initializes run-time objects corresponding to the elements in your layout. It parses the elements of your layout in-order (depth-first), instantiating the Views and adding them to their parent(s). 
-See <a href="how-android-draws.html">How Android Draws Views</a> for more information.</p>
-
-<p>Attributes named <code>layout_<em>something</em></code> apply to that
-object's LayoutParams member. <a href="{@docRoot}guide/topics/resources/available-resources.html#layoutresources">Layout
-Resources</a> also describes how to learn the syntax for specifying
-LayoutParams properties. </p>
-
-<p>Also note that Android draws elements in the order in which they
-appear in the XML. Therefore, if elements overlap, the last one in the XML
-file will probably be drawn on top of any previously listed elements in that
-same space.</p>
-
-<p>The following values are supported for dimensions (described in {@link
-android.util.TypedValue TypedValue}):</p>
-
-<ul>
-    <li>px (pixels) </li>
-    <li>dip (device independent pixels) </li>
-    <li>sp (scaled pixels &mdash; best for text size) </li>
-    <li>pt (points) </li>
-    <li>in (inches) </li>
-    <li>mm (millimeters) </li>
-</ul>
-
-<p>Example: <code>android:layout_width=&quot;25px&quot;</code> </p>
-
-<p>For more information about these dimensions, see <a href="{@docRoot}guide/topics/resources/available-resources.html#dimension">Dimension Values</a>.</p>
-
-<p>The example below shows an XML file and the resulting screen in the UI. Note that the text on the
-top of the screen was set by calling {@link
-android.app.Activity#setTitle(java.lang.CharSequence) Activity.setTitle}. Note
-that the attributes that refer to relative elements (i.e., layout_toLeft)
-refer to the ID using the syntax of a relative resource
-(@id/<em>id_number</em>). </p>
-
-<table border="1">
-    <tr>
-        <td>
-        <pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
-&lt;!-- Demonstrates using a relative layout to create a form --&gt;
-&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android
-                android:layout_width=&quot;fill_parent&quot; 
-                android:layout_height=&quot;wrap_content&quot;
-                android:background=&quot;@drawable/blue&quot;
-                android:padding=&quot;10px&quot;&gt;
-
-    &lt;TextView id=&quot;@+id/label&quot; 
-              android:layout_width=&quot;fill_parent&quot; 
-              android:layout_height=&quot;wrap_content&quot; 
-              android:text=&quot;Type here:&quot;/&gt;
-
-    &lt;EditText id=&quot;@+id/entry&quot; 
-              android:layout_width=&quot;fill_parent&quot; 
-              android:layout_height=&quot;wrap_content&quot; 
-              android:background=&quot;@android:drawable/editbox_background&quot;
-              android:layout_below=&quot;@id/label&quot;/&gt;
-  
-    &lt;Button id=&quot;@+id/ok&quot; 
-            android:layout_width=&quot;wrap_content&quot; 
-            android:layout_height=&quot;wrap_content&quot; 
-            android:layout_below=&quot;@id/entry&quot;
-            android:layout_alignParentRight=&quot;true&quot;
-            android:layout_marginLeft=&quot;10px&quot;
-            android:text=&quot;OK&quot; /&gt;
-
-    &lt;Button android:layout_width=&quot;wrap_content&quot; 
-            android:layout_height=&quot;wrap_content&quot;
-            android:layout_toLeftOf=&quot;@id/ok&quot;
-            android:layout_alignTop=&quot;@id/ok&quot;
-            android:text=&quot;Cancel&quot; /&gt;
-&lt;/RelativeLayout&gt;</pre></td>
-        <td><img src="{@docRoot}images/designing_ui_layout_example.png" alt="Screen shot showing how this layout XML file is rendered."  /></td>
-    </tr>
-</table>
-
-
-<h2 id="LoadingTheResource">Loading the XML Resource</h2>
-<p>Loading the compiled layout resource is very easy, and done with a single
-call in the activity's <code>onCreate()</code> method, as shown here:</p>
-
-<pre>
-protected void onCreate(Bundle savedInstanceState)
-{
-   // Be sure to call the super class.
-   super.onCreate(savedInstanceState);
-
-   // Load the compiled layout resource into the window's
-   // default ViewGroup.
-   // The source file is res/layout/hello_activity.xml
-    setContentView(R.layout.hello_activity);
-  
-   // Retrieve any important stored values.
-   restoreValues(savedInstanceState);
-} </pre>
-
-<h2 id="Position">Position</h2>
-   <p>
-   The geometry of a view is that of a rectangle. A view has a location,
-   expressed as a pair of <em>left</em> and <em>top</em> coordinates, and
-   two dimensions, expressed as a width and a height. The unit for location
-   and dimensions is the pixel.
-   </p>
-  
-   <p>
-   It is possible to retrieve the location of a view by invoking the methods
-   {@link android.view.View#getLeft()} and {@link android.view.View#getTop()}. The former returns the left, or X,
-   coordinate of the rectangle representing the view. The latter returns the
-   top, or Y, coordinate of the rectangle representing the view. These methods
-   both return the location of the view relative to its parent. For instance,
-   when getLeft() returns 20, that means the view is located 20 pixels to the
-   right of the left edge of its direct parent.
-   </p>
-  
-   <p>
-   In addition, several convenience methods are offered to avoid unnecessary
-   computations, namely {@link android.view.View#getRight()} and {@link android.view.View#getBottom()}.
-   These methods return the coordinates of the right and bottom edges of the
-   rectangle representing the view. For instance, calling {@link android.view.View#getRight()}
-   is similar to the following computation: <code>getLeft() + getWidth()</code>.
-   </p>
-   
-
-<h2 id="SizePaddingMargins">Size, Padding and Margins</h2>
-   <p>
-   The size of a view is expressed with a width and a height. A view actually
-   possess two pairs of width and height values.
-   </p>
-  
-   <p>
-   The first pair is known as <em>measured width</em> and
-   <em>measured height</em>. These dimensions define how big a view wants to be
-   within its parent. The
-   measured dimensions can be obtained by calling {@link android.view.View#getMeasuredWidth()}
-   and {@link android.view.View#getMeasuredHeight()}.
-   </p>
-  
-   <p>
-   The second pair is simply known as <em>width</em> and <em>height</em>, or
-   sometimes <em>drawing width</em> and <em>drawing height</em>. These
-   dimensions define the actual size of the view on screen, at drawing time and
-   after layout. These values may, but do not have to, be different from the
-   measured width and height. The width and height can be obtained by calling
-   {@link android.view.View#getWidth()} and {@link android.view.View#getHeight()}. 
-   </p>
-  
-   <p>
-   To measure its dimensions, a view takes into account its padding. The padding
-   is expressed in pixels for the left, top, right and bottom parts of the view.
-   Padding can be used to offset the content of the view by a specific amount of
-   pixels. For instance, a left padding of 2 will push the view's content by
-   2 pixels to the right of the left edge. Padding can be set using the
-   {@link android.view.View#setPadding(int, int, int, int)} method and queried by calling
-   {@link android.view.View#getPaddingLeft()}, {@link android.view.View#getPaddingTop()},
-   {@link android.view.View#getPaddingRight()} and {@link android.view.View#getPaddingBottom()}.  
-   </p>
-  
-   <p>
-   Even though a view can define a padding, it does not provide any support for
-   margins. However, view groups provide such a support. Refer to
-   {@link android.view.ViewGroup} and
-   {@link android.view.ViewGroup.MarginLayoutParams} for further information.
-   </p>
-   
\ No newline at end of file
diff --git a/docs/html/guide/topics/views/how-android-draws.jd b/docs/html/guide/topics/views/how-android-draws.jd
deleted file mode 100644
index f497db7..0000000
--- a/docs/html/guide/topics/views/how-android-draws.jd
+++ /dev/null
@@ -1,90 +0,0 @@
-page.title=How Android Draws Views
-parent.title=Views and Layout
-parent.link=index.html
-@jd:body
-
-
-<p>As mentioned in the introduction to <a href="index.html">Views and Layout</a>, 
-drawing begins when the Activity requests the root node of the layout to measure and 
-draw the layout tree. Drawing is handled by walking the tree and rendering each view that
-   intersects the invalid region. In turn, each view group is responsible for requesting
-each of its children to be drawn and each view is responsible for drawing itself.
- Because the tree is traversed in-order,
-   this means that parents will be drawn before (i.e., behind) their children, with
-   siblings drawn in the order they appear in the tree.
-   </p>
-
-<div class="sidebox">
-  <p>The framework will not draw views that are not in the invalid region, and also 
-   will take care of drawing the views background for you.</p>
-   <p>You can force a view to draw, by calling {@link android.view.View#invalidate()}.
-   </p>
-</div>
-
-<p>
-   Drawing the layout is a two pass process: a measure pass and a layout pass. The measuring
-   pass is implemented in {@link android.view.View#measure(int, int)} and is a top-down traversal
-   of the view tree. Each view pushes dimension specifications down the tree
-   during the recursion. At the end of the measure pass, every view has stored
-   its measurements. The second pass happens in
-   {@link android.view.View#layout(int,int,int,int)} and is also top-down. During
-   this pass each parent is responsible for positioning all of its children
-   using the sizes computed in the measure pass.
-   </p>
-   
-   <p>
-   When a view's measure() method returns, its {@link android.view.View#getMeasuredWidth()} and
-   {@link android.view.View#getMeasuredHeight()} values must be set, along with those for all of
-   that view's descendants. A view's measured width and measured height values
-   must respect the constraints imposed by the view's parents. This guarantees
-   that at the end of the measure pass, all parents accept all of their
-   children's measurements. A parent view may call measure() more than once on
-   its children. For example, the parent may measure each child once with
-   unspecified dimensions to find out how big they want to be, then call
-   measure() on them again with actual numbers if the sum of all the children's
-   unconstrained sizes is too big or too small (i.e., if the children don't agree among themselves
-  as to how much space they each get, the parent will intervene and set the rules on the second pass).
-   </p>
-   
-   <div class="sidebox"><p>
-   To intiate a layout, call {@link android.view.View#requestLayout}. This method is typically
-   called by a view on itself when it believes that is can no longer fit within
-   its current bounds.</p>
-   </div>
-
-   <p>
-   The measure pass uses two classes to communicate dimensions. The
-   {@link android.view.View.MeasureSpec} class is used by views to tell their parents how they
-   want to be measured and positioned. The base LayoutParams class just
-   describes how big the view wants to be for both width and height. For each
-   dimension, it can specify one of:</p>
-   <ul>
-    <li> an exact number
-    <li>FILL_PARENT, which means the view wants to be as big as its parent
-    (minus padding)</li>
-    <li> WRAP_CONTENT, which means that the view wants to be just big enough to
-    enclose its content (plus padding).</li>
-   </ul>
-  <p>There are subclasses of LayoutParams for different subclasses of ViewGroup.
-   For example, AbsoluteLayout has its own subclass of LayoutParams which adds
-   an X and Y value.
-   </p>
-   
-   <p>
-   MeasureSpecs are used to push requirements down the tree from parent to
-   child. A MeasureSpec can be in one of three modes:</p>
-   <ul>
-    <li>UNSPECIFIED: This is used by a parent to determine the desired dimension
-    of a child view. For example, a LinearLayout may call measure() on its child
-    with the height set to UNSPECIFIED and a width of EXACTLY 240 to find out how
-    tall the child view wants to be given a width of 240 pixels.</li>
-    <li>EXACTLY: This is used by the parent to impose an exact size on the
-    child. The child must use this size, and guarantee that all of its
-    descendants will fit within this size.</li>
-    <li>AT_MOST: This is used by the parent to impose a maximum size on the
-    child. The child must gurantee that it and all of its descendants will fit
-    within this size.</li>
-   </ul>
-   
-
-
diff --git a/docs/html/guide/topics/views/index.jd b/docs/html/guide/topics/views/index.jd
deleted file mode 100644
index a246ba1..0000000
--- a/docs/html/guide/topics/views/index.jd
+++ /dev/null
@@ -1,216 +0,0 @@
-page.title=Views and Layout
-@jd:body
-
-<div id="qv-wrapper">
-<div id="qv">
-
-  <h2>Key classes and packages</h2>
-  <ol>
-    <li>{@link android.view.View}</li>
-    <li>{@link android.view.ViewGroup}</li>
-    <li>{@link android.widget}</li>
-  </ol>
-
-  <h2>In this document</h2>
-  <ol>
-    <li><a href="#ViewHierarchy">View Hierarchy</a></li>
-    <li><a href="#Layout">Layout</a></li>
-    <li><a href="#Widgets">Widgets</a></li>
-    <li><a href="#Events">Events</a></li>
-    <li><a href="#Adapters">Adapters</a></li>
-    <li><a href="#StylesAndThemes">Styles and Themes</a></li>
-  </ol>
-</div>
-</div>
-
-<p>In an Android application, a user interface is built using {@link android.view.View} and 
-{@link android.view.ViewGroup} objects. There are many types of views and view groups, each of which 
-is a descendant of the {@link android.view.View} class.</p>
-
-<p>View objects are the basic units of user interface expression on the Android platform. 
-The View class serves as the base for subclasses called "widgets," which offer fully implemented
-UI objects, like text fields and buttons. The ViewGroup class serves as the base for subclasses called "layouts,"
-which offer different kinds of layout architecture, like linear, tabular and relative.</p>
-
-<p>A View object is a data structure whose properties store the layout properties and content for a specific 
-rectangular area of the screen. A View object handles its own measurement, layout, drawing, focus change, 
-scrolling, and key/gesture interactions for the rectangular screen area it represents. </p>
-
-
-<h2 id="ViewHierarchy">View Hierarchy</h2>
-
-<p>On the Android platform, you will define an Activity's UI using a hierarchy of view and view group nodes, 
-as shown in the diagram below. This hierarchy tree can be as simple or complex as you need it to be, and you 
-can build it up using Android's set of predefined widgets and layouts, or with custom view types that you 
-create yourself.</p>
-
-<img src="{@docRoot}images/viewgroup.png" alt="" width="312" height="211" align="center"/>
-
-<p>The Android system will notify your Activity when it becomes active and receives focus.
-In order to attach the view hierarchy tree to the screen for rendering, your Activity must call its 
-<code>setContentView()</code> method and pass a reference to the root node object. The Android system
-receives this reference so that it can invalidate, measure, and draw the tree. The root node requests 
-that its child nodes draw themselves &mdash; in turn, each view group node is responsible for 
-calling <code>Draw()</code> on each of its own child views, so that each child view can render itself. 
-The children may request a size and location within the parent, but the parent object has the final 
-decision on where how big each child can be. To learn more about how a view group and its children are measured
-and drawn, read <a href="how-android-draws.html">How Android Draws Views</a>.</p>
-
-
-<h2 id="Layout">Layout</h2>
-
-<p>The most common way to define your layout and express the view hierarchy is with an XML layout file.
-XML offers a human-readable structure for the layout, much like HTML. Each element in XML is 
-(usually a descendant of) either a View or ViewGroup object. View objects are leaves in the tree, 
-ViewGroup objects are branches in the tree. The name of an XML element
-is the respective class object name. So a <code>&lt;TextView></code> element creates
-a {@link android.widget.TextView} widget in your UI, and a <code>&lt;LinearLayout></code> element creates
-a {@link android.widget.LinearLayout} layout branch in the tree. To learn more about how to write your layout in XML, 
-read <a href="declaring-layout.html">Declaring and Querying Layout</a>.
-
-<div class="sidebox-wrapper">
-<div class="sidebox">
-  <p><b>Tip:</b> You can also draw new views and view groups from within your code, 
-  by adding new View and ViewGroup objects to an
-  existing ViewGroup (specifically, you'll use the <code>addView()</code> methods to dynamically insert new views). 
-  To see how to add views in your code, see the {@link android.view.ViewGroup} reference.</p>
-</div>
-</div>
-
-<p>There are a variety of ways in which you can layout your views, using different view groups.
-Some pre-defined view groups offered by Android (called layouts) include LinearLayout, RelativeLayout, AbsoluteLayout,
-TableLayout, GridLayout and others. Each offers a different mechanisms for arranging child views
-among each other. 
-To learn more about how to use some of these view groups for your layout, 
-read <a href="layout.html">Common Layout Objects</a>.
-
-<h3 id="IDs">IDs</h3>
-
-<p>Views may have an integer ID associated with them. The ID is written as a string, but once the application is
-compiled, it will be referenced as an integer.
-These IDs are typically assigned in the layout XML file as an attribute of the view,
-and are used to uniquely identify a view within the tree. The usual syntax for an ID, inside an XML tag is:</p>
-<pre>id="&#64;+id/my_button"</pre>
-<p>The  at-symbol (&#64;) at the beginning of the string indicates that the XML parser should parse and expand the rest
-of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must
-be created and added to our resources (in the <code>R.java</code> file). There are a number of other ID resources that
-are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol,
-but must add the <code>android</code> package namespace, like so:</p>
-<pre>id="&#64;android:id/empty"</pre>
-<p>With the <code>android</code> package namespace in place, we're now referencing an ID from the <code>android.R</code>
-resources class, rather than the local resources class.</p>
-
-<p>In order to create views and reference them from the application, a common pattern is to:</p>
-<ol>
-  <li>Define a view/widget in the layout file and assign it a unique ID. E.g.:
-<pre>
-&lt;Button id="&#64;+id/my_button"
-  android:layout_width="wrap_content"
-  android:layout_height="wrap_content"
-  android:text="&#64;string/my_button_text"/>
-</pre>
-  </li>
-  <li>Then create an instance of the view object and capture it from the layout 
-(typically in the <code>onCreate()</code> method).
-<pre>
-Button myButton = (Button) findViewById(R.id.my_button);
-</pre>
-  </li>
-</ol>
-<p>Defining IDs for view objects is important when creating a {@link android.widget.RelativeLayout}.
-In a relative layout, sibling views can define their layout relative to another sibling view, 
-which is referenced by the unique ID.</p>
-<p>An ID need not be unique throughout the entire tree, but it should be
-unique within the part of the tree you are searching (which may often be the entire tree, so it's best 
-to be completely unique when possible).</p>
-
-
-<h3>Layout Parameters</h3>
-
-<p>Every ViewGroup class implements a nested class that extends {@link
-android.view.ViewGroup.LayoutParams}. This subclass
-contains property types that define each child view's size and position, as
-appropriate for that type of view group. As you can see in the figure below, the parent
-view group defines layout parameters for each child view (including the child view group).</p>
-
-<img src="{@docRoot}images/layoutparams.png" alt="" height="300" align="center"/>
-
-<p>Note that every LayoutParams subclass has its own syntax for setting
-values. Each child element must define LayoutParams that are appropriate for its parent, 
-though it may also define different LayoutParams for its own children. </p>
-
-<p>All view groups include a width and height, and each view is required to define them. 
-Many LayoutParams also include optional margins and
-borders. You can specify width and height with exact measurements, though you probably won't want
-to do this often. More often, you will tell your view to size itself either to
-the dimensions required by its content, or to become as big as its parent view group
-will allow (with the <var>wrap_content</var> and <var>fill_parent</var> values, respectively).
-The accepted measurement types are defined in the 
-<a href="{@docRoot}guide/topics/resources/available-resources.html#dimension">Available Resources</a> document.</p>
-
-<h2 id="Widgets">Widgets</h2>
-
-
-<p>The View class also serves as a base class for <em>widgets</em> &mdash; a set of fully implemented 
-View subclasses that draw interactive screen elements, so you can quickly build your UI. 
-Android provides a vast collection of widgets for special actions.
-Some of them are basic interaction elements like buttons and text fields, while others are more complex, 
-like a date picker or zoom controls.</p>
-<p>For a list of all built-in widgets, see the {@link android.widget widget}.</p>
-
-<p>You're not limited to the kinds of views, layouts and widgets provided by the Android platform. If you'd
-like to do something more customized, create your own widget or layout, you can.
-Read more in <a href="custom-components.html">Building Custom Components</a>.
-
-
-<h2 id="Events">Events</h2>
-
-<p>Once you've designed and built your UI layout, you need to handle the user interaction with it.
-Obviously, the views that you've implemented in the layout are the 
-receptors for such interaction events. Because the View class is built to listen for most interaction events,
-receiving and handling them is pretty straigh-forward. When you want to perform an action upon an event, 
-you need to do one of two things:</p>
-<ul>
-  <li>Override an existing callback method for the view you've implemented, which will be called when something
-like a touch or focus event occurs.</li>
-  <li>Define a listener interface, like {@link android.view.View.OnClickListener} (for handling "clicks" on a View). 
-You must then define the listener for your view with the respective <code>set...Listener()</code>
-method (such as {@link android.view.View#setOnClickListener(android.view.View.OnClickListener) setOnCLickListener()}).</li>
-</ul>
-
-<p>To learn more about handling events and writing your own listeners, 
-read <a href="ui-events.html">Handling UI Events</a>.</p>
-
-
-<h2 id="Adapters">Adapters</h2>
-
-<p>Sometimes you'll want to populate a view group with some information that can't be hard-coded, instead, 
-you want to bind your view to an external source of data. To do this, you use an AdapterView as
-your view group and each child View is initialized and populated with data from the Adapter.</p>
-<p>The AdapterView object is an implementation of ViewGroup that determines its child views
-based on a given Adapter object. The Adapter acts like a courier between your data source (perhaps an
-array of external strings) and the AdapterView, which displays it. There are several implementations
-of the Adapter class, for specific tasks, such as the CursorAdapter for reading database data from a Cursor,
-or an ArrayAdapter for reading from an arbitrary array.</p>
-<p>To learn more about using an Adapter to populate your views, read 
-<a href="binding.html">Binding to Data with AdapterView</a>.</p>
-
-
-<h2 id="StylesAndThemes">Styles and Themes</h2>
-
-<p>Perhaps you're not satisfied with the look of the standard widgets. To revise them, you can create some 
-of your own styles and themes.</p>
-
-<ul>
-  <li>A style is a set of one or more formatting attributes that you can apply as a unit to individual elements 
-in your layout. For example, you could define a style that specifies a certain text size and color, then 
-apply it to only specific View elements.</li>
-  <li>A theme is a set of one or more formatting attributes that you can apply as a unit to all activities in 
-an application, or just a single activity. For example, you could define a theme that sets specific colors for 
-the window frame and the panel background, and sets text sizes and colors for menus. This theme can then be 
-applied to specific activities or the entire application.</li>
-</ul>
-
-<p>Styles and themes are resources. Android provides some default style and theme resources that you can use, 
-or you can declare your own custom style and theme resources. Learn more about using styles and themes in the
-<a href="themes.html">Applying Styles and Themes</a> document.</p>
diff --git a/docs/html/guide/topics/views/ui-events.jd b/docs/html/guide/topics/views/ui-events.jd
deleted file mode 100644
index 96136f8..0000000
--- a/docs/html/guide/topics/views/ui-events.jd
+++ /dev/null
@@ -1,113 +0,0 @@
-page.title=Handling UI Events
-parent.title=Views and Layout
-parent.link=index.html
-@jd:body
-
-<div id="qv-wrapper">
-<div id="qv">
-  <h2>In this document</h2>
-  <ol>
-    <li><a href="#TouchMode">Touch Mode</a></li>
-    <li><a href="#Scrolling">Scrolling</a></li>
-    <li><a href="#EventCycle">Event Cycle</a></li>
-  </ol>
-
-  <h2>See also</h2>
-  <ol>
-    <li><a href="{@docRoot}guide/tutorials/views/hello-formstuff.html">Hello Form Stuff tutorial</a></li>
-  </ol>
-</div>
-</div>
-
-<p>Many Android classes declare callback methods for handling relevant UI events such as keypresses, 
-touch events, focus changes, and so on. For example, {@link android.app.Activity Activity} provides 
-the methods <code>onKeyDown()</code> and <code>onKeyUp()</code> and {@link android.widget.TextView TextView} 
-provides <code>onFocusChanged()</code>. </p>
-
-<p>In most cases, you can handle events just by overriding the appropriate handler methods. 
-When an event is received, the Android system calls your handler method with the event data.</p>
-
-<p>However, some classes do not declare handler methods for specific events. For example, 
-{@link android.widget.Button} does not declare an <code>onClick()</code> handler method. So, to handle a click event, 
-you need to create an anonymous class to act as a listener for the event, then register the listener with the 
-target class object (via the appropriate <code>set...Listener()</code> method). The example below shows how to set 
-up a handler for click events in a Button object. </p>
-
-</p>
-<pre>public class ExampleSendResult extends Activity
-{
-    protected void onCreate(Bundle savedValues)
-    {
-        ...
-
-        // Capture our button from layout and listen for clicks.
-        Button button = (Button)findViewById(R.id.corky);
-        button.setOnClickListener(mCorkyListener);
-    }
-
-    // Create an anonymous class to act as a button click listener.
-    private OnClickListener mCorkyListener = new OnClickListener()
-    {
-        public void onClick(View v)
-        {
-          //do something when the button is clicked
-        }
-    };
-}
-</pre>
-
-
-<h2 id="TouchMode">Touch Mode</h2>
-   <p>
-   When a user is navigating a user interface via directional keys such as a D-pad, it is
-   necessary to give focus to actionable items such as buttons so the user can see
-   what will take input.  If the device has touch capabilities, however, and the user
-   begins interacting with the interface by touching it, it is no longer necessary to
-   always highlight, or give focus to, a particular view.  Thus, there is a mode
-   for interaction named "touch mode."
-   </p>
-   <p>
-   For a touch-capable device, once the user touches the screen, the device
-   will enter touch mode.  From this point onward, only views for which
-   {@link android.view.View#isFocusableInTouchMode} is true will be focusable, such as text editing widgets.
-   Other views that are touchable, like buttons, will not take focus when touched; they will
-   simply fire their on-click listeners when pressed.
-   </p>
-   <p>
-   Any time a user hits a directional key, such as a D-pad direction, the view device will
-   exit touch mode, and find a view to take focus, so that the user may resume interacting
-   with the user interface without touching the screen.
-   </p>
-   <p>
-   The touch mode state is maintained across {@link android.app.Activity}s. To query the current state, you can call
-   {@link android.view.View#isInTouchMode} to see whether the device is currently in touch mode.
-   </p>
-  
-
-<h2 id="Scrolling">Scrolling</h2>
-   <p>
-   The framework provides basic support for views that wish to internally
-   scroll their content. This includes keeping track of the X and Y scroll
-   offset as well as mechanisms for drawing scrollbars. See
-   {@link android.view.View#scrollBy(int, int)}, {@link android.view.View#scrollTo(int, int)} for more details.
-   </p>
-
-<h2 is="EventCycle">Event Cycle</h2>
-   <p>The basic cycle of a view is as follows:</p>
-   <ol>
-    <li>An event comes in and is dispatched to the appropriate view. The view
-    handles the event and notifies any listeners.</li>
-    <li>If, in the course of processing the event, the view's bounds may need
-    to be changed, the view will call {@link android.view.View#requestLayout()}.</li>
-    <li>Similarly, if in the course of processing the event the view's appearance
-    may need to be changed, the view will call {@link android.view.View#invalidate()}.</li>
-    <li>If either {@link android.view.View#requestLayout()} or {@link android.view.View#invalidate()} were called,
-    the framework will take care of measuring, laying out, and drawing the tree
-    as appropriate.</li>
-   </ol>
-   
-   <p class="note"><strong>Note:</strong> The entire view tree is single threaded. You must always be on
-   the UI thread when calling any method on any view.
-   If you are doing work on other threads and want to update the state of a view
-   from that thread, you should use a {@link android.os.Handler}.
-   </p>
\ No newline at end of file
diff --git a/docs/html/guide/tutorials/hello-world.jd b/docs/html/guide/tutorials/hello-world.jd
index c993048..bbc4f77 100644
--- a/docs/html/guide/tutorials/hello-world.jd
+++ b/docs/html/guide/tutorials/hello-world.jd
@@ -330,7 +330,7 @@
 layout approaches produce identical results.</p>
 
 <p>There's a lot more to creating these XML layouts, but that's as far as we'll go
-here. Read the <a href="{@docRoot}guide/topics/views/index.html">Views and Layout</a> documentation for more 
+here. Read the <a href="{@docRoot}guide/topics/ui/index.html">User Interface</a> documentation for more 
 information on creating layouts.</p>
 
 <div class="special">
diff --git a/docs/html/guide/tutorials/notepad/codelab/NotepadCodeLab.zip b/docs/html/guide/tutorials/notepad/codelab/NotepadCodeLab.zip
old mode 100755
new mode 100644
index 86f5e9d..c7dd989
--- a/docs/html/guide/tutorials/notepad/codelab/NotepadCodeLab.zip
+++ b/docs/html/guide/tutorials/notepad/codelab/NotepadCodeLab.zip
Binary files differ
diff --git a/docs/html/guide/tutorials/notepad/notepad-ex1.jd b/docs/html/guide/tutorials/notepad/notepad-ex1.jd
index 45ed97e..b7f42bf 100644
--- a/docs/html/guide/tutorials/notepad/notepad-ex1.jd
+++ b/docs/html/guide/tutorials/notepad/notepad-ex1.jd
@@ -1,4 +1,6 @@
 page.title=Notepad Exercise 1
+parent.title=Notepad Tutorial
+parent.link=index.html
 @jd:body
 
 
@@ -584,5 +586,4 @@
 
 <p>Once you are ready, move on to <a href="notepad-ex2.html">Tutorial
 Exercise 2</a> to add the ability to create, edit and delete notes.</p>
-<p><a href="index.html">Back to the Tutorial main page...</a></p>
 
diff --git a/docs/html/guide/tutorials/notepad/notepad-ex2.jd b/docs/html/guide/tutorials/notepad/notepad-ex2.jd
index b4608fb..3b8fa0b 100644
--- a/docs/html/guide/tutorials/notepad/notepad-ex2.jd
+++ b/docs/html/guide/tutorials/notepad/notepad-ex2.jd
@@ -1,9 +1,12 @@
 page.title=Notepad Exercise 2
+parent.title=Notepad Tutorial
+parent.link=index.html
 @jd:body
 
 
 <p><em>In this exercise, you will add a second Activity to your notepad application, to let the user
-create, edit, and delete notes. The new Activity assumes responsibility for creating new notes by
+create and edit notes. You will also allow the user to delete existing notes through a context menu. 
+The new Activity assumes responsibility for creating new notes by
 collecting user input and packing it into a return Bundle provided by the intent. This exercise
 demonstrates:</em></p>
 <ul>
@@ -11,6 +14,7 @@
 <li><em>Invoking another Activity asynchronously using <code>startActivityForResult()</code></em></li>
 <li><em>Passing data between Activity in Bundle objects</em></li>
 <li><em>How to use a more advanced screen layout</em></li>
+<li><em>How to create a context menu</em></li>
 </ul>
 
 <div style="float:right;white-space:nowrap">
@@ -51,7 +55,8 @@
     </li>
     <li>
       There are also a couple of new overridden methods
-      (<code>onListItemClick()</code> and <code>onActivityResult()</code>)
+      (<code>onCreateContextMenu()</code>, <code>onContextItemSelected()</code>, 
+      <code>onListItemClick()</code> and <code>onActivityResult()</code>)
       which we will be filling in below.
     </li>
 </ul>
@@ -59,59 +64,62 @@
 
 <h2>Step 2</h2>
 
-	<p>Add an entry to the menu for deleting a note:</p>
+<div class="sidebox">
+<p>Context menus should always be used when performing actions upon specific elements in the UI.
+When you register a View to a context menu, the context menu is revealed by performing a "long-click"
+on the UI component (press and hold the touchscreen or highlight and hold down the selection key for about two seconds).</p>
+</div>
+
+<p>First, let's create the context menu that will allow users to delete individual notes.
+Open the Notepadv2 class.</p>
+
 <ol>
+    <li>In order for each list item in the ListView to register for the context menu, we call
+    <code>registerForContextMenu()</code> and pass it our ListView. So, at the very end of 
+    the <code>onCreate()</code> method add this line:
+    <pre>registerForContextMenu(getListView());</pre>
+    <p>Because our Activity extends the ListActivity class, <code>getListView()</code> will return us
+    the local ListView object for the Activity. Now, each list item in this ListView will activate the
+    context menu.
     <li>
-      In the <code>onCreateOptionsMenu()</code> method, add a new line:
-      <pre>menu.add(0, DELETE_ID, 0, R.string.menu_delete);</pre>
-    </li>
-    <li>
-      The whole method should now look like this:<br>
+      Now fill in the <code>onCreateContextMenu()</code> method. This callback is similar to the other
+    menu callback used for the options menu. Here, we add just one line, which will add a menu item
+    to delete a note. Call <code>menu.add()</code> like so:
       <pre>
-&#64;Override
-public boolean onCreateOptionsMenu(Menu menu) {
-    super.onCreateOptionsMenu(menu);
-    menu.add(0, INSERT_ID, 0, R.string.menu_insert);
+public boolean onCreateContextMenu(Menu menu, View v
+        ContextMenuInfo menuInfo) {
+    super.onCreateContextMenu(menu, v, menuInfo);
     menu.add(0, DELETE_ID, 0, R.string.menu_delete);
-    return true;
 }</pre>
+    <p>The <code>onCreateContextMenu()</code> callback some passes other information in addition to the Menu object, 
+    such as the View that has been triggered for the menu and
+    an extra object that may contain additional information about the object selected. However, we don't care about
+    these here, because we only have one kind of object in the Activity that uses context menus. In the next
+    step, we'll handle the menu item selection.</p>
     </li>
 </ol>
 
 <h2>Step 3</h2>
-    <p>In the <code>onMenuItemSelected()</code> method, add a new case for 
-    <code>DELETE_ID</code>:</p>
-    <pre>
-mDbHelper.deleteNote(getListView().getSelectedItemId());
-fillData();
-return true;</pre>
-
-  <ol>
-    <li>
-      Here, we use the <code>deleteNote</code> method to remove the note specified by ID.
-      In order to get the ID, we call <code>getListView().getSelectedItemId()</code>.
-    </li>
-    <li>
-      Then we fill the data to keep everything up to date.
-    </li>
-   </ol>
-    <p>
-      The whole method should now look like this:</p>
-      <pre>
-&#64;Override
-public boolean onMenuItemSelected(int featureId, MenuItem item) {
+  <p>Now that the we've registered our ListView for a context menu and defined our context menu item, we need
+  to handle the callback when it is selected. For this, we need to identify the list ID of the
+  selected item, then delete it. So fill in the 
+  <code>onContextItemSelected()</code> method like this:</p>
+<pre>
+public boolean onContextItemSelected(MenuItem item) {
     switch(item.getItemId()) {
-    case INSERT_ID:
-        createNote();
-        return true;
     case DELETE_ID:
-        mDbHelper.deleteNote(getListView().getSelectedItemId());
+        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
+        mDbHelper.deleteNote(info.id);
         fillData();
         return true;
     }
-       
-    return super.onMenuItemSelected(featureId, item);
+    return super.onContextItemSelected(item);
 }</pre>
+<p>Here, we retrieve the {@link android.widget.AdapterView.AdapterContextMenuInfo AdapterContextMenuInfo}
+with {@link android.view.MenuItem#getMenuInfo()}. The <var>id</var> field of this object tells us
+the position of the item in the ListView. We then pass this to the <code>deleteNote()</code>
+method of our NotesDbAdapter and the note is deleted. That's it for the context menu &mdash; notes
+can now be deleted.</p>
 
 <h2 style="clear:right;">Step 4</h2>
 <div class="sidebox" style="border:2px solid #FFFFDD;float:right;
@@ -294,8 +302,8 @@
     but that doesn't mean it is even close to the kind of sophistication you will be likely to want
     in real Android applications.</p>
     <p style="padding-left:.5em;font-size:12px;margin:0; padding:.0em .5em .5em 1em;">Creating a
-    good UI is part art and part science, and the rest is work. Mastering <a
-    href="{@docRoot}guide/topics/views/declaring-layout.html">Android layout</a> is an essential part of creating
+    good UI is part art and part science, and the rest is work. Mastery of <a
+    href="{@docRoot}guide/topics/ui/declaring-layout.html">Declaring Layout</a> is an essential part of creating
     a good looking Android application.</p>
     <p style="padding-left:.5em;font-size:12px;margin:0; 
      padding:.0em .5em .5em 1em;">Take a look at the 
@@ -570,7 +578,7 @@
     receive, and more. </p>
     <p style="padding-left:.5em;font-size:12px;margin:0; 
      padding:.0em .5em .5em 1em;">For more information, see the reference document 
-    <a href="{@docRoot}guide/topics/manifest/manifest.html">AndroidManifest.xml</a></p>
+    <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml File</a></p>
   </div>  
 
 <p>Finally, the new Activity has to be defined in the manifest file:</p>
@@ -636,5 +644,4 @@
 Exercise 3</a> where you will fix the problems with the back button and lost
 edits by introducing a proper life cycle into the NoteEdit Activity.</p>
 
-<p><a href="index.html">Back to the Tutorial main page...</a>.</p>
 
diff --git a/docs/html/guide/tutorials/notepad/notepad-ex3.jd b/docs/html/guide/tutorials/notepad/notepad-ex3.jd
index a2eaa48..8737280 100644
--- a/docs/html/guide/tutorials/notepad/notepad-ex3.jd
+++ b/docs/html/guide/tutorials/notepad/notepad-ex3.jd
@@ -1,4 +1,6 @@
 page.title=Notepad Exercise 3
+parent.title=Notepad Tutorial
+parent.link=index.html
 @jd:body
 
 
@@ -354,4 +356,3 @@
 When you are ready, move on to the <a href="notepad-extra-credit.html">Tutorial
 Extra Credit</a> exercise, where you can use the Eclipse debugger to
 examine the life-cycle events as they happen.</p>
-<p><a href="index.html">Back to the Tutorial main page...</a></p>
diff --git a/docs/html/guide/tutorials/notepad/notepad-extra-credit.jd b/docs/html/guide/tutorials/notepad/notepad-extra-credit.jd
index f64e90e..0d59b56 100644
--- a/docs/html/guide/tutorials/notepad/notepad-extra-credit.jd
+++ b/docs/html/guide/tutorials/notepad/notepad-extra-credit.jd
@@ -1,4 +1,6 @@
-page.title=Tutorial: Extra Credit
+page.title=Notepad Extra Credit
+parent.title=Notepad Tutorial
+parent.link=index.html
 @jd:body
 
 
@@ -65,6 +67,4 @@
 your application development, but also superb profiling support. You can also
 try using <a href="{@docRoot}guide/developing/tools/traceview.html">Traceview</a> to profile your application. If your application is running too slow, this can help you 
 find the bottlenecks and fix them.</p>
-<p><a href="index.html">Back to the Tutorial main
-page...</a></p>
 
diff --git a/docs/html/guide/tutorials/views/hello-mapview.jd b/docs/html/guide/tutorials/views/hello-mapview.jd
index fcdf056..b0f59de 100644
--- a/docs/html/guide/tutorials/views/hello-mapview.jd
+++ b/docs/html/guide/tutorials/views/hello-mapview.jd
@@ -43,7 +43,7 @@
       The API key is generated using the MD5 fingerprint of your application certificate. For the purposes of 
       this exercise, you should use the fingerprint of your debug certificate (which cannot be used to release
       your application for Android devices, but will work while developing). See how to 
-      <a href="{@docRoot}guide/topics/geo/mapkey.html#getdebugfingerprint">generate a fingerprint from your 
+      <a href="{@docRoot}guide/topics/location/geo/mapkey.html#getdebugfingerprint">generate a fingerprint from your 
       debug certificate</a>, then <a href="http://code.google.com/android/maps-api-signup.html">register the 
       certificate</a> to retieve an API key.
       Insert the API key as the value of the <code>apiKey</code> attribute. If you do not insert a valid
diff --git a/docs/html/guide/tutorials/views/index.jd b/docs/html/guide/tutorials/views/index.jd
index 6a6ac4b..2248c68 100644
--- a/docs/html/guide/tutorials/views/index.jd
+++ b/docs/html/guide/tutorials/views/index.jd
@@ -30,67 +30,67 @@
 <div>
 
 <div class="view">
-<a href="hello-linearlayout.html">LinearLayout<br/>
-<img src="images/hello-linearlayout.png" height="285" width="200" /></a>
+<a href="hello-linearlayout.html">LinearLayout</a><br/>
+<a href="hello-linearlayout.html"><img src="images/hello-linearlayout.png" height="285" width="200" /></a>
 </div>
 <div class="view">
-<a href="hello-relativelayout.html">RelativeLayout<br/>
-<img src="images/hello-relativelayout.png" height="285" width="200" /></a>
+<a href="hello-relativelayout.html">RelativeLayout</a><br/>
+<a href="hello-relativelayout.html"><img src="images/hello-relativelayout.png" height="285" width="200" /></a>
 </div>
 <div class="view">
-<a href="hello-tablelayout.html">TableLayout<br/>
-<img src="images/hello-tablelayout.png" height="285" width="200" /></a>
+<a href="hello-tablelayout.html">TableLayout</a><br/>
+<a href="hello-tablelayout.html"><img src="images/hello-tablelayout.png" height="285" width="200" /></a>
 </div>
 
 <div class="view">
-<a href="hello-datepicker.html">DatePicker<br/>
-<img src="images/hello-datepicker.png" height="285" width="200" /></a>
+<a href="hello-datepicker.html">DatePicker</a><br/>
+<a href="hello-datepicker.html"><img src="images/hello-datepicker.png" height="285" width="200" /></a>
 </div>
 
 <div class="view">
-<a href="hello-timepicker.html">TimePicker<br/>
-<img src="images/hello-timepicker.png" height="285" width="200" /></a>
+<a href="hello-timepicker.html">TimePicker</a><br/>
+<a href="hello-timepicker.html"><img src="images/hello-timepicker.png" height="285" width="200" /></a>
 </div>
 <div class="view">
-<a href="hello-formstuff.html">Form Stuff<br/>
-<img src="images/hello-formstuff.png" height="285" width="200" /></a>
+<a href="hello-formstuff.html">Form Stuff</a><br/>
+<a href="hello-formstuff.html"><img src="images/hello-formstuff.png" height="285" width="200" /></a>
 </div>
 <div class="view">
-<a href="hello-spinner.html">Spinner<br/>
-<img src="images/hello-spinner.png" height="285" width="200" /></a>
+<a href="hello-spinner.html">Spinner</a><br/>
+<a href="hello-spinner.html"><img src="images/hello-spinner.png" height="285" width="200" /></a>
 </div>
 
 <div class="view">
-<a href="hello-autocomplete.html">AutoComplete<br/>
-<img src="images/hello-autocomplete.png" height="285" width="200" /></a>
+<a href="hello-autocomplete.html">AutoComplete</a><br/>
+<a href="hello-autocomplete.html"><img src="images/hello-autocomplete.png" height="285" width="200" /></a>
 </div>
 <div class="view">
-<a href="hello-listview.html">ListView<br/>
-<img src="images/hello-listview.png" height="285" width="200" /></a>
+<a href="hello-listview.html">ListView</a><br/>
+<a href="hello-listview.html"><img src="images/hello-listview.png" height="285" width="200" /></a>
 </div>
 <div class="view">
-<a href="hello-gridview.html">GridView<br/>
-<img src="images/hello-gridview.png" height="285" width="200" /></a>
+<a href="hello-gridview.html">GridView</a><br/>
+<a href="hello-gridview.html"><img src="images/hello-gridview.png" height="285" width="200" /></a>
 </div>
 
 <div class="view">
-<a href="hello-gallery.html">Gallery<br/>
-<img src="images/hello-gallery.png" height="285" width="200" /></a>
+<a href="hello-gallery.html">Gallery</a><br/>
+<a href="hello-gallery.html"><img src="images/hello-gallery.png" height="285" width="200" /></a>
 </div>
 
 <div class="view">
-<a href="hello-tabwidget.html">TabWidget<br/>
-<img src="images/hello-tabwidget.png" height="285" width="200" /></a>
+<a href="hello-tabwidget.html">TabWidget</a><br/>
+<a href="hello-tabwidget.html"><img src="images/hello-tabwidget.png" height="285" width="200" /></a>
 </div>
 
 <div class="view">
-<a href="hello-mapview.html">MapView<br/>
-<img src="images/hello-mapview.png" height="285" width="200" /></a>
+<a href="hello-mapview.html">MapView</a><br/>
+<a href="hello-mapview.html"><img src="images/hello-mapview.png" height="285" width="200" /></a>
 </div>
 
 <div class="view">
-<a href="hello-webview.html">WebView<br/>
-<img src="images/hello-webview.png" height="285" width="200" /></a>
+<a href="hello-webview.html">WebView</a><br/>
+<a href="hello-webview.html"><img src="images/hello-webview.png" height="285" width="200" /></a>
 </div>
 
 <!--
diff --git a/docs/html/images/adc1r1_deck.pdf b/docs/html/images/adc1r1_deck.pdf
deleted file mode 100644
index e76a554..0000000
--- a/docs/html/images/adc1r1_deck.pdf
+++ /dev/null
Binary files differ
diff --git a/docs/html/images/binder_rpc.png b/docs/html/images/binder_rpc.png
new file mode 100644
index 0000000..1021109
--- /dev/null
+++ b/docs/html/images/binder_rpc.png
Binary files differ
diff --git a/docs/html/images/options_menu.png b/docs/html/images/options_menu.png
new file mode 100755
index 0000000..ecb9394
--- /dev/null
+++ b/docs/html/images/options_menu.png
Binary files differ
diff --git a/docs/html/images/radio_buttons.png b/docs/html/images/radio_buttons.png
new file mode 100755
index 0000000..b755e42
--- /dev/null
+++ b/docs/html/images/radio_buttons.png
Binary files differ
diff --git a/docs/html/images/table_layout.png b/docs/html/images/table_layout.png
index bc1a47c..e7fae2d 100644
--- a/docs/html/images/table_layout.png
+++ b/docs/html/images/table_layout.png
Binary files differ
diff --git a/docs/html/index.jd b/docs/html/index.jd
index 05ab987..8db339d 100644
--- a/docs/html/index.jd
+++ b/docs/html/index.jd
@@ -7,14 +7,16 @@
               <div id="mainBodyLeft">			
                     <div id="homeMiddle">
                         <div id="homeTitle">
-                            <div style="float:left;">
-                                <h2>T-Mobile G1 Now Available!</h2>
-                            </div>
-                            <div style="float:right;" align="center">
-                                <a href="http://www.t-mobileg1.com">Learn more &raquo;</a><br />
-                             <!--   <img src="{@docRoot}assets/images/icon_robot.jpg" style="margin:8px 10px 0 10px; clear:both;" /> -->
-                            </div>
+                            <h2>Developer Announcements</h2>
                         </div><!-- end homeTitle -->
+                        <div id="announcement-block">
+                        <!-- total max width is 520px -->
+                            <img src="{@docRoot}assets/images/home/IO-logo.png" alt="Google I/O Developer Conference 2009" width="242px" />
+                            <div id="announcement" style="width:270px">
+                              <p>Google I/O is a two-day developer event that will take place May 27-28 at Moscone Center, San Francisco.</p>
+                              <p><a href="http://code.google.com/events/io/">Learn more &raquo;</a></p>
+                            </div> <!-- end annoucement -->
+                        </div> <!-- end annoucement-block -->
                         <div id="carouselMain">
                             <div id="bulletinImg"></div>
                             <div id="bulletinDesc"></div>
@@ -27,51 +29,32 @@
                                   <!-- populated by buildCarousel() -->
                                 </div>
                             </div><!-- end list-clip -->
-                            <a href="javascript:{}" id="arrow-right" onclick="" class="arrow-right-off"></a>
+                            <a href="javascript:page_right()" id="arrow-right" onclick="" class="arrow-right-on"></a>
                             <div class="clearer"></div>
                         </div><!-- end app-list container -->
                     </div><!-- end homeMiddle -->
 
                     <div style="clear:both">&nbsp;</div>
-
-                    <div id="homeBottom">
-                        <table>
-                            <tr>
-                                <td>
-                                    <br />
-                                    <h2>Featured Developer App: BreadCrumbz</h2>
-                                    <p>Amos Yoffe takes navigation to the next level with BreadCrumbz.</p>
-                                    <p><a href="http://www.bcrumbz.com">Learn more about this developer &raquo;</a></p>
-                                </td>
-                                <td>
-                                    <img src="{@docRoot}assets/images/logo_breadcrumbz.jpg" />
-                                </td>
-                            </tr>
-                        </table>
-                    </div><!-- end homeBottom -->
               </div><!-- end mainBodyLeft -->
 
               <div id="mainBodyRight">
                       <table id="rightColumn">
                               <tr>
-                                      <td class="imageCell"><img src="{@docRoot}assets/images/icon_download.jpg" style="padding:0" /></td>
+                                      <td class="imageCell"><a href="{@docRoot}sdk/index.html"><img src="{@docRoot}assets/images/icon_download.jpg" style="padding:0" /></a></td>
                                       <td>
                                               <h2 class="green">Download</h2>
-                                              <p>Latest SDK</p>
-                                              <p><a href="{@docRoot}sdk/index.html">Download now</a></p>
+                                              <p>The Android SDK has the tools, sample code, and docs you need to create great apps.  </p>
+                                              <p><a href="{@docRoot}sdk/1.1_r1/index.html">Learn more &raquo;</a></p>
                                       </td>
                               </tr>
                               <tr>
                                       <td colspan="2"><div class="seperator">&nbsp;</div></td>
                               </tr>
                               <tr>
-                                      <td class="imageCell"><img src="{@docRoot}assets/images/icon_market.jpg" style="padding:0" /></td>
-                                      <td valign="middle"><br /><h2 class="green">Market</h2></td>
-                              </tr>
-                              <tr>
-                                      <td colspan="2">
-                                              <br />
-                                              <p>Android Market is an open service that will give developers the opportunity to distribute applications to handsets.</p>
+                                      <td class="imageCell"><a href="http://www.android.com/market.html"><img src="{@docRoot}assets/images/icon_market.jpg" style="padding:0" /></a></td>
+                                      <td>
+                                              <h2 class="green">Publish</h2>
+                                              <p>Android Market is an open service that lets you distribute your apps to handsets.</p>
                                               <p><a href="http://www.android.com/market.html">Learn more &raquo;</a></p>
                                       </td>
                               </tr>
@@ -79,16 +62,25 @@
                                       <td colspan="2"><div class="seperator">&nbsp;</div></td>
                               </tr>
                               <tr>
-                                      <td class="imageCell"><img src="{@docRoot}assets/images/icon_contribute.jpg" style="padding:0" /></td>
+                                      <td class="imageCell"><a href="http://source.android.com"><img src="{@docRoot}assets/images/icon_contribute.jpg" style="padding:0" /></a></td>
                                       <td>
                                               <h2 class="green">Contribute</h2>
-                                              <p>Create using our open source codebase and help us keep this project growing.</p>
+                                              <p>Android Open Source Project gives you access to the entire platform source.</p>
                                               <p><a href="http://source.android.com">Learn more &raquo;</a></p>
                                       </td>
                               </tr>
                               <tr>
                                       <td colspan="2"><div class="seperator">&nbsp;</div></td>
                               </tr>
+                              <tr>
+                                      <td class="imageCell"><a href="http://www.youtube.com/user/androiddevelopers"><img src="{@docRoot}assets/images/video-droid.png" style="padding:0" /></a></td>
+                                      <td>
+                                              <h2 class="green">Watch</h2>
+                                              <object width="150" height="140"><param name="movie" value="http://www.youtube.com/v/x1ZZ-R3p_w8&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/x1ZZ-R3p_w8&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="140"></embed></object>
+                                              <p style="margin-top:1em"><a href="http://www.youtube.com/user/androiddevelopers">More Android videos &raquo;</a></p>
+                                      </td>
+                              </tr>
+
                       </table>
               </div>
 	</div>
@@ -125,10 +117,10 @@
     'sdk': {
       'layout':"imgLeft",
       'icon':"sdk-small.png",
-      'name':"SDK 1.0 r1",
+      'name':"SDK 1.1 r1",
       'img':"sdk-large.png",
-      'title':"Android 1.0 SDK r1",
-      'desc': "<p>The first Android 1.0 SDK is available for download. This is the first release guaranteed to operate on the first Android devices. If you want to release an application for Android, you should be developing with this SDK.</p><p><a href='{@docRoot}sdk/index.html'>Download Android 1.0 SDK r1</a></p>"
+      'title':"Android 1.1 SDK r1",
+      'desc': "<p>A new Android SDK is available for download. The new SDK includes minor API changes, new UI localizations, bug fixes and some new application features.</p><p><a href='{@docRoot}sdk/1.1_r1/index.html'>Download Android 1.1 SDK r1</a></p>"
     },
 
     'mapskey': {
@@ -137,7 +129,7 @@
       'name':"Maps API Key",
       'img':"maps-large.png",
       'title':"Maps API Key",
-      'desc':"<p>If you're writing an Android application that uses Google Maps (with MapView), you must register your application to obtain a Maps API Key. Without the key, your maps application will not work on Android devices. Obtaining a key requires just a couple of steps.</p><p><a href='{@docRoot}guide/topics/geo/mapkey.html'>Learn how to get a Maps API Key</a></p>"
+      'desc':"<p>If you're writing an Android application that uses Google Maps (with MapView), you must register your application to obtain a Maps API Key. Without the key, your maps application will not work on Android devices. Obtaining a key requires just a couple of steps.</p><p><a href='{@docRoot}guide/topics/location/geo/mapkey.html'>Learn how to get a Maps API Key</a></p>"
     },
 
     'market': {
@@ -147,6 +139,15 @@
       'img':"market-large.png",
       'title':"",
       'desc': "<p>Android Market helps you get your applications into the hands of users. The beta version of Market is now open and you can begin sharing your applications with users of the first Android-powered phone, the T-Mobile G1.</p><p><a href='http://market.android.com/publish/'>Publish your Android app on Market &raquo;</a></p>"
+    },
+
+    'devphone': {
+      'layout':"imgLeft",
+      'icon':"devphone-small.png",
+      'name':"Dev Phone 1",
+      'img':"devphone-large.png",
+      'title':"Android Dev Phone 1",
+      'desc': "<p>Run and debug your Android applications directly on this device. Modify and rebuild the Android operating system, and flash it onto the phone. The Android Dev Phone 1 is carrier independent, and available for purchase by any developer registered with <a href='http://market.android.com/publish'>Android Market</a>.</p><p><a href='/guide/developing/device.html#dev-phone-1'>Learn more about the Android Dev Phone 1 &raquo;</a></p>"
     }
 
   }
diff --git a/docs/html/license.jd b/docs/html/license.jd
new file mode 100644
index 0000000..39fb3a0
--- /dev/null
+++ b/docs/html/license.jd
@@ -0,0 +1,142 @@
+page.title=Content License		
+@jd:body
+
+<div id="mainBodyFluid">
+<h1>Content License</h1>
+
+<p>For the purposes of licensing, the content of this site is divided
+into two categories:</p>
+<ul>
+  <li>Documentation content, found under the "Dev Guide" and "Reference"
+  tabs, including both static content and content extracted from source 
+  code modules, as well as sample code, and </li>
+<li>All other site content</li>
+</ul>
+
+<p>The documentation content on this site is made available to
+you as part of the <a href="http://source.android.com">Android Open
+Source Project</a>. This documentation, including any code shown in it,
+is licensed under the <a
+href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0
+license</a>, the preferred license for all parts of the of the Android
+Open Source Project.</p>
+
+<p>Apache 2.0 is a commercial and open-source-friendly software
+license. The majority of the Android platform and documentation is
+licensed under the Apache 2.0 license. While the project strives to
+adhere to the preferred license, there may be exceptions, such as for
+documentation (code comments) extracted from a source code module that
+is licensed under GPLv2 or other license. In those cases, the license
+covering the source code module will apply to the documentation
+extracted from it. </p>
+
+<p>All other content on this site, except as otherwise noted,
+is licensed under the <a
+href="http://creativecommons.org/licenses/by/2.5/">Creative Commons
+Attribution 2.5</a> license. </p>
+
+<p>You may use the content of this site in any way that is consistent
+with the specific license that applies to the content, as described
+above. For content licensed under Creative Commons Attribution 2.5, we
+ask that you give proper <a href="#attribution">attribution</a>. </p>
+
+
+<h3 id="terms">Terms of Use</h3>
+
+<p>We are pleased to license the Android documentation and sample code under
+terms that encourage you to take, modify, reuse, re-purpose, and remix the
+content as you see fit. Except as noted in the Restrictions section below, you
+are free to use the documentation content in your own creations. For example,
+you could quote the text in a book, cut-and-paste sections to your blog, record
+it as an audiobook for the visually impaired, or even translate it. </p>
+
+
+<h3 id="restrictions">Restrictions</h3>
+
+<ul>
+<li>While the documentation itself is available to you under the Apache 2.0
+license, note that proprietary trademarks and brand features are not
+included in that license.</li>
+
+<li>Google's trademarks and other brand features (including the 	
+ANDROID stylized typeface logo) are not included in the license.
+Please see <a href="http://www.google.com/permissions/guidelines.html">
+Guidelines for Third Party Use of Google Brand Features</a> for
+information about this usage. </li>
+
+<li>In some cases, a page may include content, such as an image, that is not 
+covered by the license. In that case, we will label the content that is not licensed. </li>
+
+<li>In addition, content linked from a page on this site is not covered
+by the license unless specifically noted. For example, pages may link to videos or
+slide decks that are not covered.</li>
+
+<li>The use of sample source code provided in the SDK or shown in this
+documentation is subject to the conditions detailed in the <a
+href="{@docRoot}sdk/terms.html">SDK Terms and Conditions</a>.</li>
+</ul>
+</h3>
+
+<h3 id="attribution">Attribution</h3>
+<p>
+Proper attribution is required when you reuse or create modified
+versions of content that appears on a page made available under the
+terms of the Creative Commons Attribution license. On this site, the
+requirement for attribution applies only to the non-documentation
+content, as described earlier in this document. The complete 
+requirements for attribution can be found in section 4b of the 
+<a href="http://creativecommons.org/licenses/by/2.5/legalcode">
+Creative Commons legal code</a>.
+</p>
+<p>
+ In practice we ask that you provide attribution to the Android Open
+ Source project to the best of the ability of the medium in which you 
+ are producing the work. There are several typical ways in which this 
+ might apply:
+</p>
+<h4>Exact Reproductions</h4>
+<p>
+ If your online work <em>exactly reproduces</em> text or images from this
+ site, in whole or in part, please include a paragraph at the bottom
+ of your page that reads: 
+</p>
+<blockquote>
+ Portions of this page are reproduced from work created and <a
+ href="http://code.google.com/policies.html">shared by the Android Open Source Project</a>
+ and used according to terms described in the <a
+ href="http://creativecommons.org/licenses/by/2.5/">Creative Commons
+ 2.5 Attribution License</a>.
+
+</blockquote>
+<p>
+ Also, please link back to the original source page so that readers can
+ refer there for more information.
+</p>
+<h4>Modified Versions</h4>
+<p>
+ If your online work shows <em>modified</em> text or images based on
+ the content from this site, please include a paragraph at the bottom of
+ your page that reads:
+</p>
+<blockquote>
+ Portions of this page are modifications based on work created and <a
+ href="http://code.google.com/policies.html">shared by the Android Open
+ Source Project</a> and used according to terms described in the <a
+ href="http://creativecommons.org/licenses/by/2.5/">Creative Commons
+ 2.5 Attribution License</a>.
+</blockquote>
+<p>
+ Again, please link back to the original source page so that readers can
+ refer there for more information. This is even more important when
+ the content has been modified.
+</p>
+<h4>Other Media</h4>
+<p>
+ If you produce non-hypertext works, such as books, audio, or
+ video, we ask that you make a best effort to include a spoken or
+ written attribution in the spirit of the messages above.
+</p>
+
+</div>	
+
+
diff --git a/docs/html/offline.jd b/docs/html/offline.jd
new file mode 100644
index 0000000..07c20d6
--- /dev/null
+++ b/docs/html/offline.jd
@@ -0,0 +1,28 @@
+home=true
+page.title=Welcome
+@jd:body
+
+<div id="mainBodyFluid">
+
+<h1>Welcome to the Android SDK!</h1>
+
+<img src="{@docRoot}images/android_icon_125.png" style="float:right; margin:1em 6em 6em;" />
+
+<p>If you've just downloaded the SDK, then continue with the 
+<a href="{@docRoot}sdk/1.1_r1/installing.html">Installing</a> guide.</p>
+
+<p>If you're upgrading from a previously installed version, then refer to the 
+<a href="{@docRoot}sdk/1.1_r1/upgrading.html">Upgrading</a> guide.</p>
+
+<p>Once you've completed the SDK installation, you can start learning about development on the Android framework
+by reading the <em><a href="{@docRoot}guide/index.html">Dev Guide</a></em>. And don't forget that the SDK comes packaged with
+a wide variety of very helpful code <a href="{@docRoot}samples/index.html">samples</a>.</p>
+
+<p>Please note that you are currently viewing a local, offline version of the Android developer documentation. 
+The offline documentation will behave just like the online documentation, except searches in the above
+search bar will not work. However, the search bar is still able to provide auto-completion for package and class names,
+which can help you quickly find reference documentation for specific classes that you remember.
+If you'd like fully searchable documentation, please visit
+<a href="http://developer.android.com/index.html">http://developer.android.com</a>.</p>
+
+</div>
\ No newline at end of file
diff --git a/docs/html/resources/bootcamp.pdf b/docs/html/resources/bootcamp.pdf
deleted file mode 100644
index a817b96..0000000
--- a/docs/html/resources/bootcamp.pdf
+++ /dev/null
Binary files differ
diff --git a/docs/html/samples/index.jd b/docs/html/samples/index.jd
index 6219f9a..c5c0b71 100644
--- a/docs/html/samples/index.jd
+++ b/docs/html/samples/index.jd
@@ -17,7 +17,7 @@
 </dl>
 
 <p>To run these samples, you should <a
-href="{@docRoot}intro/installing.html#creatingaproject">import them into
-Eclipse</a> or <a href="{@docRoot}intro/installing.html#otherides">use
+href="{@docRoot}guide/developing/eclipse-adt.html#creatingaproject">import them into
+Eclipse</a> or <a href="{@docRoot}guide/developing/other-ide.html">use
 activitycreator.py</a>, as described in the <a
-href="{@docRoot}intro/installing.html">Installing the SDK</a>.</p>
+href="{@docRoot}sdk/1.1_r1/installing.html">Installing the SDK</a>.</p>
diff --git a/docs/html/sdk/1.0_r1/RELEASENOTES.jd b/docs/html/sdk/1.0_r1/RELEASENOTES.jd
deleted file mode 100644
index c6a38bb..0000000
--- a/docs/html/sdk/1.0_r1/RELEASENOTES.jd
+++ /dev/null
@@ -1,100 +0,0 @@
-page.title=Release Notes, 1.0 r1
-@jd:body
-
-
-<p>This SDK release is the first to include the Android 1.0 platform and application API. Applications developed on this SDK will be compatible with mobile devices running the Android 1.0 platform, when such devices are available.</p>
-
-<p>This release includes mainly bug fixes, although some smaller features were added. The Android 1.0 also includes several API changes from the 0.9 version. For more information on API changes, see the <a href="{@docRoot}migrating/0.9-1.0/changes-overview.html">Overview of Changes</a> and the <a href="{@docRoot}migrating/0.9-1.0/changes.html">API Differences Report</a>. For those porting from the M5 release, the SDK also includes the legacy changes overview and API Differences Reports. See the current Overview of Changes for more information. </p>
-
-<h3>ADT Plugin Compatibility</h3>
-
-<p>For this version of the SDK &mdash; Android 1.0 SDK, Release 1 &mdash; the compatible version of the Android Development Tools (ADT) Plugin for Eclipse is <strong>0.8.0</strong>. If you are using a previous version of ADT, you should update to the latest version for use with this SDK. For information about how to update your ADT plugin, see <a href="{@docRoot}intro/upgrading.html">Upgrading the SDK</a>.</p>
-
-<h3>Installation and Upgrade Notes</h3>
-
-<p>If you've been developing an application using a previous SDK version and you want the application to run on Android-powered mobile devices, you must port the application to the Android 1.0 SDK. Please see <a href="{@docRoot}intro/upgrading.html">Upgrading the SDK</a> for detailed instructions on how to make the transition to this release.  Be sure to wipe application user data (emulator option <code>-wipe-data</code>) when running your application on the Android 1.0 SDK emulator.</p>
-
-<p>If you're installing the Android SDK for the first time, please see the instructions in <a href="{@docRoot}intro/installing.html">Installing the SDK</a>.
-
-<h3>Other Notes</h3>
-
-<p><strong>MapView API Key</strong></p>
-
-<p>MapView is a class that lets you easily integrate Google Maps into your application. Before you can access the maps data, you will need to register with the Google Maps service and receive a Maps API Key, which you then add to your MapView for authentication to the server.</p>
-
-<p>Currently, the registration service for MapView is not yet active and Google Maps is not yet enforcing the Maps API Key requirement. However, note that the registration service will be activated soon, so that MapViews in any application deployed to a mobile device will require registration and a valid Maps API Key. </p>
-
-<p>As soon as the registration service becomes available, we will update the page at <a href="http://code.google.com/android/toolbox/apis/mapkey.html">http://code.google.com/android/toolbox/apis/mapkey.html</a> with details about how and where to register. Please check that page periodically for registration information, if you are using a MapView.</p>
-
-
-<h3>Resolved Issues, Changes</h3>
-
-<p><strong>Emulator</strong></p>
-<ul>
-<li>Emulator now saves the user image in &lt;android&gt;/SDK1.0/</code></li>
-<li>Fixed EsounD-related freezes on Linux.</li>
-<li>Fixed the documentation in -help-audio. '-audio list' doesn't work, one
- needs to call -help-audio-out and -help-audio-in to get the list of valid
- audio backends.</li>
-<li>Fixed scrollwheel Dpad emulation in rotated mode. before that, using the
- scroll-wheel would always generated Dpad Up/Down events, even when in
- landscape mode.</li>
-<li>Several Obsolete command options were removed.</li>
-<li>Setting the network speed through the console or the -netspeed option will
- properly modify the connectivity icon on the device.</li>
-<li>Setting the GSM voice registration state to 'roaming' in the console will
- properly modify the voice icon on the device</li>
-</ul>
-
-<p><strong>SQLite</strong></p>
-<ul>
-<li>SQLite is now included in the SDK package on all platforms. </li>
-</ul>
-
-<h3>Known Issues</h3>
-
-<p><strong>JUnit and Eclipse/ADT</strong></p>
-<ul>
-<li>If you are developing in Eclipse/ADT and want to add JUnit test
-classes, you can do so. However, you need to set up a custom JUnit configuration
-before your tests will run properly. For detailed information about how to set
-up the JUnit configuration, see the troubleshooting topic <a
-href="{@docRoot}kb/troubleshooting.html#addjunit">Running a Junit test class
-in Eclipse</a>.</li>
-</ul>
-
-<p><strong>Other</strong></p>
-
-<ul>
-<li>It is not possible to send MMS messages between emulator instances. </li>
-<li>In some cases, you may encounter problems when using the browser on an
-emulator started with the command-line option <code>-http-proxy</code>. </li>
-<li>We regret to inform developers that Android 1.0 will not include support for
-dot-matrix printers.</li>
-<li>On the OSX platform, if you manually remove the ~/.android directory
-using <code>rm -rf ~/.android</code>, then try to run 
-the emulator, it crashes. This happens because the emulator fails to create 
-a new .android directory before attempting to create the child SDK1.0 directory.
-To work around this issue, manually create a new .android directory using
-<code>mkdir ~/.android</code>, then run the emulator. The emulator 
-creates the SDK1.0 directory and starts normally. </li>
-<li>The final set of Intent patterns honored by Android 1.0 has not yet been
-fully documented. Documentation will be provided in future releases.</li>
-<li>In ADT Editor, you can add at most ten new resource values at a time,
-in a given res/values/*.xml, using the form in the Android Resources pane. 
-If you add more than ten, the Android Resources pane will not display the
-attributes fields for the additional resource entries. To work around this 
-problem, you can close the file in the editor and open it again, or you 
-can edit the resource entries in the XML text mode. </li>
-<li>The emulator's battery-control commands (<code>power &lt;option&gt</code>)
-are not working in this release.</li>
-	<li>We regret to inform developers that Android 1.0 will not support 3.5" floppy disks.
-	</li>
-	<li>Unfortunately, the ability to play audio streams from memory (such as via an InputStream or Reader) will not be possible in Android 1.0.&nbsp; As a workaround, we recommend that developers save media content to SD card and use MediaPlayer to play from a file URI, or embed a small HTTP server and play from a URI on localhost (such as http://127.0.0.1:4242/something).
-	</li>
-	<li>Android now supports modules or libraries that can be optionally linked into applications; a good example is the MapView, which has been moved into such a library. However, Android 1.0 will not support the ability for third-party developers to create such libraries for sharing with other applications.
-	</li>
-	<li>We believe that we have eliminated the problem with very long emulator startups on Windows, but had some trouble reproducing the issue.&nbsp; We are interested in feedback from developers, if this issue persists.
-	</li>
-</ul>
-
diff --git a/docs/html/sdk/1.0_r1/index.jd b/docs/html/sdk/1.0_r1/index.jd
index 7ad4e88..d236844 100644
--- a/docs/html/sdk/1.0_r1/index.jd
+++ b/docs/html/sdk/1.0_r1/index.jd
@@ -1,6 +1,8 @@
-page.title=Download 1.0r1
+page.title=Android 1.0 SDK, release 1
 
-sdk.version=Android 1.0 SDK, release 1
+sdk.not_latest_version=true
+
+sdk.version=1.0_r1
 sdk.date=September 23, 2008
 
 sdk.win_download=android-sdk-windows-1.0_r1.zip
@@ -15,4 +17,48 @@
 sdk.linux_bytes=87.8 MB
 sdk.linux_checksum=2660b4029039b7d714e59827e9a9a11d
 
+
 @jd:body
+
+<h2>Included in this SDK</h2>
+
+<p>This SDK includes some awesome stuff.</p>
+
+
+<h2>System and Software Requirements</h2>
+
+<p>The following systems and development environments are supported by this SDK.</p>
+
+<h4>Supported Operating Systems:</h4>
+<ul>
+  <li>Windows XP or Vista</li>
+  <li>Mac OS X 10.4.8 or later (x86 only)</li>
+  <li>Linux (tested on Linux Ubuntu Dapper Drake)</li>
+</ul>
+
+<h4>Supported Development Environments:</h4>
+<ul>
+  <li>Eclipse IDE
+    <ul>
+      <li><a href="http://www.eclipse.org/downloads/">Eclipse</a> 3.3 (Europa), 3.4 (Ganymede)
+        <ul>
+        <li>Eclipse <a href="http://www.eclipse.org/jdt">JDT</a> plugin (included in most Eclipse IDE packages) </li>
+        <li><a href="http://www.eclipse.org/webtools">WST</a> (optional, but needed for the Android Editors feature; included in <a href="http://www.eclipse.org/downloads/moreinfo/compare.php">most Eclipse IDE packages</a>)</li>
+        </ul>
+      </li>     
+      <li><a href="http://java.sun.com/javase/downloads/index.jsp">JDK 5 or JDK 6</a> (JRE alone is not sufficient)</li>
+      <li><a href="installing.html#installingplugin">Android Development Tools plugin</a> (optional)</li>
+      <li><strong>Not</strong> compatible with Gnu Compiler for Java (gcj)</li>
+    </ul>
+  </li>
+  <li>Other development environments or IDEs
+    <ul>
+      <li><a href="http://java.sun.com/javase/downloads/index.jsp">JDK 5 or JDK 6</a> (JRE alone is not sufficient)</li>
+      <li><a href="http://ant.apache.org/">Apache Ant</a> 1.6.5 or later for Linux and Mac, 1.7 or later for Windows</li>
+      <li><strong>Not</strong> compatible with Gnu Compiler for Java (gcj)</li>
+    </ul>
+  </li>
+</ul>
+
+<p class="note"><strong>Note:</strong> If JDK is already installed on your development computer, please take a moment to make sure that it meets the version requirements listed above. In
+particular, note that some Linux distributions may include JDK 1.4 or Gnu Compiler for Java, both of which are not supported for Android development. </p>
\ No newline at end of file
diff --git a/docs/html/sdk/1.0_r1/terms.jd b/docs/html/sdk/1.0_r1/terms.jd
deleted file mode 100644
index 5c6e6fc..0000000
--- a/docs/html/sdk/1.0_r1/terms.jd
+++ /dev/null
@@ -1,7 +0,0 @@
-page.title=Terms and Conditions
-@jd:body
-
-<?cs include:"terms_body.html" ?>
-
-
-
diff --git a/docs/html/sdk/1.0_r1/requirements.jd b/docs/html/sdk/1.0_r2/index.jd
similarity index 68%
copy from docs/html/sdk/1.0_r1/requirements.jd
copy to docs/html/sdk/1.0_r2/index.jd
index 6af3900..6fbca6d 100644
--- a/docs/html/sdk/1.0_r1/requirements.jd
+++ b/docs/html/sdk/1.0_r2/index.jd
@@ -1,18 +1,42 @@
-page.title=System and Software Requirements
+page.title=Android 1.0 SDK, release 2
+
+sdk.not_latest_version=true
+
+sdk.version=1.0_r2
+sdk.date=November 2008
+
+sdk.win_download=android-sdk-windows-1.0_r2.zip
+sdk.win_bytes=98360564
+sdk.win_checksum=a5e1af8ac145946b4a9627516ad4a711
+
+sdk.mac_download=android-sdk-mac_x86-1.0_r2.zip
+sdk.mac_bytes=93771410
+sdk.mac_checksum=87b99d5e9f59b78363a63200c11498e8
+
+sdk.linux_download=android-sdk-linux_x86-1.0_r2.zip
+sdk.linux_bytes=94186463
+sdk.linux_checksum=a1f3b6d854596f850f5008856d0f380e
+
+
 @jd:body
 
+<h2>Included in this SDK</h2>
 
-<p>To develop Android applications using the code and tools in the Android SDK, 
-you need a suitable development computer and development environment, as described below.</p>
+<p>This SDK includes some awesome stuff.</p>
 
-<p><strong>Supported Operating Systems:</strong></p>
+
+<h2>System and Software Requirements</h2>
+
+<p>The following systems and development environments are supported by this SDK.</p>
+
+<h4>Supported Operating Systems:</h4>
 <ul>
   <li>Windows XP or Vista</li>
   <li>Mac OS X 10.4.8 or later (x86 only)</li>
   <li>Linux (tested on Linux Ubuntu Dapper Drake)</li>
 </ul>
 
-<p><strong>Supported Development Environments:</strong></p>
+<h4>Supported Development Environments:</h4>
 <ul>
   <li>Eclipse IDE
     <ul>
diff --git a/docs/html/sdk/1.0_r2/installing.jd b/docs/html/sdk/1.0_r2/installing.jd
new file mode 100644
index 0000000..0f15396
--- /dev/null
+++ b/docs/html/sdk/1.0_r2/installing.jd
@@ -0,0 +1,124 @@
+page.title=Installing the SDK
+@jd:body
+
+
+<p>This page describes how to install the Android SDK and set up your development environment. If you haven't 
+downloaded the SDK yet, follow the link below.</p>
+
+<div class="linkbox"><a href="http://developer.android.com/sdk/">Download the SDK</a></div>
+
+<p>Before you begin, be sure that you're development environment meets the SDK
+<a href="requirements.html">System and Software Requirements</a>.</p>
+
+<div class="special">
+<h4 style="margin-top">Upgrading?</h4>
+<p>If you have already developed applications using an earlier version of the 
+SDK, please skip this page and read the 
+<b><a href="upgrading.html">Upgrading the SDK</a></b> document.  
+</p>
+</div>
+
+
+<a name="installingsdk"></a>
+<a name="setup"></a>
+<h2>Installing the SDK</h2>
+
+	<p>After downloading the SDK, unpack the .zip archive to a suitable location on your machine. By default, the SDK files are unpacked into a directory named  <code>android_sdk_<em>&lt;platform</em>&gt;_<em>&lt;release&gt;</em>_<em>&lt;build&gt;</em></code>. The directory contains the subdirectories <code>tools/</code>, <code>samples/</code>, and others. </p>
+	
+	<p>Make a note of the name and location of the unpacked SDK directory on your system &mdash; you will need to refer to the SDK directory later, when setting up the Android plugin or using SDK tools. </p>
+
+        <p>Optionally, you can add the path to the SDK <code>tools</code> directory to your path. As mentioned above, the <code>tools/</code> directory is located in the SDK directory. </p>
+     <ul>
+          <li>On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look
+          for a line that sets the PATH environment variable and add the
+          full path to the <code>tools/</code> directory to it. If you don't 
+          see a line setting the path, you can add one:</li>
+
+          <ul><code>export PATH=${PATH}:<em>&lt;your_sdk_dir&gt;</em>/tools</code></ul>
+
+          <li>On a Mac, look in your home directory for .bash_profile and
+          proceed as for Linux. You can create the .bash_profile, if 
+          you haven't already set one up on your machine. </li>
+
+          <li>On Windows, right click on My Computer, and select Properties.  
+        Under the Advanced tab, hit the Environment Variables button, and in the
+        dialog that comes up, double-click on Path under System Variables. Add  the full path to the <code>tools/</code> directory to the path. </li>
+        </ul>
+
+        <p>Adding <code>tools</code> to your path lets you run Android Debug Bridge (adb) and the other command line <a href="{@docRoot}guide/developing/tools/index.html">tools</a> without needing to supply the full path to the tools directory. Note that, if you update your SDK, you should remember to update your PATH settings to point to the new location, if different.</p>
+
+<h3>Setting up Eclipse</h3>
+<p>If you'll be developing with the Eclipse IDE, follow the following procedure to setup the IDE
+to use the Android SDK.</p>
+<p>Basically, you just need to update your Eclipse preferences to point to the Android SDK directory:</p>
+<ol>
+    <li>Select <strong>Window</strong> &gt; <strong>Preferences...</strong> to open the Preferences
+        panel. (Mac OS X: <strong>Eclipse</strong> &gt; <strong>Preferences</strong>) </li>
+    <li>Select <strong>Android</strong> from the left panel. </li>
+    <li>For the SDK Location in the main panel, click <strong>Browse...</strong> and locate the SDK directory. </li>
+    <li>Click <strong>Apply</strong>, then <strong>OK</strong>.</li>
+</ol>
+<p>Done! We now recommend that you install the ADT Eclipse plugin, which will provide some much-appreciated assistance in developing Android apps with Eclipse...</p>
+
+<a name="installingplugin"></a>
+<h2>Installing the Eclipse Plugin (ADT)</h2>
+
+<p>If you will be using the Eclipse IDE as your environment for developing Android applications, you can install a custom plugin called Android Development Tools (ADT), which adds integrated support for Android projects and tools. The ADT plugin includes a variety of powerful extensions that make creating, running, and debugging Android applications faster and easier. This plugin is highly recommended for Eclipse users.</p>
+
+<p>If you <em>will not</em> be using the Eclipse IDE, you do not need to download or install the ADT plugin.</p>
+
+<p><strong>Follow this guide to install the ADT Plugin</strong></p>
+
+<a name="installnotes"></a>
+<h2>Installation Notes</h2>
+<h4>Ubuntu Linux Notes</h4>
+<ul>
+    <li>If you need help installing and configuring Java on your
+development machine, you might find these resources helpful: 
+        <ul>
+           <li><a href="https://help.ubuntu.com/community/Java">https://help.ubuntu.com/community/Java </a></li>
+           <li><a href="https://help.ubuntu.com/community/Java">https://help.ubuntu.com/community/JavaInstallation </a></li>
+       </ul>
+   </li>
+<li>Here are the steps to install Java and Eclipse, prior to installing
+the Android SDK and ADT Plugin.
+<ol>
+    <li>If you are running a 64-bit distribution on your development
+machine, you need to install the <code>ia32-libs</code> package using
+<code>apt-get:</code>:
+        <pre>apt-get install ia32-libs</pre></li>
+    <li>Next, install Java:
+        <pre>apt-get install sun-java6-bin</pre></li>
+    <li>The Ubuntu package manager does not currently offer an Eclipse 3.3
+    version for download, so we recommend that you download Eclipse from
+eclipse.org (<a
+href="http://www.eclipse.org/downloads/">http://www.eclipse.org/
+downloads/</a>). A Java or RCP version of Eclipse is recommended.</li>
+<li>Follow the steps given in previous sections to install the SDK 
+and the ADT plugin. </li>
+</ol>
+</ul>
+<h4>Other Linux Notes</h4>
+<ul>
+    <li>If JDK is already installed on your development computer, please
+take a moment to make sure that it meets the version requirements listed
+at the top of this page. In particular, note that some Linux
+distributions may include JDK 1.4 or Gnu Compiler for Java, both of
+which are not supported for Android development.</li>
+</ul>
+
+<a name="developingwitheclipse"></a>
+<a name="existingcode"></a>
+<a name="creatingaproject" id="creatingaproject"></a>
+<a name="launchconfig" id="launchconfig"></a>
+<a name="installingrunningdebugging" id="installingrunningdebugging"></a>
+<a name="otherides" id="otherides"></a>
+<a name="buildingwithant"></a>
+<a name="debugging" id="debugging"></a>
+<a name="additionaldebugging" id="additionaldebugging"></a>
+<a name="toptips" id="toptips"></a>
+<a name="debughelpers"></a>
+<a name="uninstalling" id="uninstalling"></a>
+<a name="tips" id="tips"></a>
+<a name="eclipse" id="eclipse"></a> 
+<a name="building"></a>
diff --git a/docs/html/sdk/1.0_r2/upgrading.jd b/docs/html/sdk/1.0_r2/upgrading.jd
new file mode 100644
index 0000000..168f1be
--- /dev/null
+++ b/docs/html/sdk/1.0_r2/upgrading.jd
@@ -0,0 +1,151 @@
+page.title=Upgrading the SDK
+@jd:body
+
+<div class="sidebox-wrapper">
+  <div class="sidebox-inner">
+
+     <h2>Useful Links</h2>
+
+      <ul class="noindent">
+        <li><a href="migrating/0.9-1.0/changes-overview.html">Overview of Changes</a>
+		      <p>A high-level look at what's changed in Android, with 
+		       discussion of how the changes may affect your apps.</p></li>
+
+        <li><a href="migrating/0.9-1.0/changes.html">API Diff Report</a> 
+                <p>A detailed report that lists all the specific changes in the latest SDK.</p></li>
+
+        <li><a href="RELEASENOTES.html">Release Notes</a> 
+                <p>Version details, known issues, and resolved issues. </p></li>
+
+        <li><a href="http://groups.google.com/group/android-developers">Android Developers Group</a> 
+            <p>A forum where you can discuss migration issues and learn from other Android developers. </p></li>
+ 
+        <li><a href="http://code.google.com/p/android/issues/list">Android Issue Tracker</a>
+            <p>If you think you may have found a bug, use the issue tracker to report it.</p></li>
+      </ul>
+
+   </div>
+</div><!-- class-sidebox -->
+
+
+<p>This guide will help you migrate your development environment and applications
+to the latest version of the SDK. Use this guide if you've been developing applications
+on a previous version of the Android SDK. 
+</p>
+
+<p>To ensure that your applications are compliant with the Android 1.0 system available 
+on mobile devices, you need to install the new SDK and port your existing Android 
+applications to the updated API. The sections below guide you through the process.</p>
+
+<h2 id="install-new">Install the new SDK</h2>
+
+<p><a href="{@docRoot}download.html">Download the SDK</a> and unpack it into a safe location.</p>
+
+<p>After unpacking the new SDK, you should:</p>
+
+<ul>
+  <li>Wipe your emulator data. <p>Some data formats have changed since the last
+  SDK release, so any previously saved data in your emulator must be removed. Open a console/terminal
+  and navigate to the <code>/tools</code> directory of your SDK. Launch the 
+  emulator with the <code>-wipe-data</code> option. </p>
+  <p>Windows: <code>emulator -wipe-data</code><br/>
+   Mac/Linux: <code>./emulator -wipe-data</code></p>
+  </li>
+  <li>Update your PATH variable (Mac/Linux; optional). <p>If you had previously setup your 
+  PATH variable to point to the SDK tools directory, then you'll need to update it to 
+  point to the new SDK. E.g., for a <code>.bashrc</code> or <code>.bash_profile</code> file:
+  <code>export PATH=$PATH:<em>&lt;your_new_sdk_dir></em>/tools</code></p>
+  </li>
+</ul>
+
+<h2 id="update-plugin">Update your ADT Eclipse Plugin</h2>
+
+<p>If you develop on Eclipse and are using the ADT plugin, follow these steps to install the new plugin that accompanies the latest SDK.</p>
+
+<table style="font-size:100%">
+<tr><th>Eclipse 3.3 (Europa)</th><th>Eclipse 3.4 (Ganymede)</th></tr>
+<tr>
+<td width="50%">
+<ol>
+    <li> Select <strong>Help</strong> &gt; <strong>Software Updates</strong> &gt; <strong>Find and Install...</strong>. </li>
+    <li> Select <strong>Search for updates of the currently installed features</strong> and click <strong>Finish</strong>. </li>
+    <li> If any update for ADT is available, select and install. </li>
+    <li> Restart Eclipse.</li>
+</ol>
+</td>
+<td>
+<ol>
+    <li>Select <strong>Help</strong> &gt; <strong>Software Updates...</strong></li>
+    <li>Select the <strong>Installed Software</strong> tab.</li>
+    <li>Click <strong>Update...</strong></li>
+    <li>If an update for ADT is available, select it and click <strong>Finish</strong>.</li>
+    <li>Restart Eclipse.</li>
+</ol>
+</td>
+</tr>
+</table>
+
+<p>After restart, update your Eclipse preferences to point to the SDK directory:</p>
+    <ol>
+      <li>Select <strong>Window</strong> > <strong>Preferences...</strong> to open the Preferences panel. (Mac OSX: <strong>Eclipse</strong> > <strong>Preferences</strong>)</li>
+      <li>Select <strong>Android</strong> from the left panel.</li>
+      <li>For the SDK Location in the main panel, click <strong>Browse...</strong> and locate the SDK directory.</li>
+      <li>Click <strong>Apply</strong>, then <strong>OK</strong>.</li>
+    </ol>
+
+<h2 id="sign">Set Up Application Signing</h2>
+
+<p>All applications must now be signed before you can install them on the emulator. Both 
+the ADT plugin and the Ant-based build tools support this requirement by signing compiled 
+.apk files with a debug key. To do so, the build tools use the Keytool utility included 
+in the JDK to to create a keystore and a key with a known alias and password. For more 
+information, see <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>.
+
+<p>To support signing, you should first make sure that Keytool is available to the SDK build 
+tools. In most cases, you can tell the SDK build tools how to find Keytool by making sure that 
+your JAVA_HOME environment variable is set and that it references a suitable JDK. Alternatively, 
+you can add the JDK version of Keytool to your PATH variable.</p>
+
+<p>If you are developing on a version of Linux that originally came with Gnu Compiler for Java, 
+make sure that the system is using the JDK version of Keytool, rather than the gcj version. 
+If keytool is already in your PATH, it might be pointing to a symlink at /usr/bin/keytool. 
+In this case, check the symlink target to make sure that it points to the keytool in the JDK.</p>
+
+<p>If you use Ant to build your .apk files (rather than ADT for Eclipse), you must regenerate 
+your build.xml file. To do that, follow these steps:</p>
+<ol>
+  <li>In your Android application project directory, locate and delete the current build.xml file.</li>
+  <li>Run activitycreator, directing output to the folder containing your application project.
+
+<pre>- exec activitycreator --out &lt;project folder&gt; your.activity.YourActivity</pre>
+
+  </li>
+</ol>
+
+<p>Run in this way, activitycreator will not erase or create new Java files (or manifest files), 
+provided the activity and package already exists. It is important that the package and the activity 
+are real. The tool creates a new build.xml file, as well as a new directory called "libs" in which 
+to place 3rd jar files, which are now automatically handled by the Ant script.</p>
+
+<h2 id="migrate">Migrate your applications</h2>
+
+<p>After updating your SDK, you will likely encounter breakages in your code, due to 
+framework and API changes. You'll need to update your code to match changes in the Android APIs.</p>
+
+<p>One way to start is to open your project in Eclipse and see where the ADT
+identifies errors in your application. From there, you can lookup
+respective changes in the 
+<a href="migrating/changes-overview.html">Overview of Changes</a>
+and <a href="migrating/changes.html">API Diffs Report</a>.</p>
+
+<p>If you have additional trouble updating your code, visit the 
+<a href="http://groups.google.com/group/android-developers">Android Developers Group</a>
+to seek help from other Android developers.</p>
+
+<p>If you have modified one of the ApiDemos applications and would like to migrate it 
+to the new SDK, note that you will need to uninstall the version of ApiDemos that comes 
+preinstalled in the emulator. For more information, or if you encounter an "reinstallation" 
+error when running or installing ApiDemos, see the troubleshooting topic 
+<a href="{@docRoot}guide/appendix/faq/troubleshooting.html#apidemosreinstall">I can't install ApiDemos 
+apps in my IDE because of a signing error</a> for information about how to solve the problem.</p>
+
diff --git a/docs/html/sdk/1.1_r1/index.jd b/docs/html/sdk/1.1_r1/index.jd
new file mode 100644
index 0000000..b516acb
--- /dev/null
+++ b/docs/html/sdk/1.1_r1/index.jd
@@ -0,0 +1,62 @@
+page.title=Download Android 1.1 SDK, Release 1
+
+sdk.version=1.1_r1
+sdk.date=February 2009
+
+sdk.win_download=android-sdk-windows-1.1_r1.zip
+sdk.win_bytes=unknown
+sdk.win_checksum=unknown
+
+sdk.mac_download=android-sdk-mac_x86-1.1_r1.zip
+sdk.mac_bytes=unknown
+sdk.mac_checksum=unknown
+
+sdk.linux_download=android-sdk-linux_x86-1.1_r1.zip
+sdk.linux_bytes=unknown
+sdk.linux_checksum=unknown
+
+
+@jd:body
+
+<h2>SDK Contents</h2>
+
+<h4>Development tools</h4>
+
+<p>The SDK includes a variety of tools for developing and debugging application code and designing an application UI. You can read about the tools in the  
+<a href="{@docRoot}guide/developing/tools/index.html">Dev Guide</a> and access them in the <code>&lt;sdk&gt;/tools/</code> directory. 
+
+<p>The tools package included in this SDK is the same as that included in the Android 1.0, Release 2 SDK. </p>
+
+<h4 id="system_images">System Images</h4>
+
+<p>The Android system images listed below are included in this SDK. For more information about a system image &mdash; features, applications included, localizations, API changes, and so on &mdash; see its Version Notes. </p>
+
+<table style="margin-right:1em;" width="80%">
+<tr>
+<th><nobr>System Image</nobr></th><th><nobr>API Level</nobr></th><th>Notes</th><th>Description</th>
+</tr>
+
+<tr>
+<td width="5%"><nobr>Android 1.1</nobr></td>
+<td  width="5%">2</td>
+<td  width="5%"><nobr><a href="{@docRoot}sdk/android-1.1.html">Version Notes</a></nobr></td>
+<td>Includes com.google.android.maps external library and a set of standard development applications. </td>
+
+</tr>
+
+</table>
+
+<h4>Sample Code and Applications</h4>
+
+<p>You can look at a variety of tutorials and samples in the <a href="{@docRoot}guide/samples/index.html">Dev Guide</a> and access the sample code itself
+in the <code>&lt;sdk&gt;/samples/</code> directory of the SDK package.</p>
+
+<h4>Documentation</h4>
+
+<p>The SDK package includes a full set of local documentation. To view it, open the <code>&lt;sdk&gt;/documentation.html</code> file in a web browser. If you are developing in an IDE such as Eclipse, you can also view the reference documentation directly in the IDE. </p>
+
+<p>The most current documentation is always available on the Android Developers site:</p>
+
+<p style="margin-left:2em;"><a href="ttp://developer.android.com/index.html">http://developer.android.com/</a></p>
+
+
diff --git a/docs/html/sdk/1.1_r1/installing.jd b/docs/html/sdk/1.1_r1/installing.jd
new file mode 100644
index 0000000..1319237
--- /dev/null
+++ b/docs/html/sdk/1.1_r1/installing.jd
@@ -0,0 +1,216 @@
+page.title=Installing the Android SDK
+sdk.version=1.1_r1
+
+@jd:body
+
+
+<p>This page describes how to install the Android 1.1 SDK, Release 1, and set up your development environment. 
+If you haven't downloaded the SDK yet, you can so so from the <a href="{@docRoot}sdk/1.1_r1/index.html">Download</a> page.</p>
+
+<p>Before you begin, be sure that your development environment meets the SDK
+<a href="{@docRoot}sdk/1.1_r1/requirements.html">System Requirements</a>.</p>
+
+<h4 style="margin-top">Upgrading?</h4>
+<p>If you have already developed applications using an earlier version of the 
+SDK, please skip this page and read the 
+<a href="{@docRoot}sdk/1.1_r1/upgrading.html"><strong>Upgrading the SDK</strong></a></b> document instead.
+</p>
+
+<a name="installingsdk"></a>
+<a name="setup"></a>
+<h2>Installing the SDK</h2>
+
+	<p>After downloading the SDK, unpack the .zip archive to a suitable location on your machine. By default, the SDK files are unpacked into a directory named  <code>android_sdk_<em>&lt;platform</em>&gt;_<em>&lt;release&gt;</em>_<em>&lt;build&gt;</em></code>. The directory contains the subdirectories <code>tools/</code>, <code>samples/</code>, and others. </p>
+	
+	<p>Make a note of the name and location of the unpacked SDK directory on your system &mdash; you will need to refer to the SDK directory later, when setting up the Android plugin or using SDK tools. </p>
+
+        <p>Optionally, you can add the path to the SDK <code>tools</code> directory to your path. As mentioned above, the <code>tools/</code> directory is located in the SDK directory. </p>
+     <ul>
+          <li>On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look
+          for a line that sets the PATH environment variable and add the
+          full path to the <code>tools/</code> directory to it. If you don't 
+          see a line setting the path, you can add one:</li>
+
+          <ul><code>export PATH=${PATH}:<em>&lt;your_sdk_dir&gt;</em>/tools</code></ul>
+
+          <li>On a Mac, look in your home directory for .bash_profile and
+          proceed as for Linux. You can create the .bash_profile, if 
+          you haven't already set one up on your machine. </li>
+
+          <li>On Windows, right click on My Computer, and select Properties.  
+        Under the Advanced tab, hit the Environment Variables button, and in the
+        dialog that comes up, double-click on Path under System Variables. Add  the full path to the <code>tools/</code> directory to the path. </li>
+        </ul>
+
+        <p>Adding <code>tools</code> to your path lets you run Android Debug Bridge (adb) and the other command line <a href="{@docRoot}guide/developing/tools/index.html">tools</a> without needing to supply the full path to the tools directory. Note that, if you update your SDK, you should remember to update your PATH settings to point to the new location, if different.</p>
+
+<h2>Setting up Eclipse</h2>
+<p>If you'll be developing with the Eclipse IDE, follow the following procedure to setup the IDE
+to use the Android SDK.</p>
+<p>Basically, you just need to update your Eclipse preferences to point to the Android SDK directory:</p>
+<ol>
+    <li>Select <strong>Window</strong> &gt; <strong>Preferences...</strong> to open the Preferences
+        panel. (Mac OS X: <strong>Eclipse</strong> &gt; <strong>Preferences</strong>) </li>
+    <li>Select <strong>Android</strong> from the left panel. </li>
+    <li>For the SDK Location in the main panel, click <strong>Browse...</strong> and locate the SDK directory. </li>
+    <li>Click <strong>Apply</strong>, then <strong>OK</strong>.</li>
+</ol>
+<p>Done! We now recommend that you install the ADT Eclipse plugin, which will provide some much-appreciated assistance in developing Android apps with Eclipse...</p>
+
+
+<h2 id="installingplugin">Installing the Eclipse Plugin (ADT)</h2>
+
+<p>If you will be using the Eclipse IDE as your environment for developing Android applications, you can install a custom plugin called Android Development Tools (ADT), which adds integrated support for Android projects and tools. The ADT plugin includes a variety of powerful extensions that make creating, running, and debugging Android applications faster and easier. Developing in ADT/Eclipse is highly recommended for Eclipse users and those new to Android.</p>
+
+<p>If you <em>will not</em> be using the Eclipse IDE, you do not need to download or install the ADT plugin. You can still develop Android applications using other tools. </p>
+
+<p>To download and install the ADT plugin, follow the steps below for your respective Eclipse version. </p>
+
+<table style="font-size:100%">
+<tr><th>Eclipse 3.3 (Europa)</th><th>Eclipse 3.4 (Ganymede)</th></tr>
+<tr>
+<td width="45%">
+<ol>
+    <li>Start Eclipse, then select <strong>Help</strong> &gt; <strong>Software Updates</strong> &gt; <strong>Find
+            and Install...</strong>. </li>
+
+    <li>In the dialog that appears, select <strong>Search for new features to install</strong> and click <strong>Next</strong>. </li>
+    <li>Click <strong>New Remote Site</strong>. </li>
+    <li>In the resulting dialog box, enter a name for the remote site (e.g. Android Plugin) and enter this as its URL:
+        <pre>https://dl-ssl.google.com/android/eclipse/</pre>
+        <p>Alternatively, you can use http in the Location URL, if you are having 
+         trouble with https (https is preferred for security reasons).</p>
+        <pre>http://dl-ssl.google.com/android/eclipse/</pre>
+        <p>Click <strong>OK</strong>.</p> </li>
+    <li>You should now see the new site added to the search list (and checked).
+        Click <strong>Finish</strong>. </li>
+    <li>In the subsequent Search Results dialog box, select the checkbox for
+    <strong>Android Plugin</strong> &gt; <strong>Developer Tools</strong>.
+    This will check both features:  "Android Developer Tools", and "Android
+    Editors". The Android Editors feature is optional, but recommended.  If
+    you choose to install it, you need the WST plugin mentioned earlier in this
+    page. Click <strong>Next</strong>. </li>
+    <li>Read the license agreement and then select <strong>Accept terms of the license agreement</strong>. 
+     Click <strong>Next</strong>. </li>
+    <li>Click <strong>Finish</strong>. </li>
+
+    <li>The ADT plugin is not signed; you can accept the installation anyway
+        by clicking <strong>Install All</strong>. </li>
+    <li>Restart Eclipse. </li>
+</ol>
+
+</td>
+<td>
+
+<ol>
+    <li>Start Eclipse, then select <strong>Help</strong> &gt; <strong>Software Updates...</strong>.
+    </li>
+    <li>In the dialog that appears, click the <strong>Available Software</strong> tab.
+    </li>
+    <li>Click <strong>Add Site...</strong>
+    </li>
+    <li>Enter this as the Location:
+      <pre>https://dl-ssl.google.com/android/eclipse/</pre>
+      <p>Alternatively, you can use http in the Location URL, if you are having 
+         trouble with https (https is preferred for security reasons).</p>
+      <pre>http://dl-ssl.google.com/android/eclipse/</pre>
+      <p>Click <strong>OK</strong>.</p></li>
+    <li>Back in the Available Software view, you should see the plugin. Select the checkbox next to 
+      <em>Developer Tools</em>  and click <strong>Install...</strong>
+    </li>
+    <li>On the subsequent Install window, "Android Developer Tools", and "Android Editors" should both be checked. 
+    The Android Editors feature is optional, but recommended.  If
+    you choose to install it, you need the WST plugin mentioned earlier in this
+    page. Click <strong>Next</strong>.
+     </li>
+    <li>Accept the license agreement and click <strong>Finish</strong>.</li>
+    <li>Restart Eclipse. </li>
+</ol>
+
+</td>
+</tr>
+</table>
+
+<h3 id="troubleshooting">Troubleshooting ADT Installation</h3>
+<p> 
+If you are having trouble downloading the ADT plugin after following the steps above, here are some suggestions: </p>
+
+<ul>
+	<li>If Eclipse can not find the remote update site containing the ADT plugin, try changing the remote site URL to use http, rather than https. That is, set the Location for the remote site to:
+        <pre>http://dl-ssl.google.com/android/eclipse/</pre></li>
+	<li>If you are behind a firewall (such as a corporate firewall), make
+        sure that you have properly configured your proxy settings in Eclipse.
+        In Eclipse 3.3/3.4, you can configure proxy information from the main
+        Eclipse menu in <strong>Window</strong> (on Mac, <strong>Eclipse</strong>) &gt; <strong>Preferences</strong> &gt; <strong>General</strong> &gt; <strong>Network Connections</strong>.</li>
+</ul>
+<p> 
+If you are still unable to use Eclipse to download the ADT plugin as a remote update site, you can download the ADT files to your local machine using a browser and the install the files in Eclipse from there:
+</p>
+<ol>
+<li><a href="{@docRoot}sdk/adt_download.html">Download the ADT zip file</a> (do not unpack it).
+<li>Follow steps 1 and 2 in the default install instructions (above).
+<li>In Eclipse 3.3, click <strong>New Archive Site...</strong>. <br/>
+    In Eclipse 3.4, click <strong>Add Site...</strong>, then <strong>Archive...</strong>
+<li>Browse and select the downloaded the zip file.
+<li>Follow the remaining procedures, above, starting from steps 5.
+</ol>
+<p> 
+Note that to update your plugin, you will have to follow these steps again instead of the default update instructions.</p>
+
+<p>Note that the "Android Editors" feature of ADT requires several optional 
+Eclipse components (for example, WST). If you encounter an error when 
+installing ADT, your Eclipse installion might not include those components. 
+For information about how to quickly add the necessary components to your 
+Eclipse installation, see the troubleshooting topic 
+<a href="{@docRoot}guide/appendix/faq/troubleshooting.html#installeclipsecomponents">ADT Installation Error: "requires plug-in org.eclipse.wst.sse.ui"</a>.</p>
+
+<h4>For Linux users</h4>
+<p>If you encounter this error when installing the ADT Plugin for Eclipse: 
+<pre>
+An error occurred during provisioning.
+Cannot connect to keystore.
+JKS</pre>
+<p>
+...then your development machine lacks a suitable Java VM. Installing Sun
+Java 6 will resolve this issue and you can then reinstall the ADT
+Plugin.</p>
+
+<a name="installnotes"></a>
+<h2>Installation Notes</h2>
+<h4>Ubuntu Linux Notes</h4>
+<ul>
+    <li>If you need help installing and configuring Java on your
+development machine, you might find these resources helpful: 
+        <ul>
+           <li><a href="https://help.ubuntu.com/community/Java">https://help.ubuntu.com/community/Java </a></li>
+           <li><a href="https://help.ubuntu.com/community/Java">https://help.ubuntu.com/community/JavaInstallation </a></li>
+       </ul>
+   </li>
+<li>Here are the steps to install Java and Eclipse, prior to installing
+the Android SDK and ADT Plugin.
+<ol>
+    <li>If you are running a 64-bit distribution on your development
+machine, you need to install the <code>ia32-libs</code> package using
+<code>apt-get:</code>:
+        <pre>apt-get install ia32-libs</pre></li>
+    <li>Next, install Java:
+        <pre>apt-get install sun-java6-bin</pre></li>
+    <li>The Ubuntu package manager does not currently offer an Eclipse 3.3
+    version for download, so we recommend that you download Eclipse from
+eclipse.org (<a
+href="http://www.eclipse.org/downloads/">http://www.eclipse.org/
+downloads/</a>). A Java or RCP version of Eclipse is recommended.</li>
+<li>Follow the steps given in previous sections to install the SDK 
+and the ADT plugin. </li>
+</ol>
+</ul>
+<h4>Other Linux Notes</h4>
+<ul>
+    <li>If JDK is already installed on your development computer, please
+take a moment to make sure that it meets the version requirements listed
+at the top of this page. In particular, note that some Linux
+distributions may include JDK 1.4 or Gnu Compiler for Java, both of
+which are not supported for Android development.</li>
+</ul>
+
+
diff --git a/docs/html/sdk/1.0_r1/requirements.jd b/docs/html/sdk/1.1_r1/requirements.jd
similarity index 81%
rename from docs/html/sdk/1.0_r1/requirements.jd
rename to docs/html/sdk/1.1_r1/requirements.jd
index 6af3900..95b658b 100644
--- a/docs/html/sdk/1.0_r1/requirements.jd
+++ b/docs/html/sdk/1.1_r1/requirements.jd
@@ -1,18 +1,20 @@
-page.title=System and Software Requirements
+page.title=System Requirements
+
+sdk.version=1.1_r1
+sdk.date=February 2009
+
 @jd:body
 
+<p>The sections below describe the system and software requirements for developing Android applications using the Android SDK tools included in Android 1.1 SDK, Release 1. </p>
 
-<p>To develop Android applications using the code and tools in the Android SDK, 
-you need a suitable development computer and development environment, as described below.</p>
-
-<p><strong>Supported Operating Systems:</strong></p>
+<h3>Supported Operating Systems</h3>
 <ul>
-  <li>Windows XP or Vista</li>
+  <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 (tested on Linux Ubuntu Dapper Drake)</li>
 </ul>
 
-<p><strong>Supported Development Environments:</strong></p>
+<h3>Supported Development Environments</h3>
 <ul>
   <li>Eclipse IDE
     <ul>
diff --git a/docs/html/sdk/1.1_r1/upgrading.jd b/docs/html/sdk/1.1_r1/upgrading.jd
new file mode 100644
index 0000000..aa7c3a5
--- /dev/null
+++ b/docs/html/sdk/1.1_r1/upgrading.jd
@@ -0,0 +1,185 @@
+page.title=Upgrading the SDK
+sdk.version=1.1_r1
+@jd:body
+
+<!--
+<div class="sidebox-wrapper">
+  <div class="sidebox-inner">
+
+     <h2>Useful Links</h2>
+
+      <ul class="noindent">
+        <li><a href="migrating/0.9-1.0/changes-overview.html">Overview of Changes</a>
+		      <p>A high-level look at what's changed in Android, with 
+		       discussion of how the changes may affect your apps.</p></li>
+
+        <li><a href="migrating/0.9-1.0/changes.html">API Diff Report</a> 
+                <p>A detailed report that lists all the specific changes in the latest SDK.</p></li>
+
+        <li><a href="RELEASENOTES.html">Release Notes</a> 
+                <p>Version details, known issues, and resolved issues. </p></li>
+
+        <li><a href="http://groups.google.com/group/android-developers">Android Developers Group</a> 
+            <p>A forum where you can discuss migration issues and learn from other Android developers. </p></li>
+ 
+        <li><a href="http://code.google.com/p/android/issues/list">Android Issue Tracker</a>
+            <p>If you think you may have found a bug, use the issue tracker to report it.</p></li>
+      </ul>
+
+   </div>
+</div>
+-->
+
+<p>This document describes how to move your devlopment environment and existing
+Android applications from an Android 1.0 SDK to the Android 1.1, Release 1 SDK.
+If you are migrating applications from an earlier SDK, please read the upgrading
+document available in the Android 1.0 SDK package.
+</p>
+
+<p>To ensure that your applications are compliant with the Android 1.1 system available 
+on mobile devices, you need to install the Android 1.1 SDK and port your existing Android 
+applications to it. The sections below guide you through the process.</p>
+
+<h2 id="install-new">Installing the Latest SDK</h2>
+
+<p><a href="{@docRoot}sdk/1.1_r1/index.html">Download the SDK</a> and unpack it into a safe location.</p>
+
+<p>After unpacking the new SDK, you should:</p>
+
+<ul>
+  <li>Wipe your emulator data. <p>Some data formats have changed since the last
+  SDK release, so any previously saved data in your emulator must be removed. Open a console/terminal
+  and navigate to the <code>/tools</code> directory of your SDK. Launch the 
+  emulator with the <code>-wipe-data</code> option. 
+  <p>Windows: <code>emulator -wipe-data</code><br/>
+   Mac/Linux: <code>./emulator -wipe-data</code></p>
+  </li>
+  <li>Update your PATH variable (Mac/Linux; optional). <p>If you had previously setup your 
+  PATH variable to point to the SDK tools directory, then you'll need to update it to 
+  point to the new SDK. For example, for a <code>.bashrc</code> or <code>.bash_profile</code> file:
+  <code>export PATH=$PATH:<em>&lt;your_new_sdk_dir></em>/tools</code></p>
+  </li>
+  <li>If (and only if) you are developing using Ant, you will also need to modify 
+  your build.xml properties to point to the new SDK. 
+  <p>Open the <code>default.properties</code> file associated with your build.xml 
+  file (typically located in the same directory). In the default.properties
+  file, update the <code>sdk-folder</code> property with the full path to
+  the new SDK directory.</p></li>
+</ul>
+
+<a name="Updating_the_ADT_plugin" id="Updating_the_ADT_plugin"></a>
+<h2 id="update-plugin">Update your ADT Eclipse Plugin</h2>
+
+<p>If you develop on Eclipse and are migrating from an Android 1.0
+SDK, no update of the ADT plugin is needed. </p>
+
+<p>If you are migrating from an earlier version of the SDK, you will
+need to update the ADT plugin. <p>You may also want to upgrade your 
+ADT plugin when a new version becomes available for your existing version 
+of the SDK.</p>
+
+<p>The steps below describe how to update the ADT plugin to the latest
+version available. </p>
+
+<table style="font-size:100%">
+<tr><th>Eclipse 3.3 (Europa)</th><th>Eclipse 3.4 (Ganymede)</th></tr>
+<tr>
+<td width="50%">
+<ol>
+    <li> Select <strong>Help</strong> &gt; <strong>Software Updates</strong> &gt; <strong>Find and Install...</strong>. </li>
+    <li> Select <strong>Search for updates of the currently installed features</strong> and click <strong>Finish</strong>. </li>
+    <li> If any update for ADT is available, select and install. </li>
+    <li> Restart Eclipse.</li>
+</ol>
+<p> Alternatively, </p>
+<ol>
+    <li> Select <strong>Help</strong> &gt; <strong>Software Updates</strong> &gt; <strong>Manage Configuration</strong>. </li>
+
+    <li> Navigate down the tree and select <strong>Android Development Tools &lt;version&gt;</strong> </li>
+    <li> Select <strong>Scan for Updates</strong> under <strong>Available Tasks</strong>.</li>
+</ol>
+</td>
+<td>
+<ol>
+    <li>Select <strong>Help</strong> &gt; <strong>Software Updates...</strong></li>
+    <li>Select the <strong>Installed Software</strong> tab.</li>
+    <li>Click <strong>Update...</strong></li>
+    <li>If an update for ADT is available, select it and click <strong>Finish</strong>.</li>
+    <li>Restart Eclipse.</li>
+</ol>
+</td>
+</tr>
+</table>
+
+<p>After restart, update your Eclipse preferences to point to the SDK directory:</p>
+    <ol>
+      <li>Select <strong>Window</strong> > <strong>Preferences...</strong> to open the Preferences panel. (Mac OSX: <strong>Eclipse</strong> > <strong>Preferences</strong>)</li>
+      <li>Select <strong>Android</strong> from the left panel.</li>
+      <li>For the SDK Location in the main panel, click <strong>Browse...</strong> and locate the SDK directory.</li>
+      <li>Click <strong>Apply</strong>, then <strong>OK</strong>.</li>
+    </ol>
+
+
+<!--
+<h2 id="sign">Set Up Application Signing</h2>
+
+<p>All applications must now be signed before you can install them on the emulator. Both 
+the ADT plugin and the Ant-based build tools support this requirement by signing compiled 
+.apk files with a debug key. To do so, the build tools use the Keytool utility included 
+in the JDK to to create a keystore and a key with a known alias and password. For more 
+information, see <a href="{@docRoot}guide/publishing/app-signing.html">Signing Your Applications</a>.
+
+<p>To support signing, you should first make sure that Keytool is available to the SDK build 
+tools. In most cases, you can tell the SDK build tools how to find Keytool by making sure that 
+your JAVA_HOME environment variable is set and that it references a suitable JDK. Alternatively, 
+you can add the JDK version of Keytool to your PATH variable.</p>
+
+<p>If you are developing on a version of Linux that originally came with Gnu Compiler for Java, 
+make sure that the system is using the JDK version of Keytool, rather than the gcj version. 
+If keytool is already in your PATH, it might be pointing to a symlink at /usr/bin/keytool. 
+In this case, check the symlink target to make sure that it points to the keytool in the JDK.</p>
+
+<p>If (and only if) you use Ant to build your .apk files (rather than ADT for Eclipse), you must regenerate 
+your build.xml file. To do that, follow these steps:</p>
+<ol>
+  <li>In your Android application project directory, locate and delete the current build.xml file.</li>
+  <li>Run activitycreator, directing output to the folder containing your application project.
+
+<pre>- exec activitycreator --out &lt;project folder&gt; your.activity.YourActivity</pre>
+
+  </li>
+</ol>
+
+<p>Run in this way, activitycreator will not erase or create new Java files (or manifest files), 
+provided the activity and package already exists. It is important that the package and the activity 
+are real. The tool creates a new build.xml file, as well as a new directory called "libs" in which 
+to place 3rd jar files, which are now automatically handled by the Ant script.</p>
+-->
+
+<h2 id="migrate">Migrate Your Applications, if Necessary</h2>
+
+<p>If (and only if) you have written apps in an SDK released previous to
+the Android 1.0 SDK, you will need to migrate your applications. After
+installing the new SDK and updating the ADT Plugin (if applicable), you
+may encounter breakages in your application code, due to 
+framework and API changes. You'll need to update your code to match the
+latest APIs.</p>
+
+<p>One way to start is to open your project in Eclipse and see where the ADT
+identifies errors in your application. From there, you can lookup
+specific API changes in the Android 1.0 APIs in the 
+<a href="http://code.google.com/android/migrating/changes-overview.html">
+Overview of Changes</a> and <a href="http://code.google.com/android/migrating/changes.html">
+API Diffs Report</a>.</p>
+
+<p>If you have additional trouble updating your code, visit the 
+<a href="http://groups.google.com/group/android-developers">Android Developers Group</a>
+to seek help from other Android developers.</p>
+
+<p>If you have modified one of the ApiDemos applications and would like to migrate it 
+to the new SDK, note that you will need to uninstall the version of ApiDemos that comes 
+preinstalled in the emulator. For more information, or if you encounter an "reinstallation" 
+error when running or installing ApiDemos, see the troubleshooting topic 
+<a href="{@docRoot}guide/appendix/faq/troubleshooting.html#apidemosreinstall">I can't install ApiDemos 
+apps in my IDE because of a signing error</a> for information about how to solve the problem.</p>
+
diff --git a/docs/html/sdk/RELEASENOTES.jd b/docs/html/sdk/RELEASENOTES.jd
new file mode 100644
index 0000000..6e0716c
--- /dev/null
+++ b/docs/html/sdk/RELEASENOTES.jd
@@ -0,0 +1,138 @@
+page.title=SDK Release Notes
+sdk.version=1.1_r1
+@jd:body
+
+<p>This document provides version-specific information about Android SDK releases. For the latest known issues, please ensure that you're viewing this page at: <a href="http://developer.android.com/sdk/RELEASENOTES.html">http://developer.android.com/sdk/RELEASENOTES.html</a>.</p>
+
+<h2>Android 1.1 SDK, Release 1</h2>
+
+<p>This SDK provides the development tools and Android system image you need to create applications for Android-powered devices. Applications developed on this SDK will be compatible with mobile devices running the Android 1.1 platform. </p>
+
+<p>This release provides an updated system image (Android 1.1), updated documentation, and the same set of development tools provided in the Android 1.0 r2 SDK. The updated system image includes bug fixes and some smaller features, as well as a few minor API changes from the 1.0 version. </p>
+
+<p>For details about the Android 1.1 system image included in the SDK &mdash; including bug fixes, features, and API changes &mdash; please read the <a href="{@docRoot}sdk/android-1.1.html">Android 1.1 Version Notes</a>.</p>
+
+<h3>App Versioning for Android 1.1</h3>
+
+<p>If you are using this SDK to build an application that is compatible <em>only</em> with Android-powered devices running the Android 1.1 platform, please note that you <strong>must</strong> set the the <code>android:minSdkVersion</code> attribute in the application's manifest to the API Level of Android 1.1 &mdash; "2".</p>
+
+<p>Specifically, you specify the <code>android:minSdkVersion</code> attribute in a <code>&lt;uses-sdk&gt;</code> element as a child of <code>&lt;manifest&gt;</code> in the manifest file. When set, the attribute looks like this: </p>
+
+<pre><code>&lt;manifest&gt;
+  ...
+  &lt;uses-sdk minSdkVersion="2"&gt;
+  ...
+&lt;/manifest&gt;</code>
+</pre>
+
+<p>By setting <code>android:minSdkVersion</code> in this way, you ensure that users will only be able to install your application if their devices are running the Android 1.1 platform. In turn, this ensures that your application will function properly on their devices, especially if it uses APIs introduced in Android 1.1. </p>
+
+<p>If your application uses APIs introduced in Android 1.1 but does not declare <code>&lt;uses-sdk minSdkVersion="2"&gt;</code>, then it will run properly on Android 1.1 devices but <em>not</em> on Android 1.0 devices. </p>
+
+<p>If your application does not use any new APIs introduced in Android 1.1, you can indicate Android 1.0 compatibility by removing <code>minSdkVersion</code> or setting the attribute to "1". However, before publishing your application, you must make sure to compile your application against the Android 1.0 system image (available in the Android 1.0 SDK), to ensure that it builds and functions properly for Android 1.0 devices. You should test the application against system images corresponding to the API Levels that the application is designed to be compatible with.</p>
+
+<p>If you are sure your application is not using Android 1.1 APIs and has no need to use them, you might find it easier to keep working in the Android 1.0 SDK, rather than migrating to the Android 1.1 SDK and having to do additional testing.</p>
+
+
+<h3>ADT Plugin Compatibility</h3>
+
+<p>For this version of the SDK &mdash; Android 1.1 SDK, Release 1
+&mdash; the compatible version of the Android Development Tools (ADT)
+Plugin for Eclipse is <strong>0.8.0</strong>. If you are using a
+previous version of ADT, you should update to the latest version for use
+with this SDK. For information about how to update your ADT plugin, see
+<a href="{@docRoot}sdk/1.1_r1/upgrading.html#update-plugin">Upgrading
+the SDK</a>.</p>
+
+<h3>Installation and Upgrade Notes</h3>
+
+<p>If you've been developing an application using an Android 1.0 SDK no
+changes to your application are needed. You may want to wipe application
+user data (emulator option <code>-wipe-data</code>) when running your
+application on the Android 1.1 emulator for the first time.</p>
+
+<p>If you're installing the Android SDK for the first time, please see
+the instructions in <a
+href="{@docRoot}sdk/1.1_r1/installing.html">Installing the SDK</a>.
+
+<h3>Other Notes</h3>
+
+<p><strong>MapView API Key</strong></p>
+
+<p>com.google.android.maps.MapView is a class that lets you
+easily integrate Google Maps into your application. Before you can
+access the maps data, you will need to register with the Google Maps
+service and receive a Maps API Key, which you then add to your MapView
+for authentication to the server.</p>
+
+<p>Developers should note that the registration service for MapView is now
+active and Google Maps is actively enforcing the Maps API Key requirement. 
+For information about how to register for a Maps API Key, see 
+<a href="{@docRoot}guide/topics/location/geo/mapkey.html">
+Obtaining a Maps API Key</a>.</p>
+
+<p><strong>USB Drivers for Windows</strong></p>
+
+<p>If you using Windows and want to develop or test your application on an
+Android-powered device (such as the T-Mobile G1), you need an appropriate USB
+driver. For your convenience, the Windows version of the Android SDK includes
+these USB drivers that you can install, to let you develop on the device:</p>
+
+<ul>
+<li>USB driver for 32-bit XP and Vista</li>
+<li>USB driver for 64-bit Vista only</li>
+</ul>
+
+<p>The USB driver files are located in the
+<code>&lt;SDK&gt;/usb_driver</code> directory. For details and
+installation instructions, see <a
+href="{@docRoot}guide/developing/device.html#setting-up">Setting Up a
+Device for Development</a>.</p>
+</p>
+
+<h3>Resolved Issues, Changes</h3>
+
+<p><strong>Emulator</strong></p>
+<ul>
+<li>Emulator now saves the user image in &lt;android&gt;/SDK1.1/</code></li>
+</ul>
+
+<h3>Known Issues</h3>
+
+<p><strong>JUnit and Eclipse/ADT</strong></p>
+<ul>
+<li>If you are developing in Eclipse/ADT and want to add JUnit test
+classes, you can do so. However, you need to set up a custom JUnit configuration
+before your tests will run properly. For detailed information about how to set
+up the JUnit configuration, see the troubleshooting topic <a
+href="{@docRoot}guide/appendix/faq/troubleshooting.html#addjunit">Running a Junit test class
+in Eclipse</a>.</li>
+</ul>
+
+<p><strong>Other</strong></p>
+
+<ul>
+<li>It is not possible to send MMS messages between emulator instances. </li>
+<li>In some cases, you may encounter problems when using the browser on an
+emulator started with the command-line option <code>-http-proxy</code>. </li>
+<li>We regret to inform developers that Android 1.1 will not include support for
+dot-matrix printers.</li>
+<li>On the OSX platform, if you manually remove the ~/.android directory
+using <code>rm -rf ~/.android</code>, then try to run 
+the emulator, it crashes. This happens because the emulator fails to create 
+a new .android directory before attempting to create the child SDK1.0 directory.
+To work around this issue, manually create a new .android directory using
+<code>mkdir ~/.android</code>, then run the emulator. The emulator 
+creates the SDK1.0 directory and starts normally. </li>
+<li>The final set of Intent patterns honored by Android 1.0 has not yet been
+fully documented. Documentation will be provided in future releases.</li>
+<li>In ADT Editor, you can add at most ten new resource values at a time,
+in a given res/values/*.xml, using the form in the Android Resources pane. 
+If you add more than ten, the Android Resources pane will not display the
+attributes fields for the additional resource entries. To work around this 
+problem, you can close the file in the editor and open it again, or you 
+can edit the resource entries in the XML text mode. </li>
+<li>The emulator's battery-control commands (<code>power &lt;option&gt</code>)
+are not working in this release.</li>
+</ul>
+
diff --git a/docs/html/guide/developing/tools/adt_download.jd b/docs/html/sdk/adt_download.jd
similarity index 90%
rename from docs/html/guide/developing/tools/adt_download.jd
rename to docs/html/sdk/adt_download.jd
index f03cc46..6e9eec4 100644
--- a/docs/html/guide/developing/tools/adt_download.jd
+++ b/docs/html/sdk/adt_download.jd
@@ -29,8 +29,8 @@
      <td style="background-color:#ffcccc;">0.8.0</td>
      <td style="background-color:#ffcccc;"><a href="http://dl-ssl.google.com/android/ADT-0.8.0.zip">ADT-0.8.0.zip</a></td>
      <td style="background-color:#ffcccc;">23&nbsp;September&nbsp;2008</td>
-     <td style="background-color:#ffcccc;">Android&nbsp;1.0&nbsp;SDK,&nbsp;Release&nbsp;1</td>
-     <td style="background-color:#ffcccc;">Required for users of Android 1.0 SDK, Release&nbsp;1. </td>
+     <td style="background-color:#ffcccc;">Android&nbsp;1.1&nbsp;SDK,&nbsp;Release&nbsp;1<br />Android&nbsp;1.0&nbsp;SDK,&nbsp;Release&nbsp;1<br /></td>
+     <td style="background-color:#ffcccc;">Required for users of Android 1.1 SDK, Release&nbsp;1 and Android&nbsp;1.0&nbsp;SDK,&nbsp;Release&nbsp;1<br /> </td>
   </tr>
   <tr>
      <td>0.7.1</td>
diff --git a/docs/html/sdk/android-1.1.jd b/docs/html/sdk/android-1.1.jd
new file mode 100644
index 0000000..8e63ba3
--- /dev/null
+++ b/docs/html/sdk/android-1.1.jd
@@ -0,0 +1,250 @@
+page.title=Android 1.1 Version Notes
+sdk.version=1.1_r1
+sys.date=February 2009
+@jd:body
+
+<p>
+<em>Date:</em> February 2009<br />
+<em>API Level:</em>&nbsp;<strong>2</strong></p>
+
+
+<p>This document provides version notes for the Android 1.1 system image included in the SDK. 
+
+<ul>
+<li><a href="#overview">Overview</a>
+<li><a href="#overview">External Libraries</a>
+<li><a href="#comp">Device Compatibility</a>
+<li><a href="#apps">Built-in Applications</a>
+<li><a href="#locs">UI Localizations</a>
+<li><a href="#resolved-issues">Resolved Issues</a>
+<li><a href="#features">New Features</a>
+<li><a href="#api-changes">API Changes</a>
+</ul></p>
+
+<h2 id="overview">Overview</h2>
+
+<p>The Android 1.1 system image delivered in the SDK is the development
+counterpart to the Android 1.1 production system image, deployable to
+Android-powered handsets starting in February 2009. </p>
+
+<p>The Android 1.1 system image delivers an updated version of the framework
+API. As with the Android 1.0 API, the Android 1.1 API 
+is assigned an integer identifier &mdash; <strong>2</strong> &mdash; that is
+stored in the system itself. This identifier, called the "API Level", allows the
+system to correctly determine whether an application is compatible with
+the system, prior to installing the application.</p>
+
+<p>Applications can reference a specific API Level value in their
+manifest files, to indicate the minimum version of the Android system
+required to run the app. To reference a minimum API Level, applications 
+can add a <code>minSdkVersion</code> attribute in their manifest files.
+The value of the attribute is an integer corresponding to an API Level 
+identifier. Prior to installing an application, the system then checks the value of 
+<code>minSdkVersion</code> and allows the install only
+if the referenced integer is less than or equal to the API Level integer stored
+in the system itself. </p>
+
+<p>If you use the Android 1.1 system image to build an application
+compatible with Android-powered devices running the Android 1.1
+platform, please note that you <strong><span
+style="color:red;">must</span></strong> set the the
+<code>android:minSdkVersion</code> attribute in the application's
+manifest to "2", which is the API strictly associated with Android 1.1.
+</p>
+
+<p>Specifically, you specify the <code>android:minSdkVersion</code>
+attribute in a <code>&lt;uses-sdk&gt;</code> element as a child of
+<code>&lt;manifest&gt;</code> in the manifest file. When set, the
+attribute looks like this: </p>
+
+<pre><code>&lt;manifest&gt;
+  ...
+  &lt;uses-sdk minSdkVersion="2"&gt;
+  ...
+&lt;/manifest&gt;</code>
+</pre>
+
+<p>By setting <code>android:minSdkVersion</code> in this way, you ensure
+that users will only be able to install your application if their
+devices are running the Android 1.1 platform. In turn, this ensures that
+your application will function properly on their devices, especially if
+it uses <a href="#apichange">APIs introduced in Android 1.1</a>. </p>
+
+<p>If your application uses APIs introduced in Android 1.1 but does not
+declare <code>&lt;uses-sdk minSdkVersion="2"&gt;</code>, then it will
+run properly on Android 1.1 devices but <em>not</em> on Android 1.0
+devices. In the latter case, the application will crash at runtime when
+it tries to use the Android 1.1 APIs.</p>
+
+<p>If your application does not use any new APIs introduced in Android
+1.1, you can indicate Android 1.0 compatibility by removing
+<code>minSdkVersion</code> or setting the attribute to "1". However,
+before publishing your application, you must make sure to compile your
+application against the Android 1.0 system image (available in the
+Android 1.0 SDK), to ensure that it builds and functions properly for
+Android 1.0 devices. You should test the application against system
+images corresponding to the API Levels that the application is designed
+to be compatible with.</p>
+
+<p>If you are sure your application is not using Android 1.1 APIs and
+has no need to use them, you might find it easier to keep working in the
+Android 1.0 SDK, rather than migrating to the Android 1.1 SDK and having
+to do additional testing.</p>
+
+
+<h2 id="extlibs">External Libraries</h2>
+
+<p>The system image includes these external libraries, which you can
+access from your application by adding a <a
+href="{@docRoot}guide/topics/manifest/uses-library-element.html">
+&lt;uses-library&gt;</a>.</p>
+	<ul>
+	<li>com.google.android.maps &mdash; gives your
+application access to Google Maps data. Note that, to use Google Maps
+data, a Maps API Key is required.</li>
+	</ul>
+
+<h2 id="comp">Device Compatibility</h2>
+
+<p>The Android 1.1 system image was tested for compatability with the
+Android-powered devices listed below:</p>
+	<ul>
+	<li><a href="http://www.t-mobileg1.com">T-Mobile G1</a></li>
+	</ul>
+
+<h2 id="apps">Built-in Applications</h2>
+
+<p>The system image includes these built-in applications:</p>
+	<ul>
+	<li>Alarm Clock</li>
+	<li>API Demos</li>
+	<li>Browser</li>
+	<li>Calculator</li>
+	<li>Camera</li>
+	<li>Contacts</li>
+	<li>Dev Tools</li>
+	<li>Dialer</li>
+	<li>Email</li>
+	<li>Maps (and StreetView)</li>
+	<li>Messaging</li>
+	<li>Music</li>
+	<li>Pictures</li>
+	<li>Settings</li>
+	</ul>
+
+<h2 id="locs">UI Localizations</h2>
+
+<p>The system image provides localized UI strings for the languages
+listed below.</p>
+	<ul>
+	<li>English, US (en_US)</li>
+	<li>German (de) </li>
+	</ul>
+
+<p>Localized UI strings match the locales that are displayable in 
+the emulator, accessible through the device Settings application.</p>
+
+<h2 id="resolved-issues">Resolved Issues</h2>
+<ul>
+<li>AlarmClock alert now plays audio/vibe directly, rather than through
+AlarmManager. AlarmClock alert starts playing audio/vibe in its
+IntentReceiver, rather than on activity start. These changes should
+prevent alarms from being blocked by modal dialogs.</li>
+<li>Fixes to device sleep. </li>
+<li>Single tap no longer opens the in-call dialpad; users now need to
+touch and drag it. </li>
+<li>Fixes a bug causing approximately 1 in 25 outbound messages to
+freeze up the IMAP connection (to a Gmail based server) when transferred
+to the Sent folder.</li>
+<li>Removes automatic account setup entries that were broken or not
+testable. Adds minor fixes to a few of the remaining entries. Makes
+improvements to warning dialogs used for a few special cases.	</li>
+<li>Changes default mail checking interval to every 15 minutes (instead
+of defaulting to "never").</li>
+<li>Fixes password-quoting bugs in IMAP, so that users can include
+special characters in passwords (e.g. spaces).</li>
+<li>Fixes various errors in auto and manual account setup	</li>
+<li>Improves reporting for various connection errors, making it easier
+for the user to diagnose failed account setups.</li>
+<li>Fixes new-mail notifications for POP3 accounts.</li>
+<li>Ensures proper auto-checking of accounts marked as "never
+check".</li>
+<li>Now displays date and time using user preference (e.g. 24 hr vs.
+AM/PM).</li>
+<li>Now shows cc: in message view.</li>
+<li>Improves recovery from POP3 connection failures.</li>
+<li>POP3 parser rules loosened, so the application can work with
+non-compliant email servers.</li>
+<li>Removes green CALL button as a shortcut for "add a new call".</li>
+</ul>
+
+<h2 id="features">New Features</h2>
+
+<ul>
+<li>Maps: Adds details and reviews when a user does a search on Maps and
+clicks on a business to view it's details.</li>
+<li>Dialer: In-call screen timeout default is now longer when using the
+speakerphone.</li>
+<li>Dialer: Adds a "Show dialpad" / "Hide dialpad" item to the in-call
+menu, to make it easier to discover the DTMF dialpad. </li>
+<li>Adds support for saving attachments from MMS</li>
+<li>Adds support for marquee in layouts.</li>
+</ul>
+
+<h2 id="api-changes">API Changes</h2>
+
+<h3>Overview</strong></h3>
+
+<ul>
+<li>Adds annotations for test systems, no actual (non-test) API
+changes.</li>
+<li>Adds a method to allow a process to easily determine its UID.
+<li>Adds support for marquee in layouts.</li>
+<li>Adds new methods for determining padding in views. Useful if you are
+writing your own
+subclasses of {@link android.view.View View}.</li>
+<li>Adds new permissions that allow an application to broadcast an SMS
+or WAP Push message. </li>
+<li>API cleanup: removes protected constructor from
+SDK-bound system images. </li>
+</ul>
+
+<h3>API Change Details</h3>
+
+<table>
+<tr>
+<th>Module or Feature</th><th>Change Description</th>
+</tr>
+<tr><td rowspan="4">Annotations for test systems</td></tr>
+    <tr><td>Added class {@link android.test.suitebuilder.annotation.LargeTest LargeTest} to package {@link android.test.suitebuilder.annotation}</td></tr>
+    <tr><td>Added class {@link android.test.suitebuilder.annotation.MediumTest MediumTest} to package {@link android.test.suitebuilder.annotation}</td></tr>
+    <tr><td>Added class {@link android.test.suitebuilder.annotation.SmallTest SmallTest} to package {@link android.test.suitebuilder.annotation}</td></tr>
+
+<tr><td rowspan="2">Allow a process to easily know its UID.</td></tr>
+    <tr><td>Added public method {@link android.os.Process#myUid} to class {@link android.os.Process android.os.Process}</td></tr>
+
+<tr><td rowspan="6">Padding in views</td></tr>
+    <tr><td>Added public method {@link android.view.View#getBottomPaddingOffset} to class {@link android.view.View android.view.View}.</td></tr>
+    <tr><td>Added public method {@link android.view.View#getLeftPaddingOffset} to class {@link android.view.View android.view.View}.</td></tr>
+    <tr><td>Added public method {@link android.view.View#getRightPaddingOffset} to class {@link android.view.View android.view.View}.</td></tr>
+    <tr><td>Added public method {@link android.view.View#getTopPaddingOffset} to class {@link android.view.View android.view.View}.</td></tr>
+    <tr><td>Added public method {@link android.view.View#isPaddingOffsetRequired} to class {@link android.view.View android.view.View}.</td></tr>
+
+<tr><td rowspan="3">Marquee support</td></tr>
+    <tr><td>Added public method {@link android.widget.TextView#setMarqueeRepeatLimit} to class {@link android.widget.TextView}</td></tr>
+    <tr><td>Added public field {@link android.R.attr#marqueeRepeatLimit android.R.attr.marqueeRepeatLimit}</td></tr>
+
+<tr><td rowspan="3">New permissions</td></tr>
+    <tr><td>Added public field {@link android.Manifest.permission#BROADCAST_SMS android.Manifest.permission.BROADCAST_SMS}</td></tr>
+    <tr><td>Added public field {@link android.Manifest.permission#BROADCAST_WAP_PUSH android.Manifest.permission.BROADCAST_WAP_PUSH}</td></tr>
+
+<tr><td rowspan="2">API cleanup</td></tr>
+    <tr><td>Removed protected constructor java.net.ServerSocket.ServerSocket(java.net.SocketImpl).</td></tr>
+
+</table>
+
+
+
+
+
+
diff --git a/docs/html/sdk/download.jd b/docs/html/sdk/download.jd
new file mode 100644
index 0000000..d64b781
--- /dev/null
+++ b/docs/html/sdk/download.jd
@@ -0,0 +1,76 @@
+page.title=Download the Android SDK
+@jd:body
+
+<p>Please carefully review the Android SDK License Agreement before downloading the SDK.
+The License Agreement constitutes a contract between you and Google with respect to your use of the SDK.</p>
+
+<iframe style="border:1px solid #888;margin:0 0 1em;height:400px;width:95%;" src="terms_body.html">
+</iframe>
+
+<script language="javascript">
+  function verify() {
+    document.getElementById('download_button').disabled = !document.getElementById('checkbox').checked;
+  }
+  function submit() {
+    var location = window.location.href;
+    if (location.indexOf('?v=') != -1) {
+      var filename = location.substring(location.indexOf('=')+1,location.length);
+      if (document.getElementById('checkbox').checked) {
+        document.location = "http://dl.google.com/android/" + filename;
+      }
+      document.getElementById('click_download').setAttribute("href", "http://dl.google.com/android/" + filename);
+      document.getElementById('next_steps').style.display = "block";
+    } else {
+      alert("You have not selected an SDK version. Please return to the Download page");
+    }
+  }
+</script>
+
+  <p>
+    <input type="checkbox" id="checkbox" onclick="verify()" />
+    <label for="checkbox">I agree to the terms of the Android SDK License Agreement.</label>
+  </p>
+  <p>
+    <input type="submit" value="Download" id="download_button" disabled="disabled" onclick="submit()" />
+  </p>
+  <p>
+  <script language="javascript">
+    var loc = window.location.href;
+    if (loc.indexOf('?v=') != -1) {
+      var filename = loc.substring(loc.indexOf('=')+1,loc.length);
+      document.write("File: " + filename);
+    }
+  </script>
+  </p>
+
+<noscript>
+  <p><strong>Please enable Javascript in your browser in order to agree to the terms and download the SDK.</strong></p>
+</noscript>
+
+<div class="special" id="next_steps" style="display:none">
+  <p>Your download should be underway. If not, <a id="click_download">click here to download</a>.</p>
+  <p>Continue your setup with one the following documents:</p>
+  <ul style="margin-top:.5em">
+    <li><a href="installing.html" class="addVersionPath">Installing</a> - If you are
+  installing the Android SDK for the first time.</li>
+    <li><a href="upgrading.html" class="addVersionPath">Upgrading</a> - If you are
+  upgrading from a previously installed version of the Android SDK.</li>
+  </ul>
+</div>
+
+<script language="javascript">
+  var loc = window.location.href;
+  var filename = loc.substring(loc.indexOf('=')+1,loc.length);
+  version = filename.substring(filename.indexOf('.')-1,filename.lastIndexOf('.'));
+  $(".addVersionPath").each(function(i) {
+    var oldHref = $(this).attr("href");
+    $(this).attr({href: "/sdk/" + version + "/" + oldHref});
+  });
+</script>
+
+
+
+
+
+
+
diff --git a/docs/html/sdk/index.html b/docs/html/sdk/index.html
deleted file mode 100644
index c5468dd..0000000
--- a/docs/html/sdk/index.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<head>
-<title>Redirecting...</title>
-<meta http-equiv="refresh" content="0;url=1.0_r1/index.html">
-</head>
-</html>
\ No newline at end of file
diff --git a/docs/html/sdk/index.jd b/docs/html/sdk/index.jd
new file mode 100644
index 0000000..38db6f8
--- /dev/null
+++ b/docs/html/sdk/index.jd
@@ -0,0 +1,5 @@
+sdk.redirect=1.1_r1
+@jd:body
+
+
+
diff --git a/docs/html/sdk/sdk_toc.cs b/docs/html/sdk/sdk_toc.cs
index 11d3086..f617302 100644
--- a/docs/html/sdk/sdk_toc.cs
+++ b/docs/html/sdk/sdk_toc.cs
@@ -1,37 +1,20 @@
+
 <ul>
-
-  <li><h2>Android 1.0</h2>
+  <li><h2>Latest SDK Release</h2>
     <ul>
-      <li><strong><a href="<?cs var:toroot ?>sdk/1.0_r1/index.html">Release 1</a></strong>
-        <ul>
-          <li><a href="<?cs var:toroot ?>sdk/1.0_r1/RELEASENOTES.html">Release Notes</a></li>
-        </ul>
-      </li>
-
-      <li><strong><a href="<?cs var:toroot ?>sdk/1.0_r2/index.html">Release 2</a></strong>
-        <ul>
-          <li><a href="<?cs var:toroot ?>sdk/1.0_r2/RELEASENOTES.html">Release Notes</a></li>
-        </ul>
-      </li>
-
+      <li><a href="<?cs var:toroot ?>sdk/1.1_r1/index.html">Download</a></li>
+      <li><a href="<?cs var:toroot ?>sdk/1.1_r1/installing.html">Installing</a></li>
+      <li><a href="<?cs var:toroot ?>sdk/1.1_r1/upgrading.html">Upgrading</a></li>
+      <li><a href="<?cs var:toroot ?>sdk/1.1_r1/requirements.html">System Requirements</a></li>
+      <li><a href="<?cs var:toroot ?>sdk/RELEASENOTES.html">SDK Release Notes</a></li>
+    </ul>
+    <ul>
+      <li><a href="<?cs var:toroot ?>sdk/android-1.1.html">Android 1.1 Version Notes</a></li>
     </ul>
   </li>
-<!-- just a template
-  <li><h2>Android 1.1</h2>
-    <ul>
-      <li><strong><a href="<?cs var:toroot ?>sdk/1.1_r1/index.html">Release 1</a></strong>
-        <ul>
-          <li><a href="<?cs var:toroot ?>sdk/1.1_r1/RELEASENOTES.html">Release Notes</a></li>
-        </ul>
-      </li>
-      <li><strong><a href="<?cs var:toroot ?>sdk/1.1_r2/index.html">Release 2</a></strong>
-        <ul>
-          <li><a href="<?cs var:toroot ?>sdk/1.1_r2/RELEASENOTES.html">Release Notes</a></li>
-        </ul>
-      </li>
-    </ul>
-  </li>
--->
-  <li><a href="<?cs var:toroot ?>sdk/terms.html">Terms and Conditions</a></li>
+</ul>
+<ul>
+  <li><a href="<?cs var:toroot ?>sdk/terms.html">SDK Terms and Conditions</a></li>
+  <li><a href="http://code.google.com/android/download_list.html">Previous SDK Releases</a></li>
 </ul>
 
diff --git a/docs/html/sdk/terms.jd b/docs/html/sdk/terms.jd
index 5599fa6..72e5bd0 100644
--- a/docs/html/sdk/terms.jd
+++ b/docs/html/sdk/terms.jd
@@ -1,4 +1,5 @@
 page.title=Terms and Conditions
+sdk.version=1.1_r1
 @jd:body
 
 <p>This is the Android Software Development Kit License Agreement.</p>
diff --git a/docs/html/sdk/terms_body.html b/docs/html/sdk/terms_body.html
new file mode 100644
index 0000000..e8fdc3c
--- /dev/null
+++ b/docs/html/sdk/terms_body.html
@@ -0,0 +1,216 @@
+
+<p>This is the Android Software Development Kit License Agreement.</p>
+
+<h2>
+	1. Introduction
+</h2>
+<p>
+	1.1 The Android Software Development Kit (referred to in this License Agreement as the "SDK" and specifically including the Android system files and packaged APIs) is licensed to you subject to the terms of this License Agreement. This License Agreement forms a legally binding contract between you and Google in relation to your use of the SDK.
+</p>
+<p>
+	1.2 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
+</p>
+<h2>
+	2. Accepting this License Agreement
+</h2>
+<p>
+	2.1 In order to use the SDK, you must first agree to this License Agreement. You may not use the SDK if you do not accept this License Agreement.
+</p>
+<p>
+	2.2 You can accept this License Agreement by:
+</p>
+<p>
+	(A) clicking to accept or agree to this License Agreement, where this option is made available to you; or
+</p>
+<p>
+	(B) by actually using the SDK. In this case, you agree that use of the SDK constitutes acceptance of the Licensing Agreement from that point onwards.
+</p>
+<p>
+	2.3 You may not use the SDK and may not accept the Licensing Agreement if you are a person barred from receiving the SDK under the laws of the United States or other countries including the country in which you are resident or from which you use the SDK.
+</p>
+<p>
+	2.4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other entity, you represent and warrant that you have full legal authority to bind your employer or such entity to this License Agreement. If you do not have the requisite authority, you may not accept the Licensing Agreement or use the SDK on behalf of your employer or other entity.
+</p>
+<h2>
+	3. SDK License from Google
+</h2>
+<p>
+	3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide, royalty-free, non- assignable and non-exclusive license to use the SDK solely to develop applications to run on the Android platform.
+</p>
+<p>
+	3.2 You agree that Google or third parties own all legal right, title and interest in and to the SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. The Android Open Source Project
+</p>
+<p>
+	3.3 Except to the extent required by applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the SDK or any part of the SDK. Except to the extent required by applicable third party licenses, you may not load any part of the SDK onto a mobile handset or any other hardware device except a personal computer, combine any part of the SDK with other software, or distribute any software or device incorporating a part of the SDK.
+</p>
+<p>
+	3.4 Use, reproduction and distribution of components of the SDK licensed under an open source software license are governed solely by the terms of that open source software license and not this License Agreement.
+</p>
+<p>
+	3.5 You agree that the form and nature of the SDK that Google provides may change without prior notice to you and that future versions of the SDK may be incompatible with applications developed on previous versions of the SDK. You agree that Google may stop (permanently or temporarily) providing the SDK (or any features within the SDK) to you or to users generally at Google's sole discretion, without prior notice to you.
+</p>
+<p>
+	3.6 Nothing in this License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
+</p>
+<p>
+	3.7 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the SDK.
+</p>
+<h2>
+	4. Use of the SDK by You
+</h2>
+<p>
+	4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under this License Agreement in or to any software applications that you develop using the SDK, including any intellectual property rights which subsist in those applications.
+</p>
+<p>
+	4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) this License Agreement and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
+</p>
+<p>
+	4.3 You agree that if you use the SDK to develop applications for general public users, you will protect the privacy and legal rights of those users. If the users provide you with user names, passwords, or other login information or personal information, your must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If the user provides your application with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, the user has given you permission to do so.
+</p>
+<p>
+	4.4 You agree that you will not engage in any activity with the SDK, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of any third party including, but not limited to, Google or any mobile communications carrier.
+</p>
+<p>
+	4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through the Android platform and/or applications for the Android platform, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.
+</p>
+<p>
+	4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under this License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.
+</p>
+<h2>
+	5. Your Developer Credentials
+</h2>
+<p>
+	5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.
+</p>
+<h2>
+	6. Privacy and Information
+</h2>
+<p>
+	6.1 In order to continually innovate and improve the SDK, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the SDK are being used and how they are being used. Before any of this information is collected, the SDK will notify you and seek your consent. If you withhold consent, the information will not be collected.
+</p>
+<p>
+	6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in accordance with Google's Privacy Policy.
+</p>
+<h2>
+	7. Third Party Applications for the Android Platform
+</h2>
+<p>
+	7.1 If you use the SDK to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.
+</p>
+<p>
+	7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.
+</p>
+<p>
+	7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party. In that case, this License Agreement does not affect your legal relationship with these third parties.
+</p>
+<h2>
+	8. Using Android APIs
+</h2>
+<p>
+	8.1 Android Maps API
+</p>
+<p>
+	8.1.1 If you use the Android Maps API (described in the SDK by the Package names "com.google.android.maps" and "com.android.location.Geocoder"), the terms of your binding legal agreement with Google include this License Agreement, the <a href="http://www.google.com/apis/maps/terms.html">Google Maps API Terms of Service</a> and the <a href="http://www.google.com/intl/en_ALL/help/terms_local.html">Google Maps Terms of Service</a>. You must read and agree to those Terms of Service before you use the Android Maps API.
+</p>
+<p>
+	8.1.2 If you use the Android Maps API to retrieve map or satellite image data from Google, you must include the following copyright notice in your application or service in a manner that is reasonably available to users:
+</p>
+<p>
+	"Copyright Notice: Data: (c)2007 TeleAtlas, AND, Europa Technologies, Kingway, Map Data Sciences Pty Ltd, PSMA, ZENRIN, Geocentre, MapLink/TeleAtlas; Imagery: (c)2007 DigitalGlobe, EarthSat, Sanborn, NYGIS, Scankort, TerraMetrics, MassGIS Commonwealth of Massachusetts, Digital Earth Technology."
+</p>
+<p>
+	8.2 Google Data APIs
+</p>
+<p>
+	8.2.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by those who provide that data (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless you have been specifically given permission to do so by the owners of that data.
+</p>
+<p>
+	8.2.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so.
+</p>
+<h2>
+	9. Terminating this License Agreement
+</h2>
+<p>
+	9.1 This License Agreement will continue to apply until terminated by either you or Google as set out below.
+</p>
+<p>
+	9.2 If you want to terminate this License Agreement, you may do so by ceasing your use of the SDK and any relevant developer credentials.
+</p>
+<p>
+	9.3 Google may at any time, terminate this License Agreement with you if:
+</p>
+<p>
+	(A) you have breached any provision of this License Agreement; or
+</p>
+<p>
+	(B) Google is required to do so by law; or
+</p>
+<p>
+	(C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated its relationship with Google or ceased to offer certain parts of the SDK to you; or
+</p>
+<p>
+	(D) Google decides to no longer providing the SDK or certain parts of the SDK to users in the country in which you are resident or from which you use the service, or the provision of the SDK or certain SDK services to you by Google is, in Google's sole discretion, no longer commercially viable.
+</p>
+<p>
+	9.4 When this License Agreement comes to an end, all of the legal rights, obligations and liabilities that you and Google have benefited from, been subject to (or which have accrued over time whilst this License Agreement has been in force) or which are expressed to continue indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall continue to apply to such rights, obligations and liabilities indefinitely.
+</p>
+<h2>
+	10. DISCLAIMER OF WARRANTIES
+</h2>
+<p>
+	10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
+</p>
+<p>
+	10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.
+</p>
+<p>
+	10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+</p>
+<h2>
+	11. LIMITATION OF LIABILITY
+</h2>
+<p>
+	11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
+</p>
+<h2>
+	12. Indemnification
+</h2>
+<p>
+	12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you with this License Agreement.
+</p>
+<h2>
+	13. Changes to the License Agreement
+</h2>
+<p>
+	13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK. When these changes are made, Google will make a new version of the License Agreement available on the website where the SDK is made available and with the SDK downloadable.
+</p>
+<p>
+	13.2 You agree that your use of a specific version of the SDK is governed by the License Agreement included with that version of the SDK.
+</p>
+<h2>
+	14. General Legal Terms
+</h2>
+<p>
+	14.1 This License Agreement constitute the whole legal agreement between you and Google and govern your use of the SDK (excluding any services which Google may provide to you under a separate written agreement), and completely replace any prior agreements between you and Google in relation to the SDK.
+</p>
+<p>
+	14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in this License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.
+</p>
+<p>
+	14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of this License Agreement is invalid, then that provision will be removed from this License Agreement without affecting the rest of this License Agreement. The remaining provisions of this License Agreement will continue to be valid and enforceable.
+</p>
+<p>
+	14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to this License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of this License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to this License Agreement.
+</p>
+<p>
+	14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
+</p>
+<p>
+	14.6 The rights granted in this License Agreement may not be assigned or transferred by either you or Google without the prior written approval of the other party. Neither you nor Google shall be permitted to delegate their responsibilities or obligations under this License Agreement without the prior written approval of the other party.
+</p>
+<p>
+	14.7 This License Agreement, and your relationship with Google under this License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from this License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
+</p>
+<p>
+	<em>August 18, 2008</em>
+</p>
diff --git a/docs/html/search.jd b/docs/html/search.jd
old mode 100755
new mode 100644
index 9269d2c..979964b
--- a/docs/html/search.jd
+++ b/docs/html/search.jd
@@ -5,73 +5,53 @@
 <script src="http://www.google.com/jsapi" type="text/javascript"></script>

 <script type="text/javascript">

       google.load('search', '1');

-      

-      // the cse class encapsulates a left and right search control

-      // both controls are driven by a shared search form

-      function cse() {

-        var sFormDiv = document.getElementById("searchForm");

-        var leftScDiv = document.getElementById("leftSearchControl");

-

-        // create a left, right search control

-        // create a custom search form

-        this.leftControl = new google.search.SearchControl();

-        this.searchForm = new google.search.SearchForm(true, sFormDiv);

-

-        // bind clear and submit functions

-        this.searchForm.setOnSubmitCallback(this, cse.prototype.onSubmit);

-        this.searchForm.setOnClearCallback(this, cse.prototype.onClear);

-

-        // set up for small result sets

-        this.leftControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);

-

-        var searcher;

-        var options;

-

-        // configure left control

-        // Site Restrict to CSE ID for reviews

-        searcher = new google.search.WebSearch();

-        options = new google.search.SearcherOptions();

-        //searcher.setSiteRestriction("000455696194071821846:reviews");

-        //searcher.setUserDefinedLabel("Product Reviews");

-        options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);

-        this.leftControl.addSearcher(searcher, options);

-

-        // draw the left and right controls

-        this.leftControl.draw(leftScDiv);

-

-        // execute a starter search

-		urlquery=location.href.split("?");

-		urlterms=urlquery[1].split(",");

-		document.getElementById("searchTitle").innerHTML = urlterms[0];

-        this.searchForm.execute(urlterms[0]);

-

-      }

-

-      // when the form fires a submit, grab its

-      // value and call the left and right control

-      cse.prototype.onSubmit = function(form) {

-        var q = form.input.value;

-        if (q && q!= "") {

-          this.leftControl.execute(q);

-		  

-		document.getElementById("searchTitle").innerHTML = "search results for \"" + q + "\"";

-        }

-        return false;

-      }

-

-      // when the form fires a clear, call the left and right control

-      cse.prototype.onClear = function(form) {

-        //this.leftControl.clearAllResults();

-        //form.input.value = "";

-		document.getElementById("searchTitle").innerHTML = form.input.value;

-        return false;

-      }

 

       function OnLoad() {

-        new cse();

+        document.getElementById("search_autocomplete").style.color = "#000";

+

+        // create search control

+        searchControl = new google.search.SearchControl();

+

+        // use our existing search form and use tabs when multiple searchers are used

+        drawOptions = new google.search.DrawOptions();

+        drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);

+        drawOptions.setInput(document.getElementById("search_autocomplete"));

+

+        // configure search result options

+        searchOptions = new google.search.SearcherOptions();

+        searchOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);

+        searchOptions.setRoot(document.getElementById("leftSearchControl"));

+

+        // configure searcher options

+        searcher = new google.search.WebSearch();

+        searcher.setUserDefinedLabel("Android Developers");

+        searcher.setSiteRestriction("001283715400630100512:ggqrtvkztwm");

+ 

+        searchControl.addSearcher(searcher, searchOptions);

+        searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);

+        searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);

+        searchControl.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING);

+

+        // upon ajax search, refresh the url and search title

+        searchControl.setSearchStartingCallback(this, function(control, searcher, query) {

+            temp = location.href.split('#');

+            url = temp ? temp[0] : location.href;

+            location.href = url + '#q=' + query;

+            document.getElementById("searchTitle").innerHTML = "search results for <em>" + query + "</em>"

+        });

+

+        searchControl.draw(null, drawOptions);

+

+        // execute a search upon page load, from url hash query

+        if (location.href.indexOf("#q=") != -1) {

+          url = location.href.split("#q=");

+          searchControl.execute(decodeURI(url[1]));

+        }

       }

+

       google.setOnLoadCallback(OnLoad, true);

 </script>

+

   <div id="mainBodyFixed" style="width:auto; margin:20px">

           <h2 id="searchTitle">search results</h2>

           <img src="{@docRoot}assets/images/hr_gray_main.jpg" />

diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index dc16c39..0b398bc 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -16,18 +16,25 @@
 
 package android.graphics;
 
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.io.OutputStream;
+import android.os.Parcelable;
+import android.os.Parcel;
+
 import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.nio.ShortBuffer;
 import java.nio.IntBuffer;
-
-import android.os.Parcel;
-import android.os.Parcelable;
+import java.io.OutputStream;
 
 public final class Bitmap implements Parcelable {
+    /**
+     * Indicates that the bitmap was created for an unknown pixel density.
+     *
+     * @see Bitmap#getDensityScale()
+     * @see Bitmap#setDensityScale(float)
+     *
+     * @hide pending API council approval 
+     */
+    public static final float DENSITY_SCALE_UNKNOWN = -1.0f;
 
     // Note:  mNativeBitmap is used by FaceDetector_jni.cpp
     // Don't change/rename without updating FaceDetector_jni.cpp
@@ -41,6 +48,9 @@
 
     private static volatile Matrix sScaleMatrix;
 
+    private float mDensityScale = DENSITY_SCALE_UNKNOWN;
+    private boolean mAutoScaling;
+
     /**
      * @noinspection UnusedDeclaration
      */
@@ -59,6 +69,104 @@
         mIsMutable = isMutable;
         mNinePatchChunk = ninePatchChunk;
     }
+
+    /**
+     * <p>Returns the density scale for this bitmap, expressed as a factor of
+     * the default density (160.) For instance, a bitmap designed for
+     * displays with a density of 240 will have a density scale of 1.5 whereas a bitmap
+     * designed for a density of 160 will have a density scale of 1.0.</p>
+     *
+     * <p>The default density scale is {@link #DENSITY_SCALE_UNKNOWN}.</p>
+     *
+     * @return A scaling factor of the default density (160) or {@link #DENSITY_SCALE_UNKNOWN}
+     *         if the scaling factor is unknown.
+     *
+     * @see #setDensityScale(float)
+     * @see #isAutoScalingEnabled()
+     * @see #setAutoScalingEnabled(boolean) 
+     * @see android.util.DisplayMetrics#DEFAULT_DENSITY
+     * @see android.util.DisplayMetrics#density
+     * @see #DENSITY_SCALE_UNKNOWN
+     *
+     * @hide pending API council approval
+     */
+    public float getDensityScale() {
+        return mDensityScale;
+    }
+
+    /**
+     * <p>Specifies the density scale for this bitmap, expressed as a factor of
+     * the default density (160.) For instance, a bitmap designed for
+     * displays with a density of 240 will have a density scale of 1.5 whereas a bitmap
+     * designed for a density of 160 will have a density scale of 1.0.</p>
+     *
+     * @param densityScale The density scaling factor to use with this bitmap or
+     *        {@link #DENSITY_SCALE_UNKNOWN} if the factor is unknown.
+     *
+     * @see #getDensityScale()
+     * @see #isAutoScalingEnabled()
+     * @see #setAutoScalingEnabled(boolean) 
+     * @see android.util.DisplayMetrics#DEFAULT_DENSITY
+     * @see android.util.DisplayMetrics#density
+     * @see #DENSITY_SCALE_UNKNOWN
+     *
+     * @hide pending API council approval
+     */
+    public void setDensityScale(float densityScale) {
+        mDensityScale = densityScale;
+    }
+
+    /**
+     * </p>Indicates whether this bitmap will be automatically be scaled at the
+     * target's density at drawing time. If auto scaling is enabled, this bitmap
+     * will be drawn with the following scale factor:</p>
+     *
+     * <pre>scale = (bitmap density scale factor) / (target density scale factor)</pre>
+     *
+     * <p>Auto scaling is turned off by default. If auto scaling is enabled but the
+     * bitmap has an unknown density scale, then the bitmap will never be automatically
+     * scaled at drawing time.</p>
+     * 
+     * @return True if the bitmap must be scaled at drawing time, false otherwise.
+     *
+     * @see #setAutoScalingEnabled(boolean)
+     * @see #getDensityScale()
+     * @see #setDensityScale(float)
+     *
+     * @hide pending API council approval
+     */
+    public boolean isAutoScalingEnabled() {
+        return mAutoScaling;
+    }
+
+    /**
+     * <p>Enables or disables auto scaling for this bitmap. When auto scaling is enabled,
+     * the bitmap will be scaled at drawing time to accomodate the drawing target's pixel
+     * density. The final scale factor for this bitmap is thus defined:</p>
+     *
+     * <pre>scale = (bitmap density scale factor) / (target density scale factor)</pre>
+     *
+     * <p>If auto scaling is enabled but the bitmap has an unknown density scale, then
+     * the bitmap will never be automatically scaled at drawing time.</p>
+     *
+     * @param autoScalingEnabled True to scale the bitmap at drawing time, false otherwise.
+     *
+     * @hide pending API council approval
+     */
+    public void setAutoScalingEnabled(boolean autoScalingEnabled) {
+        mAutoScaling = autoScalingEnabled;
+    }
+
+    /**
+     * Sets the nine patch chunk.
+     *
+     * @param chunk The definition of the nine patch
+     *
+     * @hide
+     */
+    public void setNinePatchChunk(byte[] chunk) {
+        mNinePatchChunk = chunk;
+    }
     
     /**
      * Free up the memory associated with this bitmap's pixels, and mark the
@@ -126,7 +234,7 @@
             throw new IllegalArgumentException("height must be > 0");
         }
     }
-    
+
     public enum Config {
         // these native values must match up with the enum in SkBitmap.h
         ALPHA_8     (2),
@@ -232,7 +340,7 @@
 
     public static Bitmap createScaledBitmap(Bitmap src, int dstWidth,
             int dstHeight, boolean filter) {
-        Matrix m = null;
+        Matrix m;
         synchronized (Bitmap.class) {
             // small pool of just 1 matrix
             m = sScaleMatrix;
@@ -279,8 +387,7 @@
      * @param width    The number of pixels in each row
      * @param height   The number of rows
      */
-    public static Bitmap createBitmap(Bitmap source, int x, int y,
-                                      int width, int height) {
+    public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height) {
         return createBitmap(source, x, y, width, height, null, false);
     }
     
@@ -301,23 +408,21 @@
      * @throws IllegalArgumentException if the x, y, width, height values are
      *         outside of the dimensions of the source bitmap.
      */
-    public static Bitmap createBitmap(Bitmap source, int x, int y, int width,
-                                      int height, Matrix m, boolean filter) {
+    public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height,
+            Matrix m, boolean filter) {
+
         checkXYSign(x, y);
         checkWidthHeight(width, height);
         if (x + width > source.getWidth()) {
-            throw new IllegalArgumentException(
-                    "x + width must be <= bitmap.width()");
+            throw new IllegalArgumentException("x + width must be <= bitmap.width()");
         }
         if (y + height > source.getHeight()) {
-            throw new IllegalArgumentException(
-                    "y + height must be <= bitmap.height()");
+            throw new IllegalArgumentException("y + height must be <= bitmap.height()");
         }
 
         // check if we can just return our argument unchanged
-        if (!source.isMutable() && x == 0 && y == 0
-                && width == source.getWidth() && height == source.getHeight()
-                && (m == null || m.isIdentity())) {
+        if (!source.isMutable() && x == 0 && y == 0 && width == source.getWidth() &&
+                height == source.getHeight() && (m == null || m.isIdentity())) {
             return source;
         }
         
@@ -331,8 +436,8 @@
         RectF dstR = new RectF(0, 0, width, height);
 
         if (m == null || m.isIdentity()) {
-            bitmap = createBitmap(neww, newh, source.hasAlpha() ?
-                                  Config.ARGB_8888 : Config.RGB_565);
+            bitmap = createBitmap(neww, newh,
+                    source.hasAlpha() ? Config.ARGB_8888 : Config.RGB_565);
             paint = null;   // not needed
         } else {
             /*  the dst should have alpha if the src does, or if our matrix
@@ -343,8 +448,7 @@
             m.mapRect(deviceR, dstR);
             neww = Math.round(deviceR.width());
             newh = Math.round(deviceR.height());
-            bitmap = createBitmap(neww, newh, hasAlpha ?
-                                  Config.ARGB_8888 : Config.RGB_565);
+            bitmap = createBitmap(neww, newh, hasAlpha ? Config.ARGB_8888 : Config.RGB_565);
             if (hasAlpha) {
                 bitmap.eraseColor(0);
             }
@@ -358,7 +462,12 @@
         }
         canvas.setBitmap(bitmap);
         canvas.drawBitmap(source, srcR, dstR, paint);
-        
+
+        // The new bitmap was created from a known bitmap source so assume that
+        // they use the same density scale
+        bitmap.setDensityScale(source.getDensityScale());
+        bitmap.setAutoScalingEnabled(source.isAutoScalingEnabled());
+
         return bitmap;
     }
     
@@ -371,8 +480,7 @@
      * @throws IllegalArgumentException if the width or height are <= 0
      */
     public static Bitmap createBitmap(int width, int height, Config config) {
-        Bitmap bm = nativeCreate(null, 0, width, width, height,
-                                 config.nativeInt, true);
+        Bitmap bm = nativeCreate(null, 0, width, width, height, config.nativeInt, true);
         bm.eraseColor(0);    // start with black/transparent pixels
         return bm;
     }
@@ -395,16 +503,16 @@
      *         the color array's length is less than the number of pixels.
      */
     public static Bitmap createBitmap(int colors[], int offset, int stride,
-                                      int width, int height, Config config) {
+            int width, int height, Config config) {
+
         checkWidthHeight(width, height);
         if (Math.abs(stride) < width) {
             throw new IllegalArgumentException("abs(stride) must be >= width");
         }
         int lastScanline = offset + (height - 1) * stride;
         int length = colors.length;
-        if (offset < 0 || (offset + width > length)
-            || lastScanline < 0
-            || (lastScanline + width > length)) {
+        if (offset < 0 || (offset + width > length) || lastScanline < 0 ||
+                (lastScanline + width > length)) {
             throw new ArrayIndexOutOfBoundsException();
         }
         return nativeCreate(colors, offset, stride, width, height,
@@ -425,8 +533,7 @@
      * @throws IllegalArgumentException if the width or height are <= 0, or if
      *         the color array's length is less than the number of pixels.
      */
-    public static Bitmap createBitmap(int colors[], int width, int height,
-                                      Config config) {
+    public static Bitmap createBitmap(int colors[], int width, int height, Config config) {
         return createBitmap(colors, 0, width, width, height, config);
     }
 
@@ -474,8 +581,7 @@
      * @param stream   The outputstream to write the compressed data.
      * @return true if successfully compressed to the specified stream.
      */
-    public boolean compress(CompressFormat format, int quality,
-                            OutputStream stream) {
+    public boolean compress(CompressFormat format, int quality, OutputStream stream) {
         checkRecycled("Can't compress a recycled bitmap");
         // do explicit check before calling the native method
         if (stream == null) {
@@ -506,6 +612,32 @@
     }
     
     /**
+     * Convenience method that returns the width of this bitmap divided
+     * by the density scale factor.
+     *
+     * @return The scaled width of this bitmap, according to the density scale factor.
+     *
+     * @hide pending API council approval
+     */
+    public int getScaledWidth() {
+        final float scale = getDensityScale();
+        return scale == DENSITY_SCALE_UNKNOWN ? getWidth() : (int) (getWidth() / scale);
+    }
+
+    /**
+     * Convenience method that returns the height of this bitmap divided
+     * by the density scale factor.
+     *
+     * @return The scaled height of this bitmap, according to the density scale factor.
+     *
+     * @hide pending API council approval
+     */
+    public int getScaledHeight() {
+        final float scale = getDensityScale();
+        return scale == DENSITY_SCALE_UNKNOWN ? getWidth() : (int) (getHeight() / scale);
+    }
+
+    /**
      * Return the number of bytes between rows in the bitmap's pixels. Note that
      * this refers to the pixels as stored natively by the bitmap. If you call
      * getPixels() or setPixels(), then the pixels are uniformly treated as
@@ -836,7 +968,7 @@
     private static native Bitmap nativeExtractAlpha(int nativeBitmap,
                                                     int nativePaint,
                                                     int[] offsetXY);
-    
+
     /* package */ final int ni() {
         return mNativeBitmap;
     }
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index 2c3f543..3813d8f 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -18,26 +18,20 @@
 
 import android.content.res.AssetManager;
 import android.content.res.Resources;
-import android.util.Log;
+import android.util.TypedValue;
+import android.util.DisplayMetrics;
 
 import java.io.BufferedInputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.FileDescriptor;
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
-
 
 /**
  * Creates Bitmap objects from various sources, including files, streams, 
  * and byte-arrays. 
  */
 public class BitmapFactory {
-    private static final String TAG = "BitmapFactory";
-    private static final boolean DEBUG_LOAD = false;
-
     public static class Options {
         /**
          * Create a default Options object, which if left unchanged will give
@@ -45,6 +39,8 @@
          */
         public Options() {
             inDither = true;
+            inDensity = 0;
+            inScaled = true;
         }
 
         /**
@@ -53,6 +49,7 @@
          * the bitmap without having to allocate the memory for its pixels.
          */
         public boolean inJustDecodeBounds;
+
         /**
          * If set to a value > 1, requests the decoder to subsample the original
          * image, returning a smaller image to save memory. The sample size is
@@ -80,20 +77,45 @@
          * image.
          */
         public boolean inDither;
-        
+
+        /**
+         * The desired pixel density of the bitmap.
+         *
+         * @see android.util.DisplayMetrics#DEFAULT_DENSITY
+         * @see android.util.DisplayMetrics#density
+         *
+         * @hide pending API council approval
+         */
+        public int inDensity;
+
+        /**
+         * </p>If the bitmap is loaded from {@link android.content.res.Resources} and
+         * this flag is turned on, the bitmap will be scaled to match the default
+         * display's pixel density.</p>
+         *
+         * </p>This flag is turned on by default and should be turned off if you need
+         * a non-scaled version of the bitmap. In this case,
+         * {@link android.graphics.Bitmap#setAutoScalingEnabled(boolean)} can be used
+         * to properly scale the bitmap at drawing time.</p>
+         *
+         * @hide pending API council approval
+         */
+        public boolean inScaled;
+
         /**
          * The resulting width of the bitmap, set independent of the state of
          * inJustDecodeBounds. However, if there is an error trying to decode,
          * outWidth will be set to -1.
          */
         public int outWidth;
+
         /**
          * The resulting height of the bitmap, set independent of the state of
          * inJustDecodeBounds. However, if there is an error trying to decode,
          * outHeight will be set to -1.
          */
         public int outHeight;
-        
+
         /**
          * If known, this string is set to the mimetype of the decoded image.
          * If not know, or there is an error, it is set to null.
@@ -103,7 +125,7 @@
         /**
          * Temp storage to use for decoding.  Suggest 16K or so.
          */
-        public byte [] inTempStorage;
+        public byte[] inTempStorage;
         
         private native void requestCancel();
 
@@ -175,6 +197,58 @@
     }
 
     /**
+     * Decode a new Bitmap from an InputStream. This InputStream was obtained from
+     * resources, which we pass to be able to scale the bitmap accordingly.
+     *
+     * @hide
+     */
+    public static Bitmap decodeStream(Resources res, TypedValue value, InputStream is,
+            Rect pad, Options opts) {
+
+        if (opts == null) {
+            opts = new Options();
+        }
+
+        Bitmap bm = decodeStream(is, pad, opts);
+
+        if (bm != null && res != null && value != null) {
+            byte[] np = bm.getNinePatchChunk();
+            final boolean isNinePatch = np != null && NinePatch.isNinePatchChunk(np);
+
+            final int density = value.density;
+            if (opts.inDensity == 0) {
+                opts.inDensity = density == TypedValue.DENSITY_DEFAULT ?
+                        DisplayMetrics.DEFAULT_DENSITY : density;
+            }            
+            float scale = opts.inDensity / (float) DisplayMetrics.DEFAULT_DENSITY;
+
+            if (opts.inScaled || isNinePatch) {
+                bm.setDensityScale(1.0f);
+                bm.setAutoScalingEnabled(false);
+                // Assume we are going to prescale for the screen
+                scale = res.getDisplayMetrics().density / scale;
+                if (scale != 1.0f) {
+                    // TODO: This is very inefficient and should be done in native by Skia
+                    final Bitmap oldBitmap = bm;
+                    bm = Bitmap.createScaledBitmap(oldBitmap, (int) (bm.getWidth() * scale + 0.5f),
+                            (int) (bm.getHeight() * scale + 0.5f), true);
+                    oldBitmap.recycle();
+
+                    if (isNinePatch) {
+                        np = nativeScaleNinePatch(np, scale, pad);
+                        bm.setNinePatchChunk(np);
+                    }
+                }
+            } else {
+                bm.setDensityScale(scale);
+                bm.setAutoScalingEnabled(true);
+            }
+        }
+
+        return bm;
+    }
+
+    /**
      * Decode an image referenced by a resource ID.
      *
      * @param res   The resources object containing the image data
@@ -189,11 +263,12 @@
         Bitmap bm = null;
         
         try {
-            InputStream is = res.openRawResource(id);
-            bm = decodeStream(is, null, opts);
+            final TypedValue value = new TypedValue();
+            final InputStream is = res.openRawResource(id, value);
+
+            bm = decodeStream(res, value, is, null, opts);
             is.close();
-        }
-        catch (java.io.IOException e) {
+        } catch (java.io.IOException e) {
             /*  do nothing.
                 If the exception happened on open, bm will be null.
                 If it happened on close, bm is still valid.
@@ -226,8 +301,7 @@
      *         decoded, or, if opts is non-null, if opts requested only the
      *         size be returned (in opts.outWidth and opts.outHeight)
      */
-    public static Bitmap decodeByteArray(byte[] data, int offset, int length,
-                                         Options opts) {
+    public static Bitmap decodeByteArray(byte[] data, int offset, int length, Options opts) {
         if ((offset | length) < 0 || data.length < offset + length) {
             throw new ArrayIndexOutOfBoundsException();
         }
@@ -265,8 +339,7 @@
      *         decoded, or, if opts is non-null, if opts requested only the
      *         size be returned (in opts.outWidth and opts.outHeight)
      */
-    public static Bitmap decodeStream(InputStream is, Rect outPadding,
-                                      Options opts) {
+    public static Bitmap decodeStream(InputStream is, Rect outPadding, Options opts) {
         // we don't throw in this case, thus allowing the caller to only check
         // the cache, and not force the image to be decoded.
         if (is == null) {
@@ -287,11 +360,9 @@
         Bitmap  bm;
 
         if (is instanceof AssetManager.AssetInputStream) {
-            bm = nativeDecodeAsset(
-                ((AssetManager.AssetInputStream)is).getAssetInt(), outPadding,
-                                   opts);
-        }
-        else {
+            bm = nativeDecodeAsset(((AssetManager.AssetInputStream) is).getAssetInt(),
+                    outPadding, opts);
+        } else {
             // pass some temp storage down to the native code. 1024 is made up,
             // but should be large enough to avoid too many small calls back
             // into is.read(...) This number is not related to the value passed
@@ -337,8 +408,7 @@
      *             image should be completely decoded, or just is size returned.
      * @return the decoded bitmap, or null
      */
-    public static Bitmap decodeFileDescriptor(FileDescriptor fd,
-                                              Rect outPadding, Options opts) {
+    public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) {
         return nativeDecodeFileDescriptor(fd, outPadding, opts);
     }
     
@@ -354,13 +424,13 @@
         return nativeDecodeFileDescriptor(fd, null, null);
     }
     
-    private static native Bitmap nativeDecodeStream(InputStream is,
-                                    byte[] storage, Rect padding, Options opts);
+    private static native Bitmap nativeDecodeStream(InputStream is, byte[] storage,
+            Rect padding, Options opts);
     private static native Bitmap nativeDecodeFileDescriptor(FileDescriptor fd,
-                                    Rect padding, Options opts);
-    private static native Bitmap nativeDecodeAsset(int asset, Rect padding,
-                                    Options opts);
+            Rect padding, Options opts);
+    private static native Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts);
     private static native Bitmap nativeDecodeByteArray(byte[] data, int offset,
-                                    int length, Options opts);
+            int length, Options opts);
+    private static native byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad);
 }
 
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index b57f428..32ecd9f 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -50,6 +50,8 @@
     // Used by native code
     @SuppressWarnings({"UnusedDeclaration"})
     private int         mSurfaceFormat;
+    @SuppressWarnings({"UnusedDeclaration"})
+    private float       mDensityScale = 1.0f;
 
     /**
      * Construct an empty raster canvas. Use setBitmap() to specify a bitmap to
@@ -74,6 +76,8 @@
         throwIfRecycled(bitmap);
         mNativeCanvas = initRaster(bitmap.ni());
         mBitmap = bitmap;
+        mDensityScale = bitmap.getDensityScale();
+        if (mDensityScale == Bitmap.DENSITY_SCALE_UNKNOWN) mDensityScale = 1.0f;
     }
     
     /*package*/ Canvas(int nativeCanvas) {
@@ -126,6 +130,8 @@
 
         native_setBitmap(mNativeCanvas, bitmap.ni());
         mBitmap = bitmap;
+        mDensityScale = bitmap.getDensityScale();
+        if (mDensityScale == Bitmap.DENSITY_SCALE_UNKNOWN) mDensityScale = 1.0f;
     }
     
     /**
@@ -163,6 +169,51 @@
      */
     public native int getHeight();
 
+    /**
+     * <p>Returns the density scale for this Canvas' backing bitmap, expressed as a
+     * factor of the default density (160dpi.) For instance, a bitmap designed for
+     * 240dpi displays will have a density scale of 1.5 whereas a bitmap
+     * designed for 160dpi will have a density scale of 1.0.</p>
+     *
+     * <p>The default density scale is {@link Bitmap#DENSITY_SCALE_UNKNOWN}.</p>
+     *
+     * @return A scaling factor of the default density (160dpi) or
+     *        {@link Bitmap#DENSITY_SCALE_UNKNOWN} if the scaling factor is unknown.
+     *
+     * @see #setDensityScale(float)
+     * @see Bitmap#getDensityScale() 
+     *
+     * @hide pending API council approval
+     */
+    public float getDensityScale() {
+        if (mBitmap != null) {
+            return mBitmap.getDensityScale();
+        }
+        return mDensityScale;
+    }
+
+    /**
+     * <p>Specifies the density scale for this Canvas' backing bitmap, expressed as a
+     * factor of the default density (160dpi.) For instance, a bitmap designed for
+     * 240dpi displays will have a density scale of 1.5 whereas a bitmap
+     * designed for 160dpi will have a density scale of 1.0.</p>
+     *
+     * @param densityScale The density scaling factor to use with this bitmap or
+     *        {@link Bitmap#DENSITY_SCALE_UNKNOWN} if the factor is unknown.
+     *
+     * @see #getDensityScale()
+     * @see Bitmap#setDensityScale(float) 
+     *
+     * @hide pending API council approval
+     */
+    public void setDensityScale(float densityScale) {
+        if (mBitmap != null) {
+            mBitmap.setDensityScale(densityScale);
+        }
+        mDensityScale = densityScale;
+        if (mDensityScale == Bitmap.DENSITY_SCALE_UNKNOWN) mDensityScale = 1.0f;
+    }
+
     // the SAVE_FLAG constants must match their native equivalents
 
     /** restore the current matrix when restore() is called */
@@ -910,7 +961,8 @@
     public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
         throwIfRecycled(bitmap);
         native_drawBitmap(mNativeCanvas, bitmap.ni(), left, top,
-                          paint != null ? paint.mNativePaint : 0);
+                paint != null ? paint.mNativePaint : 0, bitmap.isAutoScalingEnabled(),
+                bitmap.getDensityScale());
     }
 
     /**
@@ -982,8 +1034,8 @@
      *                 be 0xFF for every pixel).
      * @param paint  May be null. The paint used to draw the bitmap
      */
-    public void drawBitmap(int[] colors, int offset, int stride, int x, int y,
-                           int width, int height, boolean hasAlpha,
+    public void drawBitmap(int[] colors, int offset, int stride, float x,
+                           float y, int width, int height, boolean hasAlpha,
                            Paint paint) {
         // check for valid input
         if (width < 0) {
@@ -1006,11 +1058,20 @@
             return;
         }
         // punch down to native for the actual draw
-        native_drawBitmap(mNativeCanvas, colors, offset, stride, x, y,
-                          width, height, hasAlpha,
-                          paint != null ? paint.mNativePaint : 0);
+        native_drawBitmap(mNativeCanvas, colors, offset, stride, x, y, width, height, hasAlpha,
+                paint != null ? paint.mNativePaint : 0);
     }
     
+    /** Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y
+     */
+    public void drawBitmap(int[] colors, int offset, int stride, int x, int y,
+                           int width, int height, boolean hasAlpha,
+                           Paint paint) {
+        // call through to the common float version
+        drawBitmap(colors, offset, stride, (float)x, (float)y, width, height,
+                   hasAlpha, paint);
+    }
+        
     /**
      * Draw the bitmap using the specified matrix.
      *
@@ -1020,7 +1081,7 @@
      */
     public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
         nativeDrawBitmapMatrix(mNativeCanvas, bitmap.ni(), matrix.ni(),
-                               paint != null ? paint.mNativePaint : 0);
+                paint != null ? paint.mNativePaint : 0);
     }
     
     private static void checkRange(int length, int offset, int count) {
@@ -1416,25 +1477,27 @@
                                                     float ry, int paint);
     private static native void native_drawPath(int nativeCanvas, int path,
                                                int paint);
-    private static native void native_drawBitmap(int nativeCanvas, int bitmap,
+    private native void native_drawBitmap(int nativeCanvas, int bitmap,
                                                  float left, float top,
-                                                 int nativePaintOrZero);
-    private static native void native_drawBitmap(int nativeCanvas, int bitmap,
+                                                 int nativePaintOrZero, boolean autoScale,
+                                                 float densityScale);
+    private native void native_drawBitmap(int nativeCanvas, int bitmap,
                                                  Rect src, RectF dst,
                                                  int nativePaintOrZero);
     private static native void native_drawBitmap(int nativeCanvas, int bitmap,
                                                  Rect src, Rect dst,
                                                  int nativePaintOrZero);
     private static native void native_drawBitmap(int nativeCanvas, int[] colors,
-                                                 int offset, int stride, int x,
-                                                 int y, int width, int height,
+                                                int offset, int stride, float x,
+                                                 float y, int width, int height,
                                                  boolean hasAlpha,
                                                  int nativePaintOrZero);
     private static native void nativeDrawBitmapMatrix(int nCanvas, int nBitmap,
                                                       int nMatrix, int nPaint);
     private static native void nativeDrawBitmapMesh(int nCanvas, int nBitmap,
-                int meshWidth, int meshHeight, float[] verts, int vertOffset,
-                                    int[] colors, int colorOffset, int nPaint);
+                                                    int meshWidth, int meshHeight,
+                                                    float[] verts, int vertOffset,
+                                                    int[] colors, int colorOffset, int nPaint);
     private static native void nativeDrawVertices(int nCanvas, int mode, int n,
                    float[] verts, int vertOffset, float[] texs, int texOffset,
                    int[] colors, int colorOffset, short[] indices,
diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java
index cabd848..2b24ef2 100644
--- a/graphics/java/android/graphics/NinePatch.java
+++ b/graphics/java/android/graphics/NinePatch.java
@@ -26,10 +26,10 @@
  * way that you define, when content added within the image exceeds the normal
  * bounds of the graphic. For a thorough explanation of a NinePatch image, 
  * read the discussion in the 
- * <a href="{@docRoot}reference/available-resources.html#ninepatch">Available 
- * Resource Types</a> document.
+ * <a href="{@docRoot}guide/topics/graphics/2d-graphics.html#nine-patch">2D
+ * Graphics</a> document.
  * <p>
- * The <a href="{@docRoot}reference/draw9patch.html">Draw 9-patch</a> 
+ * The <a href="{@docRoot}guide/developing/tools/draw9patch.html">Draw 9-Patch</a> 
  * tool offers an extremely handy way to create your NinePatch images,
  * using a WYSIWYG graphics editor.
  * </p>
@@ -50,6 +50,17 @@
         validateNinePatchChunk(mBitmap.ni(), chunk);
     }
 
+    /**
+     * @hide
+     */
+    public NinePatch(NinePatch patch) {
+        mBitmap = patch.mBitmap;
+        mChunk = patch.mChunk;
+        mSrcName = patch.mSrcName;
+        mPaint = new Paint(patch.mPaint);
+        validateNinePatchChunk(mBitmap.ni(), mChunk);
+    }
+
     public void setPaint(Paint p) {
         mPaint = p;
     }
diff --git a/graphics/java/android/graphics/drawable/AnimationDrawable.java b/graphics/java/android/graphics/drawable/AnimationDrawable.java
index c6b772e9..bab1703 100644
--- a/graphics/java/android/graphics/drawable/AnimationDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimationDrawable.java
@@ -74,6 +74,7 @@
 public class AnimationDrawable extends DrawableContainer implements Runnable {
     private final AnimationState mAnimationState;
     private int mCurFrame = -1;
+    private boolean mMutated;
 
     public AnimationDrawable() {
         this(null);
@@ -283,6 +284,15 @@
         setFrame(0, true, false);
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mAnimationState.mDurations = mAnimationState.mDurations.clone();
+            mMutated = true;
+        }
+        return this;
+    }
+
     private final static class AnimationState extends DrawableContainerState {
         private int[] mDurations;
         private boolean mOneShot;
diff --git a/graphics/java/android/graphics/drawable/BitmapDrawable.java b/graphics/java/android/graphics/drawable/BitmapDrawable.java
index 7f3df9a..5b32246 100644
--- a/graphics/java/android/graphics/drawable/BitmapDrawable.java
+++ b/graphics/java/android/graphics/drawable/BitmapDrawable.java
@@ -28,6 +28,7 @@
 import android.graphics.Shader;
 import android.graphics.BitmapShader;
 import android.util.AttributeSet;
+import android.util.DisplayMetrics;
 import android.view.Gravity;
 
 import org.xmlpull.v1.XmlPullParser;
@@ -62,9 +63,12 @@
 
     private boolean mApplyGravity;
     private boolean mRebuildShader;
+    private int mBitmapWidth;
+    private int mBitmapHeight;
+    private boolean mMutated;
 
     public BitmapDrawable() {
-        mBitmapState = new BitmapState(null);
+        mBitmapState = new BitmapState((Bitmap) null);
     }
 
     public BitmapDrawable(Bitmap bitmap) {
@@ -92,7 +96,62 @@
     public final Bitmap getBitmap() {
         return mBitmap;
     }
-    
+
+    private void setBitmap(Bitmap bitmap) {
+        mBitmap = bitmap;
+        if (bitmap != null) {
+            mBitmapWidth = bitmap.getWidth();
+            mBitmapHeight = bitmap.getHeight();
+        } else {
+            mBitmapWidth = mBitmapHeight = -1;
+        }
+    }
+
+    /**
+     * Set the density scale at which this drawable will be rendered. This
+     * method assumes the drawable will be rendered at the same density as the
+     * specified canvas.
+     *
+     * @param canvas The Canvas from which the density scale must be obtained.
+     *
+     * @see android.graphics.Bitmap#setDensityScale(float) 
+     * @see android.graphics.Bitmap#getDensityScale()
+     *
+     * @hide pending API council approval
+     */
+    public void setDensityScale(Canvas canvas) {
+        setDensityScale(canvas.getDensityScale());
+    }
+
+    /**
+     * Set the density scale at which this drawable will be rendered.
+     *
+     * @param metrics The DisplayMetrics indicating the density scale for this drawable.
+     *
+     * @see android.graphics.Bitmap#setDensityScale(float)
+     * @see android.graphics.Bitmap#getDensityScale()
+     *
+     * @hide pending API council approval
+     */
+    public void setDensityScale(DisplayMetrics metrics) {
+        setDensityScale(metrics.density);
+    }
+
+    /**
+     * Set the density scale at which this drawable will be rendered.
+     *
+     * @param density The density scale for this drawable.
+     *
+     * @see android.graphics.Bitmap#setDensityScale(float)
+     * @see android.graphics.Bitmap#getDensityScale()
+     *
+     * @hide pending API council approval
+     */
+    public void setDensityScale(float density) {
+        density = (density == Bitmap.DENSITY_SCALE_UNKNOWN ? 1.0f : density);
+        mBitmapState.mTargetDensityScale = density;
+    }
+
     /** Get the gravity used to position/stretch the bitmap within its bounds.
         See android.view.Gravity
      * @return the gravity applied to the bitmap
@@ -184,7 +243,7 @@
             Shader shader = state.mPaint.getShader();
             if (shader == null) {
                 if (mApplyGravity) {
-                    Gravity.apply(state.mGravity, bitmap.getWidth(), bitmap.getHeight(),
+                    Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight,
                             getBounds(), mDstRect);
                     mApplyGravity = false;
                 }
@@ -209,6 +268,21 @@
         mBitmapState.mPaint.setColorFilter(cf);
     }
 
+    /**
+     * A mutable BitmapDrawable still shares its Bitmap with any other Drawable
+     * that comes from the same resource.
+     *
+     * @return This drawable.
+     */
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mBitmapState = new BitmapState(mBitmapState);
+            mMutated = true;
+        }
+        return this;
+    }
+
     @Override
     public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
             throws XmlPullParserException, IOException {
@@ -226,7 +300,9 @@
             throw new XmlPullParserException(parser.getPositionDescription() +
                     ": <bitmap> requires a valid src attribute");
         }
-        mBitmapState.mBitmap = mBitmap = bitmap;
+        mBitmapState.mBitmap = bitmap;
+        setBitmap(bitmap);
+        setDensityScale(r.getDisplayMetrics());
 
         final Paint paint = mBitmapState.mPaint;
         paint.setAntiAlias(a.getBoolean(com.android.internal.R.styleable.BitmapDrawable_antialias,
@@ -256,14 +332,29 @@
 
     @Override
     public int getIntrinsicWidth() {
-        Bitmap bitmap = mBitmap;
-        return bitmap != null ? bitmap.getWidth() : -1;
+        final Bitmap bitmap = mBitmap;
+        final BitmapState state = mBitmapState;
+
+        if (!state.mAutoScale || state.mBitmapScale == Bitmap.DENSITY_SCALE_UNKNOWN) {
+            return mBitmapWidth;
+        } else {
+            return bitmap != null ? (int) (mBitmapWidth /
+                    (state.mBitmapScale / state.mTargetDensityScale) + 0.5f) : -1;
+
+        }
     }
 
     @Override
     public int getIntrinsicHeight() {
-        Bitmap bitmap = mBitmap;
-        return bitmap != null ? bitmap.getHeight() : -1;
+        final Bitmap bitmap = mBitmap;
+        final BitmapState state = mBitmapState;
+
+        if (!state.mAutoScale || state.mBitmapScale == Bitmap.DENSITY_SCALE_UNKNOWN) {
+            return mBitmapHeight;
+        } else {
+            return bitmap != null ? (int) (mBitmapHeight /
+                    (state.mBitmapScale / state.mTargetDensityScale) + 0.5f) : -1;
+        }
     }
 
     @Override
@@ -289,9 +380,29 @@
         Paint mPaint = new Paint(DEFAULT_PAINT_FLAGS);
         Shader.TileMode mTileModeX;
         Shader.TileMode mTileModeY;
+        boolean mAutoScale;
+        float mBitmapScale;
+        float mTargetDensityScale = 1.0f;
 
         BitmapState(Bitmap bitmap) {
             mBitmap = bitmap;
+            if (bitmap != null) {
+                mBitmapScale = bitmap.getDensityScale();
+                mAutoScale = bitmap.isAutoScalingEnabled();
+            } else {
+                mBitmapScale = 1.0f;
+                mAutoScale = false;
+            }
+        }
+
+        BitmapState(BitmapState bitmapState) {
+            this(bitmapState.mBitmap);
+            mChangingConfigurations = bitmapState.mChangingConfigurations;
+            mGravity = bitmapState.mGravity;
+            mTileModeX = bitmapState.mTileModeX;
+            mTileModeY = bitmapState.mTileModeY;
+            mTargetDensityScale = bitmapState.mTargetDensityScale;
+            mPaint = new Paint(bitmapState.mPaint);
         }
 
         @Override
@@ -307,6 +418,6 @@
 
     private BitmapDrawable(BitmapState state) {
         mBitmapState = state;
-        mBitmap = state.mBitmap;
+        setBitmap(state.mBitmap);
     }
 }
diff --git a/graphics/java/android/graphics/drawable/ClipDrawable.java b/graphics/java/android/graphics/drawable/ClipDrawable.java
index 6029388..95d4dd0 100644
--- a/graphics/java/android/graphics/drawable/ClipDrawable.java
+++ b/graphics/java/android/graphics/drawable/ClipDrawable.java
@@ -24,7 +24,6 @@
 import android.graphics.*;
 import android.view.Gravity;
 import android.util.AttributeSet;
-import android.util.Log;
 
 import java.io.IOException;
 
@@ -100,9 +99,8 @@
         mClipState.mDrawable = dr;
         mClipState.mOrientation = orientation;
         mClipState.mGravity = g;
-        if (dr != null) {
-            dr.setCallback(this);
-        }
+
+        dr.setCallback(this);
     }
 
     // overrides from Drawable.Callback
@@ -168,8 +166,7 @@
 
     @Override
     protected boolean onStateChange(int[] state) {
-        boolean changed = mClipState.mDrawable.setState(state);
-        return changed;
+        return mClipState.mDrawable.setState(state);
     }
 
     @Override
@@ -233,7 +230,17 @@
         return null;
     }
 
+    
+
     final static class ClipState extends ConstantState {
+        Drawable mDrawable;
+        int mChangingConfigurations;
+        int mOrientation;
+        int mGravity;
+
+        private boolean mCheckedConstantState;
+        private boolean mCanConstantState;
+
         ClipState(ClipState orig, ClipDrawable owner) {
             if (orig != null) {
                 mDrawable = orig.mDrawable.getConstantState().newDrawable();
@@ -262,14 +269,6 @@
 
             return mCanConstantState;
         }
-
-        Drawable mDrawable;
-        int mChangingConfigurations;
-        int mOrientation;
-        int mGravity;
-
-        private boolean mCheckedConstantState;
-        private boolean mCanConstantState;
     }
 
     private ClipDrawable(ClipState state) {
diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java
index 0021241..cf72f38 100644
--- a/graphics/java/android/graphics/drawable/Drawable.java
+++ b/graphics/java/android/graphics/drawable/Drawable.java
@@ -29,6 +29,7 @@
 import android.util.AttributeSet;
 import android.util.StateSet;
 import android.util.Xml;
+import android.util.TypedValue;
 
 /**
  * A Drawable is a general abstraction for "something that can be drawn."  Most
@@ -91,7 +92,7 @@
  *     whose overall size is modified based on the current level.
  * </ul>
  * <p>For information and examples of creating drawable resources (XML or bitmap files that
- * can be loaded in code), see <a href="{@docRoot}devel/resources-i18n.html">Resources
+ * can be loaded in code), see <a href="{@docRoot}guide/topics/resources/resources-i18n.html">Resources
  * and Internationalization</a>.
  */
 public abstract class Drawable {
@@ -102,7 +103,7 @@
     private Rect mBounds = new Rect();
     /*package*/ Callback mCallback = null;
     private boolean mVisible = true;
-    
+
     /**
      * Draw in its bounds (set via setBounds) respecting optional effects such
      * as alpha (set via setAlpha) and color filter (set via setColorFilter).
@@ -618,9 +619,36 @@
     }
 
     /**
+     * Make this drawable mutable. This operation cannot be reversed. A mutable
+     * drawable is guaranteed to not share its state with any other drawable.
+     * This is especially useful when you need to modify properties of drawables
+     * loaded from resources. By default, all drawables instances loaded from
+     * the same resource share a common state; if you modify the state of one
+     * instance, all the other instances will receive the same modification.
+     *
+     * Calling this method on a mutable Drawable will have no effect.
+     *
+     * @return This drawable.
+     */
+    public Drawable mutate() {
+        return this;
+    }
+
+    /**
      * Create a drawable from an inputstream
      */
     public static Drawable createFromStream(InputStream is, String srcName) {
+        return createFromResourceStream(null, null, is, srcName);
+    }
+
+    /**
+     * Create a drawable from an inputstream
+     * 
+     * @hide pending API council approval
+     */
+    public static Drawable createFromResourceStream(Resources res, TypedValue value,
+            InputStream is, String srcName) {
+
         if (is == null) {
             return null;
         }
@@ -632,14 +660,14 @@
             Rects only to drop them on the floor.
         */
         Rect pad = new Rect();
-        Bitmap  bm = BitmapFactory.decodeStream(is, pad, null);
+        Bitmap  bm = BitmapFactory.decodeStream(res, value, is, pad, null);
         if (bm != null) {
             byte[] np = bm.getNinePatchChunk();
             if (np == null || !NinePatch.isNinePatchChunk(np)) {
                 np = null;
                 pad = null;
             }
-            return drawableFromBitmap(bm, np, pad, srcName);
+            return drawableFromBitmap(res, bm, np, pad, srcName);
         }
         return null;
     }
@@ -647,7 +675,7 @@
     /**
      * Create a drawable from an XML document. For more information on how to
      * create resources in XML, see
-     * <a href="{@docRoot}devel/resources-i18n.html">Resources and
+     * <a href="{@docRoot}guide/topics/resources/resources-i18n.html">Resources and
      * Internationalization</a>.
      */
     public static Drawable createFromXml(Resources r, XmlPullParser parser)
@@ -708,6 +736,9 @@
             drawable = new InsetDrawable();
         } else if (name.equals("bitmap")) {
             drawable = new BitmapDrawable();
+            if (r != null) {
+               ((BitmapDrawable) drawable).setDensityScale(r.getDisplayMetrics());
+            }
         } else {
             throw new XmlPullParserException(parser.getPositionDescription() +
                     ": invalid drawable tag " + name);
@@ -728,7 +759,7 @@
 
         Bitmap bm = BitmapFactory.decodeFile(pathName);
         if (bm != null) {
-            return drawableFromBitmap(bm, null, null, pathName);
+            return drawableFromBitmap(null, bm, null, null, pathName);
         }
 
         return null;
@@ -758,11 +789,19 @@
         return null;
     }
 
-    private static Drawable drawableFromBitmap(Bitmap bm, byte[] np, Rect pad, String srcName) {
+    private static Drawable drawableFromBitmap(Resources res, Bitmap bm, byte[] np,
+            Rect pad, String srcName) {
+
         if (np != null) {
             return new NinePatchDrawable(bm, np, pad, srcName);
         }
-        return new BitmapDrawable(bm);
+
+        final BitmapDrawable drawable = new BitmapDrawable(bm);
+        if (res != null) {
+            drawable.setDensityScale(res.getDisplayMetrics());
+        }
+
+        return drawable;
     }
 }
 
diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java
index e6c48be..29f2a00 100644
--- a/graphics/java/android/graphics/drawable/DrawableContainer.java
+++ b/graphics/java/android/graphics/drawable/DrawableContainer.java
@@ -21,12 +21,13 @@
 public class DrawableContainer extends Drawable implements Drawable.Callback {
     
     private DrawableContainerState mDrawableContainerState;
-    private Drawable        mCurrDrawable;
-    private int             mAlpha = 0xFF;
-    private ColorFilter     mColorFilter;
-    private boolean         mDither;
+    private Drawable mCurrDrawable;
+    private int mAlpha = 0xFF;
+    private ColorFilter mColorFilter;
+    private boolean mDither;
 
-    private int             mCurIndex = -1;
+    private int mCurIndex = -1;
+    private boolean mMutated;
 
     // overrides from Drawable
 
@@ -229,6 +230,17 @@
         return null;
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            for (Drawable child : mDrawableContainerState.mDrawables) {
+                child.mutate();
+            }
+            mMutated = true;
+        }
+        return this;
+    }
+
     public abstract static class DrawableContainerState extends ConstantState {
         final DrawableContainer mOwner;
 
@@ -277,7 +289,9 @@
 
                 mCheckedConstantState = mCanConstantState = true;
                 mVariablePadding = orig.mVariablePadding;
-                mConstantPadding = orig.mConstantPadding;
+                if (orig.mConstantPadding != null) {
+                    mConstantPadding = new Rect(orig.mConstantPadding);
+                }
                 mConstantSize = orig.mConstantSize;
                 mComputedConstantSize = orig.mComputedConstantSize;
                 mConstantWidth = orig.mConstantWidth;
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index cdfca1b..82cb795 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -106,20 +106,21 @@
      */
     public static final int SWEEP_GRADIENT  = 2;
 
-    private final GradientState mGradientState;
+    private GradientState mGradientState;
     
     private final Paint mFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
-    private Rect        mPadding;
-    private Paint       mStrokePaint;   // optional, set by the caller
+    private Rect mPadding;
+    private Paint mStrokePaint;   // optional, set by the caller
     private ColorFilter mColorFilter;   // optional, set by the caller
-    private int         mAlpha = 0xFF;  // modified by the caller
-    private boolean     mDither;
+    private int mAlpha = 0xFF;  // modified by the caller
+    private boolean mDither;
 
-    private final Path  mPath = new Path();
+    private final Path mPath = new Path();
     private final RectF mRect = new RectF();
     
-    private Paint       mLayerPaint;    // internal, used if we use saveLayer()
-    private boolean     mRectIsDirty;   // internal state
+    private Paint mLayerPaint;    // internal, used if we use saveLayer()
+    private boolean mRectIsDirty;   // internal state
+    private boolean mMutated;
 
     /**
      * Controls how the gradient is oriented relative to the drawable's bounds
@@ -791,31 +792,41 @@
         return mGradientState;
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mGradientState = new GradientState(mGradientState);
+            initializeWithState(mGradientState);
+            mMutated = true;
+        }
+        return this;
+    }
+
     final static class GradientState extends ConstantState {
-        public int          mChangingConfigurations;
-        public int          mShape = RECTANGLE;
-        public int          mGradient = LINEAR_GRADIENT;
-        public Orientation  mOrientation;
-        public int[]        mColors;
-        public float[]      mPositions;
-        public boolean      mHasSolidColor;
-        public int          mSolidColor;
-        public int          mStrokeWidth = -1;   // if >= 0 use stroking.
-        public int          mStrokeColor;
-        public float        mStrokeDashWidth;
-        public float        mStrokeDashGap;
-        public float        mRadius;    // use this if mRadiusArray is null
-        public float[]      mRadiusArray;
-        public Rect         mPadding;
-        public int          mWidth = -1;
-        public int          mHeight = -1;
-        public float        mInnerRadius;
-        public float        mThickness;
-        private float       mCenterX = 0.5f;
-        private float       mCenterY = 0.5f;
-        private float       mGradientRadius = 0.5f;
-        private boolean     mUseLevel;
-        private boolean     mUseLevelForShape;
+        public int mChangingConfigurations;
+        public int mShape = RECTANGLE;
+        public int mGradient = LINEAR_GRADIENT;
+        public Orientation mOrientation;
+        public int[] mColors;
+        public float[] mPositions;
+        public boolean mHasSolidColor;
+        public int mSolidColor;
+        public int mStrokeWidth = -1;   // if >= 0 use stroking.
+        public int mStrokeColor;
+        public float mStrokeDashWidth;
+        public float mStrokeDashGap;
+        public float mRadius;    // use this if mRadiusArray is null
+        public float[] mRadiusArray;
+        public Rect mPadding;
+        public int mWidth = -1;
+        public int mHeight = -1;
+        public float mInnerRadius;
+        public float mThickness;
+        private float mCenterX = 0.5f;
+        private float mCenterY = 0.5f;
+        private float mGradientRadius = 0.5f;
+        private boolean mUseLevel;
+        private boolean mUseLevelForShape;
         
         
         GradientState() {
@@ -827,6 +838,32 @@
             mColors = colors;
         }
 
+        public GradientState(GradientState state) {
+            mChangingConfigurations = state.mChangingConfigurations;
+            mShape = state.mShape;
+            mGradient = state.mGradient;
+            mOrientation = state.mOrientation;
+            mColors = state.mColors.clone();
+            mPositions = state.mPositions.clone();
+            mHasSolidColor = state.mHasSolidColor;
+            mStrokeWidth = state.mStrokeWidth;
+            mStrokeColor = state.mStrokeColor;
+            mStrokeDashWidth = state.mStrokeDashWidth;
+            mStrokeDashGap = state.mStrokeDashGap;
+            mRadius = state.mRadius;
+            mRadiusArray = state.mRadiusArray.clone();
+            mPadding = new Rect(state.mPadding);
+            mWidth = state.mWidth;
+            mHeight = state.mHeight;
+            mInnerRadius = state.mInnerRadius;
+            mThickness = state.mThickness;
+            mCenterX = state.mCenterX;
+            mCenterY = state.mCenterY;
+            mGradientRadius = state.mGradientRadius;
+            mUseLevel = state.mUseLevel;
+            mUseLevelForShape = state.mUseLevelForShape;
+        }
+
         @Override
         public Drawable newDrawable() {
             return new GradientDrawable(this);
@@ -895,6 +932,11 @@
 
     private GradientDrawable(GradientState state) {
         mGradientState = state;
+        initializeWithState(state);
+        mRectIsDirty = true;
+    }
+
+    private void initializeWithState(GradientState state) {
         if (state.mHasSolidColor) {
             mFillPaint.setColor(state.mSolidColor);
         }
@@ -906,12 +948,11 @@
             mStrokePaint.setColor(state.mStrokeColor);
 
             if (state.mStrokeDashWidth != 0.0f) {
-                DashPathEffect e = new DashPathEffect(new float[] {
-                        state.mStrokeDashWidth, state.mStrokeDashGap}, 0);
+                DashPathEffect e = new DashPathEffect(
+                        new float[] { state.mStrokeDashWidth, state.mStrokeDashGap }, 0);
                 mStrokePaint.setPathEffect(e);
             }
         }
-        mRectIsDirty = true;
     }
 }
 
diff --git a/graphics/java/android/graphics/drawable/InsetDrawable.java b/graphics/java/android/graphics/drawable/InsetDrawable.java
index 80b8e96..6047726 100644
--- a/graphics/java/android/graphics/drawable/InsetDrawable.java
+++ b/graphics/java/android/graphics/drawable/InsetDrawable.java
@@ -44,6 +44,9 @@
 public class InsetDrawable extends Drawable implements Drawable.Callback
 {
     // Most of this is copied from ScaleDrawable.
+    private InsetState mInsetState;
+    private final Rect mTmpRect = new Rect();
+    private boolean mMutated;
 
     /*package*/ InsetDrawable() {
         this(null);
@@ -239,7 +242,27 @@
         return null;
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mInsetState.mDrawable.mutate();
+            mMutated = true;
+        }
+        return this;
+    }
+
     final static class InsetState extends ConstantState {
+        Drawable mDrawable;
+        int mChangingConfigurations;
+
+        int mInsetLeft;
+        int mInsetTop;
+        int mInsetRight;
+        int mInsetBottom;
+
+        boolean mCheckedConstantState;
+        boolean mCanConstantState;
+
         InsetState(InsetState orig, InsetDrawable owner) {
             if (orig != null) {
                 mDrawable = orig.mDrawable.getConstantState().newDrawable();
@@ -270,25 +293,10 @@
 
             return mCanConstantState;
         }
-
-        Drawable mDrawable;
-        int mChangingConfigurations;
-
-        int mInsetLeft;
-        int mInsetTop;
-        int mInsetRight;
-        int mInsetBottom;
-
-        boolean mCheckedConstantState;
-        boolean mCanConstantState;
     }
 
     private InsetDrawable(InsetState state) {
-        InsetState as = new InsetState(state, this);
-        mInsetState = as;
+        mInsetState = new InsetState(state, this);
     }
-
-    private InsetState  mInsetState;
-    private final Rect  mTmpRect = new Rect();
 }
 
diff --git a/graphics/java/android/graphics/drawable/LayerDrawable.java b/graphics/java/android/graphics/drawable/LayerDrawable.java
index 59dfbd4..c777205 100644
--- a/graphics/java/android/graphics/drawable/LayerDrawable.java
+++ b/graphics/java/android/graphics/drawable/LayerDrawable.java
@@ -51,6 +51,7 @@
     private int[] mPaddingB;
 
     private final Rect mTmpRect = new Rect();
+    private boolean mMutated;
 
     /**
      * Create a new layer drawable with the list of specified layers.
@@ -71,16 +72,16 @@
     LayerDrawable(Drawable[] layers, LayerState state) {
         this(state);
         int length = layers.length;
-        Rec[] r = new Rec[length];
+        ChildDrawable[] r = new ChildDrawable[length];
 
         for (int i = 0; i < length; i++) {
-            r[i] = new Rec();
+            r[i] = new ChildDrawable();
             r[i].mDrawable = layers[i];
             layers[i].setCallback(this);
             mLayerState.mChildrenChangingConfigurations |= layers[i].getChangingConfigurations();
         }
         mLayerState.mNum = length;
-        mLayerState.mArray = r;
+        mLayerState.mChildren = r;
 
         ensurePadding();
     }
@@ -171,26 +172,26 @@
      */
     private void addLayer(Drawable layer, int id, int left, int top, int right, int bottom) {
         final LayerState st = mLayerState;
-        int N = st.mArray != null ? st.mArray.length : 0;
+        int N = st.mChildren != null ? st.mChildren.length : 0;
         int i = st.mNum;
         if (i >= N) {
-            Rec[] nu = new Rec[N + 10];
+            ChildDrawable[] nu = new ChildDrawable[N + 10];
             if (i > 0) {
-                System.arraycopy(st.mArray, 0, nu, 0, i);
+                System.arraycopy(st.mChildren, 0, nu, 0, i);
             }
-            st.mArray = nu;
+            st.mChildren = nu;
         }
 
         mLayerState.mChildrenChangingConfigurations |= layer.getChangingConfigurations();
         
-        Rec rec = new Rec();
-        st.mArray[i] = rec;
-        rec.mId = id;
-        rec.mDrawable = layer;
-        rec.mInsetL = left;
-        rec.mInsetT = top;
-        rec.mInsetR = right;
-        rec.mInsetB = bottom;
+        ChildDrawable childDrawable = new ChildDrawable();
+        st.mChildren[i] = childDrawable;
+        childDrawable.mId = id;
+        childDrawable.mDrawable = layer;
+        childDrawable.mInsetL = left;
+        childDrawable.mInsetT = top;
+        childDrawable.mInsetR = right;
+        childDrawable.mInsetB = bottom;
         st.mNum++;
 
         layer.setCallback(this);
@@ -203,7 +204,7 @@
      * @return The {@link Drawable} of the layer that has the given id in the hierarchy or null.
      */
     public Drawable findDrawableByLayerId(int id) {
-        final Rec[] layers = mLayerState.mArray;
+        final ChildDrawable[] layers = mLayerState.mChildren;
         
         for (int i = mLayerState.mNum - 1; i >= 0; i--) {
             if (layers[i].mId == id) {
@@ -221,7 +222,7 @@
      * @param id The ID to assign to the layer.
      */
     public void setId(int index, int id) {
-        mLayerState.mArray[index].mId = id;
+        mLayerState.mChildren[index].mId = id;
     }
     
     /**
@@ -240,7 +241,7 @@
      * @return The {@link android.graphics.drawable.Drawable} at the specified layer index.
      */
     public Drawable getDrawable(int index) {
-        return mLayerState.mArray[index].mDrawable;
+        return mLayerState.mChildren[index].mDrawable;
     }
 
     /**
@@ -251,7 +252,7 @@
      * @return The id of the layer or {@link android.view.View#NO_ID} if the layer has no id. 
      */
     public int getId(int index) {
-        return mLayerState.mArray[index].mId;
+        return mLayerState.mChildren[index].mId;
     }
     
     /**
@@ -263,7 +264,7 @@
      *         the id was not found).
      */
     public boolean setDrawableByLayerId(int id, Drawable drawable) {
-        final Rec[] layers = mLayerState.mArray;
+        final ChildDrawable[] layers = mLayerState.mChildren;
         
         for (int i = mLayerState.mNum - 1; i >= 0; i--) {
             if (layers[i].mId == id) {
@@ -282,11 +283,11 @@
         bottom -= b;
     */
     public void setLayerInset(int index, int l, int t, int r, int b) {
-        Rec rec = mLayerState.mArray[index];
-        rec.mInsetL = l;
-        rec.mInsetT = t;
-        rec.mInsetR = r;
-        rec.mInsetB = b;
+        ChildDrawable childDrawable = mLayerState.mChildren[index];
+        childDrawable.mInsetL = l;
+        childDrawable.mInsetT = t;
+        childDrawable.mInsetR = r;
+        childDrawable.mInsetB = b;
     }
 
     // overrides from Drawable.Callback
@@ -313,7 +314,7 @@
 
     @Override
     public void draw(Canvas canvas) {
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         for (int i=0; i<N; i++) {
             array[i].mDrawable.draw(canvas);
@@ -336,7 +337,7 @@
         padding.top = 0;
         padding.right = 0;
         padding.bottom = 0;
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         for (int i=0; i<N; i++) {
             reapplyPadding(i, array[i]);
@@ -351,7 +352,7 @@
     @Override
     public boolean setVisible(boolean visible, boolean restart) {
         boolean changed = super.setVisible(visible, restart);
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         for (int i=0; i<N; i++) {
             array[i].mDrawable.setVisible(visible, restart);
@@ -361,7 +362,7 @@
 
     @Override
     public void setDither(boolean dither) {
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         for (int i=0; i<N; i++) {
             array[i].mDrawable.setDither(dither);
@@ -370,7 +371,7 @@
 
     @Override
     public void setAlpha(int alpha) {
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         for (int i=0; i<N; i++) {
             array[i].mDrawable.setAlpha(alpha);
@@ -379,7 +380,7 @@
     
     @Override
     public void setColorFilter(ColorFilter cf) {
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         for (int i=0; i<N; i++) {
             array[i].mDrawable.setColorFilter(cf);
@@ -398,12 +399,12 @@
     
     @Override
     protected boolean onStateChange(int[] state) {
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         boolean paddingChanged = false;
         boolean changed = false;
         for (int i=0; i<N; i++) {
-            final Rec r = array[i];
+            final ChildDrawable r = array[i];
             if (r.mDrawable.setState(state)) {
                 changed = true;
             }
@@ -419,12 +420,12 @@
     
     @Override
     protected boolean onLevelChange(int level) {
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         boolean paddingChanged = false;
         boolean changed = false;
         for (int i=0; i<N; i++) {
-            final Rec r = array[i];
+            final ChildDrawable r = array[i];
             if (r.mDrawable.setLevel(level)) {
                 changed = true;
             }
@@ -440,11 +441,11 @@
 
     @Override
     protected void onBoundsChange(Rect bounds) {
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         int padL=0, padT=0, padR=0, padB=0;
         for (int i=0; i<N; i++) {
-            final Rec r = array[i];
+            final ChildDrawable r = array[i];
             r.mDrawable.setBounds(bounds.left + r.mInsetL + padL,
                                   bounds.top + r.mInsetT + padT,
                                   bounds.right - r.mInsetR - padR,
@@ -459,11 +460,11 @@
     @Override
     public int getIntrinsicWidth() {
         int width = -1;
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         int padL=0, padR=0;
         for (int i=0; i<N; i++) {
-            final Rec r = array[i];
+            final ChildDrawable r = array[i];
             int w = r.mDrawable.getIntrinsicWidth()
                   + r.mInsetL + r.mInsetR + padL + padR;
             if (w > width) {
@@ -478,11 +479,11 @@
     @Override
     public int getIntrinsicHeight() {
         int height = -1;
-        final Rec[] array = mLayerState.mArray;
+        final ChildDrawable[] array = mLayerState.mChildren;
         final int N = mLayerState.mNum;
         int padT=0, padB=0;
         for (int i=0; i<N; i++) {
-            final Rec r = array[i];
+            final ChildDrawable r = array[i];
             int h = r.mDrawable.getIntrinsicHeight() + r.mInsetT + r.mInsetB + + padT + padB;
             if (h > height) {
                 height = h;
@@ -493,7 +494,7 @@
         return height;
     }
 
-    private boolean reapplyPadding(int i, Rec r) {
+    private boolean reapplyPadding(int i, ChildDrawable r) {
         final Rect rect = mTmpRect;
         r.mDrawable.getPadding(rect);
         if (rect.left != mPaddingL[i] || rect.top != mPaddingT[i] ||
@@ -527,7 +528,20 @@
         return null;
     }
 
-    static class Rec {
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            final ChildDrawable[] array = mLayerState.mChildren;
+            final int N = mLayerState.mNum;
+            for (int i = 0; i < N; i++) {
+                array[i].mDrawable.mutate();
+            }
+            mMutated = true;
+        }
+        return this;
+    }
+
+    static class ChildDrawable {
         public Drawable mDrawable;
         public int mInsetL, mInsetT, mInsetR, mInsetB;
         public int mId;
@@ -535,7 +549,7 @@
 
     static class LayerState extends ConstantState {
         int mNum;
-        Rec[] mArray;
+        ChildDrawable[] mChildren;
 
         int mChangingConfigurations;
         int mChildrenChangingConfigurations;
@@ -551,18 +565,18 @@
 
         LayerState(LayerState orig, LayerDrawable owner) {
             if (orig != null) {
-                final Rec[] origRec = orig.mArray;
+                final ChildDrawable[] origChildDrawable = orig.mChildren;
                 final int N = orig.mNum;
 
                 mNum = N;
-                mArray = new Rec[N];
+                mChildren = new ChildDrawable[N];
 
                 mChangingConfigurations = orig.mChangingConfigurations;
                 mChildrenChangingConfigurations = orig.mChildrenChangingConfigurations;
                 
                 for (int i = 0; i < N; i++) {
-                    final Rec r = mArray[i] = new Rec();
-                    final Rec or = origRec[i];
+                    final ChildDrawable r = mChildren[i] = new ChildDrawable();
+                    final ChildDrawable or = origChildDrawable[i];
                     r.mDrawable = or.mDrawable.getConstantState().newDrawable();
                     r.mDrawable.setCallback(owner);
                     r.mInsetL = or.mInsetL;
@@ -579,7 +593,7 @@
                 mCheckedConstantState = mCanConstantState = true;
             } else {
                 mNum = 0;
-                mArray = null;
+                mChildren = null;
             }
         }
 
@@ -599,11 +613,9 @@
             }
 
             final int N = mNum;
-            int op = N > 0 ? mArray[0].mDrawable.getOpacity()
-                    : PixelFormat.TRANSPARENT;
+            int op = N > 0 ? mChildren[0].mDrawable.getOpacity() : PixelFormat.TRANSPARENT;
             for (int i = 1; i < N; i++) {
-                op = Drawable.resolveOpacity(op, mArray[i].mDrawable
-                        .getOpacity());
+                op = Drawable.resolveOpacity(op, mChildren[i].mDrawable.getOpacity());
             }
             mOpacity = op;
             mHaveOpacity = true;
@@ -618,7 +630,7 @@
             boolean stateful = false;
             final int N = mNum;
             for (int i = 0; i < N; i++) {
-                if (mArray[i].mDrawable.isStateful()) {
+                if (mChildren[i].mDrawable.isStateful()) {
                     stateful = true;
                     break;
                 }
@@ -630,11 +642,11 @@
         }
 
         public synchronized boolean canConstantState() {
-            if (!mCheckedConstantState && mArray != null) {
+            if (!mCheckedConstantState && mChildren != null) {
                 mCanConstantState = true;
                 final int N = mNum;
                 for (int i=0; i<N; i++) {
-                    if (mArray[i].mDrawable.getConstantState() == null) {
+                    if (mChildren[i].mDrawable.getConstantState() == null) {
                         mCanConstantState = false;
                         break;
                     }
diff --git a/graphics/java/android/graphics/drawable/LevelListDrawable.java b/graphics/java/android/graphics/drawable/LevelListDrawable.java
index 93dc32c..cf94a3a 100644
--- a/graphics/java/android/graphics/drawable/LevelListDrawable.java
+++ b/graphics/java/android/graphics/drawable/LevelListDrawable.java
@@ -26,24 +26,26 @@
 import android.util.AttributeSet;
 
 /**
- * 
- * A resource that manages a number of alternate Drawables, each assigned a maximum numerical value. 
- * Setting the level value of the object with {@link #setLevel(int)} will load the image with the next 
- * greater or equal value assigned to its max attribute. 
- * A good example use of 
+ * A resource that manages a number of alternate Drawables, each assigned a maximum numerical value.
+ * Setting the level value of the object with {@link #setLevel(int)} will load the image with the next
+ * greater or equal value assigned to its max attribute.
+ * A good example use of
  * a LevelListDrawable would be a battery level indicator icon, with different images to indicate the current
  * battery level.
  * <p>
  * It can be defined in an XML file with the <code>&lt;level-list></code> element.
  * Each Drawable level is defined in a nested <code>&lt;item></code>
  * </p>
+ *
  * @attr ref android.R.styleable#LevelListDrawableItem_minLevel
  * @attr ref android.R.styleable#LevelListDrawableItem_maxLevel
  * @attr ref android.R.styleable#LevelListDrawableItem_drawable
  */
 public class LevelListDrawable extends DrawableContainer {
-    public LevelListDrawable()
-    {
+    private final LevelListState mLevelListState;
+    private boolean mMutated;
+
+    public LevelListDrawable() {
         this(null);
     }
 
@@ -54,7 +56,7 @@
             onLevelChange(getLevel());
         }
     }
-    
+
     // overrides from Drawable
 
     @Override
@@ -65,21 +67,22 @@
         }
         return super.onLevelChange(level);
     }
-    
-    @Override public void inflate(Resources r, XmlPullParser parser,
-            AttributeSet attrs)
-    throws XmlPullParserException, IOException {
+
+    @Override
+    public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
+            throws XmlPullParserException, IOException {
+
         super.inflate(r, parser, attrs);
-        
+
         int type;
 
         int low = 0;
 
-        final int innerDepth = parser.getDepth()+1;
+        final int innerDepth = parser.getDepth() + 1;
         int depth;
-        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
-               && ((depth=parser.getDepth()) >= innerDepth
-                       || type != XmlPullParser.END_TAG)) {
+        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                && ((depth = parser.getDepth()) >= innerDepth
+                || type != XmlPullParser.END_TAG)) {
             if (type != XmlPullParser.START_TAG) {
                 continue;
             }
@@ -87,50 +90,60 @@
             if (depth > innerDepth || !parser.getName().equals("item")) {
                 continue;
             }
-            
+
             TypedArray a = r.obtainAttributes(attrs,
                     com.android.internal.R.styleable.LevelListDrawableItem);
-            
+
             low = a.getInt(
                     com.android.internal.R.styleable.LevelListDrawableItem_minLevel, 0);
             int high = a.getInt(
                     com.android.internal.R.styleable.LevelListDrawableItem_maxLevel, 0);
             int drawableRes = a.getResourceId(
                     com.android.internal.R.styleable.LevelListDrawableItem_drawable, 0);
-            
+
             a.recycle();
-            
+
             if (high < 0) {
                 throw new XmlPullParserException(parser.getPositionDescription()
-                    + ": <item> tag requires a 'maxLevel' attribute");
+                        + ": <item> tag requires a 'maxLevel' attribute");
             }
-            
+
             Drawable dr;
             if (drawableRes != 0) {
                 dr = r.getDrawable(drawableRes);
             } else {
-                while ((type=parser.next()) == XmlPullParser.TEXT) {
+                while ((type = parser.next()) == XmlPullParser.TEXT) {
                 }
                 if (type != XmlPullParser.START_TAG) {
                     throw new XmlPullParserException(
                             parser.getPositionDescription()
-                            + ": <item> tag requires a 'drawable' attribute or "
-                            + "child tag defining a drawable");
+                                    + ": <item> tag requires a 'drawable' attribute or "
+                                    + "child tag defining a drawable");
                 }
                 dr = Drawable.createFromXmlInner(r, parser, attrs);
             }
 
             mLevelListState.addLevel(low, high, dr);
-            low = high+1;
         }
 
         onLevelChange(getLevel());
     }
 
-    private final static class LevelListState extends DrawableContainerState
-    {
-        LevelListState(LevelListState orig, LevelListDrawable owner)
-        {
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mLevelListState.mLows = mLevelListState.mLows.clone();
+            mLevelListState.mHighs = mLevelListState.mHighs.clone();
+            mMutated = true;
+        }
+        return this;
+    }
+
+    private final static class LevelListState extends DrawableContainerState {
+        private int[] mLows;
+        private int[] mHighs;
+
+        LevelListState(LevelListState orig, LevelListDrawable owner) {
             super(orig, owner);
 
             if (orig != null) {
@@ -142,19 +155,17 @@
             }
         }
 
-        public void addLevel(int low, int high, Drawable drawable)
-        {
+        public void addLevel(int low, int high, Drawable drawable) {
             int pos = addChild(drawable);
             mLows[pos] = low;
             mHighs[pos] = high;
         }
 
-        public int indexOfLevel(int level)
-        {
+        public int indexOfLevel(int level) {
             final int[] lows = mLows;
             final int[] highs = mHighs;
             final int N = getChildCount();
-            for (int i=0; i<N; i++) {
+            for (int i = 0; i < N; i++) {
                 if (level >= lows[i] && level <= highs[i]) {
                     return i;
                 }
@@ -163,14 +174,12 @@
         }
 
         @Override
-        public Drawable newDrawable()
-        {
+        public Drawable newDrawable() {
             return new LevelListDrawable(this);
         }
 
         @Override
-        public void growArray(int oldSize, int newSize)
-        {
+        public void growArray(int oldSize, int newSize) {
             super.growArray(oldSize, newSize);
             int[] newInts = new int[newSize];
             System.arraycopy(mLows, 0, newInts, 0, oldSize);
@@ -179,19 +188,13 @@
             System.arraycopy(mHighs, 0, newInts, 0, oldSize);
             mHighs = newInts;
         }
-
-        private int[]   mLows;
-        private int[]   mHighs;
     }
 
-    private LevelListDrawable(LevelListState state)
-    {
+    private LevelListDrawable(LevelListState state) {
         LevelListState as = new LevelListState(state, this);
         mLevelListState = as;
         setConstantState(as);
         onLevelChange(getLevel());
     }
-
-    private final LevelListState mLevelListState;
 }
 
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index c98ef5b..3ded37b 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -26,9 +26,13 @@
  *
  */
 public class NinePatchDrawable extends Drawable {
+    private NinePatchState mNinePatchState;
+    private NinePatch mNinePatch;
+    private Rect mPadding;
+    private Paint mPaint;
+    private boolean mMutated;
 
-    public NinePatchDrawable(Bitmap bitmap, byte[] chunk,
-                             Rect padding, String srcName) {
+    public NinePatchDrawable(Bitmap bitmap, byte[] chunk, Rect padding, String srcName) {
         this(new NinePatchState(new NinePatch(bitmap, chunk, srcName), padding));
     }
     
@@ -45,8 +49,7 @@
 
     @Override
     public int getChangingConfigurations() {
-        return super.getChangingConfigurations()
-                | mNinePatchState.mChangingConfigurations;
+        return super.getChangingConfigurations() | mNinePatchState.mChangingConfigurations;
     }
     
     @Override
@@ -104,12 +107,13 @@
     }
 
     /**
-     * Returns a {@link android.graphics.PixelFormat graphics.PixelFormat} value of OPAQUE or TRANSLUCENT.
+     * Returns a {@link android.graphics.PixelFormat graphics.PixelFormat}
+     * value of OPAQUE or TRANSLUCENT.
      */
     @Override
     public int getOpacity() {
-        return mNinePatch.hasAlpha() || (mPaint != null && mPaint.getAlpha() < 255)
-            ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE;
+        return mNinePatch.hasAlpha() || (mPaint != null && mPaint.getAlpha() < 255) ?
+                PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE;
     }
 
     @Override
@@ -123,16 +127,35 @@
         return mNinePatchState;
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mNinePatchState = new NinePatchState(mNinePatchState);
+            mNinePatch = mNinePatchState.mNinePatch;
+            mPadding = mNinePatchState.mPadding;
+            mMutated = true;
+        }
+        return this;
+    }
+
     final static class NinePatchState extends ConstantState {
-        NinePatchState(NinePatch ninePatch, Rect padding)
-        {
+        final NinePatch mNinePatch;
+        final Rect mPadding;
+        int mChangingConfigurations;
+
+        NinePatchState(NinePatch ninePatch, Rect padding) {
             mNinePatch = ninePatch;
             mPadding = padding;
         }
 
+        NinePatchState(NinePatchState state) {
+            mNinePatch = new NinePatch(state.mNinePatch);
+            mPadding = new Rect(state.mPadding);
+            mChangingConfigurations = state.mChangingConfigurations;
+        }
+
         @Override
-        public Drawable newDrawable()
-        {
+        public Drawable newDrawable() {
             return new NinePatchDrawable(this);
         }
         
@@ -140,10 +163,6 @@
         public int getChangingConfigurations() {
             return mChangingConfigurations;
         }
-
-        final NinePatch mNinePatch;
-        final Rect      mPadding;
-        int             mChangingConfigurations;
     }
 
     private NinePatchDrawable(NinePatchState state) {
@@ -151,10 +170,5 @@
         mNinePatch = state.mNinePatch;
         mPadding = state.mPadding;
     }
-
-    private final NinePatchState    mNinePatchState;
-    private final NinePatch         mNinePatch;
-    private final Rect              mPadding;
-    private Paint                   mPaint;
 }
 
diff --git a/graphics/java/android/graphics/drawable/RotateDrawable.java b/graphics/java/android/graphics/drawable/RotateDrawable.java
index 3e03ed4..e4b821a 100644
--- a/graphics/java/android/graphics/drawable/RotateDrawable.java
+++ b/graphics/java/android/graphics/drawable/RotateDrawable.java
@@ -45,6 +45,10 @@
  * @attr ref android.R.styleable#RotateDrawable_drawable
  */
 public class RotateDrawable extends Drawable implements Drawable.Callback {
+    private static final float MAX_LEVEL = 10000.0f;
+
+    private RotateState mState;
+    private boolean mMutated;
 
     /**
      * <p>Create a new rotating drawable with an empty state.</p>
@@ -248,6 +252,15 @@
         }
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mState.mDrawable.mutate();
+            mMutated = true;
+        }
+        return this;
+    }
+
     /**
      * <p>Represents the state of a rotation for a given drawable. The same
      * rotate drawable can be invoked with different states to drive several
@@ -268,6 +281,9 @@
 
         float mCurrentDegrees;
 
+        private boolean mCanConstantState;
+        private boolean mCheckedConstantState;        
+
         public RotateState(RotateState source, RotateDrawable owner) {
             if (source != null) {
                 mDrawable = source.mDrawable.getConstantState().newDrawable();
@@ -300,12 +316,5 @@
 
             return mCanConstantState;
         }
-
-        private boolean mCanConstantState;
-        private boolean mCheckedConstantState;
     }
-
-    private static final float MAX_LEVEL = 10000.0f;
-
-    private RotateState mState;
 }
diff --git a/graphics/java/android/graphics/drawable/ScaleDrawable.java b/graphics/java/android/graphics/drawable/ScaleDrawable.java
index c40c8c0..b3322c9 100644
--- a/graphics/java/android/graphics/drawable/ScaleDrawable.java
+++ b/graphics/java/android/graphics/drawable/ScaleDrawable.java
@@ -24,7 +24,6 @@
 import android.graphics.*;
 import android.view.Gravity;
 import android.util.AttributeSet;
-import android.util.Log;
 
 import java.io.IOException;
 
@@ -44,6 +43,7 @@
  */
 public class ScaleDrawable extends Drawable implements Drawable.Callback {
     private ScaleState mScaleState;
+    private boolean mMutated;
     private final Rect mTmpRect = new Rect();
 
     ScaleDrawable() {
@@ -234,7 +234,25 @@
         return null;
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mScaleState.mDrawable.mutate();
+            mMutated = true;
+        }
+        return this;
+    }
+
     final static class ScaleState extends ConstantState {
+        Drawable mDrawable;
+        int mChangingConfigurations;
+        float mScaleWidth;
+        float mScaleHeight;
+        int mGravity;
+
+        private boolean mCheckedConstantState;
+        private boolean mCanConstantState;
+
         ScaleState(ScaleState orig, ScaleDrawable owner) {
             if (orig != null) {
                 mDrawable = orig.mDrawable.getConstantState().newDrawable();
@@ -264,15 +282,6 @@
 
             return mCanConstantState;
         }
-
-        Drawable mDrawable;
-        int mChangingConfigurations;
-        float mScaleWidth;
-        float mScaleHeight;
-        int mGravity;
-
-        private boolean mCheckedConstantState;
-        private boolean mCanConstantState;
     }
 
     private ScaleDrawable(ScaleState state) {
diff --git a/graphics/java/android/graphics/drawable/ShapeDrawable.java b/graphics/java/android/graphics/drawable/ShapeDrawable.java
index 7e1284f..d24194f 100644
--- a/graphics/java/android/graphics/drawable/ShapeDrawable.java
+++ b/graphics/java/android/graphics/drawable/ShapeDrawable.java
@@ -28,15 +28,24 @@
 import java.io.IOException;
 
 /**
- * An object that draws primitive shapes. 
+ * A Drawable object that draws primitive shapes. 
  * A ShapeDrawable takes a {@link android.graphics.drawable.shapes.Shape}
  * object and manages its presence on the screen. If no Shape is given, then
  * the ShapeDrawable will default to a 
  * {@link android.graphics.drawable.shapes.RectShape}.
+ *
+ * @attr ref android.R.styleable#ShapeDrawablePadding_left
+ * @attr ref android.R.styleable#ShapeDrawablePadding_top
+ * @attr ref android.R.styleable#ShapeDrawablePadding_right
+ * @attr ref android.R.styleable#ShapeDrawablePadding_bottom
+ * @attr ref android.R.styleable#ShapeDrawable_color
+ * @attr ref android.R.styleable#ShapeDrawable_width
+ * @attr ref android.R.styleable#ShapeDrawable_height
  */
 public class ShapeDrawable extends Drawable {
     private ShapeState mShapeState;
-    
+    private boolean mMutated;
+
     /**
      * ShapeDrawable constructor.
      */
@@ -334,6 +343,21 @@
         return mShapeState;
     }
 
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            mShapeState.mPaint = new Paint(mShapeState.mPaint);
+            mShapeState.mPadding = new Rect(mShapeState.mPadding);
+            try {
+                mShapeState.mShape = mShapeState.mShape.clone();
+            } catch (CloneNotSupportedException e) {
+                return null;
+            }
+            mMutated = true;
+        }
+        return this;
+    }
+
     /**
      * Defines the intrinsic properties of this ShapeDrawable's Shape.
      */
diff --git a/graphics/java/android/graphics/drawable/StateListDrawable.java b/graphics/java/android/graphics/drawable/StateListDrawable.java
index 1dc16272..475825c 100644
--- a/graphics/java/android/graphics/drawable/StateListDrawable.java
+++ b/graphics/java/android/graphics/drawable/StateListDrawable.java
@@ -27,10 +27,9 @@
 import android.util.StateSet;
 
 /**
- * 
  * Lets you assign a number of graphic images to a single Drawable and swap out the visible item by a string
  * ID value.
- *
+ * <p/>
  * <p>It can be defined in an XML file with the <code>&lt;selector></code> element.
  * Each state Drawable is defined in a nested <code>&lt;item></code> element.</p>
  *
@@ -51,15 +50,18 @@
  * @attr ref android.R.styleable#DrawableStates_state_pressed
  */
 public class StateListDrawable extends DrawableContainer {
-    public StateListDrawable()
-    {
+    private final StateListState mStateListState;
+    private boolean mMutated;
+
+    public StateListDrawable() {
         this(null);
     }
 
     /**
      * Add a new image/string ID to the set of images.
+     *
      * @param stateSet - An array of resource Ids to associate with the image.
-     * Switch to this image by calling setState(). 
+     *                 Switch to this image by calling setState().
      * @param drawable -The image to show.
      */
     public void addState(int[] stateSet, Drawable drawable) {
@@ -74,7 +76,7 @@
     public boolean isStateful() {
         return true;
     }
-    
+
     @Override
     protected boolean onStateChange(int[] stateSet) {
         int idx = mStateListState.indexOfStateSet(stateSet);
@@ -87,30 +89,31 @@
         return super.onStateChange(stateSet);
     }
 
-    @Override public void inflate(Resources r, XmlPullParser parser,
+    @Override
+    public void inflate(Resources r, XmlPullParser parser,
             AttributeSet attrs)
-    throws XmlPullParserException, IOException {
-        
+            throws XmlPullParserException, IOException {
+
         TypedArray a = r.obtainAttributes(attrs,
                 com.android.internal.R.styleable.StateListDrawable);
 
         super.inflateWithAttributes(r, parser, a,
                 com.android.internal.R.styleable.StateListDrawable_visible);
-        
+
         mStateListState.setVariablePadding(a.getBoolean(
                 com.android.internal.R.styleable.StateListDrawable_variablePadding, false));
         mStateListState.setConstantSize(a.getBoolean(
                 com.android.internal.R.styleable.StateListDrawable_constantSize, false));
-            
+
         a.recycle();
-        
+
         int type;
 
-        final int innerDepth = parser.getDepth()+1;
+        final int innerDepth = parser.getDepth() + 1;
         int depth;
-        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
-               && ((depth=parser.getDepth()) >= innerDepth
-                       || type != XmlPullParser.END_TAG)) {
+        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                && ((depth = parser.getDepth()) >= innerDepth
+                || type != XmlPullParser.END_TAG)) {
             if (type != XmlPullParser.START_TAG) {
                 continue;
             }
@@ -118,9 +121,9 @@
             if (depth > innerDepth || !parser.getName().equals("item")) {
                 continue;
             }
-            
+
             int drawableRes = 0;
-            
+
             int i;
             int j = 0;
             final int numAttrs = attrs.getAttributeCount();
@@ -132,27 +135,27 @@
                     drawableRes = attrs.getAttributeResourceValue(i, 0);
                 } else {
                     states[j++] = attrs.getAttributeBooleanValue(i, false)
-                                  ? stateResId
-                                  : -stateResId;
+                            ? stateResId
+                            : -stateResId;
                 }
             }
             states = StateSet.trimStateSet(states, j);
-            
+
             Drawable dr;
             if (drawableRes != 0) {
                 dr = r.getDrawable(drawableRes);
             } else {
-                while ((type=parser.next()) == XmlPullParser.TEXT) {
+                while ((type = parser.next()) == XmlPullParser.TEXT) {
                 }
                 if (type != XmlPullParser.START_TAG) {
                     throw new XmlPullParserException(
                             parser.getPositionDescription()
-                            + ": <item> tag requires a 'drawable' attribute or "
-                            + "child tag defining a drawable");
+                                    + ": <item> tag requires a 'drawable' attribute or "
+                                    + "child tag defining a drawable");
                 }
                 dr = Drawable.createFromXmlInner(r, parser, attrs);
             }
-            
+
             mStateListState.addStateSet(states, dr);
         }
 
@@ -162,49 +165,63 @@
     StateListState getStateListState() {
         return mStateListState;
     }
-    
+
     /**
      * Gets the number of states contained in this drawable.
-     * 
+     *
      * @return The number of states contained in this drawable.
+     * @hide pending API council
      * @see #getStateSet(int)
      * @see #getStateDrawable(int)
-     * @hide pending API council
      */
     public int getStateCount() {
-        return mStateListState.getChildCount();        
+        return mStateListState.getChildCount();
     }
 
     /**
      * Gets the state set at an index.
-     * 
+     *
      * @param index The index of the state set.
      * @return The state set at the index.
+     * @hide pending API council
      * @see #getStateCount()
      * @see #getStateDrawable(int)
-     * @hide pending API council
      */
     public int[] getStateSet(int index) {
         return mStateListState.mStateSets[index];
     }
-    
+
     /**
      * Gets the drawable at an index.
-     * 
+     *
      * @param index The index of the drawable.
      * @return The drawable at the index.
+     * @hide pending API council
      * @see #getStateCount()
      * @see #getStateSet(int)
-     * @hide pending API council
      */
     public Drawable getStateDrawable(int index) {
         return mStateListState.getChildren()[index];
     }
-    
-    static final class StateListState extends DrawableContainerState
-    {
-        StateListState(StateListState orig, StateListDrawable owner)
-        {
+
+    @Override
+    public Drawable mutate() {
+        if (!mMutated && super.mutate() == this) {
+            final int[][] sets = mStateListState.mStateSets;
+            final int count = sets.length;
+            mStateListState.mStateSets = new int[count][];
+            for (int i = 0; i < count; i++) {
+                mStateListState.mStateSets[i] = sets[i].clone();
+            }
+            mMutated = true;
+        }
+        return this;
+    }
+
+    static final class StateListState extends DrawableContainerState {
+        private int[][] mStateSets;
+
+        StateListState(StateListState orig, StateListDrawable owner) {
             super(orig, owner);
 
             if (orig != null) {
@@ -220,11 +237,10 @@
             return pos;
         }
 
-        private int indexOfStateSet(int[] stateSet)
-        {
+        private int indexOfStateSet(int[] stateSet) {
             final int[][] stateSets = mStateSets;
             final int N = getChildCount();
-            for (int i=0; i<N; i++) {
+            for (int i = 0; i < N; i++) {
                 if (StateSet.stateSetMatches(stateSets[i], stateSet)) {
                     return i;
                 }
@@ -233,31 +249,24 @@
         }
 
         @Override
-        public Drawable newDrawable()
-        {
+        public Drawable newDrawable() {
             return new StateListDrawable(this);
         }
 
         @Override
-        public void growArray(int oldSize, int newSize)
-        {
+        public void growArray(int oldSize, int newSize) {
             super.growArray(oldSize, newSize);
             final int[][] newStateSets = new int[newSize][];
             System.arraycopy(mStateSets, 0, newStateSets, 0, oldSize);
             mStateSets = newStateSets;
         }
-
-        private int[][]         mStateSets;
     }
 
-    private StateListDrawable(StateListState state)
-    {
+    private StateListDrawable(StateListState state) {
         StateListState as = new StateListState(state, this);
         mStateListState = as;
         setConstantState(as);
         onStateChange(getState());
     }
-
-    private final StateListState mStateListState;
 }
 
diff --git a/graphics/java/android/graphics/drawable/TransitionDrawable.java b/graphics/java/android/graphics/drawable/TransitionDrawable.java
index a99d4e50..358f889 100644
--- a/graphics/java/android/graphics/drawable/TransitionDrawable.java
+++ b/graphics/java/android/graphics/drawable/TransitionDrawable.java
@@ -63,7 +63,9 @@
     private int mFrom;
     private int mTo;
     private int mDuration;
-    private TransitionState mState;
+    private int mOriginalDuration;
+    private int mAlpha = 0;
+    private boolean mCrossFade;
 
     /**
      * Create a new transition drawable with the specified list of layers. At least
@@ -85,12 +87,10 @@
 
     private TransitionDrawable(TransitionState state) {
         super(state);
-        mState = state;
     }
 
     private TransitionDrawable(TransitionState state, Drawable[] layers) {
         super(layers, state);
-        mState = state;
     }
 
     @Override
@@ -106,8 +106,8 @@
     public void startTransition(int durationMillis) {
         mFrom = 0;
         mTo = 255;
-        mState.mAlpha = 0;
-        mState.mDuration = mDuration = durationMillis;
+        mAlpha = 0;
+        mDuration = mOriginalDuration = durationMillis;
         mReverse = false;
         mTransitionState = TRANSITION_STARTING;
         invalidateSelf();
@@ -117,7 +117,7 @@
      * Show only the first layer.
      */
     public void resetTransition() {
-        mState.mAlpha = 0;
+        mAlpha = 0;
         mTransitionState = TRANSITION_NONE;
         invalidateSelf();
     }
@@ -133,36 +133,35 @@
     public void reverseTransition(int duration) {
         final long time = SystemClock.uptimeMillis();
         // Animation is over
-        if (time - mStartTimeMillis > mState.mDuration) {
-            if (mState.mAlpha == 0) {
+        if (time - mStartTimeMillis > mDuration) {
+            if (mAlpha == 0) {
                 mFrom = 0;
                 mTo = 255;
-                mState.mAlpha = 0;
+                mAlpha = 0;
                 mReverse = false;
             } else {
                 mFrom = 255;
                 mTo = 0;
-                mState.mAlpha = 255;
+                mAlpha = 255;
                 mReverse = true;
             }
-            mDuration = mState.mDuration = duration;
+            mDuration = mOriginalDuration = duration;
             mTransitionState = TRANSITION_STARTING;
             invalidateSelf();
             return;
         }
 
         mReverse = !mReverse;
-        mFrom = mState.mAlpha;
+        mFrom = mAlpha;
         mTo = mReverse ? 0 : 255;
         mDuration = (int) (mReverse ? time - mStartTimeMillis :
-                mState.mDuration - (time - mStartTimeMillis));
+                mOriginalDuration - (time - mStartTimeMillis));
         mTransitionState = TRANSITION_STARTING;
     }
 
     @Override
     public void draw(Canvas canvas) {
         boolean done = true;
-        final TransitionState state = mState;
 
         switch (mTransitionState) {
             case TRANSITION_STARTING:
@@ -177,14 +176,14 @@
                             (SystemClock.uptimeMillis() - mStartTimeMillis) / mDuration;
                     done = normalized >= 1.0f;
                     normalized = Math.min(normalized, 1.0f);
-                    state.mAlpha = (int) (mFrom  + (mTo - mFrom) * normalized);
+                    mAlpha = (int) (mFrom  + (mTo - mFrom) * normalized);
                 }
                 break;
         }
       
-        final int alpha = state.mAlpha;
-        final boolean crossFade = state.mCrossFade;
-        final Rec[] array = mLayerState.mArray;
+        final int alpha = mAlpha;
+        final boolean crossFade = mCrossFade;
+        final ChildDrawable[] array = mLayerState.mChildren;
         Drawable d;
 
         d = array[0].mDrawable;
@@ -217,7 +216,7 @@
      * @param enabled True to enable cross fading, false otherwise.
      */
     public void setCrossFadeEnabled(boolean enabled) {
-        mState.mCrossFade = enabled;
+        mCrossFade = enabled;
     }
 
     /**
@@ -226,14 +225,10 @@
      * @return True if cross fading is enabled, false otherwise.
      */
     public boolean isCrossFadeEnabled() {
-        return mState.mCrossFade;
+        return mCrossFade;
     }
 
     static class TransitionState extends LayerState {
-        int mAlpha = 0;
-        int mDuration;
-        boolean mCrossFade;
-
         TransitionState(TransitionState orig, TransitionDrawable owner) {
             super(orig, owner);
         }
diff --git a/graphics/java/android/graphics/drawable/package.html b/graphics/java/android/graphics/drawable/package.html
index 17ee865..da49df7 100644
--- a/graphics/java/android/graphics/drawable/package.html
+++ b/graphics/java/android/graphics/drawable/package.html
@@ -4,6 +4,6 @@
 display only, such as bitmaps and gradients. These elements are often used
 by widgets as background images or simply as indicators (for example, a volume
 level indicator). You can create most of these in XML as described in <a 
-href="{@docRoot}reference/available-resources.html">Resources</a>.
+href="{@docRoot}guide/topics/resources/available-resources.html">Availeble Resource Types</a>.
 </BODY>
 </HTML>
diff --git a/graphics/java/android/graphics/drawable/shapes/PathShape.java b/graphics/java/android/graphics/drawable/shapes/PathShape.java
index 3656a0b..30b7347 100644
--- a/graphics/java/android/graphics/drawable/shapes/PathShape.java
+++ b/graphics/java/android/graphics/drawable/shapes/PathShape.java
@@ -64,5 +64,12 @@
         mScaleX = width / mStdWidth;
         mScaleY = height / mStdHeight;
     }
+
+    @Override
+    public PathShape clone() throws CloneNotSupportedException {
+        PathShape shape = (PathShape) super.clone();
+        shape.mPath = new Path(mPath);
+        return shape;
+    }
 }
 
diff --git a/graphics/java/android/graphics/drawable/shapes/RectShape.java b/graphics/java/android/graphics/drawable/shapes/RectShape.java
index 4f038ae..a3d2654 100644
--- a/graphics/java/android/graphics/drawable/shapes/RectShape.java
+++ b/graphics/java/android/graphics/drawable/shapes/RectShape.java
@@ -50,4 +50,11 @@
     protected final RectF rect() {
         return mRect;
     }
+
+    @Override
+    public RectShape clone() throws CloneNotSupportedException {
+        final RectShape shape = (RectShape) super.clone();
+        shape.mRect = new RectF(mRect);
+        return shape;
+    }
 }
diff --git a/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java b/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java
index 54ef3f7..f4cf15c 100644
--- a/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java
+++ b/graphics/java/android/graphics/drawable/shapes/RoundRectShape.java
@@ -105,4 +105,15 @@
             }
         }
     }
+
+    @Override
+    public RoundRectShape clone() throws CloneNotSupportedException {
+        RoundRectShape shape = (RoundRectShape) super.clone();
+        shape.mOuterRadii = mOuterRadii.clone();
+        shape.mInnerRadii = mInnerRadii.clone();
+        shape.mInset = new RectF(mInset);
+        shape.mInnerRect = new RectF(mInnerRect);
+        shape.mPath = new Path(mPath);
+        return shape;
+    }
 }
diff --git a/graphics/java/android/graphics/drawable/shapes/Shape.java b/graphics/java/android/graphics/drawable/shapes/Shape.java
index fc54bc1..4e192f95 100644
--- a/graphics/java/android/graphics/drawable/shapes/Shape.java
+++ b/graphics/java/android/graphics/drawable/shapes/Shape.java
@@ -25,7 +25,7 @@
  * but more graphical control is available if you instead pass
  * it to a {@link android.graphics.drawable.ShapeDrawable}.
  */
-public abstract class Shape {
+public abstract class Shape implements Cloneable {
     private float mWidth;
     private float mHeight;
     
@@ -92,4 +92,9 @@
      * @param height the new height of the Shape
      */
     protected void onResize(float width, float height) {}
+
+    @Override
+    public Shape clone() throws CloneNotSupportedException {
+        return (Shape) super.clone();
+    }
 }
diff --git a/include/GLES/egl.h b/include/GLES/egl.h
deleted file mode 100644
index 08834ab..0000000
--- a/include/GLES/egl.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_EGL_H
-#define ANDROID_EGL_H
-
-#include <GLES/gl.h>
-#include <GLES/egltypes.h>
-#include <GLES/eglnatives.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define EGL_VERSION_1_0         1
-#define EGL_VERSION_1_1         1
-#define EGL_VERSION_1_2         1
-
-#define EGL_FALSE               0
-#define EGL_TRUE                1
-
-/* Errors */
-#define EGL_SUCCESS                     0x3000
-#define EGL_NOT_INITIALIZED             0x3001
-#define EGL_BAD_ACCESS                  0x3002
-#define EGL_BAD_ALLOC                   0x3003
-#define EGL_BAD_ATTRIBUTE               0x3004
-#define EGL_BAD_CONFIG                  0x3005
-#define EGL_BAD_CONTEXT                 0x3006
-#define EGL_BAD_CURRENT_SURFACE         0x3007
-#define EGL_BAD_DISPLAY                 0x3008
-#define EGL_BAD_MATCH                   0x3009
-#define EGL_BAD_NATIVE_PIXMAP           0x300A
-#define EGL_BAD_NATIVE_WINDOW           0x300B
-#define EGL_BAD_PARAMETER               0x300C
-#define EGL_BAD_SURFACE                 0x300D
-#define EGL_CONTEXT_LOST                0x300E
-
-/* Config attributes */
-#define EGL_BUFFER_SIZE                 0x3020
-#define EGL_ALPHA_SIZE                  0x3021
-#define EGL_BLUE_SIZE                   0x3022
-#define EGL_GREEN_SIZE                  0x3023
-#define EGL_RED_SIZE                    0x3024
-#define EGL_DEPTH_SIZE                  0x3025
-#define EGL_STENCIL_SIZE                0x3026
-#define EGL_CONFIG_CAVEAT               0x3027
-#define EGL_CONFIG_ID                   0x3028
-#define EGL_LEVEL                       0x3029
-#define EGL_MAX_PBUFFER_HEIGHT          0x302A
-#define EGL_MAX_PBUFFER_PIXELS          0x302B
-#define EGL_MAX_PBUFFER_WIDTH           0x302C
-#define EGL_NATIVE_RENDERABLE           0x302D
-#define EGL_NATIVE_VISUAL_ID            0x302E
-#define EGL_NATIVE_VISUAL_TYPE          0x302F
-#define EGL_SAMPLES                     0x3031
-#define EGL_SAMPLE_BUFFERS              0x3032
-#define EGL_SURFACE_TYPE                0x3033
-#define EGL_TRANSPARENT_TYPE            0x3034
-#define EGL_TRANSPARENT_BLUE_VALUE      0x3035
-#define EGL_TRANSPARENT_GREEN_VALUE     0x3036
-#define EGL_TRANSPARENT_RED_VALUE       0x3037
-#define EGL_NONE                        0x3038
-#define EGL_BIND_TO_TEXTURE_RGB         0x3039
-#define EGL_BIND_TO_TEXTURE_RGBA        0x303A
-#define EGL_MIN_SWAP_INTERVAL           0x303B
-#define EGL_MAX_SWAP_INTERVAL           0x303C
-#define EGL_LUMINANCE_SIZE              0x303D
-#define EGL_ALPHA_MASK_SIZE             0x303E
-#define EGL_COLOR_BUFFER_TYPE           0x303F
-#define EGL_RENDERABLE_TYPE             0x3040
-
-/* Config values */
-#define EGL_DONT_CARE                   ((EGLint)-1)
-
-#define EGL_SLOW_CONFIG                 0x3050
-#define EGL_NON_CONFORMANT_CONFIG       0x3051
-#define EGL_TRANSPARENT_RGB             0x3052
-#define EGL_NO_TEXTURE                  0x305C
-#define EGL_TEXTURE_RGB                 0x305D
-#define EGL_TEXTURE_RGBA                0x305E
-#define EGL_TEXTURE_2D                  0x305F
-#define EGL_RGB_BUFFER                  0x308E
-#define EGL_LUMINANCE_BUFFER            0x308F
-
-/* Config attribute mask bits */
-#define EGL_PBUFFER_BIT                 0x01
-#define EGL_PIXMAP_BIT                  0x02
-#define EGL_WINDOW_BIT                  0x04
-#define EGL_OPENGL_ES_BIT               0x01
-#define EGL_OPENVG_BIT                  0x02
-
-/* String names */
-#define EGL_VENDOR                      0x3053
-#define EGL_VERSION                     0x3054
-#define EGL_EXTENSIONS                  0x3055
-#define EGL_CLIENT_APIS                 0x308D
-
-/* Surface attributes */
-#define EGL_HEIGHT                      0x3056
-#define EGL_WIDTH                       0x3057
-#define EGL_LARGEST_PBUFFER             0x3058
-#define EGL_TEXTURE_FORMAT              0x3080
-#define EGL_TEXTURE_TARGET              0x3081
-#define EGL_MIPMAP_TEXTURE              0x3082
-#define EGL_MIPMAP_LEVEL                0x3083
-#define EGL_RENDER_BUFFER               0x3086
-#define EGL_COLORSPACE                  0x3087
-#define EGL_ALPHA_FORMAT                0x3088
-#define EGL_HORIZONTAL_RESOLUTION       0x3090
-#define EGL_VERTICAL_RESOLUTION         0x3091
-#define EGL_PIXEL_ASPECT_RATIO          0x3092
-#define EGL_SWAP_BEHAVIOR               0x3093
-
-#define EGL_BACK_BUFFER                 0x3084
-#define EGL_SINGLE_BUFFER               0x3085
-
-#define EGL_DISPLAY_SCALING             10000
-
-#define EGL_UNKNOWN                     ((EGLint)-1)
-
-/* Back buffer swap behaviors */
-#define EGL_BUFFER_PRESERVED            0x3094
-#define EGL_BUFFER_DESTROYED            0x3095
-
-/* CreatePbufferFromClientBuffer buffer types */
-#define EGL_OPENVG_IMAGE                0x3096
-
-/* QueryContext targets */
-#define EGL_CONTEXT_CLIENT_TYPE         0x3097
-
-/* BindAPI/QueryAPI targets */
-#define EGL_OPENGL_ES_API               0x30A0
-#define EGL_OPENVG_API                  0x30A1
-
-/* WaitNative engines */
-#define EGL_CORE_NATIVE_ENGINE          0x305B
-
-/* Current surfaces */
-#define EGL_DRAW                        0x3059
-#define EGL_READ                        0x305A
-
-
-EGLDisplay eglGetDisplay(NativeDisplayType display);
-EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
-EGLBoolean eglTerminate(EGLDisplay dpy);
-
-EGLBoolean eglGetConfigs(   EGLDisplay dpy,
-                            EGLConfig *configs,
-                            EGLint config_size, EGLint *num_config);
-
-EGLBoolean eglChooseConfig( EGLDisplay dpy, const EGLint *attrib_list,
-                            EGLConfig *configs, EGLint config_size,
-                            EGLint *num_config);
-
-EGLBoolean eglGetConfigAttrib(  EGLDisplay dpy, EGLConfig config,
-                                EGLint attribute, EGLint *value);
-
-EGLSurface eglCreateWindowSurface(  EGLDisplay dpy, EGLConfig config,
-                                    NativeWindowType window,
-                                    const EGLint *attrib_list);
-
-EGLSurface eglCreatePixmapSurface(  EGLDisplay dpy, EGLConfig config,
-                                    NativePixmapType pixmap,
-                                    const EGLint *attrib_list);
-
-EGLSurface eglCreatePbufferSurface( EGLDisplay dpy, EGLConfig config,
-                                    const EGLint *attrib_list);
-                                    
-EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
-
-EGLBoolean eglQuerySurface( EGLDisplay dpy, EGLSurface surface,
-                            EGLint attribute, EGLint *value);
-
-EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config,
-                            EGLContext share_list, const EGLint *attrib_list);
-
-EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
-
-EGLBoolean eglMakeCurrent(  EGLDisplay dpy, EGLSurface draw,
-                            EGLSurface read, EGLContext ctx);
-
-EGLContext eglGetCurrentContext(void);
-EGLSurface eglGetCurrentSurface(EGLint readdraw);
-EGLDisplay eglGetCurrentDisplay(void);
-EGLBoolean eglQueryContext( EGLDisplay dpy, EGLContext ctx,
-                            EGLint attribute, EGLint *value);
-
-EGLBoolean eglWaitGL(void);
-EGLBoolean eglWaitNative(EGLint engine);
-EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface draw);
-EGLBoolean eglCopyBuffers(  EGLDisplay dpy, EGLSurface surface,
-                            NativePixmapType target);
-
-EGLint eglGetError(void);
-const char* eglQueryString(EGLDisplay dpy, EGLint name);
-void (*eglGetProcAddress (const char *procname))();
-
-/* ----------------------------------------------------------------------------
- * EGL 1.1
- * ----------------------------------------------------------------------------
- */
-
-EGLBoolean eglSurfaceAttrib(
-        EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
-EGLBoolean eglBindTexImage(
-        EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-EGLBoolean eglReleaseTexImage(
-        EGLDisplay dpy, EGLSurface surface, EGLint buffer);
-
-EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval);
-
-/* ----------------------------------------------------------------------------
- * EGL 1.2
- * ----------------------------------------------------------------------------
- */
-
-EGLBoolean eglBindAPI(EGLenum api);
-EGLenum eglQueryAPI(void);
-EGLBoolean eglWaitClient(void);
-EGLBoolean eglReleaseThread(void);
-EGLSurface eglCreatePbufferFromClientBuffer(
-          EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
-          EGLConfig config, const EGLint *attrib_list);
-
-/* ----------------------------------------------------------------------------
- * Android extentions
- * ----------------------------------------------------------------------------
- */
-
-EGLBoolean eglSwapRectangleANDROID(EGLDisplay dpy, EGLSurface draw,
-        EGLint l, EGLint t, EGLint w, EGLint h);
-
-EGLBoolean eglCopyFrontToBackANDROID(EGLDisplay dpy,
-        EGLSurface surface,
-        EGLint l, EGLint t, EGLint w, EGLint h);
-
-const char* eglQueryStringConfigANDROID(
-        EGLDisplay dpy, EGLConfig config, EGLint name);
-
-void* eglGetRenderBufferAddressANDROID(EGLDisplay dpy, EGLSurface surface);
-
-EGLBoolean eglCopyBitsANDROID(EGLDisplay dpy,
-        NativeWindowType draw, EGLint x, EGLint y,
-        NativeWindowType read,
-        EGLint crop_x, EGLint crop_y, EGLint crop_w, EGLint crop_h,
-        EGLint flags);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /*ANDROID_EGL_H*/
diff --git a/include/GLES/egltypes.h b/include/GLES/egltypes.h
deleted file mode 100644
index 698239b..0000000
--- a/include/GLES/egltypes.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_EGL_TYPES_H
-#define ANDROID_EGL_TYPES_H
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef unsigned int EGLBoolean;
-typedef int32_t EGLint;
-typedef int EGLenum;
-typedef void *EGLDisplay;
-typedef void *EGLConfig;
-typedef void *EGLSurface;
-typedef void *EGLContext;
-typedef void *EGLClientBuffer;
-
-#define EGL_DEFAULT_DISPLAY ((NativeDisplayType)0)
-
-#define EGL_NO_CONTEXT      ((EGLContext)0)
-#define EGL_NO_DISPLAY      ((EGLDisplay)0)
-#define EGL_NO_SURFACE      ((EGLSurface)0)
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* ANDROID_EGL_TYPES_H */
diff --git a/include/GLES/gl.h b/include/GLES/gl.h
deleted file mode 100644
index 50b6ac4..0000000
--- a/include/GLES/gl.h
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __gl_h_
-#define __gl_h_
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*****************************************************************************/
-
-typedef int8_t              GLbyte;         // b
-typedef int16_t             GLshort;        // s
-typedef int32_t             GLint;          // i
-typedef ssize_t             GLsizei;        // i
-typedef int32_t             GLfixed;        // x
-typedef int32_t             GLclampx;       // x
-typedef float               GLfloat;        // f
-typedef float               GLclampf;       // f
-typedef uint8_t             GLubyte;        // ub
-typedef uint8_t             GLboolean;      // ub
-typedef uint16_t            GLushort;       // us
-typedef uint32_t            GLuint;         // ui
-typedef unsigned int        GLenum;         // ui
-typedef unsigned int        GLbitfield;     // ui
-typedef void                GLvoid;
-typedef intptr_t            GLintptr; 
-typedef int                 GLsizeiptr; 
-typedef GLintptr            GLintptrARB; 
-typedef GLsizeiptr          GLsizeiptrARB; 
-
-/*****************************************************************************/
-
-#define GL_VERSION_ES_CM_1_0                1
-#define GL_VERSION_ES_CL_1_0                1
-#define GL_VERSION_ES_CM_1_1                1
-#define GL_VERSION_ES_CL_1_1                1
-
-#define GL_OES_byte_coordinates             1
-#define GL_OES_fixed_point                  1
-#define GL_OES_single_precision             1
-#define GL_OES_read_format                  1
-#define GL_OES_compressed_paletted_texture  1
-#define GL_OES_draw_texture                 1
-#define GL_OES_matrix_get                   1
-#define GL_OES_query_matrix                 1
-#define GL_OES_vertex_buffer_object         1
-#define GL_OES_point_size_array             1
-#define GL_OES_point_sprite                 1
-#define GL_ARB_texture_non_power_of_two     1
-
-/*****************************************************************************/
-/* OpenGL ES 1.0 names */
-
-#define GL_FALSE                            0
-#define GL_TRUE                             1
-
-/* begin mode */
-#define GL_POINTS                           0x0000
-#define GL_LINES                            0x0001
-#define GL_LINE_LOOP                        0x0002
-#define GL_LINE_STRIP                       0x0003
-#define GL_TRIANGLES                        0x0004
-#define GL_TRIANGLE_STRIP                   0x0005
-#define GL_TRIANGLE_FAN                     0x0006
-
-/* clear mask  */
-#define GL_DEPTH_BUFFER_BIT                 0x00000100
-#define GL_STENCIL_BUFFER_BIT               0x00000400
-#define GL_COLOR_BUFFER_BIT                 0x00004000
-
-/* enable/disable */
-#define GL_FOG                              0x0B60
-#define GL_LIGHTING                         0x0B50
-#define GL_TEXTURE_2D                       0x0DE1
-#define GL_CULL_FACE                        0x0B44
-#define GL_ALPHA_TEST                       0x0BC0
-#define GL_BLEND                            0x0BE2
-#define GL_COLOR_LOGIC_OP                   0x0BF2
-#define GL_DITHER                           0x0BD0
-#define GL_STENCIL_TEST                     0x0B90
-#define GL_DEPTH_TEST                       0x0B71
-#define GL_POINT_SMOOTH                     0x0B10
-#define GL_LINE_SMOOTH                      0x0B20
-#define GL_SCISSOR_TEST                     0x0C11
-#define GL_COLOR_MATERIAL                   0x0B57
-#define GL_NORMALIZE                        0x0BA1
-#define GL_RESCALE_NORMAL                   0x803A
-#define GL_POLYGON_OFFSET_FILL              0x8037
-#define GL_VERTEX_ARRAY                     0x8074
-#define GL_NORMAL_ARRAY                     0x8075
-#define GL_COLOR_ARRAY                      0x8076
-#define GL_TEXTURE_COORD_ARRAY              0x8078
-#define GL_MULTISAMPLE                      0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE         0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE              0x809F
-#define GL_SAMPLE_COVERAGE                  0x80A0
-
-/* gets */
-#define GL_SMOOTH_POINT_SIZE_RANGE          0x0B12
-#define GL_SMOOTH_LINE_WIDTH_RANGE          0x0B22
-#define GL_ALIASED_POINT_SIZE_RANGE         0x846D
-#define GL_ALIASED_LINE_WIDTH_RANGE         0x846E
-#define GL_MAX_LIGHTS                       0x0D31
-#define GL_MAX_CLIP_PLANES                  0x0D32
-#define GL_MAX_TEXTURE_SIZE                 0x0D33
-#define GL_MAX_MODELVIEW_STACK_DEPTH        0x0D36
-#define GL_MAX_PROJECTION_STACK_DEPTH       0x0D38
-#define GL_MAX_TEXTURE_STACK_DEPTH          0x0D39
-#define GL_MAX_VIEWPORT_DIMS                0x0D3A
-#define GL_MAX_ELEMENTS_VERTICES            0x80E8
-#define GL_MAX_ELEMENTS_INDICES             0x80E9
-#define GL_MAX_TEXTURE_UNITS                0x84E2
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS   0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS       0x86A3
-#define GL_SUBPIXEL_BITS                    0x0D50
-#define GL_RED_BITS                         0x0D52
-#define GL_GREEN_BITS                       0x0D53
-#define GL_BLUE_BITS                        0x0D54
-#define GL_ALPHA_BITS                       0x0D55
-#define GL_DEPTH_BITS                       0x0D56
-#define GL_STENCIL_BITS                     0x0D57
-
-/* clip planes */
-#define GL_CLIP_PLANE0                      0x3000
-#define GL_CLIP_PLANE1                      0x3001
-#define GL_CLIP_PLANE2                      0x3002
-#define GL_CLIP_PLANE3                      0x3003
-#define GL_CLIP_PLANE4                      0x3004
-#define GL_CLIP_PLANE5                      0x3005
-
-/* errors */
-#define GL_NO_ERROR                         0
-#define GL_INVALID_ENUM                     0x0500
-#define GL_INVALID_VALUE                    0x0501
-#define GL_INVALID_OPERATION                0x0502
-#define GL_STACK_OVERFLOW                   0x0503
-#define GL_STACK_UNDERFLOW                  0x0504
-#define GL_OUT_OF_MEMORY                    0x0505
-
-/* fog */
-#define GL_EXP                              0x0800
-#define GL_EXP2                             0x0801
-#define GL_FOG_DENSITY                      0x0B62
-#define GL_FOG_START                        0x0B63
-#define GL_FOG_END                          0x0B64
-#define GL_FOG_MODE                         0x0B65
-#define GL_FOG_COLOR                        0x0B66
-
-/* culling */
-#define GL_CW                               0x0900
-#define GL_CCW                              0x0901
-
-#define GL_FRONT                            0x0404
-#define GL_BACK                             0x0405
-#define GL_FRONT_AND_BACK                   0x0408
-
-/* hints */
-#define GL_DONT_CARE                        0x1100
-#define GL_FASTEST                          0x1101
-#define GL_NICEST                           0x1102
-
-#define GL_PERSPECTIVE_CORRECTION_HINT      0x0C50
-#define GL_POINT_SMOOTH_HINT                0x0C51
-#define GL_LINE_SMOOTH_HINT                 0x0C52
-#define GL_POLYGON_SMOOTH_HINT              0x0C53
-#define GL_FOG_HINT                         0x0C54
-#define GL_GENERATE_MIPMAP_HINT             0x8192
-
-/* lights */
-#define GL_LIGHT_MODEL_AMBIENT              0x0B53
-#define GL_LIGHT_MODEL_TWO_SIDE             0x0B52
-
-#define GL_AMBIENT                          0x1200
-#define GL_DIFFUSE                          0x1201
-#define GL_SPECULAR                         0x1202
-#define GL_POSITION                         0x1203
-#define GL_SPOT_DIRECTION                   0x1204
-#define GL_SPOT_EXPONENT                    0x1205
-#define GL_SPOT_CUTOFF                      0x1206
-#define GL_CONSTANT_ATTENUATION             0x1207
-#define GL_LINEAR_ATTENUATION               0x1208
-#define GL_QUADRATIC_ATTENUATION            0x1209
-
-#define GL_LIGHT0                           0x4000
-#define GL_LIGHT1                           0x4001
-#define GL_LIGHT2                           0x4002
-#define GL_LIGHT3                           0x4003
-#define GL_LIGHT4                           0x4004
-#define GL_LIGHT5                           0x4005
-#define GL_LIGHT6                           0x4006
-#define GL_LIGHT7                           0x4007
-
-/* material */
-#define GL_EMISSION                         0x1600
-#define GL_SHININESS                        0x1601
-#define GL_AMBIENT_AND_DIFFUSE              0x1602
-
-/* matrix */
-#define GL_MODELVIEW                        0x1700
-#define GL_PROJECTION                       0x1701
-#define GL_TEXTURE                          0x1702
-
-/* types */
-#define GL_BYTE                             0x1400
-#define GL_UNSIGNED_BYTE                    0x1401
-#define GL_SHORT                            0x1402
-#define GL_UNSIGNED_SHORT                   0x1403
-#define GL_FLOAT                            0x1406
-#define GL_FIXED                            0x140C
-
-/* pixel formats */
-#define GL_ALPHA                            0x1906
-#define GL_RGB                              0x1907
-#define GL_RGBA                             0x1908
-#define GL_LUMINANCE                        0x1909
-#define GL_LUMINANCE_ALPHA                  0x190A
-
-/* pixel store */
-#define GL_UNPACK_ALIGNMENT                 0x0CF5
-#define GL_PACK_ALIGNMENT                   0x0D05
-
-/* pixel types */
-#define GL_UNSIGNED_SHORT_4_4_4_4           0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1           0x8034
-#define GL_UNSIGNED_SHORT_5_6_5             0x8363
-
-/* logic op */
-#define GL_CLEAR                            0x1500   // 0
-#define GL_AND                              0x1501   // s & d
-#define GL_AND_REVERSE                      0x1502   // s & ~d
-#define GL_COPY                             0x1503   // s
-#define GL_AND_INVERTED                     0x1504   // ~s & d
-#define GL_NOOP                             0x1505   // d
-#define GL_XOR                              0x1506   // s ^ d
-#define GL_OR                               0x1507   // s | d
-#define GL_NOR                              0x1508   // ~(s | d)
-#define GL_EQUIV                            0x1509   // ~(s ^ d)
-#define GL_INVERT                           0x150A   // ~d
-#define GL_OR_REVERSE                       0x150B   // s | ~d
-#define GL_COPY_INVERTED                    0x150C   // ~s 
-#define GL_OR_INVERTED                      0x150D   // ~s | d
-#define GL_NAND                             0x150E   // ~(s & d)
-#define GL_SET                              0x150F   // 1
-
-/* shade model */
-#define GL_FLAT                             0x1D00
-#define GL_SMOOTH                           0x1D01
-
-/* strings */
-#define GL_VENDOR                           0x1F00
-#define GL_RENDERER                         0x1F01
-#define GL_VERSION                          0x1F02
-#define GL_EXTENSIONS                       0x1F03
-
-/* stencil */
-#define GL_KEEP                             0x1E00
-#define GL_REPLACE                          0x1E01
-#define GL_INCR                             0x1E02
-#define GL_DECR                             0x1E03
-
-/* alpha & stencil */
-#define GL_NEVER                            0x0200
-#define GL_LESS                             0x0201
-#define GL_EQUAL                            0x0202
-#define GL_LEQUAL                           0x0203
-#define GL_GREATER                          0x0204
-#define GL_NOTEQUAL                         0x0205
-#define GL_GEQUAL                           0x0206
-#define GL_ALWAYS                           0x0207
-
-/* blending equation & function */
-#define GL_ZERO                             0           // SD
-#define GL_ONE                              1           // SD
-#define GL_SRC_COLOR                        0x0300      //  D
-#define GL_ONE_MINUS_SRC_COLOR              0x0301      //  D
-#define GL_SRC_ALPHA                        0x0302      // SD
-#define GL_ONE_MINUS_SRC_ALPHA              0x0303      // SD
-#define GL_DST_ALPHA                        0x0304      // SD
-#define GL_ONE_MINUS_DST_ALPHA              0x0305      // SD
-#define GL_DST_COLOR                        0x0306      // S
-#define GL_ONE_MINUS_DST_COLOR              0x0307      // S
-#define GL_SRC_ALPHA_SATURATE               0x0308      // S
-    
-/* Texture parameter name */
-#define GL_TEXTURE_MIN_FILTER               0x2801
-#define GL_TEXTURE_MAG_FILTER               0x2800
-#define GL_TEXTURE_WRAP_S                   0x2802
-#define GL_TEXTURE_WRAP_T                   0x2803
-#define GL_GENERATE_MIPMAP                  0x8191
-#define GL_TEXTURE_CROP_RECT_OES            0x8B9D
-
-/* Texture Filter */
-#define GL_NEAREST                          0x2600
-#define GL_LINEAR                           0x2601
-#define GL_NEAREST_MIPMAP_NEAREST           0x2700
-#define GL_LINEAR_MIPMAP_NEAREST            0x2701
-#define GL_NEAREST_MIPMAP_LINEAR            0x2702
-#define GL_LINEAR_MIPMAP_LINEAR             0x2703
-
-/* Texture Wrap Mode */
-#define GL_CLAMP                            0x2900
-#define GL_REPEAT                           0x2901
-#define GL_CLAMP_TO_EDGE                    0x812F
-
-/* Texture Env Mode */
-#define GL_REPLACE                          0x1E01
-#define GL_MODULATE                         0x2100
-#define GL_DECAL                            0x2101
-#define GL_ADD                              0x0104
-
-/* Texture Env Parameter */
-#define GL_TEXTURE_ENV_MODE                 0x2200
-#define GL_TEXTURE_ENV_COLOR                0x2201
-
-/* Texture Env Target */
-#define GL_TEXTURE_ENV                      0x2300
-
-/* TMUs */
-#define GL_TEXTURE0                         0x84C0
-#define GL_TEXTURE1                         0x84C1
-#define GL_TEXTURE2                         0x84C2
-#define GL_TEXTURE3                         0x84C3
-#define GL_TEXTURE4                         0x84C4
-#define GL_TEXTURE5                         0x84C5
-#define GL_TEXTURE6                         0x84C6
-#define GL_TEXTURE7                         0x84C7
-#define GL_TEXTURE8                         0x84C8
-#define GL_TEXTURE9                         0x84C9
-#define GL_TEXTURE10                        0x84CA
-#define GL_TEXTURE11                        0x84CB
-#define GL_TEXTURE12                        0x84CC
-#define GL_TEXTURE13                        0x84CD
-#define GL_TEXTURE14                        0x84CE
-#define GL_TEXTURE15                        0x84CF
-#define GL_TEXTURE16                        0x84D0
-#define GL_TEXTURE17                        0x84D1
-#define GL_TEXTURE18                        0x84D2
-#define GL_TEXTURE19                        0x84D3
-#define GL_TEXTURE20                        0x84D4
-#define GL_TEXTURE21                        0x84D5
-#define GL_TEXTURE22                        0x84D6
-#define GL_TEXTURE23                        0x84D7
-#define GL_TEXTURE24                        0x84D8
-#define GL_TEXTURE25                        0x84D9
-#define GL_TEXTURE26                        0x84DA
-#define GL_TEXTURE27                        0x84DB
-#define GL_TEXTURE28                        0x84DC
-#define GL_TEXTURE29                        0x84DD
-#define GL_TEXTURE30                        0x84DE
-#define GL_TEXTURE31                        0x84DF
-
-/*****************************************************************************/
-/* OpenGL ES 1.1 additions */
-
-#define GL_ARRAY_BUFFER                         0x8892
-#define GL_ELEMENT_ARRAY_BUFFER                 0x8893
-
-#define GL_STATIC_DRAW                          0x88E4
-#define GL_DYNAMIC_DRAW                         0x88E8
-
-#define GL_BUFFER_SIZE                          0x8764
-#define GL_BUFFER_USAGE                         0x8765
-
-#define GL_ARRAY_BUFFER_BINDING                 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING         0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING          0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING          0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING           0x8898
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING   0x889A
-
-/*****************************************************************************/
-/* Required extensions */
-
-#define GL_PALETTE4_RGB8_OES                        0x8B90
-#define GL_PALETTE4_RGBA8_OES                       0x8B91
-#define GL_PALETTE4_R5_G6_B5_OES                    0x8B92
-#define GL_PALETTE4_RGBA4_OES                       0x8B93
-#define GL_PALETTE4_RGB5_A1_OES                     0x8B94
-#define GL_PALETTE8_RGB8_OES                        0x8B95
-#define GL_PALETTE8_RGBA8_OES                       0x8B96
-#define GL_PALETTE8_R5_G6_B5_OES                    0x8B97
-#define GL_PALETTE8_RGBA4_OES                       0x8B98
-#define GL_PALETTE8_RGB5_A1_OES                     0x8B99
-
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES       0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES     0x8B9B
-
-#define GL_POINT_SPRITE_OES                         0x8861
-#define GL_COORD_REPLACE_OES                        0x8862
-
-#define GL_POINT_SIZE_ARRAY_OES                     0x8B9C
-#define GL_POINT_SIZE_ARRAY_TYPE_OES                0x898A
-#define GL_POINT_SIZE_ARRAY_STRIDE_OES              0x898B
-#define GL_POINT_SIZE_ARRAY_POINTER_OES             0x898C
-#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES      0x8B9F
-
-/*****************************************************************************/
-/* Extensions */
-
-#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES   0x898D
-#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES  0x898E
-#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES     0x898F
-
-#define GL_DIRECT_TEXTURE_2D_QUALCOMM               0x7E80
-
-
-
-
-/*****************************************************************************/
-/* OpenGL ES 1.0 functions */
-
-void glActiveTexture(GLenum texture);
-void glAlphaFunc(GLenum func, GLclampf ref);
-void glAlphaFuncx(GLenum func, GLclampx ref);
-void glBindTexture(GLenum target, GLuint texture);
-void glBlendFunc(GLenum sfactor, GLenum dfactor);
-void glClear(GLbitfield mask);
-void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-void glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
-void glClearDepthf(GLclampf depth);
-void glClearDepthx(GLclampx depth);
-void glClearStencil(GLint s);
-void glClientActiveTexture(GLenum texture);
-void glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-void glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
-void glColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-void glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
-void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
-        GLsizei width, GLsizei height, GLint border,
-        GLsizei imageSize, const GLvoid *data);
-void glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset,
-        GLint yoffset, GLsizei width, GLsizei height,
-        GLenum format, GLsizei imageSize,
-        const GLvoid *data);
-void glCopyTexImage2D(  GLenum target, GLint level, GLenum internalformat,
-        GLint x, GLint y, GLsizei width, GLsizei height,
-        GLint border);
-void glCopyTexSubImage2D(   GLenum target, GLint level, GLint xoffset,
-        GLint yoffset, GLint x, GLint y, GLsizei width,
-        GLsizei height);
-void glCullFace(GLenum mode);
-void glDeleteTextures(GLsizei n, const GLuint *textures);
-void glDepthFunc(GLenum func);
-void glDepthMask(GLboolean flag);
-void glDepthRangef(GLclampf zNear, GLclampf zFar);
-void glDepthRangex(GLclampx zNear, GLclampx zFar);
-void glDisable(GLenum cap);
-void glDisableClientState(GLenum array);
-void glDrawArrays(GLenum mode, GLint first, GLsizei count);
-void glDrawElements(GLenum mode, GLsizei count,
-        GLenum type, const GLvoid *indices);
-void glEnable(GLenum cap);
-void glEnableClientState(GLenum array);
-void glFinish(void);
-void glFlush(void);
-void glFogf(GLenum pname, GLfloat param);
-void glFogfv(GLenum pname, const GLfloat *params);
-void glFogx(GLenum pname, GLfixed param);
-void glFogxv(GLenum pname, const GLfixed *params);
-void glFrontFace(GLenum mode);
-void glFrustumf(GLfloat left, GLfloat right,
-        GLfloat bottom, GLfloat top,
-        GLfloat zNear, GLfloat zFar);
-void glFrustumx(GLfixed left, GLfixed right,
-        GLfixed bottom, GLfixed top,
-        GLfixed zNear, GLfixed zFar);
-void glGenTextures(GLsizei n, GLuint *textures);
-GLenum glGetError(void);
-void glGetIntegerv(GLenum pname, GLint *params);
-const GLubyte * glGetString(GLenum name);
-void glHint(GLenum target, GLenum mode);
-void glLightModelf(GLenum pname, GLfloat param);
-void glLightModelfv(GLenum pname, const GLfloat *params);
-void glLightModelx(GLenum pname, GLfixed param);
-void glLightModelxv(GLenum pname, const GLfixed *params);
-void glLightf(GLenum light, GLenum pname, GLfloat param);
-void glLightfv(GLenum light, GLenum pname, const GLfloat *params);
-void glLightx(GLenum light, GLenum pname, GLfixed param);
-void glLightxv(GLenum light, GLenum pname, const GLfixed *params);
-void glLineWidth(GLfloat width);
-void glLineWidthx(GLfixed width);
-void glLoadIdentity(void);
-void glLoadMatrixf(const GLfloat *m);
-void glLoadMatrixx(const GLfixed *m);
-void glLogicOp(GLenum opcode);
-void glMaterialf(GLenum face, GLenum pname, GLfloat param);
-void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params);
-void glMaterialx(GLenum face, GLenum pname, GLfixed param);
-void glMaterialxv(GLenum face, GLenum pname, const GLfixed *params);
-void glMatrixMode(GLenum mode);
-void glMultMatrixf(const GLfloat *m);
-void glMultMatrixx(const GLfixed *m);
-void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-void glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
-void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
-void glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz);
-void glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
-void glOrthof(  GLfloat left, GLfloat right,
-        GLfloat bottom, GLfloat top,
-        GLfloat zNear, GLfloat zFar);
-void glOrthox(  GLfixed left, GLfixed right,
-        GLfixed bottom, GLfixed top,
-        GLfixed zNear, GLfixed zFar);
-void glPixelStorei(GLenum pname, GLint param);
-void glPointSize(GLfloat size);
-void glPointSizex(GLfixed size);
-void glPolygonOffset(GLfloat factor, GLfloat units);
-void glPolygonOffsetx(GLfixed factor, GLfixed units);
-void glPopMatrix(void);
-void glPushMatrix(void);
-void glReadPixels(  GLint x, GLint y, GLsizei width, GLsizei height,
-        GLenum format, GLenum type, GLvoid *pixels);
-void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
-void glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
-void glSampleCoverage(GLclampf value, GLboolean invert);
-void glSampleCoveragex(GLclampx value, GLboolean invert);
-void glScalef(GLfloat x, GLfloat y, GLfloat z);
-void glScalex(GLfixed x, GLfixed y, GLfixed z);
-void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
-void glShadeModel(GLenum mode);
-void glStencilFunc(GLenum func, GLint ref, GLuint mask);
-void glStencilMask(GLuint mask);
-void glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
-void glTexCoordPointer( GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer);
-void glTexEnvf(GLenum target, GLenum pname, GLfloat param);
-void glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params);
-void glTexEnvx(GLenum target, GLenum pname, GLfixed param);
-void glTexEnvxv(GLenum target, GLenum pname, const GLfixed *params);
-void glTexImage2D(  GLenum target, GLint level, GLenum internalformat,
-        GLsizei width, GLsizei height, GLint border, GLenum format,
-        GLenum type, const GLvoid *pixels);
-void glTexParameterf(GLenum target, GLenum pname, GLfloat param);
-void glTexParameterx(GLenum target, GLenum pname, GLfixed param);
-void glTexSubImage2D(   GLenum target, GLint level, GLint xoffset,
-        GLint yoffset, GLsizei width, GLsizei height,
-        GLenum format, GLenum type, const GLvoid *pixels);
-void glTranslatef(GLfloat x, GLfloat y, GLfloat z);
-void glTranslatex(GLfixed x, GLfixed y, GLfixed z);
-void glVertexPointer(   GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer);
-void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
-
-/*****************************************************************************/
-/* OpenGL ES 1.1 functions */
-
-void glClipPlanef(GLenum plane, const GLfloat* equation);
-void glClipPlanex(GLenum plane, const GLfixed* equation);
-
-void glBindBuffer(GLenum target, GLuint buffer);
-void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
-void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
-void glDeleteBuffers(GLsizei n, const GLuint* buffers);
-void glGenBuffers(GLsizei n, GLuint* buffers);
-
-void glGetBooleanv(GLenum pname, GLboolean *params);
-void glGetFixedv(GLenum pname, GLfixed *params);
-void glGetFloatv(GLenum pname, GLfloat *params);
-void glGetPointerv(GLenum pname, void **params);
-void glGetBufferParameteriv(GLenum target, GLenum pname, GLint *params);
-void glGetClipPlanef(GLenum pname, GLfloat eqn[4]);
-void glGetClipPlanex(GLenum pname, GLfixed eqn[4]);
-void glGetLightxv(GLenum light, GLenum pname, GLfixed *params);
-void glGetLightfv(GLenum light, GLenum pname, GLfloat *params);
-void glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params);
-void glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params);
-void glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params);
-void glGetTexEnviv(GLenum env, GLenum pname, GLint *params);
-void glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params);
-void glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params);
-void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params);
-void glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params);
-GLboolean glIsBuffer(GLuint buffer);
-GLboolean glIsEnabled(GLenum cap);
-GLboolean glIsTexture(GLuint texture);
-void glPointParameterf(GLenum pname, GLfloat param);
-void glPointParameterfv(GLenum pname, const GLfloat *params);
-void glPointParameterx(GLenum pname, GLfixed param);
-void glPointParameterxv(GLenum pname, const GLfixed *params);
-void glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
-void glTexEnvi(GLenum target, GLenum pname, GLint param);
-void glTexEnviv(GLenum target, GLenum pname, const GLint *params);
-void glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params);
-void glTexParameteriv(GLenum target, GLenum pname, const GLint *params);
-void glTexParameteri(GLenum target, GLenum pname, GLint param);
-void glTexParameterxv(GLenum target, GLenum pname, const GLfixed *params);
-
-/*****************************************************************************/
-/* Required extensions functions */
-
-void glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer);
-
-
-/*****************************************************************************/
-/* Extensions functions */
-
-void glDrawTexsOES(GLshort x , GLshort y, GLshort z, GLshort w, GLshort h);
-void glDrawTexiOES(GLint x, GLint y, GLint z, GLint w, GLint h);
-void glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat h);
-void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h);
-void glDrawTexsvOES(const GLshort* coords);
-void glDrawTexivOES(const GLint* coords);
-void glDrawTexfvOES(const GLfloat* coords);
-void glDrawTexxvOES(const GLfixed* coords);
-GLbitfield glQueryMatrixxOES(GLfixed* mantissa, GLint* exponent);
-
-/* called by dalvik */
-void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count);
-void glNormalPointerBounds(GLenum type, GLsizei stride,
-        const GLvoid *pointer, GLsizei count);
-void glTexCoordPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count);
-void glVertexPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gl_h_ */
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 77676bf..6bd54ba 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -99,23 +99,31 @@
     static status_t getOutputSamplingRate(int* samplingRate);
     static status_t getOutputFrameCount(int* frameCount);
     static status_t getOutputLatency(uint32_t* latency);
+    
+    static status_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount, 
+        size_t* buffSize);
 
     // ----------------------------------------------------------------------------
 
 private:
 
-    class DeathNotifier: public IBinder::DeathRecipient
+    class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient
     {
     public:
-        DeathNotifier() {      
+        AudioFlingerClient() {      
         }
         
+        // DeathRecipient
         virtual void binderDied(const wp<IBinder>& who);
+        
+        // IAudioFlingerClient
+        virtual void audioOutputChanged(uint32_t frameCount, uint32_t samplingRate, uint32_t latency);
+        
     };
 
-    static sp<DeathNotifier> gDeathNotifier;
+    static sp<AudioFlingerClient> gAudioFlingerClient;
 
-    friend class DeathNotifier;
+    friend class AudioFlingerClient;
 
     static Mutex gLock;
     static sp<IAudioFlinger> gAudioFlinger;
@@ -123,6 +131,13 @@
     static int gOutSamplingRate;
     static int gOutFrameCount;
     static uint32_t gOutLatency;
+    
+    static size_t gInBuffSize;
+    // previous parameters for recording buffer size queries
+    static uint32_t gPrevInSamplingRate;
+    static int gPrevInFormat;
+    static int gPrevInChannelCount;
+
 };
 
 };  // namespace android
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index fd62daa..5b2bab9 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -51,6 +51,7 @@
         MUSIC           = 3,
         ALARM           = 4,
         NOTIFICATION    = 5,
+        BLUETOOTH_SCO   = 6,
         NUM_STREAM_TYPES
     };
 
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 69703b2..df601d7 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -26,6 +26,7 @@
 #include <utils/IInterface.h>
 #include <media/IAudioTrack.h>
 #include <media/IAudioRecord.h>
+#include <media/IAudioFlingerClient.h>
 
 
 namespace android {
@@ -107,6 +108,15 @@
     // Temporary interface, do not use
     // TODO: Replace with a more generic key:value get/set mechanism
     virtual     status_t  setParameter(const char* key, const char* value) = 0;
+    
+    // register a current process for audio output change notifications
+    virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
+    
+    // retrieve the audio recording buffer size
+    virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount) = 0;
+    
+    // force AudioFlinger thread out of standby
+    virtual     void        wakeUp() = 0;
 };
 
 
diff --git a/include/media/IAudioFlingerClient.h b/include/media/IAudioFlingerClient.h
new file mode 100644
index 0000000..10c3e0f
--- /dev/null
+++ b/include/media/IAudioFlingerClient.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_IAUDIOFLINGERCLIENT_H
+#define ANDROID_IAUDIOFLINGERCLIENT_H
+
+
+#include <utils/RefBase.h>
+#include <utils/IInterface.h>
+
+
+namespace android {
+
+// ----------------------------------------------------------------------------
+
+class IAudioFlingerClient : public IInterface
+{
+public:
+    DECLARE_META_INTERFACE(AudioFlingerClient);
+
+    // Notifies a change of audio output from/to hardware to/from A2DP.
+    virtual void audioOutputChanged(uint32_t frameCount, uint32_t samplingRate, uint32_t latency) = 0;
+
+};
+
+
+// ----------------------------------------------------------------------------
+
+class BnAudioFlingerClient : public BnInterface<IAudioFlingerClient>
+{
+public:
+    virtual status_t    onTransact( uint32_t code,
+                                    const Parcel& data,
+                                    Parcel* reply,
+                                    uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_IAUDIOFLINGERCLIENT_H
diff --git a/include/media/JetPlayer.h b/include/media/JetPlayer.h
index 4268170..16764a9 100644
--- a/include/media/JetPlayer.h
+++ b/include/media/JetPlayer.h
@@ -33,9 +33,12 @@
 
 public:
 
-    static const int JET_USERID_UPDATE           = 1;
-    static const int JET_NUMQUEUEDSEGMENT_UPDATE = 2;
-    static const int JET_PAUSE_UPDATE            = 3;
+    // to keep in sync with the JetPlayer class constants
+    // defined in frameworks/base/media/java/android/media/JetPlayer.java
+    static const int JET_EVENT                   = 1;
+    static const int JET_USERID_UPDATE           = 2;
+    static const int JET_NUMQUEUEDSEGMENT_UPDATE = 3;
+    static const int JET_PAUSE_UPDATE            = 4;
 
     JetPlayer(jobject javaJetPlayer, 
             int maxTracks = 32, 
@@ -44,7 +47,8 @@
     int init();
     int release();
     
-    int openFile(const char* url);
+    int loadFromFile(const char* url);
+    int loadFromFD(const int fd, const long long offset, const long long length);
     int closeFile();
     int play();
     int pause();
@@ -53,6 +57,7 @@
     int setMuteFlags(EAS_U32 muteFlags, bool sync);
     int setMuteFlag(int trackNum, bool muteFlag, bool sync);
     int triggerClip(int clipId);
+    int clearQueue();
 
     void setEventCallback(jetevent_callback callback);
     
@@ -62,7 +67,8 @@
 private:
     static  int         renderThread(void*);
     int                 render();
-    void                fireEventOnStatusChange();
+    void                fireUpdateOnStatusChange();
+    void                fireEventsFromJetQueue();
 
     JetPlayer() {} // no default constructor
     void dump();
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index 30e4578..7f0e7b3 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -17,9 +17,6 @@
 #ifndef ANDROID_MEDIAPLAYERINTERFACE_H
 #define ANDROID_MEDIAPLAYERINTERFACE_H
 
-#include <pthread.h>
-#include <signal.h>
-
 #ifdef __cplusplus
 
 #include <ui/ISurface.h>
@@ -74,7 +71,6 @@
     virtual             ~MediaPlayerBase() {}
     virtual status_t    initCheck() = 0;
     virtual bool        hardwareOutput() = 0;
-    virtual status_t    setSigBusHandlerStructTLSKey(pthread_key_t key) { return 0; }
     virtual status_t    setDataSource(const char *url) = 0;
     virtual status_t    setDataSource(int fd, int64_t offset, int64_t length) = 0;
     virtual status_t    setVideoSurface(const sp<ISurface>& surface) = 0;
@@ -125,34 +121,6 @@
 
 #endif // __cplusplus
 
-// A thread can set the thread local variable identified by the pthread_key_t
-// that was passed to the player using the setSigBusHandlerStructTLSKey()
-// method to the address of the following structure.
-// If 'handlesigbus' is non-NULL, the function it points to will be called,
-// and if it returns 0, the signal will be assumed to have been handled,
-// and no other action will be taken. If it returns non-zero, the old SIGBUS
-// handler will be called.
-// If 'handlesigbus is NULL, then sigbusvar must be non NULL. The system's
-// SIGBUS handler will map an accessible page filled with zeroes at the
-// location that caused the original fault, set the variable pointed to by
-// sigbusvar to a non-zero value, and exit (which causes the operation to
-// be retried, which should now succeed).
-// If base and len are non zero, which is strongly recommended, they will
-// be used as additional constraints on the signal handler. That is, when
-// specified, the fault address must be in the range specified by base and
-// len in order for handlesigbus() to be called or sigbusvar to be set.
-// If the fault address is outside of the range, the old SIGBUS handler
-// will be called.
-struct mediasigbushandler {
-    int (*handlesigbus)(siginfo_t *, struct mediasigbushandler *);
-    int  *sigbusvar;
-    char *base;
-    int len;
-    // these next two are free for application use
-    struct mediasigbushandler *next;
-    void *data;
-};
-
 
 #endif // ANDROID_MEDIAPLAYERINTERFACE_H
 
diff --git a/include/media/PVPlayer.h b/include/media/PVPlayer.h
index 5f302ed..6d98852 100644
--- a/include/media/PVPlayer.h
+++ b/include/media/PVPlayer.h
@@ -20,6 +20,12 @@
 #include <utils/Errors.h>
 #include <media/MediaPlayerInterface.h>
 
+#define MAX_OPENCORE_INSTANCES 25
+
+#ifdef MAX_OPENCORE_INSTANCES
+#include <cutils/atomic.h>
+#endif
+
 class PlayerDriver;
 
 namespace android {
@@ -31,7 +37,6 @@
     virtual             ~PVPlayer();
 
     virtual status_t    initCheck();
-    virtual status_t    setSigBusHandlerStructTLSKey(pthread_key_t key);
     virtual status_t    setDataSource(const char *url);
     virtual status_t    setDataSource(int fd, int64_t offset, int64_t length);
     virtual status_t    setVideoSurface(const sp<ISurface>& surface);
@@ -62,10 +67,13 @@
     char *                      mDataSourcePath;
     bool                        mIsDataSourceSet;
     sp<ISurface>                mSurface;
-    void *                      mMemBase;
-    off_t                       mMemSize;
+    int                         mSharedFd;
     status_t                    mInit;
     int                         mDuration;
+
+#ifdef MAX_OPENCORE_INSTANCES
+    static volatile int32_t     sNumInstances;
+#endif
 };
 
 }; // namespace android
diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h
index 0cfdeec7..ec64e4d 100644
--- a/include/media/ToneGenerator.h
+++ b/include/media/ToneGenerator.h
@@ -85,8 +85,6 @@
         TONE_RESTARTING  //
     };
 
-    static const unsigned int NUM_PCM_BUFFERS = 2; // Number of AudioTrack pcm buffers
-    
     static const unsigned int TONEGEN_MAX_WAVES = 3;
     static const unsigned int TONEGEN_MAX_SEGMENTS = 4;  // Maximun number of elenemts in
     static const unsigned int TONEGEN_INF = 0xFFFFFFFF;  // Represents infinite time duration
@@ -127,7 +125,6 @@
     const ToneDescriptor *mpNewToneDesc;  // pointer to next active tone descriptor
 
     int mSamplingRate;  // AudioFlinger Sampling rate
-    int mBufferSize;  // PCM buffer size in frames
     AudioTrack *mpAudioTrack;  // Pointer to audio track used for playback
     Mutex mLock;  // Mutex to control concurent access to ToneGenerator object from audio callback and application API
     Mutex mCbkCondLock; // Mutex associated to mWaitCbkCond
diff --git a/include/private/opengles/gl_context.h b/include/private/opengles/gl_context.h
index 3056139..0c7ad46 100644
--- a/include/private/opengles/gl_context.h
+++ b/include/private/opengles/gl_context.h
@@ -28,6 +28,7 @@
 #include <private/pixelflinger/ggl_context.h>
 
 #include <GLES/gl.h>
+#include <GLES/glext.h>
 
 namespace android {
 
diff --git a/include/ui/Camera.h b/include/ui/Camera.h
index 44acce5..e593fea 100644
--- a/include/ui/Camera.h
+++ b/include/ui/Camera.h
@@ -23,8 +23,8 @@
 namespace android {
 
 /*
- * A set of bit masks for specifying how the received frames from preview are
- * handled before the frame callback call.
+ * A set of bit masks for specifying how the received preview frames are
+ * handled before the previewCallback() call.
  *
  * The least significant 3 bits of an "int" value are used for this purpose:
  *
@@ -34,10 +34,18 @@
  *       | |-----------> determine whether the callback is one-shot or not
  *       |-------------> determine whether the frame is copied out or not
  *
+ * WARNING:
+ * When a frame is sent directly without copying, it is the frame receiver's
+ * responsiblity to make sure that the frame data won't get corrupted by
+ * subsequent preview frames filled by the camera. This flag is recommended
+ * only when copying out data brings significant performance price and the
+ * handling/processing of the received frame data is always faster than
+ * the preview frame rate so that data corruption won't occur.
+ *
  * For instance,
  * 1. 0x00 disables the callback. In this case, copy out and one shot bits
  *    are ignored.
- * 2. 0x01 enables a callback without copying out the recievied frames. A
+ * 2. 0x01 enables a callback without copying out the received frames. A
  *    typical use case is the Camcorder application to avoid making costly
  *    frame copies.
  * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical
@@ -96,6 +104,18 @@
             // get preview state
             bool        previewEnabled();
 
+            // start recording mode, must call setPreviewDisplay first
+            status_t    startRecording();
+
+            // stop recording mode
+            void        stopRecording();
+
+            // get recording state
+            bool        recordingEnabled();
+
+            // release a recording frame
+            void        releaseRecordingFrame(const sp<IMemory>& mem);
+
             // autoFocus - status returned from callback
             status_t    autoFocus();
 
@@ -111,20 +131,19 @@
             void        setShutterCallback(shutter_callback cb, void *cookie);
             void        setRawCallback(frame_callback cb, void *cookie);
             void        setJpegCallback(frame_callback cb, void *cookie);
-
-            void        setFrameCallback(frame_callback cb,
-                            void *cookie,
-                            int frame_callback_flag = FRAME_CALLBACK_FLAG_NOOP);
-
+            void        setRecordingCallback(frame_callback cb, void *cookie);
+            void        setPreviewCallback(frame_callback cb, void *cookie, int preview_callback_flag = FRAME_CALLBACK_FLAG_NOOP);
             void        setErrorCallback(error_callback cb, void *cookie);
             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        frameCallback(const sp<IMemory>& frame);
+    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);
 
     sp<ICamera>         remote();
 
@@ -155,8 +174,10 @@
             void                *mRawCallbackCookie;
             frame_callback      mJpegCallback;
             void                *mJpegCallbackCookie;
-            frame_callback      mFrameCallback;
-            void                *mFrameCallbackCookie;
+            frame_callback      mPreviewCallback;
+            void                *mPreviewCallbackCookie;
+            frame_callback      mRecordingCallback;
+            void                *mRecordingCallbackCookie;
             error_callback      mErrorCallback;
             void                *mErrorCallbackCookie;
             autofocus_callback  mAutoFocusCallback;
diff --git a/include/ui/CameraHardwareInterface.h b/include/ui/CameraHardwareInterface.h
index 2bd53dd..b068c52 100644
--- a/include/ui/CameraHardwareInterface.h
+++ b/include/ui/CameraHardwareInterface.h
@@ -20,12 +20,16 @@
 #include <utils/IMemory.h>
 #include <utils/RefBase.h>
 #include <ui/CameraParameters.h>
+#include <ui/Overlay.h>
 
 namespace android {
 
 /** Callback for startPreview() */
 typedef void (*preview_callback)(const sp<IMemory>& mem, void* user);
 
+/** Callback for startRecord() */
+typedef void (*recording_callback)(const sp<IMemory>& mem, void* user);
+
 /** Callback for takePicture() */
 typedef void (*shutter_callback)(void* user);
 
@@ -89,6 +93,11 @@
      * call back parameter may be null.
      */
     virtual status_t    startPreview(preview_callback cb, void* user) = 0;
+    /**
+     * Only used if overlays are used for camera preview.
+     */
+    virtual bool useOverlay() {return false;}
+    virtual status_t setOverlay(const sp<Overlay> &overlay) {return BAD_VALUE;}
 
     /**
      * Stop a previously started preview.
@@ -101,6 +110,29 @@
     virtual bool        previewEnabled() = 0;
 
     /**
+     * Start record mode. When a record image is available recording_callback()
+     * is called with the user parameter.  Every record frame must be released
+     * by calling releaseRecordingFrame().
+     */
+    virtual status_t    startRecording(recording_callback cb, void* user) = 0;
+
+    /**
+     * Stop a previously started recording.
+     */
+    virtual void        stopRecording() = 0;
+
+    /**
+     * Returns true if recording is enabled.
+     */
+    virtual bool        recordingEnabled() = 0;
+    
+    /**
+     * Release a record frame previously returned by the recording_callback()
+     * passed to startRecord().
+     */
+    virtual void        releaseRecordingFrame(const sp<IMemory>& mem) = 0;
+
+    /**
      * Start auto focus, the callback routine is called
      * once when focusing is complete. autoFocus() will
      * be called again if another auto focus is needed.
diff --git a/include/ui/CameraParameters.h b/include/ui/CameraParameters.h
index e35a054..9ca1806 100644
--- a/include/ui/CameraParameters.h
+++ b/include/ui/CameraParameters.h
@@ -29,6 +29,12 @@
     CameraParameters(const String8 &params) { unflatten(params); }
     ~CameraParameters();
 
+    enum {
+        CAMERA_ORIENTATION_UNKNOWN = 0,
+        CAMERA_ORIENTATION_PORTRAIT = 1,
+        CAMERA_ORIENTATION_LANDSCAPE = 2,
+    };
+
     String8 flatten() const;
     void unflatten(const String8 &params);
 
@@ -57,6 +63,9 @@
     void setPictureFormat(const char *format);
     const char *getPictureFormat() const;
 
+    int getOrientation() const;
+    void setOrientation(int orientation);
+
     void dump() const;
     status_t dump(int fd, const Vector<String16>& args) const;
 
diff --git a/include/ui/EGLDisplaySurface.h b/include/ui/EGLDisplaySurface.h
index 0190e09..a8b5853 100644
--- a/include/ui/EGLDisplaySurface.h
+++ b/include/ui/EGLDisplaySurface.h
@@ -27,7 +27,10 @@
 #include <pixelflinger/pixelflinger.h>
 #include <linux/fb.h>
 
+#include <EGL/egl.h>
+
 struct copybit_device_t;
+struct copybit_image_t;
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -44,17 +47,17 @@
     
     int32_t getPageFlipCount() const;
     void    copyFrontToBack(const Region& copyback);
+    void    copyFrontToImage(const copybit_image_t& dst);
+    void    copyBackToImage(const copybit_image_t& dst);
     
+    void        setSwapRectangle(int l, int t, int w, int h);
+
 private:
     static void         hook_incRef(NativeWindowType window);
     static void         hook_decRef(NativeWindowType window);
     static uint32_t     hook_swapBuffers(NativeWindowType window);
-    static void         hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h);
-    static uint32_t     hook_nextBuffer(NativeWindowType window);
      
             uint32_t    swapBuffers();
-            uint32_t    nextBuffer();
-            void        setSwapRectangle(int l, int t, int w, int h);
 
             status_t    mapFrameBuffer();
 
diff --git a/include/ui/EGLNativeSurface.h b/include/ui/EGLNativeSurface.h
index c303cd8..7964e7c 100644
--- a/include/ui/EGLNativeSurface.h
+++ b/include/ui/EGLNativeSurface.h
@@ -23,7 +23,7 @@
 #include <cutils/atomic.h>
 #include <utils/RefBase.h>
 
-#include <GLES/eglnatives.h>
+#include <EGL/eglnatives.h>
 
 // ---------------------------------------------------------------------------
 namespace android {
diff --git a/include/ui/EGLNativeWindowSurface.h b/include/ui/EGLNativeWindowSurface.h
index 058479a..3494234 100644
--- a/include/ui/EGLNativeWindowSurface.h
+++ b/include/ui/EGLNativeWindowSurface.h
@@ -20,6 +20,7 @@
 #include <stdint.h>
 #include <sys/types.h>
 #include <ui/EGLNativeSurface.h>
+#include <EGL/egl.h>
 
 // ---------------------------------------------------------------------------
 namespace android {
@@ -33,18 +34,16 @@
     EGLNativeWindowSurface(const sp<Surface>& surface);
     ~EGLNativeWindowSurface();
 
+    void        setSwapRectangle(int l, int t, int w, int h);
+
 private:
     static void         hook_incRef(NativeWindowType window);
     static void         hook_decRef(NativeWindowType window);
     static uint32_t     hook_swapBuffers(NativeWindowType window);
-    static uint32_t     hook_nextBuffer(NativeWindowType window);
-    static void         hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h);
     static void         hook_connect(NativeWindowType window);
     static void         hook_disconnect(NativeWindowType window);
 
             uint32_t    swapBuffers();
-            uint32_t    nextBuffer();
-            void        setSwapRectangle(int l, int t, int w, int h);
             void        connect();
             void        disconnect();
             
diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h
index 017c145..3848d8c 100644
--- a/include/ui/EventHub.h
+++ b/include/ui/EventHub.h
@@ -76,6 +76,9 @@
         DEVICE_REMOVED = 0x20000000
     };
     
+    // examine key input devices for specific framework keycode support
+    bool hasKeys(size_t numCodes, int32_t* keyCodes, uint8_t* outFlags);
+
     virtual bool getEvent(int32_t* outDeviceId, int32_t* outType,
             int32_t* outScancode, int32_t* outKeycode, uint32_t *outFlags,
             int32_t* outValue, nsecs_t* outWhen);
@@ -100,6 +103,7 @@
         const String8   path;
         String8         name;
         uint32_t        classes;
+        uint8_t*        keyBitmask;
         KeyLayoutMap*   layoutMap;
         String8         keylayoutFilename;
         device_t*       next;
@@ -134,8 +138,6 @@
 #ifdef EV_SW
     int32_t         mSwitches[SW_MAX+1];
 #endif
-
-    KeyLayoutMap * mLayoutMap;
 };
 
 }; // namespace android
diff --git a/include/ui/ICamera.h b/include/ui/ICamera.h
index ea2fcee..241fb63 100644
--- a/include/ui/ICamera.h
+++ b/include/ui/ICamera.h
@@ -48,9 +48,9 @@
     // pass the buffered ISurface to the camera service
     virtual status_t        setPreviewDisplay(const sp<ISurface>& surface) = 0;
 
-    // set the frame callback flag to affect how the received frames from
+    // set the preview callback flag to affect how the received frames from
     // preview are handled.
-    virtual void            setFrameCallbackFlag(int frame_callback_flag) = 0;
+    virtual void            setPreviewCallbackFlag(int flag) = 0;
 
     // start preview mode, must call setPreviewDisplay first
     virtual status_t        startPreview() = 0;
@@ -61,6 +61,18 @@
     // get preview state
     virtual bool            previewEnabled() = 0;
 
+    // start recording mode
+    virtual status_t        startRecording() = 0;
+
+    // stop recording mode
+    virtual void            stopRecording() = 0;    
+
+    // get recording state
+    virtual bool            recordingEnabled() = 0;
+
+    // release a recording frame
+    virtual void            releaseRecordingFrame(const sp<IMemory>& mem) = 0;
+
     // auto focus
     virtual status_t        autoFocus() = 0;
 
diff --git a/include/ui/ICameraClient.h b/include/ui/ICameraClient.h
index a286b8e..73b951c 100644
--- a/include/ui/ICameraClient.h
+++ b/include/ui/ICameraClient.h
@@ -32,9 +32,10 @@
     virtual void            shutterCallback() = 0;
     virtual void            rawCallback(const sp<IMemory>& picture) = 0;
     virtual void            jpegCallback(const sp<IMemory>& picture) = 0;
-    virtual void            frameCallback(const sp<IMemory>& frame) = 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;
 
 };
 
diff --git a/include/ui/ISurface.h b/include/ui/ISurface.h
index 9a7383c..1c8043d 100644
--- a/include/ui/ISurface.h
+++ b/include/ui/ISurface.h
@@ -34,11 +34,56 @@
 
 class ISurface : public IInterface
 {
+protected:
+    enum {
+        REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION,
+        UNREGISTER_BUFFERS,
+        POST_BUFFER, // one-way transaction
+        CREATE_OVERLAY,
+    };
+
 public: 
     DECLARE_META_INTERFACE(Surface);
 
-    virtual status_t registerBuffers(int w, int h, int hstride, int vstride,
-            PixelFormat format, const sp<IMemoryHeap>& heap) = 0;
+    
+    class BufferHeap {
+    public:
+        enum {
+            /* flip source image horizontally */
+            FLIP_H    = 0x01,
+            /* flip source image vertically */
+            FLIP_V    = 0x02,
+            /* rotate source image 90 degrees */
+            ROT_90    = 0x04,
+            /* rotate source image 180 degrees */
+            ROT_180   = 0x03,
+            /* rotate source image 270 degrees */
+            ROT_270   = 0x07,
+        };
+        BufferHeap();
+        
+        BufferHeap(uint32_t w, uint32_t h,
+                int32_t hor_stride, int32_t ver_stride, 
+                PixelFormat format, const sp<IMemoryHeap>& heap);
+        
+        BufferHeap(uint32_t w, uint32_t h,
+                int32_t hor_stride, int32_t ver_stride, 
+                PixelFormat format, uint32_t transform, uint32_t flags,
+                const sp<IMemoryHeap>& heap);
+        
+        ~BufferHeap(); 
+        
+        uint32_t w;
+        uint32_t h;
+        int32_t hor_stride;
+        int32_t ver_stride;
+        PixelFormat format;
+        uint32_t transform;
+        uint32_t flags;
+        sp<IMemoryHeap> heap;
+    };
+    
+    virtual status_t registerBuffers(const BufferHeap& buffers) = 0;
 
     virtual void postBuffer(ssize_t offset) = 0; // one-way
 
diff --git a/include/ui/Overlay.h b/include/ui/Overlay.h
index f8454fd..66514b4 100644
--- a/include/ui/Overlay.h
+++ b/include/ui/Overlay.h
@@ -91,6 +91,7 @@
     int32_t getFormat() const;
     int32_t getWidthStride() const;
     int32_t getHeightStride() const;
+    int32_t getBufferCount() const;
     status_t getStatus() const;
     
 private:
diff --git a/include/ui/PixelFormat.h b/include/ui/PixelFormat.h
index b65c959..14af823 100644
--- a/include/ui/PixelFormat.h
+++ b/include/ui/PixelFormat.h
@@ -71,6 +71,10 @@
 
     PIXEL_FORMAT_YCbCr_422_SP= GGL_PIXEL_FORMAT_YCbCr_422_SP,
     PIXEL_FORMAT_YCbCr_420_SP= GGL_PIXEL_FORMAT_YCbCr_420_SP,
+    PIXEL_FORMAT_YCbCr_422_P = GGL_PIXEL_FORMAT_YCbCr_422_P,
+    PIXEL_FORMAT_YCbCr_420_P = GGL_PIXEL_FORMAT_YCbCr_420_P,
+    PIXEL_FORMAT_YCbCr_422_I = GGL_PIXEL_FORMAT_YCbCr_422_I,
+    PIXEL_FORMAT_YCbCr_420_I = GGL_PIXEL_FORMAT_YCbCr_420_I,
 
     // New formats can be added if they're also defined in
     // pixelflinger/format.h
@@ -80,7 +84,19 @@
 
 struct PixelFormatInfo
 {
+    enum { // components
+        ALPHA               = 1,
+        RGB                 = 2,
+        RGBA                = 3,
+        LUMINANCE           = 4,
+        LUMINANCE_ALPHA     = 5,
+        Y_CB_CR_SP          = 6,
+        Y_CB_CR_P           = 7,
+        Y_CB_CR_I           = 8,
+    };
+
     inline PixelFormatInfo() : version(sizeof(PixelFormatInfo)) { }
+    size_t getScanlineSize(unsigned int width) const;
     size_t      version;
     PixelFormat format;
     size_t      bytesPerPixel;
@@ -93,7 +109,9 @@
     uint8_t     l_green;
     uint8_t     h_blue;
     uint8_t     l_blue;
-    uint32_t    reserved[2];
+    uint8_t     components;
+    uint8_t     reserved0[3];
+    uint32_t    reserved1;
 };
 
 // Consider caching the results of these functions are they're not
diff --git a/include/utils/Asset.h b/include/utils/Asset.h
index d8351f5..453a204 100644
--- a/include/utils/Asset.h
+++ b/include/utils/Asset.h
@@ -62,7 +62,11 @@
 
     enum {
         /* data larger than this does not get uncompressed into a buffer */
+#ifdef HAVE_ANDROID_OS
         UNCOMPRESS_DATA_MAX = 1 * 1024 * 1024
+#else
+        UNCOMPRESS_DATA_MAX = 2 * 1024 * 1024
+#endif
     };
 
     /*
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index 2d56e3e..d83a33c 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -223,7 +223,7 @@
 {
     // Number of bytes in this structure.
     uint16_t size;
-    
+
     // Always set to 0.
     uint8_t res0;
         
@@ -1131,10 +1131,8 @@
                 && orientation != settings.orientation) {
                 return false;
             }
-            if (settings.density != 0 && density != 0
-                && density != settings.density) {
-                return false;
-            }
+            // Density not taken into account, always match, no matter what
+            // density is specified for the resource
             if (settings.touchscreen != 0 && touchscreen != 0
                 && touchscreen != settings.touchscreen) {
                 return false;
@@ -1464,11 +1462,11 @@
      * @return ssize_t Either a >= 0 table index or a negative error code.
      */
     ssize_t getResource(uint32_t resID, Res_value* outValue, bool mayBeBag=false,
-            uint32_t* outSpecFlags=NULL) const;
+            uint32_t* outSpecFlags=NULL, ResTable_config* outConfig=NULL) const;
 
     inline ssize_t getResource(const ResTable_ref& res, Res_value* outValue,
             uint32_t* outSpecFlags=NULL) const {
-        return getResource(res.ident, outValue, outSpecFlags);
+        return getResource(res.ident, outValue, false, outSpecFlags, NULL);
     }
 
     ssize_t resolveReference(Res_value* inOutValue,
diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp
index c8c8431..3c18036 100644
--- a/libs/audioflinger/A2dpAudioInterface.cpp
+++ b/libs/audioflinger/A2dpAudioInterface.cpp
@@ -99,6 +99,10 @@
     if (strcmp(key, "a2dp_sink_address") == 0) {        
         return mOutput->setAddress(value);
     }
+    if (strcmp(key, "bluetooth_enabled") == 0 &&
+        strcmp(value, "false") == 0) {
+        return mOutput->close();
+    }
 
     return 0;
 }
@@ -154,8 +158,7 @@
 
 A2dpAudioInterface::A2dpAudioStreamOut::~A2dpAudioStreamOut()
 {
-    if (mData)
-        a2dp_cleanup(mData);
+    close();
 }
 
 ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t bytes)
@@ -186,7 +189,8 @@
     
     return bytes;
 
-Error:   
+Error:
+    close();
     // Simulate audio output timing in case of error
     usleep(bytes * 1000000 / frameSize() / sampleRate());
 
@@ -213,17 +217,22 @@
 
     if (strcmp(address, mA2dpAddress)) {
         strcpy(mA2dpAddress, address);
-        
-        if (mInitialized) {
-            a2dp_cleanup(mData);
-            mData = NULL;
-            mInitialized = false;
-        }
+        close();
     }
     
     return NO_ERROR;
 }
 
+status_t A2dpAudioInterface::A2dpAudioStreamOut::close()
+{
+    if (mData) {
+        a2dp_cleanup(mData);
+        mData = NULL;
+        mInitialized = false;
+    }
+    return NO_ERROR;
+}
+
 status_t A2dpAudioInterface::A2dpAudioStreamOut::dump(int fd, const Vector<String16>& args)
 {
     return NO_ERROR;
diff --git a/libs/audioflinger/A2dpAudioInterface.h b/libs/audioflinger/A2dpAudioInterface.h
index 2197d0e..38ba684 100644
--- a/libs/audioflinger/A2dpAudioInterface.h
+++ b/libs/audioflinger/A2dpAudioInterface.h
@@ -77,10 +77,11 @@
         virtual size_t      bufferSize() const { return 512 * 20; }
         virtual int         channelCount() const { return 2; }
         virtual int         format() const { return AudioSystem::PCM_16_BIT; }
-        virtual uint32_t    latency() const { return ((1000*channelCount()*bufferSize())/frameSize())/sampleRate() + 200; }
+        virtual uint32_t    latency() const { return ((1000*bufferSize())/frameSize())/sampleRate() + 200; }
         virtual status_t    setVolume(float volume) { return INVALID_OPERATION; }
         virtual ssize_t     write(const void* buffer, size_t bytes);
                 status_t    standby();
+                status_t    close();
         virtual status_t    dump(int fd, const Vector<String16>& args);
 
     private:
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index c330bc8..017a298 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -183,6 +183,7 @@
 void AudioFlinger::setOutput(AudioStreamOut* output)
 {
     mRequestedOutput = output;
+    mWaitWorkCV.broadcast();
 }
 
 void AudioFlinger::doSetOutput(AudioStreamOut* output)
@@ -198,6 +199,7 @@
     mFrameCount = getOutputFrameCount(output);
     mAudioMixer = (output == mA2dpOutput ? mA2dpAudioMixer : mHardwareAudioMixer);
     mOutput = output;
+    notifyOutputChange_l();
 }
 
 size_t AudioFlinger::getOutputFrameCount(AudioStreamOut* output) 
@@ -211,6 +213,8 @@
     return (streamType == AudioTrack::SYSTEM ||
             streamType == AudioTrack::RING ||
             streamType == AudioTrack::ALARM ||
+            streamType == AudioTrack::VOICE_CALL ||
+            streamType == AudioTrack::BLUETOOTH_SCO ||
             streamType == AudioTrack::NOTIFICATION);
 }
 
@@ -344,7 +348,8 @@
     int16_t* curBuf = mMixBuffer;
     Vector< sp<Track> > tracksToRemove;
     size_t enabledTracks = 0;
-    nsecs_t standbyTime = systemTime();
+    nsecs_t standbyTime = systemTime();    
+    nsecs_t outputSwitchStandbyTime = 0;
 
     do {
         enabledTracks = 0;
@@ -362,6 +367,11 @@
                     mOutput->standby();
                     mStandby = true;
                 }
+                if (outputSwitchStandbyTime) {
+                    AudioStreamOut *output = (mOutput == mHardwareOutput) ? mA2dpOutput : mHardwareOutput;
+                    output->standby();
+                    outputSwitchStandbyTime = 0;
+                }
                 mHardwareStatus = AUDIO_HW_IDLE;
                 // we're about to wait, flush the binder command buffer
                 IPCThreadState::self()->flushCommands();
@@ -375,11 +385,18 @@
             if (mRequestedOutput != mOutput) {
 
                 // put current output into standby mode
-                if (mOutput) mOutput->standby();
+                if (mOutput) {
+                    outputSwitchStandbyTime = systemTime() + milliseconds(mOutput->latency());
+                }
 
                 // change output
                 doSetOutput(mRequestedOutput);
             }
+            if (outputSwitchStandbyTime && systemTime() > outputSwitchStandbyTime) {
+                AudioStreamOut *output = (mOutput == mHardwareOutput) ? mA2dpOutput : mHardwareOutput;
+                output->standby();
+                outputSwitchStandbyTime = 0;
+            }
 
             // find out which tracks need to be processed
             size_t count = activeTracks.size();
@@ -481,7 +498,7 @@
                     removeActiveTrack(track);
                     if (track->isTerminated()) {
                         mTracks.remove(track);
-                        mAudioMixer->deleteTrackName(track->mName);
+                        deleteTrackName(track->mName);
                     }
                 }
             }  
@@ -512,7 +529,7 @@
             // active tracks were late. Sleep a little bit to give
             // them another chance. If we're too late, the audio
             // hardware will zero-fill for us.
-            LOGV("no buffers - usleep(%lu)", sleepTime);
+//            LOGV("no buffers - usleep(%lu)", sleepTime);
             usleep(sleepTime);
             if (sleepTime < kMaxBufferRecoveryInUsecs) {
                 sleepTime += kBufferRecoveryInUsecs;
@@ -802,12 +819,14 @@
 
     mStreamTypes[stream].volume = value;
     status_t ret = NO_ERROR;
-    if (stream == AudioTrack::VOICE_CALL) {
+    if (stream == AudioTrack::VOICE_CALL ||
+        stream == AudioTrack::BLUETOOTH_SCO) {
         AutoMutex lock(mHardwareLock);
         mHardwareStatus = AUDIO_SET_VOICE_VOLUME;
         ret = mAudioHardware->setVoiceVolume(value);
         mHardwareStatus = AUDIO_HW_IDLE;
     }
+
     return ret;
 }
 
@@ -821,7 +840,20 @@
     if (uint32_t(stream) >= AudioTrack::NUM_STREAM_TYPES) {
         return BAD_VALUE;
     }
+#ifdef WITH_A2DP
+    if (stream == AudioTrack::MUSIC) 
+    {
+        AutoMutex lock(&mLock);
+        if (mA2dpDisableCount > 0)
+            mMusicMuteSaved = muted;
+        else
+            mStreamTypes[stream].mute = muted;
+    } else {
+        mStreamTypes[stream].mute = muted;
+    }
+#else
     mStreamTypes[stream].mute = muted;
+#endif
     return NO_ERROR;
 }
 
@@ -838,6 +870,12 @@
     if (uint32_t(stream) >= AudioTrack::NUM_STREAM_TYPES) {
         return true;
     }
+#ifdef WITH_A2DP
+    if (stream == AudioTrack::MUSIC && mA2dpDisableCount > 0) 
+    {
+        return mMusicMuteSaved;
+    }
+#endif
     return mStreamTypes[stream].mute;
 }
 
@@ -869,6 +907,59 @@
     return result;
 }
 
+
+void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
+{
+    Mutex::Autolock _l(mLock);
+
+    sp<IBinder> binder = client->asBinder();
+    if (mNotificationClients.indexOf(binder) < 0) {
+        LOGV("Adding notification client %p", binder.get());
+        binder->linkToDeath(this);
+        mNotificationClients.add(binder);
+    }
+}
+
+
+size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, int format, int channelCount)
+{
+    return mAudioHardware->getInputBufferSize(sampleRate, format, channelCount);
+}
+
+void AudioFlinger::wakeUp()
+{
+    mWaitWorkCV.broadcast();
+}
+
+void AudioFlinger::binderDied(const wp<IBinder>& who) {
+    Mutex::Autolock _l(mLock);
+
+    IBinder *binder = who.unsafe_get();
+
+    if (binder != NULL) {
+        int index = mNotificationClients.indexOf(binder);
+        if (index >= 0) {
+            LOGV("Removing notification client %p", binder);
+            mNotificationClients.removeAt(index);
+        }
+    }
+}
+
+// must be called with mLock held
+void AudioFlinger::notifyOutputChange_l()
+{
+    size_t size = mNotificationClients.size();
+    uint32_t latency = mOutput->latency();
+    for (size_t i = 0; i < size; i++) {
+        sp<IBinder> binder = mNotificationClients.itemAt(i).promote();
+        if (binder != NULL) {
+            LOGV("Notifying output change to client %p", binder.get());
+            sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient> (binder);
+            client->audioOutputChanged(mFrameCount, mSampleRate, latency);
+        }
+    }
+}
+
 void AudioFlinger::removeClient(pid_t pid)
 {
     Mutex::Autolock _l(mLock);
@@ -920,7 +1011,7 @@
     if (t!=NULL) {
         t->reset();
     }
-    audioMixer()->deleteTrackName(name);
+    deleteTrackName(name);
     removeActiveTrack(track);
     mWaitWorkCV.broadcast();
 }
@@ -938,7 +1029,7 @@
     if (mActiveTracks.indexOf(track) < 0) {
         LOGV("remove track (%d) and delete from mixer", track->name());
         mTracks.remove(track);
-        audioMixer()->deleteTrackName(keep->name());
+        deleteTrackName(keep->name());
     }
 }
 
@@ -953,9 +1044,11 @@
         if (mA2dpDisableCount++ == 0 && isA2dpEnabled()) {
             setA2dpEnabled(false);
             mA2dpSuppressed = true;
-            LOGD("mA2dpSuppressed = true\n");
+            mMusicMuteSaved = mStreamTypes[AudioTrack::MUSIC].mute;
+            mStreamTypes[AudioTrack::MUSIC].mute = true;
+            LOGV("mA2dpSuppressed = true, track %d\n", track->name());
         }
-        LOGD("mA2dpDisableCount incremented to %d\n", mA2dpDisableCount);
+        LOGV("mA2dpDisableCount incremented to %d, track %d\n", mA2dpDisableCount, track->name());
     }
 #endif
 }
@@ -969,17 +1062,45 @@
     if (streamDisablesA2dp(track->type())) {
         if (mA2dpDisableCount > 0) {
             mA2dpDisableCount--;
+            LOGV("mA2dpDisableCount decremented to %d, track %d\n", mA2dpDisableCount, track->name());
             if (mA2dpDisableCount == 0 && mA2dpSuppressed) {
                 setA2dpEnabled(true);
                 mA2dpSuppressed = false;
-            }
-            LOGD("mA2dpDisableCount decremented to %d\n", mA2dpDisableCount);
+                mStreamTypes[AudioTrack::MUSIC].mute = mMusicMuteSaved;
+                LOGV("mA2dpSuppressed = false, track %d\n", track->name());
+            }   
         } else
             LOGE("mA2dpDisableCount is already zero");
     }
 #endif
 }
 
+int AudioFlinger::getTrackName()
+{
+    // Both mixers must have the same set of track used to avoid mismatches when
+    // switching from A2DP output to hardware output
+    int a2DpName;
+    int hwName;
+#ifdef WITH_A2DP
+    a2DpName = mA2dpAudioMixer->getTrackName();
+#endif
+    hwName = mHardwareAudioMixer->getTrackName();
+    
+    LOGW_IF((a2DpName != hwName), "getTrackName track name mismatch! A2DP %d, HW %d", a2DpName, hwName);
+    
+    return hwName;
+}
+
+void AudioFlinger::deleteTrackName(int name)
+{
+    // Both mixers must have the same set of track used to avoid mismatches when
+    // switching from A2DP output to hardware output
+    mHardwareAudioMixer->deleteTrackName(name);
+#ifdef WITH_A2DP
+    mA2dpAudioMixer->deleteTrackName(name);
+#endif
+}
+
 // ----------------------------------------------------------------------------
 
 AudioFlinger::Client::Client(const sp<AudioFlinger>& audioFlinger, pid_t pid)
@@ -1022,7 +1143,8 @@
         mFormat(format),
         mFlags(0)
 {
-    mName = audioFlinger->audioMixer()->getTrackName();
+    mName = audioFlinger->getTrackName();
+    LOGV("TrackBase contructor name %d, calling thread %d", mName, IPCThreadState::self()->getCallingPid());
     if (mName < 0) {
         LOGE("no more track names availlable");
         return;
@@ -1237,14 +1359,14 @@
 
 status_t AudioFlinger::Track::start()
 {
-    LOGV("start(%d)", mName);
+    LOGV("start(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
     mAudioFlinger->addTrack(this);
     return NO_ERROR;
 }
 
 void AudioFlinger::Track::stop()
 {
-    LOGV("stop(%d)", mName);
+    LOGV("stop(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
     Mutex::Autolock _l(mAudioFlinger->mLock);
     if (mState > STOPPED) {
         mState = STOPPED;
@@ -1258,7 +1380,7 @@
 
 void AudioFlinger::Track::pause()
 {
-    LOGV("pause(%d)", mName);
+    LOGV("pause(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid());
     Mutex::Autolock _l(mAudioFlinger->mLock);
     if (mState == ACTIVE || mState == RESUMING) {
         mState = PAUSING;
@@ -1485,7 +1607,7 @@
 
 AudioFlinger::RecordTrack::~RecordTrack()
 {
-    mAudioFlinger->audioMixer()->deleteTrackName(mName);
+    mAudioFlinger->deleteTrackName(mName);
 }
 
 status_t AudioFlinger::RecordTrack::getNextBuffer(AudioBufferProvider::Buffer* buffer)
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index 9ab362a..38fa001 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 
 #include <media/IAudioFlinger.h>
+#include <media/IAudioFlingerClient.h>
 #include <media/IAudioTrack.h>
 #include <media/IAudioRecord.h>
 #include <media/AudioTrack.h>
@@ -54,7 +55,7 @@
 
 static const nsecs_t kStandbyTimeInNsecs = seconds(3);
 
-class AudioFlinger : public BnAudioFlinger, protected Thread
+class AudioFlinger : public BnAudioFlinger, protected Thread, public IBinder::DeathRecipient 
 {
 public:
     static void instantiate();
@@ -109,6 +110,15 @@
 
     virtual     status_t    setParameter(const char* key, const char* value);
 
+    virtual     void        registerClient(const sp<IAudioFlingerClient>& client);
+    
+    virtual     size_t      getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
+    
+    virtual     void        wakeUp();
+    
+    // IBinder::DeathRecipient
+    virtual     void        binderDied(const wp<IBinder>& who);
+
     enum hardware_call_state {
         AUDIO_HW_IDLE = 0,
         AUDIO_HW_INIT,
@@ -314,7 +324,7 @@
         virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
 
         bool isMuted() const {
-            return mMute;
+            return (mMute || mAudioFlinger->mStreamTypes[mStreamType].mute);
         }
 
         bool isPausing() const {
@@ -382,6 +392,8 @@
                 void        destroyTrack(const sp<Track>& track);
                 void        addActiveTrack(const wp<Track>& track);
                 void        removeActiveTrack(const wp<Track>& track);
+                int         getTrackName();
+                void        deleteTrackName(int name);
 
                 AudioMixer* audioMixer() {
                     return mAudioMixer;
@@ -460,6 +472,8 @@
                 status_t    startRecord(RecordTrack* recordTrack);
                 void        stopRecord(RecordTrack* recordTrack);
 
+                void notifyOutputChange_l();
+
     mutable     Mutex                                       mHardwareLock;
     mutable     Mutex                                       mLock;
     mutable     Condition                                   mWaitWorkCV;
@@ -494,6 +508,8 @@
                 bool                                mInWrite;
                 int                                 mA2dpDisableCount;
                 bool                                mA2dpSuppressed;
+                bool                                mMusicMuteSaved;
+                SortedVector< wp<IBinder> >         mNotificationClients;
 };
 
 // ----------------------------------------------------------------------------
diff --git a/libs/surfaceflinger/Android.mk b/libs/surfaceflinger/Android.mk
index d14cebf..53ba3bc 100644
--- a/libs/surfaceflinger/Android.mk
+++ b/libs/surfaceflinger/Android.mk
@@ -15,7 +15,9 @@
     LayerBlur.cpp \
     LayerBitmap.cpp \
     LayerDim.cpp \
+    LayerOrientationAnim.cpp \
     LayerScreenshot.cpp \
+    OrientationAnimation.cpp \
     RFBServer.cpp \
     SurfaceFlinger.cpp \
     Tokenizer.cpp \
@@ -38,7 +40,8 @@
 	libcorecg \
 	libsgl \
 	libpixelflinger \
-	libGLES_CM
+	libEGL \
+	libGLESv1_CM
 
 LOCAL_C_INCLUDES := \
 	$(call include-path-for, corecg graphics)
diff --git a/libs/surfaceflinger/BootAnimation.cpp b/libs/surfaceflinger/BootAnimation.cpp
index d18f59a..2b30336 100644
--- a/libs/surfaceflinger/BootAnimation.cpp
+++ b/libs/surfaceflinger/BootAnimation.cpp
@@ -39,7 +39,9 @@
 #include <core/SkBitmap.h>
 #include <images/SkImageDecoder.h>
 
-#include <GLES/egl.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+#include <EGL/eglext.h>
 
 #include "BootAnimation.h"
 
@@ -47,32 +49,28 @@
 
 // ---------------------------------------------------------------------------
 
-BootAnimation::BootAnimation(const sp<ISurfaceComposer>& composer)
-:   Thread(false)
-{
+BootAnimation::BootAnimation(const sp<ISurfaceComposer>& composer) :
+    Thread(false) {
     mSession = SurfaceComposerClient::clientForConnection(
             composer->createConnection()->asBinder());
 }
 
-BootAnimation::~BootAnimation()
-{
+BootAnimation::~BootAnimation() {
 }
 
-void BootAnimation::onFirstRef()
-{
+void BootAnimation::onFirstRef() {
     run("BootAnimation", PRIORITY_DISPLAY);
 }
 
-const sp<SurfaceComposerClient>& BootAnimation::session() const 
-{
+const sp<SurfaceComposerClient>& BootAnimation::session() const {
     return mSession;
 }
 
-status_t BootAnimation::initTexture(
-        Texture* texture, AssetManager& assets, const char* name)
-{
+status_t BootAnimation::initTexture(Texture* texture, AssetManager& assets,
+        const char* name) {
     Asset* asset = assets.open(name, Asset::ACCESS_BUFFER);
-    if (!asset) return NO_INIT;
+    if (!asset)
+        return NO_INIT;
     SkBitmap bitmap;
     SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(),
             &bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode);
@@ -84,32 +82,32 @@
     bitmap.lockPixels();
 
     const int w = bitmap.width();
-    const int h = bitmap.height();    
+    const int h = bitmap.height();
     const void* p = bitmap.getPixels();
-    
+
     GLint crop[4] = { 0, h, w, -h };
     texture->w = w;
     texture->h = h;
 
     glGenTextures(1, &texture->name);
     glBindTexture(GL_TEXTURE_2D, texture->name);
-    
-    switch(bitmap.getConfig()) {
+
+    switch (bitmap.getConfig()) {
         case SkBitmap::kA8_Config:
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0,
-                    GL_ALPHA, GL_UNSIGNED_BYTE, p);
+            glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA,
+                    GL_UNSIGNED_BYTE, p);
             break;
         case SkBitmap::kARGB_4444_Config:
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0,
-                    GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, p);
+            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
+                    GL_UNSIGNED_SHORT_4_4_4_4, p);
             break;
         case SkBitmap::kARGB_8888_Config:
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0,
-                    GL_RGBA, GL_UNSIGNED_BYTE, p);
+            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA,
+                    GL_UNSIGNED_BYTE, p);
             break;
         case SkBitmap::kRGB_565_Config:
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0,
-                    GL_RGB, GL_UNSIGNED_SHORT_5_6_5, p);
+            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB,
+                    GL_UNSIGNED_SHORT_5_6_5, p);
             break;
         default:
             break;
@@ -123,8 +121,7 @@
     return NO_ERROR;
 }
 
-status_t BootAnimation::readyToRun()
-{
+status_t BootAnimation::readyToRun() {
     mAssets.addDefaultAssets();
 
     DisplayInfo dinfo;
@@ -133,32 +130,27 @@
         return -1;
 
     // create the native surface
-    sp<Surface> s = session()->createSurface(getpid(), 0, 
-            dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
+    sp<Surface> s = session()->createSurface(getpid(), 0, dinfo.w, dinfo.h,
+            PIXEL_FORMAT_RGB_565);
     session()->openTransaction();
     s->setLayer(0x40000000);
     session()->closeTransaction();
 
     // initialize opengl and egl
-    const EGLint attribs[] = {
-            EGL_RED_SIZE,       5,
-            EGL_GREEN_SIZE,     6,
-            EGL_BLUE_SIZE,      5,
-            EGL_DEPTH_SIZE,     0,
-            EGL_NONE
-    };
+    const EGLint attribs[] = { EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6,
+            EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, 0, EGL_NONE };
     EGLint w, h, dummy;
     EGLint numConfigs;
     EGLConfig config;
     EGLSurface surface;
     EGLContext context;
     EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-    eglInitialize(display, NULL, NULL);
     eglChooseConfig(display, attribs, &config, 1, &numConfigs);
 
-    surface = eglCreateWindowSurface(
-            display, config, new EGLNativeWindowSurface(s), NULL);
-    
+    mNativeWindowSurface = new EGLNativeWindowSurface(s);
+    surface = eglCreateWindowSurface(display, config, 
+            mNativeWindowSurface.get(), NULL);
+
     context = eglCreateContext(display, config, NULL, NULL);
     eglQuerySurface(display, surface, EGL_WIDTH, &w);
     eglQuerySurface(display, surface, EGL_HEIGHT, &h);
@@ -167,7 +159,7 @@
     mContext = context;
     mSurface = surface;
     mWidth = w;
-    mHeight= h;
+    mHeight = h;
     mFlingerSurface = s;
 
     // initialize GL
@@ -180,25 +172,21 @@
     return NO_ERROR;
 }
 
-void BootAnimation::requestExit()
-{
+void BootAnimation::requestExit() {
     mBarrier.open();
     Thread::requestExit();
 }
 
-bool BootAnimation::threadLoop()
-{
+bool BootAnimation::threadLoop() {
     bool r = android();
-    eglMakeCurrent(mDisplay, 0, 0, 0);
-    eglDestroyContext(mDisplay, mContext);    
+    eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+    eglDestroyContext(mDisplay, mContext);
     eglDestroySurface(mDisplay, mSurface);
-    eglTerminate(mDisplay);
+    mNativeWindowSurface.clear();
     return r;
 }
 
-
-bool BootAnimation::android()
-{
+bool BootAnimation::android() {
     initTexture(&mAndroid[0], mAssets, "images/android_320x480.png");
     initTexture(&mAndroid[1], mAssets, "images/boot_robot.png");
     initTexture(&mAndroid[2], mAssets, "images/boot_robot_glow.png");
@@ -219,9 +207,9 @@
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
     const int steps = 8;
-    for (int i=1 ; i<steps ; i++) {
+    for (int i = 1; i < steps; i++) {
         float fade = i / float(steps);
-        glColor4f(1, 1, 1, fade*fade);
+        glColor4f(1, 1, 1, fade * fade);
         glClear(GL_COLOR_BUFFER_BIT);
         glDrawTexiOES(0, 0, 0, mAndroid[0].w, mAndroid[0].h);
         eglSwapBuffers(mDisplay, mSurface);
@@ -232,79 +220,73 @@
     glDisable(GL_BLEND);
     glDrawTexiOES(0, 0, 0, mAndroid[0].w, mAndroid[0].h);
     eglSwapBuffers(mDisplay, mSurface);
-    
-    
+
     // update rect for the robot
     const int x = mWidth - mAndroid[1].w - 33;
-    const int y = (mHeight - mAndroid[1].h)/2 - 1;
-    const Rect updateRect(x, y, x+mAndroid[1].w, y+mAndroid[1].h);
+    const int y = (mHeight - mAndroid[1].h) / 2 - 1;
+    const Rect updateRect(x, y, x + mAndroid[1].w, y + mAndroid[1].h);
 
     // draw and update only what we need
-    eglSwapRectangleANDROID(mDisplay, mSurface,
-            updateRect.left, updateRect.top, 
-            updateRect.width(), updateRect.height());
+    mNativeWindowSurface->setSwapRectangle(updateRect.left,
+            updateRect.top, updateRect.width(), updateRect.height());
 
     glEnable(GL_SCISSOR_TEST);
-    glScissor(updateRect.left, mHeight-updateRect.bottom,
-            updateRect.width(), updateRect.height()); 
+    glScissor(updateRect.left, mHeight - updateRect.bottom, updateRect.width(),
+            updateRect.height());
 
     const nsecs_t startTime = systemTime();
-    do
-    {
+    do {
         // glow speed and shape
         nsecs_t time = systemTime() - startTime;
-        float t = ((4.0f/(360.0f*us2ns(16667))) * time);
+        float t = ((4.0f / (360.0f * us2ns(16667))) * time);
         t = t - floorf(t);
-        const float fade = 0.5f + 0.5f*sinf(t * 2*M_PI);
+        const float fade = 0.5f + 0.5f * sinf(t * 2 * M_PI);
 
         // fade the glow in and out
         glDisable(GL_BLEND);
         glBindTexture(GL_TEXTURE_2D, mAndroid[2].name);
         glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
         glColor4f(fade, fade, fade, fade);
-        glDrawTexiOES(updateRect.left, mHeight-updateRect.bottom, 0,
+        glDrawTexiOES(updateRect.left, mHeight - updateRect.bottom, 0,
                 updateRect.width(), updateRect.height());
 
         // draw the robot
         glEnable(GL_BLEND);
         glBindTexture(GL_TEXTURE_2D, mAndroid[1].name);
         glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-        glDrawTexiOES(updateRect.left, mHeight-updateRect.bottom, 0,
+        glDrawTexiOES(updateRect.left, mHeight - updateRect.bottom, 0,
                 updateRect.width(), updateRect.height());
 
         // make sure sleep a lot to not take too much CPU away from 
         // the boot process. With this "glow" animation there is no
         // visible difference. 
-        usleep(16667*4);
+        usleep(16667 * 4);
 
         eglSwapBuffers(mDisplay, mSurface);
     } while (!exitPending());
-    
-    
+
     glDeleteTextures(1, &mAndroid[0].name);
     glDeleteTextures(1, &mAndroid[1].name);
     glDeleteTextures(1, &mAndroid[2].name);
     return false;
 }
 
-
-bool BootAnimation::cylon()
-{
+bool BootAnimation::cylon() {
     // initialize the textures...
-    initTexture(&mLeftTrail,  mAssets, "images/cylon_left.png");
+    initTexture(&mLeftTrail, mAssets, "images/cylon_left.png");
     initTexture(&mRightTrail, mAssets, "images/cylon_right.png");
     initTexture(&mBrightSpot, mAssets, "images/cylon_dot.png");
 
     int w = mWidth;
     int h = mHeight;
 
-    const Point c(w/2 , h/2);
+    const Point c(w / 2, h / 2);
     const GLint amplitude = 60;
-    const int scx = c.x - amplitude - mBrightSpot.w/2;
-    const int scy = c.y - mBrightSpot.h/2;
-    const int scw = amplitude*2 + mBrightSpot.w;
+    const int scx = c.x - amplitude - mBrightSpot.w / 2;
+    const int scy = c.y - mBrightSpot.h / 2;
+    const int scw = amplitude * 2 + mBrightSpot.w;
     const int sch = mBrightSpot.h;
-    const Rect updateRect(scx, h-scy-sch, scx+scw, h-scy);
+    const Rect updateRect(scx, h - scy - sch, scx + scw, h - scy);
 
     // erase screen
     glDisable(GL_SCISSOR_TEST);
@@ -314,33 +296,29 @@
 
     glClear(GL_COLOR_BUFFER_BIT);
 
-    eglSwapRectangleANDROID(mDisplay, mSurface,
-            updateRect.left, updateRect.top, 
-            updateRect.width(), updateRect.height());
+    mNativeWindowSurface->setSwapRectangle(updateRect.left,
+            updateRect.top, updateRect.width(), updateRect.height());
 
     glEnable(GL_SCISSOR_TEST);
     glEnable(GL_BLEND);
     glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
 
-
     // clear the screen to white
     Point p;
     float t = 0;
     float alpha = 1.0f;
     const nsecs_t startTime = systemTime();
     nsecs_t fadeTime = 0;
-    
-    do
-    {
+
+    do {
         // Set scissor in interesting area
-        glScissor(scx, scy, scw, sch); 
+        glScissor(scx, scy, scw, sch);
 
         // erase screen
         glClear(GL_COLOR_BUFFER_BIT);
 
-
         // compute wave
-        const float a = (t * 2*M_PI) - M_PI/2;
+        const float a = (t * 2 * M_PI) - M_PI / 2;
         const float sn = sinf(a);
         const float cs = cosf(a);
         GLint x = GLint(amplitude * sn);
@@ -350,50 +328,50 @@
 
         if (derivative > 0) {
             // vanishing trail...
-            p.x = (-amplitude + c.x) - mBrightSpot.w/2;
-            p.y = c.y-mLeftTrail.h/2;
-            float fade = 2.0f*(0.5f-t);
+            p.x = (-amplitude + c.x) - mBrightSpot.w / 2;
+            p.y = c.y - mLeftTrail.h / 2;
+            float fade = 2.0f * (0.5f - t);
             //fade *= fade;
             glColor4f(fade, fade, fade, fade);
             glBindTexture(GL_TEXTURE_2D, mLeftTrail.name);
             glDrawTexiOES(p.x, p.y, 0, mLeftTrail.w, mLeftTrail.h);
 
             // trail...
-            p.x = (x + c.x) - (mRightTrail.w + mBrightSpot.w/2) + 16;
-            p.y = c.y-mRightTrail.h/2;
-            fade = t<0.25f ? t*4.0f : 1.0f;
+            p.x = (x + c.x) - (mRightTrail.w + mBrightSpot.w / 2) + 16;
+            p.y = c.y - mRightTrail.h / 2;
+            fade = t < 0.25f ? t * 4.0f : 1.0f;
             fade *= fade;
             glColor4f(fade, fade, fade, fade);
             glBindTexture(GL_TEXTURE_2D, mRightTrail.name);
             glDrawTexiOES(p.x, p.y, 0, mRightTrail.w, mRightTrail.h);
-        } else { 
+        } else {
             // vanishing trail..
-            p.x = (amplitude + c.x) - (mRightTrail.w + mBrightSpot.w/2) + 16;
-            p.y = c.y-mRightTrail.h/2;
-            float fade = 2.0f*(0.5f-(t-0.5f));
+            p.x = (amplitude + c.x) - (mRightTrail.w + mBrightSpot.w / 2) + 16;
+            p.y = c.y - mRightTrail.h / 2;
+            float fade = 2.0f * (0.5f - (t - 0.5f));
             //fade *= fade;
             glColor4f(fade, fade, fade, fade);
             glBindTexture(GL_TEXTURE_2D, mRightTrail.name);
             glDrawTexiOES(p.x, p.y, 0, mRightTrail.w, mRightTrail.h);
 
             // trail...
-            p.x = (x + c.x) - mBrightSpot.w/2;
-            p.y = c.y-mLeftTrail.h/2;
-            fade = t<0.5f+0.25f ? (t-0.5f)*4.0f : 1.0f;
+            p.x = (x + c.x) - mBrightSpot.w / 2;
+            p.y = c.y - mLeftTrail.h / 2;
+            fade = t < 0.5f + 0.25f ? (t - 0.5f) * 4.0f : 1.0f;
             fade *= fade;
             glColor4f(fade, fade, fade, fade);
             glBindTexture(GL_TEXTURE_2D, mLeftTrail.name);
             glDrawTexiOES(p.x, p.y, 0, mLeftTrail.w, mLeftTrail.h);
         }
 
-        const Point p( x + c.x-mBrightSpot.w/2, c.y-mBrightSpot.h/2 );
+        const Point p(x + c.x - mBrightSpot.w / 2, c.y - mBrightSpot.h / 2);
         glBindTexture(GL_TEXTURE_2D, mBrightSpot.name);
-        glColor4f(1,0.5,0.5,1);
+        glColor4f(1, 0.5, 0.5, 1);
         glDrawTexiOES(p.x, p.y, 0, mBrightSpot.w, mBrightSpot.h);
 
         // update animation
         nsecs_t time = systemTime() - startTime;
-        t = ((4.0f/(360.0f*us2ns(16667))) * time);
+        t = ((4.0f / (360.0f * us2ns(16667))) * time);
         t = t - floorf(t);
 
         eglSwapBuffers(mDisplay, mSurface);
@@ -406,7 +384,7 @@
             alpha = 1.0f - ((float(time) * 6.0f) / float(s2ns(1)));
 
             session()->openTransaction();
-            mFlingerSurface->setAlpha(alpha*alpha);
+            mFlingerSurface->setAlpha(alpha * alpha);
             session()->closeTransaction();
         }
     } while (alpha > 0);
@@ -421,4 +399,5 @@
 
 // ---------------------------------------------------------------------------
 
-}; // namespace android
+}
+; // namespace android
diff --git a/libs/surfaceflinger/BootAnimation.h b/libs/surfaceflinger/BootAnimation.h
index a4a6d49..b20cea0 100644
--- a/libs/surfaceflinger/BootAnimation.h
+++ b/libs/surfaceflinger/BootAnimation.h
@@ -26,7 +26,8 @@
 #include <ui/ISurfaceComposer.h>
 #include <ui/SurfaceComposerClient.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
 
 #include "Barrier.h"
 
@@ -35,6 +36,7 @@
 namespace android {
 
 class AssetManager;
+class EGLNativeWindowSurface;
 
 // ---------------------------------------------------------------------------
 
@@ -74,6 +76,7 @@
     EGLDisplay  mContext;
     EGLDisplay  mSurface;
     sp<Surface> mFlingerSurface;
+    sp<EGLNativeWindowSurface> mNativeWindowSurface;
     Barrier mBarrier;
 };
 
diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
index 92588fa..f14d7e9 100644
--- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
+++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.cpp
@@ -21,14 +21,16 @@
 #include <string.h>
 #include <math.h>
 
-#include <GLES/egl.h>
-
 #include <cutils/properties.h>
 
 #include <utils/Log.h>
 
 #include <ui/EGLDisplaySurface.h>
 
+#include <GLES/gl.h>
+#include <EGL/eglext.h>
+
+
 #include "DisplayHardware/DisplayHardware.h"
 
 #include <hardware/copybit.h>
@@ -136,26 +138,19 @@
     const char* const egl_extensions = eglQueryString(
             display, EGL_EXTENSIONS);
     
-    const char* egl_extensions_config = egl_extensions;
-    
-    if (strstr(egl_extensions, "EGL_ANDROID_query_string_config")) {
-        egl_extensions_config = eglQueryStringConfigANDROID(
-                display, config, EGL_EXTENSIONS);
-    }
-
     LOGI("EGL informations:");
     LOGI("# of configs : %d", numConfigs);
     LOGI("vendor    : %s", eglQueryString(display, EGL_VENDOR));
     LOGI("version   : %s", eglQueryString(display, EGL_VERSION));
     LOGI("extensions: %s", egl_extensions);
-    LOGI("ext/config: %s", egl_extensions_config);
     LOGI("Client API: %s", eglQueryString(display, EGL_CLIENT_APIS)?:"Not Supported");
 
-    if (strstr(egl_extensions_config, "EGL_ANDROID_swap_rectangle")) {
-        mFlags |= SWAP_RECTANGLE_EXTENSION;
-        // TODO: get the real "update_on_demand" behavior
-        mFlags |= UPDATE_ON_DEMAND;
-    }
+    // TODO: get this from the devfb driver (probably should be HAL module)
+    mFlags |= SWAP_RECTANGLE_EXTENSION;
+    
+    // TODO: get the real "update_on_demand" behavior (probably should be HAL module)
+    mFlags |= UPDATE_ON_DEMAND;
+
     if (eglGetConfigAttrib(display, config, EGL_CONFIG_CAVEAT, &dummy) == EGL_TRUE) {
         if (dummy == EGL_SLOW_CONFIG)
             mFlags |= SLOW_CONFIG;
@@ -173,9 +168,6 @@
     if (eglQuerySurface(display, surface, EGL_SWAP_BEHAVIOR, &dummy) == EGL_TRUE) {
         if (dummy == EGL_BUFFER_PRESERVED) {
             mFlags |= BUFFER_PRESERVED;
-            if (strstr(egl_extensions_config, "EGL_ANDROID_copy_front_to_back")) {
-                mFlags |= COPY_BACK_EXTENSION;
-            }
         }
     }
     
@@ -330,8 +322,7 @@
 
     if (mFlags & SWAP_RECTANGLE_EXTENSION) {
         const Rect& b(newDirty.bounds());
-        eglSwapRectangleANDROID(
-                dpy, surface,
+        mDisplaySurface->setSwapRectangle(
                 b.left, b.top, b.width(), b.height());
     }
 
@@ -352,3 +343,11 @@
 {
     eglMakeCurrent(mDisplay, mSurface, mSurface, mContext);
 }
+
+void DisplayHardware::copyFrontToImage(const copybit_image_t& front) const {
+    mDisplaySurface->copyFrontToImage(front);
+}
+
+void DisplayHardware::copyBackToImage(const copybit_image_t& front) const {
+    mDisplaySurface->copyBackToImage(front);
+}
diff --git a/libs/surfaceflinger/DisplayHardware/DisplayHardware.h b/libs/surfaceflinger/DisplayHardware/DisplayHardware.h
index df97b60..550a4d1 100644
--- a/libs/surfaceflinger/DisplayHardware/DisplayHardware.h
+++ b/libs/surfaceflinger/DisplayHardware/DisplayHardware.h
@@ -22,7 +22,7 @@
 #include <ui/PixelFormat.h>
 #include <ui/Region.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
 
 #include "DisplayHardware/DisplayHardwareBase.h"
 
@@ -39,7 +39,6 @@
 {
 public:
     enum {
-        COPY_BACK_EXTENSION     = 0x00000001,
         DIRECT_TEXTURE          = 0x00000002,
         SWAP_RECTANGLE_EXTENSION= 0x00000004,
         COPY_BITS_EXTENSION     = 0x00000008,
@@ -80,6 +79,9 @@
     copybit_device_t* getBlitEngine() const { return mBlitEngine; }
     overlay_control_device_t* getOverlayEngine() const { return mOverlayEngine; }
     
+    void copyFrontToImage(const copybit_image_t& front) const;
+    void copyBackToImage(const copybit_image_t& front) const;
+       
     Rect bounds() const {
         return Rect(mWidth, mHeight);
     }
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index f65d669..31e63ef 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -186,9 +186,7 @@
         copybit_device_t* copybit = mFlinger->getBlitEngine();
         copybit->set_parameter(copybit, COPYBIT_TRANSFORM, getOrientation());
         copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, s.alpha);
-        copybit->set_parameter(copybit, COPYBIT_DITHER,
-                s.flags & ISurfaceComposer::eLayerDither ?
-                        COPYBIT_ENABLE : COPYBIT_DISABLE);
+        copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
 
         region_iterator it(clip);
         err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it);
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index bdefba3..9277a64 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -23,6 +23,9 @@
 #include <utils/Errors.h>
 #include <utils/Log.h>
 
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
 #include "clz.h"
 #include "LayerBase.h"
 #include "LayerBlur.h"
@@ -111,6 +114,12 @@
         mDrawingState.h = h;
     }
 }
+void LayerBase::forceVisibilityTransaction() {
+    // this can be called without SurfaceFlinger.mStateLock, but if we
+    // can atomically increment the sequence number, it doesn't matter.
+    android_atomic_inc(&mCurrentState.sequence);
+    requestTransaction();
+}
 bool LayerBase::requestTransaction() {
     int32_t old = setTransactionFlags(eTransactionNeeded);
     return ((old & eTransactionNeeded) == 0);
@@ -220,10 +229,15 @@
     return Point(front.w, front.h);
 }
 
+Transform LayerBase::getDrawingStateTransform() const
+{
+    return drawingState().transform;
+}
+
 void LayerBase::validateVisibility(const Transform& planeTransform)
 {
     const Layer::State& s(drawingState());
-    const Transform tr(planeTransform * s.transform);
+    const Transform tr(planeTransform * getDrawingStateTransform());
     const bool transformed = tr.transformed();
    
     const Point size(getPhysicalSize());
@@ -350,6 +364,10 @@
             return;
         }        
     }
+
+    // reset GL state
+    glEnable(GL_SCISSOR_TEST);
+
     onDraw(clip);
 
     /*
@@ -391,6 +409,7 @@
     Rect r;
     Region::iterator iterator(clip);
     if (iterator) {
+        glEnable(GL_SCISSOR_TEST);
         glVertexPointer(2, GL_FIXED, 0, mVertices);
         while (iterator.iterate(&r)) {
             const GLint sy = fbHeight - (r.top + r.height());
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index 5e14dc85..2377a14 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -86,8 +86,8 @@
                 uint32_t        z;
                 uint8_t         alpha;
                 uint8_t         flags;
-                uint8_t         sequence;   // changes when visible regions can change
-                uint8_t         reserved;
+                uint8_t         reserved[2];
+                int32_t         sequence;   // changes when visible regions can change
                 uint32_t        tint;
                 Transform       transform;
                 Region          transparentRegion;
@@ -104,11 +104,11 @@
             
             void commitTransaction(bool skipSize);
             bool requestTransaction();
-
+            void forceVisibilityTransaction();
+            
             uint32_t getTransactionFlags(uint32_t flags);
             uint32_t setTransactionFlags(uint32_t flags);
             
-            void validateVisibility(const Transform& globalTransform);
             Rect visibleBounds() const;
             void drawRegion(const Region& reg) const;
 
@@ -162,7 +162,19 @@
      * the bitmap (as opposed to the size of the drawing state).
      */
     virtual Point getPhysicalSize() const;
-    
+
+    /**
+     * validateVisibility - cache a bunch of things
+     */
+    virtual void validateVisibility(const Transform& globalTransform);
+
+    /**
+     * getDrawingStateTransform - returns the drawing state's transform.
+     * This is used in validateVisibility() and can be use to override or
+     * modify the transform (if so make sure to trigger a transaction).
+     */
+    virtual Transform getDrawingStateTransform() const;
+
     /**
      * lockPageFlip - called each time the screen is redrawn and returns whether
      * the visible regions need to be recomputed (this is a fairly heavy
@@ -320,8 +332,7 @@
             *params = mParams;
         }
 
-        virtual status_t registerBuffers(int w, int h, int hstride, int vstride,
-                PixelFormat format, const sp<IMemoryHeap>& heap) 
+        virtual status_t registerBuffers(const ISurface::BufferHeap& buffers) 
                 { return INVALID_OPERATION; }
         virtual void postBuffer(ssize_t offset) { }
         virtual void unregisterBuffers() { };
diff --git a/libs/surfaceflinger/LayerBitmap.cpp b/libs/surfaceflinger/LayerBitmap.cpp
index 7c98857..e844350 100644
--- a/libs/surfaceflinger/LayerBitmap.cpp
+++ b/libs/surfaceflinger/LayerBitmap.cpp
@@ -69,18 +69,15 @@
         return NO_ERROR;
     }
 
+    PixelFormatInfo info;
+    getPixelFormatInfo(format, &info);
+
     uint32_t allocFlags = MemoryDealer::PAGE_ALIGNED;
     const uint32_t align = 4; // must match GL_UNPACK_ALIGNMENT
-    const uint32_t Bpp = bytesPerPixel(format);
+    const uint32_t Bpp = info.bytesPerPixel;
     uint32_t stride = (w + (alignment-1)) & ~(alignment-1);
     stride = ((stride * Bpp + (align-1)) & ~(align-1)) / Bpp;
-    size_t size = stride * h * Bpp;
-    if (format == PIXEL_FORMAT_YCbCr_422_SP ||
-        format == PIXEL_FORMAT_YCbCr_420_SP) {
-        // in YUV planar, bitsPerPixel is for the Y plane
-        size = (size * bitsPerPixel(format)) / 8;
-    }
-
+    size_t size = info.getScanlineSize(stride) * h;
     if (allocFlags & MemoryDealer::PAGE_ALIGNED) {
         size_t pagesize = getpagesize();
         size = (size + (pagesize-1)) & ~(pagesize-1);
diff --git a/libs/surfaceflinger/LayerBitmap.h b/libs/surfaceflinger/LayerBitmap.h
index 4c2eb50..9ad64c4 100644
--- a/libs/surfaceflinger/LayerBitmap.h
+++ b/libs/surfaceflinger/LayerBitmap.h
@@ -70,9 +70,6 @@
     void getBitmapSurface(copybit_image_t* img) const;
 
 private:
-    LayerBitmap(const LayerBitmap& rhs);
-    LayerBitmap& operator = (const LayerBitmap& rhs);
-
     sp<MemoryDealer>        mAllocator;
     sp<IMemory>             mBitsMemory;
     uint32_t                mAllocFlags;
diff --git a/libs/surfaceflinger/LayerBlur.cpp b/libs/surfaceflinger/LayerBlur.cpp
index efadbcf..d3e456f 100644
--- a/libs/surfaceflinger/LayerBlur.cpp
+++ b/libs/surfaceflinger/LayerBlur.cpp
@@ -23,6 +23,9 @@
 #include <utils/Errors.h>
 #include <utils/Log.h>
 
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
 #include "BlurFilter.h"
 #include "LayerBlur.h"
 #include "SurfaceFlinger.h"
diff --git a/libs/surfaceflinger/LayerBuffer.cpp b/libs/surfaceflinger/LayerBuffer.cpp
index c9cebf4..fc0a603 100644
--- a/libs/surfaceflinger/LayerBuffer.cpp
+++ b/libs/surfaceflinger/LayerBuffer.cpp
@@ -25,6 +25,9 @@
 #include <utils/Log.h>
 #include <utils/StopWatch.h>
 
+#include <utils/IPCThreadState.h>
+#include <utils/IServiceManager.h>
+
 #include <ui/PixelFormat.h>
 #include <ui/EGLDisplaySurface.h>
 
@@ -100,6 +103,15 @@
         source->unregisterBuffers();
 }
 
+Transform LayerBuffer::getDrawingStateTransform() const
+{
+    Transform tr(LayerBaseClient::getDrawingStateTransform());
+    sp<Source> source(getSource());
+    if (source != 0)
+        source->updateTransform(&tr);
+    return tr;
+}
+
 uint32_t LayerBuffer::doTransaction(uint32_t flags)
 {
     sp<Source> source(getSource());
@@ -132,15 +144,13 @@
 /**
  * This creates a "buffer" source for this surface
  */
-status_t LayerBuffer::registerBuffers(int w, int h, int hstride, int vstride,
-        PixelFormat format, const sp<IMemoryHeap>& memoryHeap)
+status_t LayerBuffer::registerBuffers(const ISurface::BufferHeap& buffers)
 {
     Mutex::Autolock _l(mLock);
     if (mSource != 0)
         return INVALID_OPERATION;
 
-    sp<BufferSource> source = new BufferSource(*this, w, h,
-            hstride, vstride, format, memoryHeap);
+    sp<BufferSource> source = new BufferSource(*this, buffers);
 
     status_t result = source->getStatus();
     if (result == NO_ERROR) {
@@ -194,13 +204,39 @@
     mOwner = 0;
 }
 
-status_t LayerBuffer::SurfaceBuffer::registerBuffers(
-        int w, int h, int hs, int vs,
-        PixelFormat format, const sp<IMemoryHeap>& heap)
+status_t LayerBuffer::SurfaceBuffer::onTransact(
+    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+    switch (code) {
+        case REGISTER_BUFFERS:
+        case UNREGISTER_BUFFERS:
+        case CREATE_OVERLAY:
+        {
+            // codes that require permission check
+            IPCThreadState* ipc = IPCThreadState::self();
+            const int pid = ipc->getCallingPid();
+            const int self_pid = getpid();
+            if (LIKELY(pid != self_pid)) {
+                // we're called from a different process, do the real check
+                if (!checkCallingPermission(
+                        String16("android.permission.ACCESS_SURFACE_FLINGER")))
+                {
+                    const int uid = ipc->getCallingUid();
+                    LOGE("Permission Denial: "
+                            "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid);
+                    return PERMISSION_DENIED;
+                }
+            }
+        }
+    }
+    return LayerBaseClient::Surface::onTransact(code, data, reply, flags);
+}
+
+status_t LayerBuffer::SurfaceBuffer::registerBuffers(const ISurface::BufferHeap& buffers)
 {
     LayerBuffer* owner(getOwner());
     if (owner)
-        return owner->registerBuffers(w, h, hs, vs, format, heap);
+        return owner->registerBuffers(buffers);
     return NO_INIT;
 }
 
@@ -237,23 +273,20 @@
 // LayerBuffer::Buffer
 // ============================================================================
 
-LayerBuffer::Buffer::Buffer(const sp<IMemoryHeap>& heap, ssize_t offset,
-        int w, int h, int hs, int vs, int f)
-: mHeap(heap)
+LayerBuffer::Buffer::Buffer(const ISurface::BufferHeap& buffers, ssize_t offset)
+    : mBufferHeap(buffers)
 {
     NativeBuffer& src(mNativeBuffer);
     src.crop.l = 0;
     src.crop.t = 0;
-    src.crop.r = w;
-    src.crop.b = h;
-    src.img.w = hs ?: w;
-    src.img.h = vs ?: h;
-    src.img.format = f;
+    src.crop.r = buffers.w;
+    src.crop.b = buffers.h;
+    src.img.w = buffers.hor_stride ?: buffers.w;
+    src.img.h = buffers.ver_stride ?: buffers.h;
+    src.img.format = buffers.format;
     src.img.offset = offset;
-    src.img.base   = heap->base();
-    src.img.fd     = heap->heapID();
-    // FIXME: make sure this buffer lies within the heap, in which case, set
-    // mHeap to null
+    src.img.base   = buffers.heap->base();
+    src.img.fd     = buffers.heap->heapID();
 }
 
 LayerBuffer::Buffer::~Buffer()
@@ -283,41 +316,53 @@
 }
 void LayerBuffer::Source::unregisterBuffers() {
 }
+void LayerBuffer::Source::updateTransform(Transform* tr) const {
+}
 
 // ---------------------------------------------------------------------------
 
 LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
-        int w, int h, int hstride, int vstride,
-        PixelFormat format, const sp<IMemoryHeap>& memoryHeap)
-    : Source(layer), mStatus(NO_ERROR), mTextureName(-1U)
+        const ISurface::BufferHeap& buffers)
+    : Source(layer), mStatus(NO_ERROR), 
+      mBufferSize(0), mTextureName(-1U)
 {
-    if (memoryHeap == NULL) {
+    if (buffers.heap == NULL) {
         // this is allowed, but in this case, it is illegal to receive
         // postBuffer(). The surface just erases the framebuffer with
         // fully transparent pixels.
-        mHeap.clear();
-        mWidth = w;
-        mHeight = h;
+        mBufferHeap = buffers;
         mLayer.setNeedsBlending(false);
         return;
     }
 
-    status_t err = (memoryHeap->heapID() >= 0) ? NO_ERROR : NO_INIT;
+    status_t err = (buffers.heap->heapID() >= 0) ? NO_ERROR : NO_INIT;
     if (err != NO_ERROR) {
+        LOGE("LayerBuffer::BufferSource: invalid heap (%s)", strerror(err));
+        mStatus = err;
+        return;
+    }
+    
+    PixelFormatInfo info;
+    err = getPixelFormatInfo(buffers.format, &info);
+    if (err != NO_ERROR) {
+        LOGE("LayerBuffer::BufferSource: invalid format %d (%s)",
+                buffers.format, strerror(err));
         mStatus = err;
         return;
     }
 
-    // TODO: validate format/parameters
-    mHeap = memoryHeap;
-    mWidth = w;
-    mHeight = h;
-    mHStride = hstride;
-    mVStride = vstride;
-    mFormat = format;
-    PixelFormatInfo info;
-    getPixelFormatInfo(format, &info);
-    mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0);
+    if (buffers.hor_stride<0 || buffers.ver_stride<0) {
+        LOGE("LayerBuffer::BufferSource: invalid parameters "
+             "(w=%d, h=%d, xs=%d, ys=%d)", 
+             buffers.w, buffers.h, buffers.hor_stride, buffers.ver_stride);
+        mStatus = BAD_VALUE;
+        return;
+    }
+
+    mBufferHeap = buffers;
+    mLayer.setNeedsBlending((info.h_alpha - info.l_alpha) > 0);    
+    mBufferSize = info.getScanlineSize(buffers.hor_stride)*buffers.ver_stride;
+    mLayer.forceVisibilityTransaction();
 }
 
 LayerBuffer::BufferSource::~BufferSource()
@@ -329,21 +374,24 @@
 
 void LayerBuffer::BufferSource::postBuffer(ssize_t offset)
 {    
-    sp<IMemoryHeap> heap;
-    int w, h, hs, vs, f;
+    ISurface::BufferHeap buffers;
     { // scope for the lock
         Mutex::Autolock _l(mLock);
-        w = mWidth;
-        h = mHeight;
-        hs= mHStride;
-        vs= mVStride;
-        f = mFormat;
-        heap = mHeap;
+        buffers = mBufferHeap;
+        if (buffers.heap != 0) {
+            const size_t memorySize = buffers.heap->getSize();
+            if ((size_t(offset) + mBufferSize) > memorySize) {
+                LOGE("LayerBuffer::BufferSource::postBuffer() "
+                     "invalid buffer (offset=%d, size=%d, heap-size=%d",
+                     int(offset), int(mBufferSize), int(memorySize));
+                return;
+            }
+        }
     }
 
     sp<Buffer> buffer;
-    if (heap != 0) {
-        buffer = new LayerBuffer::Buffer(heap, offset, w, h, hs, vs, f);
+    if (buffers.heap != 0) {
+        buffer = new LayerBuffer::Buffer(buffers, offset);
         if (buffer->getStatus() != NO_ERROR)
             buffer.clear();
         setBuffer(buffer);
@@ -354,7 +402,7 @@
 void LayerBuffer::BufferSource::unregisterBuffers()
 {
     Mutex::Autolock _l(mLock);
-    mHeap.clear();
+    mBufferHeap.heap.clear();
     mBuffer.clear();
     mLayer.invalidate();
 }
@@ -371,6 +419,17 @@
     mBuffer = buffer;
 }
 
+void LayerBuffer::BufferSource::updateTransform(Transform* tr) const
+{
+    uint32_t bufTransform = mBufferHeap.transform;
+    // TODO: handle all transforms
+    if (bufTransform == ISurface::BufferHeap::ROT_90) {
+        Transform rot90;
+        rot90.set(0, -1, 1, 0);
+        *tr = (*tr) * rot90;
+    }
+}
+
 void LayerBuffer::BufferSource::onDraw(const Region& clip) const 
 {
     sp<Buffer> buffer(getBuffer());
@@ -452,11 +511,13 @@
         region_iterator it(clip);
         copybit->set_parameter(copybit, COPYBIT_TRANSFORM, mLayer.getOrientation());
         copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, s.alpha);
-        copybit->set_parameter(copybit, COPYBIT_DITHER,
-                s.flags & ISurfaceComposer::eLayerDither ?
-                        COPYBIT_ENABLE : COPYBIT_DISABLE);
+        copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
+
         err = copybit->stretch(copybit,
                 &dst, &src.img, &drect, &src.crop, &it);
+        if (err != NO_ERROR) {
+            LOGE("copybit failed (%s)", strerror(err));
+        }
     }
 
     if (!can_use_copybit || err) {
diff --git a/libs/surfaceflinger/LayerBuffer.h b/libs/surfaceflinger/LayerBuffer.h
index 6e3d49f..5532532 100644
--- a/libs/surfaceflinger/LayerBuffer.h
+++ b/libs/surfaceflinger/LayerBuffer.h
@@ -22,7 +22,7 @@
 
 #include <utils/IMemory.h>
 #include <private/ui/LayerState.h>
-#include <GLES/eglnatives.h>
+#include <EGL/eglnatives.h>
 
 #include "LayerBase.h"
 #include "LayerBitmap.h"
@@ -46,6 +46,7 @@
         virtual void onVisibilityResolved(const Transform& planeTransform);
         virtual void postBuffer(ssize_t offset);
         virtual void unregisterBuffers();
+        virtual void updateTransform(Transform* tr) const;
     protected:
         LayerBuffer& mLayer;
     };
@@ -67,9 +68,9 @@
     virtual void onDraw(const Region& clip) const;
     virtual uint32_t doTransaction(uint32_t flags);
     virtual void unlockPageFlip(const Transform& planeTransform, Region& outDirtyRegion);
+    virtual Transform getDrawingStateTransform() const;
 
-    status_t registerBuffers(int w, int h, int hstride, int vstride,
-            PixelFormat format, const sp<IMemoryHeap>& heap);
+    status_t registerBuffers(const ISurface::BufferHeap& buffers);
     void postBuffer(ssize_t offset);
     void unregisterBuffers();
     sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, int32_t format);
@@ -89,10 +90,9 @@
 
     class Buffer : public LightRefBase<Buffer> {
     public:
-        Buffer(const sp<IMemoryHeap>& heap, ssize_t offset,
-                int w, int h, int hs, int vs, int f);
+        Buffer(const ISurface::BufferHeap& buffers, ssize_t offset);
         inline status_t getStatus() const {
-            return mHeap!=0 ? NO_ERROR : NO_INIT;
+            return mBufferHeap.heap!=0 ? NO_ERROR : NO_INIT;
         }
         inline const NativeBuffer& getBuffer() const {
             return mNativeBuffer;
@@ -103,34 +103,29 @@
         Buffer(const Buffer& rhs);
         ~Buffer();
     private:
-        sp<IMemoryHeap>    mHeap;
-        NativeBuffer       mNativeBuffer;
+        ISurface::BufferHeap    mBufferHeap;
+        NativeBuffer            mNativeBuffer;
     };
 
     class BufferSource : public Source {
     public:
-        BufferSource(LayerBuffer& layer,
-                int w, int h, int hstride, int vstride,
-                PixelFormat format, const sp<IMemoryHeap>& heap);
+        BufferSource(LayerBuffer& layer, const ISurface::BufferHeap& buffers);
         virtual ~BufferSource();
 
         status_t getStatus() const { return mStatus; }
         sp<Buffer> getBuffer() const;
         void setBuffer(const sp<Buffer>& buffer);
 
+        virtual void updateTransform(Transform* tr) const; 
         virtual void onDraw(const Region& clip) const;
         virtual void postBuffer(ssize_t offset);
         virtual void unregisterBuffers();
     private:
         mutable Mutex   mLock;
-        sp<IMemoryHeap> mHeap;
         sp<Buffer>      mBuffer;
         status_t        mStatus;
-        int             mWidth;
-        int             mHeight;
-        int             mHStride;
-        int             mVStride;
-        int             mFormat;
+        ISurface::BufferHeap mBufferHeap;
+        size_t          mBufferSize;
         mutable sp<MemoryDealer> mTemporaryDealer;
         mutable LayerBitmap mTempBitmap;
         mutable GLuint  mTextureName;
@@ -186,8 +181,9 @@
     public:
                 SurfaceBuffer(SurfaceID id, LayerBuffer* owner);
         virtual ~SurfaceBuffer();
-        virtual status_t registerBuffers(int w, int h, int hstride, int vstride,
-                PixelFormat format, const sp<IMemoryHeap>& heap);
+        virtual status_t onTransact(
+            uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
+        virtual status_t registerBuffers(const ISurface::BufferHeap& buffers);
         virtual void postBuffer(ssize_t offset);
         virtual void unregisterBuffers();
         virtual sp<OverlayRef> createOverlay(
diff --git a/libs/surfaceflinger/LayerOrientationAnim.cpp b/libs/surfaceflinger/LayerOrientationAnim.cpp
new file mode 100644
index 0000000..46b3b19
--- /dev/null
+++ b/libs/surfaceflinger/LayerOrientationAnim.cpp
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SurfaceFlinger"
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/Errors.h>
+#include <utils/Log.h>
+
+#include <core/SkBitmap.h>
+
+#include <ui/EGLDisplaySurface.h>
+
+#include "LayerBase.h"
+#include "LayerOrientationAnim.h"
+#include "SurfaceFlinger.h"
+#include "DisplayHardware/DisplayHardware.h"
+#include "OrientationAnimation.h"
+
+namespace android {
+// ---------------------------------------------------------------------------
+
+const uint32_t LayerOrientationAnim::typeInfo = LayerBase::typeInfo | 0x80;
+const char* const LayerOrientationAnim::typeID = "LayerOrientationAnim";
+
+// ---------------------------------------------------------------------------
+
+LayerOrientationAnim::LayerOrientationAnim(
+        SurfaceFlinger* flinger, DisplayID display, 
+        OrientationAnimation* anim, 
+        const LayerBitmap& bitmap,
+        const LayerBitmap& bitmapIn)
+    : LayerBase(flinger, display), mAnim(anim), 
+      mBitmap(bitmap), mBitmapIn(bitmapIn), 
+      mTextureName(-1), mTextureNameIn(-1)
+{
+    mStartTime = systemTime();
+    mFinishTime = 0;
+    mOrientationCompleted = false;
+    mFirstRedraw = false;
+    mLastNormalizedTime = 0;
+    mLastScale = 0;
+    mNeedsBlending = false;
+}
+
+LayerOrientationAnim::~LayerOrientationAnim()
+{
+    if (mTextureName != -1U) {
+        LayerBase::deletedTextures.add(mTextureName);
+    }
+    if (mTextureNameIn != -1U) {
+        LayerBase::deletedTextures.add(mTextureNameIn);
+    }
+}
+
+bool LayerOrientationAnim::needsBlending() const 
+{
+    return mNeedsBlending; 
+}
+
+Point LayerOrientationAnim::getPhysicalSize() const
+{
+    const GraphicPlane& plane(graphicPlane(0));
+    const DisplayHardware& hw(plane.displayHardware());
+    return Point(hw.getWidth(), hw.getHeight());
+}
+
+void LayerOrientationAnim::validateVisibility(const Transform&)
+{
+    const Layer::State& s(drawingState());
+    const Transform tr(getDrawingStateTransform());
+    const Point size(getPhysicalSize());
+    uint32_t w = size.x;
+    uint32_t h = size.y;
+    mTransformedBounds = tr.makeBounds(w, h);
+    mLeft = tr.tx();
+    mTop  = tr.ty();
+    transparentRegionScreen.clear();
+    mTransformed = true;
+    mCanUseCopyBit = false;
+    copybit_device_t* copybit = mFlinger->getBlitEngine();
+    if (copybit) { 
+        mCanUseCopyBit = true;
+    }
+}
+
+void LayerOrientationAnim::onOrientationCompleted()
+{
+    mFinishTime = systemTime();
+    mOrientationCompleted = true;
+    mFirstRedraw = true;
+    mNeedsBlending = true;
+    mFlinger->invalidateLayerVisibility(this);
+}
+
+void LayerOrientationAnim::onDraw(const Region& clip) const
+{
+    // Animation...
+    const float MIN_SCALE = 0.5f;
+    const float DURATION = ms2ns(200);
+    const float BOUNCES_PER_SECOND = 1.618f;
+    const float BOUNCES_AMPLITUDE = 1.0f/32.0f;
+
+    const nsecs_t now = systemTime();
+    float scale, alpha;
+    
+    if (mOrientationCompleted) {
+        if (mFirstRedraw) {
+            mFirstRedraw = false;
+            
+            // make a copy of what's on screen
+            copybit_image_t image;
+            mBitmapIn.getBitmapSurface(&image);
+            const DisplayHardware& hw(graphicPlane(0).displayHardware());
+            hw.copyBackToImage(image);
+
+            // and erase the screen for this round
+            glDisable(GL_BLEND);
+            glDisable(GL_DITHER);
+            glDisable(GL_SCISSOR_TEST);
+            glClearColor(0,0,0,0);
+            glClear(GL_COLOR_BUFFER_BIT);
+            
+            // FIXME: code below is gross
+            mNeedsBlending = false;
+            LayerOrientationAnim* self(const_cast<LayerOrientationAnim*>(this));
+            mFlinger->invalidateLayerVisibility(self);
+        }
+
+        // make sure pick-up where we left off
+        const float duration = DURATION * mLastNormalizedTime;
+        const float normalizedTime = (float(now - mFinishTime) / duration);
+        if (normalizedTime <= 1.0f) {
+            const float squaredTime = normalizedTime*normalizedTime;
+            scale = (1.0f - mLastScale)*squaredTime + mLastScale;
+            alpha = (1.0f - normalizedTime);
+            alpha *= alpha;
+            alpha *= alpha;
+        } else {
+            mAnim->onAnimationFinished();
+            scale = 1.0f;
+            alpha = 0.0f;
+        }
+    } else {
+        const float normalizedTime = float(now - mStartTime) / DURATION;
+        if (normalizedTime <= 1.0f) {
+            mLastNormalizedTime = normalizedTime;
+            const float squaredTime = normalizedTime*normalizedTime;
+            scale = (MIN_SCALE-1.0f)*squaredTime + 1.0f;
+            alpha = 1.0f;
+        } else {
+            mLastNormalizedTime = 1.0f;
+            const float to_seconds = DURATION / seconds(1);
+            const float phi = BOUNCES_PER_SECOND * 
+                    (((normalizedTime - 1.0f) * to_seconds)*M_PI*2);
+            scale = MIN_SCALE + BOUNCES_AMPLITUDE * (1.0f - cosf(phi));
+            alpha = 1.0f;
+        }
+        mLastScale = scale;
+    }
+    drawScaled(scale, alpha);
+}
+
+void LayerOrientationAnim::drawScaled(float f, float alpha) const
+{
+    copybit_image_t dst;
+    const GraphicPlane& plane(graphicPlane(0));
+    const DisplayHardware& hw(plane.displayHardware());
+    hw.getDisplaySurface(&dst);
+
+    // clear screen
+    // TODO: with update on demand, we may be able 
+    // to not erase the screen at all during the animation 
+    if (!mOrientationCompleted) {
+        glDisable(GL_BLEND);
+        glDisable(GL_DITHER);
+        glDisable(GL_SCISSOR_TEST);
+        glClearColor(0,0,0,0);
+        glClear(GL_COLOR_BUFFER_BIT);
+    }
+    
+    const int w = dst.w*f; 
+    const int h = dst.h*f; 
+    const int xc = uint32_t(dst.w-w)/2;
+    const int yc = uint32_t(dst.h-h)/2;
+    const copybit_rect_t drect = { xc, yc, xc+w, yc+h }; 
+
+    copybit_image_t src;
+    mBitmap.getBitmapSurface(&src);
+    const copybit_rect_t srect = { 0, 0, src.w, src.h };
+
+    int err = NO_ERROR;
+    const int can_use_copybit = canUseCopybit();
+    if (can_use_copybit)  {
+        copybit_device_t* copybit = mFlinger->getBlitEngine();
+        copybit->set_parameter(copybit, COPYBIT_TRANSFORM, 0);
+        copybit->set_parameter(copybit, COPYBIT_DITHER, COPYBIT_ENABLE);
+
+        if (alpha < 1.0f) {
+            copybit_image_t srcIn;
+            mBitmapIn.getBitmapSurface(&srcIn);
+            region_iterator it(Region(Rect( drect.l, drect.t, drect.r, drect.b )));
+            copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, 0xFF);
+            err = copybit->stretch(copybit, &dst, &srcIn, &drect, &srect, &it);
+        }
+
+        if (!err && alpha > 0.0f) {
+            region_iterator it(Region(Rect( drect.l, drect.t, drect.r, drect.b )));
+            copybit->set_parameter(copybit, COPYBIT_PLANE_ALPHA, int(alpha*255));
+            err = copybit->stretch(copybit, &dst, &src, &drect, &srect, &it);
+        }
+        LOGE_IF(err != NO_ERROR, "copybit failed (%s)", strerror(err));
+    }
+    if (!can_use_copybit || err) {   
+        GGLSurface t;
+        t.version = sizeof(GGLSurface);
+        t.width  = src.w;
+        t.height = src.h;
+        t.stride = src.w;
+        t.vstride= src.h;
+        t.format = src.format;
+        t.data = (GGLubyte*)(intptr_t(src.base) + src.offset);
+
+        Transform tr;
+        tr.set(f,0,0,f);
+        tr.set(xc, yc);
+        
+        // FIXME: we should not access mVertices and mDrawingState like that,
+        // but since we control the animation, we know it's going to work okay.
+        // eventually we'd need a more formal way of doing things like this.
+        LayerOrientationAnim& self(const_cast<LayerOrientationAnim&>(*this));
+        tr.transform(self.mVertices[0], 0, 0);
+        tr.transform(self.mVertices[1], 0, src.h);
+        tr.transform(self.mVertices[2], src.w, src.h);
+        tr.transform(self.mVertices[3], src.w, 0);
+        if (!(mFlags & DisplayHardware::SLOW_CONFIG)) {
+            // Too slow to do this in software
+            self.mDrawingState.flags |= ISurfaceComposer::eLayerFilter;
+        }
+
+        if (alpha < 1.0f) {
+            copybit_image_t src;
+            mBitmapIn.getBitmapSurface(&src);
+            t.data = (GGLubyte*)(intptr_t(src.base) + src.offset);
+            if (UNLIKELY(mTextureNameIn == -1LU)) {
+                mTextureNameIn = createTexture();
+                GLuint w=0, h=0;
+                const Region dirty(Rect(t.width, t.height));
+                loadTexture(dirty, mTextureNameIn, t, w, h);
+            }
+            self.mDrawingState.alpha = 255;
+            const Region clip(Rect( drect.l, drect.t, drect.r, drect.b ));
+            drawWithOpenGL(clip, mTextureName, t);
+        }
+
+        t.data = (GGLubyte*)(intptr_t(src.base) + src.offset);
+        if (UNLIKELY(mTextureName == -1LU)) {
+            mTextureName = createTexture();
+            GLuint w=0, h=0;
+            const Region dirty(Rect(t.width, t.height));
+            loadTexture(dirty, mTextureName, t, w, h);
+        }
+        self.mDrawingState.alpha = int(alpha*255);
+        const Region clip(Rect( drect.l, drect.t, drect.r, drect.b ));
+        drawWithOpenGL(clip, mTextureName, t);
+    }
+}
+
+// ---------------------------------------------------------------------------
+
+}; // namespace android
diff --git a/libs/surfaceflinger/LayerOrientationAnim.h b/libs/surfaceflinger/LayerOrientationAnim.h
new file mode 100644
index 0000000..73676859
--- /dev/null
+++ b/libs/surfaceflinger/LayerOrientationAnim.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_LAYER_ORIENTATION_ANIM_H
+#define ANDROID_LAYER_ORIENTATION_ANIM_H
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <utils/threads.h>
+#include <utils/Parcel.h>
+
+#include "LayerBase.h"
+#include "LayerBitmap.h"
+
+namespace android {
+
+// ---------------------------------------------------------------------------
+class OrientationAnimation;
+
+class LayerOrientationAnim : public LayerBase
+{
+public:    
+    static const uint32_t typeInfo;
+    static const char* const typeID;
+    virtual char const* getTypeID() const { return typeID; }
+    virtual uint32_t getTypeInfo() const { return typeInfo; }
+    
+                LayerOrientationAnim(SurfaceFlinger* flinger, DisplayID display,
+                        OrientationAnimation* anim, 
+                        const LayerBitmap& zoomOut,
+                        const LayerBitmap& zoomIn);
+        virtual ~LayerOrientationAnim();
+
+            void onOrientationCompleted();
+
+    virtual void onDraw(const Region& clip) const;
+    virtual Point getPhysicalSize() const;
+    virtual void validateVisibility(const Transform& globalTransform);
+    virtual bool needsBlending() const;
+    virtual bool isSecure() const       { return false; }
+private:
+    void drawScaled(float scale, float alpha) const;
+
+    OrientationAnimation* mAnim;
+    LayerBitmap mBitmap;
+    LayerBitmap mBitmapIn;
+    nsecs_t mStartTime;
+    nsecs_t mFinishTime;
+    bool mOrientationCompleted;
+    mutable bool mFirstRedraw;
+    mutable float mLastNormalizedTime;
+    mutable float mLastScale;
+    mutable GLuint  mTextureName;
+    mutable GLuint  mTextureNameIn;
+    mutable bool mNeedsBlending;
+};
+
+// ---------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_LAYER_ORIENTATION_ANIM_H
diff --git a/libs/surfaceflinger/LayerScreenshot.cpp b/libs/surfaceflinger/LayerScreenshot.cpp
index 3e7132b..40c47b0 100644
--- a/libs/surfaceflinger/LayerScreenshot.cpp
+++ b/libs/surfaceflinger/LayerScreenshot.cpp
@@ -35,7 +35,7 @@
 namespace android {
 // ---------------------------------------------------------------------------
 
-const uint32_t LayerScreenshot::typeInfo = LayerBase::typeInfo | 0x20;
+const uint32_t LayerScreenshot::typeInfo = LayerBase::typeInfo | 0x40;
 const char* const LayerScreenshot::typeID = "LayerScreenshot";
 
 // ---------------------------------------------------------------------------
diff --git a/libs/surfaceflinger/OrientationAnimation.cpp b/libs/surfaceflinger/OrientationAnimation.cpp
new file mode 100644
index 0000000..f6f1326
--- /dev/null
+++ b/libs/surfaceflinger/OrientationAnimation.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SurfaceFlinger"
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <limits.h>
+
+#include "LayerOrientationAnim.h"
+#include "OrientationAnimation.h"
+#include "SurfaceFlinger.h"
+#include "VRamHeap.h"
+
+#include "DisplayHardware/DisplayHardware.h"
+
+namespace android {
+
+// ---------------------------------------------------------------------------
+
+OrientationAnimation::OrientationAnimation(const sp<SurfaceFlinger>& flinger)
+    : mFlinger(flinger), mLayerOrientationAnim(NULL), mState(DONE)
+{
+    // allocate a memory-dealer for this the first time
+    mTemporaryDealer = mFlinger->getSurfaceHeapManager()->createHeap(
+            ISurfaceComposer::eHardware);
+}
+
+OrientationAnimation::~OrientationAnimation()
+{
+}
+
+void OrientationAnimation::onOrientationChanged()
+{
+    if (mState == DONE)
+        mState = PREPARE;
+}
+
+void OrientationAnimation::onAnimationFinished()
+{
+    if (mState != DONE)
+        mState = FINISH;
+}
+
+bool OrientationAnimation::run_impl()
+{
+    bool skip_frame;
+    switch (mState) {
+        default:
+        case DONE:
+            skip_frame = done();
+            break;
+        case PREPARE:
+            skip_frame = prepare();
+            break;
+        case PHASE1:
+            skip_frame = phase1();
+            break;
+        case PHASE2:
+            skip_frame = phase2();
+            break;
+        case FINISH:
+            skip_frame = finished();
+            break;
+    }
+    return skip_frame;
+}
+
+bool OrientationAnimation::done()
+{
+    if (mFlinger->isFrozen()) {
+        // we are not allowed to draw, but pause a bit to make sure
+        // apps don't end up using the whole CPU, if they depend on
+        // surfaceflinger for synchronization.
+        usleep(8333); // 8.3ms ~ 120fps
+        return true;
+    }
+    return false;
+}
+
+bool OrientationAnimation::prepare()
+{
+    mState = PHASE1;
+    
+    const GraphicPlane& plane(mFlinger->graphicPlane(0));
+    const DisplayHardware& hw(plane.displayHardware());
+    const uint32_t w = hw.getWidth();
+    const uint32_t h = hw.getHeight();
+
+    LayerBitmap bitmap;
+    bitmap.init(mTemporaryDealer);
+    bitmap.setBits(w, h, 1, hw.getFormat());
+
+    LayerBitmap bitmapIn;
+    bitmapIn.init(mTemporaryDealer);
+    bitmapIn.setBits(w, h, 1, hw.getFormat());
+
+    copybit_image_t front;
+    bitmap.getBitmapSurface(&front);
+    hw.copyFrontToImage(front);
+
+    LayerOrientationAnim* l = new LayerOrientationAnim(
+            mFlinger.get(), 0, this, bitmap, bitmapIn);
+    l->initStates(w, h, 0);
+    l->setLayer(INT_MAX-1);
+    mFlinger->addLayer(l);
+    mLayerOrientationAnim = l;
+    return true;
+}
+
+bool OrientationAnimation::phase1()
+{
+    if (mFlinger->isFrozen() == false) {
+        // start phase 2
+        mState = PHASE2;
+        mLayerOrientationAnim->onOrientationCompleted();
+        mLayerOrientationAnim->invalidate();
+        return true;
+        
+    }
+    mLayerOrientationAnim->invalidate();
+    return false;
+}
+
+bool OrientationAnimation::phase2()
+{
+    // do the 2nd phase of the animation
+    mLayerOrientationAnim->invalidate();
+    return false;
+}
+
+bool OrientationAnimation::finished()
+{
+    mState = DONE;
+    mFlinger->removeLayer(mLayerOrientationAnim);
+    mLayerOrientationAnim = NULL;
+    return true;
+}
+
+// ---------------------------------------------------------------------------
+
+}; // namespace android
diff --git a/libs/surfaceflinger/OrientationAnimation.h b/libs/surfaceflinger/OrientationAnimation.h
new file mode 100644
index 0000000..ba33fce
--- /dev/null
+++ b/libs/surfaceflinger/OrientationAnimation.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_ORIENTATION_ANIMATION_H
+#define ANDROID_ORIENTATION_ANIMATION_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include "SurfaceFlinger.h"
+
+namespace android {
+
+// ---------------------------------------------------------------------------
+
+class SurfaceFlinger;
+class MemoryDealer;
+class LayerOrientationAnim;
+
+class OrientationAnimation
+{
+public:    
+                 OrientationAnimation(const sp<SurfaceFlinger>& flinger);
+        virtual ~OrientationAnimation();
+
+   void onOrientationChanged();
+   void onAnimationFinished();
+   inline bool run() {
+       if (LIKELY(mState == DONE))
+           return false;
+       return run_impl();
+   }
+
+private:
+    enum {
+        DONE = 0,
+        PREPARE,
+        PHASE1,
+        PHASE2,
+        FINISH
+    };
+
+    bool run_impl();
+    bool done();
+    bool prepare();
+    bool phase1();
+    bool phase2();
+    bool finished();
+
+    sp<SurfaceFlinger> mFlinger;
+    sp<MemoryDealer> mTemporaryDealer;
+    LayerOrientationAnim* mLayerOrientationAnim;
+    int mState;
+};
+
+// ---------------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_ORIENTATION_ANIMATION_H
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 4c719e8..4e457c9 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -52,7 +52,9 @@
 #include "LayerBuffer.h"
 #include "LayerDim.h"
 #include "LayerBitmap.h"
+#include "LayerOrientationAnim.h"
 #include "LayerScreenshot.h"
+#include "OrientationAnimation.h"
 #include "SurfaceFlinger.h"
 #include "RFBServer.h"
 #include "VRamHeap.h"
@@ -224,6 +226,7 @@
 SurfaceFlinger::~SurfaceFlinger()
 {
     glDeleteTextures(1, &mWormholeTexName);
+    delete mOrientationAnimation;
 }
 
 copybit_device_t* SurfaceFlinger::getBlitEngine() const
@@ -447,6 +450,8 @@
      *  We're now ready to accept clients...
      */
 
+    mOrientationAnimation = new OrientationAnimation(this);
+    
     // start CPU gauge display
     if (mDebugCpu)
         mCpuGauge = new CPUGauge(this, ms2ns(500));
@@ -471,8 +476,8 @@
 {
     // wait for something to do
     if (UNLIKELY(isFrozen())) {
-        // wait 2 seconds
-        int err = mSyncObject.wait(ms2ns(3000));
+        // wait 5 seconds
+        int err = mSyncObject.wait(ms2ns(5000));
         if (err != NO_ERROR) {
             if (isFrozen()) {
                 // we timed out and are still frozen
@@ -555,11 +560,8 @@
 
 void SurfaceFlinger::postFramebuffer()
 {
-    if (UNLIKELY(isFrozen())) {
-        // we are not allowed to draw, but pause a bit to make sure
-        // apps don't end up using the whole CPU, if they depend on
-        // surfaceflinger for synchronization.
-        usleep(8333); // 8.3ms ~ 120fps
+    const bool skip = mOrientationAnimation->run();
+    if (UNLIKELY(skip)) {
         return;
     }
 
@@ -684,6 +686,8 @@
 
             mVisibleRegionsDirty = true;
             mDirtyRegion.set(hw.bounds());
+
+            mOrientationAnimation->onOrientationChanged();
         }
 
         if (mCurrentState.freezeDisplay != mDrawingState.freezeDisplay) {
@@ -874,19 +878,9 @@
 
     uint32_t flags = hw.getFlags();
     if (flags & DisplayHardware::BUFFER_PRESERVED) {
-        if (flags & DisplayHardware::COPY_BACK_EXTENSION) {
-            // yay. nothing to do here.
-        } else {
-            if (flags & DisplayHardware::UPDATE_ON_DEMAND) {
-                // we need to fully redraw the part that will be updated
-                mDirtyRegion.set(mInvalidRegion.bounds());
-            } else {
-                // TODO: we only need te redraw the part that had been drawn
-                // the round before and is not drawn now
-            }
-        }
+        // here we assume DisplayHardware::flip()'s  implementation
+        // performs the copy-back optimization.
     } else {
-        // COPY_BACK_EXTENSION makes no sense here
         if (flags & DisplayHardware::UPDATE_ON_DEMAND) {
             // we need to fully redraw the part that will be updated
             mDirtyRegion.set(mInvalidRegion.bounds());
@@ -1076,6 +1070,29 @@
     // XXX: mFPS has the value we want
  }
 
+status_t SurfaceFlinger::addLayer(LayerBase* layer)
+{
+    Mutex::Autolock _l(mStateLock);
+    addLayer_l(layer);
+    setTransactionFlags(eTransactionNeeded|eTraversalNeeded);
+    return NO_ERROR;
+}
+
+status_t SurfaceFlinger::removeLayer(LayerBase* layer)
+{
+    Mutex::Autolock _l(mStateLock);
+    removeLayer_l(layer);
+    setTransactionFlags(eTransactionNeeded);
+    return NO_ERROR;
+}
+
+status_t SurfaceFlinger::invalidateLayerVisibility(LayerBase* layer)
+{
+    layer->forceVisibilityTransaction();
+    setTransactionFlags(eTraversalNeeded);
+    return NO_ERROR;
+}
+
 status_t SurfaceFlinger::addLayer_l(LayerBase* layer)
 {
     ssize_t i = mCurrentState.layersSortedByZ.add(
diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h
index a242f1a..8e5fd88 100644
--- a/libs/surfaceflinger/SurfaceFlinger.h
+++ b/libs/surfaceflinger/SurfaceFlinger.h
@@ -35,11 +35,11 @@
 #include <private/ui/LayerState.h>
 #include <private/ui/SurfaceFlingerSynchro.h>
 
+#include "Barrier.h"
+#include "BootAnimation.h"
+#include "CPUGauge.h"
 #include "Layer.h"
 #include "Tokenizer.h"
-#include "CPUGauge.h"
-#include "BootAnimation.h"
-#include "Barrier.h"
 
 struct copybit_device_t;
 struct overlay_device_t;
@@ -48,16 +48,18 @@
 
 // ---------------------------------------------------------------------------
 
-class BClient;
 class Client;
+class BClient;
 class DisplayHardware;
+class FreezeLock;
 class GPUHardwareInterface;
 class IGPUCallback;
 class Layer;
 class LayerBuffer;
+class LayerOrientationAnim;
+class OrientationAnimation;
 class RFBServer;
 class SurfaceHeapManager;
-class FreezeLock;
 
 typedef int32_t ClientID;
 
@@ -181,7 +183,12 @@
 
             copybit_device_t* getBlitEngine() const;
             overlay_control_device_t* getOverlayEngine() const;
+
             
+    status_t removeLayer(LayerBase* layer);
+    status_t addLayer(LayerBase* layer);
+    status_t invalidateLayerVisibility(LayerBase* layer);
+    
 private:
     friend class BClient;
     friend class LayerBase;
@@ -352,6 +359,8 @@
                 bool                        mFreezeDisplay;
                 int32_t                     mFreezeCount;
                 nsecs_t                     mFreezeDisplayTime;
+                friend class OrientationAnimation;
+                OrientationAnimation*       mOrientationAnimation;
 
                 // access protected by mDebugLock
     mutable     Mutex                       mDebugLock;
diff --git a/libs/surfaceflinger/VRamHeap.cpp b/libs/surfaceflinger/VRamHeap.cpp
index 77bc576..0ccd71f 100644
--- a/libs/surfaceflinger/VRamHeap.cpp
+++ b/libs/surfaceflinger/VRamHeap.cpp
@@ -35,8 +35,6 @@
 #include <utils/MemoryHeapPmem.h>
 #include <utils/MemoryHeapBase.h>
 
-#include <GLES/eglnatives.h>
-
 #include "GPUHardware/GPUHardware.h"
 #include "SurfaceFlinger.h"
 #include "VRamHeap.h"
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index 50c6008..6c60b85 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -84,8 +84,10 @@
     mRawCallbackCookie = 0;
     mJpegCallback = 0;
     mJpegCallbackCookie = 0;
-    mFrameCallback = 0;
-    mFrameCallbackCookie = 0;
+    mPreviewCallback = 0;
+    mPreviewCallbackCookie = 0;
+    mRecordingCallback = 0;
+    mRecordingCallbackCookie = 0;
     mErrorCallback = 0;
     mErrorCallbackCookie = 0;
     mAutoFocusCallback = 0;
@@ -184,6 +186,15 @@
     return c->startPreview();
 }
 
+// start recording mode, must call setPreviewDisplay first
+status_t Camera::startRecording()
+{
+    LOGV("startRecording");
+    sp <ICamera> c = mCamera;
+    if (c == 0) return NO_INIT;
+    return c->startRecording();
+}
+
 // stop preview mode
 void Camera::stopPreview()
 {
@@ -193,6 +204,24 @@
     c->stopPreview();
 }
 
+// stop recording mode
+void Camera::stopRecording()
+{
+    LOGV("stopRecording");
+    sp <ICamera> c = mCamera;
+    if (c == 0) return;
+    c->stopRecording();
+}
+
+// release a recording frame
+void Camera::releaseRecordingFrame(const sp<IMemory>& mem)
+{
+    LOGV("releaseRecordingFrame");
+    sp <ICamera> c = mCamera;
+    if (c == 0) return;
+    c->releaseRecordingFrame(mem);
+}
+
 // get preview state
 bool Camera::previewEnabled()
 {
@@ -202,6 +231,15 @@
     return c->previewEnabled();
 }
 
+// get recording state
+bool Camera::recordingEnabled()
+{
+    LOGV("recordingEnabled");
+    sp <ICamera> c = mCamera;
+    if (c == 0) return false;
+    return c->recordingEnabled();
+}
+
 status_t Camera::autoFocus()
 {
     LOGV("autoFocus");
@@ -266,14 +304,21 @@
     mJpegCallbackCookie = cookie;
 }
 
-void Camera::setFrameCallback(frame_callback cb, void *cookie, int frame_callback_flag)
+void Camera::setPreviewCallback(frame_callback cb, void *cookie, int flag)
 {
-    LOGV("setFrameCallback");
-    mFrameCallback = cb;
-    mFrameCallbackCookie = cookie;
+    LOGV("setPreviewCallback");
+    mPreviewCallback = cb;
+    mPreviewCallbackCookie = cookie;
     sp <ICamera> c = mCamera;
     if (c == 0) return;
-    mCamera->setFrameCallbackFlag(frame_callback_flag);
+    mCamera->setPreviewCallbackFlag(flag);
+}
+
+void Camera::setRecordingCallback(frame_callback cb, void *cookie)
+{
+    LOGV("setRecordingCallback");
+    mRecordingCallback = cb;
+    mRecordingCallbackCookie = cookie;
 }
 
 void Camera::setErrorCallback(error_callback cb, void *cookie)
@@ -316,12 +361,21 @@
     }
 }
 
-// callback from camera service when video frame is ready
-void Camera::frameCallback(const sp<IMemory>& frame)
+// callback from camera service when preview frame is ready
+void Camera::previewCallback(const sp<IMemory>& frame)
 {
     LOGV("frameCallback");
-    if (mFrameCallback) {
-        mFrameCallback(frame, mFrameCallbackCookie);
+    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);
     }
 }
 
diff --git a/libs/ui/CameraParameters.cpp b/libs/ui/CameraParameters.cpp
index 7ca77bb..6c25836 100644
--- a/libs/ui/CameraParameters.cpp
+++ b/libs/ui/CameraParameters.cpp
@@ -24,6 +24,9 @@
 
 namespace android {
 
+static const char* portrait = "portrait";
+static const char* landscape = "landscape";
+
 CameraParameters::CameraParameters()
                 : mMap()
 {
@@ -182,6 +185,23 @@
     set("preview-format", format);
 }
 
+int CameraParameters::getOrientation() const
+{
+    const char* orientation = get("orientation");
+    if (orientation && !strcmp(orientation, portrait))
+        return CAMERA_ORIENTATION_PORTRAIT;
+    return CAMERA_ORIENTATION_LANDSCAPE;
+}
+
+void CameraParameters::setOrientation(int orientation)
+{
+    if (orientation == CAMERA_ORIENTATION_PORTRAIT) {
+        set("preview-format", portrait);
+    } else {
+        set("preview-format", landscape);
+    }
+}
+
 const char *CameraParameters::getPreviewFormat() const
 {
     return get("preview-format");
diff --git a/libs/ui/EGLDisplaySurface.cpp b/libs/ui/EGLDisplaySurface.cpp
index 44258a8..d06c98b 100644
--- a/libs/ui/EGLDisplaySurface.cpp
+++ b/libs/ui/EGLDisplaySurface.cpp
@@ -42,7 +42,7 @@
 #include <linux/msm_mdp.h>
 #endif
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
 
 #include <pixelflinger/format.h>
 
@@ -71,8 +71,6 @@
     egl_native_window_t::incRef = &EGLDisplaySurface::hook_incRef;
     egl_native_window_t::decRef = &EGLDisplaySurface::hook_decRef;
     egl_native_window_t::swapBuffers = &EGLDisplaySurface::hook_swapBuffers;
-    egl_native_window_t::setSwapRectangle = &EGLDisplaySurface::hook_setSwapRectangle;
-    egl_native_window_t::nextBuffer = &EGLDisplaySurface::hook_nextBuffer;
     egl_native_window_t::connect = 0;
     egl_native_window_t::disconnect = 0;
 
@@ -136,15 +134,6 @@
     EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
     return that->swapBuffers();
 }
-uint32_t EGLDisplaySurface::hook_nextBuffer(NativeWindowType window) {
-    EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
-    return that->nextBuffer();
-}
-void EGLDisplaySurface::hook_setSwapRectangle(NativeWindowType window,
-        int l, int t, int w, int h) {
-    EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
-    that->setSwapRectangle(l, t, w, h);
-}
 
 void EGLDisplaySurface::setSwapRectangle(int l, int t, int w, int h)
 {
@@ -249,15 +238,6 @@
     return mPageFlipCount;
 }
 
-uint32_t EGLDisplaySurface::nextBuffer()
-{
-    // update the address of the buffer to draw to next
-    const GGLSurface& buffer = mFb[mIndex];
-    egl_native_window_t::offset =
-        intptr_t(buffer.data) - egl_native_window_t::base;
-    return 0;
-}
-
 void EGLDisplaySurface::copyFrontToBack(const Region& copyback)
 {
 #if HAVE_ANDROID_OS
@@ -318,6 +298,59 @@
     }
 }
 
+void EGLDisplaySurface::copyFrontToImage(const copybit_image_t& dst)
+{
+#if HAVE_ANDROID_OS
+    if (mBlitEngine) {
+        copybit_image_t src = {
+                w:      egl_native_window_t::stride,
+                h:      egl_native_window_t::height,
+                format: egl_native_window_t::format,
+                offset: mFb[mIndex].data - mFb[0].data,
+                base:   (void*)egl_native_window_t::base,
+                fd:     egl_native_window_t::fd
+        };
+        region_iterator it(Region(Rect(
+                egl_native_window_t::width, egl_native_window_t::height)));
+        mBlitEngine->blit(mBlitEngine, &dst, &src, &it);
+    } else
+#endif
+    {
+        uint8_t* const screen_src = mFb[  mIndex].data;
+        const size_t bpp = bytesPerPixel(egl_native_window_t::format);
+        const size_t bpr = egl_native_window_t::stride * bpp;
+        memcpy((char*)dst.base + dst.offset, screen_src,
+                bpr*egl_native_window_t::height);
+    }
+}
+
+void EGLDisplaySurface::copyBackToImage(const copybit_image_t& dst)
+{
+#if HAVE_ANDROID_OS
+    if (mBlitEngine) {
+        copybit_image_t src = {
+                w:      egl_native_window_t::stride,
+                h:      egl_native_window_t::height,
+                format: egl_native_window_t::format,
+                offset: mFb[1-mIndex].data - mFb[0].data,
+                base:   (void*)egl_native_window_t::base,
+                fd:     egl_native_window_t::fd
+        };
+        region_iterator it(Region(Rect(
+                egl_native_window_t::width, egl_native_window_t::height)));
+        mBlitEngine->blit(mBlitEngine, &dst, &src, &it);
+    } else
+#endif
+    {
+        uint8_t* const screen_src = mFb[1-mIndex].data;
+        const size_t bpp = bytesPerPixel(egl_native_window_t::format);
+        const size_t bpr = egl_native_window_t::stride * bpp;
+        memcpy((char*)dst.base + dst.offset, screen_src,
+                bpr*egl_native_window_t::height);
+    }
+}
+
+
 status_t EGLDisplaySurface::mapFrameBuffer()
 {
     char const * const device_template[] = {
diff --git a/libs/ui/EGLNativeWindowSurface.cpp b/libs/ui/EGLNativeWindowSurface.cpp
index d55fb70..f1071cf 100644
--- a/libs/ui/EGLNativeWindowSurface.cpp
+++ b/libs/ui/EGLNativeWindowSurface.cpp
@@ -28,7 +28,7 @@
 #include <ui/DisplayInfo.h>
 #include <ui/Rect.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
 
 #include <pixelflinger/format.h>
 
@@ -48,8 +48,6 @@
     egl_native_window_t::incRef = &EGLNativeWindowSurface::hook_incRef;
     egl_native_window_t::decRef = &EGLNativeWindowSurface::hook_decRef;
     egl_native_window_t::swapBuffers = &EGLNativeWindowSurface::hook_swapBuffers;
-    egl_native_window_t::nextBuffer = &EGLNativeWindowSurface::hook_nextBuffer;
-    egl_native_window_t::setSwapRectangle = &EGLNativeWindowSurface::hook_setSwapRectangle;
     egl_native_window_t::connect = &EGLNativeWindowSurface::hook_connect;
     egl_native_window_t::disconnect = &EGLNativeWindowSurface::hook_disconnect;
     
@@ -98,18 +96,6 @@
     return that->swapBuffers();
 }
 
-uint32_t EGLNativeWindowSurface::hook_nextBuffer(NativeWindowType window)
-{
-    EGLNativeWindowSurface* that = static_cast<EGLNativeWindowSurface*>(window);
-    return that->nextBuffer();
-}
-
-void EGLNativeWindowSurface::hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h)
-{
-    EGLNativeWindowSurface* that = static_cast<EGLNativeWindowSurface*>(window);
-    that->setSwapRectangle(l, t, w, h);
-}
-
 void EGLNativeWindowSurface::setSwapRectangle(int l, int t, int w, int h)
 {
     mSurface->setSwapRectangle(Rect(l, t, l+w, t+h));
@@ -138,17 +124,6 @@
     return 0;
 }
 
-uint32_t EGLNativeWindowSurface::nextBuffer()
-{
-    const sp<Surface>& surface(mSurface);
-    Surface::SurfaceInfo info;
-    surface->nextBuffer(&info);
-    // update the address of the buffer to draw to next
-    egl_native_window_t::base   = intptr_t(info.base);
-    egl_native_window_t::offset = intptr_t(info.bits) - intptr_t(info.base);
-    return 0;
-}
-
 void EGLNativeWindowSurface::connect()
 {   
     if (!mConnected) {
diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp
index 700aa3a..3b29b09 100644
--- a/libs/ui/EventHub.cpp
+++ b/libs/ui/EventHub.cpp
@@ -71,10 +71,11 @@
 
 EventHub::device_t::device_t(int32_t _id, const char* _path)
     : id(_id), path(_path), classes(0)
-    , layoutMap(new KeyLayoutMap()), next(NULL) {
+    , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), next(NULL) {
 }
 
 EventHub::device_t::~device_t() {
+    delete [] keyBitmask;
     delete layoutMap;
 }
 
@@ -403,6 +404,36 @@
     return true;
 }
 
+/*
+ * Inspect the known devices to determine whether physical keys exist for the given
+ * framework-domain key codes.
+ */
+bool EventHub::hasKeys(size_t numCodes, int32_t* keyCodes, uint8_t* outFlags) {
+    for (size_t codeIndex = 0; codeIndex < numCodes; codeIndex++) {
+        outFlags[codeIndex] = 0;
+
+        // check each available hardware device for support for this keycode
+        Vector<int32_t> scanCodes;
+        for (int n = 0; (n < mFDCount) && (outFlags[codeIndex] == 0); n++) {
+            if (mDevices[n]) {
+                status_t err = mDevices[n]->layoutMap->findScancodes(keyCodes[codeIndex], &scanCodes);
+                if (!err) {
+                    // check the possible scan codes identified by the layout map against the
+                    // map of codes actually emitted by the driver
+                    for (size_t sc = 0; sc < scanCodes.size(); sc++) {
+                        if (test_bit(scanCodes[sc], mDevices[n]->keyBitmask)) {
+                            outFlags[codeIndex] = 1;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    return true;
+}
+
 // ----------------------------------------------------------------------------
 
 int EventHub::open_device(const char *deviceName)
@@ -527,6 +558,16 @@
                 break;
             }
         }
+        if ((device->classes & CLASS_KEYBOARD) != 0) {
+            device->keyBitmask = new uint8_t[(KEY_MAX+1)/8];
+            if (device->keyBitmask != NULL) {
+                memcpy(device->keyBitmask, key_bitmask, sizeof(key_bitmask));
+            } else {
+                delete device;
+                LOGE("out of memory allocating key bitmask");
+                return -1;
+            }
+        }
     }
     if (test_bit(BTN_MOUSE, key_bitmask)) {
         uint8_t rel_bitmask[(REL_MAX+1)/8];
diff --git a/libs/ui/ICamera.cpp b/libs/ui/ICamera.cpp
index 7b0922e..ab0fef1 100644
--- a/libs/ui/ICamera.cpp
+++ b/libs/ui/ICamera.cpp
@@ -28,7 +28,7 @@
 enum {
     DISCONNECT = IBinder::FIRST_CALL_TRANSACTION,
     SET_PREVIEW_DISPLAY,
-    SET_FRAME_CALLBACK_FLAG,
+    SET_PREVIEW_CALLBACK_FLAG,
     START_PREVIEW,
     STOP_PREVIEW,
     AUTO_FOCUS,
@@ -38,7 +38,11 @@
     CONNECT,
     LOCK,
     UNLOCK,
-    PREVIEW_ENABLED
+    PREVIEW_ENABLED,
+    START_RECORDING,
+    STOP_RECORDING,
+    RECORDING_ENABLED,
+    RELEASE_RECORDING_FRAME,
 };
 
 class BpCamera: public BpInterface<ICamera>
@@ -69,15 +73,15 @@
         return reply.readInt32();
     }
 
-    // set the frame callback flag to affect how the received frames from
-    // preview are handled.
-    void setFrameCallbackFlag(int frame_callback_flag)
+    // set the preview callback flag to affect how the received frames from
+    // preview are handled. See Camera.h for details.
+    void setPreviewCallbackFlag(int flag)
     {
-        LOGV("setFrameCallbackFlag(%d)", frame_callback_flag);
+        LOGV("setPreviewCallbackFlag(%d)", flag);
         Parcel data, reply;
         data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
-        data.writeInt32(frame_callback_flag);
-        remote()->transact(SET_FRAME_CALLBACK_FLAG, data, &reply);
+        data.writeInt32(flag);
+        remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply);
     }
 
     // start preview mode, must call setPreviewDisplay first
@@ -90,6 +94,16 @@
         return reply.readInt32();
     }
 
+    // start recording mode, must call setPreviewDisplay first
+    status_t startRecording()
+    {
+        LOGV("startRecording");
+        Parcel data, reply;
+        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
+        remote()->transact(START_RECORDING, data, &reply);
+        return reply.readInt32();
+    }
+
     // stop preview mode
     void stopPreview()
     {
@@ -99,6 +113,24 @@
         remote()->transact(STOP_PREVIEW, data, &reply);
     }
 
+    // stop recording mode
+    void stopRecording()
+    {
+        LOGV("stopRecording");
+        Parcel data, reply;
+        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
+        remote()->transact(STOP_RECORDING, data, &reply);
+    }
+
+    void releaseRecordingFrame(const sp<IMemory>& mem)
+    {
+        LOGV("releaseRecordingFrame");
+        Parcel data, reply;
+        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
+        data.writeStrongBinder(mem->asBinder());
+        remote()->transact(RELEASE_RECORDING_FRAME, data, &reply);
+    }
+
     // check preview state
     bool previewEnabled()
     {
@@ -109,6 +141,16 @@
         return reply.readInt32();
     }
 
+    // check recording state
+    bool recordingEnabled()
+    {
+        LOGV("recordingEnabled");
+        Parcel data, reply;
+        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
+        remote()->transact(RECORDING_ENABLED, data, &reply);
+        return reply.readInt32();
+    }
+
     // auto focus
     status_t autoFocus()
     {
@@ -202,11 +244,11 @@
             reply->writeInt32(setPreviewDisplay(surface));
             return NO_ERROR;
         } break;
-        case SET_FRAME_CALLBACK_FLAG: {
-            LOGV("SET_FRAME_CALLBACK_TYPE");
+        case SET_PREVIEW_CALLBACK_FLAG: {
+            LOGV("SET_PREVIEW_CALLBACK_TYPE");
             CHECK_INTERFACE(ICamera, data, reply);
-            int frame_callback_flag = data.readInt32();
-            setFrameCallbackFlag(frame_callback_flag);
+            int callback_flag = data.readInt32();
+            setPreviewCallbackFlag(callback_flag);
             return NO_ERROR;
         } break;
         case START_PREVIEW: {
@@ -215,18 +257,43 @@
             reply->writeInt32(startPreview());
             return NO_ERROR;
         } break;
+        case START_RECORDING: {
+            LOGV("START_RECORDING");
+            CHECK_INTERFACE(ICamera, data, reply);
+            reply->writeInt32(startRecording());
+            return NO_ERROR;
+        } break;
         case STOP_PREVIEW: {
             LOGV("STOP_PREVIEW");
             CHECK_INTERFACE(ICamera, data, reply);
             stopPreview();
             return NO_ERROR;
         } break;
+        case STOP_RECORDING: {
+            LOGV("STOP_RECORDING");
+            CHECK_INTERFACE(ICamera, data, reply);
+            stopRecording();
+            return NO_ERROR;
+        } break;
+        case RELEASE_RECORDING_FRAME: {
+            LOGV("RELEASE_RECORDING_FRAME");
+            CHECK_INTERFACE(ICamera, data, reply);
+            sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
+            releaseRecordingFrame(mem);
+            return NO_ERROR;
+        } break;
         case PREVIEW_ENABLED: {
             LOGV("PREVIEW_ENABLED");
             CHECK_INTERFACE(ICamera, data, reply);
             reply->writeInt32(previewEnabled());
             return NO_ERROR;
         } break;
+        case RECORDING_ENABLED: {
+            LOGV("RECORDING_ENABLED");
+            CHECK_INTERFACE(ICamera, data, reply);
+            reply->writeInt32(recordingEnabled());
+            return NO_ERROR;
+        } break;
         case AUTO_FOCUS: {
             LOGV("AUTO_FOCUS");
             CHECK_INTERFACE(ICamera, data, reply);
diff --git a/libs/ui/ICameraClient.cpp b/libs/ui/ICameraClient.cpp
index c5d6d52..4bec9d2 100644
--- a/libs/ui/ICameraClient.cpp
+++ b/libs/ui/ICameraClient.cpp
@@ -28,9 +28,10 @@
     SHUTTER_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
     RAW_CALLBACK,
     JPEG_CALLBACK,
-    FRAME_CALLBACK,
+    PREVIEW_CALLBACK,
     ERROR_CALLBACK,
-    AUTOFOCUS_CALLBACK
+    AUTOFOCUS_CALLBACK,
+    RECORDING_CALLBACK,
 };
 
 class BpCameraClient: public BpInterface<ICameraClient>
@@ -70,14 +71,24 @@
         remote()->transact(JPEG_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
     }
 
-    // callback from camera service to app with video frame data
-    void frameCallback(const sp<IMemory>& frame)
+    // callback from camera service to app with preview frame data
+    void previewCallback(const sp<IMemory>& frame)
     {
-        LOGV("frameCallback");
+        LOGV("previewCallback");
         Parcel data, reply;
         data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
         data.writeStrongBinder(frame->asBinder());
-        remote()->transact(FRAME_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
+        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
@@ -135,11 +146,18 @@
             jpegCallback(picture);
             return NO_ERROR;
         } break;
-        case FRAME_CALLBACK: {
-            LOGV("FRAME_CALLBACK");
+        case PREVIEW_CALLBACK: {
+            LOGV("PREVIEW_CALLBACK");
             CHECK_INTERFACE(ICameraClient, data, reply);
             sp<IMemory> frame = interface_cast<IMemory>(data.readStrongBinder());
-            frameCallback(frame);
+            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: {
diff --git a/libs/ui/ISurface.cpp b/libs/ui/ISurface.cpp
index 6f3cd47..abd3634 100644
--- a/libs/ui/ISurface.cpp
+++ b/libs/ui/ISurface.cpp
@@ -27,12 +27,33 @@
 
 namespace android {
 
-enum {
-    REGISTER_BUFFERS = IBinder::FIRST_CALL_TRANSACTION,
-    UNREGISTER_BUFFERS,
-    POST_BUFFER, // one-way transaction
-    CREATE_OVERLAY,
-};
+ISurface::BufferHeap::BufferHeap() 
+    : w(0), h(0), hor_stride(0), ver_stride(0), format(0),
+    transform(0), flags(0) 
+{     
+}
+
+ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h,
+        int32_t hor_stride, int32_t ver_stride,
+        PixelFormat format, const sp<IMemoryHeap>& heap)
+    : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride),
+      format(format), heap(heap) 
+{
+}
+
+ISurface::BufferHeap::BufferHeap(uint32_t w, uint32_t h,
+        int32_t hor_stride, int32_t ver_stride,
+        PixelFormat format, uint32_t transform, uint32_t flags,
+        const sp<IMemoryHeap>& heap)
+        : w(w), h(h), hor_stride(hor_stride), ver_stride(ver_stride),
+          format(format), transform(transform), flags(flags), heap(heap) 
+{
+}
+
+
+ISurface::BufferHeap::~BufferHeap() 
+{     
+}
 
 class BpSurface : public BpInterface<ISurface>
 {
@@ -42,17 +63,18 @@
     {
     }
 
-    virtual status_t registerBuffers(int w, int h, int hstride, int vstride,
-            PixelFormat format, const sp<IMemoryHeap>& heap)
+    virtual status_t registerBuffers(const BufferHeap& buffers)
     {
         Parcel data, reply;
         data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
-        data.writeInt32(w);
-        data.writeInt32(h);
-        data.writeInt32(hstride);
-        data.writeInt32(vstride);
-        data.writeInt32(format);
-        data.writeStrongBinder(heap->asBinder());
+        data.writeInt32(buffers.w);
+        data.writeInt32(buffers.h);
+        data.writeInt32(buffers.hor_stride);
+        data.writeInt32(buffers.ver_stride);
+        data.writeInt32(buffers.format);
+        data.writeInt32(buffers.transform);
+        data.writeInt32(buffers.flags);
+        data.writeStrongBinder(buffers.heap->asBinder());
         remote()->transact(REGISTER_BUFFERS, data, &reply);
         status_t result = reply.readInt32();
         return result;
@@ -102,13 +124,16 @@
     switch(code) {
         case REGISTER_BUFFERS: {
             CHECK_INTERFACE(ISurface, data, reply);
-            int w = data.readInt32();
-            int h = data.readInt32();
-            int hs= data.readInt32();
-            int vs= data.readInt32();
-            PixelFormat f = data.readInt32();
-            sp<IMemoryHeap> heap(interface_cast<IMemoryHeap>(data.readStrongBinder()));
-            status_t err = registerBuffers(w,h,hs,vs,f,heap);
+            BufferHeap buffer;
+            buffer.w = data.readInt32();
+            buffer.h = data.readInt32();
+            buffer.hor_stride = data.readInt32();
+            buffer.ver_stride= data.readInt32();
+            buffer.format = data.readInt32();
+            buffer.transform = data.readInt32();
+            buffer.flags = data.readInt32();
+            buffer.heap = interface_cast<IMemoryHeap>(data.readStrongBinder());
+            status_t err = registerBuffers(buffer);
             reply->writeInt32(err);
             return NO_ERROR;
         } break;
diff --git a/libs/ui/Overlay.cpp b/libs/ui/Overlay.cpp
index c8e61689..b236edc 100644
--- a/libs/ui/Overlay.cpp
+++ b/libs/ui/Overlay.cpp
@@ -59,6 +59,12 @@
     return mOverlayData->queueBuffer(mOverlayData, buffer);
 }
 
+int32_t Overlay::getBufferCount() const
+{
+    if (mStatus != NO_ERROR) return mStatus;
+    return mOverlayData->getBufferCount(mOverlayData);
+}
+
 void* Overlay::getBufferAddress(overlay_buffer_t buffer)
 {
     if (mStatus != NO_ERROR) return NULL;
diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp
index 605c8ae..b65ed97 100644
--- a/libs/ui/PixelFormat.cpp
+++ b/libs/ui/PixelFormat.cpp
@@ -19,6 +19,18 @@
 
 namespace android {
 
+size_t PixelFormatInfo::getScanlineSize(unsigned int width) const
+{
+    size_t size;
+    if ((components >= 6) && (components <= 8)) {
+        // YCbCr formats are differents.
+        size = (width * bitsPerPixel)>>3;
+    } else {
+        size = width * bytesPerPixel;
+    }
+    return size;
+}
+
 ssize_t bytesPerPixel(PixelFormat format)
 {
     PixelFormatInfo info;
@@ -47,7 +59,25 @@
     if (!valid) {
         return BAD_INDEX;
     }
-
+    
+    #define COMPONENT(name) \ 
+        case GGL_##name: info->components = PixelFormatInfo::name; break;
+    
+    switch (i->components) {
+        COMPONENT(ALPHA)
+        COMPONENT(RGB)
+        COMPONENT(RGBA)
+        COMPONENT(LUMINANCE)
+        COMPONENT(LUMINANCE_ALPHA)
+        COMPONENT(Y_CB_CR_SP)
+        COMPONENT(Y_CB_CR_P)
+        COMPONENT(Y_CB_CR_I)
+        default:
+            return BAD_INDEX;
+    }
+    
+    #undef COMPONENT
+    
     info->format = format;
     info->bytesPerPixel = i->size;
     info->bitsPerPixel  = i->bitsPerPixel;
@@ -59,6 +89,7 @@
     info->l_green       = i->gl;
     info->h_blue        = i->bh;
     info->l_blue        = i->bl;
+
     return NO_ERROR;
 }
 
diff --git a/libs/utils/Parcel.cpp b/libs/utils/Parcel.cpp
index 0eba0b0..0f4b647 100644
--- a/libs/utils/Parcel.cpp
+++ b/libs/utils/Parcel.cpp
@@ -658,15 +658,20 @@
     status_t err;
     err = writeInt32(handle.numFds);
     if (err != NO_ERROR) return err;
-    
+
     err = writeInt32(handle.numInts);
     if (err != NO_ERROR) return err;
-    
+
     for (int i=0 ; err==NO_ERROR && i<handle.numFds ; i++)
         err = writeDupFileDescriptor(handle.data[i]);
-    
+
+    if (err != NO_ERROR) {
+        LOGD("write native handle, write dup fd failed");
+        return err;
+    }
+
     err = write(handle.data + handle.numFds, sizeof(int)*handle.numInts);
-    
+
     return err;
 }
 
@@ -947,7 +952,7 @@
     }
     
     for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
-        h->data[i] = readFileDescriptor();
+        h->data[i] = dup(readFileDescriptor());
         if (h->data[i] < 0) err = BAD_VALUE;
     }
     
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 5a09fb4..71e7cd7 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -1736,7 +1736,7 @@
 }
 
 ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag,
-        uint32_t* outSpecFlags) const
+        uint32_t* outSpecFlags, ResTable_config* outConfig) const
 {
     if (mError != NO_ERROR) {
         return mError;
@@ -1809,7 +1809,7 @@
             (const Res_value*)(((const uint8_t*)type) + offset);
         ResTable_config thisConfig;
         thisConfig.copyFromDtoH(type->config);
-        
+
         if (outSpecFlags != NULL) {
             if (typeClass->typeSpecFlags != NULL) {
                 *outSpecFlags |= dtohl(typeClass->typeSpecFlags[e]);
@@ -1834,6 +1834,9 @@
         outValue->res0 = bestValue->res0;
         outValue->dataType = bestValue->dataType;
         outValue->data = dtohl(bestValue->data);
+        if (outConfig != NULL) {
+            *outConfig = bestItem;
+        }
         TABLE_NOISY(size_t len;
               printf("Found value: pkg=%d, type=%d, str=%s, int=%d\n",
                      bestPackage->header->index,
@@ -3484,7 +3487,7 @@
         
         ResTable_config thisConfig;
         thisConfig.copyFromDtoH(thisType->config);
-        
+
         TABLE_GETENTRY(LOGI("Match entry 0x%x in type 0x%x (sz 0x%x): imsi:%d/%d=%d/%d lang:%c%c=%c%c cnt:%c%c=%c%c "
                             "orien:%d=%d touch:%d=%d density:%d=%d key:%d=%d inp:%d=%d nav:%d=%d w:%d=%d h:%d=%d\n",
                            entryIndex, typeIndex+1, dtohl(thisType->config.size),
diff --git a/libs/utils/String8.cpp b/libs/utils/String8.cpp
index ab843f6..c50d343 100644
--- a/libs/utils/String8.cpp
+++ b/libs/utils/String8.cpp
@@ -317,8 +317,10 @@
         ->editResize(myLen+otherLen+1);
     if (buf) {
         char* str = (char*)buf->data();
-        memcpy(str+myLen, other, otherLen+1);
         mString = str;
+        str += myLen;
+        memcpy(str, other, otherLen);
+        str[otherLen] = '\0';
         return NO_ERROR;
     }
     return NO_MEMORY;
diff --git a/location/java/com/android/internal/location/GpsLocationProvider.java b/location/java/com/android/internal/location/GpsLocationProvider.java
index c6f13c9..6672e29 100644
--- a/location/java/com/android/internal/location/GpsLocationProvider.java
+++ b/location/java/com/android/internal/location/GpsLocationProvider.java
@@ -164,16 +164,15 @@
     // current setting - 5 minutes
     private static final long RETRY_INTERVAL = 5*60*1000; 
 
-    private LocationCollector mCollector;
+    private ILocationCollector mCollector;
 
     public static boolean isSupported() {
         return native_is_supported();
     }
 
-    public GpsLocationProvider(Context context, LocationCollector collector) {
+    public GpsLocationProvider(Context context) {
         super(LocationManager.GPS_PROVIDER);
         mContext = context;
-        mCollector = collector;
 
         mProperties = new Properties();
         try {
@@ -183,10 +182,14 @@
             stream.close();
             mNtpServer = mProperties.getProperty("NTP_SERVER", null);
         } catch (IOException e) {
-            Log.e(TAG, "Could not open GPS configuration file " + PROPERTIES_FILE, e);
+            Log.w(TAG, "Could not open GPS configuration file " + PROPERTIES_FILE);
         }
     }
 
+    public void setLocationCollector(ILocationCollector collector) {
+        mCollector = collector;
+    }
+
     /**
      * Returns true if the provider requires access to a
      * data network (e.g., the Internet), false otherwise.
@@ -623,7 +626,8 @@
             }
 
             // Send to collector
-            if ((flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG) {
+            if ((flags & LOCATION_HAS_LAT_LONG) == LOCATION_HAS_LAT_LONG
+                    && mCollector != null) {
                 mCollector.updateLocation(mLocation);
             }
         }
@@ -644,7 +648,7 @@
         if (Config.LOGV) Log.v(TAG, "reportStatus status: " + status);
 
         boolean wasNavigating = mNavigating;
-        mNavigating = (status == GPS_STATUS_SESSION_BEGIN || status == GPS_STATUS_ENGINE_ON);
+        mNavigating = (status == GPS_STATUS_SESSION_BEGIN);
 
         if (wasNavigating != mNavigating) {
             synchronized(mListeners) {
diff --git a/location/java/com/android/internal/location/ILocationCollector.java b/location/java/com/android/internal/location/ILocationCollector.java
new file mode 100644
index 0000000..8a7cdcc
--- /dev/null
+++ b/location/java/com/android/internal/location/ILocationCollector.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.location;
+
+import android.location.Location;
+import android.net.wifi.ScanResult;
+
+import com.android.internal.location.CellState;
+
+import java.util.List;
+
+/**
+ * Listens for GPS and cell/wifi changes and anonymously uploads to server for
+ * improving quality of service of NetworkLocationProvider. This service is only enabled when
+ * the user has enabled the network location provider.
+ *
+ * {@hide}
+ */
+public interface ILocationCollector {
+    /**
+     * Updates GPS location if collection is enabled
+     *
+     * @param location location object
+     */
+    abstract public void updateLocation(Location location);
+
+    /**
+     * Updates wifi scan results if collection is enabled
+     *
+     * @param currentScanResults scan results
+     */
+    abstract public void updateWifiScanResults(List<ScanResult> currentScanResults);
+
+    /**
+     * Updates the status of the network location provider.
+     *
+     * @param enabled true if user has enabled network location based on Google's database
+     * of wifi points and cell towers.
+     */
+    abstract public void updateNetworkProviderStatus(boolean enabled);
+
+    /**
+     * Updates cell tower state. This is usually always up to date so should be uploaded
+     * each time a new location is available.
+     *
+     * @param newState cell state
+     */
+    abstract public void updateCellState(CellState newState);
+
+    /**
+     * Updates the battery health. Battery level is healthy if there is greater than
+     * {@link #MIN_BATTERY_LEVEL} percentage left or if the device is plugged in
+     *
+     * @param scale maximum scale for battery
+     * @param level current level
+     * @param plugged true if device is plugged in
+     */
+    abstract public void updateBatteryState(int scale, int level, boolean plugged);
+}
diff --git a/location/java/com/android/internal/location/INetworkLocationManager.java b/location/java/com/android/internal/location/INetworkLocationManager.java
new file mode 100644
index 0000000..83bbe1f
--- /dev/null
+++ b/location/java/com/android/internal/location/INetworkLocationManager.java
@@ -0,0 +1,28 @@
+ /*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.location;
+
+/**
+ * Used to register network location and collection services 
+ * with the Location Manager Service.
+ *
+ * {@hide}
+ */
+public interface INetworkLocationManager {
+    void setNetworkLocationProvider(INetworkLocationProvider provider);
+    void setLocationCollector(ILocationCollector collector);
+}
\ No newline at end of file
diff --git a/location/java/com/android/internal/location/INetworkLocationProvider.java b/location/java/com/android/internal/location/INetworkLocationProvider.java
new file mode 100644
index 0000000..730cb48
--- /dev/null
+++ b/location/java/com/android/internal/location/INetworkLocationProvider.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.location;
+
+import android.location.Address;
+import android.location.Location;
+import android.net.wifi.ScanResult;
+
+import com.google.common.io.protocol.ProtoBuf;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Interface for network location provider
+ *
+ * {@hide}
+ */
+public interface INetworkLocationProvider {
+
+    public interface Callback {
+
+        /**
+         * Callback function to notify of a received network location
+         *
+         * @param location location object that is received. may be null if not a valid location
+         * @param successful true if network query was successful, even if no location was found
+         */
+        void locationReceived(Location location, boolean successful);
+    }
+
+    /**
+     * Updates the current cell lock status.
+     *
+     * @param acquired true if a cell lock has been acquired
+     */
+    abstract public void updateCellLockStatus(boolean acquired);
+
+    /**
+     * Notifies the provider if Wifi has been enabled or disabled
+     * by the user
+     *
+     * @param enabled true if wifi is enabled; false otherwise
+     */
+    abstract public void updateWifiEnabledState(boolean enabled);
+
+    /**
+     * Notifies the provider that there are scan results available.
+     *
+     * @param scanResults list of wifi scan results
+     */
+    abstract public void updateWifiScanResults(List<ScanResult> scanResults);
+
+    /**
+     * Adds a list of application clients
+     * Only used by the NetworkLocationProvider
+     *
+     * @param applications list of package names
+     */
+    abstract public void addListener(String[] applications);
+
+    /**
+     * Removes a list of application clients
+     * Only used by the NetworkLocationProvider
+     *
+     * @param applications list of package names
+     */
+    abstract public void removeListener(String[] applications);
+
+
+    abstract public String getFromLocation(double latitude, double longitude, int maxResults,
+        String language, String country, String variant, String appName, List<Address> addrs);
+
+    abstract public String getFromLocationName(String locationName,
+        double lowerLeftLatitude, double lowerLeftLongitude,
+        double upperRightLatitude, double upperRightLongitude, int maxResults,
+        String language, String country, String variant, String appName, List<Address> addrs);
+
+}
diff --git a/location/java/com/android/internal/location/LocationCache.java b/location/java/com/android/internal/location/LocationCache.java
deleted file mode 100644
index 079c9c7..0000000
--- a/location/java/com/android/internal/location/LocationCache.java
+++ /dev/null
@@ -1,608 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.android.internal.location;
-
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import android.location.Location;
-import android.location.LocationManager;
-import android.net.wifi.ScanResult;
-import android.os.Bundle;
-import android.util.Log;
-
-/**
- * Data store to cache cell-id and wifi locations from the network
- *
- * {@hide}
- */
-public class LocationCache {
-    private static final String TAG = "LocationCache";
-
-    // Version of cell cache
-    private static final int CACHE_DB_VERSION = 1;
-
-    // Don't save cache more than once every minute
-    private static final long SAVE_FREQUENCY = 60 * 1000;
-
-    // Location of the cache file;
-    private static final String mCellCacheFile = "cache.cell";
-    private static final String mWifiCacheFile = "cache.wifi";
-
-    // Maximum time (in millis) that a record is valid for, before it needs
-    // to be refreshed from the server.
-    private static final long MAX_CELL_REFRESH_RECORD_AGE = 12 * 60 * 60 * 1000; // 12 hours
-    private static final long MAX_WIFI_REFRESH_RECORD_AGE = 48 * 60 * 60 * 1000; // 48 hours
-
-    // Cache sizes
-    private static final int MAX_CELL_RECORDS = 50;
-    private static final int MAX_WIFI_RECORDS = 200;
-
-    // Cache constants
-    private static final long CELL_SMOOTHING_WINDOW = 30 * 1000; // 30 seconds
-    private static final int WIFI_MIN_AP_REQUIRED = 2;
-    private static final int WIFI_MAX_MISS_ALLOWED = 5;
-    private static final int MAX_ACCURACY_ALLOWED = 5000; // 5km
-
-    // Caches
-    private final Cache<Record> mCellCache;
-    private final Cache<Record> mWifiCache;
-
-    // Currently calculated centroids
-    private final LocationCentroid mCellCentroid = new LocationCentroid();
-    private final LocationCentroid mWifiCentroid = new LocationCentroid();
-
-    // Extra key and values
-    private final String EXTRA_KEY_LOCATION_TYPE = "networkLocationType";
-    private final String EXTRA_VALUE_LOCATION_TYPE_CELL = "cell";
-    private final String EXTRA_VALUE_LOCATION_TYPE_WIFI = "wifi";
-
-    public LocationCache() {
-        mCellCache = new Cache<Record>(LocationManager.SYSTEM_DIR, mCellCacheFile,
-            MAX_CELL_RECORDS, MAX_CELL_REFRESH_RECORD_AGE);
-        mWifiCache = new Cache<Record>(LocationManager.SYSTEM_DIR, mWifiCacheFile,
-            MAX_WIFI_RECORDS, MAX_WIFI_REFRESH_RECORD_AGE);
-    }
-
-    /**
-     * Looks up network location on device cache
-     *
-     * @param cellState primary cell state
-     * @param cellHistory history of cell states
-     * @param scanResults wifi scan results
-     * @param result location object to fill if location is found
-     * @return true if cache was able to answer query (successfully or not), false if call to
-     * server is required
-     */
-    public synchronized boolean lookup(CellState cellState, List<CellState> cellHistory,
-        List<ScanResult> scanResults, Location result) {
-
-        if (Log.isLoggable(TAG, Log.VERBOSE)) {
-            Log.d(TAG, "including cell:" + (cellState != null) +
-                ", wifi:" + ((scanResults != null)? scanResults.size() : "null"));
-        }
-
-        long now = System.currentTimeMillis();
-
-        mCellCentroid.reset();
-        mWifiCentroid.reset();
-
-        if (cellState != null && cellState.isValid()) {
-            String primaryCellKey = getCellCacheKey(cellState.getMcc(), cellState.getMnc(),
-                cellState.getLac(), cellState.getCid());
-            Record record = mCellCache.lookup(primaryCellKey);
-
-            // Relax MCC/MNC condition
-            if (record == null) {
-                primaryCellKey = getCellCacheKey(-1, -1, cellState.getLac(), cellState.getCid());
-                record = mCellCache.lookup(primaryCellKey);
-            }
-
-            if (record == null) {
-                // Make a server request if primary cell doesn't exist in DB
-                return false;
-            }
-
-            if (record.isValid()) {
-                mCellCentroid.addLocation(record.getLat(), record.getLng(), record.getAccuracy(),
-                    record.getConfidence());
-            }
-        }
-
-        if (cellHistory != null) {
-            for (CellState historicalCell : cellHistory) {
-                // Cell location might need to be smoothed if you are on the border of two cells
-                if (now - historicalCell.getTime() < CELL_SMOOTHING_WINDOW) {
-                    String historicalCellKey = getCellCacheKey(historicalCell.getMcc(),
-                        historicalCell.getMnc(), historicalCell.getLac(), historicalCell.getCid());
-                    Record record = mCellCache.lookup(historicalCellKey);
-
-                    // Relax MCC/MNC condition
-                    if (record == null) {
-                        historicalCellKey = getCellCacheKey(-1, -1, historicalCell.getLac(),
-                            historicalCell.getCid());
-                        record = mCellCache.lookup(historicalCellKey);
-                    }
-
-                    if (record != null && record.isValid()) {
-                        mCellCentroid.addLocation(record.getLat(), record.getLng(),
-                            record.getAccuracy(), record.getConfidence());
-                    }
-                }
-            }
-        }
-
-        if (scanResults != null) {
-            int miss = 0;
-            for (ScanResult scanResult : scanResults) {
-                String wifiKey = scanResult.BSSID;
-                Record record = mWifiCache.lookup(wifiKey);
-                if (record == null) {
-                    miss++;
-                } else {
-                    if (record.isValid()) {
-                        mWifiCentroid.addLocation(record.getLat(), record.getLng(),
-                            record.getAccuracy(), record.getConfidence());
-                    }
-                }
-            }
-
-            if (mWifiCentroid.getNumber() >= WIFI_MIN_AP_REQUIRED) {
-                // Try to return best out of the available cell or wifi location
-            } else if (miss > Math.min(WIFI_MAX_MISS_ALLOWED, (scanResults.size()+1)/2)) {
-                // Make a server request
-                return false;
-            } else {
-                 // Don't use wifi location, only consider using cell location
-                 mWifiCache.save();
-                 mWifiCentroid.reset();
-            }
-        }
-
-        if (mCellCentroid.getNumber() > 0) {
-            mCellCache.save();
-        }
-        if (mWifiCentroid.getNumber() > 0) {
-            mWifiCache.save();
-        }
-
-        int cellAccuracy = mCellCentroid.getAccuracy();
-        int wifiAccuracy = mWifiCentroid.getAccuracy();
-
-        int cellConfidence = mCellCentroid.getConfidence();
-        int wifiConfidence = mWifiCentroid.getConfidence();
-
-        if (Log.isLoggable(TAG, Log.VERBOSE)) {
-            Log.d(TAG, "cellAccuracy:" + cellAccuracy+ ", wifiAccuracy:" + wifiAccuracy);
-        }
-
-        if ((mCellCentroid.getNumber() == 0 || cellAccuracy > MAX_ACCURACY_ALLOWED) &&
-            (mWifiCentroid.getNumber() == 0 || wifiAccuracy > MAX_ACCURACY_ALLOWED)) {
-          // Return invalid location if neither location is valid
-          result.setAccuracy(-1);
-
-          // don't make server request
-          return true;
-        }
-
-        float[] distance = new float[1];
-        Location.distanceBetween(mCellCentroid.getCentroidLat(), mCellCentroid.getCentroidLng(),
-                                 mWifiCentroid.getCentroidLat(), mWifiCentroid.getCentroidLng(),
-                                 distance);
-
-        boolean consistent = distance[0] <= (cellAccuracy + wifiAccuracy);
-
-        boolean useCell = true;
-
-        if (consistent) {
-            // If consistent locations, use one with greater accuracy
-            useCell = (cellAccuracy <= wifiAccuracy);
-        } else {
-            // If inconsistent locations, use one with greater confidence
-            useCell = (cellConfidence >= wifiConfidence);
-        }
-
-        if (useCell) {
-            // Use cell results
-            result.setAccuracy(cellAccuracy);
-            result.setLatitude(mCellCentroid.getCentroidLat());
-            result.setLongitude(mCellCentroid.getCentroidLng());
-            result.setTime(now);
-
-            Bundle extras = result.getExtras() == null ? new Bundle() : result.getExtras();
-            extras.putString(EXTRA_KEY_LOCATION_TYPE, EXTRA_VALUE_LOCATION_TYPE_CELL);
-            result.setExtras(extras);
-
-        } else {
-            // Use wifi results
-            result.setAccuracy(wifiAccuracy);
-            result.setLatitude(mWifiCentroid.getCentroidLat());
-            result.setLongitude(mWifiCentroid.getCentroidLng());
-            result.setTime(now);
-
-            Bundle extras = result.getExtras() == null ? new Bundle() : result.getExtras();
-            extras.putString(EXTRA_KEY_LOCATION_TYPE, EXTRA_VALUE_LOCATION_TYPE_WIFI);
-            result.setExtras(extras);
-
-        }
-
-        // don't make a server request
-        return true;
-    }
-
-    public synchronized void insert(int mcc, int mnc, int lac, int cid, double lat, double lng,
-        int accuracy, int confidence, long time) {
-        String key = getCellCacheKey(mcc, mnc, lac, cid);
-        if (accuracy <= 0) {
-            mCellCache.insert(key, new Record());
-        } else {
-            mCellCache.insert(key, new Record(accuracy, confidence, lat, lng, time));
-        }
-    }
-
-    public synchronized void insert(String bssid, double lat, double lng, int accuracy,
-        int confidence, long time) {
-        if (accuracy <= 0) {
-            mWifiCache.insert(bssid, new Record());
-        } else {
-            mWifiCache.insert(bssid, new Record(accuracy, confidence, lat, lng, time));
-        }
-    }
-
-    public synchronized void save() {
-        mCellCache.save();
-        mWifiCache.save();
-    }
-
-    /**
-     * Cell or Wifi location record
-     */
-    public static class Record {
-
-        private final double lat;
-        private final double lng;
-        private final int accuracy;
-        private final int confidence;
-
-        // Time (since the epoch) of original reading.
-        private final long originTime;
-
-        public static Record read(DataInput dataInput) throws IOException {
-            final int accuracy = dataInput.readInt();
-            final int confidence = dataInput.readInt();
-            final double lat = dataInput.readDouble();
-            final double lng = dataInput.readDouble();
-            final long readingTime = dataInput.readLong();
-            return new Record(accuracy, confidence, lat, lng, readingTime);
-        }
-
-        /**
-         * Creates an "invalid" record indicating there was no location data
-         * available for the given data
-         */
-        public Record() {
-            this(-1, 0, 0, 0, System.currentTimeMillis());
-        }
-
-        /**
-         * Creates a Record
-         *
-         * @param accuracy acuracy in meters. If < 0, then this is an invalid record.
-         * @param confidence confidence (0-100)
-         * @param lat latitude
-         * @param lng longitude
-         * @param time  Time of the original location reading from the server
-         */
-        public Record(int accuracy, int confidence, double lat, double lng, long time) {
-            this.accuracy = accuracy;
-            this.confidence = confidence;
-            this.originTime = time;
-            this.lat = lat;
-            this.lng = lng;
-        }
-
-        public double getLat() {
-            return lat;
-        }
-
-        public double getLng() {
-            return lng;
-        }
-
-        public int getAccuracy() {
-            return accuracy;
-        }
-
-        public int getConfidence() {
-            return confidence;
-        }
-
-        public boolean isValid() {
-            return accuracy > 0;
-        }
-
-        public long getTime() {
-            return originTime;
-        }
-
-        public void write(DataOutput dataOut) throws IOException {
-            dataOut.writeInt(accuracy);
-            dataOut.writeInt(confidence);
-            dataOut.writeDouble(lat);
-            dataOut.writeDouble(lng);
-            dataOut.writeLong(originTime);
-        }
-
-        @Override
-        public String toString() {
-            return lat + "," + lng + "," + originTime +"," + accuracy + "," + confidence;
-        }
-    }
-
-    public class Cache<T> extends LinkedHashMap {
-        private final long mMaxAge;
-        private final int mCapacity;
-        private final String mDir;
-        private final String mFile;
-        private long mLastSaveTime = 0;
-
-        public Cache(String dir, String file, int capacity, long maxAge) {
-            super(capacity + 1, 1.1f, true);
-            this.mCapacity = capacity;
-            this.mDir = dir;
-            this.mFile = file;
-            this.mMaxAge = maxAge;
-            load();
-        }
-
-        private LocationCache.Record lookup(String key) {
-            LocationCache.Record result = (LocationCache.Record) get(key);
-
-            if (result == null) {
-                if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                    Log.d(TAG, "lookup: " + key + " failed");
-                }
-                return null;
-            }
-
-            // Cache entry needs refresh
-            if (result.getTime() + mMaxAge < System.currentTimeMillis()) {
-                if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                    Log.d(TAG, "lookup: " + key + " expired");
-                }
-                return null;
-            }
-
-            if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                Log.d(TAG, "lookup: " + key + " " + result.toString());
-            }
-
-            return result;
-        }
-
-        private void insert(String key, LocationCache.Record record) {
-            remove(key);
-            put(key, record);
-
-            if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                Log.d(TAG, "insert: " + key + " " + record.toString());
-            }
-        }
-
-        @Override
-        protected boolean removeEldestEntry(Map.Entry eldest) {
-            // Remove cache entries when it has more than capacity
-            return size() > mCapacity;
-        }
-
-        private void load() {
-            FileInputStream istream;
-            try {
-                File f = new File(mDir, mFile);
-                istream = new FileInputStream(f);
-            } catch (FileNotFoundException e) {
-                // No existing DB - return new CellCache
-                return;
-            }
-
-            DataInputStream dataInput = new DataInputStream(istream);
-
-            try {
-                int version = dataInput.readUnsignedShort();
-                if (version != CACHE_DB_VERSION) {
-                    // Ignore records - invalid version ID.
-                    dataInput.close();
-                    return;
-                }
-                int records = dataInput.readUnsignedShort();
-
-                for (int i = 0; i < records; i++) {
-                    final String key = dataInput.readUTF();
-                    final LocationCache.Record record = LocationCache.Record.read(dataInput);
-                    //Log.d(TAG, key + " " + record.toString());
-                    put(key, record);
-                }
-
-                dataInput.close();
-            } catch (IOException e) {
-                // Something's corrupted - return a new CellCache
-            }
-        }
-
-        private void save() {
-            long now = System.currentTimeMillis();
-            if (mLastSaveTime != 0 && (now - mLastSaveTime < SAVE_FREQUENCY)) {
-                // Don't save to file more often than SAVE_FREQUENCY
-                return;
-            }
-
-            FileOutputStream ostream;
-
-            File systemDir = new File(mDir);
-            if (!systemDir.exists()) {
-                if (!systemDir.mkdirs()) {
-                    Log.e(TAG, "Cache.save(): couldn't create directory");
-                    return;
-                }
-            }
-
-            try {
-                File f = new File(mDir, mFile);
-                ostream = new FileOutputStream(f);
-            } catch (FileNotFoundException e) {
-                Log.d(TAG, "Cache.save(): unable to create cache file", e);
-                return;
-            }
-
-            DataOutputStream dataOut = new DataOutputStream(ostream);
-            try {
-                dataOut.writeShort(CACHE_DB_VERSION);
-
-                dataOut.writeShort(size());
-
-                for (Iterator iter = entrySet().iterator(); iter.hasNext();) {
-                    Map.Entry entry = (Map.Entry) iter.next();
-                    String key = (String) entry.getKey();
-                    LocationCache.Record record = (LocationCache.Record) entry.getValue();
-                    dataOut.writeUTF(key);
-                    record.write(dataOut);
-                }
-
-                dataOut.close();
-                mLastSaveTime = now;
-                
-            } catch (IOException e) {
-                Log.e(TAG, "Cache.save(): unable to write cache", e);
-                // This should never happen
-            }
-        }
-    }
-
-    public class LocationCentroid {
-
-        double mLatSum = 0;
-        double mLngSum = 0;
-        int mNumber = 0;
-        int mConfidence = 0;
-
-        double mCentroidLat = 0;
-        double mCentroidLng = 0;
-
-        // Probably never have to calculate centroid for more than 10 locations
-        final static int MAX_SIZE = 10;
-        double[] mLats = new double[MAX_SIZE];
-        double[] mLngs = new double[MAX_SIZE];
-        int[] mRadii = new int[MAX_SIZE];
-
-        LocationCentroid() {
-            reset();
-        }
-
-        public void reset() {
-            mLatSum = 0;
-            mLngSum = 0;
-            mNumber = 0;
-            mConfidence = 0;
-
-            mCentroidLat = 0;
-            mCentroidLng = 0;
-
-            for (int i = 0; i < MAX_SIZE; i++) {
-                mLats[i] = 0;
-                mLngs[i] = 0;
-                mRadii[i] = 0;
-            }
-        }
-
-        public void addLocation(double lat, double lng, int accuracy, int confidence) {
-            if (mNumber < MAX_SIZE && accuracy <= MAX_ACCURACY_ALLOWED) {
-                mLatSum += lat;
-                mLngSum += lng;
-                if (confidence > mConfidence) {
-                  mConfidence = confidence;
-                }
-
-                mLats[mNumber] = lat;
-                mLngs[mNumber] = lng;
-                mRadii[mNumber] = accuracy;
-                mNumber++;
-            }
-        }
-
-        public int getNumber() {
-            return mNumber;
-        }
-
-        public double getCentroidLat() {
-            if (mCentroidLat == 0 && mNumber != 0) {
-                mCentroidLat = mLatSum/mNumber;
-            }
-            return mCentroidLat;
-        }
-
-        public double getCentroidLng() {
-            if (mCentroidLng == 0 && mNumber != 0) {
-                mCentroidLng = mLngSum/mNumber;
-            }
-            return mCentroidLng;
-        }
-
-        public int getConfidence() {
-            return mConfidence;
-        }
-
-        public int getAccuracy() {
-            if (mNumber == 0) {
-                return 0;
-            }
-
-            if (mNumber == 1) {
-                return mRadii[0];
-            }
-
-            double cLat = getCentroidLat();
-            double cLng = getCentroidLng();
-
-            int meanDistanceSum = 0;
-            int smallestCircle = MAX_ACCURACY_ALLOWED;
-            int smallestCircleDistance = MAX_ACCURACY_ALLOWED;
-            float[] distance = new float[1];
-            boolean outlierExists = false;
-
-            for (int i = 0; i < mNumber; i++) {
-                Location.distanceBetween(cLat, cLng, mLats[i], mLngs[i], distance);
-                meanDistanceSum += (int)distance[0];
-                if (distance[0] > mRadii[i]) {
-                    outlierExists = true;
-                }
-                if (mRadii[i] < smallestCircle) {
-                    smallestCircle = mRadii[i];
-                    smallestCircleDistance = (int)distance[0];
-                }
-            }
-
-            if (outlierExists) {
-                return meanDistanceSum/mNumber;
-            } else {
-                return Math.max(smallestCircle, smallestCircleDistance);
-            }
-        }
-
-    }
-
-    private String getCellCacheKey(int mcc, int mnc, int lac, int cid) {
-        return mcc + ":" + mnc + ":" + lac + ":" + cid;
-    }
-
-}
diff --git a/location/java/com/android/internal/location/LocationCollector.java b/location/java/com/android/internal/location/LocationCollector.java
deleted file mode 100644
index 39f432f..0000000
--- a/location/java/com/android/internal/location/LocationCollector.java
+++ /dev/null
@@ -1,499 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location;
-
-import com.android.internal.location.protocol.GDebugProfile;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import android.location.Location;
-import android.net.wifi.ScanResult;
-import android.os.SystemClock;
-import android.os.SystemProperties;
-import android.util.Log;
-
-/**
- * Listens for GPS and cell/wifi changes and anonymously uploads to server for
- * improving quality of service of NetworkLocationProvider. This service is only enabled when
- * the user has enabled the network location provider.
- *
- * {@hide}
- */
-public class LocationCollector {
-
-    private static final String TAG = "LocationCollector";
-
-    // last location valid for 12 minutes
-    private static final long MIN_VALID_LOCATION_TIME = 12 * 60 * 1000L;
-
-    // don't send wifi more than every 10 min
-    private static final long MIN_TIME_BETWEEN_WIFI_REPORTS = 10 * 60 * 1000L;
-
-    // atleast 5 changed APs for wifi collection
-    private static final int MIN_CHANGED_WIFI_POINTS = 5;
-
-    // don't collect if distance moved less than 200 meters
-    private static final int MIN_DISTANCE_BETWEEN_REPORTS = 200;
-
-    // don't collect if battery level less than 20%
-    private static final double MIN_BATTERY_LEVEL = 0.2;
-
-    // if battery level is greater than 90% and plugged in, collect more frequently
-    private static final double CHARGED_BATTERY_LEVEL = 0.9;
-
-    // collect bursts every 15 minutes (running on battery)
-    private static final long BURST_REST_TIME_ON_BATTERY = 15 * 60 * 1000L;
-
-    // collect bursts every 8 minutes (when plugged in)
-    private static final long BURST_REST_TIME_PLUGGED = 8 * 60 * 1000L;
-
-    // collect burst samples every 12 seconds
-    private static final int BURST_MEASUREMENT_INTERVAL = 12 * 1000;
-
-    // collect 11 burst samples before resting (11 samples every 12 seconds = 2 minute bursts)
-    private static final int BURST_NUM_SAMPLES = 11;
-
-    // don't collect bursts if user in same loc for 2 bursts
-    private static final int MAX_BURSTS_FROM_SAME_LOCATION = 2;
-
-    // don't send more than 2 bursts if user hasn't moved more than 25 meters
-    private static final int MIN_DISTANCE_BETWEEN_BURSTS = 25;
-
-    // Cell State
-    private CellState mCellState = null;
-    private CellUploads mCellUploads = new CellUploads();
-
-    // GPS state
-    private Location mLastKnownLocation = null;
-    private Location mLastUploadedLocation = null;
-    private long mLastKnownLocationTime = 0;
-    private long mLastUploadedLocationTime = 0;
-
-    // Burst state
-    private Location mLastBurstLocation = null;
-    private long mLastBurstEndTime = 0;
-    private long mCurrentBurstStartTime = 0;
-    private int mCurrentBurstNumSamples = 0;
-    private int mNumBurstsFromLastLocation = 0;
-
-    // WiFi state
-    private List<ScanResult> mWifiLastScanResults = null;
-    private List<ScanResult> mWifiCurrentScanResults = null;
-    private long mLastWifiScanElapsedTime = 0;
-    private long mLastWifiScanRealTime = 0;
-    private boolean mWifiUploadedWithoutLocation = false;
-
-    // Collection state
-    private boolean mNetworkProviderIsEnabled = true;
-    private boolean mBatteryLevelIsHealthy = true;
-    private boolean mBatteryChargedAndPlugged = false;
-
-    // Location masf service
-    private LocationMasfClient mMasfClient;
-
-    public LocationCollector(LocationMasfClient masfClient) {
-        mMasfClient = masfClient;
-    }
-
-    /**
-     * Updates cell tower state. This is usually always up to date so should be uploaded
-     * each time a new location is available.
-     *
-     * @param newState cell state
-     */
-    public synchronized void updateCellState(CellState newState) {
-        if (newState == null) {
-            throw new IllegalArgumentException("cell state is null");
-        }
-
-        if (!newState.isValid()) {
-            return;
-        }
-
-        if (mCellState != null && mCellState.equals(newState)) {
-            return;
-        }
-
-        mCellState = newState;
-        log("updateCellState(): Updated to " + mCellState.getCid() + "," + mCellState.getLac());
-
-        if (isCollectionEnabled()) {
-            addToQueue(GDebugProfile.TRIGGER_CELL_CHANGE);
-        }
-    }
-
-    /**
-     * Updates GPS location if collection is enabled
-     *
-     * @param location location object
-     */
-    public synchronized void updateLocation(Location location) {
-
-        // Don't do anything if collection is disabled
-        if (!isCollectionEnabled()) {
-            return;
-        }
-
-        long now = SystemClock.elapsedRealtime();
-
-        // Update last known location
-        if (mLastKnownLocation == null) {
-            mLastKnownLocation = new Location(location);
-        } else {
-            mLastKnownLocation.set(location);
-        }
-        mLastKnownLocationTime = now;
-
-        // Burst rest time depends on battery state
-        long restTime = BURST_REST_TIME_ON_BATTERY;
-        if (mBatteryChargedAndPlugged) {
-            restTime = BURST_REST_TIME_PLUGGED;
-        }
-
-        int trigger;
-
-        // In burst mode if either first burst or enough time has passed since last burst
-        if (mLastBurstEndTime == 0 || (now - mLastBurstEndTime > restTime)) {
-
-            // If location is too recent, then don't do anything!
-            if (now - mLastUploadedLocationTime < BURST_MEASUREMENT_INTERVAL) {
-                return;
-            }
-
-            int distanceFromLastBurst = -1;
-            if (mLastBurstLocation != null) {
-                distanceFromLastBurst = (int) mLastBurstLocation.distanceTo(location);
-
-                // Too many bursts from same location, don't upload
-                if (distanceFromLastBurst < MIN_DISTANCE_BETWEEN_BURSTS &&
-                    mNumBurstsFromLastLocation >= MAX_BURSTS_FROM_SAME_LOCATION) {
-                    log("NO UPLOAD: Too many bursts from same location.");
-                    return;
-                }
-            }
-
-            if (mCurrentBurstStartTime == 0) {
-                // Start the burst!
-                mCurrentBurstStartTime = now;
-                mCurrentBurstNumSamples = 1;
-                trigger = GDebugProfile.TRIGGER_COLLECTION_START_BURST;
-
-            } else if (now - mCurrentBurstStartTime > restTime) {
-                // Burst got old, start a new one
-                mCurrentBurstStartTime = now;
-                mCurrentBurstNumSamples = 1;
-                trigger = GDebugProfile.TRIGGER_COLLECTION_RESTART_BURST;
-
-            } else if (mCurrentBurstNumSamples == BURST_NUM_SAMPLES - 1) {
-                // Finished a burst
-                mLastBurstEndTime = now;
-                mCurrentBurstStartTime = 0;
-                mCurrentBurstNumSamples = 0;
-
-                // Make sure we don't upload too many bursts from same location
-                if (mLastBurstLocation == null) {
-                    mLastBurstLocation = new Location(location);
-                    mNumBurstsFromLastLocation = 1;
-                    trigger = GDebugProfile.TRIGGER_COLLECTION_END_BURST;
-
-                } else {
-
-                    if (distanceFromLastBurst != -1 &&
-                        distanceFromLastBurst < MIN_DISTANCE_BETWEEN_BURSTS) {
-                        // User hasnt moved much from last location, keep track of count,
-                        // don't update last burst loc
-                        mNumBurstsFromLastLocation++;
-                        trigger = GDebugProfile.TRIGGER_COLLECTION_END_BURST_AT_SAME_LOCATION;
-
-                    } else {
-                        // User has moved enough, update last burst loc
-                        mLastBurstLocation.set(location);
-                        mNumBurstsFromLastLocation = 1;
-                        trigger = GDebugProfile.TRIGGER_COLLECTION_END_BURST;
-                    }
-                }
-
-            } else {
-                // Increment burst sample count
-                mCurrentBurstNumSamples++;
-                trigger = GDebugProfile.TRIGGER_COLLECTION_CONTINUE_BURST;
-            }
-
-        } else if (mLastUploadedLocation != null
-            && (mLastUploadedLocation.distanceTo(location) > MIN_DISTANCE_BETWEEN_REPORTS)) {
-            // If not in burst mode but has moved a reasonable distance, upload!
-            trigger = GDebugProfile.TRIGGER_COLLECTION_MOVED_DISTANCE;
-
-        } else {
-            // Not in burst mode or hasn't moved enough
-            log("NO UPLOAD: Not in burst or moving mode. Resting for " + restTime + " ms");
-            return;
-        }
-
-        log("updateLocation(): Updated location with trigger " + trigger);
-        addToQueue(trigger);
-    }
-
-    /**
-     * Updates wifi scan results if collection is enabled
-     *
-     * @param currentScanResults scan results
-     */
-    public synchronized void updateWifiScanResults(List<ScanResult> currentScanResults) {
-        if (!isCollectionEnabled()) {
-            return;
-        }
-
-        if (currentScanResults == null || currentScanResults.size() == 0) {
-            return;
-        }
-
-        long now = SystemClock.elapsedRealtime();
-
-        // If wifi scan recently received, then don't upload
-        if ((mLastWifiScanElapsedTime != 0)
-            && ((now - mLastWifiScanElapsedTime) <= MIN_TIME_BETWEEN_WIFI_REPORTS)) {
-            return;
-        }
-
-        if (mWifiCurrentScanResults == null) {
-            mWifiCurrentScanResults = new ArrayList<ScanResult>();
-        } else {
-            mWifiCurrentScanResults.clear();
-        }
-        mWifiCurrentScanResults.addAll(currentScanResults);
-
-        // If wifi has changed enough
-        boolean wifiHasChanged = false;
-
-        if (mWifiLastScanResults == null) {
-            wifiHasChanged = true;
-        } else {
-            // Calculate the number of new AP points received
-            HashSet<String> previous = new HashSet<String>();
-            HashSet<String> current = new HashSet<String>();
-            for (ScanResult s : mWifiLastScanResults) {
-                previous.add(s.BSSID);
-            }
-            for (ScanResult s : mWifiCurrentScanResults) {
-                current.add(s.BSSID);
-            }
-            current.removeAll(previous);
-
-            if (current.size() >
-                Math.min(MIN_CHANGED_WIFI_POINTS, ((mWifiCurrentScanResults.size()+1)/2))) {
-                wifiHasChanged = true;
-            }
-        }
-
-        if (!wifiHasChanged) {
-            log("updateWifiScanResults(): Wifi results haven't changed much");
-            return;
-        }
-
-        if (mWifiLastScanResults == null) {
-            mWifiLastScanResults = new ArrayList<ScanResult>();
-        } else {
-            mWifiLastScanResults.clear();
-        }
-        mWifiLastScanResults.addAll(mWifiCurrentScanResults);
-
-        mLastWifiScanElapsedTime = now;
-        mLastWifiScanRealTime = System.currentTimeMillis();
-
-        log("updateWifiScanResults(): Updated " + mWifiLastScanResults.size() + " APs");
-        addToQueue(GDebugProfile.TRIGGER_WIFI_CHANGE);
-    }
-
-    /**
-     * Updates the status of the network location provider.
-     *
-     * @param enabled true if user has enabled network location based on Google's database
-     * of wifi points and cell towers.
-     */
-    public void updateNetworkProviderStatus(boolean enabled) {
-        mNetworkProviderIsEnabled = enabled;
-    }
-
-    /**
-     * Updates the battery health. Battery level is healthy if there is greater than
-     * {@link #MIN_BATTERY_LEVEL} percentage left or if the device is plugged in
-     *
-     * @param scale maximum scale for battery
-     * @param level current level
-     * @param plugged true if device is plugged in
-     */
-    public void updateBatteryState(int scale, int level, boolean plugged) {
-        mBatteryLevelIsHealthy = (plugged || (level >= (MIN_BATTERY_LEVEL * scale)));
-        mBatteryChargedAndPlugged = (plugged && (level >= (CHARGED_BATTERY_LEVEL * scale)));
-    }
-
-    /**
-     * Anonymous data collection is only enabled when the user has enabled the network
-     * location provider, i.e. is making use of the service and if the device battery level
-     * is healthy.
-     *
-     * Additionally, data collection will *never* happen if the system
-     * property ro.com.google.locationfeatures is not set.
-     *
-     * @return true if anonymous location collection is enabled
-     */
-    private boolean isCollectionEnabled() {
-        // This class provides a Google-specific location feature, so it's enabled only
-        // when the system property ro.com.google.locationfeatures is set.
-        if (!SystemProperties.get("ro.com.google.locationfeatures").equals("1")) {
-            return false;
-        }
-        return mBatteryLevelIsHealthy && mNetworkProviderIsEnabled;
-    }
-
-    /**
-     * Adds to the MASF request queue
-     *
-     * @param trigger the event that triggered this collection event
-     */
-    private synchronized void addToQueue(int trigger) {
-
-        long now = SystemClock.elapsedRealtime();
-
-        // Include location if:
-        // It has been received in the last 12 minutes.
-        boolean includeLocation = false;
-        if (mLastKnownLocation != null &&
-            (now - mLastKnownLocationTime <= MIN_VALID_LOCATION_TIME)) {
-            includeLocation = true;
-        }
-
-        // Include wifi if:
-        // Wifi is new OR
-        // Wifi is old but last wifi upload was without location
-        boolean includeWifi = false;
-        if (trigger == GDebugProfile.TRIGGER_WIFI_CHANGE || (mWifiUploadedWithoutLocation &&
-                includeLocation && (now - mLastWifiScanElapsedTime < MIN_VALID_LOCATION_TIME))) {
-            includeWifi = true;
-            mWifiUploadedWithoutLocation = !includeLocation;
-        }
-
-        // Include cell if:
-        // Wifi or location information is already being included
-        // The cell hasn't been uploaded with the same location recently
-        boolean includeCell = false;
-
-        if (mCellState != null && (includeWifi || includeLocation)) {
-            includeCell = true;
-
-            if (!includeWifi && includeLocation) {
-                if (mCellUploads.contains(mCellState, mLastKnownLocation)) {
-                    includeCell = false;
-                }
-            } 
-        }        
-
-        if (!includeLocation && !includeWifi) {
-            log("NO UPLOAD: includeLocation=false, includeWifi=false");
-            return;
-        } else if (!includeCell && trigger == GDebugProfile.TRIGGER_CELL_CHANGE) {
-            log("NO UPLOAD: includeCell=false");
-            return;
-        } else {
-            log("UPLOAD: includeLocation=" + includeLocation + ", includeWifi=" +
-                includeWifi + ", includeCell=" + includeCell);
-        }
-
-        if (includeLocation) {
-            // Update last uploaded location
-            if (mLastUploadedLocation == null) {
-                mLastUploadedLocation = new Location(mLastKnownLocation);
-            } else {
-                mLastUploadedLocation.set(mLastKnownLocation);
-            }
-            mLastUploadedLocationTime = now;
-        }
-
-        // Immediately send output if finishing a burst for live traffic requirements
-        boolean immediate = false;
-        if (trigger == GDebugProfile.TRIGGER_COLLECTION_END_BURST||
-            trigger == GDebugProfile.TRIGGER_COLLECTION_END_BURST_AT_SAME_LOCATION) {
-            immediate = true;
-        }
-
-        try {
-            CellState cell = includeCell ? mCellState : null;
-            List<ScanResult> wifi = includeWifi ? mWifiLastScanResults : null;
-            Location loc = includeLocation ? mLastUploadedLocation : null;
-
-            mMasfClient.queueCollectionReport(
-                trigger, loc, cell, wifi, mLastWifiScanRealTime, immediate);
-
-        } catch(Exception e) {
-            Log.e(TAG, "addToQueue got exception:", e);
-        }
-    }
-
-    private class CellUploads {
-
-        private final int MIN_DISTANCE = MIN_DISTANCE_BETWEEN_REPORTS / 4; // 50 meters
-        private final int SIZE = 5;
-        private final String[] cells = new String[SIZE];
-        private final boolean[] valid = new boolean[SIZE];
-        private final double[] latitudes = new double[SIZE];
-        private final double[] longitudes = new double[SIZE];
-        private final float[] distance = new float[1];
-        private int index = 0;
-
-        private CellUploads() {
-            for (int i = 0; i < SIZE; i++) {
-                valid[i] = false;
-            }
-        }
-
-        private boolean contains(CellState cellState, Location loc) {
-            String cell =
-                cellState.getCid() + ":" + cellState.getLac() + ":" +
-                cellState.getMnc() + ":" + cellState.getMcc();
-            double lat = loc.getLatitude();
-            double lng = loc.getLongitude();
-
-            for (int i = 0; i < SIZE; i++) {
-                if (valid[i] && cells[i].equals(cell)) {
-                    Location.distanceBetween(latitudes[i], longitudes[i], lat, lng, distance);
-                    if (distance[0] < MIN_DISTANCE) {
-                        return true;
-                    }
-                }
-            }
-            cells[index] = cell;
-            latitudes[index] = lat;
-            longitudes[index] = lng;
-            valid[index] = true;
-
-            index++;
-            if (index == SIZE) {
-                index = 0;
-            }
-            return false;
-        }
-    }
-
-    private void log(String string) {
-        if (Log.isLoggable(TAG, Log.VERBOSE)) {
-            Log.d(TAG, string);
-        }
-    }
-}
diff --git a/location/java/com/android/internal/location/LocationMasfClient.java b/location/java/com/android/internal/location/LocationMasfClient.java
deleted file mode 100644
index 179c630..0000000
--- a/location/java/com/android/internal/location/LocationMasfClient.java
+++ /dev/null
@@ -1,1194 +0,0 @@
-// Copyright 2008 The Android Open Source Project
-
-package com.android.internal.location;
-
-import com.google.common.Config;
-import com.google.common.android.AndroidConfig;
-import com.google.common.io.protocol.ProtoBuf;
-import com.google.masf.MobileServiceMux;
-import com.google.masf.ServiceCallback;
-import com.google.masf.protocol.PlainRequest;
-import com.google.masf.protocol.Request;
-
-import com.android.internal.location.protocol.GAddress;
-import com.android.internal.location.protocol.GAddressComponent;
-import com.android.internal.location.protocol.GAppProfile;
-import com.android.internal.location.protocol.GCell;
-import com.android.internal.location.protocol.GCellularPlatformProfile;
-import com.android.internal.location.protocol.GCellularProfile;
-import com.android.internal.location.protocol.GDebugProfile;
-import com.android.internal.location.protocol.GDeviceLocation;
-import com.android.internal.location.protocol.GFeature;
-import com.android.internal.location.protocol.GGeocodeRequest;
-import com.android.internal.location.protocol.GLatLng;
-import com.android.internal.location.protocol.GLocReply;
-import com.android.internal.location.protocol.GLocReplyElement;
-import com.android.internal.location.protocol.GLocRequest;
-import com.android.internal.location.protocol.GLocRequestElement;
-import com.android.internal.location.protocol.GLocation;
-import com.android.internal.location.protocol.GPlatformProfile;
-import com.android.internal.location.protocol.GPrefetchMode;
-import com.android.internal.location.protocol.GRectangle;
-import com.android.internal.location.protocol.GWifiDevice;
-import com.android.internal.location.protocol.GWifiProfile;
-import com.android.internal.location.protocol.GcellularMessageTypes;
-import com.android.internal.location.protocol.GdebugprofileMessageTypes;
-import com.android.internal.location.protocol.GlatlngMessageTypes;
-import com.android.internal.location.protocol.GlocationMessageTypes;
-import com.android.internal.location.protocol.GrectangleMessageTypes;
-import com.android.internal.location.protocol.GwifiMessageTypes;
-import com.android.internal.location.protocol.LocserverMessageTypes;
-import com.android.internal.location.protocol.ResponseCodes;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-
-import android.content.Context;
-import android.location.Address;
-import android.location.Location;
-import android.location.LocationManager;
-import android.net.wifi.ScanResult;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.text.TextUtils;
-import android.util.EventLog;
-import android.util.Log;
-import android.telephony.NeighboringCellInfo;
-
-/**
- * Service to communicate to the Google Location Server (GLS) via MASF server
- *
- * {@hide}
- */
-public class LocationMasfClient {
-
-    static final String TAG = "LocationMasfClient";
-
-    // Address of the MASF server to connect to.
-    private static final String MASF_SERVER_ADDRESS = "http://www.google.com/loc/m/api";
-
-    // MobileServiceMux app/platform-specific values (application name matters!)
-    private static final String APPLICATION_NAME = "location";
-    private static final String APPLICATION_VERSION = "1.0";
-    private static final String PLATFORM_ID = "android";
-    private static final String DISTRIBUTION_CHANNEL = "android";
-    private static String PLATFORM_BUILD = null;
-
-    // Methods exposed by the MASF server
-    private static final String REQUEST_QUERY_LOC = "g:loc/ql";
-    private static final String REQUEST_UPLOAD_LOC = "g:loc/ul";
-
-    // Max time to wait for request to end  
-    private static final long REQUEST_TIMEOUT = 5000;
-
-    // Constant to divide Lat, Lng returned by server
-    private static final double E7 = 10000000.0;
-
-    // Max wifi points to include
-    private static final int MAX_WIFI_TO_INCLUDE = 25;
-
-    // Location of GLS cookie
-    private static final String PLATFORM_KEY_FILE = "gls.platform.key";
-    private String mPlatformKey;
-
-    // Cell cache
-    private LocationCache mLocationCache;
-
-    // Location object that the cache manages
-    private Location mLocation = new Location(LocationManager.NETWORK_PROVIDER);
-
-    // ProtoBuf objects we can reuse for subsequent requests
-    private final int MAX_COLLECTION_BUFFER_SIZE = 30;
-    private final long MIN_COLLECTION_INTERVAL = 15 * 60 * 1000; // 15 minutes
-    private ProtoBuf mPlatformProfile = null;
-    private ProtoBuf mCellularPlatformProfile = null;
-    private ProtoBuf mCurrentCollectionRequest = null;
-    private long mLastCollectionUploadTime = 0;
-
-    // Objects for current request
-    private List<ScanResult> mWifiScanResults = new ArrayList<ScanResult>();
-    private CellState mCellState = null;
-    private List<CellState> mCellHistory;
-
-    // This tag is used for the event log.
-    private static final int COLLECTION_EVENT_LOG_TAG = 2740;
-
-    // Extra values to designate whether location is from cache or network request
-    private static final String EXTRA_KEY_LOCATION_SOURCE = "networkLocationSource";
-    private static final String EXTRA_VALUE_LOCATION_SOURCE_CACHED = "cached";
-    private static final String EXTRA_VALUE_LOCATION_SOURCE_SERVER = "server";
-
-    // Maximum accuracy tolerated for a valid location
-    private static final int MAX_ACCURACY_ALLOWED = 5000; // 5km
-
-    // Indicates whether this is the first message after a device restart
-    private boolean mDeviceRestart = true;
-
-    /**
-     * Initializes the MobileServiceMux. Must be called before using any other function in the
-     * class.
-     */
-    public LocationMasfClient(Context context) {
-        MobileServiceMux mux = MobileServiceMux.getSingleton();
-        if (mux == null) {
-            AndroidConfig config = new AndroidConfig(context);
-            Config.setConfig(config);
-
-            MobileServiceMux.initialize
-                (MASF_SERVER_ADDRESS,
-                    APPLICATION_NAME,
-                    APPLICATION_VERSION,
-                    PLATFORM_ID,
-                   DISTRIBUTION_CHANNEL);
-        }
-        mLocationCache = new LocationCache();
-
-        if (Build.FINGERPRINT != null) {
-            PLATFORM_BUILD = PLATFORM_ID + "/" + Build.FINGERPRINT;
-        } else {
-            PLATFORM_BUILD = PLATFORM_ID;
-        }
-    }
-
-    /**
-     * Returns the location for the given cell or wifi information.
-     *
-     * @param apps list of apps requesting location
-     * @param trigger event that triggered this network request
-     * @param cellState cell tower state
-     * @param cellHistory history of acquired cell states
-     * @param scanResults list of wifi scan results
-     * @param scanTime time at which wireless scan was triggered
-     * @param callback function to call with received location
-     */
-    public synchronized void getNetworkLocation(Collection<String> apps, int trigger,
-        CellState cellState, List<CellState> cellHistory, List<ScanResult> scanResults,
-        long scanTime, NetworkLocationProvider.Callback callback) {
-
-        final NetworkLocationProvider.Callback finalCallback = callback;
-
-        boolean foundInCache =
-            mLocationCache.lookup(cellState, cellHistory, scanResults, mLocation);
-        
-        if (foundInCache) {
-
-            if (SystemClock.elapsedRealtime() - mLastCollectionUploadTime > MIN_COLLECTION_INTERVAL) {
-                uploadCollectionReport(true);
-            }
-
-            Bundle extras = mLocation.getExtras() == null ? new Bundle() : mLocation.getExtras();
-            extras.putString(EXTRA_KEY_LOCATION_SOURCE, EXTRA_VALUE_LOCATION_SOURCE_CACHED);
-            mLocation.setExtras(extras);
-
-            Log.d(TAG, "getNetworkLocation(): Returning cache location with accuracy " +
-                mLocation.getAccuracy());
-            finalCallback.locationReceived(mLocation, true);
-            return;
-        }
-
-        Log.d(TAG, "getNetworkLocation(): Location not found in cache, making network request");
-
-        // Copy over to objects for this request
-        mWifiScanResults.clear();
-        if (scanResults != null) {
-            mWifiScanResults.addAll(scanResults);
-        }
-        mCellState = cellState;
-        mCellHistory = cellHistory;
-
-        // Create a RequestElement
-        ProtoBuf requestElement = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST_ELEMENT);
-
-        // Debug profile
-        ProtoBuf debugProfile = new ProtoBuf(GdebugprofileMessageTypes.GDEBUG_PROFILE);
-        requestElement.setProtoBuf(GLocRequestElement.DEBUG_PROFILE, debugProfile);
-        
-        if (mDeviceRestart) {
-            debugProfile.setBool(GDebugProfile.DEVICE_RESTART, true);
-            mDeviceRestart = false;
-        }
-
-        if (trigger != -1) {
-            debugProfile.setInt(GDebugProfile.TRIGGER, trigger);
-        }
-
-        // Cellular profile
-        if (mCellState != null && mCellState.isValid()) {
-            ProtoBuf cellularProfile = new ProtoBuf(GcellularMessageTypes.GCELLULAR_PROFILE);
-            cellularProfile.setLong(GCellularProfile.TIMESTAMP, mCellState.getTime());
-            cellularProfile.setInt(GCellularProfile.PREFETCH_MODE,
-                GPrefetchMode.PREFETCH_MODE_MORE_NEIGHBORS);
-
-            // Primary cell
-            ProtoBuf primaryCell = new ProtoBuf(GcellularMessageTypes.GCELL);
-            primaryCell.setInt(GCell.LAC, mCellState.getLac());
-            primaryCell.setInt(GCell.CELLID, mCellState.getCid());
-
-            if ((mCellState.getMcc() != -1) && (mCellState.getMnc() != -1)) {
-                primaryCell.setInt(GCell.MCC, mCellState.getMcc());
-                primaryCell.setInt(GCell.MNC, mCellState.getMnc());
-            }
-
-            if (mCellState.getSignalStrength() != -1) {
-                primaryCell.setInt(GCell.RSSI, mCellState.getSignalStrength());
-            }
-
-            cellularProfile.setProtoBuf(GCellularProfile.PRIMARY_CELL, primaryCell);
-
-            // History of cells
-            for (CellState c : cellHistory) {
-                ProtoBuf pastCell = new ProtoBuf(GcellularMessageTypes.GCELL);
-                pastCell.setInt(GCell.LAC, c.getLac());
-                pastCell.setInt(GCell.CELLID, c.getCid());
-                if ((c.getMcc() != -1) && (c.getMnc() != -1)) {
-                    pastCell.setInt(GCell.MCC, c.getMcc());
-                    pastCell.setInt(GCell.MNC, c.getMnc());
-                }
-
-                if (c.getSignalStrength() != -1) {
-                    pastCell.setInt(GCell.RSSI, c.getSignalStrength());
-                }
-
-                pastCell.setInt(GCell.AGE, (int)(mCellState.getTime() - c.getTime()));
-                cellularProfile.addProtoBuf(GCellularProfile.HISTORICAL_CELLS, pastCell);
-            }
-
-            // Neighboring Cells
-            addNeighborsToCellProfile(mCellState, cellularProfile);
-
-            requestElement.setProtoBuf(GLocRequestElement.CELLULAR_PROFILE, cellularProfile);
-        }
-
-        // Wifi profile
-        if (mWifiScanResults != null && mWifiScanResults.size() > 0) {
-            ProtoBuf wifiProfile = new ProtoBuf(GwifiMessageTypes.GWIFI_PROFILE);
-            wifiProfile.setLong(GWifiProfile.TIMESTAMP, scanTime);
-            wifiProfile.setInt(GWifiProfile.PREFETCH_MODE,
-                 GPrefetchMode.PREFETCH_MODE_MORE_NEIGHBORS);
-
-            int count = 0;
-            for (ScanResult s : mWifiScanResults) {
-                ProtoBuf wifiDevice = new ProtoBuf(GwifiMessageTypes.GWIFI_DEVICE);
-                wifiDevice.setString(GWifiDevice.MAC, s.BSSID);
-                wifiProfile.addProtoBuf(GWifiProfile.WIFI_DEVICES, wifiDevice);
-                count++;
-                if (count >= MAX_WIFI_TO_INCLUDE) {
-                    break;
-                }
-            }
-
-            requestElement.setProtoBuf(GLocRequestElement.WIFI_PROFILE, wifiProfile);
-        }
-
-        // Request to send over wire
-        ProtoBuf request = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST);
-        request.addProtoBuf(GLocRequest.REQUEST_ELEMENTS, requestElement);
-
-        // Create a Platform Profile
-        ProtoBuf platformProfile = createPlatformProfile();
-        if (mCellState != null && mCellState.isValid()) {
-            // Include cellular platform Profile
-            ProtoBuf cellularPlatform = createCellularPlatformProfile(mCellState);
-            platformProfile.setProtoBuf(GPlatformProfile.CELLULAR_PLATFORM_PROFILE,
-                cellularPlatform);
-        }
-        request.setProtoBuf(GLocRequest.PLATFORM_PROFILE, platformProfile);
-
-        // Include App Profiles
-        if (apps != null) {
-            for (String app : apps) {
-                ProtoBuf appProfile = new ProtoBuf(GlocationMessageTypes.GAPP_PROFILE);
-                appProfile.setString(GAppProfile.APP_NAME, app);
-                request.addProtoBuf(GLocRequest.APP_PROFILES, appProfile);
-            }
-        }
-
-        // Queue any waiting collection events as well
-        uploadCollectionReport(false);
-
-        ByteArrayOutputStream payload = new ByteArrayOutputStream();
-        try {
-            request.outputTo(payload);
-        } catch (IOException e) {
-            Log.e(TAG, "getNetworkLocation(): unable to write request to payload", e);
-            return;
-        }
-
-        // Creates  request and a listener with a call back function
-        ProtoBuf reply = new ProtoBuf(LocserverMessageTypes.GLOC_REPLY);
-        Request plainRequest =
-            new PlainRequest(REQUEST_QUERY_LOC, (short)0, payload.toByteArray());
-
-        ProtoRequestListener listener = new ProtoRequestListener(reply, new ServiceCallback() {
-            public void onRequestComplete(Object result) {
-                ProtoBuf response = (ProtoBuf) result;
-                boolean successful = parseNetworkLocationReply(response);
-                finalCallback.locationReceived(mLocation, successful);
-
-            }
-        });
-        plainRequest.setListener(listener);
-
-        // Send request
-        MobileServiceMux serviceMux = MobileServiceMux.getSingleton();
-        serviceMux.submitRequest(plainRequest, true);
-    }
-
-    private synchronized boolean parseNetworkLocationReply(ProtoBuf response) {
-        if (response == null) {
-            Log.e(TAG, "getNetworkLocation(): response is null");
-            return false;
-        }
-
-        int status1 = response.getInt(GLocReply.STATUS);
-        if (status1 != ResponseCodes.STATUS_STATUS_SUCCESS) {
-            Log.e(TAG, "getNetworkLocation(): RPC failed with status " + status1);
-            return false;
-        }
-
-        if (response.has(GLocReply.PLATFORM_KEY)) {
-            String platformKey = response.getString(GLocReply.PLATFORM_KEY);
-            if (!TextUtils.isEmpty(platformKey)) {
-                setPlatformKey(platformKey);
-            }
-        }
-
-        if (!response.has(GLocReply.REPLY_ELEMENTS)) {
-            Log.e(TAG, "getNetworkLocation(): no ReplyElement");
-            return false;
-        }
-        ProtoBuf replyElement = response.getProtoBuf(GLocReply.REPLY_ELEMENTS);
-
-        // Get prefetched data to add to the device cache
-        Log.d(TAG, "getNetworkLocation(): Number of prefetched entries " +
-            replyElement.getCount(GLocReplyElement.DEVICE_LOCATION));
-        long now = System.currentTimeMillis();
-        for (int i = 0; i < replyElement.getCount(GLocReplyElement.DEVICE_LOCATION); i++ ) {
-            ProtoBuf device = replyElement.getProtoBuf(GLocReplyElement.DEVICE_LOCATION, i);
-            double lat = 0;
-            double lng = 0;
-            int accuracy = -1;
-            int confidence = -1;
-            int locType = -1;
-            if (device.has(GDeviceLocation.LOCATION)) {
-                ProtoBuf deviceLocation = device.getProtoBuf(GDeviceLocation.LOCATION);
-                if (deviceLocation.has(GLocation.ACCURACY) &&
-                    deviceLocation.has(GLocation.LAT_LNG)
-                    && deviceLocation.has(GLocation.CONFIDENCE)) {
-                    lat = deviceLocation.getProtoBuf(GLocation.LAT_LNG).
-                        getInt(GLatLng.LAT_E7) / E7;
-                    lng = deviceLocation.getProtoBuf(GLocation.LAT_LNG).
-                        getInt(GLatLng.LNG_E7) / E7;
-                    accuracy = deviceLocation.getInt(GLocation.ACCURACY);
-                    confidence = deviceLocation.getInt(GLocation.CONFIDENCE);
-                }
-                if (deviceLocation.has(GLocation.LOC_TYPE)) {
-                    locType = deviceLocation.getInt(GLocation.LOC_TYPE);
-                }
-            }
-
-            // Get cell key
-            if (device.has(GDeviceLocation.CELL) && locType != GLocation.LOCTYPE_TOWER_LOCATION) {
-                ProtoBuf deviceCell = device.getProtoBuf(GDeviceLocation.CELL);
-                int cid = deviceCell.getInt(GCell.CELLID);
-                int lac = deviceCell.getInt(GCell.LAC);
-                int mcc = -1;
-                int mnc = -1;
-                if (deviceCell.has(GCell.MNC) && deviceCell.has(GCell.MCC)) {
-                    mcc = deviceCell.getInt(GCell.MCC);
-                    mnc = deviceCell.getInt(GCell.MNC);
-                }
-                mLocationCache.
-                    insert(mcc, mnc, lac, cid, lat, lng, accuracy, confidence, now);
-            }
-
-            // Get wifi key
-            if (device.has(GDeviceLocation.WIFI_DEVICE)) {
-                ProtoBuf deviceWifi = device.getProtoBuf(GDeviceLocation.WIFI_DEVICE);
-                String bssid = deviceWifi.getString(GWifiDevice.MAC);
-                mLocationCache.insert(bssid, lat, lng, accuracy, confidence, now);
-            }
-        }
-
-        mLocationCache.save();
-
-        int status2 = replyElement.getInt(GLocReplyElement.STATUS);
-        if (status2 != ResponseCodes.STATUS_STATUS_SUCCESS &&
-            status2 != ResponseCodes.STATUS_STATUS_FAILED) {
-            Log.e(TAG, "getNetworkLocation(): GLS failed with status " + status2);
-            return false;
-        }
-
-        // For consistent results for user, always return cache computed location
-        boolean foundInCache =
-            mLocationCache.lookup(mCellState, mCellHistory, mWifiScanResults, mLocation);
-
-        if (foundInCache) {
-
-            Bundle extras = mLocation.getExtras() == null ? new Bundle() : mLocation.getExtras();
-            extras.putString(EXTRA_KEY_LOCATION_SOURCE, EXTRA_VALUE_LOCATION_SOURCE_SERVER);
-            mLocation.setExtras(extras);
-
-            Log.d(TAG, "getNetworkLocation(): Returning network location with accuracy " +
-                mLocation.getAccuracy());
-            return true;
-        }
-
-        if (status2 == ResponseCodes.STATUS_STATUS_FAILED) {
-            Log.e(TAG, "getNetworkLocation(): GLS does not have location");
-            // We return true here since even though there is no location, there is no need to retry
-            // since server doesn't have location
-            return true;
-        }
-
-        // Get server computed location to return for now
-        if (!replyElement.has(GLocReplyElement.LOCATION)) {
-            Log.e(TAG, "getNetworkLocation(): no location in ReplyElement");
-            return false;
-        }
-        ProtoBuf location = replyElement.getProtoBuf(GLocReplyElement.LOCATION);
-
-        if (!location.has(GLocation.LAT_LNG)) {
-            Log.e(TAG, "getNetworkLocation(): no Lat,Lng in location");
-            return false;
-        }
-
-        ProtoBuf point = location.getProtoBuf(GLocation.LAT_LNG);
-        double lat = point.getInt(GLatLng.LAT_E7) / E7;
-        double lng = point.getInt(GLatLng.LNG_E7) / E7;
-
-        int accuracy = 0;
-        if (location.has(GLocation.ACCURACY)) {
-            accuracy = location.getInt(GLocation.ACCURACY);
-        }
-
-        if (accuracy > MAX_ACCURACY_ALLOWED) {
-            Log.e(TAG, "getNetworkLocation(): accuracy is too high " + accuracy);
-            return false;
-        }
-
-        mLocation.setLatitude(lat);
-        mLocation.setLongitude(lng);
-        mLocation.setTime(System.currentTimeMillis());
-        mLocation.setAccuracy(accuracy);
-
-        Bundle extras = mLocation.getExtras() == null ? new Bundle() : mLocation.getExtras();
-        extras.putString(EXTRA_KEY_LOCATION_SOURCE, EXTRA_VALUE_LOCATION_SOURCE_SERVER);
-        mLocation.setExtras(extras);
-
-        Log.e(TAG, "getNetworkLocation(): Returning *server* computed location with accuracy " +
-            accuracy);
-
-        return true;
-    }
-
-    /**
-     * Gets a reverse geocoded location from the given lat,lng point. Also attaches the name
-     * of the requesting application with the request
-     *
-     * @param locale locale for geocoded location
-     * @param appPackageName name of the package, may be null
-     * @param lat latitude
-     * @param lng longitude
-     * @param maxResults maximum number of addresses to return
-     * @param addrs the list of addresses to fill up
-     * @throws IOException if network is unavailable or some other issue
-     */
-    public void reverseGeocode(Locale locale, String appPackageName,
-        double lat, double lng, int maxResults, List<Address> addrs) throws IOException {
-
-        // Reverse geocoding request element
-        ProtoBuf requestElement = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST_ELEMENT);
-
-        ProtoBuf latlngElement = new ProtoBuf(GlatlngMessageTypes.GLAT_LNG);
-        latlngElement.setInt(GLatLng.LAT_E7, (int)(lat * E7));
-        latlngElement.setInt(GLatLng.LNG_E7, (int)(lng * E7));
-
-        ProtoBuf locationElement = new ProtoBuf(GlocationMessageTypes.GLOCATION);
-        locationElement.setProtoBuf(GLocation.LAT_LNG, latlngElement);
-        locationElement.setLong(GLocation.TIMESTAMP, System.currentTimeMillis());
-        requestElement.setProtoBuf(GLocRequestElement.LOCATION, locationElement);
-
-        ProtoBuf geocodeElement =
-            new ProtoBuf(LocserverMessageTypes.GGEOCODE_REQUEST);
-        geocodeElement.setInt(GGeocodeRequest.NUM_FEATURE_LIMIT, maxResults);
-        requestElement.setProtoBuf(GLocRequestElement.GEOCODE, geocodeElement);
-
-        // Request to send over wire
-        ProtoBuf request = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST);
-        request.addProtoBuf(GLocRequest.REQUEST_ELEMENTS, requestElement);
-
-        // Create platform profile
-        ProtoBuf platformProfile = createPlatformProfile(locale);
-        request.setProtoBuf(GLocRequest.PLATFORM_PROFILE, platformProfile);
-
-        // Include app name
-        if (appPackageName != null) {
-            ProtoBuf appProfile = new ProtoBuf(GlocationMessageTypes.GAPP_PROFILE);
-            appProfile.setString(GAppProfile.APP_NAME, appPackageName);
-            request.setProtoBuf(GLocRequest.APP_PROFILES, appProfile);
-        }
-
-        // Queue any waiting collection events as well
-        uploadCollectionReport(false);
-
-        ByteArrayOutputStream payload = new ByteArrayOutputStream();
-        try {
-            request.outputTo(payload);
-        } catch (IOException e) {
-            Log.e(TAG, "reverseGeocode(): unable to write request to payload");
-            throw e;
-        }
-
-        // Creates  request and a listener with no callback function
-        ProtoBuf reply = new ProtoBuf(LocserverMessageTypes.GLOC_REPLY);
-        Request plainRequest =
-            new PlainRequest(REQUEST_QUERY_LOC, (short)0, payload.toByteArray());
-        ProtoRequestListener listener = new ProtoRequestListener(reply, null);
-        plainRequest.setListener(listener);
-
-        // Immediately send request and block for response until REQUEST_TIMEOUT
-        MobileServiceMux serviceMux = MobileServiceMux.getSingleton();
-        serviceMux.submitRequest(plainRequest, true);
-        ProtoBuf response;
-        try {
-            response = (ProtoBuf)listener.getAsyncResult().get(REQUEST_TIMEOUT);
-        } catch (InterruptedException e) {
-            Log.e(TAG, "reverseGeocode(): response timeout");
-            throw new IOException("response time-out");
-        }
-
-        if (response == null) {
-            throw new IOException("Unable to parse response from server");
-        }
-
-        // Parse the response
-        int status1 = response.getInt(GLocReply.STATUS);
-        if (status1 != ResponseCodes.STATUS_STATUS_SUCCESS) {
-            Log.e(TAG, "reverseGeocode(): RPC failed with status " + status1);
-            throw new IOException("RPC failed with status " + status1);
-        }
-
-        if (response.has(GLocReply.PLATFORM_KEY)) {
-            String platformKey = response.getString(GLocReply.PLATFORM_KEY);
-            if (!TextUtils.isEmpty(platformKey)) {
-                setPlatformKey(platformKey);
-            }
-        }
-
-        if (!response.has(GLocReply.REPLY_ELEMENTS)) {
-            Log.e(TAG, "reverseGeocode(): no ReplyElement");
-            return;
-        }
-        ProtoBuf replyElement = response.getProtoBuf(GLocReply.REPLY_ELEMENTS);
-
-        int status2 = replyElement.getInt(GLocReplyElement.STATUS);
-        if (status2 != ResponseCodes.STATUS_STATUS_SUCCESS) {
-            Log.e(TAG, "reverseGeocode(): GLS failed with status " + status2);
-            return;
-        }
-
-        if (!replyElement.has(GLocReplyElement.LOCATION)) {
-            Log.e(TAG, "reverseGeocode(): no location in ReplyElement");
-            return;
-        }
-
-        ProtoBuf location = replyElement.getProtoBuf(GLocReplyElement.LOCATION);
-        if (!location.has(GLocation.FEATURE)) {
-            Log.e(TAG, "reverseGeocode(): no feature in GLocation");
-            return;
-        }
-
-        getAddressFromProtoBuf(location, locale, addrs);
-    }
-
-    /**
-     * Gets a forward geocoded location from the given location string. Also attaches the name
-     * of the requesting application with the request
-     *
-     * Optionally, can specify the bounding box that the search results should be restricted to
-     *
-     * @param locale locale for geocoded location
-     * @param appPackageName name of the package, may be null
-     * @param locationString string to forward geocode
-     * @param lowerLeftLatitude latitude of lower left point of bounding box
-     * @param lowerLeftLongitude longitude of lower left point of bounding box
-     * @param upperRightLatitude latitude of upper right point of bounding box
-     * @param upperRightLongitude longitude of upper right point of bounding box
-     * @param maxResults maximum number of results to return
-     * @param addrs the list of addresses to fill up
-     * @throws IOException if network is unavailable or some other issue
-     */
-    public void forwardGeocode(Locale locale, String appPackageName, String locationString,
-        double lowerLeftLatitude, double lowerLeftLongitude,
-        double upperRightLatitude, double upperRightLongitude, int maxResults, List<Address> addrs)
-        throws IOException {
-
-        // Forward geocoding request element
-        ProtoBuf requestElement = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST_ELEMENT);
-
-        ProtoBuf locationElement = new ProtoBuf(GlocationMessageTypes.GLOCATION);
-        locationElement.setLong(GLocation.TIMESTAMP, System.currentTimeMillis());
-        locationElement.setString(GLocation.LOCATION_STRING, locationString);
-        requestElement.setProtoBuf(GLocRequestElement.LOCATION, locationElement);
-
-        ProtoBuf geocodeElement =
-            new ProtoBuf(LocserverMessageTypes.GGEOCODE_REQUEST);
-        geocodeElement.setInt(GGeocodeRequest.NUM_FEATURE_LIMIT, maxResults);
-
-        if (lowerLeftLatitude != 0 && lowerLeftLongitude !=0 &&
-            upperRightLatitude !=0 && upperRightLongitude !=0) {
-            ProtoBuf lowerLeft = new ProtoBuf(GlatlngMessageTypes.GLAT_LNG);
-            lowerLeft.setInt(GLatLng.LAT_E7, (int)(lowerLeftLatitude * E7));
-            lowerLeft.setInt(GLatLng.LNG_E7, (int)(lowerLeftLongitude * E7));
-
-            ProtoBuf upperRight = new ProtoBuf(GlatlngMessageTypes.GLAT_LNG);
-            upperRight.setInt(GLatLng.LAT_E7, (int)(upperRightLatitude * E7));
-            upperRight.setInt(GLatLng.LNG_E7, (int)(upperRightLongitude * E7));
-
-            ProtoBuf boundingBox = new ProtoBuf(GrectangleMessageTypes.GRECTANGLE);
-            boundingBox.setProtoBuf(GRectangle.LOWER_LEFT, lowerLeft);
-            boundingBox.setProtoBuf(GRectangle.UPPER_RIGHT, upperRight);
-            geocodeElement.setProtoBuf(GGeocodeRequest.BOUNDING_BOX, boundingBox);
-        }
-        requestElement.setProtoBuf(GLocRequestElement.GEOCODE, geocodeElement);
-
-        // Request to send over wire
-        ProtoBuf request = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST);
-        request.addProtoBuf(GLocRequest.REQUEST_ELEMENTS, requestElement);
-
-        // Create platform profile
-        ProtoBuf platformProfile = createPlatformProfile(locale);
-        request.setProtoBuf(GLocRequest.PLATFORM_PROFILE, platformProfile);
-
-        // Include app name
-        if (appPackageName != null) {
-            ProtoBuf appProfile = new ProtoBuf(GlocationMessageTypes.GAPP_PROFILE);
-            appProfile.setString(GAppProfile.APP_NAME, appPackageName);
-            request.setProtoBuf(GLocRequest.APP_PROFILES, appProfile);
-        }
-
-        // Queue any waiting collection events as well
-        uploadCollectionReport(false);
-
-        ByteArrayOutputStream payload = new ByteArrayOutputStream();
-        try {
-            request.outputTo(payload);
-        } catch (IOException e) {
-            Log.e(TAG, "forwardGeocode(): unable to write request to payload");
-            throw e;
-        }
-
-        // Creates  request and a listener with no callback function
-        ProtoBuf reply = new ProtoBuf(LocserverMessageTypes.GLOC_REPLY);
-        Request plainRequest =
-            new PlainRequest(REQUEST_QUERY_LOC, (short)0, payload.toByteArray());
-        ProtoRequestListener listener = new ProtoRequestListener(reply, null);
-        plainRequest.setListener(listener);
-
-        // Immediately send request and block for response until REQUEST_TIMEOUT
-        MobileServiceMux serviceMux = MobileServiceMux.getSingleton();
-        serviceMux.submitRequest(plainRequest, true);
-        ProtoBuf response;
-        try {
-            response = (ProtoBuf)listener.getAsyncResult().get(REQUEST_TIMEOUT);
-        } catch (InterruptedException e) {
-            Log.e(TAG, "forwardGeocode(): response timeout");
-            throw new IOException("response time-out");
-        }
-
-        if (response == null) {
-            throw new IOException("Unable to parse response from server");
-        }
-
-        // Parse the response
-        int status1 = response.getInt(GLocReply.STATUS);
-        if (status1 != ResponseCodes.STATUS_STATUS_SUCCESS) {
-            Log.e(TAG, "forwardGeocode(): RPC failed with status " + status1);
-            throw new IOException("RPC failed with status " + status1);
-        }
-
-        if (response.has(GLocReply.PLATFORM_KEY)) {
-            String platformKey = response.getString(GLocReply.PLATFORM_KEY);
-            if (!TextUtils.isEmpty(platformKey)) {
-                setPlatformKey(platformKey);
-            }
-        }
-
-        if (!response.has(GLocReply.REPLY_ELEMENTS)) {
-            Log.e(TAG, "forwardGeocode(): no ReplyElement");
-            return;
-        }
-        ProtoBuf replyElement = response.getProtoBuf(GLocReply.REPLY_ELEMENTS);
-
-        int status2 = replyElement.getInt(GLocReplyElement.STATUS);
-        if (status2 != ResponseCodes.STATUS_STATUS_SUCCESS) {
-            Log.e(TAG, "forwardGeocode(): GLS failed with status " + status2);
-            return;
-        }
-
-        if (!replyElement.has(GLocReplyElement.LOCATION)) {
-            Log.e(TAG, "forwardGeocode(): no location in ReplyElement");
-            return;
-        }
-
-        ProtoBuf location = replyElement.getProtoBuf(GLocReplyElement.LOCATION);
-        if (!location.has(GLocation.FEATURE)) {
-            Log.e(TAG, "forwardGeocode(): no feature in GLocation");
-            return;
-        }
-
-        getAddressFromProtoBuf(location, locale, addrs);
-    }
-
-    /**
-     * Queues a location collection request to be sent to the server
-     *
-     * @param trigger what triggered this collection event
-     * @param location last known location
-     * @param cellState cell tower state
-     * @param scanResults list of wifi points
-     * @param scanTime real time at which wifi scan happened
-     * @param immediate true if request should be sent immediately instead of being queued
-     */
-    public synchronized void queueCollectionReport(int trigger, Location location,
-        CellState cellState, List<ScanResult> scanResults, long scanTime, boolean immediate) {
-
-        // Create a RequestElement
-        ProtoBuf requestElement = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST_ELEMENT);
-
-        // Include debug profile
-        ProtoBuf debugProfile = new ProtoBuf(GdebugprofileMessageTypes.GDEBUG_PROFILE);
-        requestElement.setProtoBuf(GLocRequestElement.DEBUG_PROFILE, debugProfile);
-
-        if (mDeviceRestart) {
-            debugProfile.setBool(GDebugProfile.DEVICE_RESTART, true);
-            mDeviceRestart = false;
-        }
-
-        if (trigger != -1) {
-            debugProfile.setInt(GDebugProfile.TRIGGER, trigger);
-            EventLog.writeEvent(COLLECTION_EVENT_LOG_TAG, trigger);            
-        }
-
-        // Include cell profile
-        if (cellState != null && cellState.isValid()) {
-            ProtoBuf cellularProfile = new ProtoBuf(GcellularMessageTypes.GCELLULAR_PROFILE);
-            cellularProfile.setLong(GCellularProfile.TIMESTAMP, cellState.getTime());
-
-            // Primary cell
-            ProtoBuf primaryCell = new ProtoBuf(GcellularMessageTypes.GCELL);
-            primaryCell.setInt(GCell.LAC, cellState.getLac());
-            primaryCell.setInt(GCell.CELLID, cellState.getCid());
-            if ((cellState.getMcc() != -1) && (cellState.getMnc() != -1)) {
-                primaryCell.setInt(GCell.MCC, cellState.getMcc());
-                primaryCell.setInt(GCell.MNC, cellState.getMnc());
-            }
-
-            if (cellState.getSignalStrength() != -1) {
-                primaryCell.setInt(GCell.RSSI, cellState.getSignalStrength());
-            }
-
-            cellularProfile.setProtoBuf(GCellularProfile.PRIMARY_CELL, primaryCell);
-
-            // Cell neighbors
-            addNeighborsToCellProfile(cellState, cellularProfile);
-
-            requestElement.setProtoBuf(GLocRequestElement.CELLULAR_PROFILE, cellularProfile);
-        }
-
-        // Include Wifi profile
-        if (scanResults != null && scanResults.size() > 0) {
-            ProtoBuf wifiProfile = new ProtoBuf(GwifiMessageTypes.GWIFI_PROFILE);
-            wifiProfile.setLong(GWifiProfile.TIMESTAMP, scanTime);
-
-            int count = 0;
-            for (ScanResult s : scanResults) {
-                ProtoBuf wifiDevice = new ProtoBuf(GwifiMessageTypes.GWIFI_DEVICE);
-                wifiDevice.setString(GWifiDevice.MAC, s.BSSID);
-                wifiDevice.setString(GWifiDevice.SSID, s.SSID);
-                wifiDevice.setInt(GWifiDevice.RSSI, s.level);
-                wifiProfile.addProtoBuf(GWifiProfile.WIFI_DEVICES, wifiDevice);
-                count++;
-                if (count >= MAX_WIFI_TO_INCLUDE) {
-                    break;
-                }
-            }
-
-            requestElement.setProtoBuf(GLocRequestElement.WIFI_PROFILE, wifiProfile);
-        }
-
-        // Location information
-        if (location != null) {
-            ProtoBuf latlngElement = new ProtoBuf(GlatlngMessageTypes.GLAT_LNG);
-            latlngElement.setInt(GLatLng.LAT_E7, (int)(location.getLatitude() * E7));
-            latlngElement.setInt(GLatLng.LNG_E7, (int)(location.getLongitude() * E7));
-
-            ProtoBuf locationElement = new ProtoBuf(GlocationMessageTypes.GLOCATION);
-            locationElement.setProtoBuf(GLocation.LAT_LNG, latlngElement);
-            locationElement.setInt(GLocation.LOC_TYPE, GLocation.LOCTYPE_GPS);
-            locationElement.setLong(GLocation.TIMESTAMP, location.getTime());
-            if (location.hasAccuracy()) {
-                locationElement.setInt(GLocation.ACCURACY, (int)location.getAccuracy());
-            }
-            if (location.hasSpeed()) {
-                locationElement.setInt(GLocation.VELOCITY, (int)location.getSpeed());
-            }
-            if (location.hasBearing()) {
-                locationElement.setInt(GLocation.HEADING, (int)location.getBearing());
-            }
-
-            requestElement.setProtoBuf(GLocRequestElement.LOCATION, locationElement);
-        }
-
-        if (mCurrentCollectionRequest == null) {
-            mCurrentCollectionRequest = new ProtoBuf(LocserverMessageTypes.GLOC_REQUEST);
-
-            // Create a Platform Profile
-            ProtoBuf platformProfile = createPlatformProfile();
-            if (cellState != null && cellState.isValid()) {
-                ProtoBuf cellularPlatform = createCellularPlatformProfile(cellState);
-                platformProfile.setProtoBuf(GPlatformProfile.CELLULAR_PLATFORM_PROFILE,
-                    cellularPlatform);
-            }
-
-            mCurrentCollectionRequest.setProtoBuf(GLocRequest.PLATFORM_PROFILE, platformProfile);
-
-        } else {
-
-            ProtoBuf platformProfile =
-                mCurrentCollectionRequest.getProtoBuf(GLocRequest.PLATFORM_PROFILE);
-            if (platformProfile == null) {
-                platformProfile = createPlatformProfile();
-                mCurrentCollectionRequest.setProtoBuf(
-                    GLocRequest.PLATFORM_PROFILE, platformProfile);
-            }
-
-            // Add cellular platform profile is not already included
-            if (platformProfile.getProtoBuf(GPlatformProfile.CELLULAR_PLATFORM_PROFILE) == null &&
-                cellState != null && cellState.isValid()) {
-                ProtoBuf cellularPlatform = createCellularPlatformProfile(cellState);
-                platformProfile.setProtoBuf(GPlatformProfile.CELLULAR_PLATFORM_PROFILE,
-                    cellularPlatform);
-            }
-        }
-
-        mCurrentCollectionRequest.addProtoBuf(GLocRequest.REQUEST_ELEMENTS, requestElement);
-
-        // Immediately upload collection events if buffer exceeds certain size
-        if (mCurrentCollectionRequest.getCount(GLocRequest.REQUEST_ELEMENTS)
-            >= MAX_COLLECTION_BUFFER_SIZE) {
-            immediate = true;
-        }
-
-        if (immediate) {
-            // Request to send over wire
-            uploadCollectionReport(immediate);
-        }
-    }
-
-    /**
-     * Uploads the collection report either immediately or based on MASF's queueing logic.
-     * Does not need a reply back
-     *
-     * @param immediate true if request should be sent immediately instead of being queued
-     */
-    private synchronized void uploadCollectionReport(boolean immediate) {
-        // There may be nothing to upload
-        if (mCurrentCollectionRequest == null ||
-            mCurrentCollectionRequest.getCount(GLocRequest.REQUEST_ELEMENTS) == 0) {
-            return;
-        }
-
-        ByteArrayOutputStream payload = new ByteArrayOutputStream();
-        try {
-            mCurrentCollectionRequest.outputTo(payload);
-        } catch (IOException e) {
-            Log.e(TAG, "uploadCollectionReport(): unable to write request to payload");
-            return;
-        }
-
-        mLastCollectionUploadTime = SystemClock.elapsedRealtime();
-
-        // Since this has already been written to the wire, we can clear this request
-        int count = mCurrentCollectionRequest.getCount(GLocRequest.REQUEST_ELEMENTS);
-        while (count > 0) {
-            mCurrentCollectionRequest.remove(GLocRequest.REQUEST_ELEMENTS, count - 1);
-            count--;
-        }
-
-        // Creates  request and a listener with a call back function
-        ProtoBuf reply = new ProtoBuf(LocserverMessageTypes.GLOC_REPLY);
-        Request plainRequest =
-            new PlainRequest(REQUEST_UPLOAD_LOC, (short)0, payload.toByteArray());
-
-        ProtoRequestListener listener = new ProtoRequestListener(reply, new ServiceCallback() {
-            public void onRequestComplete(Object result) {
-                ProtoBuf response = (ProtoBuf) result;
-
-                if (response == null) {
-                    Log.e(TAG, "uploadCollectionReport(): response is null");
-                    return;
-                }
-
-                int status1 = response.getInt(GLocReply.STATUS);
-                if (status1 != ResponseCodes.STATUS_STATUS_SUCCESS) {
-                    Log.w(TAG, "uploadCollectionReport(): RPC failed with status " + status1);
-                    return;
-                }
-
-                if (response.has(GLocReply.PLATFORM_KEY)) {
-                    String platformKey = response.getString(GLocReply.PLATFORM_KEY);
-                    if (!TextUtils.isEmpty(platformKey)) {
-                        setPlatformKey(platformKey);
-                    }
-                }
-
-                if (!response.has(GLocReply.REPLY_ELEMENTS)) {
-                    Log.w(TAG, "uploadCollectionReport(): no ReplyElement");
-                    return;
-                }
-
-                int count = response.getCount(GLocReply.REPLY_ELEMENTS);
-                for (int i = 0; i < count; i++) {
-                    ProtoBuf replyElement = response.getProtoBuf(GLocReply.REPLY_ELEMENTS, i);
-                    int status2 = replyElement.getInt(GLocReplyElement.STATUS);
-                    if (status2 != ResponseCodes.STATUS_STATUS_SUCCESS) {
-                        Log.w(TAG, "uploadCollectionReport(): GLS failed with " + status2);
-                    }
-                }
-
-            }
-        });
-        plainRequest.setListener(listener);
-
-        // Send request
-        MobileServiceMux serviceMux = MobileServiceMux.getSingleton();
-        serviceMux.submitRequest(plainRequest, immediate);
-
-    }
-
-    private String getPlatformKey() {
-        if (mPlatformKey != null) {
-            return mPlatformKey;
-        }
-
-        try {
-            File file = new File(LocationManager.SYSTEM_DIR, PLATFORM_KEY_FILE);
-            FileInputStream istream = new FileInputStream(file);
-            DataInputStream dataInput = new DataInputStream(istream);
-            String platformKey = dataInput.readUTF();
-            dataInput.close();
-            mPlatformKey = platformKey;
-            return mPlatformKey;
-        } catch(FileNotFoundException e) {
-            // No file, just ignore
-            return null;
-        } catch(IOException e) {
-            // Unable to read from file, just ignore
-            return null;
-        }
-    }
-
-    private void setPlatformKey(String platformKey) {
-        File systemDir = new File(LocationManager.SYSTEM_DIR);
-        if (!systemDir.exists()) {
-            if (!systemDir.mkdirs()) {
-                Log.w(TAG, "setPlatformKey(): couldn't create directory");
-                return;
-            }
-        }
-
-        try {
-            File file = new File(LocationManager.SYSTEM_DIR, PLATFORM_KEY_FILE);
-            FileOutputStream ostream = new FileOutputStream(file);
-            DataOutputStream dataOut = new DataOutputStream(ostream);
-            dataOut.writeUTF(platformKey);
-            dataOut.close();
-            mPlatformKey = platformKey;
-        } catch (FileNotFoundException e) {
-            Log.w(TAG, "setPlatformKey(): unable to create platform key file");
-        } catch (IOException e) {
-            Log.w(TAG, "setPlatformKey(): unable to write to platform key");
-        }
-    }
-
-    private ProtoBuf createPlatformProfile() {
-        Locale locale = Locale.getDefault();
-        return createPlatformProfile(locale);
-    }
-
-    private ProtoBuf createPlatformProfile(Locale locale) {
-        if (mPlatformProfile == null) {
-            mPlatformProfile = new ProtoBuf(GlocationMessageTypes.GPLATFORM_PROFILE);
-            mPlatformProfile.setString(GPlatformProfile.VERSION, APPLICATION_VERSION);
-            mPlatformProfile.setString(GPlatformProfile.PLATFORM, PLATFORM_BUILD);
-        }
-
-        // Add Locale
-        if ((locale != null) && (locale.toString() != null)) {
-            mPlatformProfile.setString(GPlatformProfile.LOCALE, locale.toString());
-        }
-
-        // Add Platform Key
-        String platformKey = getPlatformKey();
-        if (!TextUtils.isEmpty(platformKey)) {
-            mPlatformProfile.setString(GPlatformProfile.PLATFORM_KEY, platformKey);
-        }
-
-        // Clear out cellular platform profile
-        mPlatformProfile.setProtoBuf(GPlatformProfile.CELLULAR_PLATFORM_PROFILE, null);
-
-        return mPlatformProfile;
-    }
-
-    private ProtoBuf createCellularPlatformProfile(CellState cellState) {
-        // Radio type
-        int radioType = -1;
-        if (cellState.getRadioType() == CellState.RADIO_TYPE_GPRS) {
-            radioType = GCellularPlatformProfile.RADIO_TYPE_GPRS;
-        } else if (cellState.getRadioType() == CellState.RADIO_TYPE_CDMA) {
-            radioType = GCellularPlatformProfile.RADIO_TYPE_CDMA;
-        } else if (cellState.getRadioType() == CellState.RADIO_TYPE_WCDMA) {
-            radioType = GCellularPlatformProfile.RADIO_TYPE_WCDMA;
-        }
-
-        if (mCellularPlatformProfile == null) {
-            mCellularPlatformProfile =
-                new ProtoBuf(GlocationMessageTypes.GCELLULAR_PLATFORM_PROFILE);
-        }
-
-        mCellularPlatformProfile.setInt(GCellularPlatformProfile.RADIO_TYPE, radioType);
-        if ((cellState.getHomeMcc() != -1) && (cellState.getHomeMnc() != -1)) {
-            mCellularPlatformProfile.setInt(GCellularPlatformProfile.HOME_MCC,
-                cellState.getHomeMcc());
-            mCellularPlatformProfile.setInt(GCellularPlatformProfile.HOME_MNC,
-                cellState.getHomeMnc());
-        }
-        if (cellState.getCarrier() != null) {
-            mCellularPlatformProfile.setString(GCellularPlatformProfile.CARRIER,
-                cellState.getCarrier());
-        }
-        
-        return mCellularPlatformProfile;
-    }
-
-    private void getAddressFromProtoBuf(ProtoBuf location, Locale locale, List<Address> addrs) {
-
-        double lat = -1;
-        double lng = -1;
-
-        if (location.has(GLocation.LAT_LNG)) {
-            ProtoBuf latlng = location.getProtoBuf(GLocation.LAT_LNG);
-            lat = latlng.getInt(GLatLng.LAT_E7)/E7;
-            lng = latlng.getInt(GLatLng.LNG_E7)/E7;
-        }
-
-        for (int a = 0; a < location.getCount(GLocation.FEATURE); a++) {
-
-            Address output = new Address(locale);
-
-            ProtoBuf feature = location.getProtoBuf(GLocation.FEATURE, a);
-            output.setFeatureName(feature.getString(GFeature.NAME));
-
-            if (feature.has(GFeature.CENTER)) {
-                ProtoBuf center = feature.getProtoBuf(GFeature.CENTER);
-                output.setLatitude(center.getInt(GLatLng.LAT_E7)/E7);
-                output.setLongitude(center.getInt(GLatLng.LNG_E7)/E7);
-
-            } else if (location.has(GLocation.LAT_LNG)) {
-                output.setLatitude(lat);
-                output.setLongitude(lng);
-            }
-
-            ProtoBuf address = feature.getProtoBuf(GFeature.ADDRESS);
-
-            for (int i = 0; i < address.getCount(GAddress.FORMATTED_ADDRESS_LINE); i++) {
-                String line = address.getString(GAddress.FORMATTED_ADDRESS_LINE, i);
-                output.setAddressLine(i, line);
-            }
-
-            for (int i = 0; i < address.getCount(GAddress.COMPONENT); i++) {
-                ProtoBuf component = address.getProtoBuf(GAddress.COMPONENT, i);
-                int type = component.getInt(GAddressComponent.FEATURE_TYPE);
-                String name = component.getString(GAddressComponent.NAME);
-
-                switch(type) {
-                    case GFeature.FEATURE_TYPE_ADMINISTRATIVE_AREA :
-                        output.setAdminArea(name);
-                        break;
-
-                    case GFeature.FEATURE_TYPE_SUB_ADMINISTRATIVE_AREA :
-                        output.setSubAdminArea(name);
-                        break;
-
-                    case GFeature.FEATURE_TYPE_LOCALITY :
-                        output.setLocality(name);
-                        break;
-
-                    case GFeature.FEATURE_TYPE_THOROUGHFARE :
-                        output.setThoroughfare(name);
-                        break;
-
-                    case GFeature.FEATURE_TYPE_POST_CODE :
-                        output.setPostalCode(name);
-                        break;
-
-                    case GFeature.FEATURE_TYPE_COUNTRY :
-                        output.setCountryName(name);
-                        break;
-
-                    case GFeature.FEATURE_TYPE_COUNTRY_CODE :
-                        output.setCountryCode(name);
-                        break;
-
-                    default :
-                        if (android.util.Config.LOGD) {
-                        Log.d(TAG, "getAddressFromProtoBuf(): Ignore feature " + type + "," + name);
-                        }
-                        break;
-                }
-            }
-
-            addrs.add(output);
-        }
-    }
-
-    private void addNeighborsToCellProfile(CellState cellState, ProtoBuf cellularProfile) {
-        List<CellState.NeighborCell> neighbors = cellState.getNeighbors();
-
-        int mPrimaryMcc = cellState.getMcc();
-        int mPrimaryMnc = cellState.getMnc();
-
-        if (neighbors != null) {
-            for (CellState.NeighborCell neighbor : neighbors) {
-                ProtoBuf nCell = new ProtoBuf(GcellularMessageTypes.GCELL);
-                nCell.setInt(GCell.CELLID, neighbor.getCid());
-                nCell.setInt(GCell.LAC, neighbor.getLac());
-                nCell.setInt(GCell.RSSI, neighbor.getRssi());
-                if (neighbor.getPsc() != -1) {
-                    nCell.setInt(GCell.PRIMARY_SCRAMBLING_CODE, neighbor.getPsc());
-                }
-                if (mPrimaryMcc != -1) {
-                    nCell.setInt(GCell.MCC, mPrimaryMcc);
-                }
-                if (mPrimaryMnc != -1) {
-                    nCell.setInt(GCell.MNC, mPrimaryMnc);
-                }
-                cellularProfile.addProtoBuf(GCellularProfile.NEIGHBORS, nCell);
-            }
-        }
-    }
-
-}
diff --git a/location/java/com/android/internal/location/NetworkLocationProvider.java b/location/java/com/android/internal/location/NetworkLocationProvider.java
deleted file mode 100644
index d0a59b9..0000000
--- a/location/java/com/android/internal/location/NetworkLocationProvider.java
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location;
-
-import com.android.internal.location.protocol.GDebugProfile;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-
-import android.content.Context;
-import android.location.Criteria;
-import android.location.Location;
-import android.location.LocationManager;
-import android.location.LocationProviderImpl;
-import android.net.wifi.ScanResult;
-import android.net.wifi.WifiManager;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.os.SystemProperties;
-import android.util.Log;
-
-/**
- * A location provider which gets approximate location from Google's
- * database of cell-tower and wi-fi locations.
- *
- * <p> It is the responsibility of the LocationManagerService to
- * notify this class of any changes in the radio information
- * by calling {@link #updateCellState} and of data state
- * changes by calling {@link #updateNetworkState}
- *
- * <p> The LocationManagerService must also notify the provider
- * of Wifi updates using the {@link #updateWifiScanResults}
- * and {@link #updateWifiEnabledState}
- * methods.
- *
- * <p> The provider uses whichever radio is available - Cell
- * or WiFi. If neither is available, it does NOT attempt to
- * switch them on.
- *
- * {@hide}
- */
-public class NetworkLocationProvider extends LocationProviderImpl {
-    private static final String TAG = "NetworkLocationProvider";
-
-    // Wait at least 60 seconds between network queries
-    private static final int MIN_NETWORK_RETRY_MILLIS = 60000;
-
-    // Max time to wait for radio update
-    private static final long MAX_TIME_TO_WAIT_FOR_RADIO = 5 * 1000; // 5 seconds
-
-    // State of entire provider
-    private int mStatus = AVAILABLE;
-    private long mStatusUpdateTime = 0;
-
-    // Network state
-    private int mNetworkState = TEMPORARILY_UNAVAILABLE;
-
-    // Cell state
-    private static final int MAX_CELL_HISTORY_TO_KEEP = 4;
-    private LinkedList<CellState> mCellHistory = new LinkedList<CellState>();
-    private CellState mCellState = null;
-    private long mLastCellStateChangeTime = 0;
-    private long mLastCellLockTime = 0;
-
-    // Wifi state
-    private static final long MIN_TIME_BETWEEN_WIFI_REPORTS = 45 * 1000; // 45 seconds
-    private List<ScanResult> mWifiLastScanResults = null;
-    private long mLastWifiScanTriggerTime = 0;
-    private long mLastWifiScanElapsedTime = 0;
-    private long mLastWifiScanRealTime = 0;
-    private long mWifiScanFrequency = MIN_TIME_BETWEEN_WIFI_REPORTS;
-    private boolean mWifiEnabled = false;
-
-    // Last known location state
-    private Location mLocation = new Location(LocationManager.NETWORK_PROVIDER);
-    private long mLastNetworkQueryTime = 0;  // Last network request, successful or not
-    private long mLastSuccessfulNetworkQueryTime = 0; // Last successful network query time
-
-    // Is provider enabled by user -- ignored by this class
-    private boolean mEnabled;
-
-    // Is provider being used by an application
-    private HashSet<String> mApplications = new HashSet<String>();
-    private boolean mTracking = false;
-
-    // Location masf service
-    private LocationMasfClient mMasfClient;
-
-    // Context of location manager service
-    private Context mContext;
-
-    public static boolean isSupported() {
-        // This class provides a Google-specific location feature, so it's enabled only
-        // when the system property ro.com.google.locationfeatures  is set.
-        if (!SystemProperties.get("ro.com.google.locationfeatures").equals("1")) {
-            return false;
-        }
-
-        // Otherwise, assume cell location should work if we are not running in the emulator
-        return !SystemProperties.get("ro.kernel.qemu").equals("1");
-    }
-
-    public NetworkLocationProvider(Context context, LocationMasfClient masfClient) {
-        super(LocationManager.NETWORK_PROVIDER);
-        mContext = context;
-        mMasfClient = masfClient;
-    }
-
-    @Override
-    public void updateNetworkState(int state) {
-        if (state == mNetworkState) {
-            return;
-        }
-        log("updateNetworkState(): Updating network state to " + state);
-        mNetworkState = state;
-
-        updateStatus(mNetworkState);
-    }
-
-    @Override
-    public void updateCellState(CellState newState) {
-        if (newState == null) {
-            log("updateCellState(): Cell state is invalid");
-            return;
-        }
-
-        if (mCellState != null && mCellState.equals(newState)) {
-            log("updateCellState(): Cell state is the same");
-            return;
-        }
-
-        // Add previous state to history
-        if ((mCellState != null) && mCellState.isValid()) {
-            if (mCellHistory.size() >= MAX_CELL_HISTORY_TO_KEEP) {
-                mCellHistory.remove(0);
-            }
-            mCellHistory.add(mCellState);
-        }
-
-        mCellState = newState;
-        log("updateCellState(): Received");
-
-        mLastCellLockTime = 0;        
-        mLastCellStateChangeTime = SystemClock.elapsedRealtime();
-    }
-
-    public void updateCellLockStatus(boolean acquired) {
-        if (acquired) {
-            mLastCellLockTime = SystemClock.elapsedRealtime();
-        } else {
-            mLastCellLockTime = 0;
-        }
-    }
-
-    @Override
-    public boolean requiresNetwork() {
-        return true;
-    }
-
-    @Override
-    public boolean requiresSatellite() {
-        return false;
-    }
-
-    @Override
-    public boolean requiresCell() {
-        return true;
-    }
-
-    @Override
-    public boolean hasMonetaryCost() {
-        return true;
-    }
-
-    @Override
-    public boolean supportsAltitude() {
-        return false;
-    }
-
-    @Override
-    public boolean supportsSpeed() {
-        return false;
-    }
-
-    @Override
-    public boolean supportsBearing() {
-        return false;
-    }
-
-    @Override
-    public int getPowerRequirement() {
-        return Criteria.POWER_LOW;
-    }
-
-    @Override
-    public void enable() {
-        // Nothing else needs to be done
-        mEnabled = true;
-    }
-
-    @Override
-    public void disable() {
-        // Nothing else needs to be done
-        mEnabled = false;
-    }
-
-    @Override
-    public boolean isEnabled() {
-        return mEnabled;
-    }
-
-    @Override
-    public int getAccuracy() {
-        return Criteria.ACCURACY_COARSE;
-    }
-
-    @Override
-    public int getStatus(Bundle extras) {
-        return mStatus;
-    }
-
-    @Override
-    public long getStatusUpdateTime() {
-        return mStatusUpdateTime;
-    }
-
-    @Override
-    public void setMinTime(long minTime) {
-        if (minTime < MIN_TIME_BETWEEN_WIFI_REPORTS) {
-            mWifiScanFrequency = MIN_TIME_BETWEEN_WIFI_REPORTS;
-        } else {
-            mWifiScanFrequency = minTime;
-        }
-        super.setMinTime(minTime);
-    }
-
-    @Override
-    public boolean getLocation(Location l) {
-
-        long now = SystemClock.elapsedRealtime();
-
-        // Trigger a wifi scan and wait for its results if necessary
-        if ((mWifiEnabled) &&
-            (mWifiLastScanResults == null ||
-                ((now - mLastWifiScanElapsedTime) > mWifiScanFrequency))) {
-
-            boolean fallback = false;
-
-            // If scan has been recently triggered
-            if (mLastWifiScanTriggerTime != 0 &&
-                ((now - mLastWifiScanTriggerTime) < mWifiScanFrequency)) {
-                if ((now - mLastWifiScanTriggerTime) > MAX_TIME_TO_WAIT_FOR_RADIO) {
-                    // If no results from last trigger available, use cell results
-                    // This will also trigger a new scan
-                    log("getLocation(): falling back to cell");
-                    fallback = true;
-                } else {
-                    // Just wait for the Wifi results to be available
-                    return false;
-                }
-            }
-
-            WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
-            log("getLocation(): triggering a wifi scan");
-            mLastWifiScanTriggerTime = now;
-            boolean succeeded = wifiManager.startScan();
-            if (!succeeded) {
-                log("getLocation(): wifi scan did not succeed");
-                // Wifi trigger failed, use cell results
-                fallback = true;
-            }
-
-            // Wait for scan results
-            if (!fallback) {
-                return false;
-            }
-        }
-
-        // If waiting for cell location
-        if (mLastCellLockTime != 0 && ((now - mLastCellLockTime) < MAX_TIME_TO_WAIT_FOR_RADIO)) {
-            return false;
-        }
-
-        // Update Location
-        // 1) If there has been a cell state change
-        // 2) If there was no successful reply for last network request
-        if (mLastCellStateChangeTime > mLastNetworkQueryTime) {
-            updateLocation();
-            return false;
-
-        } else if ((mLastNetworkQueryTime != 0)
-            && (mLastNetworkQueryTime > mLastSuccessfulNetworkQueryTime)
-            && ((now - mLastNetworkQueryTime) > MIN_NETWORK_RETRY_MILLIS)) {
-            updateLocation();
-            return false;
-        }
-
-        if (mLocation != null && mLocation.getAccuracy() > 0) {
-            
-            // We could have a Cell Id location which hasn't changed in a
-            // while because we haven't switched towers so if the last location
-            // time + mWifiScanFrequency is less than current time update the 
-            // locations time.
-            long currentTime = System.currentTimeMillis();
-            if ((mLocation.getTime() + mWifiScanFrequency) < currentTime) {
-                mLocation.setTime(currentTime);
-            }
-            l.set(mLocation);
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    @Override
-    public void enableLocationTracking(boolean enable) {
-        if (enable == mTracking) {
-            return;
-        }
-
-        log("enableLocationTracking(): " + enable);
-        mTracking = enable;
-
-        if (!enable) {
-            // When disabling the location provider, be sure to clear out old location
-            clearLocation();
-        } else {
-            // When enabling provider, force location
-            forceLocation();
-        }
-    }
-
-    @Override
-    public boolean isLocationTracking() {
-        return mTracking;
-    }
-
-    /**
-     * Notifies the provider that there are scan results available.
-     *
-     * @param scanResults list of wifi scan results
-     */
-    public void updateWifiScanResults(List<ScanResult> scanResults) {
-        if (!mTracking) {
-            return;
-        }
-
-        long now = SystemClock.elapsedRealtime();
-
-        if (scanResults == null) {
-            mWifiLastScanResults = null;
-            mLastWifiScanElapsedTime = now;
-            mLastWifiScanRealTime = System.currentTimeMillis();
-
-            log("updateWifIScanResults(): NULL APs");
-
-            // Force cell location since no wifi results available
-            if (mWifiEnabled) {
-                mLastCellLockTime = 0;
-                mLastCellStateChangeTime = SystemClock.elapsedRealtime();
-            }
-
-        } else if ((mWifiLastScanResults == null)
-            || (mWifiLastScanResults.size() <= 2 && scanResults.size() > mWifiLastScanResults.size()) 
-            || ((now - mLastWifiScanElapsedTime) > mWifiScanFrequency)) {
-
-            if (mWifiLastScanResults == null) {
-                mWifiLastScanResults = new ArrayList<ScanResult>();
-            } else {
-                mWifiLastScanResults.clear();
-            }
-            mWifiLastScanResults.addAll(scanResults);
-            mLastWifiScanElapsedTime = now;
-            mLastWifiScanRealTime = System.currentTimeMillis();
-
-            log("updateWifIScanResults(): " + mWifiLastScanResults.size() + " APs");
-            updateLocation();
-
-        }
-    }
-
-    /**
-     * Notifies the provider if Wifi has been enabled or disabled
-     * by the user
-     *
-     * @param enabled true if wifi is enabled; false otherwise
-     */
-    public void updateWifiEnabledState(boolean enabled) {
-        mWifiEnabled = enabled;
-
-        log("updateWifiEnabledState(): " + enabled);
-
-        // Force location update
-        forceLocation();
-    }
-    
-    public void addListener(String[] applications) {
-        if (applications != null) {
-            for (String app : applications) {
-                String a = app.replaceAll("com.google.android.", "");
-                a = a.replaceAll("com.android.", "");
-                mApplications.add(a);
-                log("addListener(): " + a);
-            }
-        }
-    }
-
-    public void removeListener(String[] applications) {
-        if (applications != null) {
-            for (String app : applications) {
-                String a = app.replaceAll("com.google.android.", "");
-                a = a.replaceAll("com.android.", "");
-                mApplications.remove(a);
-                log("removeListener(): " + a);
-            }
-        }
-    }
-
-    private void clearLocation() {
-        mLocation.setAccuracy(-1);
-        updateStatus(TEMPORARILY_UNAVAILABLE);
-    }
-
-    private void forceLocation() {
-        if (mWifiEnabled) {
-            // Force another wifi scan
-            mWifiLastScanResults = null;
-            mLastWifiScanTriggerTime = 0;
-            mLastWifiScanElapsedTime = 0;
-            mLastWifiScanRealTime = 0;
-        } else {
-            // Force another cell location request
-            mLastCellLockTime = 0;
-            mLastCellStateChangeTime = SystemClock.elapsedRealtime();
-        }
-    }
-
-    private void updateStatus(int status) {
-        if (status != mStatus) {
-            mStatus = status;
-            mStatusUpdateTime = SystemClock.elapsedRealtime();
-        }
-    }
-
-    /**
-     * Gets location from the server is applications are tracking this provider
-     *
-     */
-    private void updateLocation() {
-
-        // If not being tracked, no need to do anything.
-        if (!mTracking) {
-            return;
-        }
-
-        // If network is not available, can't do anything
-        if (mNetworkState != AVAILABLE) {
-            return;
-        }
-
-        final long now = SystemClock.elapsedRealtime();
-        
-        // There is a pending network request
-        if ((mLastNetworkQueryTime != 0) &&
-            (mLastNetworkQueryTime > mLastSuccessfulNetworkQueryTime) &&
-            ((now - mLastNetworkQueryTime) <= MIN_NETWORK_RETRY_MILLIS)) {
-            return;
-        }
-
-        // Don't include wifi points if they're too old
-        List<ScanResult> scanResults = null;
-        if (mWifiEnabled && (mWifiLastScanResults != null &&
-            ((now - mLastWifiScanElapsedTime) < (mWifiScanFrequency + MAX_TIME_TO_WAIT_FOR_RADIO)))) {
-            scanResults = mWifiLastScanResults;
-        }
-
-        // If no valid cell information available
-        boolean noCell = mCellState == null || !mCellState.isValid();
-
-        // If no valid wifi information available
-        boolean noWifi = scanResults == null || (scanResults.size() == 0);
-
-        // If no cell-id or wi-fi update, just return invalid location
-        if (noCell && noWifi) {
-            clearLocation();
-            return;
-        }
-
-        // What kind of a network location request was it
-        int trigger;
-        if (!mWifiEnabled) {
-            if (!noCell) {
-                trigger = GDebugProfile.TRIGGER_CELL_AND_WIFI_CHANGE;
-            } else {
-                trigger = GDebugProfile.TRIGGER_WIFI_CHANGE;
-            }
-        } else {
-            trigger = GDebugProfile.TRIGGER_CELL_CHANGE;
-        }
-
-        try {
-            mLastNetworkQueryTime = now;
-            mMasfClient.getNetworkLocation(mApplications, trigger, mCellState, mCellHistory,
-                scanResults, mLastWifiScanRealTime, new Callback() {
-                public void locationReceived(Location location, boolean networkSuccessful) {
-                    // If location is valid and not the same as previously known location
-                    if ((location != null) && (location.getAccuracy() > 0) &&
-                        (location.getTime() != mLocation.getTime())) {
-                        mLocation.set(location);
-                        updateStatus(AVAILABLE);
-                    } else {
-                        // Location is unavailable
-                        clearLocation();
-                    } 
-
-                    // Even if no location is available, network request could have succeeded
-                    if (networkSuccessful) {
-                        mLastSuccessfulNetworkQueryTime = SystemClock.elapsedRealtime();
-                    }
-
-                }
-            });
-        } catch(Exception e) {
-            Log.e(TAG, "updateLocation got exception:", e);
-        }
-    }
-
-    public interface Callback {
-
-        /**
-         * Callback function to notify of a received network location
-         *
-         * @param location location object that is received. may be null if not a valid location
-         * @param successful true if network query was successful, even if no location was found
-         */
-        void locationReceived(Location location, boolean successful);
-    }
-
-    private void log(String log) {
-        if (Log.isLoggable(TAG, Log.DEBUG)) {
-            Log.d(TAG, log);
-        }
-    }
-
-}
diff --git a/location/java/com/android/internal/location/ProtoRequestListener.java b/location/java/com/android/internal/location/ProtoRequestListener.java
deleted file mode 100644
index d73cd05..0000000
--- a/location/java/com/android/internal/location/ProtoRequestListener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-package com.android.internal.location;
-
-import com.google.common.io.GoogleHttpConnection;
-import com.google.common.io.protocol.ProtoBuf;
-import com.google.masf.ServiceCallback;
-import com.google.masf.protocol.Request;
-import com.google.masf.protocol.Response;
-import com.google.masf.services.AsyncResult;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import android.util.Log;
-
-/**
- * Listener for protocol buffer requests
- *
- * {@hide}
- */
-
-public class ProtoRequestListener implements Request.Listener {
-    private final static String TAG = "ProtoRequestListener";
-    private AsyncResult result;
-    private ProtoBuf protoResponse;
-
-    /**
-     * @return the asynchronous result object
-     */
-    public AsyncResult getAsyncResult() {
-        return result;
-    }
-
-    /**
-     * Constructor for a ProtoRequestListener
-     *
-     * @param protoResponse ProtoBuf with correct type to fill response with
-     * @param callback function to call after completed request (may be null)
-     */
-    public ProtoRequestListener(ProtoBuf protoResponse, ServiceCallback callback) {
-        this.result = new AsyncResult(callback);
-        this.protoResponse = protoResponse;
-    }
-
-    public boolean requestComplete(Request request, Response response)
-        throws IOException {
-        InputStream is = response.getInputStream();
-        if (response.getStatusCode() == GoogleHttpConnection.HTTP_OK) {
-            protoResponse.parse(is);
-            result.setResult(protoResponse);
-        } else {
-            result.setResult(null);
-        }
-        return true;
-    }
-
-    public void requestException(Request request, Exception exception) {
-        Log.e(TAG, "requestException()", exception);
-    }
-}
diff --git a/location/java/com/android/internal/location/protocol/GAddress.java b/location/java/com/android/internal/location/protocol/GAddress.java
deleted file mode 100644
index 86a3912..0000000
--- a/location/java/com/android/internal/location/protocol/GAddress.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GAddress {
-  static final int FORMATTED_ADDRESS_LINE = 1;
-  static final int COMPONENT = 2;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GAddressComponent.java b/location/java/com/android/internal/location/protocol/GAddressComponent.java
deleted file mode 100644
index a06a23d..0000000
--- a/location/java/com/android/internal/location/protocol/GAddressComponent.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GAddressComponent {
-  static final int NAME = 1;
-  static final int FEATURE_TYPE = 2;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GAppProfile.java b/location/java/com/android/internal/location/protocol/GAppProfile.java
deleted file mode 100644
index e3332eb..0000000
--- a/location/java/com/android/internal/location/protocol/GAppProfile.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GAppProfile {
-  static final int APP_NAME = 1;
-  static final int APP_KEY = 2;
-  static final int REQUEST_TYPE = 3;
-  static final int SEARCH_TYPE = 4;
-  static final int SEARCH_TERM = 5;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GCell.java b/location/java/com/android/internal/location/protocol/GCell.java
deleted file mode 100644
index 21d1c48..0000000
--- a/location/java/com/android/internal/location/protocol/GCell.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GCell {
-  static final int LAC = 1;
-  static final int CELLID = 2;
-  static final int MNC = 3;
-  static final int MCC = 4;
-  static final int RSSI = 5;
-  static final int AGE = 6;
-  static final int TIMING_ADVANCE = 7;
-  static final int PRIMARY_SCRAMBLING_CODE = 8;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GCellularPlatformProfile.java b/location/java/com/android/internal/location/protocol/GCellularPlatformProfile.java
deleted file mode 100644
index a17da20..0000000
--- a/location/java/com/android/internal/location/protocol/GCellularPlatformProfile.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GCellularPlatformProfile {
-  static final int RADIO_TYPE_GPRS = 3;
-  static final int RADIO_TYPE_CDMA = 4;
-  static final int RADIO_TYPE_WCDMA = 5;
-
-  static final int RADIO_TYPE = 1;
-  static final int CARRIER = 2;
-  static final int IP = 3;
-  static final int HOME_MNC = 4;
-  static final int HOME_MCC = 5;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GCellularProfile.java b/location/java/com/android/internal/location/protocol/GCellularProfile.java
deleted file mode 100644
index 8c85bf7..0000000
--- a/location/java/com/android/internal/location/protocol/GCellularProfile.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GCellularProfile {
-  static final int PRIMARY_CELL = 1;
-  static final int TIMESTAMP = 2;
-  static final int NEIGHBORS = 3;
-  static final int HISTORICAL_CELLS = 4;
-  static final int PREFETCH_MODE = 5;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GDebugProfile.java b/location/java/com/android/internal/location/protocol/GDebugProfile.java
deleted file mode 100644
index b964387..0000000
--- a/location/java/com/android/internal/location/protocol/GDebugProfile.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GDebugProfile {
-  static final int TRIGGER_CELL_CHANGE = 1;
-  static final int TRIGGER_WIFI_CHANGE = 2;
-  static final int TRIGGER_CELL_AND_WIFI_CHANGE = 3;
-  static final int TRIGGER_GPS_CHANGE = 4;
-  static final int TRIGGER_OTHER = 5;
-  static final int TRIGGER_COLLECTION_START_BURST = 6;
-  static final int TRIGGER_COLLECTION_RESTART_BURST = 7;
-  static final int TRIGGER_COLLECTION_CONTINUE_BURST = 8;
-  static final int TRIGGER_COLLECTION_END_BURST = 9;
-  static final int TRIGGER_COLLECTION_END_BURST_AT_SAME_LOCATION = 10;
-  static final int TRIGGER_COLLECTION_MOVED_DISTANCE = 11;
-
-  static final int TRIGGER = 1;
-  static final int ACTUAL_REQUEST = 2;
-  static final int CACHE_LOCATION = 3;
-  static final int DEVICE_RESTART = 4;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GDeviceLocation.java b/location/java/com/android/internal/location/protocol/GDeviceLocation.java
deleted file mode 100644
index 462ab07..0000000
--- a/location/java/com/android/internal/location/protocol/GDeviceLocation.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GDeviceLocation {
-  static final int LOCATION = 1;
-  static final int CELL = 2;
-  static final int WIFI_DEVICE = 3;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GFeature.java b/location/java/com/android/internal/location/protocol/GFeature.java
deleted file mode 100644
index 73fc1b3..0000000
--- a/location/java/com/android/internal/location/protocol/GFeature.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GFeature {
-  static final int NAME = 1;
-  static final int FEATURE_TYPE = 2;
-  static final int ADDRESS = 3;
-  static final int BOUNDS = 4;
-  static final int CENTER = 5;
-
-  static final int FEATURE_TYPE_UNKNOWN_TYPE = 0;
-  static final int FEATURE_TYPE_COUNTRY = 1;
-  static final int FEATURE_TYPE_COUNTRY_CODE = 2;
-  static final int FEATURE_TYPE_ADMINISTRATIVE_AREA = 3;
-  static final int FEATURE_TYPE_SUB_ADMINISTRATIVE_AREA = 4;
-  static final int FEATURE_TYPE_LOCALITY = 5;
-  static final int FEATURE_TYPE_SUB_LOCALITY = 6;
-  static final int FEATURE_TYPE_PREMISES = 7;
-  static final int FEATURE_TYPE_THOROUGHFARE = 8;
-  static final int FEATURE_TYPE_SUB_THOROUGHFARE = 9;
-  static final int FEATURE_TYPE_POST_CODE = 10;    
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GGeocodeRequest.java b/location/java/com/android/internal/location/protocol/GGeocodeRequest.java
deleted file mode 100644
index 4d56cc0..0000000
--- a/location/java/com/android/internal/location/protocol/GGeocodeRequest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GGeocodeRequest {
-  static final int NUM_FEATURE_LIMIT = 1;
-  static final int INCLUDE_BOUNDING_BOXES = 2;
-  static final int BOUNDING_BOX = 3;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GGpsProfile.java b/location/java/com/android/internal/location/protocol/GGpsProfile.java
deleted file mode 100644
index be69eb0..0000000
--- a/location/java/com/android/internal/location/protocol/GGpsProfile.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GGpsProfile {
-  static final int FIX_QUALITY_INVALID = 0;
-  static final int FIX_QUALITY_GPS_FIX = 1;
-  static final int FIX_QUALITY_DGPS_FIX = 2;
-
-  static final int GPS_FIX_TYPE = 1;
-  static final int PDOP = 2;
-  static final int HDOP = 3;
-  static final int VDOP = 4;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GLocReply.java b/location/java/com/android/internal/location/protocol/GLocReply.java
deleted file mode 100644
index 7a0504f..0000000
--- a/location/java/com/android/internal/location/protocol/GLocReply.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GLocReply {
-  static final int STATUS = 1;
-  static final int REPLY_ELEMENTS = 2;
-  static final int PLATFORM_KEY = 3;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GLocReplyElement.java b/location/java/com/android/internal/location/protocol/GLocReplyElement.java
deleted file mode 100644
index bc47fcf..0000000
--- a/location/java/com/android/internal/location/protocol/GLocReplyElement.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GLocReplyElement {
-  static final int STATUS = 1;
-  static final int LOCATION = 2;
-  static final int DEVICE_LOCATION = 3;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GLocRequest.java b/location/java/com/android/internal/location/protocol/GLocRequest.java
deleted file mode 100644
index 7761c11..0000000
--- a/location/java/com/android/internal/location/protocol/GLocRequest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GLocRequest {
-  static final int PLATFORM_PROFILE = 1;
-  static final int APP_PROFILES = 2;
-  static final int USER_PROFILE = 3;
-  static final int REQUEST_ELEMENTS = 4;
-  static final int MASF_CLIENT_INFO = 257;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GLocRequestElement.java b/location/java/com/android/internal/location/protocol/GLocRequestElement.java
deleted file mode 100644
index d758953..0000000
--- a/location/java/com/android/internal/location/protocol/GLocRequestElement.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GLocRequestElement {
-  static final int CELLULAR_PROFILE = 1;
-  static final int WIFI_PROFILE = 2;
-  static final int LOCATION = 3;
-  static final int GEOCODE = 4;
-  static final int DEBUG_PROFILE = 99;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GLocation.java b/location/java/com/android/internal/location/protocol/GLocation.java
deleted file mode 100644
index 9a1eb1f..0000000
--- a/location/java/com/android/internal/location/protocol/GLocation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GLocation {
-  static final int LOCTYPE_GPS = 0;
-  static final int LOCTYPE_MAPCENTER = 1;
-  static final int LOCTYPE_CENTROID = 2;
-  static final int LOCTYPE_TOWER_LOCATION = 3;
-
-  static final int LAT_LNG = 1;
-  static final int SOURCE = 2;
-  static final int ACCURACY = 3;
-  static final int CONFIDENCE = 4;
-  static final int FEATURE = 5;
-  static final int TIMESTAMP = 6;
-  static final int OBSOLETE = 7;
-  static final int LOC_TYPE = 8;
-  static final int MISC = 9;
-  static final int ALTITUDE = 10;
-  static final int VERTICAL_ACCURACY = 11;
-  static final int VELOCITY = 12;
-  static final int HEADING = 13;
-  static final int GPS_PROFILE = 14;
-  static final int LOCATION_STRING = 15;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GPlatformProfile.java b/location/java/com/android/internal/location/protocol/GPlatformProfile.java
deleted file mode 100644
index 32a1f8f..0000000
--- a/location/java/com/android/internal/location/protocol/GPlatformProfile.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GPlatformProfile {
-  static final int VERSION = 1;
-  static final int PLATFORM = 2;
-  static final int PLATFORM_KEY = 3;
-  static final int DISTRIBUTION_CHANNEL = 4;
-  static final int LOCALE = 5;
-  static final int CELLULAR_PLATFORM_PROFILE = 6;
-  static final int WIFI_PLATFORM_PROFILE = 7;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GPrefetchMode.java b/location/java/com/android/internal/location/protocol/GPrefetchMode.java
deleted file mode 100644
index 041b686..0000000
--- a/location/java/com/android/internal/location/protocol/GPrefetchMode.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GPrefetchMode {
-  static final int PREFETCH_MODE_NO_PREFETCH = 0;
-  static final int PREFETCH_MODE_REQUESTED_NEIGHBORS_ONLY = 1;
-  static final int PREFETCH_MODE_MORE_NEIGHBORS = 2;
-
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GRectangle.java b/location/java/com/android/internal/location/protocol/GRectangle.java
deleted file mode 100644
index b8412e6..0000000
--- a/location/java/com/android/internal/location/protocol/GRectangle.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GRectangle {
-  static final int LOWER_LEFT = 1;
-  static final int UPPER_RIGHT = 2;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GUserProfile.java b/location/java/com/android/internal/location/protocol/GUserProfile.java
deleted file mode 100644
index 2ce962c..0000000
--- a/location/java/com/android/internal/location/protocol/GUserProfile.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GUserProfile {
-  static final int USER_NAME = 1;
-  static final int AUTH_TOKEN = 2;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GWifiDevice.java b/location/java/com/android/internal/location/protocol/GWifiDevice.java
deleted file mode 100644
index 62bd03a..0000000
--- a/location/java/com/android/internal/location/protocol/GWifiDevice.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GWifiDevice {
-  static final int MAC = 1;
-  static final int SSID = 2;
-  static final int CHANNEL = 3;
-  static final int RSSI = 4;
-  static final int NOISE = 5;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GWifiPlatformProfile.java b/location/java/com/android/internal/location/protocol/GWifiPlatformProfile.java
deleted file mode 100644
index 7f1efcb..0000000
--- a/location/java/com/android/internal/location/protocol/GWifiPlatformProfile.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GWifiPlatformProfile {
-  static final int RADIO_TYPE_WIFI802_11_A = 1;
-  static final int RADIO_TYPE_WIFI802_11_B = 2;
-  static final int RADIO_TYPE_WIFI802_11_G = 3;
-  static final int RADIO_TYPE_WIFI802_11_N = 4;
-
-  static final int SCANNER_MAC = 1;
-  static final int SCANNER_IP = 2;
-  static final int RADIO_TYPE = 3;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GWifiProfile.java b/location/java/com/android/internal/location/protocol/GWifiProfile.java
deleted file mode 100644
index e731027..0000000
--- a/location/java/com/android/internal/location/protocol/GWifiProfile.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface GWifiProfile {
-  static final int TIMESTAMP = 1;
-  static final int WIFI_DEVICES = 2;
-  static final int PREFETCH_MODE = 3;
-}
-
diff --git a/location/java/com/android/internal/location/protocol/GaddressMessageTypes.java b/location/java/com/android/internal/location/protocol/GaddressMessageTypes.java
deleted file mode 100644
index 7b6ffd0..0000000
--- a/location/java/com/android/internal/location/protocol/GaddressMessageTypes.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GaddressMessageTypes {
-  public static final ProtoBufType GADDRESS = new ProtoBufType();
-  public static final ProtoBufType GADDRESS_COMPONENT = new ProtoBufType();
-
-  static {
-    GADDRESS
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_DATA,
-          GAddress.FORMATTED_ADDRESS_LINE, null)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GAddress.COMPONENT, GADDRESS_COMPONENT);
-
-    GADDRESS_COMPONENT
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_DATA,
-          GAddressComponent.NAME, null)
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT32,
-          GAddressComponent.FEATURE_TYPE, null);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/GcellularMessageTypes.java b/location/java/com/android/internal/location/protocol/GcellularMessageTypes.java
deleted file mode 100644
index 37a6d52..0000000
--- a/location/java/com/android/internal/location/protocol/GcellularMessageTypes.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GcellularMessageTypes {
-  public static final ProtoBufType GCELL = new ProtoBufType();
-  public static final ProtoBufType GCELLULAR_PROFILE = new ProtoBufType();
-
-  static {
-    GCELL
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT32,
-          GCell.LAC, null)
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT32,
-          GCell.CELLID, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCell.MNC, new Long(-1))
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCell.MCC, new Long(-1))
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCell.RSSI, new Long(-9999))
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCell.AGE, new Long(0))
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCell.TIMING_ADVANCE, new Long(-1))
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCell.PRIMARY_SCRAMBLING_CODE, null);
-
-    GCELLULAR_PROFILE
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_MESSAGE,
-          GCellularProfile.PRIMARY_CELL, GCELL)
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT64,
-          GCellularProfile.TIMESTAMP, null)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GCellularProfile.NEIGHBORS, GCELL)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GCellularProfile.HISTORICAL_CELLS, GCELL)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCellularProfile.PREFETCH_MODE, null);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/GdebugprofileMessageTypes.java b/location/java/com/android/internal/location/protocol/GdebugprofileMessageTypes.java
deleted file mode 100644
index 9a51efe..0000000
--- a/location/java/com/android/internal/location/protocol/GdebugprofileMessageTypes.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBuf;
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GdebugprofileMessageTypes {
-  public static final ProtoBufType GDEBUG_PROFILE = new ProtoBufType();
-
-  static {
-    GDEBUG_PROFILE
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GDebugProfile.TRIGGER, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_BOOL,
-          GDebugProfile.ACTUAL_REQUEST, ProtoBuf.TRUE)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GDebugProfile.CACHE_LOCATION, GlocationMessageTypes.GDEVICE_LOCATION)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_BOOL,
-          GDebugProfile.DEVICE_RESTART, ProtoBuf.FALSE);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/GfeatureMessageTypes.java b/location/java/com/android/internal/location/protocol/GfeatureMessageTypes.java
deleted file mode 100644
index 24b182a..0000000
--- a/location/java/com/android/internal/location/protocol/GfeatureMessageTypes.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GfeatureMessageTypes {
-  public static final ProtoBufType GFEATURE_TYPE = new ProtoBufType();
-  public static final ProtoBufType GFEATURE = new ProtoBufType();
-
-  static {
-    GFEATURE
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_DATA,
-          GFeature.NAME, null)
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT32,
-          GFeature.FEATURE_TYPE, null)
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_MESSAGE,
-          GFeature.ADDRESS, GaddressMessageTypes.GADDRESS)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GFeature.BOUNDS, GrectangleMessageTypes.GRECTANGLE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GFeature.CENTER, GlatlngMessageTypes.GLAT_LNG);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/GlatlngMessageTypes.java b/location/java/com/android/internal/location/protocol/GlatlngMessageTypes.java
deleted file mode 100644
index b6a9086..0000000
--- a/location/java/com/android/internal/location/protocol/GlatlngMessageTypes.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GlatlngMessageTypes {
-  public static final ProtoBufType GLAT_LNG = new ProtoBufType();
-
-  static {
-    GLAT_LNG
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_FIXED32,
-          GLatLng.LAT_E7, null)
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_FIXED32,
-          GLatLng.LNG_E7, null);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/GlocationMessageTypes.java b/location/java/com/android/internal/location/protocol/GlocationMessageTypes.java
deleted file mode 100644
index 067d47c8..0000000
--- a/location/java/com/android/internal/location/protocol/GlocationMessageTypes.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GlocationMessageTypes {
-  public static final ProtoBufType GGPS_PROFILE = new ProtoBufType();
-  public static final ProtoBufType GLOCATION = new ProtoBufType();
-  public static final ProtoBufType GDEVICE_LOCATION = new ProtoBufType();
-  public static final ProtoBufType GCELLULAR_PLATFORM_PROFILE = new ProtoBufType();
-  public static final ProtoBufType GWIFI_PLATFORM_PROFILE = new ProtoBufType();
-  public static final ProtoBufType GPREFETCH_MODE = new ProtoBufType();
-  public static final ProtoBufType GPLATFORM_PROFILE = new ProtoBufType();
-  public static final ProtoBufType GAPP_PROFILE = new ProtoBufType();
-  public static final ProtoBufType GUSER_PROFILE = new ProtoBufType();
-
-  static {
-    GGPS_PROFILE
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GGpsProfile.GPS_FIX_TYPE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GGpsProfile.PDOP, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GGpsProfile.HDOP, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GGpsProfile.VDOP, null);
-
-    GLOCATION
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocation.LAT_LNG, GlatlngMessageTypes.GLAT_LNG)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GLocation.SOURCE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GLocation.ACCURACY, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GLocation.CONFIDENCE, null)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GLocation.FEATURE, GfeatureMessageTypes.GFEATURE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT64,
-          GLocation.TIMESTAMP, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_BOOL,
-          GLocation.OBSOLETE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GLocation.LOC_TYPE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GLocation.MISC, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GLocation.ALTITUDE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GLocation.VERTICAL_ACCURACY, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GLocation.VELOCITY, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GLocation.HEADING, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocation.GPS_PROFILE, GGPS_PROFILE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GLocation.LOCATION_STRING, null);
-
-    GDEVICE_LOCATION
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GDeviceLocation.LOCATION, GLOCATION)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GDeviceLocation.CELL, GcellularMessageTypes.GCELL)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GDeviceLocation.WIFI_DEVICE, GwifiMessageTypes.GWIFI_DEVICE);
-
-    GCELLULAR_PLATFORM_PROFILE
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCellularPlatformProfile.RADIO_TYPE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GCellularPlatformProfile.CARRIER, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GCellularPlatformProfile.IP, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCellularPlatformProfile.HOME_MNC, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GCellularPlatformProfile.HOME_MCC, null);
-
-    GWIFI_PLATFORM_PROFILE
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GWifiPlatformProfile.SCANNER_MAC, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GWifiPlatformProfile.SCANNER_IP, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GWifiPlatformProfile.RADIO_TYPE, null);
-
-    GPLATFORM_PROFILE
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_DATA,
-          GPlatformProfile.VERSION, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GPlatformProfile.PLATFORM, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GPlatformProfile.PLATFORM_KEY, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GPlatformProfile.DISTRIBUTION_CHANNEL, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GPlatformProfile.LOCALE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GPlatformProfile.CELLULAR_PLATFORM_PROFILE, GCELLULAR_PLATFORM_PROFILE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GPlatformProfile.WIFI_PLATFORM_PROFILE, GWIFI_PLATFORM_PROFILE);
-
-    GAPP_PROFILE
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GAppProfile.APP_NAME, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GAppProfile.APP_KEY, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GAppProfile.REQUEST_TYPE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GAppProfile.SEARCH_TYPE, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GAppProfile.SEARCH_TERM, null);
-
-    GUSER_PROFILE
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GUserProfile.USER_NAME, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GUserProfile.AUTH_TOKEN, null);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/GrectangleMessageTypes.java b/location/java/com/android/internal/location/protocol/GrectangleMessageTypes.java
deleted file mode 100644
index aeb0047..0000000
--- a/location/java/com/android/internal/location/protocol/GrectangleMessageTypes.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GrectangleMessageTypes {
-  public static final ProtoBufType GRECTANGLE = new ProtoBufType();
-
-  static {
-    GRECTANGLE
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_MESSAGE,
-          GRectangle.LOWER_LEFT, GlatlngMessageTypes.GLAT_LNG)
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_MESSAGE,
-          GRectangle.UPPER_RIGHT, GlatlngMessageTypes.GLAT_LNG);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/GwifiMessageTypes.java b/location/java/com/android/internal/location/protocol/GwifiMessageTypes.java
deleted file mode 100644
index cd7119bd..0000000
--- a/location/java/com/android/internal/location/protocol/GwifiMessageTypes.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBufType;
-
-public class GwifiMessageTypes {
-  public static final ProtoBufType GWIFI_DEVICE = new ProtoBufType();
-  public static final ProtoBufType GWIFI_PROFILE = new ProtoBufType();
-
-  static {
-    GWIFI_DEVICE
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_DATA,
-          GWifiDevice.MAC, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GWifiDevice.SSID, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GWifiDevice.CHANNEL, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GWifiDevice.RSSI, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GWifiDevice.NOISE, null);
-
-    GWIFI_PROFILE
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT64,
-          GWifiProfile.TIMESTAMP, null)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GWifiProfile.WIFI_DEVICES, GWIFI_DEVICE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_INT32,
-          GWifiProfile.PREFETCH_MODE, null);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/LocserverMessageTypes.java b/location/java/com/android/internal/location/protocol/LocserverMessageTypes.java
deleted file mode 100644
index 8ffd004..0000000
--- a/location/java/com/android/internal/location/protocol/LocserverMessageTypes.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-import com.google.common.io.protocol.ProtoBuf;
-import com.google.common.io.protocol.ProtoBufType;
-
-public class LocserverMessageTypes {
-  public static final ProtoBufType RESPONSE_CODES = new ProtoBufType();
-  public static final ProtoBufType GLOC_REQUEST_ELEMENT = new ProtoBufType();
-  public static final ProtoBufType GLOC_REQUEST = new ProtoBufType();
-  public static final ProtoBufType GGEOCODE_REQUEST = new ProtoBufType();
-  public static final ProtoBufType GLOC_REPLY_ELEMENT = new ProtoBufType();
-  public static final ProtoBufType GLOC_REPLY = new ProtoBufType();
-
-  static {
-    GLOC_REQUEST_ELEMENT
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocRequestElement.CELLULAR_PROFILE, GcellularMessageTypes.GCELLULAR_PROFILE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocRequestElement.WIFI_PROFILE, GwifiMessageTypes.GWIFI_PROFILE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocRequestElement.LOCATION, GlocationMessageTypes.GLOCATION)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocRequestElement.GEOCODE, GGEOCODE_REQUEST)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocRequestElement.DEBUG_PROFILE, GdebugprofileMessageTypes.GDEBUG_PROFILE);
-
-    GLOC_REQUEST
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_MESSAGE,
-          GLocRequest.PLATFORM_PROFILE, GlocationMessageTypes.GPLATFORM_PROFILE)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GLocRequest.APP_PROFILES, GlocationMessageTypes.GAPP_PROFILE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocRequest.USER_PROFILE, GlocationMessageTypes.GUSER_PROFILE)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GLocRequest.REQUEST_ELEMENTS, GLOC_REQUEST_ELEMENT)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocRequest.MASF_CLIENT_INFO, null);
-
-    GGEOCODE_REQUEST
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_FIXED32,
-          GGeocodeRequest.NUM_FEATURE_LIMIT, new Long(1))
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_BOOL,
-          GGeocodeRequest.INCLUDE_BOUNDING_BOXES, ProtoBuf.FALSE)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GGeocodeRequest.BOUNDING_BOX, GrectangleMessageTypes.GRECTANGLE);
-
-    GLOC_REPLY_ELEMENT
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT32,
-          GLocReplyElement.STATUS, null)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_MESSAGE,
-          GLocReplyElement.LOCATION, GlocationMessageTypes.GLOCATION)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GLocReplyElement.DEVICE_LOCATION, GlocationMessageTypes.GDEVICE_LOCATION);
-
-    GLOC_REPLY
-      .addElement(ProtoBufType.REQUIRED | ProtoBufType.TYPE_INT32,
-          GLocReply.STATUS, null)
-      .addElement(ProtoBufType.REPEATED | ProtoBufType.TYPE_MESSAGE,
-          GLocReply.REPLY_ELEMENTS, GLOC_REPLY_ELEMENT)
-      .addElement(ProtoBufType.OPTIONAL | ProtoBufType.TYPE_DATA,
-          GLocReply.PLATFORM_KEY, null);
-
-  }
-}
diff --git a/location/java/com/android/internal/location/protocol/ResponseCodes.java b/location/java/com/android/internal/location/protocol/ResponseCodes.java
deleted file mode 100644
index 2ea9318..0000000
--- a/location/java/com/android/internal/location/protocol/ResponseCodes.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.location.protocol;
-
-public interface ResponseCodes {
-  static final int STATUS_STATUS_SUCCESS = 0;
-  static final int STATUS_STATUS_FAILED = 1;
-  static final int STATUS_AUTHORIZATION_REJECTED = 2;
-  static final int STATUS_NO_SOURCE_EXISTS = 3;
-  static final int STATUS_SIGNAL_TOO_WEAK = 4;
-  static final int STATUS_INVALID_REQUEST = 5;
-  static final int STATUS_INVALID_NUM_REQUESTS = 6;
-  static final int STATUS_INVALID_USERLOCATION_FORMAT = 7;
-  static final int STATUS_INVALID_OPERATION_CODE = 8;
-  static final int STATUS_INVALID_MAC_STRING_FORMAT = 9;
-  static final int STATUS_INVALID_CELLID_STRING_FORMAT = 10;
-  static final int STATUS_NON_EXISTENT_AP = 11;
-  static final int STATUS_NON_EXISTENT_CELLID = 12;
-  static final int STATUS_STATUS_FAILED_NO_SOURCE = 13;
-  static final int STATUS_STATUS_FAILED_NO_SAVE = 14;
-  static final int STATUS_PLATFORM_KEY_EXPIRED = 15;
-  static final int STATUS_NO_STORE_EXISTS = 16;
-  static final int STATUS_NO_CELLIDDATA_FOR_UPDATE = 17;
-  static final int STATUS_NON_SUPPORTED_OPERATION_IN_UPDATE = 18;
-  static final int STATUS_NON_SUPPORTED_OPERATION = 19;
-  static final int STATUS_STATUS_FAILED_NO_GEOCODE = 20;
-  static final int STATUS_BLACKLISTED_IP_CELLID = 100;
-  static final int STATUS_BLACKLISTED_IP_WIFI = 101;
-
-}
-
diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java
index c857e17..0732b61 100644
--- a/media/java/android/media/AudioFormat.java
+++ b/media/java/android/media/AudioFormat.java
@@ -18,9 +18,9 @@
 
 /**
  * The AudioFormat class is used to access a number of audio format and
- * channel configuration constants.
+ * channel configuration constants. They are for instance used
+ * in __link AudioTrack} and __link AudioRecord}.
  * 
- * {@hide Pending API council review}
  */
 public class AudioFormat {
     
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 52cf69f..2978774 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -49,37 +49,60 @@
     private static boolean localLOGV = DEBUG || android.util.Config.LOGV;
 
     /**
+     * Broadcast intent, a hint for applications that audio is about to become
+     * 'noisy' due to a change in audio outputs. For example, this intent may
+     * be sent when a wired headset is unplugged, or when an A2DP audio
+     * sink is disconnected, and the audio system is about to automatically
+     * switch audio route to the speaker. Applications that are controlling
+     * audio streams may consider pausing, reducing volume or some other action
+     * on receipt of this intent so as not to surprise the user with audio
+     * from the speaker.
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_AUDIO_BECOMING_NOISY = "android.media.AUDIO_BECOMING_NOISY";
+
+    /**
      * Sticky broadcast intent action indicating that the ringer mode has
      * changed. Includes the new ringer mode.
-     * 
+     *
      * @see #EXTRA_RINGER_MODE
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String RINGER_MODE_CHANGED_ACTION = "android.media.RINGER_MODE_CHANGED";
-    
+
     /**
      * The new ringer mode.
-     * 
+     *
      * @see #RINGER_MODE_CHANGED_ACTION
      * @see #RINGER_MODE_NORMAL
      * @see #RINGER_MODE_SILENT
      * @see #RINGER_MODE_VIBRATE
      */
     public static final String EXTRA_RINGER_MODE = "android.media.EXTRA_RINGER_MODE";
-    
+
     /**
      * Broadcast intent action indicating that the vibrate setting has
      * changed. Includes the vibrate type and its new setting.
-     * 
+     *
      * @see #EXTRA_VIBRATE_TYPE
      * @see #EXTRA_VIBRATE_SETTING
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String VIBRATE_SETTING_CHANGED_ACTION = "android.media.VIBRATE_SETTING_CHANGED";
-    
+
+    /**
+     * @hide Broadcast intent when the volume for a particular stream type changes.
+     * Includes the stream and the new volume
+     *
+     * @see #EXTRA_VOLUME_STREAM_TYPE
+     * @see #EXTRA_VOLUME_STREAM_VALUE
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String VOLUME_CHANGED_ACTION = "android.media.VOLUME_CHANGED_ACTION";
+
     /**
      * The new vibrate setting for a particular type.
-     * 
+     *
      * @see #VIBRATE_SETTING_CHANGED_ACTION
      * @see #EXTRA_VIBRATE_TYPE
      * @see #VIBRATE_SETTING_ON
@@ -87,16 +110,27 @@
      * @see #VIBRATE_SETTING_ONLY_SILENT
      */
     public static final String EXTRA_VIBRATE_SETTING = "android.media.EXTRA_VIBRATE_SETTING";
-    
+
     /**
      * The vibrate type whose setting has changed.
-     * 
+     *
      * @see #VIBRATE_SETTING_CHANGED_ACTION
      * @see #VIBRATE_TYPE_NOTIFICATION
      * @see #VIBRATE_TYPE_RINGER
      */
     public static final String EXTRA_VIBRATE_TYPE = "android.media.EXTRA_VIBRATE_TYPE";
-    
+
+    /**
+     * @hide The stream type for the volume changed intent.
+     */
+    public static final String EXTRA_VOLUME_STREAM_TYPE = "android.media.EXTRA_VOLUME_STREAM_TYPE";
+
+    /**
+     * @hide The volume associated with the stream for the volume changed intent.
+     */
+    public static final String EXTRA_VOLUME_STREAM_VALUE =
+        "android.media.EXTRA_VOLUME_STREAM_VALUE";
+
     /** The audio stream for phone calls */
     public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL;
     /** The audio stream for system sounds */
@@ -109,6 +143,8 @@
     public static final int STREAM_ALARM = AudioSystem.STREAM_ALARM;
     /** The audio stream for notifications */
     public static final int STREAM_NOTIFICATION = AudioSystem.STREAM_NOTIFICATION;
+    /** @hide The audio stream for phone calls when connected to bluetooth */
+    public static final int STREAM_BLUETOOTH_SCO = AudioSystem.STREAM_BLUETOOTH_SCO;
     /** Number of audio streams */
     /**
      * @deprecated Use AudioSystem.getNumStreamTypes() instead
@@ -123,9 +159,10 @@
         8,  // STREAM_RING
         16, // STREAM_MUSIC
         8,  // STREAM_ALARM
-        8   // STREAM_NOTIFICATION
-    }; 
-    
+        8,  // STREAM_NOTIFICATION
+        15, // STREAM_BLUETOOTH_SCO
+    };
+
     /**  @hide Default volume index values for audio streams */
     public static final int[] DEFAULT_STREAM_VOLUME = new int[] {
         4,  // STREAM_VOICE_CALL
@@ -133,12 +170,13 @@
         5,  // STREAM_RING
         11, // STREAM_MUSIC
         6,  // STREAM_ALARM
-        5   // STREAM_NOTIFICATION
-    }; 
-    
+        5,  // STREAM_NOTIFICATION
+        7   // STREAM_BLUETOOTH_SCO
+    };
+
     /**
      * Increase the ringer volume.
-     * 
+     *
      * @see #adjustVolume(int, int)
      * @see #adjustStreamVolume(int, int, int)
      */
@@ -146,7 +184,7 @@
 
     /**
      * Decrease the ringer volume.
-     * 
+     *
      * @see #adjustVolume(int, int)
      * @see #adjustStreamVolume(int, int, int)
      */
@@ -155,17 +193,17 @@
     /**
      * Maintain the previous ringer volume. This may be useful when needing to
      * show the volume toast without actually modifying the volume.
-     * 
+     *
      * @see #adjustVolume(int, int)
      * @see #adjustStreamVolume(int, int, int)
      */
     public static final int ADJUST_SAME = 0;
 
     // Flags should be powers of 2!
-    
+
     /**
      * Show a toast containing the current volume.
-     * 
+     *
      * @see #adjustStreamVolume(int, int, int)
      * @see #adjustVolume(int, int)
      * @see #setStreamVolume(int, int, int)
@@ -183,12 +221,12 @@
      * mode (for example, the ring stream type). If this flag is included, this
      * behavior will be present regardless of the stream type being affected by
      * the ringer mode.
-     * 
+     *
      * @see #adjustVolume(int, int)
      * @see #adjustStreamVolume(int, int, int)
      */
     public static final int FLAG_ALLOW_RINGER_MODES = 1 << 1;
-    
+
     /**
      * Whether to play a sound when changing the volume.
      * <p>
@@ -197,28 +235,28 @@
      * in some cases (for example, the decided stream type is not
      * {@link AudioManager#STREAM_RING}, or the volume is being adjusted
      * downward).
-     * 
+     *
      * @see #adjustStreamVolume(int, int, int)
      * @see #adjustVolume(int, int)
      * @see #setStreamVolume(int, int, int)
      */
     public static final int FLAG_PLAY_SOUND = 1 << 2;
-    
+
     /**
      * Removes any sounds/vibrate that may be in the queue, or are playing (related to
      * changing volume).
      */
     public static final int FLAG_REMOVE_SOUND_AND_VIBRATE = 1 << 3;
-    
+
     /**
      * Whether to vibrate if going into the vibrate ringer mode.
      */
     public static final int FLAG_VIBRATE = 1 << 4;
-    
+
     /**
      * Ringer mode that will be silent and will not vibrate. (This overrides the
      * vibrate setting.)
-     * 
+     *
      * @see #setRingerMode(int)
      * @see #getRingerMode()
      */
@@ -228,7 +266,7 @@
      * Ringer mode that will be silent and will vibrate. (This will cause the
      * phone ringer to always vibrate, but the notification vibrate to only
      * vibrate if set.)
-     * 
+     *
      * @see #setRingerMode(int)
      * @see #getRingerMode()
      */
@@ -238,7 +276,7 @@
      * Ringer mode that may be audible and may vibrate. It will be audible if
      * the volume before changing out of this mode was audible. It will vibrate
      * if the vibrate setting is on.
-     * 
+     *
      * @see #setRingerMode(int)
      * @see #getRingerMode()
      */
@@ -246,53 +284,53 @@
 
     /**
      * Vibrate type that corresponds to the ringer.
-     * 
+     *
      * @see #setVibrateSetting(int, int)
      * @see #getVibrateSetting(int)
      * @see #shouldVibrate(int)
      */
     public static final int VIBRATE_TYPE_RINGER = 0;
-    
+
     /**
      * Vibrate type that corresponds to notifications.
-     * 
+     *
      * @see #setVibrateSetting(int, int)
      * @see #getVibrateSetting(int)
      * @see #shouldVibrate(int)
      */
     public static final int VIBRATE_TYPE_NOTIFICATION = 1;
-    
+
     /**
      * Vibrate setting that suggests to never vibrate.
-     * 
+     *
      * @see #setVibrateSetting(int, int)
      * @see #getVibrateSetting(int)
      */
     public static final int VIBRATE_SETTING_OFF = 0;
-    
+
     /**
      * Vibrate setting that suggests to vibrate when possible.
-     * 
+     *
      * @see #setVibrateSetting(int, int)
      * @see #getVibrateSetting(int)
      */
     public static final int VIBRATE_SETTING_ON = 1;
-    
+
     /**
      * Vibrate setting that suggests to only vibrate when in the vibrate ringer
      * mode.
-     * 
+     *
      * @see #setVibrateSetting(int, int)
      * @see #getVibrateSetting(int)
      */
     public static final int VIBRATE_SETTING_ONLY_SILENT = 2;
-    
+
     /**
      * Suggests using the default stream type. This may not be used in all
      * places a stream type is needed.
      */
     public static final int USE_DEFAULT_STREAM_TYPE = Integer.MIN_VALUE;
-    
+
     private static IAudioService sService;
 
     /**
@@ -315,8 +353,8 @@
 
     /**
      * Adjusts the volume of a particular stream by one step in a direction.
-     * 
-     * @param streamType The stream type to adjust. One of {@link #STREAM_VOICE_CALL}, 
+     *
+     * @param streamType The stream type to adjust. One of {@link #STREAM_VOICE_CALL},
      * {@link #STREAM_SYSTEM}, {@link #STREAM_RING}, {@link #STREAM_MUSIC} or
      * {@link #STREAM_ALARM}
      * @param direction The direction to adjust the volume. One of
@@ -340,7 +378,7 @@
      * active, it will have the highest priority regardless of if the in-call
      * screen is showing. Another example, if music is playing in the background
      * and a call is not active, the music stream will be adjusted.
-     * 
+     *
      * @param direction The direction to adjust the volume. One of
      *            {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE}, or
      *            {@link #ADJUST_SAME}.
@@ -361,7 +399,7 @@
     /**
      * Adjusts the volume of the most relevant stream, or the given fallback
      * stream.
-     * 
+     *
      * @param direction The direction to adjust the volume. One of
      *            {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE}, or
      *            {@link #ADJUST_SAME}.
@@ -380,10 +418,10 @@
             Log.e(TAG, "Dead object in adjustVolume", e);
         }
     }
-    
+
     /**
      * Returns the current ringtone mode.
-     * 
+     *
      * @return The current ringtone mode, one of {@link #RINGER_MODE_NORMAL},
      *         {@link #RINGER_MODE_SILENT}, or {@link #RINGER_MODE_VIBRATE}.
      * @see #setRingerMode(int)
@@ -400,7 +438,7 @@
 
     /**
      * Returns the maximum volume index for a particular stream.
-     * 
+     *
      * @param streamType The stream type whose maximum volume index is returned.
      * @return The maximum valid volume index for the stream.
      * @see #getStreamVolume(int)
@@ -417,7 +455,7 @@
 
     /**
      * Returns the current volume index for a particular stream.
-     * 
+     *
      * @param streamType The stream type whose volume index is returned.
      * @return The current volume index for the stream.
      * @see #getStreamMaxVolume(int)
@@ -439,7 +477,7 @@
      * Silent mode will mute the volume and will not vibrate. Vibrate mode will
      * mute the volume and vibrate. Normal mode will be audible and may vibrate
      * according to user settings.
-     * 
+     *
      * @param ringerMode The ringer mode, one of {@link #RINGER_MODE_NORMAL},
      *            {@link #RINGER_MODE_SILENT}, or {@link #RINGER_MODE_VIBRATE}.
      * @see #getRingerMode()
@@ -455,7 +493,7 @@
 
     /**
      * Sets the volume index for a particular stream.
-     * 
+     *
      * @param streamType The stream whose volume index should be set.
      * @param index The volume index to set. See
      *            {@link #getStreamMaxVolume(int)} for the largest valid value.
@@ -471,7 +509,7 @@
             Log.e(TAG, "Dead object in setStreamVolume", e);
         }
     }
-     
+
     /**
      * Solo or unsolo a particular stream. All other streams are muted.
      * <p>
@@ -479,13 +517,13 @@
      * with an active solo request on a stream dies, all streams that were muted
      * because of this request will be unmuted automatically.
      * <p>
-     * The solo requests for a given stream are cumulative: the AudioManager 
+     * The solo requests for a given stream are cumulative: the AudioManager
      * can receive several solo requests from one or more clients and the stream
      * will be unsoloed only when the same number of unsolo requests are received.
      * <p>
-     * For a better user experience, applications MUST unsolo a soloed stream 
+     * For a better user experience, applications MUST unsolo a soloed stream
      * in onPause() and solo is again in onResume() if appropriate.
-     * 
+     *
      * @param streamType The stream to be soloed/unsoloed.
      * @param state The required solo state: true for solo ON, false for solo OFF
      */
@@ -497,7 +535,7 @@
             Log.e(TAG, "Dead object in setStreamSolo", e);
         }
     }
- 
+
     /**
      * Mute or unmute an audio stream.
      * <p>
@@ -505,13 +543,13 @@
      * with an active mute request on a stream dies, this stream will be unmuted
      * automatically.
      * <p>
-     * The mute requests for a given stream are cumulative: the AudioManager 
+     * The mute requests for a given stream are cumulative: the AudioManager
      * can receive several mute requests from one or more clients and the stream
      * will be unmuted only when the same number of unmute requests are received.
      * <p>
-     * For a better user experience, applications MUST unmute a muted stream 
+     * For a better user experience, applications MUST unmute a muted stream
      * in onPause() and mute is again in onResume() if appropriate.
-     * 
+     *
      * @param streamType The stream to be muted/unmuted.
      * @param state The required mute state: true for mute ON, false for mute OFF
      */
@@ -532,7 +570,7 @@
      * vibrate. The notification manager will not vibrate if the policy doesn't
      * allow it, so the client should always set a vibrate pattern and let the
      * notification manager control whether or not to actually vibrate.
-     * 
+     *
      * @param vibrateType The type of vibrate. One of
      *            {@link #VIBRATE_TYPE_NOTIFICATION} or
      *            {@link #VIBRATE_TYPE_RINGER}.
@@ -550,13 +588,13 @@
             return false;
         }
     }
-    
+
     /**
      * Returns whether the user's vibrate setting for a vibrate type.
      * <p>
      * This shouldn't be needed by most clients that want to vibrate, instead
      * see {@link #shouldVibrate(int)}.
-     * 
+     *
      * @param vibrateType The type of vibrate. One of
      *            {@link #VIBRATE_TYPE_NOTIFICATION} or
      *            {@link #VIBRATE_TYPE_RINGER}.
@@ -578,7 +616,7 @@
 
     /**
      * Sets the setting for when the vibrate type should vibrate.
-     * 
+     *
      * @param vibrateType The type of vibrate. One of
      *            {@link #VIBRATE_TYPE_NOTIFICATION} or
      *            {@link #VIBRATE_TYPE_RINGER}.
@@ -597,11 +635,11 @@
             Log.e(TAG, "Dead object in setVibrateSetting", e);
         }
     }
-    
+
     /**
      * Sets the speakerphone on or off.
      *
-     * @param on set <var>true</var> to turn on speakerphone; 
+     * @param on set <var>true</var> to turn on speakerphone;
      *           <var>false</var> to turn it off
      */
     public void setSpeakerphoneOn(boolean on){
@@ -620,17 +658,17 @@
     /**
      * Sets audio routing to the Bluetooth headset on or off.
      *
-     * @param on set <var>true</var> to route SCO (voice) audio to/from Bluetooth 
+     * @param on set <var>true</var> to route SCO (voice) audio to/from Bluetooth
      *           headset; <var>false</var> to route audio to/from phone earpiece
      */
     public void setBluetoothScoOn(boolean on){
         // Don't disable A2DP when turning off SCO.
         // A2DP does not affect in-call routing.
-        setRouting(MODE_RINGTONE, 
+        setRouting(MODE_RINGTONE,
                on ? ROUTE_BLUETOOTH_SCO: ROUTE_SPEAKER, ROUTE_ALL & ~ROUTE_BLUETOOTH_A2DP);
-        setRouting(MODE_NORMAL, 
+        setRouting(MODE_NORMAL,
                 on ? ROUTE_BLUETOOTH_SCO: ROUTE_SPEAKER, ROUTE_ALL & ~ROUTE_BLUETOOTH_A2DP);
-        setRouting(MODE_IN_CALL, 
+        setRouting(MODE_IN_CALL,
                 on ? ROUTE_BLUETOOTH_SCO: ROUTE_EARPIECE, ROUTE_ALL);
     }
 
@@ -647,15 +685,15 @@
     /**
      * Sets A2DP audio routing to the Bluetooth headset on or off.
      *
-     * @param on set <var>true</var> to route A2DP audio to/from Bluetooth 
+     * @param on set <var>true</var> to route A2DP audio to/from Bluetooth
      *           headset; <var>false</var> disable A2DP audio
      */
     public void setBluetoothA2dpOn(boolean on){
         // the audio flinger chooses A2DP as a higher priority,
         // so there is no need to disable other routes.
-        setRouting(MODE_RINGTONE, 
+        setRouting(MODE_RINGTONE,
                on ? ROUTE_BLUETOOTH_A2DP: 0, ROUTE_BLUETOOTH_A2DP);
-        setRouting(MODE_NORMAL, 
+        setRouting(MODE_NORMAL,
                 on ? ROUTE_BLUETOOTH_A2DP: 0, ROUTE_BLUETOOTH_A2DP);
     }
 
@@ -672,7 +710,7 @@
     /**
      * Sets audio routing to the wired headset on or off.
      *
-     * @param on set <var>true</var> to route audio to/from wired 
+     * @param on set <var>true</var> to route audio to/from wired
      *           headset; <var>false</var> disable wired headset audio
      * @hide
      */
@@ -701,7 +739,7 @@
     /**
      * Sets the microphone mute on or off.
      *
-     * @param on set <var>true</var> to mute the microphone; 
+     * @param on set <var>true</var> to mute the microphone;
      *           <var>false</var> to turn mute off
      */
     public void setMicrophoneMute(boolean on){
@@ -762,57 +800,57 @@
 
     /* modes for setMode/getMode/setRoute/getRoute */
     /**
-     * Audio harware modes. 
-     */    
+     * Audio harware modes.
+     */
     /**
-     * Invalid audio mode. 
-     */    
+     * Invalid audio mode.
+     */
     public static final int MODE_INVALID            = AudioSystem.MODE_INVALID;
     /**
      * Current audio mode. Used to apply audio routing to current mode.
-     */    
+     */
     public static final int MODE_CURRENT            = AudioSystem.MODE_CURRENT;
     /**
      * Normal audio mode: not ringing and no call established.
-     */    
+     */
     public static final int MODE_NORMAL             = AudioSystem.MODE_NORMAL;
     /**
      * Ringing audio mode. An incoming is being signaled.
-     */    
+     */
     public static final int MODE_RINGTONE           = AudioSystem.MODE_RINGTONE;
     /**
      * In call audio mode. A call is established.
-     */    
+     */
     public static final int MODE_IN_CALL            = AudioSystem.MODE_IN_CALL;
 
     /* Routing bits for setRouting/getRouting API */
     /**
      * Routing audio output to earpiece
-     */        
+     */
     public static final int ROUTE_EARPIECE          = AudioSystem.ROUTE_EARPIECE;
     /**
      * Routing audio output to spaker
-     */        
+     */
     public static final int ROUTE_SPEAKER           = AudioSystem.ROUTE_SPEAKER;
     /**
      * @deprecated use {@link #ROUTE_BLUETOOTH_SCO}
-     */        
+     */
     @Deprecated public static final int ROUTE_BLUETOOTH = AudioSystem.ROUTE_BLUETOOTH_SCO;
     /**
      * Routing audio output to bluetooth SCO
-     */        
+     */
     public static final int ROUTE_BLUETOOTH_SCO     = AudioSystem.ROUTE_BLUETOOTH_SCO;
     /**
      * Routing audio output to headset
-     */        
+     */
     public static final int ROUTE_HEADSET           = AudioSystem.ROUTE_HEADSET;
     /**
      * Routing audio output to bluetooth A2DP
-     */        
+     */
     public static final int ROUTE_BLUETOOTH_A2DP    = AudioSystem.ROUTE_BLUETOOTH_A2DP;
     /**
      * Used for mask parameter of {@link #setRouting(int,int,int)}.
-     */        
+     */
     public static final int ROUTE_ALL               = AudioSystem.ROUTE_ALL;
 
     /**
@@ -892,33 +930,33 @@
     /**
      * Keyboard and direction pad click sound
      * @see #playSoundEffect(int)
-     */        
+     */
     public static final int FX_KEY_CLICK = 0;
     /**
      * Focuse has moved up
      * @see #playSoundEffect(int)
-     */        
+     */
     public static final int FX_FOCUS_NAVIGATION_UP = 1;
     /**
      * Focuse has moved down
      * @see #playSoundEffect(int)
-     */        
+     */
     public static final int FX_FOCUS_NAVIGATION_DOWN = 2;
     /**
      * Focuse has moved left
      * @see #playSoundEffect(int)
-     */        
+     */
     public static final int FX_FOCUS_NAVIGATION_LEFT = 3;
     /**
      * Focuse has moved right
      * @see #playSoundEffect(int)
-     */        
+     */
     public static final int FX_FOCUS_NAVIGATION_RIGHT = 4;
     /**
-     * @hide Number of sound effects 
-     */ 
+     * @hide Number of sound effects
+     */
     public static final int NUM_SOUND_EFFECTS = 5;
-    
+
     /**
      * Plays a sound effect (Key clicks, lid open/close...)
      * @param effectType The type of sound effect. One of
@@ -951,10 +989,10 @@
     private boolean querySoundEffectsEnabled() {
         return Settings.System.getInt(mContext.getContentResolver(), Settings.System.SOUND_EFFECTS_ENABLED, 0) != 0;
     }
-    
-    
+
+
     /**
-     *  Load Sound effects. 
+     *  Load Sound effects.
      *  This method must be called when sound effects are enabled.
      */
     public void loadSoundEffects() {
@@ -965,9 +1003,9 @@
             Log.e(TAG, "Dead object in loadSoundEffects"+e);
         }
     }
-    
+
     /**
-     *  Unload Sound effects. 
+     *  Unload Sound effects.
      *  This method can be called to free some memory when
      *  sound effects are disabled.
      */
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index 7912003b..1314ba1 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -34,11 +34,14 @@
  * to record audio from the audio input hardware of the platform. This is
  * achieved by "pulling" (reading) the data from the AudioRecord object. The
  * application is responsible for polling the AudioRecord object in time using one of 
- * the following three methods:  {@link #read(byte[], int)}, {@link #read(short[], int)}
+ * the following three methods:  {@link #read(byte[],int, int)}, {@link #read(short[], int, int)}
  * or {@link #read(ByteBuffer, int)}. The choice of which method to use will be based 
  * on the audio data storage format that is the most convenient for the user of AudioRecord.
- * 
- * {@hide Pending API council review}
+ * <p>Upon creation, an AudioRecord object initializes its associated audio buffer that it will
+ * fill with the new audio data. The size of this buffer, specified during the construction, 
+ * determines how long an AudioRecord can record before "over-running" data that has not
+ * been read yet. Data should be from the audio hardware in chunks of sizes inferior to
+ * the total recording buffer size.
  */
 public class AudioRecord
 {
@@ -82,22 +85,22 @@
      */
     public static final int ERROR_INVALID_OPERATION = -3;
     
-    private static final int AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT      = -4;
-    private static final int AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT = -5;
-    private static final int AUDIORECORD_ERROR_SETUP_INVALIDFORMAT       = -6;
-    private static final int AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE   = -7;
-    private static final int AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED    = -8;
+    private static final int AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT      = -16;
+    private static final int AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT = -17;
+    private static final int AUDIORECORD_ERROR_SETUP_INVALIDFORMAT       = -18;
+    private static final int AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE   = -19;
+    private static final int AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED    = -20;
     
     // Events:
     // to keep in sync with frameworks/base/include/media/AudioRecord.h 
     /**
      * Event id for when the recording head has reached a previously set marker.
      */
-    protected static final int EVENT_MARKER  = 2;
+    private static final int NATIVE_EVENT_MARKER  = 2;
     /**
      * Event id for when the previously set update period has passed during recording.
      */
-    protected static final int EVENT_NEW_POS = 3;
+    private static final int NATIVE_EVENT_NEW_POS = 3;
     
     private final static String TAG = "AudioRecord-Java";
 
@@ -130,63 +133,63 @@
     /**
      * The audio data sampling rate in Hz.
      */
-    protected int mSampleRate = 22050;
+    private int mSampleRate = 22050;
     /**
      * The number of input audio channels (1 is mono, 2 is stereo)
      */
-    protected int mChannelCount = 1;
+    private int mChannelCount = 1;
     /**
      * The current audio channel configuration
      */
-    protected int mChannelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
+    private int mChannelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
     /**
      * The encoding of the audio samples.
-     * @see #AudioFormat.ENCODING_PCM_8BIT
-     * @see #AudioFormat.ENCODING_PCM_16BIT
+     * @see AudioFormat#ENCODING_PCM_8BIT
+     * @see AudioFormat#ENCODING_PCM_16BIT
      */
-    protected int mAudioFormat = AudioFormat.ENCODING_PCM_16BIT;
+    private int mAudioFormat = AudioFormat.ENCODING_PCM_16BIT;
     /**
      * Where the audio data is recorded from.
      */
-    protected int mRecordSource = MediaRecorder.AudioSource.DEFAULT;
+    private int mRecordSource = MediaRecorder.AudioSource.DEFAULT;
     /**
      * Indicates the state of the AudioRecord instance.
      */
-    protected int mState = STATE_UNINITIALIZED;
+    private int mState = STATE_UNINITIALIZED;
     /**
      * Indicates the recording state of the AudioRecord instance.
      */
-    protected int mRecordingState = RECORDSTATE_STOPPED;
+    private int mRecordingState = RECORDSTATE_STOPPED;
     /**
      * Lock to make sure mRecordingState updates are reflecting the actual state of the object.
      */
-    protected Object mRecordingStateLock = new Object();
+    private Object mRecordingStateLock = new Object();
     /**
      * The listener the AudioRecord notifies when a previously set marker is reached.
      *  @see #setMarkerReachedListener(OnMarkerReachedListener)
      */
-    protected OnMarkerReachedListener mMarkerListener = null;
+    private OnMarkerReachedListener mMarkerListener = null;
     /**
      * Lock to protect marker listener updates against event notifications
      */
-    protected final Object mMarkerListenerLock = new Object();
+    private final Object mMarkerListenerLock = new Object();
     /**
      * The listener the AudioRecord notifies periodically during recording.
      *  @see #setPeriodicNotificationListener(OnPeriodicNotificationListener)
      */
-    protected OnPeriodicNotificationListener mPeriodicListener = null;
+    private OnPeriodicNotificationListener mPeriodicListener = null;
     /**
      * Lock to protect periodic listener updates against event notifications
      */
-    protected final Object mPeriodicListenerLock = new Object();
+    private final Object mPeriodicListenerLock = new Object();
     /**
      * Handler for events coming from the native code
      */
-    protected NativeEventHandler mNativeEventHandler = null;
+    private NativeEventHandler mNativeEventHandler = null;
     /**
      * Size of the native audio buffer.
      */
-    protected int mNativeBufferSizeInBytes = 0;
+    private int mNativeBufferSizeInBytes = 0;
 
     
     //---------------------------------------------------------
@@ -194,30 +197,30 @@
     //--------------------
     /**
      * Class constructor.
-     * @param audioSource the recording source. See {@link MediaRecorder.AudioSource.DEFAULT}
-     *   and {@link MediaRecorder.AudioSource.MIC}.
+     * @param audioSource the recording source. See {@link MediaRecorder.AudioSource} for
+     *    recording source definitions.
      * @param sampleRateInHz the sample rate expressed in Hertz. Examples of rates are (but
      *   not limited to) 44100, 22050 and 11025.
      * @param channelConfig describes the configuration of the audio channels. 
-     *   See {@link AudioFormat.CHANNEL_CONFIGURATION_MONO} and
-     *   {@link AudioFormat.CHANNEL_CONFIGURATION_STEREO}
+     *   See {@link AudioFormat#CHANNEL_CONFIGURATION_MONO} and
+     *   {@link AudioFormat#CHANNEL_CONFIGURATION_STEREO}
      * @param audioFormat the format in which the audio data is represented. 
-     *   See {@link AudioFormat.ENCODING_PCM_16BIT} and 
-     *   {@link AudioFormat.ENCODING_PCM_8BIT}
+     *   See {@link AudioFormat#ENCODING_PCM_16BIT} and 
+     *   {@link AudioFormat#ENCODING_PCM_8BIT}
      * @param bufferSizeInBytes the total size (in bytes) of the buffer where audio data is written
      *   to during the recording. New audio data can be read from this buffer in smaller chunks 
      *   than this size.
      * @throws java.lang.IllegalArgumentException
      */
     public AudioRecord(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, 
-            int blockSizeInBytes)
+            int bufferSizeInBytes)
     throws IllegalArgumentException {   
         mState = STATE_UNINITIALIZED;
         mRecordingState = RECORDSTATE_STOPPED;
 
         audioParamCheck(audioSource, sampleRateInHz, channelConfig, audioFormat);
 
-        audioBuffSizeCheck(blockSizeInBytes);
+        audioBuffSizeCheck(bufferSizeInBytes);
 
         // native initialization
         //TODO: update native initialization when information about hardware init failure
@@ -367,8 +370,8 @@
     }
 
     /**
-     * Returns the configured audio data format. See {@link #AudioFormat.ENCODING_PCM_16BIT}
-     * and {@link #AudioFormat.ENCODING_PCM_8BIT}.
+     * Returns the configured audio data format. See {@link AudioFormat#ENCODING_PCM_16BIT}
+     * and {@link AudioFormat#ENCODING_PCM_8BIT}.
      */
     public int getAudioFormat() {
         return mAudioFormat;
@@ -376,8 +379,8 @@
 
     /**
      * Returns the configured channel configuration. 
-     * See {@link #AudioFormat.CHANNEL_CONFIGURATION_MONO}
-     * and {@link #AudioFormat.CHANNEL_CONFIGURATION_STEREO}.
+     * See {@link AudioFormat#CHANNEL_CONFIGURATION_MONO}
+     * and {@link AudioFormat#CHANNEL_CONFIGURATION_STEREO}.
      */
     public int getChannelConfiguration() {
         return mChannelConfiguration;
@@ -395,8 +398,8 @@
      * AudioRecord instance has been created to check if it was initialized 
      * properly. This ensures that the appropriate hardware resources have been
      * acquired.
-     * @see AudioRecord.STATE_INITIALIZED
-     * @see AudioRecord.STATE_UNINITIALIZED
+     * @see AudioRecord#STATE_INITIALIZED
+     * @see AudioRecord#STATE_UNINITIALIZED
      */
     public int getState() {
         return mState;
@@ -404,8 +407,8 @@
 
     /**
      * Returns the recording state of the AudioRecord instance.
-     * @see AudioRecord.RECORDSTATE_STOPPED
-     * @see AudioRecord.RECORDSTATE_RECORDING
+     * @see AudioRecord#RECORDSTATE_STOPPED
+     * @see AudioRecord#RECORDSTATE_RECORDING
      */
     public int getRecordingState() {
         return mRecordingState;
@@ -472,16 +475,15 @@
     //--------------------
     /**
      * Reads audio data from the audio hardware for recording into a buffer.
-     * @throws IllegalStateException
      * @param audioData the array to which the recorded audio data is written.
      * @param offsetInBytes index in audioData from which the data is written.
      * @param sizeInBytes the number of requested bytes.
-     * @return the number of bytes that were read. This will not exceed sizeInBytes
+     * @return the number of bytes that were read or -1 if the object wasn't properly
+     *    initialized. The number of bytes will not exceed sizeInBytes.
      */    
-    public int read(byte[] audioData, int offsetInBytes, int sizeInBytes)
-    throws IllegalStateException {
+    public int read(byte[] audioData, int offsetInBytes, int sizeInBytes) {
         if (mState != STATE_INITIALIZED) {
-            throw(new IllegalStateException("read() called on uninitialized AudioRecord."));
+            return -1;
         }
 
         return native_read_in_byte_array(audioData, offsetInBytes, sizeInBytes);
@@ -490,16 +492,15 @@
 
     /**
      * Reads audio data from the audio hardware for recording into a buffer.
-     * @throws IllegalStateException
      * @param audioData the array to which the recorded audio data is written.
      * @param offsetInShorts index in audioData from which the data is written.
      * @param sizeInShorts the number of requested shorts.
-     * @return the number of shorts that were read. This will not exceed sizeInShorts
+     * @return the number of shorts that were read. or -1 if the object wasn't properly
+     *    initialized. The number of shorts will not exceed sizeInShorts
      */    
-    public int read(short[] audioData, int offsetInShorts, int sizeInShorts)
-    throws IllegalStateException {
+    public int read(short[] audioData, int offsetInShorts, int sizeInShorts) {
         if (mState != STATE_INITIALIZED) {
-            throw(new IllegalStateException("read() called on uninitialized AudioRecord."));
+            return -1;
         }
 
         return native_read_in_short_array(audioData, offsetInShorts, sizeInShorts);
@@ -509,15 +510,14 @@
     /**
      * Reads audio data from the audio hardware for recording into a direct buffer. If this buffer
      * is not a direct buffer, this method will always return 0.
-     * @throws IllegalStateException
      * @param audioBuffer the direct buffer to which the recorded audio data is written.
      * @param sizeInBytes the number of requested bytes.
-     * @return the number of bytes that were read. This will not exceed sizeInBytes.
+     * @return the number of bytes that were read or -1 if the object wasn't properly
+     *    initialized. The number of bytes will not exceed sizeInBytes.
      */    
-    public int read(ByteBuffer audioBuffer, int sizeInBytes)
-    throws IllegalStateException {
+    public int read(ByteBuffer audioBuffer, int sizeInBytes) {
         if (mState != STATE_INITIALIZED) {
-            throw(new IllegalStateException("read() called on uninitialized AudioRecord."));
+            return -1;
         }
 
         return native_read_in_direct_buffer(audioBuffer, sizeInBytes);
@@ -590,7 +590,7 @@
          * Called on the listener to notify it that the previously set marker has been reached
          * by the recording head.
          */
-        void onMarkerReached(AudioRecord track);
+        void onMarkerReached(AudioRecord recorder);
     }
 
 
@@ -603,7 +603,7 @@
          * Called on the listener to periodically notify it that the recording head has reached
          * a multiple of the notification period.
          */
-        void onPeriodicNotification(AudioRecord track);
+        void onPeriodicNotification(AudioRecord recorder);
     }
 
     
@@ -628,14 +628,14 @@
                 return;
             }
             switch(msg.what) {
-            case EVENT_MARKER:
+            case NATIVE_EVENT_MARKER:
                 synchronized (mMarkerListenerLock) {
                     if (mAudioRecord.mMarkerListener != null) {
                         mAudioRecord.mMarkerListener.onMarkerReached(mAudioRecord);
                     }
                 }
                 break;
-            case EVENT_NEW_POS:
+            case NATIVE_EVENT_NEW_POS:
                 synchronized (mPeriodicListenerLock) {
                     if (mAudioRecord.mPeriodicListener != null) {
                         mAudioRecord.mPeriodicListener.onPeriodicNotification(mAudioRecord);
@@ -643,7 +643,7 @@
                 }
                 break;
             default:
-                Log.e(TAG, "[ android.media.AudioTrack.NativeEventHandler ] " +
+                Log.e(TAG, "[ android.media.AudioRecord.NativeEventHandler ] " +
                         "Unknown event type: " + msg.what);
                 break;
             }
@@ -658,14 +658,14 @@
     private static void postEventFromNative(Object audiorecord_ref,
             int what, int arg1, int arg2, Object obj) {
         //logd("Event posted from the native side: event="+ what + " args="+ arg1+" "+arg2);
-        AudioRecord track = (AudioRecord)((WeakReference)audiorecord_ref).get();
-        if (track == null) {
+        AudioRecord recorder = (AudioRecord)((WeakReference)audiorecord_ref).get();
+        if (recorder == null) {
             return;
         }
         
-        if (track.mNativeEventHandler != null) {
-            Message m = track.mNativeEventHandler.obtainMessage(what, arg1, arg2, obj);
-            track.mNativeEventHandler.sendMessage(m);
+        if (recorder.mNativeEventHandler != null) {
+            Message m = recorder.mNativeEventHandler.obtainMessage(what, arg1, arg2, obj);
+            recorder.mNativeEventHandler.sendMessage(m);
         }
 
     }
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index b39e7bb..f3d8957 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -16,8 +16,7 @@
 
 package android.media;
 
-import com.android.internal.telephony.ITelephony;
-
+import android.app.ActivityManagerNative;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
@@ -32,11 +31,13 @@
 import android.os.Message;
 import android.os.RemoteException;
 import android.os.ServiceManager;
-import android.provider.Settings.System;
 import android.provider.Settings;
+import android.provider.Settings.System;
 import android.util.Log;
 import android.view.VolumePanel;
 
+import com.android.internal.telephony.ITelephony;
+
 import java.io.IOException;
 import java.util.ArrayList;
 
@@ -50,19 +51,19 @@
  * volume and later persist to the database. Similarly, setting the ringer mode
  * will update the state and broadcast a change and in a separate thread later
  * persist the ringer mode.
- * 
+ *
  * @hide
  */
 public class AudioService extends IAudioService.Stub {
-    
+
     private static final String TAG = "AudioService";
 
     /** How long to delay before persisting a change in volume/ringer mode. */
     private static final int PERSIST_DELAY = 3000;
-    
+
     private Context mContext;
     private ContentResolver mContentResolver;
-    
+
     /** The UI */
     private VolumePanel mVolumePanel;
 
@@ -75,7 +76,7 @@
     private static final int SENDMSG_NOOP = 1;
     /** If the msg is already queued, queue this one and leave the old. */
     private static final int SENDMSG_QUEUE = 2;
-    
+
     // AudioHandler message.whats
     private static final int MSG_SET_SYSTEM_VOLUME = 0;
     private static final int MSG_PERSIST_VOLUME = 1;
@@ -91,18 +92,18 @@
     private AudioHandler mAudioHandler;
     /** @see VolumeStreamState */
     private VolumeStreamState[] mStreamStates;
-    
+
     private boolean mMicMute;
     private int mMode;
     private int[] mRoutes = new int[AudioSystem.NUM_MODES];
     private Object mSettingsLock = new Object();
     private boolean mMediaServerOk;
-    
+
     private SoundPool mSoundPool;
     private Object mSoundEffectsLock = new Object();
     private static final int NUM_SOUNDPOOL_CHANNELS = 4;
     private static final float SOUND_EFFECT_VOLUME = 1.0f;
-    
+
     /* Sound effect file names  */
     private static final String SOUND_EFFECTS_PATH = "/media/audio/ui/";
     private static final String[] SOUND_EFFECT_FILES = new String[] {
@@ -119,7 +120,7 @@
         {0, -1},  // FX_FOCUS_NAVIGATION_LEFT
         {0, -1}   // FX_FOCUS_NAVIGATION_RIGHT
     };
-       
+
     private AudioSystem.ErrorCallback mAudioSystemCallback = new AudioSystem.ErrorCallback() {
         public void onError(int error) {
             switch (error) {
@@ -145,7 +146,7 @@
      * Current ringer mode from one of {@link AudioManager#RINGER_MODE_NORMAL},
      * {@link AudioManager#RINGER_MODE_SILENT}, or
      * {@link AudioManager#RINGER_MODE_VIBRATE}.
-     */ 
+     */
     private int mRingerMode;
 
     /** @see System#MODE_RINGER_STREAMS_AFFECTED */
@@ -153,7 +154,7 @@
 
     /** @see System#MUTE_STREAMS_AFFECTED */
     private int mMuteAffectedStreams;
-    
+
     /**
      * Has multiple bits per vibrate type to indicate the type's vibrate
      * setting. See {@link #setVibrateSetting(int, int)}.
@@ -162,23 +163,23 @@
      * type since it depends on the ringer mode. See {@link #shouldVibrate(int)}.
      */
     private int mVibrateSetting;
-    
+
     ///////////////////////////////////////////////////////////////////////////
     // Construction
     ///////////////////////////////////////////////////////////////////////////
-    
+
     /** @hide */
     public AudioService(Context context) {
         mContext = context;
         mContentResolver = context.getContentResolver();
         mVolumePanel = new VolumePanel(context, this);
-        
+
         createAudioSystemThread();
         createStreamStates();
         readPersistedSettings();
         readAudioSettings();
         mMediaServerOk = true;
-        AudioSystem.setErrorCallback(mAudioSystemCallback); 
+        AudioSystem.setErrorCallback(mAudioSystemCallback);
         if (Settings.System.getInt(mContentResolver, Settings.System.SOUND_EFFECTS_ENABLED, 0) == 1) {
             loadSoundEffects();
         }
@@ -189,8 +190,8 @@
         mAudioSystemThread.start();
         waitForAudioHandlerCreation();
     }
-    
-    /** Waits for the volume handler to be created by the other thread. */ 
+
+    /** Waits for the volume handler to be created by the other thread. */
     private void waitForAudioHandlerCreation() {
         synchronized(this) {
             while (mAudioHandler == null) {
@@ -203,37 +204,51 @@
             }
         }
     }
-    
+
     private void createStreamStates() {
-        final int[] volumeLevelsPhone = createVolumeLevels(0, AudioManager.MAX_STREAM_VOLUME[AudioManager.STREAM_VOICE_CALL]);
-        final int[] volumeLevelsCoarse = createVolumeLevels(0, AudioManager.MAX_STREAM_VOLUME[AudioManager.STREAM_SYSTEM]);
-        final int[] volumeLevelsFine = createVolumeLevels(0, AudioManager.MAX_STREAM_VOLUME[AudioManager.STREAM_MUSIC]);
-        
+        final int[] volumeLevelsPhone =
+            createVolumeLevels(0, AudioManager.MAX_STREAM_VOLUME[AudioManager.STREAM_VOICE_CALL]);
+        final int[] volumeLevelsCoarse =
+            createVolumeLevels(0, AudioManager.MAX_STREAM_VOLUME[AudioManager.STREAM_SYSTEM]);
+        final int[] volumeLevelsFine =
+            createVolumeLevels(0, AudioManager.MAX_STREAM_VOLUME[AudioManager.STREAM_MUSIC]);
+        final int[] volumeLevelsBtPhone =
+            createVolumeLevels(0,
+                    AudioManager.MAX_STREAM_VOLUME[AudioManager.STREAM_BLUETOOTH_SCO]);
+
         int numStreamTypes = AudioSystem.getNumStreamTypes();
         VolumeStreamState[] streams = mStreamStates = new VolumeStreamState[numStreamTypes];
-        
+
         for (int i = 0; i < numStreamTypes; i++) {
             final int[] levels;
-            
+
             switch (i) {
-                
+
                 case AudioSystem.STREAM_MUSIC:
                     levels = volumeLevelsFine;
                     break;
-                    
+
                 case AudioSystem.STREAM_VOICE_CALL:
                     levels = volumeLevelsPhone;
                     break;
-                    
+
+                case AudioSystem.STREAM_BLUETOOTH_SCO:
+                    levels = volumeLevelsBtPhone;
+                    break;
+
                 default:
                     levels = volumeLevelsCoarse;
                     break;
             }
-            
-            streams[i] = new VolumeStreamState(System.VOLUME_SETTINGS[i], i, levels);
+
+            if (i == AudioSystem.STREAM_BLUETOOTH_SCO) {
+                streams[i] = new VolumeStreamState(AudioManager.DEFAULT_STREAM_VOLUME[i], i,levels);
+            } else {
+                streams[i] = new VolumeStreamState(System.VOLUME_SETTINGS[i], i, levels);
+            }
         }
     }
-    
+
     private static int[] createVolumeLevels(int offset, int numlevels) {
         double curve = 1.0f; // 1.4f
         int [] volumes = new int[numlevels + offset];
@@ -249,7 +264,7 @@
         }
         return volumes;
     }
-    
+
     private void readPersistedSettings() {
         final ContentResolver cr = mContentResolver;
 
@@ -260,19 +275,19 @@
         mVibrateSetting = System.getInt(cr, System.VIBRATE_ON, 0);
 
         mMuteAffectedStreams = System.getInt(cr,
-                System.MUTE_STREAMS_AFFECTED, 
+                System.MUTE_STREAMS_AFFECTED,
                 ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM)));
-        
+
         // Each stream will read its own persisted settings
-        
+
         // Broadcast the sticky intent
         broadcastRingerMode();
-        
+
         // Broadcast vibrate settings
         broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
         broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION);
     }
-    
+
     private void readAudioSettings() {
         synchronized (mSettingsLock) {
             mMicMute = AudioSystem.isMicrophoneMuted();
@@ -282,7 +297,7 @@
             }
         }
     }
-    
+
     private void applyAudioSettings() {
         synchronized (mSettingsLock) {
             AudioSystem.muteMicrophone(mMicMute);
@@ -291,46 +306,46 @@
                 AudioSystem.setRouting(mode, mRoutes[mode], AudioSystem.ROUTE_ALL);
             }
         }
-    }
-    
+   }
+
     ///////////////////////////////////////////////////////////////////////////
     // IPC methods
     ///////////////////////////////////////////////////////////////////////////
-    
+
     /** @see AudioManager#adjustVolume(int, int) */
     public void adjustVolume(int direction, int flags) {
         adjustSuggestedStreamVolume(direction, AudioManager.USE_DEFAULT_STREAM_TYPE, flags);
     }
-    
+
     /** @see AudioManager#adjustVolume(int, int, int) */
     public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) {
 
         int streamType = getActiveStreamType(suggestedStreamType);
-        
+
         // Don't play sound on other streams
         if (streamType != AudioSystem.STREAM_RING && (flags & AudioManager.FLAG_PLAY_SOUND) != 0) {
             flags &= ~AudioManager.FLAG_PLAY_SOUND;
         }
-        
+
         adjustStreamVolume(streamType, direction, flags);
     }
-    
+
     /** @see AudioManager#adjustStreamVolume(int, int, int) */
     public void adjustStreamVolume(int streamType, int direction, int flags) {
         ensureValidDirection(direction);
         ensureValidStreamType(streamType);
-       
+
         boolean notificationsUseRingVolume = Settings.System.getInt(mContentResolver,
                 Settings.System.NOTIFICATIONS_USE_RING_VOLUME, 1) == 1;
         if (notificationsUseRingVolume && streamType == AudioManager.STREAM_NOTIFICATION) {
             // Redirect the volume change to the ring stream
             streamType = AudioManager.STREAM_RING;
         }
-        
+
         VolumeStreamState streamState = mStreamStates[streamType];
-        final int oldIndex = streamState.mIndex; 
+        final int oldIndex = streamState.mIndex;
         boolean adjustVolume = true;
-        
+
         // If either the client forces allowing ringer modes for this adjustment,
         // or the stream type is one that is affected by ringer modes
         if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0
@@ -339,21 +354,21 @@
             // it does, it will handle adjusting the volome, so we won't below
             adjustVolume = checkForRingerModeChange(oldIndex, direction);
         }
-        
+
         if (adjustVolume && streamState.adjustIndex(direction)) {
-            
+
             boolean alsoUpdateNotificationVolume =  notificationsUseRingVolume &&
                     streamType == AudioManager.STREAM_RING;
             if (alsoUpdateNotificationVolume) {
                 mStreamStates[AudioManager.STREAM_NOTIFICATION].adjustIndex(direction);
             }
-            
+
             // Post message to set system volume (it in turn will post a message
             // to persist). Do not change volume if stream is muted.
             if (streamState.muteCount() == 0) {
                 sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, streamType, SENDMSG_NOOP, 0, 0,
                         streamState, 0);
-                
+
                 if (alsoUpdateNotificationVolume) {
                     sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, AudioManager.STREAM_NOTIFICATION,
                             SENDMSG_NOOP, 0, 0, mStreamStates[AudioManager.STREAM_NOTIFICATION], 0);
@@ -363,12 +378,44 @@
 
         // UI
         mVolumePanel.postVolumeChanged(streamType, flags);
+        // Broadcast Intent
+        sendVolumeUpdate(streamType);
     }
 
     /** @see AudioManager#setStreamVolume(int, int, int) */
     public void setStreamVolume(int streamType, int index, int flags) {
         ensureValidStreamType(streamType);
-        
+        syncRingerAndNotificationStreamVolume(streamType, index, false);
+
+        setStreamVolumeInt(streamType, index, false);
+
+        // UI, etc.
+        mVolumePanel.postVolumeChanged(streamType, flags);
+        // Broadcast Intent
+        sendVolumeUpdate(streamType);
+    }
+
+    private void sendVolumeUpdate(int streamType) {
+        Intent intent = new Intent(AudioManager.VOLUME_CHANGED_ACTION);
+        intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, streamType);
+        intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, getStreamVolume(streamType));
+
+        // Currently, sending the intent only when the stream is BLUETOOTH_SCO
+        if (streamType == AudioManager.STREAM_BLUETOOTH_SCO) {
+            mContext.sendBroadcast(intent);
+        }
+    }
+
+    /**
+     * Sync the STREAM_RING and STREAM_NOTIFICATION volumes if mandated by the
+     * value in Settings.
+     *
+     * @param streamType Type of the stream
+     * @param index Volume index for the stream
+     * @param force If true, set the volume even if the current and desired
+     * volume as same
+     */
+    private void syncRingerAndNotificationStreamVolume(int streamType, int index, boolean force) {
         boolean notificationsUseRingVolume = Settings.System.getInt(mContentResolver,
                 Settings.System.NOTIFICATIONS_USE_RING_VOLUME, 1) == 1;
         if (notificationsUseRingVolume) {
@@ -378,23 +425,24 @@
             }
             if (streamType == AudioManager.STREAM_RING) {
                 // One-off to sync notification volume to ringer volume
-                setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION, index); 
+                setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION, index, force);
             }
         }
-        
-        setStreamVolumeInt(streamType, index);
-        
-        // UI, etc.
-        mVolumePanel.postVolumeChanged(streamType, flags);
     }
 
+
     /**
      * Sets the stream state's index, and posts a message to set system volume.
      * This will not call out to the UI. Assumes a valid stream type.
+     *
+     * @param streamType Type of the stream
+     * @param index Desired volume index of the stream
+     * @param force If true, set the volume even if the desired volume is same
+     * as the current volume.
      */
-    private void setStreamVolumeInt(int streamType, int index) {
+    private void setStreamVolumeInt(int streamType, int index, boolean force) {
         VolumeStreamState streamState = mStreamStates[streamType];
-        if (streamState.setIndex(index)) {
+        if (streamState.setIndex(index) || force) {
             // Post message to set system volume (it in turn will post a message
             // to persist). Do not change volume if stream is muted.
             if (streamState.muteCount() == 0) {
@@ -403,7 +451,7 @@
             }
         }
     }
-    
+
     /** @see AudioManager#setStreamSolo(int, boolean) */
     public void setStreamSolo(int streamType, boolean state, IBinder cb) {
         for (int stream = 0; stream < mStreamStates.length; stream++) {
@@ -412,7 +460,7 @@
             mStreamStates[stream].mute(cb, state);
          }
     }
-    
+
     /** @see AudioManager#setStreamMute(int, boolean) */
     public void setStreamMute(int streamType, boolean state, IBinder cb) {
         if (isStreamAffectedByMute(streamType)) {
@@ -441,32 +489,33 @@
     public void setRingerMode(int ringerMode) {
         if (ringerMode != mRingerMode) {
             mRingerMode = ringerMode;
-            
+
             // Adjust volumes via posting message
             int numStreamTypes = AudioSystem.getNumStreamTypes();
             if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
                 for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
                     if (!isStreamAffectedByRingerMode(streamType)) continue;
                     // Bring back last audible volume
-                    setStreamVolumeInt(streamType, mStreamStates[streamType].mLastAudibleIndex);
+                    setStreamVolumeInt(streamType, mStreamStates[streamType].mLastAudibleIndex,
+                                       false);
                 }
             } else {
                 for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
                     if (!isStreamAffectedByRingerMode(streamType)) continue;
                     // Either silent or vibrate, either way volume is 0
-                    setStreamVolumeInt(streamType, 0);
+                    setStreamVolumeInt(streamType, 0, false);
                 }
             }
-            
+
             // Send sticky broadcast
             broadcastRingerMode();
-            
+
             // Post a persist ringer mode msg
             sendMsg(mAudioHandler, MSG_PERSIST_RINGER_MODE, SHARED_MSG,
                     SENDMSG_REPLACE, 0, 0, null, PERSIST_DELAY);
         }
     }
-    
+
     /** @see AudioManager#shouldVibrate(int) */
     public boolean shouldVibrate(int vibrateType) {
 
@@ -474,21 +523,21 @@
 
             case AudioManager.VIBRATE_SETTING_ON:
                 return mRingerMode != AudioManager.RINGER_MODE_SILENT;
-                
+
             case AudioManager.VIBRATE_SETTING_ONLY_SILENT:
                 return mRingerMode == AudioManager.RINGER_MODE_VIBRATE;
-            
+
             case AudioManager.VIBRATE_SETTING_OFF:
-                // Phone ringer should always vibrate in vibrate mode 
+                // Phone ringer should always vibrate in vibrate mode
                 if (vibrateType == AudioManager.VIBRATE_TYPE_RINGER) {
                     return mRingerMode == AudioManager.RINGER_MODE_VIBRATE;
                 }
-                
+
             default:
                 return false;
         }
     }
-    
+
     /** @see AudioManager#getVibrateSetting(int) */
     public int getVibrateSetting(int vibrateType) {
         return (mVibrateSetting >> (vibrateType * 2)) & 3;
@@ -498,10 +547,10 @@
     public void setVibrateSetting(int vibrateType, int vibrateSetting) {
 
         mVibrateSetting = getValueForVibrateSetting(mVibrateSetting, vibrateType, vibrateSetting);
-        
+
         // Broadcast change
         broadcastVibrateSetting(vibrateType);
-        
+
         // Post message to set ringer mode (it in turn will post a message
         // to persist)
         sendMsg(mAudioHandler, MSG_PERSIST_VIBRATE_SETTING, SHARED_MSG, SENDMSG_NOOP, 0, 0,
@@ -518,13 +567,13 @@
         // First clear the existing setting. Each vibrate type has two bits in
         // the value. Note '3' is '11' in binary.
         existingValue &= ~(3 << (vibrateType * 2));
-        
+
         // Set into the old value
         existingValue |= (vibrateSetting & 3) << (vibrateType * 2);
-        
+
         return existingValue;
     }
-    
+
     /** @see AudioManager#setMicrophoneMute(boolean) */
     public void setMicrophoneMute(boolean on) {
         if (!checkAudioSettingsPermission("setMicrophoneMute()")) {
@@ -534,15 +583,15 @@
             if (on != mMicMute) {
                 AudioSystem.muteMicrophone(on);
                 mMicMute = on;
-            } 
+            }
         }
     }
-    
+
     /** @see AudioManager#isMicrophoneMute() */
     public boolean isMicrophoneMute() {
         return mMicMute;
     }
-    
+
     /** @see AudioManager#setMode(int) */
     public void setMode(int mode) {
         if (!checkAudioSettingsPermission("setMode()")) {
@@ -552,15 +601,19 @@
             if (mode != mMode) {
                 AudioSystem.setMode(mode);
                 mMode = mode;
-            } 
+            }
+            int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
+            int index = mStreamStates[streamType].mIndex;
+            syncRingerAndNotificationStreamVolume(streamType, index, true);
+            setStreamVolumeInt(streamType, index, true);
         }
     }
-    
+
     /** @see AudioManager#getMode() */
     public int getMode() {
         return mMode;
     }
-    
+
     /** @see AudioManager#setRouting(int, int, int) */
     public void setRouting(int mode, int routes, int mask) {
         if (!checkAudioSettingsPermission("setRouting()")) {
@@ -570,10 +623,14 @@
             if ((mRoutes[mode] & mask) != (routes & mask)) {
                 AudioSystem.setRouting(mode, routes, mask);
                 mRoutes[mode] = (mRoutes[mode] & ~mask) | (routes & mask);
-            } 
+            }
+            int streamType = getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
+            int index = mStreamStates[streamType].mIndex;
+            syncRingerAndNotificationStreamVolume(streamType, index, true);
+            setStreamVolumeInt(streamType, index, true);
         }
     }
-    
+
     /** @see AudioManager#getRouting(int) */
     public int getRouting(int mode) {
         return mRoutes[mode];
@@ -583,7 +640,7 @@
     public boolean isMusicActive() {
         return AudioSystem.isMusicActive();
     }
-    
+
     /** @see AudioManager#setParameter(String, String) */
     public void setParameter(String key, String value) {
         AudioSystem.setParameter(key, value);
@@ -596,8 +653,8 @@
     }
 
     /**
-     * Loads samples into the soundpool. 
-     * This method must be called at when sound effects are enabled  
+     * Loads samples into the soundpool.
+     * This method must be called at when sound effects are enabled
      */
     public boolean loadSoundEffects() {
         synchronized (mSoundEffectsLock) {
@@ -605,17 +662,17 @@
             if (mSoundPool == null) {
                 return false;
             }
-            /* 
-             * poolId table: The value -1 in this table indicates that corresponding 
-             * file (same index in SOUND_EFFECT_FILES[] has not been loaded. 
-             * Once loaded, the value in poolId is the sample ID and the same 
+            /*
+             * poolId table: The value -1 in this table indicates that corresponding
+             * file (same index in SOUND_EFFECT_FILES[] has not been loaded.
+             * Once loaded, the value in poolId is the sample ID and the same
              * sample can be reused for another effect using the same file.
-             */ 
+             */
             int[] poolId = new int[SOUND_EFFECT_FILES.length];
             for (int fileIdx = 0; fileIdx < SOUND_EFFECT_FILES.length; fileIdx++) {
                 poolId[fileIdx] = -1;
             }
-            /* 
+            /*
              * Effects whose value in SOUND_EFFECT_FILES_MAP[effect][1] is -1 must be loaded.
              * If load succeeds, value in SOUND_EFFECT_FILES_MAP[effect][1] is > 0:
              * this indicates we have a valid sample loaded for this effect.
@@ -638,12 +695,12 @@
                 }
             }
         }
-        
+
         return true;
     }
 
     /**
-     *  Unloads samples from the sound pool. 
+     *  Unloads samples from the sound pool.
      *  This method can be called to free some memory when
      *  sound effects are disabled.
      */
@@ -665,12 +722,12 @@
                     mSoundPool.unload(SOUND_EFFECT_FILES_MAP[effect][1]);
                     SOUND_EFFECT_FILES_MAP[effect][1] = -1;
                     poolId[SOUND_EFFECT_FILES_MAP[effect][0]] = -1;
-                } 
+                }
             }
             mSoundPool = null;
         }
     }
-    
+
     ///////////////////////////////////////////////////////////////////////////
     // Internal methods
     ///////////////////////////////////////////////////////////////////////////
@@ -683,7 +740,7 @@
     private boolean checkForRingerModeChange(int oldIndex, int direction) {
         boolean adjustVolumeIndex = true;
         int newRingerMode = mRingerMode;
-        
+
         if (mRingerMode == AudioManager.RINGER_MODE_NORMAL && oldIndex == 1
                 && direction == AudioManager.ADJUST_LOWER) {
             newRingerMode = AudioManager.RINGER_MODE_VIBRATE;
@@ -697,7 +754,7 @@
                 && mRingerMode == AudioManager.RINGER_MODE_SILENT) {
             newRingerMode = AudioManager.RINGER_MODE_VIBRATE;
         }
-        
+
         if (newRingerMode != mRingerMode) {
             setRingerMode(newRingerMode);
 
@@ -708,18 +765,18 @@
              */
             adjustVolumeIndex = false;
         }
-        
+
         return adjustVolumeIndex;
     }
-    
+
     public boolean isStreamAffectedByRingerMode(int streamType) {
-        return (mRingerModeAffectedStreams & (1 << streamType)) != 0;        
+        return (mRingerModeAffectedStreams & (1 << streamType)) != 0;
     }
-    
+
     public boolean isStreamAffectedByMute(int streamType) {
         return (mMuteAffectedStreams & (1 << streamType)) != 0;
     }
-    
+
     private void ensureValidDirection(int direction) {
         if (direction < AudioManager.ADJUST_LOWER || direction > AudioManager.ADJUST_RAISE) {
             throw new IllegalArgumentException("Bad direction " + direction);
@@ -736,13 +793,15 @@
         boolean isOffhook = false;
         try {
             ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
-            isOffhook = phone.isOffhook();
+            if (phone != null) isOffhook = phone.isOffhook();
         } catch (RemoteException e) {
             Log.w(TAG, "Couldn't connect to phone service", e);
         }
 
-        // TODO: applications can influence this
-        if (isOffhook) {
+        if ((getRouting(AudioSystem.MODE_IN_CALL) & AudioSystem.ROUTE_BLUETOOTH_SCO) != 0) {
+            // Log.v(TAG, "getActiveStreamType: Forcing STREAM_BLUETOOTH_SCO...");
+            return AudioSystem.STREAM_BLUETOOTH_SCO;
+        } else if (isOffhook) {
             // Log.v(TAG, "getActiveStreamType: Forcing STREAM_VOICE_CALL...");
             return AudioSystem.STREAM_VOICE_CALL;
         } else if (AudioSystem.isMusicActive()) {
@@ -756,29 +815,33 @@
             return suggestedStreamType;
         }
     }
-    
+
     private void broadcastRingerMode() {
         // Send sticky broadcast
-        Intent broadcast = new Intent(AudioManager.RINGER_MODE_CHANGED_ACTION);
-        broadcast.putExtra(AudioManager.EXTRA_RINGER_MODE, mRingerMode);
-        long origCallerIdentityToken = Binder.clearCallingIdentity();
-        mContext.sendStickyBroadcast(broadcast);
-        Binder.restoreCallingIdentity(origCallerIdentityToken);
+        if (ActivityManagerNative.isSystemReady()) {
+            Intent broadcast = new Intent(AudioManager.RINGER_MODE_CHANGED_ACTION);
+            broadcast.putExtra(AudioManager.EXTRA_RINGER_MODE, mRingerMode);
+            long origCallerIdentityToken = Binder.clearCallingIdentity();
+            mContext.sendStickyBroadcast(broadcast);
+            Binder.restoreCallingIdentity(origCallerIdentityToken);
+        }
     }
-    
+
     private void broadcastVibrateSetting(int vibrateType) {
         // Send broadcast
-        Intent broadcast = new Intent(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
-        broadcast.putExtra(AudioManager.EXTRA_VIBRATE_TYPE, vibrateType);
-        broadcast.putExtra(AudioManager.EXTRA_VIBRATE_SETTING, getVibrateSetting(vibrateType));
-        mContext.sendBroadcast(broadcast);
+        if (ActivityManagerNative.isSystemReady()) {
+            Intent broadcast = new Intent(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);
+            broadcast.putExtra(AudioManager.EXTRA_VIBRATE_TYPE, vibrateType);
+            broadcast.putExtra(AudioManager.EXTRA_VIBRATE_SETTING, getVibrateSetting(vibrateType));
+            mContext.sendBroadcast(broadcast);
+        }
     }
-    
+
     // Message helper methods
     private static int getMsg(int baseMsg, int streamType) {
-        return (baseMsg & 0xffff) | streamType << 16;  
+        return (baseMsg & 0xffff) | streamType << 16;
     }
-    
+
     private static int getMsgBase(int msg) {
         return msg & 0xffff;
     }
@@ -792,11 +855,11 @@
         } else if (existingMsgPolicy == SENDMSG_NOOP && handler.hasMessages(msg)) {
             return;
         }
-        
+
         handler
                 .sendMessageDelayed(handler.obtainMessage(msg, arg1, arg2, obj), delay);
     }
-    
+
     boolean checkAudioSettingsPermission(String method) {
         if (mContext.checkCallingOrSelfPermission("android.permission.MODIFY_AUDIO_SETTINGS")
                 == PackageManager.PERMISSION_GRANTED) {
@@ -809,29 +872,29 @@
         return false;
     }
 
-    
+
     ///////////////////////////////////////////////////////////////////////////
     // Inner classes
     ///////////////////////////////////////////////////////////////////////////
-    
+
     public class VolumeStreamState {
         private final String mVolumeIndexSettingName;
-        private final String mLastAudibleVolumeIndexSettingName; 
+        private final String mLastAudibleVolumeIndexSettingName;
         private final int mStreamType;
-        
+
         private final int[] mVolumes;
         private int mIndex;
         private int mLastAudibleIndex;
         private ArrayList<VolumeDeathHandler> mDeathHandlers; //handles mute/solo requests client death
-        
+
         private VolumeStreamState(String settingName, int streamType, int[] volumes) {
-            
+
             mVolumeIndexSettingName = settingName;
             mLastAudibleVolumeIndexSettingName = settingName + System.APPEND_FOR_LAST_AUDIBLE;
-            
+
             mStreamType = streamType;
             mVolumes = volumes;
-            
+
             final ContentResolver cr = mContentResolver;
             mIndex = getValidIndex(Settings.System.getInt(cr, mVolumeIndexSettingName, AudioManager.DEFAULT_STREAM_VOLUME[streamType]));
             mLastAudibleIndex = getValidIndex(Settings.System.getInt(cr,
@@ -841,14 +904,31 @@
             mDeathHandlers = new ArrayList<VolumeDeathHandler>();
         }
 
+        /**
+         * Constructor to be used when there is no setting associated with the VolumeStreamState.
+         *
+         * @param defaultVolume Default volume of the stream to use.
+         * @param streamType Type of the stream.
+         * @param volumes Volumes levels associated with this stream.
+         */
+        private VolumeStreamState(int defaultVolume, int streamType, int[] volumes) {
+            mVolumeIndexSettingName = null;
+            mLastAudibleVolumeIndexSettingName = null;
+            mIndex = mLastAudibleIndex = defaultVolume;
+            mStreamType = streamType;
+            mVolumes = volumes;
+            AudioSystem.setVolume(mStreamType, defaultVolume);
+            mDeathHandlers = new ArrayList<VolumeDeathHandler>();
+        }
+
         public boolean adjustIndex(int deltaIndex) {
             return setIndex(mIndex + deltaIndex);
         }
-        
+
         public boolean setIndex(int index) {
             int oldIndex = mIndex;
             mIndex = getValidIndex(index);
-            
+
             if (oldIndex != mIndex) {
                 if (mIndex > 0) {
                     mLastAudibleIndex = mIndex;
@@ -858,11 +938,11 @@
                 return false;
             }
         }
-        
+
         public int getMaxIndex() {
             return mVolumes.length - 1;
         }
-        
+
         public void mute(IBinder cb, boolean state) {
             VolumeDeathHandler handler = getDeathHandler(cb, state);
             if (handler == null) {
@@ -871,17 +951,17 @@
             }
             handler.mute(state);
         }
-        
+
         private int getValidIndex(int index) {
             if (index < 0) {
                 return 0;
             } else if (index >= mVolumes.length) {
                 return mVolumes.length - 1;
             }
-            
+
             return index;
         }
-        
+
         private class VolumeDeathHandler implements IBinder.DeathRecipient {
             private IBinder mICallback; // To be notified of client's death
             private int mMuteCount; // Number of active mutes for this client
@@ -924,7 +1004,7 @@
                                 mDeathHandlers.remove(this);
                                 mICallback.unlinkToDeath(this, 0);
                                 if (muteCount() == 0) {
-                                    // If the stream is not mut any more, restore it's volume if 
+                                    // If the stream is not mut any more, restore it's volume if
                                     // ringer mode allows it
                                     if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
                                         setIndex(mLastAudibleIndex);
@@ -980,59 +1060,59 @@
             }
         }
     }
-    
+
     /** Thread that handles native AudioSystem control. */
     private class AudioSystemThread extends Thread {
         AudioSystemThread() {
             super("AudioService");
         }
-        
+
         @Override
         public void run() {
             // Set this thread up so the handler will work on it
             Looper.prepare();
-            
+
             synchronized(AudioService.this) {
                 mAudioHandler = new AudioHandler();
 
                 // Notify that the handler has been created
                 AudioService.this.notify();
             }
-            
+
             // Listen for volume change requests that are set by VolumePanel
             Looper.loop();
         }
     }
-    
+
     /** Handles internal volume messages in separate volume thread. */
     private class AudioHandler extends Handler {
-        
+
         private void setSystemVolume(VolumeStreamState streamState) {
-            
+
             // Adjust volume
             AudioSystem
                     .setVolume(streamState.mStreamType, streamState.mVolumes[streamState.mIndex]);
-            
+
             // Post a persist volume msg
             sendMsg(mAudioHandler, MSG_PERSIST_VOLUME, streamState.mStreamType,
                     SENDMSG_REPLACE, 0, 0, streamState, PERSIST_DELAY);
         }
-        
+
         private void persistVolume(VolumeStreamState streamState) {
             System.putInt(mContentResolver, streamState.mVolumeIndexSettingName,
                     streamState.mIndex);
             System.putInt(mContentResolver, streamState.mLastAudibleVolumeIndexSettingName,
                     streamState.mLastAudibleIndex);
         }
-        
+
         private void persistRingerMode() {
             System.putInt(mContentResolver, System.MODE_RINGER, mRingerMode);
         }
-        
+
         private void persistVibrateSetting() {
             System.putInt(mContentResolver, System.VIBRATE_ON, mVibrateSetting);
         }
-        
+
         private void playSoundEffect(int effectType) {
             synchronized (mSoundEffectsLock) {
                 if (mSoundPool == null) {
@@ -1084,36 +1164,36 @@
                 }
             }
         }
-      
+
         @Override
         public void handleMessage(Message msg) {
             int baseMsgWhat = getMsgBase(msg.what);
-            
+
             switch (baseMsgWhat) {
-                
+
                 case MSG_SET_SYSTEM_VOLUME:
                     setSystemVolume((VolumeStreamState) msg.obj);
                     break;
-                    
+
                 case MSG_PERSIST_VOLUME:
                     persistVolume((VolumeStreamState) msg.obj);
                     break;
-                
+
                 case MSG_PERSIST_RINGER_MODE:
                     persistRingerMode();
                     break;
-                
+
                 case MSG_PERSIST_VIBRATE_SETTING:
                     persistVibrateSetting();
                     break;
-                    
+
                 case MSG_MEDIA_SERVER_DIED:
                     Log.e(TAG, "Media server died.");
-                    // Force creation of new IAudioflinger interface     
+                    // Force creation of new IAudioflinger interface
                     mMediaServerOk = false;
                     AudioSystem.getMode();
                     break;
-                    
+
                 case MSG_MEDIA_SERVER_STARTED:
                     Log.e(TAG, "Media server started.");
                     // Restore audio routing and stream volumes
@@ -1139,5 +1219,5 @@
             }
         }
     }
-    
+
 }
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 37100677..d0fa795 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -43,15 +43,17 @@
     public static final int STREAM_ALARM = 4;
     /* The audio stream for notifications */
     public static final int STREAM_NOTIFICATION = 5;
+    /* @hide The audio stream for phone calls when connected on bluetooth */
+    public static final int STREAM_BLUETOOTH_SCO = 6;
     /**
      * @deprecated Use {@link #numStreamTypes() instead}
      */
     public static final int NUM_STREAMS = 5;
 
     // Expose only the getter method publicly so we can change it in the future
-    private static final int NUM_STREAM_TYPES = 6;
+    private static final int NUM_STREAM_TYPES = 7;
     public static final int getNumStreamTypes() { return NUM_STREAM_TYPES; }
-    
+
     /* max and min volume levels */
     /* Maximum volume setting, for use with setVolume(int,int) */
     public static final int MAX_VOLUME = 100;
@@ -78,7 +80,7 @@
     /*
      * Sets the microphone mute on or off.
      *
-     * param on set <var>true</var> to mute the microphone; 
+     * param on set <var>true</var> to mute the microphone;
      *           <var>false</var> to turn mute off
      * return command completion status see AUDIO_STATUS_OK, see AUDIO_STATUS_ERROR
      */
@@ -116,18 +118,18 @@
     public static final int MODE_RINGTONE           = 1;
     public static final int MODE_IN_CALL            = 2;
     public static final int NUM_MODES               = 3;
-    
+
 
     /* Routing bits for setRouting/getRouting API */
     public static final int ROUTE_EARPIECE          = (1 << 0);
     public static final int ROUTE_SPEAKER           = (1 << 1);
-     
-    /** @deprecated use {@link #ROUTE_BLUETOOTH_SCO} */        
+
+    /** @deprecated use {@link #ROUTE_BLUETOOTH_SCO} */
     @Deprecated public static final int ROUTE_BLUETOOTH = (1 << 2);
     public static final int ROUTE_BLUETOOTH_SCO     = (1 << 2);
     public static final int ROUTE_HEADSET           = (1 << 3);
     public static final int ROUTE_BLUETOOTH_A2DP    = (1 << 4);
-    public static final int ROUTE_ALL               = 0xFFFFFFFF;  
+    public static final int ROUTE_ALL               = 0xFFFFFFFF;
 
     /*
      * Sets the audio routing for a specified mode
@@ -185,7 +187,7 @@
     public static final int AUDIO_STATUS_ERROR = 1;
     /* Media server died. see ErrorCallback */
     public static final int AUDIO_STATUS_SERVER_DIED = 100;
-    
+
     private static ErrorCallback mErrorCallback;
 
     /*
@@ -211,7 +213,7 @@
     {
         mErrorCallback = cb;
     }
-    
+
     private static void errorCallbackFromNative(int error)
     {
         if (mErrorCallback != null) {
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 2b7656f..9bb1df9 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -30,12 +30,31 @@
 /**
  * The AudioTrack class manages and plays a single audio resource for Java applications.
  * It allows to stream PCM audio buffers to the audio hardware for playback. This is
- * be achieved by "pushing" the data to the AudioTrack object using the
- *  {@link #write(byte[], int, int)} or {@link #write(short[], int, int)} method.
- * During construction, an AudioTrack object can be initialized with a given buffer.
- * This size determines how long an AudioTrack can play before running out of data.
- * 
- * {@hide Pending API council review}
+ * achieved by "pushing" the data to the AudioTrack object using one of the
+ *  {@link #write(byte[], int, int)} and {@link #write(short[], int, int)} methods.
+ * <p>An AudioTrack instance can operate under two modes: static of streaming.<br>
+ * The Streaming mode consists in continuously writing data to the AudioTrack, using one
+ * of the write() methods. These are blocking and return when the data has been transferred
+ * from the Java layer to the native layer, and is queued for playback. The streaming mode
+ *  is most useful when playing blocks of audio data that for instance are:
+ * <ul>
+ *   <li>too big to fit in memory because of the duration of the sound to play,</li>
+ *   <li>too big to fit in memory because of the characteristics of the audio data
+ *         (high sampling rate, bits per sample ...)</li>
+ *   <li>chosen, received or generated as the audio keeps playing.</li>
+ * </ul>
+ * The static mode is to be chosen when dealing with short sounds that fit in memory and
+ * that need to be played with the smallest latency possible. Static mode AudioTrack instances can
+ * play the sound without the need to transfer the audio data from Java to the audio hardware
+ * each time the sound is to be played. The static mode will therefore be preferred for UI and
+ * game sounds that are played often, and with the smallest overhead possible.
+ * <p>Upon creation, an AudioTrack object initializes its associated audio buffer.
+ * The size of this buffer, specified during the construction, determines how long an AudioTrack
+ * can play before running out of data.<br>
+ * For an AudioTrack using the static mode, this size is the maximum size of the sound that can
+ * be played from it.<br>
+ * For the streaming mode, data will be written to the hardware in chunks of
+ * sizes inferior to the total buffer size.
  */
 public class AudioTrack
 {
@@ -46,42 +65,41 @@
     private static final float VOLUME_MIN = 0.0f;
     /** Maximum value for a channel volume */
     private static final float VOLUME_MAX = 1.0f;
-    
+
     /** state of an AudioTrack this is stopped */
     public static final int PLAYSTATE_STOPPED = 1;  // matches SL_PLAYSTATE_STOPPED
     /** state of an AudioTrack this is paused */
     public static final int PLAYSTATE_PAUSED  = 2;  // matches SL_PLAYSTATE_PAUSED
     /** state of an AudioTrack this is playing */
     public static final int PLAYSTATE_PLAYING = 3;  // matches SL_PLAYSTATE_PLAYING
-    
-    /** 
-     * Creation mode where audio data is transferred from Java to the native layer 
+
+    /**
+     * Creation mode where audio data is transferred from Java to the native layer
      * only once before the audio starts playing.
      */
     public static final int MODE_STATIC = 0;
-    /** 
-     * Creation mode where audio data is streamed from Java to the native layer 
+    /**
+     * Creation mode where audio data is streamed from Java to the native layer
      * as the audio is playing.
      */
     public static final int MODE_STREAM = 1;
-    
-    /** 
-     * State of an AudioTrack that was not successfully initialized upon creation 
+
+    /**
+     * State of an AudioTrack that was not successfully initialized upon creation
      */
     public static final int STATE_UNINITIALIZED = 0;
-    /** 
+    /**
      * State of an AudioTrack that is ready to be used.
      */
     public static final int STATE_INITIALIZED   = 1;
     /**
-     * State of a successfully initialized AudioTrack that uses static data, 
+     * State of a successfully initialized AudioTrack that uses static data,
      * but that hasn't received that data yet.
      */
     public static final int STATE_NO_STATIC_DATA = 2;
 
-    
-    // to keep in sync with libs/android_runtime/android_media_AudioTrack.cpp
-    //    error codes
+    // Error codes:
+    // to keep in sync with frameworks/base/core/jni/android_media_AudioTrack.cpp
     /**
      * Denotes a successful operation.
      */
@@ -90,139 +108,145 @@
      * Denotes a generic operation failure.
      */
     public  static final int ERROR                                 = -1;
-    private static final int ERROR_NATIVESETUP_AUDIOSYSTEM         = -2;
-    private static final int ERROR_NATIVESETUP_INVALIDCHANNELCOUNT = -3;
-    private static final int ERROR_NATIVESETUP_INVALIDFORMAT       = -4;
-    private static final int ERROR_NATIVESETUP_INVALIDSTREAMTYPE   = -5;
-    private static final int ERROR_NATIVESETUP_NATIVEINITFAILED    = -6;
     /**
      * Denotes a failure due to the use of an invalid value.
      */
-    public  static final int ERROR_BAD_VALUE                       = -7;
+    public  static final int ERROR_BAD_VALUE                       = -2;
     /**
      * Denotes a failure due to the improper use of a method.
      */
-    public  static final int ERROR_INVALID_OPERATION               = -8;
-    //    events
+    public  static final int ERROR_INVALID_OPERATION               = -3;
+
+    private static final int ERROR_NATIVESETUP_AUDIOSYSTEM         = -16;
+    private static final int ERROR_NATIVESETUP_INVALIDCHANNELCOUNT = -17;
+    private static final int ERROR_NATIVESETUP_INVALIDFORMAT       = -18;
+    private static final int ERROR_NATIVESETUP_INVALIDSTREAMTYPE   = -19;
+    private static final int ERROR_NATIVESETUP_NATIVEINITFAILED    = -20;
+
+    // Events:
+    // to keep in sync with frameworks/base/include/media/AudioTrack.h
     /**
      * Event id for when the playback head has reached a previously set marker.
      */
-    protected static final int NATIVE_EVENT_MARKER  = 3;
+    private static final int NATIVE_EVENT_MARKER  = 3;
     /**
      * Event id for when the previously set update period has passed during playback.
      */
-    protected static final int NATIVE_EVENT_NEW_POS = 4;
-    
+    private static final int NATIVE_EVENT_NEW_POS = 4;
+
     private final static String TAG = "AudioTrack-Java";
 
-    
+
     //--------------------------------------------------------------------------
     // Member variables
     //--------------------
     /**
      * Indicates the state of the AudioTrack instance
      */
-    protected int mState = STATE_UNINITIALIZED;
+    private int mState = STATE_UNINITIALIZED;
     /**
      * Indicates the play state of the AudioTrack instance
      */
-    protected int mPlayState = PLAYSTATE_STOPPED;
+    private int mPlayState = PLAYSTATE_STOPPED;
     /**
      * Lock to make sure mPlayState updates are reflecting the actual state of the object.
      */
-    protected final Object mPlayStateLock = new Object();
+    private final Object mPlayStateLock = new Object();
     /**
      * The listener the AudioTrack notifies previously set marker is reached.
      *  @see #setMarkerReachedListener(OnMarkerReachedListener)
      */
-    protected OnMarkerReachedListener mMarkerListener = null;
+    private OnMarkerReachedListener mMarkerListener = null;
     /**
      * Lock to protect marker listener updates against event notifications
      */
-    protected final Object mMarkerListenerLock = new Object();
+    private final Object mMarkerListenerLock = new Object();
     /**
      * The listener the AudioTrack notifies periodically during playback.
      *  @see #setPeriodicNotificationListener(OnPeriodicNotificationListener)
      */
-    protected OnPeriodicNotificationListener mPeriodicListener = null;
+    private OnPeriodicNotificationListener mPeriodicListener = null;
     /**
      * Lock to protect periodic listener updates against event notifications
      */
-    protected final Object mPeriodicListenerLock = new Object();
+    private final Object mPeriodicListenerLock = new Object();
     /**
      * Size of the native audio buffer.
      */
-    protected int mNativeBufferSizeInBytes = 0;
+    private int mNativeBufferSizeInBytes = 0;
     /**
      * Handler for events coming from the native code
      */
-    protected NativeEventHandler mNativeEventHandler = null;
+    private NativeEventHandler mNativeEventHandler = null;
     /**
      * The audio data sampling rate in Hz.
      */
-    protected int mSampleRate = 22050;
+    private int mSampleRate = 22050;
     /**
      * The number of input audio channels (1 is mono, 2 is stereo)
      */
-    protected int mChannelCount = 1;
+    private int mChannelCount = 1;
     /**
      * The type of the audio stream to play. See
-     *   {@link AudioManager.STREAM_VOICE_CALL}, {@link AudioManager.STREAM_SYSTEM},
-     *   {@link AudioManager.STREAM_RING}, {@link AudioManager.STREAM_MUSIC} and
-     *   {@link AudioManager.STREAM_ALARM}
+     *   {@link AudioManager#STREAM_VOICE_CALL}, {@link AudioManager#STREAM_SYSTEM},
+     *   {@link AudioManager#STREAM_RING}, {@link AudioManager#STREAM_MUSIC} and
+     *   {@link AudioManager#STREAM_ALARM}
      */
-    protected int mStreamType = AudioManager.STREAM_MUSIC;
+    private int mStreamType = AudioManager.STREAM_MUSIC;
     /**
      * The way audio is consumed by the hardware, streaming or static.
      */
-    protected int mDataLoadMode = MODE_STREAM;
+    private int mDataLoadMode = MODE_STREAM;
     /**
      * The current audio channel configuration
      */
-    protected int mChannelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
+    private int mChannelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;
     /**
      * The encoding of the audio samples.
-     * @see #AudioFormat.ENCODING_PCM_8BIT
-     * @see #AudioFormat.ENCODING_PCM_16BIT
+     * @see AudioFormat#ENCODING_PCM_8BIT
+     * @see AudioFormat#ENCODING_PCM_16BIT
      */
-    protected int mAudioFormat = AudioFormat.ENCODING_PCM_16BIT;
+    private int mAudioFormat = AudioFormat.ENCODING_PCM_16BIT;
 
 
     //--------------------------------
     // Used exclusively by native code
     //--------------------
-    /** 
-     * Accessed by native methods: provides access to C++ AudioTrack object 
+    /**
+     * Accessed by native methods: provides access to C++ AudioTrack object
      */
     @SuppressWarnings("unused")
     private int mNativeTrackInJavaObj;
-    /** 
+    /**
      * Accessed by native methods: provides access to the JNI data (i.e. resources used by
      * the native AudioTrack object, but not stored in it).
      */
     @SuppressWarnings("unused")
     private int mJniData;
-    
-    
+
+
     //--------------------------------------------------------------------------
     // Constructor, Finalize
     //--------------------
     /**
      * Class constructor.
-     * @param streamType the type of the audio stream. See 
-     *   {@link AudioSystem.STREAM_VOICE_CALL}, {@link AudioSystem.STREAM_SYSTEM},
-     *   {@link AudioSystem.STREAM_RING}, {@link AudioSystem.STREAM_MUSIC} and
-     *   {@link AudioSystem.STREAM_ALARM}
+     * @param streamType the type of the audio stream. See
+
+     *   {@link AudioManager#STREAM_VOICE_CALL}, {@link AudioManager#STREAM_SYSTEM},
+     *   {@link AudioManager#STREAM_RING}, {@link AudioManager#STREAM_MUSIC} and
+     *   {@link AudioManager#STREAM_ALARM}
      * @param sampleRateInHz the sample rate expressed in Hertz. Examples of rates are (but
      *   not limited to) 44100, 22050 and 11025.
-     * @param channelConfig describes the configuration of the audio channels. 
-     *   See {@link AudioFormat.CHANNEL_CONFIGURATION_MONO} and
-     *   {@link AudioFormat.CHANNEL_CONFIGURATION_STEREO}
-     * @param audioFormat the format in which the audio data is represented. 
-     *   See {@link AudioFormat.ENCODING_PCM_16BIT} and 
-     *   {@link AudioFormat.ENCODING_PCM_8BIT}
+     * @param channelConfig describes the configuration of the audio channels.
+
+     *   See {@link AudioFormat#CHANNEL_CONFIGURATION_MONO} and
+     *   {@link AudioFormat#CHANNEL_CONFIGURATION_STEREO}
+
+     * @param audioFormat the format in which the audio data is represented.
+     *   See {@link AudioFormat#ENCODING_PCM_16BIT} and
+     *   {@link AudioFormat#ENCODING_PCM_8BIT}
      * @param bufferSizeInBytes the total size (in bytes) of the buffer where audio data is read
-     *   from for playback. If using the AudioTrack in streaming mode, you can write data into 
+     *   from for playback. If using the AudioTrack in streaming mode, you can write data into
      *   this buffer in smaller chunks than this size. If using the AudioTrack in static mode,
      *   this is the maximum size of the sound that will be played for this instance.
      * @param mode streaming or static buffer. See {@link #MODE_STATIC} and {@link #MODE_STREAM}
@@ -230,7 +254,7 @@
      */
     public AudioTrack(int streamType, int sampleRateInHz, int channelConfig, int audioFormat,
             int bufferSizeInBytes, int mode)
-    throws IllegalArgumentException {   
+    throws IllegalArgumentException {
         mState = STATE_UNINITIALIZED;
 
         audioParamCheck(streamType, sampleRateInHz, channelConfig, audioFormat, mode);
@@ -238,8 +262,8 @@
         audioBuffSizeCheck(bufferSizeInBytes);
 
         // native initialization
-        int initResult = native_setup(new WeakReference<AudioTrack>(this), 
-                mStreamType, mSampleRate, mChannelCount, mAudioFormat, 
+        int initResult = native_setup(new WeakReference<AudioTrack>(this),
+                mStreamType, mSampleRate, mChannelCount, mAudioFormat,
                 mNativeBufferSizeInBytes, mDataLoadMode);
         if (initResult != SUCCESS) {
             loge("Error code "+initResult+" when initializing AudioTrack.");
@@ -252,8 +276,8 @@
             mState = STATE_INITIALIZED;
         }
     }
-    
-    
+
+
     // Convenience method for the constructor's parameter checks.
     // This is where constructor IllegalArgumentException-s are thrown
     // postconditions:
@@ -262,25 +286,27 @@
     //    mAudioFormat is valid
     //    mSampleRate is valid
     //    mDataLoadMode is valid
-    private void audioParamCheck(int streamType, int sampleRateInHz, 
+    private void audioParamCheck(int streamType, int sampleRateInHz,
                                  int channelConfig, int audioFormat, int mode) {
-      
+
         //--------------
         // stream type
         if( (streamType != AudioManager.STREAM_ALARM) && (streamType != AudioManager.STREAM_MUSIC)
            && (streamType != AudioManager.STREAM_RING) && (streamType != AudioManager.STREAM_SYSTEM)
-           && (streamType != AudioManager.STREAM_VOICE_CALL) && (streamType != AudioManager.STREAM_NOTIFICATION) ) {
+           && (streamType != AudioManager.STREAM_VOICE_CALL)
+           && (streamType != AudioManager.STREAM_NOTIFICATION)
+           && (streamType != AudioManager.STREAM_BLUETOOTH_SCO)) {
             throw (new IllegalArgumentException("Invalid stream type."));
         } else {
             mStreamType = streamType;
         }
-        
+
         //--------------
         // sample rate
         if ( (sampleRateInHz < 4000) || (sampleRateInHz > 48000) ) {
             throw (new IllegalArgumentException(sampleRateInHz
                     + "Hz is not a supported sample rate."));
-        } else { 
+        } else {
             mSampleRate = sampleRateInHz;
         }
 
@@ -314,10 +340,10 @@
             break;
         default:
             mAudioFormat = AudioFormat.ENCODING_INVALID;
-            throw(new IllegalArgumentException("Unsupported sample encoding." 
+            throw(new IllegalArgumentException("Unsupported sample encoding."
                 + " Should be ENCODING_PCM_8BIT or ENCODING_PCM_16BIT."));
         }
-        
+
         //--------------
         // audio load mode
         if ( (mode != MODE_STREAM) && (mode != MODE_STATIC) ) {
@@ -326,8 +352,8 @@
             mDataLoadMode = mode;
         }
     }
-    
-    
+
+
     // Convenience method for the contructor's audio buffer size check.
     // preconditions:
     //    mChannelCount is valid
@@ -335,18 +361,18 @@
     // postcondition:
     //    mNativeBufferSizeInBytes is valid (multiple of frame size, positive)
     private void audioBuffSizeCheck(int audioBufferSize) {
-        // NB: this section is only valid with PCM data. 
+        // NB: this section is only valid with PCM data.
         //     To update when supporting compressed formats
-        int frameSizeInBytes = mChannelCount 
+        int frameSizeInBytes = mChannelCount
                 * (mAudioFormat == AudioFormat.ENCODING_PCM_8BIT ? 1 : 2);
         if ((audioBufferSize % frameSizeInBytes != 0) || (audioBufferSize < 1)) {
             throw (new IllegalArgumentException("Invalid audio buffer size."));
         }
-        
+
         mNativeBufferSizeInBytes = audioBufferSize;
     }
-    
-    
+
+
     // Convenience method for the creation of the native event handler
     // It is called only when a non-null event listener is set.
     // precondition:
@@ -361,8 +387,8 @@
             mNativeEventHandler = null;
         }
     }
-    
-    
+
+
     /**
      * Releases the native AudioTrack resources.
      */
@@ -377,7 +403,7 @@
     @Override
     protected void finalize() {
         native_finalize();
-    } 
+    }
 
     //--------------------------------------------------------------------------
     // Getters
@@ -390,7 +416,7 @@
     static public float getMinVolume() {
         return AudioTrack.VOLUME_MIN;
     }
-    
+
     /**
      * Returns the maximum valid volume value. Volume values set above this one will
      * be clamped at this value.
@@ -398,8 +424,8 @@
      */
     static public float getMaxVolume() {
         return AudioTrack.VOLUME_MAX;
-    }    
-    
+    }
+
     /**
      * Returns the configured audio data sample rate in Hz
      */
@@ -408,27 +434,28 @@
     }
 
     /**
-     * Returns the configured audio data format. See {@link #AudioFormat.ENCODING_PCM_16BIT}
-     * and {@link #AudioFormat.ENCODING_PCM_8BIT}.
+     * Returns the configured audio data format. See {@link AudioFormat#ENCODING_PCM_16BIT}
+     * and {@link AudioFormat#ENCODING_PCM_8BIT}.
      */
     public int getAudioFormat() {
         return mAudioFormat;
     }
-    
+
     /**
      * Returns the type of audio stream this AudioTrack is configured for.
-     * Compare the result against {@link AudioManager.STREAM_VOICE_CALL}, 
-     * {@link AudioManager.STREAM_SYSTEM}, {@link AudioManager.STREAM_RING}, 
-     * {@link AudioManager.STREAM_MUSIC} or {@link AudioManager.STREAM_ALARM}
+     * Compare the result against {@link AudioManager#STREAM_VOICE_CALL},
+     * {@link AudioManager#STREAM_SYSTEM}, {@link AudioManager#STREAM_RING},
+     * {@link AudioManager#STREAM_MUSIC} or {@link AudioManager#STREAM_ALARM}
      */
     public int getStreamType() {
         return mStreamType;
     }
 
     /**
-     * Returns the configured channel configuration. 
-     * See {@link #AudioFormat.CHANNEL_CONFIGURATION_MONO}
-     * and {@link #AudioFormat.CHANNEL_CONFIGURATION_STEREO}.
+     * Returns the configured channel configuration.
+
+     * See {@link AudioFormat#CHANNEL_CONFIGURATION_MONO}
+     * and {@link AudioFormat#CHANNEL_CONFIGURATION_STEREO}.
      */
     public int getChannelConfiguration() {
         return mChannelConfiguration;
@@ -443,19 +470,19 @@
 
     /**
      * Returns the state of the AudioTrack instance. This is useful after the
-     * AudioTrack instance has been created to check if it was initialized 
+     * AudioTrack instance has been created to check if it was initialized
      * properly. This ensures that the appropriate hardware resources have been
      * acquired.
      */
     public int getState() {
         return mState;
     }
-    
+
     /**
      * Returns the playback state of the AudioTrack instance.
-     * @see AudioTrack.PLAYSTATE_STOPPED
-     * @see AudioTrack.PLAYSTATE_PAUSED
-     * @see AudioTrack.PLAYSTATE_PLAYING
+     * @see #PLAYSTATE_STOPPED
+     * @see #PLAYSTATE_PAUSED
+     * @see #PLAYSTATE_PLAYING
      */
     public int getPlayState() {
         return mPlayState;
@@ -495,11 +522,49 @@
     static public int getNativeOutputSampleRate() {
         return native_get_output_sample_rate();
     }
-
     
+    /**
+     * {@hide}
+     * Returns the minimum buffer size required for the successful creation of an AudioTrack
+     * object to be created in the {@link #MODE_STREAM} mode.
+     * @param sampleRateInHz the sample rate expressed in Hertz.
+     * @param channelConfig describes the configuration of the audio channels. 
+     *   See {@link AudioFormat#CHANNEL_CONFIGURATION_MONO} and
+     *   {@link AudioFormat#CHANNEL_CONFIGURATION_STEREO}
+     * @param audioFormat the format in which the audio data is represented. 
+     *   See {@link AudioFormat#ENCODING_PCM_16BIT} and 
+     *   {@link AudioFormat#ENCODING_PCM_8BIT}
+     * @return -1 if an invalid parameter was passed or if the implementation was unable to
+     *   query the hardware for its output properties, or the minimum buffer size expressed
+     *   in number of bytes.
+     */
+    static public int getMinBufferSize(int sampleRateInHz, int channelConfig, int audioFormat) {
+        int channelCount = 0;
+        switch(channelConfig) {
+        case AudioFormat.CHANNEL_CONFIGURATION_MONO:
+            channelCount = 1;
+            break;
+        case AudioFormat.CHANNEL_CONFIGURATION_STEREO:
+            channelCount = 2;
+            break;
+        default:
+            loge("getMinBufferSize(): Invalid channel configuration.");
+            return -1;
+        }
+        
+        if ((audioFormat != AudioFormat.ENCODING_PCM_16BIT) 
+            && (audioFormat != AudioFormat.ENCODING_PCM_8BIT)) {
+            loge("getMinBufferSize(): Invalid audio format.");
+            return -1;
+        }
+        
+        return native_get_min_buff_size(sampleRateInHz, channelCount, audioFormat);
+    }
+
+
     //--------------------------------------------------------------------------
     // Initialization / configuration
-    //--------------------  
+    //--------------------
     /**
      * Sets the listener the AudioTrack notifies when a previously set marker is reached.
      * @param listener
@@ -512,8 +577,8 @@
             createNativeEventHandler();
         }
     }
-    
-    
+
+
     /**
      * Sets the listener the AudioTrack notifies periodically during playback.
      * @param listener
@@ -526,22 +591,20 @@
             createNativeEventHandler();
         }
     }
-    
-    
-     /** 
-     * Sets the specified left/right output volume values on the AudioTrack. Values are clamped 
+
+
+     /**
+     * Sets the specified left/right output volume values on the AudioTrack. Values are clamped
      * to the ({@link #getMinVolume()}, {@link #getMaxVolume()}) interval if outside this range.
-     * @param leftVolume output attenuation for the left channel. A value of 0.0f is silence, 
+     * @param leftVolume output attenuation for the left channel. A value of 0.0f is silence,
      *      a value of 1.0f is no attenuation.
      * @param rightVolume output attenuation for the right channel
-     * @return {@link #SUCCESS}
-     * @throws IllegalStateException
+     * @return error code or success, see {@link #SUCCESS},
+     *    {@link #ERROR_INVALID_OPERATION}
      */
-    public int setStereoVolume(float leftVolume, float rightVolume)
-    throws IllegalStateException {
+    public int setStereoVolume(float leftVolume, float rightVolume) {
         if (mState != STATE_INITIALIZED) {
-            throw(new IllegalStateException("setStereoVolume() called on an "+
-                "uninitialized AudioTrack."));
+            return ERROR_INVALID_OPERATION;
         }
 
         // clamp the volumes
@@ -559,11 +622,11 @@
         }
 
         native_setVolume(leftVolume, rightVolume);
-        
+
         return SUCCESS;
     }
-    
-    
+
+
     /**
      * Sets the playback sample rate for this track. This sets the sampling rate at which
      * the audio data will be consumed and played back, not the original sampling rate of the
@@ -573,70 +636,88 @@
      * sample rate (see {@link #getNativeOutputSampleRate()}). Use {@link #getSampleRate()} to
      * check the rate actually used in hardware after potential clamping.
      * @param sampleRateInHz
-     * @return {@link #SUCCESS}
+     * @return error code or success, see {@link #SUCCESS},
+     *    {@link #ERROR_INVALID_OPERATION}
      */
     public int setPlaybackRate(int sampleRateInHz) {
+        if (mState != STATE_INITIALIZED) {
+            return ERROR_INVALID_OPERATION;
+        }
         native_set_playback_rate(sampleRateInHz);
         return SUCCESS;
     }
-    
-    
+
+
     /**
-     * 
+     *
      * @param markerInFrames marker in frames
      * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE},
-     *  {@link #ERROR_INVALID_OPERATION} 
+     *  {@link #ERROR_INVALID_OPERATION}
      */
     public int setNotificationMarkerPosition(int markerInFrames) {
+        if (mState != STATE_INITIALIZED) {
+            return ERROR_INVALID_OPERATION;
+        }
         return native_set_marker_pos(markerInFrames);
     }
-    
-    
+
+
     /**
      * @param periodInFrames update period in frames
      * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_INVALID_OPERATION}
      */
     public int setPositionNotificationPeriod(int periodInFrames) {
+        if (mState != STATE_INITIALIZED) {
+            return ERROR_INVALID_OPERATION;
+        }
         return native_set_pos_update_period(periodInFrames);
     }
-    
-    
+
+
     /**
      * Sets the playback head position. The track must be stopped for the position to be changed.
      * @param positionInFrames playback head position in frames
-     * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE}
-     * @throws java.lang.IllegalStateException if the track is not in 
-     *    the {@link #PLAYSTATE_STOPPED} state.
+     * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE},
+     *    {@link #ERROR_INVALID_OPERATION}
      */
-    public int setPlaybackHeadPosition(int positionInFrames)
-    throws IllegalStateException {
+    public int setPlaybackHeadPosition(int positionInFrames) {
         synchronized(mPlayStateLock) {
             if(mPlayState == PLAYSTATE_STOPPED) {
                 return native_set_position(positionInFrames);
+            } else {
+                return ERROR_INVALID_OPERATION;
             }
         }
-        throw(new IllegalStateException("setPlaybackHeadPosition() called on a track that is "+
-                "not in the PLAYSTATE_STOPPED play state."));
     }
-    
+
     /**
      * Sets the loop points and the loop count. The loop can be infinite.
      * @param startInFrames loop start marker in frames
      * @param endInFrames loop end marker in frames
-     * @param loopCount the number of times the loop is looped. 
+     * @param loopCount the number of times the loop is looped.
      *    A value of -1 means infinite looping.
-     * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE}
+     * @return error code or success, see {@link #SUCCESS}, {@link #ERROR_BAD_VALUE},
+     *    {@link #ERROR_INVALID_OPERATION}
      */
     public int setLoopPoints(int startInFrames, int endInFrames, int loopCount) {
         return native_set_loop(startInFrames, endInFrames, loopCount);
     }
 
+    /**
+     * Sets the initialization state of the instance. To be used in an AudioTrack subclass
+     * constructor to set a subclass-specific post-initialization state.
+     * @param state the state of the AudioTrack instance
+     */
+    protected void setState(int state) {
+        mState = state;
+    }
+
 
     //---------------------------------------------------------
     // Transport control methods
     //--------------------
     /**
-     * Starts playing an AudioTrack. 
+     * Starts playing an AudioTrack.
      * @throws IllegalStateException
      */
     public void play()
@@ -644,7 +725,7 @@
         if (mState != STATE_INITIALIZED) {
             throw(new IllegalStateException("play() called on uninitialized AudioTrack."));
         }
-        
+
         synchronized(mPlayStateLock) {
             native_start();
             mPlayState = PLAYSTATE_PLAYING;
@@ -671,7 +752,7 @@
     /**
      * Pauses the playback of the audio data.
      * @throws IllegalStateException
-     */    
+     */
     public void pause()
     throws IllegalStateException {
         if (mState != STATE_INITIALIZED) {
@@ -685,25 +766,21 @@
             mPlayState = PLAYSTATE_PAUSED;
         }
     }
-    
-    
+
+
     //---------------------------------------------------------
     // Audio data supply
     //--------------------
 
     /**
      * Flushes the audio data currently queued for playback.
-     * @throws IllegalStateException
-     */    
-    public void flush()
-    throws IllegalStateException {
-        if (mState != STATE_INITIALIZED) {
-            throw(new IllegalStateException("flush() called on uninitialized AudioTrack."));
-        }
-        //logd("flush()");
+     */
 
-        // flush the data in native layer
-        native_flush();
+    public void flush() {
+        if (mState == STATE_INITIALIZED) {
+            // flush the data in native layer
+            native_flush();
+        }
 
     }
 
@@ -712,12 +789,12 @@
      * @param audioData the array that holds the data to play.
      * @param offsetInBytes the offset in audioData where the data to play starts.
      * @param sizeInBytes the number of bytes to read in audioData after the offset.
-     * @return the number of bytes that were written.
-     * @throws IllegalStateException
-     */    
-    public int write(byte[] audioData,int offsetInBytes, int sizeInBytes)
-    throws IllegalStateException {
-        if ((mDataLoadMode == MODE_STATIC) 
+     * @return the number of bytes that were written or -1 if the object wasn't properly
+     *    initialized.
+     */
+
+    public int write(byte[] audioData,int offsetInBytes, int sizeInBytes) {
+        if ((mDataLoadMode == MODE_STATIC)
                 && (mState == STATE_NO_STATIC_DATA)
                 && (sizeInBytes > 0)) {
             mState = STATE_INITIALIZED;
@@ -726,24 +803,24 @@
         //     or: how to update data for static tracks?
 
         if (mState != STATE_INITIALIZED) {
-            throw(new IllegalStateException("write() called on uninitialized AudioTrack."));
+            return -1;
         }
 
         return native_write_byte(audioData, offsetInBytes, sizeInBytes);
     }
-    
-    
+
+
     /**
      * Writes the audio data to the audio hardware for playback.
      * @param audioData the array that holds the data to play.
      * @param offsetInShorts the offset in audioData where the data to play starts.
      * @param sizeInShorts the number of bytes to read in audioData after the offset.
-     * @return the number of shorts that were written.
-     * @throws IllegalStateException
-     */    
-    public int write(short[] audioData, int offsetInShorts, int sizeInShorts)
-    throws IllegalStateException {
-        if ((mDataLoadMode == MODE_STATIC) 
+     * @return the number of shorts that were written or -1 if the object wasn't properly
+     *    initialized.
+     */
+
+    public int write(short[] audioData, int offsetInShorts, int sizeInShorts) {
+        if ((mDataLoadMode == MODE_STATIC)
                 && (mState == STATE_NO_STATIC_DATA)
                 && (sizeInShorts > 0)) {
             mState = STATE_INITIALIZED;
@@ -752,13 +829,13 @@
         //     or: how to update data for static tracks?
 
         if (mState != STATE_INITIALIZED) {
-            throw(new IllegalStateException("write() called on uninitialized AudioTrack."));
+            return -1;
         }
 
         return native_write_short(audioData, offsetInShorts, sizeInShorts);
     }
-    
-    
+
+
     /**
      * Notifies the native resource to reuse the audio data already loaded in the native
      * layer. This call is only valid with AudioTrack instances that don't use the streaming
@@ -791,7 +868,7 @@
 
 
     /**
-     * Interface definition for a callback to be invoked for each periodic AudioTrack 
+     * Interface definition for a callback to be invoked for each periodic AudioTrack
      * update during playback. The update interval is set by setPositionNotificationPeriod().
      */
     public interface OnPeriodicNotificationListener  {
@@ -858,28 +935,28 @@
         if (track == null) {
             return;
         }
-        
+
         if (track.mNativeEventHandler != null) {
             Message m = track.mNativeEventHandler.obtainMessage(what, arg1, arg2, obj);
             track.mNativeEventHandler.sendMessage(m);
         }
 
     }
-    
-    
+
+
     //---------------------------------------------------------
     // Native methods called from the Java side
     //--------------------
 
-    private native final int native_setup(Object audiotrack_this, 
-            int streamType, int sampleRate, int nbChannels, int audioFormat, 
+    private native final int native_setup(Object audiotrack_this,
+            int streamType, int sampleRate, int nbChannels, int audioFormat,
             int buffSizeInBytes, int mode);
 
     private native final void native_finalize();
-    
+
     private native final void native_release();
 
-    private native final void native_start();  
+    private native final void native_start();
 
     private native final void native_stop();
 
@@ -887,34 +964,36 @@
 
     private native final void native_flush();
 
-    private native final int native_write_byte(byte[] audioData, 
+    private native final int native_write_byte(byte[] audioData,
                                                int offsetInBytes, int sizeInBytes);
-    
-    private native final int native_write_short(short[] audioData, 
+
+    private native final int native_write_short(short[] audioData,
                                                 int offsetInShorts, int sizeInShorts);
-    
+
     private native final int native_reload_static();
 
     private native final int native_get_native_frame_count();
 
     private native final void native_setVolume(float leftVolume, float rightVolume);
-    
+
     private native final void native_set_playback_rate(int sampleRateInHz);
     private native final int  native_get_playback_rate();
-    
+
     private native final int native_set_marker_pos(int marker);
     private native final int native_get_marker_pos();
-    
+
     private native final int native_set_pos_update_period(int updatePeriod);
     private native final int native_get_pos_update_period();
-    
+
     private native final int native_set_position(int position);
     private native final int native_get_position();
-    
+
     private native final int native_set_loop(int start, int end, int loopCount);
-    
+
     static private native final int native_get_output_sample_rate();
-    
+    static private native final int native_get_min_buff_size(
+            int sampleRateInHz, int channelConfig, int audioFormat);
+
 
     //---------------------------------------------------------
     // Utility methods
@@ -928,7 +1007,4 @@
         Log.e(TAG, "[ android.media.AudioTrack ] " + msg);
     }
 
-}
-
-
-
+}
\ No newline at end of file
diff --git a/media/java/android/media/JetPlayer.java b/media/java/android/media/JetPlayer.java
index b9268d5..bfa2f80 100644
--- a/media/java/android/media/JetPlayer.java
+++ b/media/java/android/media/JetPlayer.java
@@ -17,9 +17,11 @@
 package android.media;
 
 
+import java.io.FileDescriptor;
 import java.lang.ref.WeakReference;
 import java.lang.CloneNotSupportedException;
 
+import android.content.res.AssetFileDescriptor;
 import android.os.Looper;
 import android.os.Handler;
 import android.os.Message;
@@ -29,9 +31,7 @@
  * JetPlayer provides access to JET content playback and control.
  * <p>
  * Use <code>JetPlayer.getJetPlayer()</code> to get an instance of this class.
- * There can only be one instance of this class at any one time.
  * 
- * @hide
  */
 public class JetPlayer
 {    
@@ -39,15 +39,29 @@
     // Constants
     //------------------------
     /**
-     * The maximum number of simultaneous tracks. Use {@link #getMaxTracks()} to
+     * The maximum number of simultaneous tracks. Use __link #getMaxTracks()} to
      * access this value.
      */
-    protected static int MAXTRACKS = 32;
+    private static int MAXTRACKS = 32;
         
-    // These constants are to be kept in sync with the ones in include/media/JetPlayer.h
-    protected static final int JET_USERID_UPDATE           = 1;
-    protected static final int JET_NUMQUEUEDSEGMENT_UPDATE = 2;
-    protected static final int JET_PAUSE_UPDATE            = 3;
+    // to keep in sync with the JetPlayer class constants
+    // defined in frameworks/base/include/media/JetPlayer.h
+    private static final int JET_EVENT                   = 1;
+    private static final int JET_USERID_UPDATE           = 2;
+    private static final int JET_NUMQUEUEDSEGMENT_UPDATE = 3;
+    private static final int JET_PAUSE_UPDATE            = 4;
+    
+    // to keep in sync with external/sonivox/arm-wt-22k/lib_src/jet_data.h
+    // Encoding of event information on 32 bits
+    private static final int JET_EVENT_VAL_MASK    = 0x0000007f; // mask for value
+    private static final int JET_EVENT_CTRL_MASK   = 0x00003f80; // mask for controller
+    private static final int JET_EVENT_CHAN_MASK   = 0x0003c000; // mask for channel
+    private static final int JET_EVENT_TRACK_MASK  = 0x00fc0000; // mask for track number
+    private static final int JET_EVENT_SEG_MASK    = 0xff000000; // mask for segment ID
+    private static final int JET_EVENT_CTRL_SHIFT  = 7;  // shift to get controller number to bit 0
+    private static final int JET_EVENT_CHAN_SHIFT  = 14; // shift to get MIDI channel to bit 0
+    private static final int JET_EVENT_TRACK_SHIFT = 18; // shift to get track ID to bit 0
+    private static final int JET_EVENT_SEG_SHIFT   = 24; // shift to get segment ID to bit 0
 
     
     //--------------------------------------------
@@ -56,13 +70,20 @@
     private EventHandler            mNativeEventHandler = null;
     
     /**
-     * Lock to protect event listener updates against event notifications
+     * Lock to protect status listener updates against status change notifications
      */
-    protected final Object mStatusListenerLock = new Object();
+    private final Object mStatusListenerLock = new Object();
     
-    protected JetStatusUpdateListener mJetStatusUpdateListener = null;
+    /**
+     * Lock to protect the event listener updates against event notifications
+     */
+    private final Object mEventListenerLock = new Object();
     
-    protected static JetPlayer singletonRef;
+    private JetStatusUpdateListener mJetStatusUpdateListener = null;
+    
+    private JetEventListener mJetEventListener = null;
+    
+    private static JetPlayer singletonRef;
     
     
     //--------------------------------
@@ -136,8 +157,14 @@
     //--------------------------------------------
     // Jet functionality
     //------------------------
-    public boolean openJetFile(String path) {
-        return native_openJetFile(path);
+    public boolean loadJetFile(String path) {
+        return native_loadJetFromFile(path);
+    }
+    
+    
+    public boolean loadJetFile(AssetFileDescriptor afd) {
+        return native_loadJetFromFileD(
+                afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
     }
     
     
@@ -195,6 +222,10 @@
     }
     
     
+    public boolean clearQueue() {
+        return native_clearQueue();
+    }
+    
      
     //---------------------------------------------------------
     // Internal class to handle events posted from native code
@@ -211,28 +242,42 @@
         @Override
         public void handleMessage(Message msg) {
             switch(msg.what) {
+            case JET_EVENT:
+                synchronized (mEventListenerLock) {
+                    if (mJetEventListener != null) {
+                        // call the appropriate listener after decoding the event parameters
+                        // encoded in msg.arg1
+                        mJetEventListener.onJetEvent(
+                            mJet,
+                            (short)((msg.arg1 & JET_EVENT_SEG_MASK)   >> JET_EVENT_SEG_SHIFT),
+                            (byte) ((msg.arg1 & JET_EVENT_TRACK_MASK) >> JET_EVENT_TRACK_SHIFT),
+                            (byte) ((msg.arg1 & JET_EVENT_CHAN_MASK)  >> JET_EVENT_CHAN_SHIFT),
+                            (byte) ((msg.arg1 & JET_EVENT_CTRL_MASK)  >> JET_EVENT_CTRL_SHIFT),
+                            (byte)  (msg.arg1 & JET_EVENT_VAL_MASK) );
+                    }
+                }
+                return;
             case JET_USERID_UPDATE:
                 synchronized (mStatusListenerLock) {
                     if (mJetStatusUpdateListener != null) {
-                        mJetStatusUpdateListener.onJetUserIdUpdate(msg.arg1, msg.arg2);
+                        mJetStatusUpdateListener.onJetUserIdUpdate(mJet, msg.arg1, msg.arg2);
                     }
                 }
                 return;
             case JET_NUMQUEUEDSEGMENT_UPDATE:
                 synchronized (mStatusListenerLock) {
                     if (mJetStatusUpdateListener != null) {
-                        mJetStatusUpdateListener.onJetNumQueuedSegmentUpdate(msg.arg1);
+                        mJetStatusUpdateListener.onJetNumQueuedSegmentUpdate(mJet, msg.arg1);
                     }
                 }
                 return;
             case JET_PAUSE_UPDATE:
                 synchronized (mStatusListenerLock) {
                     if (mJetStatusUpdateListener != null)
-                        mJetStatusUpdateListener.onJetPauseUpdate(msg.arg1);
+                        mJetStatusUpdateListener.onJetPauseUpdate(mJet, msg.arg1);
                 }
                 return;
 
-
             default:
                 loge("Unknown message type " + msg.what);
                 return;
@@ -242,7 +287,7 @@
     
     
     //--------------------------------------------
-    // Jet event listener
+    // Jet status update listener
     //------------------------
     public void setStatusUpdateListener(JetStatusUpdateListener listener) {
         synchronized(mStatusListenerLock) {
@@ -255,31 +300,66 @@
     }
     
     /**
-     * Handles the notification when the JET segment userID is updated.
+     * Handles the notification when the JET status is updated.
      */
     public interface JetStatusUpdateListener {
         /**
          * Callback for when JET's currently playing segment userID is updated.
          * 
+         * @param player the JET player the status update is coming from
          * @param userId the ID of the currently playing segment
          * @param repeatCount the repetition count for the segment (0 means it plays once)
          */
-        void onJetUserIdUpdate(int userId, int repeatCount);
+        void onJetUserIdUpdate(JetPlayer player, int userId, int repeatCount);
         
         /**
          * Callback for when JET's number of queued segments is updated.
          * 
+         * @param player the JET player the status update is coming from
          * @param nbSegments the number of segments in the JET queue
          */
-        void onJetNumQueuedSegmentUpdate(int nbSegments);
+        void onJetNumQueuedSegmentUpdate(JetPlayer player, int nbSegments);
         
         /**
          * Callback for when JET pause state is updated.
          * 
+         * @param player the JET player the status update is coming from
          * @param paused indicates whether JET is paused or not
          */
-        void onJetPauseUpdate(int paused);
-    };
+        void onJetPauseUpdate(JetPlayer player, int paused);
+    }
+    
+    
+    //--------------------------------------------
+    // Jet event listener
+    //------------------------
+    public void setEventListener(JetEventListener listener) {
+        synchronized(mEventListenerLock) {
+            mJetEventListener = listener;
+        }
+        
+        if ((listener != null) && (mNativeEventHandler == null)) {
+            createNativeEventHandler();
+        }
+    }
+    
+    /**
+     * Handles the notification when the JET engine generates an event.
+     */
+    public interface JetEventListener {
+        /**
+         * Callback for when the JET engine generates a new event.
+         * 
+         * @param player the JET player the event is coming from
+         * @param segment 8 bit unsigned value
+         * @param track 6 bit unsigned value
+         * @param channel 4 bit unsigned value
+         * @param controller 7 bit unsigned value
+         * @param value 7 bit unsigned value
+         */
+        void onJetEvent(JetPlayer player,
+                short segment, byte track, byte channel, byte controller, byte value);
+    }
     
     
     //--------------------------------------------
@@ -289,7 +369,8 @@
                 int maxTracks, int trackBufferSize);
     private native final void    native_finalize();
     private native final void    native_release();
-    private native final boolean native_openJetFile(String pathToJetFile);
+    private native final boolean native_loadJetFromFile(String pathToJetFile);
+    private native final boolean native_loadJetFromFileD(FileDescriptor fd, long offset, long len);
     private native final boolean native_closeJetFile();
     private native final boolean native_playJet();
     private native final boolean native_pauseJet();
@@ -300,7 +381,8 @@
     private native final boolean native_setMuteFlags(int muteFlags, boolean sync);
     private native final boolean native_setMuteArray(boolean[]muteArray, boolean sync);
     private native final boolean native_setMuteFlag(int trackId, boolean muteFlag, boolean sync);
-    private native final boolean native_triggerClip(int clipId); 
+    private native final boolean native_triggerClip(int clipId);
+    private native final boolean native_clearQueue();
     
     //---------------------------------------------------------
     // Called exclusively by native code
diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java
index 22361aa..f05842d 100644
--- a/media/java/android/media/MediaFile.java
+++ b/media/java/android/media/MediaFile.java
@@ -102,13 +102,17 @@
         addFileType("AMR", FILE_TYPE_AMR, "audio/amr");
         addFileType("AWB", FILE_TYPE_AWB, "audio/amr-wb");
         addFileType("WMA", FILE_TYPE_WMA, "audio/x-ms-wma");    
-        addFileType("OGG", FILE_TYPE_OGG, "application/ogg");    
+        addFileType("OGG", FILE_TYPE_OGG, "application/ogg");
+        addFileType("OGA", FILE_TYPE_OGG, "application/ogg");
  
         addFileType("MID", FILE_TYPE_MID, "audio/midi");
+        addFileType("MIDI", FILE_TYPE_MID, "audio/midi");
         addFileType("XMF", FILE_TYPE_MID, "audio/midi");
         addFileType("RTTTL", FILE_TYPE_MID, "audio/midi");
         addFileType("SMF", FILE_TYPE_SMF, "audio/sp-midi");
         addFileType("IMY", FILE_TYPE_IMY, "audio/imelody");
+        addFileType("RTX", FILE_TYPE_MID, "audio/midi");
+        addFileType("OTA", FILE_TYPE_MID, "audio/midi");
         
         addFileType("MP4", FILE_TYPE_MP4, "video/mp4");
         addFileType("M4V", FILE_TYPE_M4V, "video/mp4");
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 1a82654..601557d 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -39,11 +39,11 @@
 /**
  * MediaPlayer class can be used to control playback
  * of audio/video files and streams. An example on how to use the methods in
- * this class can be found in <a href="../widget/VideoView.html">VideoView</a>.
- * Please see <a href="../../../toolbox/apis/media.html">Android Media APIs</a>
+ * this class can be found in {@link android.widget.VideoView}.
+ * Please see <a href="{@docRoot}guide/topics/media/index.html">Audio and Video</a>
  * for additional help using MediaPlayer.
  *
- * <p>Topics covered are:
+ * <p>Topics covered here are:
  * <ol>
  * <li><a href="#StateDiagram">State Diagram</a>
  * <li><a href="#Valid_and_Invalid_States">Valid and Invalid States</a>
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 651cc41..4a30114 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -24,7 +24,7 @@
  * Used to record audio and video. The recording control is based on a
  * simple state machine (see below). 
  * 
- * <p><img src="../../../images/mediarecorder_state_diagram.gif" border="0" />
+ * <p><img src="{@docRoot}images/mediarecorder_state_diagram.gif" border="0" />
  * </p>
  * 
  * <p>A common case of using MediaRecorder to record audio works as follows:
@@ -42,8 +42,8 @@
  * recorder.release(); // Now the object cannot be reused
  * </pre>
  * 
- * <p>See the <a href="../../../toolbox/apis/media.html">Android Media APIs</a> 
- * page for additional help with using MediaRecorder.
+ * <p>See the <a href="{@docRoot}guide/topics/media/index.html">Audio and Video</a>
+ * documentation for additional help with using MediaRecorder.
  */
 public class MediaRecorder
 {    
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 38203b6..fc8476d 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -118,6 +118,7 @@
     private static final String NOTIFICATIONS_DIR = "/notifications/";
     private static final String ALARMS_DIR = "/alarms/";
     private static final String MUSIC_DIR = "/music/";
+    private static final String PODCAST_DIR = "/podcasts/";
     
     private static final String[] ID3_GENRES = {
         // ID3v1 Genres
@@ -455,8 +456,9 @@
                     boolean ringtones = (path.indexOf(RINGTONES_DIR) > 0);
                     boolean notifications = (path.indexOf(NOTIFICATIONS_DIR) > 0);
                     boolean alarms = (path.indexOf(ALARMS_DIR) > 0);
+                    boolean podcasts = (path.indexOf(PODCAST_DIR) > 0);
                     boolean music = (path.indexOf(MUSIC_DIR) > 0) ||
-                        (!ringtones && !notifications && !alarms);
+                        (!ringtones && !notifications && !alarms && !podcasts);
 
                     if (mFileType == MediaFile.FILE_TYPE_MP3 ||
                             mFileType == MediaFile.FILE_TYPE_MP4 ||
@@ -473,7 +475,7 @@
                         // we used to compute the width and height but it's not worth it
                     }
                     
-                    result = endFile(entry, ringtones, notifications, alarms, music);
+                    result = endFile(entry, ringtones, notifications, alarms, music, podcasts);
                 }
             } catch (RemoteException e) {
                 Log.e(TAG, "RemoteException in MediaScanner.scanFile()", e);
@@ -586,7 +588,8 @@
             return map;
         }
     
-        public Uri endFile(FileCacheEntry entry, boolean ringtones, boolean notifications, boolean alarms, boolean music) 
+        private Uri endFile(FileCacheEntry entry, boolean ringtones, boolean notifications,
+                boolean alarms, boolean music, boolean podcasts) 
                 throws RemoteException {
             // update database
             Uri tableUri;
@@ -634,6 +637,7 @@
                 values.put(Audio.Media.IS_NOTIFICATION, notifications);
                 values.put(Audio.Media.IS_ALARM, alarms);
                 values.put(Audio.Media.IS_MUSIC, music);
+                values.put(Audio.Media.IS_PODCAST, podcasts);
             } else if (isImage) {
                 // nothing right now
             }
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 2810a9c..8eb638e 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -60,15 +60,18 @@
     return sp<Surface>(p);
 }
 
-static void process_media_recorder_call(JNIEnv *env, status_t opStatus, const char* exception, const char* message)
+// Returns true if it throws an exception.
+static bool process_media_recorder_call(JNIEnv *env, status_t opStatus, const char* exception, const char* message)
 {
     LOGV("process_media_recorder_call");
     if (opStatus == (status_t)INVALID_OPERATION) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
+        return true;
     } else if (opStatus != (status_t)OK) {
         jniThrowException(env, exception, message);
+        return true;
     }
-    return;
+    return false;
 }
 
 static void android_media_MediaRecorder_setCamera(JNIEnv* env, jobject thiz, jobject camera)
@@ -196,7 +199,9 @@
     if (surface != NULL) {
         const sp<Surface>& native_surface = get_surface(env, surface);
         LOGI("prepare: surface=%p (id=%d)", native_surface.get(), native_surface->ID());
-        process_media_recorder_call(env, mr->setPreviewSurface(native_surface), "java/lang/RuntimeException", "setPreviewSurface failed.");
+        if (process_media_recorder_call(env, mr->setPreviewSurface(native_surface), "java/lang/RuntimeException", "setPreviewSurface failed.")) {
+            return;
+        }
     }
     process_media_recorder_call(env, mr->prepare(), "java/io/IOException", "prepare failed.");
 }
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp
index 7872a8d..559f9d5 100644
--- a/media/jni/soundpool/SoundPool.cpp
+++ b/media/jni/soundpool/SoundPool.cpp
@@ -64,13 +64,6 @@
         mChannels.push_back(&mChannelPool[i]);
     }
 
-    if (AudioSystem::getOutputFrameCount(&mFrameCount) != NO_ERROR) {
-        mFrameCount = kDefaultFrameCount;
-    }
-    if (AudioSystem::getOutputSamplingRate(&mSampleRate) != NO_ERROR) {
-        mSampleRate = kDefaultSampleRate;
-    }
-
     // start decode thread
     startThreads();
 }
@@ -481,8 +474,8 @@
 {
     AudioTrack* oldTrack;
 
-    LOGV("play: sampleID=%d, channelID=%d, leftVolume=%f, rightVolume=%f, priority=%d, loop=%d, rate=%f",
-            sample->sampleID(), nextChannelID, leftVolume, rightVolume, priority, loop, rate);
+    LOGV("play %p: sampleID=%d, channelID=%d, leftVolume=%f, rightVolume=%f, priority=%d, loop=%d, rate=%f",
+            this, sample->sampleID(), nextChannelID, leftVolume, rightVolume, priority, loop, rate);
 
     // if not idle, this voice is being stolen
     if (mState != IDLE) {
@@ -496,9 +489,17 @@
     }
 
     // initialize track
+    int afFrameCount;
+    int afSampleRate;
+    if (AudioSystem::getOutputFrameCount(&afFrameCount) != NO_ERROR) {
+        afFrameCount = kDefaultFrameCount;
+    }
+    if (AudioSystem::getOutputSamplingRate(&afSampleRate) != NO_ERROR) {
+        afSampleRate = kDefaultSampleRate;
+    }
     int numChannels = sample->numChannels();
     uint32_t sampleRate = uint32_t(float(sample->sampleRate()) * rate + 0.5);
-    uint32_t bufferFrames = (mSoundPool->mFrameCount * sampleRate) / mSoundPool->mSampleRate;
+    uint32_t bufferFrames = (afFrameCount * sampleRate) / afSampleRate;
     uint32_t frameCount = 0;
 
     if (loop) {
@@ -511,12 +512,21 @@
     }
 
     AudioTrack* newTrack;
+    
+    // mToggle toggles each time a track is started on a given channel.
+    // The toggle is concatenated with the SoundChannel address and passed to AudioTrack
+    // as callback user data. This enables the detection of callbacks received from the old
+    // audio track while the new one is being started and avoids processing them with 
+    // wrong audio audio buffer size  (mAudioBufferSize)
+    unsigned long toggle = mToggle ^ 1;
+    void *userData = (void *)((unsigned long)this | toggle);
+    
 #ifdef USE_SHARED_MEM_BUFFER
     newTrack = new AudioTrack(mSoundPool->streamType(), sampleRate, sample->format(),
-            numChannels, sample->getIMemory(), 0, callback, this);
+            numChannels, sample->getIMemory(), 0, callback, userData);
 #else
     newTrack = new AudioTrack(mSoundPool->streamType(), sampleRate, sample->format(),
-            numChannels, frameCount, 0, callback, this, bufferFrames);
+            numChannels, frameCount, 0, callback, userData, bufferFrames);
 #endif
     if (newTrack->initCheck() != NO_ERROR) {
         LOGE("Error creating AudioTrack");
@@ -529,6 +539,8 @@
 
     {
         Mutex::Autolock lock(&mLock);
+        // From now on, AudioTrack callbacks recevieved with previous toggle value will be ignored.
+        mToggle = toggle;
         oldTrack = mAudioTrack;
         mAudioTrack = newTrack;
         mPos = 0;
@@ -583,7 +595,13 @@
 
 void SoundChannel::callback(int event, void* user, void *info)
 {
-    SoundChannel* channel = static_cast<SoundChannel*>(user);
+    unsigned long toggle = (unsigned long)user & 1;
+    SoundChannel* channel = static_cast<SoundChannel*>((void *)((unsigned long)user & ~1));
+    
+    if (channel->mToggle != toggle) {
+        LOGV("callback with wrong toggle");
+        return;
+    }
     channel->process(event, info);
 }
 
@@ -592,7 +610,7 @@
     //LOGV("process(%d)", mChannelID);
     sp<Sample> sample = mSample;
 
-    LOGV("SoundChannel::process event %d", event);
+//    LOGV("SoundChannel::process event %d", event);
 
     if (event == AudioTrack::EVENT_MORE_DATA) {
        AudioTrack::Buffer* b = static_cast<AudioTrack::Buffer *>(info);
diff --git a/media/jni/soundpool/SoundPool.h b/media/jni/soundpool/SoundPool.h
index d02ae8b..7802781 100644
--- a/media/jni/soundpool/SoundPool.h
+++ b/media/jni/soundpool/SoundPool.h
@@ -118,7 +118,7 @@
 class SoundChannel : public SoundEvent {
 public:
     enum state { IDLE, RESUMING, STOPPING, PAUSED, PLAYING };
-    SoundChannel() : mAudioTrack(0), mState(IDLE), mNumChannels(1), mPos(0) {}
+    SoundChannel() : mAudioTrack(0), mState(IDLE), mNumChannels(1), mPos(0), mToggle(0) {}
     ~SoundChannel();
     void init(SoundPool* soundPool);
     void play(const sp<Sample>& sample, int channelID, float leftVolume, float rightVolume,
@@ -151,6 +151,7 @@
     int                 mNumChannels;
     int                 mPos;
     int                 mAudioBufferSize;
+    unsigned long       mToggle;
 };
 
 // application object for managing a pool of sounds
@@ -215,8 +216,6 @@
     int                     mAllocated;
     int                     mNextSampleID;
     int                     mNextChannelID;
-    int                     mFrameCount;
-    int                     mSampleRate;
     bool                    mQuit;
 };
 
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk
index 2a697b9..8020da2 100644
--- a/media/libmedia/Android.mk
+++ b/media/libmedia/Android.mk
@@ -4,6 +4,7 @@
 LOCAL_SRC_FILES:= \
 	AudioTrack.cpp \
 	IAudioFlinger.cpp \
+	IAudioFlingerClient.cpp \
 	IAudioTrack.cpp \
 	IAudioRecord.cpp \
 	AudioRecord.cpp \
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 3d39181..a987b92 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -128,8 +128,22 @@
         return BAD_VALUE;
     }
 
-    // TODO: Get input frame count from hardware.
-    int minFrameCount = 1024*2;
+    size_t inputBuffSizeInBytes = -1;
+    if (AudioSystem::getInputBufferSize(sampleRate, format, channelCount, &inputBuffSizeInBytes)
+        != NO_ERROR) {
+            LOGE("AudioSystem could not query the input buffer size.");
+            return NO_INIT;
+    }
+    if (inputBuffSizeInBytes == 0) {
+        LOGE("Recording parameters are not supported: sampleRate %d, channelCount %d, format %d",
+            sampleRate, channelCount, format);
+        return BAD_VALUE;
+    }
+    int frameSizeInBytes = channelCount * (format == AudioSystem::PCM_16_BIT ? 2 : 1);
+    
+    // We use 2* size of input buffer for ping pong use of record buffer.
+    int minFrameCount = 2 * inputBuffSizeInBytes / frameSizeInBytes;
+    LOGV("AudioRecord::set() minFrameCount = %d", minFrameCount);
 
     if (frameCount == 0) {
         frameCount = minFrameCount;
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index a375b55..cf91105 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -15,6 +15,8 @@
  */
 
 #define LOG_TAG "AudioSystem"
+//#define LOG_NDEBUG 0
+
 #include <utils/Log.h>
 #include <utils/IServiceManager.h>
 #include <media/AudioSystem.h>
@@ -26,12 +28,17 @@
 // client singleton for AudioFlinger binder interface
 Mutex AudioSystem::gLock;
 sp<IAudioFlinger> AudioSystem::gAudioFlinger;
-sp<AudioSystem::DeathNotifier> AudioSystem::gDeathNotifier;
+sp<AudioSystem::AudioFlingerClient> AudioSystem::gAudioFlingerClient;
 audio_error_callback AudioSystem::gAudioErrorCallback = NULL;
 // Cached values
 int AudioSystem::gOutSamplingRate = 0;
 int AudioSystem::gOutFrameCount = 0;
 uint32_t AudioSystem::gOutLatency = 0;
+// Cached values for recording queries
+uint32_t AudioSystem::gPrevInSamplingRate = 16000;
+int AudioSystem::gPrevInFormat = AudioSystem::PCM_16_BIT;
+int AudioSystem::gPrevInChannelCount = 1;
+size_t AudioSystem::gInBuffSize = 0;
 
 
 // establish binder interface to AudioFlinger service
@@ -48,15 +55,16 @@
             LOGW("AudioFlinger not published, waiting...");
             usleep(500000); // 0.5 s
         } while(true);
-        if (gDeathNotifier == NULL) {
-            gDeathNotifier = new DeathNotifier();
+        if (gAudioFlingerClient == NULL) {
+            gAudioFlingerClient = new AudioFlingerClient();
         } else {
             if (gAudioErrorCallback) {
                 gAudioErrorCallback(NO_ERROR);
             }
          }
-        binder->linkToDeath(gDeathNotifier);
+        binder->linkToDeath(gAudioFlingerClient);
         gAudioFlinger = interface_cast<IAudioFlinger>(binder);
+        gAudioFlinger->registerClient(gAudioFlingerClient);
         // Cache frequently accessed parameters 
         gOutFrameCount = (int)gAudioFlinger->frameCount();
         gOutSamplingRate = (int)gAudioFlinger->sampleRate();
@@ -250,7 +258,7 @@
         const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
         if (af == 0) return PERMISSION_DENIED;
         // gOutSamplingRate is updated by get_audio_flinger()
-    }    
+    }
     *samplingRate = gOutSamplingRate;
     
     return NO_ERROR;
@@ -261,7 +269,7 @@
     if (gOutFrameCount == 0) {
         const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
         if (af == 0) return PERMISSION_DENIED;
-        // gOutSamplingRate is updated by get_audio_flinger()
+        // gOutFrameCount is updated by get_audio_flinger()
     }
     *frameCount = gOutFrameCount;
     return NO_ERROR;
@@ -279,14 +287,38 @@
     return NO_ERROR;
 }
 
+status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, int format, int channelCount, 
+    size_t* buffSize)
+{
+    // Do we have a stale gInBufferSize or are we requesting the input buffer size for new values
+    if ((gInBuffSize == 0) || (sampleRate != gPrevInSamplingRate) || (format != gPrevInFormat) 
+        || (channelCount != gPrevInChannelCount)) {
+        // save the request params
+        gPrevInSamplingRate = sampleRate;
+        gPrevInFormat = format; 
+        gPrevInChannelCount = channelCount;
+
+        gInBuffSize = 0;
+        const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+        if (af == 0) {
+            return PERMISSION_DENIED;
+        }
+        gInBuffSize = af->getInputBufferSize(sampleRate, format, channelCount);
+    } 
+    *buffSize = gInBuffSize;
+    
+    return NO_ERROR;
+}
+
 // ---------------------------------------------------------------------------
 
-void AudioSystem::DeathNotifier::binderDied(const wp<IBinder>& who) {
+void AudioSystem::AudioFlingerClient::binderDied(const wp<IBinder>& who) {   
     Mutex::Autolock _l(AudioSystem::gLock);
     AudioSystem::gAudioFlinger.clear();
     AudioSystem::gOutSamplingRate = 0;
     AudioSystem::gOutFrameCount = 0;
     AudioSystem::gOutLatency = 0;
+    AudioSystem::gInBuffSize = 0;
     
     if (gAudioErrorCallback) {
         gAudioErrorCallback(DEAD_OBJECT);
@@ -294,6 +326,15 @@
     LOGW("AudioFlinger server died!");
 }
 
+void AudioSystem::AudioFlingerClient::audioOutputChanged(uint32_t frameCount, uint32_t samplingRate, uint32_t latency) {
+
+    AudioSystem::gOutFrameCount = frameCount;
+    AudioSystem::gOutSamplingRate = samplingRate;
+    AudioSystem::gOutLatency = latency;
+
+    LOGV("AudioFlinger output changed!");
+}
+
 void AudioSystem::setErrorCallback(audio_error_callback cb) {
     Mutex::Autolock _l(AudioSystem::gLock);
     gAudioErrorCallback = cb;
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index f9f8568..63b2012 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -603,13 +603,17 @@
             if (__builtin_expect(result!=NO_ERROR, false)) { 
                 cblk->waitTimeMs += WAIT_PERIOD_MS;
                 if (cblk->waitTimeMs >= cblk->bufferTimeoutMs) {
-                    LOGW(   "obtainBuffer timed out (is the CPU pegged?) "
-                            "user=%08x, server=%08x", cblk->user, cblk->server);
-                    mAudioTrack->start(); // FIXME: Wake up audioflinger
-                    timeout = 1;
+                    // timing out when a loop has been set and we have already written upto loop end
+                    // is a normal condition: no need to wake AudioFlinger up.
+                    if (cblk->user < cblk->loopEnd) {
+                        LOGW(   "obtainBuffer timed out (is the CPU pegged?) "
+                                "user=%08x, server=%08x", cblk->user, cblk->server);
+                        mAudioFlinger->wakeUp();
+                        timeout = 1;
+                    }
                     cblk->waitTimeMs = 0;
                 }
-                ;
+                
                 if (--waitCount == 0) {
                     return TIMED_OUT;
                 }
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 018ea6c..4215820 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -51,6 +51,9 @@
     GET_MIC_MUTE,
     IS_MUSIC_ACTIVE,
     SET_PARAMETER,
+    REGISTER_CLIENT,
+    GET_INPUTBUFFERSIZE,
+    WAKE_UP
 };
 
 class BpAudioFlinger : public BpInterface<IAudioFlinger>
@@ -303,6 +306,33 @@
         remote()->transact(SET_PARAMETER, data, &reply);
         return reply.readInt32();
     }
+    
+    virtual void registerClient(const sp<IAudioFlingerClient>& client)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+        data.writeStrongBinder(client->asBinder());
+        remote()->transact(REGISTER_CLIENT, data, &reply);
+    }
+    
+    virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+        data.writeInt32(sampleRate);
+        data.writeInt32(format);
+        data.writeInt32(channelCount);
+        remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
+        return reply.readInt32();
+    }
+    
+    virtual void wakeUp()
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+        remote()->transact(WAKE_UP, data, &reply);
+        return;
+    }
 };
 
 IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -470,6 +500,26 @@
             reply->writeInt32( setParameter(key, value) );
             return NO_ERROR;
         } break;
+        case REGISTER_CLIENT: {
+            CHECK_INTERFACE(IAudioFlinger, data, reply);
+            sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient>(data.readStrongBinder());
+            registerClient(client);
+            return NO_ERROR;
+        } break;
+        case GET_INPUTBUFFERSIZE: {
+            CHECK_INTERFACE(IAudioFlinger, data, reply);
+            uint32_t sampleRate = data.readInt32();
+            int format = data.readInt32();
+            int channelCount = data.readInt32();
+            reply->writeInt32( getInputBufferSize(sampleRate, format, channelCount) );
+            return NO_ERROR;
+        } break;
+        case WAKE_UP: {
+            CHECK_INTERFACE(IAudioFlinger, data, reply);
+            wakeUp();
+            return NO_ERROR;
+        } break;
+
         default:
             return BBinder::onTransact(code, data, reply, flags);
     }
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp
new file mode 100644
index 0000000..d956266
--- /dev/null
+++ b/media/libmedia/IAudioFlingerClient.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "IAudioFlingerClient"
+#include <utils/Log.h>
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/Parcel.h>
+
+#include <media/IAudioFlingerClient.h>
+
+namespace android {
+
+enum {
+    AUDIO_OUTPUT_CHANGED = IBinder::FIRST_CALL_TRANSACTION
+};
+
+class BpAudioFlingerClient : public BpInterface<IAudioFlingerClient>
+{
+public:
+    BpAudioFlingerClient(const sp<IBinder>& impl)
+        : BpInterface<IAudioFlingerClient>(impl)
+    {
+    }
+
+    void audioOutputChanged(uint32_t frameCount, uint32_t samplingRate, uint32_t latency)
+    {
+        Parcel data, reply;
+        data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
+        data.writeInt32(frameCount);
+        data.writeInt32(samplingRate);
+        data.writeInt32(latency);
+        remote()->transact(AUDIO_OUTPUT_CHANGED, data, &reply);
+    }
+};
+
+IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient");
+
+// ----------------------------------------------------------------------
+
+#define CHECK_INTERFACE(interface, data, reply) \
+        do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \
+            LOGW("Call incorrectly routed to " #interface); \
+            return PERMISSION_DENIED; \
+        } } while (0)
+
+status_t BnAudioFlingerClient::onTransact(
+    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+    switch(code) {
+        case AUDIO_OUTPUT_CHANGED: {
+            CHECK_INTERFACE(IAudioFlingerClient, data, reply);
+            uint32_t frameCount = data.readInt32();
+            uint32_t samplingRate = data.readInt32();
+            uint32_t latency = data.readInt32();
+            audioOutputChanged(frameCount, samplingRate, latency);
+            return NO_ERROR;
+        } break;
+        default:
+            return BBinder::onTransact(code, data, reply, flags);
+    }
+}
+
+// ----------------------------------------------------------------------------
+
+}; // namespace android
diff --git a/media/libmedia/JetPlayer.cpp b/media/libmedia/JetPlayer.cpp
index f0edf88..ead24d4 100644
--- a/media/libmedia/JetPlayer.cpp
+++ b/media/libmedia/JetPlayer.cpp
@@ -214,12 +214,15 @@
             }
             p += count * pLibConfig->numChannels;
             num_output += count * pLibConfig->numChannels * sizeof(EAS_PCM);
+            
+             // send events that were generated (if any) to the event callback
+            fireEventsFromJetQueue();
         }
 
         // update playback state
         //LOGV("JetPlayer::render(): updating state");
         JET_Status(mEasData, &mJetStatus);
-        fireEventOnStatusChange();
+        fireUpdateOnStatusChange();
         mPaused = mJetStatus.paused;
 
         mMutex.unlock(); // UNLOCK ]]]]]]]] -----------------------------------
@@ -261,9 +264,9 @@
 
 
 //-------------------------------------------------------------------------------------------------
-// fire up an event if any of the status fields has changed
+// fire up an update if any of the status fields has changed
 // precondition: mMutex locked
-void JetPlayer::fireEventOnStatusChange()
+void JetPlayer::fireUpdateOnStatusChange()
 {
     if(  (mJetStatus.currentUserID      != mPreviousJetStatus.currentUserID)
        ||(mJetStatus.segmentRepeatCount != mPreviousJetStatus.segmentRepeatCount) ) {
@@ -303,9 +306,31 @@
 
 
 //-------------------------------------------------------------------------------------------------
-int JetPlayer::openFile(const char* path)
+// fire up all the JET events in the JET engine queue (until the queue is empty)
+// precondition: mMutex locked
+void JetPlayer::fireEventsFromJetQueue()
 {
-    LOGV("JetPlayer::openFile(): path=%s", path);
+    if(!mEventCallback) {
+        // no callback, just empty the event queue
+        while (JET_GetEvent(mEasData, NULL, NULL)) { }
+        return;
+    }
+    
+    EAS_U32 rawEvent;
+    while (JET_GetEvent(mEasData, &rawEvent, NULL)) {
+        mEventCallback(
+            JetPlayer::JET_EVENT,
+            rawEvent,
+            -1,
+            mJavaJetPlayerRef);
+    }
+}
+
+
+//-------------------------------------------------------------------------------------------------
+int JetPlayer::loadFromFile(const char* path)
+{
+    LOGV("JetPlayer::loadFromFile(): path=%s", path);
 
     Mutex::Autolock lock(mMutex);
 
@@ -326,6 +351,29 @@
     return( result );
 }
 
+
+//-------------------------------------------------------------------------------------------------
+int JetPlayer::loadFromFD(const int fd, const long long offset, const long long length)
+{
+    LOGV("JetPlayer::loadFromFD(): fd=%d offset=%lld length=%lld", fd, offset, length);
+    
+    Mutex::Autolock lock(mMutex);
+
+    mEasJetFileLoc = (EAS_FILE_LOCATOR) malloc(sizeof(EAS_FILE));
+    mEasJetFileLoc->fd = fd;
+    mEasJetFileLoc->offset = offset;
+    mEasJetFileLoc->length = length;
+    mEasJetFileLoc->path = NULL;
+    
+    EAS_RESULT result = JET_OpenFile(mEasData, mEasJetFileLoc);
+    if(result != EAS_SUCCESS)
+        mState = EAS_STATE_ERROR;
+    else
+        mState = EAS_STATE_OPEN;
+    return( result );
+}
+
+
 //-------------------------------------------------------------------------------------------------
 int JetPlayer::closeFile()
 {
@@ -348,7 +396,7 @@
     JET_Status(mEasData, &mJetStatus);
     this->dumpJetStatus(&mJetStatus);
     
-    fireEventOnStatusChange();
+    fireUpdateOnStatusChange();
 
     // wake up render thread
     LOGV("JetPlayer::play(): wakeup render thread");
@@ -368,7 +416,7 @@
 
     JET_Status(mEasData, &mJetStatus);
     this->dumpJetStatus(&mJetStatus);
-    fireEventOnStatusChange();
+    fireUpdateOnStatusChange();
 
 
     return result;
@@ -408,6 +456,14 @@
 }
 
 //-------------------------------------------------------------------------------------------------
+int JetPlayer::clearQueue()
+{
+    LOGV("JetPlayer::clearQueue");
+    Mutex::Autolock lock(mMutex);
+    return JET_Clear_Queue(mEasData);
+}
+
+//-------------------------------------------------------------------------------------------------
 void JetPlayer::dump()
 {
     LOGE("JetPlayer dump: JET file=%s", mEasJetFileLoc->path);
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 584d135..fa36460 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -97,10 +97,6 @@
         LOGE("Unable to marshal AudioFlinger");
         return;
     }
-    if (AudioSystem::getOutputFrameCount(&mBufferSize) != NO_ERROR) {
-        LOGE("Unable to marshal AudioFlinger");
-        return;
-    }
     mStreamType = streamType;
     mVolume = volume;
     mpAudioTrack = 0;
@@ -275,9 +271,9 @@
         mpAudioTrack = 0;
     }
 
-   // Open audio track in mono, PCM 16bit, default sampling rate, 2 buffers of
+   // Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
     mpAudioTrack
-            = new AudioTrack(mStreamType, 0, AudioSystem::PCM_16_BIT, 1, NUM_PCM_BUFFERS*mBufferSize, 0, audioCallback, this, mBufferSize);
+            = new AudioTrack(mStreamType, 0, AudioSystem::PCM_16_BIT, 1, 0, 0, audioCallback, this, 0);
 
     if (mpAudioTrack == 0) {
         LOGE("AudioTrack allocation failed");
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index ebdbda8..31ff507 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -172,7 +172,7 @@
 status_t MediaPlayer::setDataSource(const char *url)
 {
     LOGV("setDataSource(%s)", url);
-    status_t err = UNKNOWN_ERROR;
+    status_t err = BAD_VALUE;
     if (url != NULL) {
         const sp<IMediaPlayerService>& service(getMediaPlayerService());
         if (service != 0) {
@@ -199,7 +199,7 @@
 {
     LOGV("setVideoSurface");
     Mutex::Autolock _l(mLock);
-    if (mPlayer == 0) return UNKNOWN_ERROR;
+    if (mPlayer == 0) return NO_INIT;
     return  mPlayer->setVideoSurface(surface->getISurface());
 }
 
@@ -219,7 +219,7 @@
 {
     LOGV("prepare");
     Mutex::Autolock _l(mLock);
-    if (mPrepareSync) return UNKNOWN_ERROR;
+    if (mPrepareSync) return -EALREADY;
     mPrepareSync = true;
     status_t ret = prepareAsync_l();
     if (ret != NO_ERROR) return ret;
@@ -253,7 +253,6 @@
         status_t ret = mPlayer->start();
         if (ret != NO_ERROR) {
             mCurrentState = MEDIA_PLAYER_STATE_ERROR;
-            ret = UNKNOWN_ERROR;
         } else {
             if (mCurrentState == MEDIA_PLAYER_PLAYBACK_COMPLETE) {
                 LOGV("playback completed immediately following start()");
@@ -275,7 +274,6 @@
         status_t ret = mPlayer->stop();
         if (ret != NO_ERROR) {
             mCurrentState = MEDIA_PLAYER_STATE_ERROR;
-            ret = UNKNOWN_ERROR;
         } else {
             mCurrentState = MEDIA_PLAYER_STOPPED;
         }
@@ -295,7 +293,6 @@
         status_t ret = mPlayer->pause();
         if (ret != NO_ERROR) {
             mCurrentState = MEDIA_PLAYER_STATE_ERROR;
-            ret = UNKNOWN_ERROR;
         } else {
             mCurrentState = MEDIA_PLAYER_PAUSED;
         }
@@ -422,7 +419,6 @@
         if (ret != NO_ERROR) {
             LOGE("reset() failed with return code (%d)", ret);
             mCurrentState = MEDIA_PLAYER_STATE_ERROR;
-            ret = UNKNOWN_ERROR;
         } else {
             mCurrentState = MEDIA_PLAYER_IDLE;
         }
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 53831717..9e366e2 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -61,113 +61,32 @@
 #undef __KERNEL__
 #endif
 
-/*
-    When USE_SIGBUS_HANDLER is set to 1, a handler for SIGBUS will be
-    installed, which allows us to recover when there is a read error
-    when accessing an mmap'ed file. However, since the kernel folks
-    don't seem to like it when non kernel folks install signal handlers
-    in their own process, this is currently disabled.
-    Without the handler, the process hosting this service will die and
-    then be restarted. This is mostly OK right now because the process is
-    not being shared with any other services, and clients of the service
-    will be notified of its death in their MediaPlayer.onErrorListener
-    callback, assuming they have installed one, and can then attempt to
-    do their own recovery.
-    It does open us up to a DOS attack against the media server, where
-    a malicious application can trivially force the media server to
-    restart continuously.
-*/
-#define USE_SIGBUS_HANDLER 0
-
-// TODO: Temp hack until we can register players
-static const char* MIDI_FILE_EXTS[] =
-{
-        ".mid",
-        ".smf",
-        ".xmf",
-        ".imy",
-        ".rtttl",
-        ".rtx",
-        ".ota"
-};
 
 namespace android {
 
+// TODO: Temp hack until we can register players
+typedef struct {
+    const char *extension;
+    const player_type playertype;
+} extmap;
+extmap FILE_EXTS [] =  {
+        {".mid", SONIVOX_PLAYER},
+        {".midi", SONIVOX_PLAYER},
+        {".smf", SONIVOX_PLAYER},
+        {".xmf", SONIVOX_PLAYER},
+        {".imy", SONIVOX_PLAYER},
+        {".rtttl", SONIVOX_PLAYER},
+        {".rtx", SONIVOX_PLAYER},
+        {".ota", SONIVOX_PLAYER},
+        {".ogg", VORBIS_PLAYER},
+        {".oga", VORBIS_PLAYER},
+};
+
 // TODO: Find real cause of Audio/Video delay in PV framework and remove this workaround
 /* static */ const uint32_t MediaPlayerService::AudioOutput::kAudioVideoDelayMs = 96;
 /* static */ int MediaPlayerService::AudioOutput::mMinBufferCount = 4;
 /* static */ bool MediaPlayerService::AudioOutput::mIsOnEmulator = false;
 
-static struct sigaction oldact;
-static pthread_key_t sigbuskey;
-
-static void sigbushandler(int signal, siginfo_t *info, void *context)
-{
-    char *faultaddr = (char*) info->si_addr;
-    LOGE("SIGBUS at %p\n", faultaddr);
-
-    struct mediasigbushandler* h = (struct mediasigbushandler*) pthread_getspecific(sigbuskey);
-
-    if (h) {
-        if (h->len) {
-            if (faultaddr < h->base || faultaddr >= h->base + h->len) {
-                // outside specified range, call old handler
-                if (oldact.sa_flags & SA_SIGINFO) {
-                    oldact.sa_sigaction(signal, info, context);
-                } else {
-                    oldact.sa_handler(signal);
-                }
-                return;
-            }
-        }
-
-        // no range specified or address was in range
-
-        if (h->handlesigbus) {
-            if (h->handlesigbus(info, h)) {
-                // thread's handler didn't handle the signal
-                if (oldact.sa_flags & SA_SIGINFO) {
-                    oldact.sa_sigaction(signal, info, context);
-                } else {
-                    oldact.sa_handler(signal);
-                }
-            }
-            return;
-        }
-
-        if (h->sigbusvar) {
-            // map in a zeroed out page so the operation can succeed
-            long pagesize = sysconf(_SC_PAGE_SIZE);
-            long pagemask = ~(pagesize - 1);
-            void * pageaddr = (void*) (((long)(faultaddr)) & pagemask);
-
-            void * bar = mmap( pageaddr, pagesize, PROT_READ, MAP_ANONYMOUS|MAP_PRIVATE|MAP_FIXED, -1, 0);
-            if (bar == MAP_FAILED) {
-                LOGE("couldn't map zero page at %p: %s", pageaddr, strerror(errno));
-                if (oldact.sa_flags & SA_SIGINFO) {
-                    oldact.sa_sigaction(signal, info, context);
-                } else {
-                    oldact.sa_handler(signal);
-                }
-                return;
-            }
-
-            LOGE("setting sigbusvar at %p", h->sigbusvar);
-            *(h->sigbusvar) = 1;
-            return;
-        }
-    }
-
-    LOGE("SIGBUS: no handler, or improperly configured handler (%p)", h);
-
-    if (oldact.sa_flags & SA_SIGINFO) {
-        oldact.sa_sigaction(signal, info, context);
-    } else {
-        oldact.sa_handler(signal);
-    }
-    return;
-}
-
 void MediaPlayerService::instantiate() {
     defaultServiceManager()->addService(
             String16("media.player"), new MediaPlayerService());
@@ -177,25 +96,10 @@
 {
     LOGV("MediaPlayerService created");
     mNextConnId = 1;
-
-    pthread_key_create(&sigbuskey, NULL);
-
-
-#if USE_SIGBUS_HANDLER
-    struct sigaction act;
-    memset(&act,0, sizeof act);
-    act.sa_sigaction = sigbushandler;
-    act.sa_flags = SA_SIGINFO;
-    sigaction(SIGBUS, &act, &oldact);
-#endif
 }
 
 MediaPlayerService::~MediaPlayerService()
 {
-#if USE_SIGBUS_HANDLER
-    sigaction(SIGBUS, &oldact, NULL);
-#endif
-    pthread_key_delete(sigbuskey);
     LOGV("MediaPlayerService destroyed");
 }
 
@@ -481,7 +385,7 @@
         locator.offset = offset;
         locator.length = length;
         EAS_HANDLE  eashandle;
-        if (EAS_OpenFile(easdata, &locator, &eashandle, NULL) == EAS_SUCCESS) {
+        if (EAS_OpenFile(easdata, &locator, &eashandle) == EAS_SUCCESS) {
             EAS_CloseFile(easdata, eashandle);
             EAS_Shutdown(easdata);
             return SONIVOX_PLAYER;
@@ -498,22 +402,16 @@
 
     // use MidiFile for MIDI extensions
     int lenURL = strlen(url);
-    for (int i = 0; i < NELEM(MIDI_FILE_EXTS); ++i) {
-        int len = strlen(MIDI_FILE_EXTS[i]);
+    for (int i = 0; i < NELEM(FILE_EXTS); ++i) {
+        int len = strlen(FILE_EXTS[i].extension);
         int start = lenURL - len;
         if (start > 0) {
-            if (!strncmp(url + start, MIDI_FILE_EXTS[i], len)) {
-                LOGV("Type is MIDI");
-                return SONIVOX_PLAYER;
+            if (!strncmp(url + start, FILE_EXTS[i].extension, len)) {
+                return FILE_EXTS[i].playertype;
             }
         }
     }
 
-    if (strcmp(url + strlen(url) - 4, ".ogg") == 0) {
-        LOGV("Type is Vorbis");
-        return VORBIS_PLAYER;
-    }
-
     // Fall through to PV
     return PV_PLAYER;
 }
@@ -539,7 +437,6 @@
     if (p != NULL) {
         if (p->initCheck() == NO_ERROR) {
             p->setNotifyCallback(cookie, notifyFunc);
-            p->setSigBusHandlerStructTLSKey(sigbuskey);
         } else {
             p.clear();
         }
diff --git a/media/libmediaplayerservice/MidiFile.cpp b/media/libmediaplayerservice/MidiFile.cpp
index cfad66c..7ce2fab 100644
--- a/media/libmediaplayerservice/MidiFile.cpp
+++ b/media/libmediaplayerservice/MidiFile.cpp
@@ -40,8 +40,6 @@
 
 // ----------------------------------------------------------------------------
 
-extern pthread_key_t EAS_sigbuskey;
-
 namespace android {
 
 // ----------------------------------------------------------------------------
@@ -132,7 +130,7 @@
     mFileLocator.fd = -1;
     mFileLocator.offset = 0;
     mFileLocator.length = 0;
-    EAS_RESULT result = EAS_OpenFile(mEasData, &mFileLocator, &mEasHandle, &mMemFailedVar);
+    EAS_RESULT result = EAS_OpenFile(mEasData, &mFileLocator, &mEasHandle);
     if (result == EAS_SUCCESS) {
         updateState();
     }
@@ -148,12 +146,6 @@
     return NO_ERROR;
 }
 
-status_t MidiFile::setSigBusHandlerStructTLSKey(pthread_key_t key)
-{
-    EAS_sigbuskey = key;
-    return 0;
-}
-
 status_t MidiFile::setDataSource(int fd, int64_t offset, int64_t length)
 {
     LOGV("MidiFile::setDataSource fd=%d", fd);
@@ -168,7 +160,7 @@
     mFileLocator.fd = dup(fd);
     mFileLocator.offset = offset;
     mFileLocator.length = length;
-    EAS_RESULT result = EAS_OpenFile(mEasData, &mFileLocator, &mEasHandle, &mMemFailedVar);
+    EAS_RESULT result = EAS_OpenFile(mEasData, &mFileLocator, &mEasHandle);
     updateState();
 
     if (result != EAS_SUCCESS) {
@@ -332,7 +324,7 @@
         EAS_HANDLE easHandle = NULL;
         EAS_RESULT result = EAS_Init(&easData);
         if (result == EAS_SUCCESS) {
-            result = EAS_OpenFile(easData, &mFileLocator, &easHandle, NULL);
+            result = EAS_OpenFile(easData, &mFileLocator, &easHandle);
         }
         if (result == EAS_SUCCESS) {
             result = EAS_Prepare(easData, easHandle);
@@ -451,8 +443,6 @@
 
     LOGV("MidiFile::render");
 
-    struct mediasigbushandler sigbushandler;
-
     // allocate render buffer
     mAudioBuffer = new EAS_PCM[pLibConfig->mixBufferSize * pLibConfig->numChannels * NUM_BUFFERS];
     if (!mAudioBuffer) {
@@ -468,10 +458,6 @@
         mCondition.signal();
     }
 
-    sigbushandler.handlesigbus = NULL;
-    sigbushandler.sigbusvar = mMemFailedVar;
-    pthread_setspecific(EAS_sigbuskey, &sigbushandler);
-
     while (1) {
         mMutex.lock();
 
diff --git a/media/libmediaplayerservice/MidiFile.h b/media/libmediaplayerservice/MidiFile.h
index 9d2dfdd..302f1cf 100644
--- a/media/libmediaplayerservice/MidiFile.h
+++ b/media/libmediaplayerservice/MidiFile.h
@@ -30,7 +30,6 @@
                         ~MidiFile();
 
     virtual status_t    initCheck();
-    virtual status_t    setSigBusHandlerStructTLSKey(pthread_key_t key);
     virtual status_t    setDataSource(const char* path);
     virtual status_t    setDataSource(int fd, int64_t offset, int64_t length);
     virtual status_t    setVideoSurface(const sp<ISurface>& surface) { return UNKNOWN_ERROR; }
@@ -57,7 +56,6 @@
 
     Mutex               mMutex;
     Condition           mCondition;
-    int*                mMemFailedVar;
     EAS_DATA_HANDLE     mEasData;
     EAS_HANDLE          mEasHandle;
     EAS_PCM*            mAudioBuffer;
diff --git a/media/libmediaplayerservice/VorbisPlayer.cpp b/media/libmediaplayerservice/VorbisPlayer.cpp
index 9a64403..009d628 100644
--- a/media/libmediaplayerservice/VorbisPlayer.cpp
+++ b/media/libmediaplayerservice/VorbisPlayer.cpp
@@ -455,13 +455,15 @@
                     current_section = 0;
                     numread = ov_read(&mVorbisFile, mAudioBuffer, AUDIOBUFFER_SIZE, &current_section);
                 } else {
-                    sendEvent(MEDIA_PLAYBACK_COMPLETE);
                     mAudioSink->stop();
                     audioStarted = false;
                     mRender = false;
                     mPaused = true;
                     int endpos = ov_time_tell(&mVorbisFile);
 
+                    LOGV("send MEDIA_PLAYBACK_COMPLETE");
+                    sendEvent(MEDIA_PLAYBACK_COMPLETE);
+
                     // wait until we're started again
                     LOGV("playback complete - wait for signal");
                     mCondition.wait(mMutex);
diff --git a/media/sdutils/sdutil.cpp b/media/sdutils/sdutil.cpp
index 0daa523..a9aabf0 100644
--- a/media/sdutils/sdutil.cpp
+++ b/media/sdutils/sdutil.cpp
@@ -114,6 +114,16 @@
     return -1;
 }
 
+static int format(const char* path) {
+    String16 string(path);
+
+    if (isMounted(path))
+        return -EBUSY;
+    gMountService->formatMedia(string);
+
+    return 0;
+}
+
 static int umsEnable(bool enable) {
     gMountService->setMassStorageEnabled(enable);
     return 0;
@@ -129,6 +139,9 @@
     if (strcmp(command, "mount") == 0) {
         android::init();
         return android::mount(argument);
+    } else if (strcmp(command, "format") == 0) {
+        android::init();
+        return android::format(argument);
     } else if (strcmp(command, "unmount") == 0) {
         android::init();
         return android::unmount(argument);
@@ -145,6 +158,7 @@
     fprintf(stderr, "usage:\n"
                     "    sdutil mount <mount path>          - mounts the SD card at the given mount point\n"
                     "    sdutil unmount <mount path>        - unmounts the SD card at the given mount point\n"
+                    "    sdutil format <mount path>         - formats the SD card at the given mount point\n"
                     "    sdutil ums enable                  - enables USB mass storage\n"
                     "    sdutil ums disable                 - disnables USB mass storage\n"
                     );
diff --git a/media/tests/MediaFrameworkTest/AndroidManifest.xml b/media/tests/MediaFrameworkTest/AndroidManifest.xml
index 16e658a..a32f590 100644
--- a/media/tests/MediaFrameworkTest/AndroidManifest.xml
+++ b/media/tests/MediaFrameworkTest/AndroidManifest.xml
@@ -42,5 +42,10 @@
          android:targetPackage="com.android.mediaframeworktest"
          android:label="MediaFramework unit tests InstrumentationRunner">
      </instrumentation>
+     
+     <instrumentation android:name=".MediaRecorderStressTestRunner"
+         android:targetPackage="com.android.mediaframeworktest"
+         android:label="MediaRecorder stress tests InstrumentationRunner">
+     </instrumentation>
 
 </manifest>
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
index 3d3878e..1731940 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
@@ -21,6 +21,7 @@
 import com.android.mediaframeworktest.functional.MediaMetadataTest;
 import com.android.mediaframeworktest.functional.CameraTest;
 import com.android.mediaframeworktest.functional.MediaRecorderTest;
+import com.android.mediaframeworktest.functional.MediaAudioTrackTest;
 
 import junit.framework.TestSuite;
 
@@ -48,6 +49,7 @@
         suite.addTestSuite(MediaMetadataTest.class);
         suite.addTestSuite(CameraTest.class);
         suite.addTestSuite(MediaRecorderTest.class);
+        suite.addTestSuite(MediaAudioTrackTest.class);
         return suite;
     }
 
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java
index 5843007..5e9c488 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaNames.java
@@ -25,16 +25,16 @@
 public class MediaNames {
   
     //Audio files
-    public static final String MP3CBR = "/sdcard/music/MP3CBR.mp3";  
-    public static final String MP3VBR = "/sdcard/music/MP3VBR.mp3";
-    public static final String SHORTMP3 = "/sdcard/music/SHORTMP3.mp3";
-    public static final String MIDI = "/sdcard/music/MIDI.mid";
-    public static final String WMA9 = "/sdcard/music/WMA9.wma";
-    public static final String WMA10 = "/sdcard/music/WMA10.wma";
-    public static final String WAV = "/sdcard/music/complicated_wav.wav";
-    public static final String AMR = "/sdcard/music/AMRNB.amr";
-    public static final String OGG = "/sdcard/music/Mists_of_Time-4T.ogg";
-    public static final String OGGSHORT = "/sdcard/music/Skippy.ogg";
+    public static final String MP3CBR = "/sdcard/media_api/music/MP3CBR.mp3";  
+    public static final String MP3VBR = "/sdcard/media_api/music/MP3VBR.mp3";
+    public static final String SHORTMP3 = "/sdcard/media_api/music/SHORTMP3.mp3";
+    public static final String MIDI = "/sdcard/media_api/music/MIDI.mid";
+    public static final String WMA9 = "/sdcard/media_api/music/WMA9.wma";
+    public static final String WMA10 = "/sdcard/media_api/music/WMA10.wma";
+    public static final String WAV = "/sdcard/media_api/music/complicated_wav.wav";
+    public static final String AMR = "/sdcard/media_api/music/AMRNB.amr";
+    public static final String OGG = "/sdcard/media_api/music/Mists_of_Time-4T.ogg";
+    public static final String OGGSHORT = "/sdcard/media_api/music/Skippy.ogg";
   
     public static final int MP3CBR_LENGTH = 231116;  
     public static final int MP3VBR_LENGTH = 126407;
@@ -60,20 +60,20 @@
     //public static final String VIDEO_RTSP3GP = "rtsp://193.159.241.21/sp/alizee05.3gp";
   
     //local video
-    public static final String VIDEO_MP4 = "/sdcard/video/gingerkids.MP4";
-    public static final String VIDEO_LONG_3GP = "/sdcard/video/radiohead.3gp";
-    public static final String VIDEO_SHORT_3GP = "/sdcard/video/short.3gp";
-    public static final String VIDEO_LARGE_SIZE_3GP = "/sdcard/video/border_large.3gp";
-    public static final String VIDEO_H263_AAC = "/sdcard/video/H263_AAC.3gp";
-    public static final String VIDEO_H263_AMR = "/sdcard/video/H263_AMR.3gp";		
-    public static final String VIDEO_H264_AAC = "/sdcard/video/H264_AAC.3gp";
-    public static final String VIDEO_H264_AMR = "/sdcard/video/H264_AMR.3gp";   
-    public static final String VIDEO_WMV = "/sdcard/video/bugs.wmv";
-    public static final String VIDEO_HIGHRES_H263 = "/sdcard/video/h263_qcif_30fps.3gp";
-    public static final String VIDEO_HIGHRES_MP4 = "/sdcard/video/mpeg4_qvga_24fps.3gp";
+    public static final String VIDEO_MP4 = "/sdcard/media_api/video/gingerkids.MP4";
+    public static final String VIDEO_LONG_3GP = "/sdcard/media_api/video/radiohead.3gp";
+    public static final String VIDEO_SHORT_3GP = "/sdcard/media_api/video/short.3gp";
+    public static final String VIDEO_LARGE_SIZE_3GP = "/sdcard/media_api/video/border_large.3gp";
+    public static final String VIDEO_H263_AAC = "/sdcard/media_api/video/H263_AAC.3gp";
+    public static final String VIDEO_H263_AMR = "/sdcard/media_api/video/H263_AMR.3gp";
+    public static final String VIDEO_H264_AAC = "/sdcard/media_api/video/H264_AAC.3gp";
+    public static final String VIDEO_H264_AMR = "/sdcard/media_api/video/H264_AMR.3gp";   
+    public static final String VIDEO_WMV = "/sdcard/media_api/video/bugs.wmv";
+    public static final String VIDEO_HIGHRES_H263 = "/sdcard/media_api/video/h263_qcif_30fps.3gp";
+    public static final String VIDEO_HIGHRES_MP4 = "/sdcard/media_api/video/mpeg4_qvga_24fps.3gp";
     
     //ringtone
-    public static final String ringtone = "/sdcard/ringtones/F1_NewVoicemail.mp3";
+    public static final String ringtone = "/sdcard/media_api/ringtones/F1_NewVoicemail.mp3";
   
     //streaming mp3
     public static final String STREAM_LARGE_MP3 = 
@@ -110,264 +110,266 @@
       "http://wms.pv.com:7070/MediaDownloadContent/UserUploads/beefcake.mp3";
 
     //Sonivox
-    public static String MIDIFILES[] = { "/sdcard/music/Leadsol.mxmf",
-        "/sdcard/music/abba.imy", "/sdcard/music/ants.mid",
-        "/sdcard/music/greensleeves.rtttl", "/sdcard/music/test.ota"};
+    public static String MIDIFILES[] = { 
+        "/sdcard/media_api/music/Leadsol.mxmf",
+        "/sdcard/media_api/music/abba.imy", "/sdcard/media_api/music/ants.mid",
+        "/sdcard/media_api/music/greensleeves.rtttl", "/sdcard/media_api/music/test.ota"};
   
     //Performance measurement
-    public static String[] WAVFILES = { "/sdcard/music_perf/WAV/M1F1-AlawWE-AFsp.wav",
-        "/sdcard/music_perf/WAV/M1F1-float64-AFsp.wav",
-        "/sdcard/music_perf/WAV/song.wav",
-        "/sdcard/music_perf/WAV/WAVEtest.wav",
-        "/sdcard/music_perf/WAV/WAVEtest_out.wav",
-        "/sdcard/music_perf/WAV/test_out.wav"};
-                    		
+    public static String[] WAVFILES = { 
+        "/sdcard/media_api/music_perf/WAV/M1F1-AlawWE-AFsp.wav",
+        "/sdcard/media_api/music_perf/WAV/M1F1-float64-AFsp.wav",
+        "/sdcard/media_api/music_perf/WAV/song.wav",
+        "/sdcard/media_api/music_perf/WAV/WAVEtest.wav",
+        "/sdcard/media_api/music_perf/WAV/WAVEtest_out.wav",
+        "/sdcard/media_api/music_perf/WAV/test_out.wav"};
+        
     public static String[] AMRNBFILES = { 
-        "/sdcard/music_perf/AMR/AI_AMR-NB_5.9kbps_6.24kbps_8khz_mono_NMC.amr",
-        "/sdcard/music_perf/AMR/AI_AMR-NB_5.15kbps_5.46kbps_8khz_mono_NMC.amr",
-        "/sdcard/music_perf/AMR/AI_AMR-NB_7.4kbps_7.80kbps_8khz_mono_NMC.amr",
-        "/sdcard/music_perf/AMR/AI_AMR-NB_7.95kbps_9.6kbps_8khz_mono_NMC.amr",
-        "/sdcard/music_perf/AMR/AI_AMR-NB_10.2kbps_10.48kbps_8khz_mono_NMC.amr"};
+        "/sdcard/media_api/music_perf/AMR/AI_AMR-NB_5.9kbps_6.24kbps_8khz_mono_NMC.amr",
+        "/sdcard/media_api/music_perf/AMR/AI_AMR-NB_5.15kbps_5.46kbps_8khz_mono_NMC.amr",
+        "/sdcard/media_api/music_perf/AMR/AI_AMR-NB_7.4kbps_7.80kbps_8khz_mono_NMC.amr",
+        "/sdcard/media_api/music_perf/AMR/AI_AMR-NB_7.95kbps_9.6kbps_8khz_mono_NMC.amr",
+        "/sdcard/media_api/music_perf/AMR/AI_AMR-NB_10.2kbps_10.48kbps_8khz_mono_NMC.amr"};
   
     public static String[] AMRWBFILES = { 
-        "/sdcard/music_perf/AMRWB/NIN_AMR-WB_15.85kbps_16kbps.amr",
-        "/sdcard/music_perf/AMRWB/NIN_AMR-WB_18.25kbps_18kbps.amr",
-        "/sdcard/music_perf/AMRWB/NIN_AMR-WB_19.85kbps_20kbps.amr",
-        "/sdcard/music_perf/AMRWB/NIN_AMR-WB_23.05kbps_23kbps.amr",
-        "/sdcard/music_perf/AMRWB/NIN_AMR-WB_23.85kbps_24kbps.amr",
-        "/sdcard/music_perf/AMRWB/PD_AMR-WB_19.85kbps_20kbps.amr",
-        "/sdcard/music_perf/AMRWB/PD_AMR-WB_23.05kbps_23kbps.amr",
-        "/sdcard/music_perf/AMRWB/PD_AMR-WB_23.85kbps_24kbps.amr",
-        "/sdcard/music_perf/AMRWB/WC_AMR-WB_23.05kbps_23kbps.amr",
-        "/sdcard/music_perf/AMRWB/WC_AMR-WB_23.85kbps_24kbps.amr", };
+        "/sdcard/media_api/music_perf/AMRWB/NIN_AMR-WB_15.85kbps_16kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/NIN_AMR-WB_18.25kbps_18kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/NIN_AMR-WB_19.85kbps_20kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/NIN_AMR-WB_23.05kbps_23kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/NIN_AMR-WB_23.85kbps_24kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/PD_AMR-WB_19.85kbps_20kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/PD_AMR-WB_23.05kbps_23kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/PD_AMR-WB_23.85kbps_24kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/WC_AMR-WB_23.05kbps_23kbps.amr",
+        "/sdcard/media_api/music_perf/AMRWB/WC_AMR-WB_23.85kbps_24kbps.amr", };
  
     public static String[] MP3FILES = { 
-        "/sdcard/music_perf/MP3/NIN_56kbps_32khz_stereo_VBR_MCA.MP3",
-        "/sdcard/music_perf/MP3/NIN_80kbps_32khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_80kbps_44.1khz_stereo_VBR_MCA.mp3", 
-        "/sdcard/music_perf/MP3/NIN_80kbps_48khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_112kbps_32khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_112kbps_44.1khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_112kbps_48khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_192kbps_32khz_mono_CBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_192kbps_44.1khz_mono_CBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_192kbps_48khz_mono_CBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_256kbps_44.1khz_mono_CBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/NIN_256kbps_48khz_mono_CBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/PD_112kbps_32khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/PD_112kbps_44.1khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/PD_112kbps_48khz_stereo_VBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/PD_192kbps_32khz_mono_CBR_DPA.mp3",
-        "/sdcard/music_perf/MP3/PD_256kbps_44.1khz_mono_CBR_DPA.mp3",
-        "/sdcard/music_perf/MP3/PD_256kbps_48khz_mono_CBR_MCA.mp3",
-        "/sdcard/music_perf/MP3/WC_256kbps_44.1khz_mono_CBR_DPA.mp3",
-        "/sdcard/music_perf/MP3/WC_256kbps_48khz_mono_CBR_DPA.mp3",
-        "/sdcard/music_perf/regular_album_photo/Apologize.mp3",
-        "/sdcard/music_perf/regular_album_photo/Because_Of_You.mp3",
-        "/sdcard/music_perf/regular_album_photo/Complicated.mp3",
-        "/sdcard/music_perf/regular_album_photo/Glamorous.mp3",
-        "/sdcard/music_perf/regular_album_photo/Im_With_You.mp3",
-        "/sdcard/music_perf/regular_album_photo/Smile.mp3",
-        "/sdcard/music_perf/regular_album_photo/Suddenly_I_See.mp3",
-        "/sdcard/music_perf/regular_album_photo/When You Say Nothing At All.mp3",
-        "/sdcard/music_perf/regular_album_photo/my_happy_ending.mp3"};
+        "/sdcard/media_api/music_perf/MP3/NIN_56kbps_32khz_stereo_VBR_MCA.MP3",
+        "/sdcard/media_api/music_perf/MP3/NIN_80kbps_32khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_80kbps_44.1khz_stereo_VBR_MCA.mp3", 
+        "/sdcard/media_api/music_perf/MP3/NIN_80kbps_48khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_112kbps_32khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_112kbps_44.1khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_112kbps_48khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_192kbps_32khz_mono_CBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_192kbps_44.1khz_mono_CBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_192kbps_48khz_mono_CBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_256kbps_44.1khz_mono_CBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/NIN_256kbps_48khz_mono_CBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/PD_112kbps_32khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/PD_112kbps_44.1khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/PD_112kbps_48khz_stereo_VBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/PD_192kbps_32khz_mono_CBR_DPA.mp3",
+        "/sdcard/media_api/music_perf/MP3/PD_256kbps_44.1khz_mono_CBR_DPA.mp3",
+        "/sdcard/media_api/music_perf/MP3/PD_256kbps_48khz_mono_CBR_MCA.mp3",
+        "/sdcard/media_api/music_perf/MP3/WC_256kbps_44.1khz_mono_CBR_DPA.mp3",
+        "/sdcard/media_api/music_perf/MP3/WC_256kbps_48khz_mono_CBR_DPA.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/Apologize.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/Because_Of_You.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/Complicated.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/Glamorous.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/Im_With_You.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/Smile.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/Suddenly_I_See.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/When You Say Nothing At All.mp3",
+        "/sdcard/media_api/music_perf/regular_album_photo/my_happy_ending.mp3"};
   
     public static String[] AACFILES = { 
-        "/sdcard/music_perf/AAC/AI_AAC_24kbps_12khz_Mono_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/AI_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/AI_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/AI_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/AI_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/AI_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/NIN_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/NIN_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/NIN_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/NIN_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/NIN_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PD_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PD_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PD_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PD_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PD_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PV_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PV_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PV_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PV_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/PV_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/WC_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/WC_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/WC_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/WC_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
-        "/sdcard/music_perf/AAC/WC_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",      
+        "/sdcard/media_api/music_perf/AAC/AI_AAC_24kbps_12khz_Mono_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/AI_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/AI_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/AI_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/AI_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/AI_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/NIN_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/NIN_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/NIN_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/NIN_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/NIN_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PD_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PD_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PD_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PD_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PD_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PV_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PV_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PV_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PV_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/PV_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/WC_AAC_56kbps_22.05khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/WC_AAC_56kbps_32khz_Stereo_CBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/WC_AAC_56kbps_44.1khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/WC_AAC_80kbps_32khz_Stereo_1pCBR_SSE.mp4",
+        "/sdcard/media_api/music_perf/AAC/WC_AAC_80kbps_32khz_Stereo_CBR_SSE.mp4",      
     };
     
-    public static String[] VIDEOFILES = { "/sdcard/video_perf/AI_CTO_Mpeg4_32kbps_10fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
-      "/sdcard/video_perf/AI_CTO_Mpeg4_32kbps_12fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
-      "/sdcard/video_perf/AI_CTO_Mpeg4_32kbps_15fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
-      "/sdcard/video_perf/AI_CTO_Mpeg4_32kbps_5fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
-      "/sdcard/video_perf/AI_CTO_Mpeg4_32kbps_5fps_SQCIF_128x96+AAC_8kbps_8khz_mono_SSE.mp4",
-      "/sdcard/video_perf/AI_CTO_Mpeg4_32kbps_7.5fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
-      "/sdcard/video_perf/AI_WMV_1024kbps_20fps_QCIF_176x144_noaudio_SSE.wmv",
-      "/sdcard/video_perf/AI_WMV_1024kbps_25fps_QCIF_176x144_noaudio_SSE.wmv",
-      "/sdcard/video_perf/Chicken.wmv",
-      "/sdcard/video_perf/MP_qcif_15fps_100kbps_48kHz_192kbps_30secs.wmv",
-      "/sdcard/video_perf/NIN_CTO_H264_123kbps_5fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
-      "/sdcard/video_perf/NIN_CTO_H264_96kbps_10.2fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
-      "/sdcard/video_perf/NIN_CTO_H264_96kbps_12fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
-      "/sdcard/video_perf/NIN_CTO_H264_96kbps_15fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
-      "/sdcard/video_perf/NIN_CTO_Mpeg4_123kbps_15fps_QCIF_176x144+AAC_32kbps_22khz_mono_SSE.3gp",
-      "/sdcard/video_perf/NIN_CTO_Mpeg4_123kbps_7.5fps_QCIF_176x144+AAC_32kbps_22khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/NIN_CTO_Mpeg4_128kbps_10fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/NIN_CTO_Mpeg4_128kbps_12fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/NIN_CTO_Mpeg4_128kbps_15fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/NIN_CTO_Mpeg4_128kbps_5fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/NIN_CTO_Mpeg4_128kbps_7.5fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/NIN_H263_128kbps_10fps_QCIF_174x144_noaudio_SSE.mp4",
-      "/sdcard/video_perf/NIN_H263_128kbps_15fps_QCIF_174x144_noaudio_SSE.mp4",
-      "/sdcard/video_perf/NIN_H263_48kbps_10fps_QCIF_174x144_noaudio_SSE.3gp",
-      "/sdcard/video_perf/NIN_H263_48kbps_12fps_QCIF_174x144_noaudio_SSE.3gp",
-      "/sdcard/video_perf/NIN_H264_123kbps_15fps_QCIF_176x144+AAC_32kbps_22khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/NIN_H264_123kbps_7.5fps_QCIF_176x144+AAC_32kbps_22khz_stereo_SSE.3gp",
-      "/sdcard/video_perf/PV_H264_2000kbps_20fps_CIF_352x288+AAC_96kbps_48khz_stereo_SSE.mp4",
-      "/sdcard/video_perf/PV_H264_2000kbps_25fps_CIF_352x288+AAC_96kbps_48khz_stereo_SSE.mp4",
-      "/sdcard/video_perf/PV_H264_2000kbps_30fps_CIF_352x288+AAC_128kbps_48khz_stereo_SSE.mp4",
-      "/sdcard/video_perf/Stevie-1.wmv",
-      "/sdcard/video_perf/WC_H264_1600kbps_20fps_QCIF_176x144+AAC_96kbps_48khz_mono_SSE.mp4",
-      "/sdcard/video_perf/WC_H264_1600kbps_25fps_QCIF_176x144+AAC_96kbps_48khz_mono_SSE.mp4",
-      "/sdcard/video_perf/WC_H264_1600kbps_30fps_QCIF_176x144+AAC_96kbps_48khz_mono_SSE.mp4",
-      "/sdcard/video_perf/bugs.wmv",
-      "/sdcard/video_perf/niceday.wmv",
-      "/sdcard/video_perf/eaglesatopnflpe.wmv",
+    public static String[] VIDEOFILES = { "/sdcard/media_api/video_perf/AI_CTO_Mpeg4_32kbps_10fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
+      "/sdcard/media_api/video_perf/AI_CTO_Mpeg4_32kbps_12fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
+      "/sdcard/media_api/video_perf/AI_CTO_Mpeg4_32kbps_15fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
+      "/sdcard/media_api/video_perf/AI_CTO_Mpeg4_32kbps_5fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
+      "/sdcard/media_api/video_perf/AI_CTO_Mpeg4_32kbps_5fps_SQCIF_128x96+AAC_8kbps_8khz_mono_SSE.mp4",
+      "/sdcard/media_api/video_perf/AI_CTO_Mpeg4_32kbps_7.5fps_SQCIF_128x96+AAC_8kbps_8khz_mono_QTE.mp4",
+      "/sdcard/media_api/video_perf/AI_WMV_1024kbps_20fps_QCIF_176x144_noaudio_SSE.wmv",
+      "/sdcard/media_api/video_perf/AI_WMV_1024kbps_25fps_QCIF_176x144_noaudio_SSE.wmv",
+      "/sdcard/media_api/video_perf/Chicken.wmv",
+      "/sdcard/media_api/video_perf/MP_qcif_15fps_100kbps_48kHz_192kbps_30secs.wmv",
+      "/sdcard/media_api/video_perf/NIN_CTO_H264_123kbps_5fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_H264_96kbps_10.2fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_H264_96kbps_12fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_H264_96kbps_15fps_QCIF_176x144+AMR_12.2kbps_8khz_mono_QTE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_Mpeg4_123kbps_15fps_QCIF_176x144+AAC_32kbps_22khz_mono_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_Mpeg4_123kbps_7.5fps_QCIF_176x144+AAC_32kbps_22khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_Mpeg4_128kbps_10fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_Mpeg4_128kbps_12fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_Mpeg4_128kbps_15fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_Mpeg4_128kbps_5fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_CTO_Mpeg4_128kbps_7.5fps_QCIF_176x144+AAC+_32kbps_48khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_H263_128kbps_10fps_QCIF_174x144_noaudio_SSE.mp4",
+      "/sdcard/media_api/video_perf/NIN_H263_128kbps_15fps_QCIF_174x144_noaudio_SSE.mp4",
+      "/sdcard/media_api/video_perf/NIN_H263_48kbps_10fps_QCIF_174x144_noaudio_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_H263_48kbps_12fps_QCIF_174x144_noaudio_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_H264_123kbps_15fps_QCIF_176x144+AAC_32kbps_22khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/NIN_H264_123kbps_7.5fps_QCIF_176x144+AAC_32kbps_22khz_stereo_SSE.3gp",
+      "/sdcard/media_api/video_perf/PV_H264_2000kbps_20fps_CIF_352x288+AAC_96kbps_48khz_stereo_SSE.mp4",
+      "/sdcard/media_api/video_perf/PV_H264_2000kbps_25fps_CIF_352x288+AAC_96kbps_48khz_stereo_SSE.mp4",
+      "/sdcard/media_api/video_perf/PV_H264_2000kbps_30fps_CIF_352x288+AAC_128kbps_48khz_stereo_SSE.mp4",
+      "/sdcard/media_api/video_perf/Stevie-1.wmv",
+      "/sdcard/media_api/video_perf/WC_H264_1600kbps_20fps_QCIF_176x144+AAC_96kbps_48khz_mono_SSE.mp4",
+      "/sdcard/media_api/video_perf/WC_H264_1600kbps_25fps_QCIF_176x144+AAC_96kbps_48khz_mono_SSE.mp4",
+      "/sdcard/media_api/video_perf/WC_H264_1600kbps_30fps_QCIF_176x144+AAC_96kbps_48khz_mono_SSE.mp4",
+      "/sdcard/media_api/video_perf/bugs.wmv",
+      "/sdcard/media_api/video_perf/niceday.wmv",
+      "/sdcard/media_api/video_perf/eaglesatopnflpe.wmv",
      
     };
     
     //wma - only support up to wma 9
     public static String[] WMASUPPORTED = {
-      "/sdcard/music_perf/WMASUPPORTED/AI_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/AI_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/NIN_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/NIN_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/PD_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/PD_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/PV_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/PV_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/WC_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
-      "/sdcard/music_perf/WMASUPPORTED/WC_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma"
+      "/sdcard/media_api/music_perf/WMASUPPORTED/AI_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/AI_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/NIN_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/NIN_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/PD_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/PD_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/PV_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/PV_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/WC_WMA9.2_32kbps_44.1khz_mono_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMASUPPORTED/WC_WMA9.2_48kbps_44.1khz_mono_CBR_DPA.wma"
       
     };
     
     public static String[] WMAUNSUPPORTED = { 
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_127kbps_48khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_44.1khz_stereo_2pVBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_48khz_stereo_2pVBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_88khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_96khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_192kbps_44.1khz_stereo_2pVBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_192kbps_88khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_192kbps_96khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_44khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_48khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_88khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_96khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_384kbps_44khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_384kbps_48khz_stereo_CBR_DPA.wma",
-      "/sdcard/music_perf/WMAUNSUPPORTED/AI_WMA10_384kbps_88khz_stereo_CBR_DPA.wma"
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_127kbps_48khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_44.1khz_stereo_2pVBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_48khz_stereo_2pVBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_88khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_128kbps_96khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_192kbps_44.1khz_stereo_2pVBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_192kbps_88khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_192kbps_96khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_44khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_48khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_88khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_256kbps_96khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_384kbps_44khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_384kbps_48khz_stereo_CBR_DPA.wma",
+      "/sdcard/media_api/music_perf/WMAUNSUPPORTED/AI_WMA10_384kbps_88khz_stereo_CBR_DPA.wma"
     };
     
     //Media Recorder
-    public static final String RECORDER_OUTPUT = "/sdcard/recorderOutput.amr";
+    public static final String RECORDER_OUTPUT = "/sdcard/media_api/recorderOutput.amr";
     
     //video thumbnail
-    public static final String THUMBNAIL_OUTPUT = "/sdcard/videoThumbnail.png";
-    public static final String GOLDEN_THUMBNAIL_OUTPUT = "/sdcard/goldenThumbnail.png";
+    public static final String THUMBNAIL_OUTPUT = "/sdcard/media_api/videoThumbnail.png";
+    public static final String GOLDEN_THUMBNAIL_OUTPUT = "/sdcard/media_api/goldenThumbnail.png";
     
     //Metadata Utility
     public static final String[] THUMBNAIL_CAPTURE_TEST_FILES = {
-      "/sdcard/metadata/test.mp4",
-      "/sdcard/metadata/test1.3gp",
-      "/sdcard/metadata/test2.3gp",
-      "/sdcard/metadata/test3.3gp",
-      "/sdcard/metadata/test4.3gp",
-      "/sdcard/metadata/test5.3gp",
-      "/sdcard/metadata/test6.3gp",
-      "/sdcard/metadata/test7.3gp",
-      "/sdcard/metadata/test8.3gp",
-      "/sdcard/metadata/test9.3gp",
-      "/sdcard/metadata/test10.3gp",
-      "/sdcard/metadata/test11.3gp",
-      "/sdcard/metadata/test12.3gp",
-      "/sdcard/metadata/test13.3gp",
-      "/sdcard/metadata/test14.3gp",
-      "/sdcard/metadata/test15.3gp",
-      "/sdcard/metadata/test16.3gp",
-      "/sdcard/metadata/test17.3gp",
-      "/sdcard/metadata/test18.3gp",
-      "/sdcard/metadata/test19.3gp",
-      "/sdcard/metadata/test20.3gp",
-      "/sdcard/metadata/test21.3gp",
-      "/sdcard/metadata/test22.3gp",
-      "/sdcard/metadata/test23.3gp",
-      "/sdcard/metadata/test24.3gp",
-      "/sdcard/metadata/test25.3gp",
-      "/sdcard/metadata/test26.3gp",
-      "/sdcard/metadata/test27.3gp",
-      "/sdcard/metadata/test28.3gp",
-      "/sdcard/metadata/test29.3gp",
-      "/sdcard/metadata/test30.3gp",
-      "/sdcard/metadata/test31.3gp",
-      "/sdcard/metadata/test32.3gp",
-      "/sdcard/metadata/test33.3gp",
-      "/sdcard/metadata/test35.mp4",
-      "/sdcard/metadata/test36.m4v",
-      "/sdcard/metadata/test34.wmv",
-      "/sdcard/metadata/test_metadata.mp4",
+      "/sdcard/media_api/metadata/test.mp4",
+      "/sdcard/media_api/metadata/test1.3gp",
+      "/sdcard/media_api/metadata/test2.3gp",
+      "/sdcard/media_api/metadata/test3.3gp",
+      "/sdcard/media_api/metadata/test4.3gp",
+      "/sdcard/media_api/metadata/test5.3gp",
+      "/sdcard/media_api/metadata/test6.3gp",
+      "/sdcard/media_api/metadata/test7.3gp",
+      "/sdcard/media_api/metadata/test8.3gp",
+      "/sdcard/media_api/metadata/test9.3gp",
+      "/sdcard/media_api/metadata/test10.3gp",
+      "/sdcard/media_api/metadata/test11.3gp",
+      "/sdcard/media_api/metadata/test12.3gp",
+      "/sdcard/media_api/metadata/test13.3gp",
+      "/sdcard/media_api/metadata/test14.3gp",
+      "/sdcard/media_api/metadata/test15.3gp",
+      "/sdcard/media_api/metadata/test16.3gp",
+      "/sdcard/media_api/metadata/test17.3gp",
+      "/sdcard/media_api/metadata/test18.3gp",
+      "/sdcard/media_api/metadata/test19.3gp",
+      "/sdcard/media_api/metadata/test20.3gp",
+      "/sdcard/media_api/metadata/test21.3gp",
+      "/sdcard/media_api/metadata/test22.3gp",
+      "/sdcard/media_api/metadata/test23.3gp",
+      "/sdcard/media_api/metadata/test24.3gp",
+      "/sdcard/media_api/metadata/test25.3gp",
+      "/sdcard/media_api/metadata/test26.3gp",
+      "/sdcard/media_api/metadata/test27.3gp",
+      "/sdcard/media_api/metadata/test28.3gp",
+      "/sdcard/media_api/metadata/test29.3gp",
+      "/sdcard/media_api/metadata/test30.3gp",
+      "/sdcard/media_api/metadata/test31.3gp",
+      "/sdcard/media_api/metadata/test32.3gp",
+      "/sdcard/media_api/metadata/test33.3gp",
+      "/sdcard/media_api/metadata/test35.mp4",
+      "/sdcard/media_api/metadata/test36.m4v",
+      "/sdcard/media_api/metadata/test34.wmv",
+      "/sdcard/media_api/metadata/test_metadata.mp4",
   };
   
   public static final String[] METADATA_RETRIEVAL_TEST_FILES = {
       // Raw AAC is not supported
-      // "/sdcard/test_raw.aac",
-      // "/sdcard/test_adts.aac",
-      // "/sdcard/test_adif.aac",
-      "/sdcard/metadata/test_metadata.mp4",
-      "/sdcard/metadata/WMA10.wma",
-      "/sdcard/metadata/Leadsol_out.wav",
-      "/sdcard/metadata/test_aac.mp4",
-      "/sdcard/metadata/test_amr.mp4",
-      "/sdcard/metadata/test_avc_amr.mp4",
-      "/sdcard/metadata/test_metadata.mp4",
-      "/sdcard/metadata/test_vbr.mp3",
-      "/sdcard/metadata/test_cbr.mp3",
-      "/sdcard/metadata/metadata_test1.mp3",
-      "/sdcard/metadata/test33.3gp",
-      "/sdcard/metadata/test35.mp4",
-      "/sdcard/metadata/test36.m4v",
-      "/sdcard/metadata/test_m4v_amr.mp4",
-      "/sdcard/metadata/test_h263_amr.mp4",
-      "/sdcard/metadata/test34.wmv",
+      // "/sdcard/media_api/test_raw.aac",
+      // "/sdcard/media_api/test_adts.aac",
+      // "/sdcard/media_api/test_adif.aac",
+      "/sdcard/media_api/metadata/test_metadata.mp4",
+      "/sdcard/media_api/metadata/WMA10.wma",
+      "/sdcard/media_api/metadata/Leadsol_out.wav",
+      "/sdcard/media_api/metadata/test_aac.mp4",
+      "/sdcard/media_api/metadata/test_amr.mp4",
+      "/sdcard/media_api/metadata/test_avc_amr.mp4",
+      "/sdcard/media_api/metadata/test_metadata.mp4",
+      "/sdcard/media_api/metadata/test_vbr.mp3",
+      "/sdcard/media_api/metadata/test_cbr.mp3",
+      "/sdcard/media_api/metadata/metadata_test1.mp3",
+      "/sdcard/media_api/metadata/test33.3gp",
+      "/sdcard/media_api/metadata/test35.mp4",
+      "/sdcard/media_api/metadata/test36.m4v",
+      "/sdcard/media_api/metadata/test_m4v_amr.mp4",
+      "/sdcard/media_api/metadata/test_h263_amr.mp4",
+      "/sdcard/media_api/metadata/test34.wmv",
   };
   
   public static final String[] ALBUMART_TEST_FILES = {
-      "/sdcard/album_photo/test_22_16_mp3.mp3",
-      "/sdcard/album_photo/PD_256kbps_48khz_mono_CBR_MCA.mp3",
-      "/sdcard/album_photo/PD_256kbps_44.1khz_mono_CBR_DPA.mp3",
-      "/sdcard/album_photo/PD_192kbps_32khz_mono_CBR_DPA.mp3",
-      "/sdcard/album_photo/NIN_256kbps_48khz_mono_CBR_MCA.mp3",
-      "/sdcard/album_photo/NIN_256kbps_44.1khz_mono_CBR_MCA.mp3",
-      "/sdcard/album_photo/NIN_112kbps(96kbps)_48khz_stereo_VBR_MCA.mp3",
-      "/sdcard/album_photo/NIN_112kbps(96kbps)_44.1khz_stereo_VBR_MCA.mp3",
-      "/sdcard/album_photo/lightGreen1.mp3",
-      "/sdcard/album_photo/babyBlue2 1.mp3",
-      "/sdcard/album_photo/2-01 01 NIN_56kbps(64kbps)_32khz_stereo_VBR_MCA.mp3",
-      "/sdcard/album_photo/02_NIN_112kbps(80kbps)_32khz_stereo_VBR_MCA.mp3",
-      "/sdcard/album_photo/No_Woman_No_Cry_128K.wma",
-      "/sdcard/album_photo/Beethoven_2.wma",
+      "/sdcard/media_api/album_photo/test_22_16_mp3.mp3",
+      "/sdcard/media_api/album_photo/PD_256kbps_48khz_mono_CBR_MCA.mp3",
+      "/sdcard/media_api/album_photo/PD_256kbps_44.1khz_mono_CBR_DPA.mp3",
+      "/sdcard/media_api/album_photo/PD_192kbps_32khz_mono_CBR_DPA.mp3",
+      "/sdcard/media_api/album_photo/NIN_256kbps_48khz_mono_CBR_MCA.mp3",
+      "/sdcard/media_api/album_photo/NIN_256kbps_44.1khz_mono_CBR_MCA.mp3",
+      "/sdcard/media_api/album_photo/NIN_112kbps(96kbps)_48khz_stereo_VBR_MCA.mp3",
+      "/sdcard/media_api/album_photo/NIN_112kbps(96kbps)_44.1khz_stereo_VBR_MCA.mp3",
+      "/sdcard/media_api/album_photo/lightGreen1.mp3",
+      "/sdcard/media_api/album_photo/babyBlue2 1.mp3",
+      "/sdcard/media_api/album_photo/2-01 01 NIN_56kbps(64kbps)_32khz_stereo_VBR_MCA.mp3",
+      "/sdcard/media_api/album_photo/02_NIN_112kbps(80kbps)_32khz_stereo_VBR_MCA.mp3",
+      "/sdcard/media_api/album_photo/No_Woman_No_Cry_128K.wma",
+      "/sdcard/media_api/album_photo/Beethoven_2.wma",
   };
 
   //TEST_PATH_1: is a video and contains metadata for key "num-tracks"
   // TEST_PATH_2: any valid media file.
   // TEST_PATH_3: invalid media file
-  public static final String TEST_PATH_1 = "/sdcard/metadata/test.mp4";
-  public static final String TEST_PATH_3 = "/sdcard/data.txt";
+  public static final String TEST_PATH_1 = "/sdcard/media_api/metadata/test.mp4";
+  public static final String TEST_PATH_3 = "/sdcard/media_api/data.txt";
   public static final String TEST_PATH_4 = "somenonexistingpathname";
   public static final String TEST_PATH_5 = "mem://012345";
   
@@ -376,81 +378,81 @@
   //cd_track_number, album, artist, author, composer, date, genre
   //title, years, duration
   public static final String META_DATA_MP3 [][] = {
-      {"/sdcard/metaDataTestMedias/MP3/ID3V1_ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist",
+      {"/sdcard/media_api/metaDataTestMedias/MP3/ID3V1_ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist",
           "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, "Blues",
           "ID3V2.3 Title", "1234", "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist",
+      {"/sdcard/media_api/metaDataTestMedias/MP3/ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist",
           "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, "Blues", 
           "ID3V2.3 Title", "1234", "313", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/ID3V1.mp3", null, "test ID3V1 Album", "test ID3V1 Artist",
+      {"/sdcard/media_api/metaDataTestMedias/MP3/ID3V1.mp3", null, "test ID3V1 Album", "test ID3V1 Artist",
           null, null, null, null, "test ID3V1 Title", "1234", "231332", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V1.mp3" , null, null, null,
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V1.mp3" , null, null, null,
               null, null, null, null, null, null, "231330", "1"},
       //The corrupted TALB field in id3v2 would not switch to id3v1 tag automatically
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TALB.mp3", "01", null, "ID3V2.3 Artist",
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TALB.mp3", "01", null, "ID3V2.3 Artist",
           "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, 
           "Blues", "ID3V2.3 Title", "1234", "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM.mp3", "01", "ID3V2.3 Album", 
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM.mp3", "01", "ID3V2.3 Album", 
            "ID3V2.3 Artist", "ID3V2.3 Lyricist", null, null, 
            "Blues", "ID3V2.3 Title", "1234", "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM_2.mp3", "01", "ID3V2.3 Album", 
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM_2.mp3", "01", "ID3V2.3 Album", 
            "ID3V2.3 Artist", null, null, null, "Blues", "ID3V2.3 Title", "1234", "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK.mp3", "dd", "ID3V2.3 Album", 
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK.mp3", "dd", "ID3V2.3 Album", 
            "ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null,
            "Blues", "ID3V2.3 Title", "1234", "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK_2.mp3", "01", "ID3V2.3 Album", 
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK_2.mp3", "01", "ID3V2.3 Album", 
            "ID3V2.3 Artist", null, null, null, null, "ID3V2.3 Title", null, "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER.mp3", "01", "ID3V2.3 Album",
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER.mp3", "01", "ID3V2.3 Album",
            "ID3V2.3 Artist", null, null, null, null, "ID3V2.3 Title", "9999", "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER_2.mp3", "01", "ID3V2.3 Album",
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER_2.mp3", "01", "ID3V2.3 Album",
            "ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null, 
            "Blues", "ID3V2.3 Title", null, "321", "1"},
-      {"/sdcard/metaDataTestMedias/MP3/Corrupted_ID3V2_TIT.mp3", null, null, null,
+      {"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TIT.mp3", null, null, null,
           null, null, null, null, null, null, "577", "1"}
   };
 
   public static final String META_DATA_OTHERS [][] = {
-      {"/sdcard/metaDataTestMedias/3GP/cat.3gp", null, null, null,
+      {"/sdcard/media_api/metaDataTestMedias/3GP/cat.3gp", null, null, null,
           null, null, "20080309T002415.000Z", null,
           null, null, "1404928", "2"},
-      {"/sdcard/metaDataTestMedias/AMR/AMR_NB.amr", null, null, null,
+      {"/sdcard/media_api/metaDataTestMedias/AMR/AMR_NB.amr", null, null, null,
           null, null, null, null,
           null, null, "126540", "1"},
-      {"/sdcard/metaDataTestMedias/AMRWB/AMR_WB.amr", null, null, null,
+      {"/sdcard/media_api/metaDataTestMedias/AMRWB/AMR_WB.amr", null, null, null,
           null, null, null, null,
           null, null, "231180", "1"},     
-      {"/sdcard/metaDataTestMedias/M4A/Jaws Of Life_ver1.m4a", null, "Suspended Animation", 
+      {"/sdcard/media_api/metaDataTestMedias/M4A/Jaws Of Life_ver1.m4a", null, "Suspended Animation", 
           "John Petrucci", null, null, "20070510T125223.000Z", 
           null, null, "2005", "231180", "1"},     
-      {"/sdcard/metaDataTestMedias/M4V/sample_iPod.m4v", null, null, 
+      {"/sdcard/media_api/metaDataTestMedias/M4V/sample_iPod.m4v", null, null, 
           null, null, null, "20051220T202015.000Z", 
           null, null, null, "3771392", "2"}, 
-      {"/sdcard/metaDataTestMedias/MIDI/MIDI.mid", null, "Suspended Animation", 
+      {"/sdcard/media_api/metaDataTestMedias/MIDI/MIDI.mid", null, "Suspended Animation", 
           "John Petrucci", null, null, "20070510T125223.000Z", 
           null, null, "2005", "231180", "1"}, 
-      {"/sdcard/metaDataTestMedias/MP4/kung_fu_panda_h264.mp4", null, "mp4 album Kung Fu Panda", 
+      {"/sdcard/media_api/metaDataTestMedias/MP4/kung_fu_panda_h264.mp4", null, "mp4 album Kung Fu Panda", 
           "mp4 artist Kung Fu Panda", null, null, "20080517T091451.000Z", 
           "Kung Fu Panda", "Kung Fu Panda", "2008", "5667840", "2"},
-      {"/sdcard/metaDataTestMedias/OGG/Ring_Classic_02.ogg", null, "Suspended Animation", 
+      {"/sdcard/media_api/metaDataTestMedias/OGG/Ring_Classic_02.ogg", null, "Suspended Animation", 
           "John Petrucci", null, null, "20070510T125223.000Z", 
           null, null, "2005", "231180", "1"},
-      {"/sdcard/metaDataTestMedias/OGG/When You Say Nothing At All.ogg", 
+      {"/sdcard/media_api/metaDataTestMedias/OGG/When You Say Nothing At All.ogg", 
           null, "Suspended Animation", "John Petrucci", 
           null, null, "20070510T125223.000Z", null, null, "2005", "231180", "1"},
-      {"/sdcard/metaDataTestMedias/WAV/Im With You.wav", null, null, 
+      {"/sdcard/media_api/metaDataTestMedias/WAV/Im With You.wav", null, null, 
           null, null, null, null, 
           null, null, null, "224000", "1"},
-      {"/sdcard/metaDataTestMedias/WMA/WMA9.wma", "6", "Ten Songs in the Key of Betrayal", 
+      {"/sdcard/media_api/metaDataTestMedias/WMA/WMA9.wma", "6", "Ten Songs in the Key of Betrayal", 
           "Alien Crime Syndicate", "Alien Crime Syndicate", 
           "wma 9 Composer", "20040521T175729.483Z", 
           "Rock", "Run for the Money", "2004", "134479", "1"},
-      {"/sdcard/metaDataTestMedias/WMA/WMA10.wma", "09", "wma 10 Album", 
+      {"/sdcard/media_api/metaDataTestMedias/WMA/WMA10.wma", "09", "wma 10 Album", 
           "wma 10 Album Artist", "wma 10 Artist", "wma 10 Composer", "20070705T063625.097Z", 
           "Acid Jazz", "wma 10 Title", "2010", "126574", "1"},
-      {"/sdcard/metaDataTestMedias/WMV/bugs.wmv", "8", "wmv 9 Album", 
+      {"/sdcard/media_api/metaDataTestMedias/WMV/bugs.wmv", "8", "wmv 9 Album", 
           null, "wmv 9 Artist ", null, "20051122T155247.540Z", 
           null, "Looney Tunes - Hare-Breadth Hurry", "2005", "193482", "2"},
-      {"/sdcard/metaDataTestMedias/WMV/clips_ver7.wmv", "50", "wmv 7 Album", 
+      {"/sdcard/media_api/metaDataTestMedias/WMV/clips_ver7.wmv", "50", "wmv 7 Album", 
           null, "Hallau Shoots & Company", null, "20020226T170045.891Z", 
           null, "CODEC Shootout", "1986", "43709", "2"}
   };
@@ -471,9 +473,25 @@
   
   public static final String RECORDED_VIDEO_3GP = "/sdcard/temp.3gp";
   
- 
-  public static final long RECORDED_TIME = 3000;
-  public static final long VALID_VIDEO_DURATION = 2000;
- 
+  public static final String INVALD_VIDEO_PATH = "/sdcard/media_api/filepathdoesnotexist" +
+      "/filepathdoesnotexist/temp.3gp";
   
+ 
+  public static final long RECORDED_TIME = 5000;
+  public static final long VALID_VIDEO_DURATION = 2000;
+  
+  //Videos for the mediaplayer stress test
+  public static String[] H263_STRESS = { 
+      "/sdcard/media_api/video_stress/h263/H263_CIF.3gp",
+      "/sdcard/media_api/video_stress/h263/H263_QCIF.3gp",
+      "/sdcard/media_api/video_stress/h263/H263_QVGA.3gp",
+      "/sdcard/media_api/video_stress/h263/H263_SQVGA.3gp"
+  };
+  
+  public static String[] MPEG4_STRESS = { 
+    "/sdcard/media_api/video_stress/h263/mpeg4_CIF.mp4",
+    "/sdcard/media_api/video_stress/h263/mpeg4_QCIF.3gp",
+    "/sdcard/media_api/video_stress/h263/mpeg4_QVGA.3gp",
+    "/sdcard/media_api/video_stress/h263/mpeg4_SQVGA.mp4"
+  };
 }
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
new file mode 100755
index 0000000..12eacd3
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mediaframeworktest;
+
+import android.test.InstrumentationTestRunner;
+import android.test.InstrumentationTestSuite;
+import com.android.mediaframeworktest.stress.MediaRecorderStressTest;
+
+import junit.framework.TestSuite;
+
+public class MediaRecorderStressTestRunner extends InstrumentationTestRunner {
+
+    @Override
+    public TestSuite getAllTests() {
+        TestSuite suite = new InstrumentationTestSuite(this);
+        suite.addTestSuite(MediaRecorderStressTest.class);
+        return suite;
+    }
+
+    @Override
+    public ClassLoader getLoader() {
+        return MediaRecorderStressTestRunner.class.getClassLoader();
+    }
+}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java
new file mode 100644
index 0000000..ae6a834
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaAudioTrackTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mediaframeworktest.functional;
+
+import com.android.mediaframeworktest.MediaFrameworkTest;
+import com.android.mediaframeworktest.MediaNames;
+
+import android.media.AudioTrack;
+import android.content.Context;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
+import android.test.suitebuilder.annotation.LargeTest;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.Suppress;
+
+/**
+ * Junit / Instrumentation test case for the media AudioTrack api
+ 
+ */  
+public class MediaAudioTrackTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> {    
+    private String TAG = "MediaAudioTrack";
+   
+    public MediaAudioTrackTest() {
+        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+      super.setUp();
+    }
+    
+    @Override 
+    protected void tearDown() throws Exception {     
+        super.tearDown();              
+    }
+       
+    //Test case 1: Set the invalid volume
+    @MediumTest
+    public void testGetMinVolume() throws Exception {
+        //To Do: Create the test case for GetMinVolume  
+        assertTrue("testGetMinVolume", true);  
+    }
+
+}
+
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java
index 20f213e..dd94164 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPlayerApiTest.java
@@ -385,9 +385,6 @@
       assertTrue("WMV SeekTo", isSeek);         
     }
     
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @LargeTest
     public void testSoundRecord() throws Exception {
       boolean isRecordered = CodecTest.mediaRecorderRecord(MediaNames.RECORDER_OUTPUT);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
index d970f5e..65451c5 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
@@ -35,8 +35,7 @@
 
 
 /**
- * Junit / Instrumentation test case for the media recorder api
- 
+ * Junit / Instrumentation test case for the media recorder api 
  */  
 public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFrameworkTest> {    
     private String TAG = "MediaRecorderTest";
@@ -60,12 +59,12 @@
     }
  
     private void recordVideo(int frameRate, int width, int height, 
-            int videoFormat, int outFormat, String outFile, boolean videoOnly){
+            int videoFormat, int outFormat, String outFile, boolean videoOnly) {
         Log.v(TAG,"startPreviewAndPrepareRecording");
-        try{
-            if (!videoOnly){
+        try {
+            if (!videoOnly) {
                 Log.v(TAG, "setAudioSource");
-                //mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+                mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
             }
             mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
             mRecorder.setOutputFormat(outFormat);
@@ -75,8 +74,8 @@
             mRecorder.setVideoSize(width, height);
             Log.v(TAG, "setEncoder");
             mRecorder.setVideoEncoder(videoFormat);
-            if (!videoOnly){
-               // mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+            if (!videoOnly) {
+                mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
             }
             mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
             Log.v(TAG, "setPreview");
@@ -88,16 +87,57 @@
             Thread.sleep(MediaNames.RECORDED_TIME);
             Log.v(TAG, "stop");
             mRecorder.stop();
-            mRecorder.reset();
             mRecorder.release();
-        } catch (Exception e){
+        } catch (Exception e) {
             Log.v("record video failed ", e.toString());
+            mRecorder.release();
         }
     }
     
-    private void getOutputVideoProperty(String outputFilePath){
+    
+    private boolean invalidRecordSetting(int frameRate, int width, int height, 
+            int videoFormat, int outFormat, String outFile, boolean videoOnly) {
+        try {
+            if (!videoOnly) {
+                Log.v(TAG, "setAudioSource");
+                mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+            }
+            mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
+            mRecorder.setOutputFormat(outFormat);
+            Log.v(TAG, "output format " + outFormat);          
+            mRecorder.setOutputFile(outFile);
+            mRecorder.setVideoFrameRate(frameRate);
+            mRecorder.setVideoSize(width, height);
+            Log.v(TAG, "setEncoder");
+            mRecorder.setVideoEncoder(videoFormat);
+            if (!videoOnly) {
+                mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+            }
+            mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+            Log.v(TAG, "setPreview");
+            mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
+            Log.v(TAG, "prepare");
+            mRecorder.prepare();
+            Log.v(TAG, "start");
+            mRecorder.start();
+            Thread.sleep(MediaNames.RECORDED_TIME);
+            Log.v(TAG, "stop");
+            mRecorder.stop();
+            mRecorder.release();
+        } catch (Exception e) {
+            Log.v("record video failed ", e.toString());
+            mRecorder.release();
+            Log.v(TAG, "reset and release");
+            return true;
+        }
+        return false;
+    }
+    
+    
+    
+    private void getOutputVideoProperty(String outputFilePath) {
         MediaPlayer mediaPlayer = new MediaPlayer();
-        try{
+        try {
             mediaPlayer.setDataSource(outputFilePath);
             Log.v(TAG, "file Path = " + outputFilePath);
             mediaPlayer.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
@@ -111,19 +151,20 @@
             mediaPlayer.release();    
         } catch (Exception e) {
             Log.v(TAG, e.toString());
+            mediaPlayer.release();
         }       
     }
     
-    private void removeFile(String filePath){
+    private void removeFile(String filePath) {
         File fileRemove = new File(filePath);
         fileRemove.delete();     
     }
     
-    private boolean validateVideo(String filePath, int width, int height){
+    private boolean validateVideo(String filePath, int width, int height) {
         boolean validVideo = false;
         getOutputVideoProperty(filePath);
         if (mOutputVideoWidth == width && mOutputVideoHeight == height &&
-                mOutputDuration > MediaNames.VALID_VIDEO_DURATION ){
+                mOutputDuration > MediaNames.VALID_VIDEO_DURATION ) {
             validVideo = true;
         }
         Log.v(TAG, "width = " + mOutputVideoWidth + " height = " + mOutputVideoHeight + " Duration = " + mOutputDuration);
@@ -143,7 +184,7 @@
     }
     
     //Format: QVGA h263
-    @Suppress
+    @LargeTest
     public void testQVGAH263() throws Exception {  
         boolean videoRecordedResult = false;
         recordVideo(15, 320, 240, MediaRecorder.VideoEncoder.H263, 
@@ -153,7 +194,7 @@
     }
     
     //Format: SQVGA h263
-    @Suppress
+    @LargeTest
     public void testSQVGAH263() throws Exception {  
         boolean videoRecordedResult = false;
         recordVideo(15, 240, 160, MediaRecorder.VideoEncoder.H263, 
@@ -184,14 +225,12 @@
       
     
    
-    @Suppress
+    @LargeTest
     public void testVideoOnly() throws Exception {       
         boolean videoRecordedResult = false;
-        for (int i=0; i< 10; i++){
         recordVideo(15, 176, 144, MediaRecorder.VideoEncoder.H263, 
                MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true);      
         videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 176, 144);
-        }
         assertTrue("QCIFH263 Video Only", videoRecordedResult);
     }
     
@@ -204,7 +243,7 @@
         assertTrue("PortraitH263", videoRecordedResult);
     }
     
-    @LargeTest
+    @Suppress
     public void testHVGAMP4() throws Exception {  
         boolean videoRecordedResult = false;
         recordVideo(15, 480, 320, MediaRecorder.VideoEncoder.MPEG_4_SP, 
@@ -242,7 +281,7 @@
     }    
     
     
-    //Format: CIF h263
+    //Format: CIF MP4
     @LargeTest
     public void testCIFMP4() throws Exception {       
         boolean videoRecordedResult = false;
@@ -253,14 +292,14 @@
     }
     
     
-    //Format: CIF h263 outputforma 3gpp
+    //Format: CIF MP4 output format 3gpp
     @LargeTest
     public void testCIFMP43GPP() throws Exception {       
         boolean videoRecordedResult = false;
         recordVideo(15, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP, 
                MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false);      
         videoRecordedResult = validateVideo(MediaNames.RECORDED_VIDEO_3GP, 352, 288);
-        assertTrue("CIFH263", videoRecordedResult);
+        assertTrue("CIFMP4 3GPP", videoRecordedResult);
     }
     
     @LargeTest
@@ -272,5 +311,29 @@
         assertTrue("QCIFH263 3GPP", videoRecordedResult);
     }
     
+    @LargeTest
+    public void testInvalidVideoPath() throws Exception {       
+        boolean isTestInvalidVideoPathSuccessful = false;
+        isTestInvalidVideoPathSuccessful = invalidRecordSetting(15, 176, 144, MediaRecorder.VideoEncoder.H263, 
+               MediaRecorder.OutputFormat.THREE_GPP, MediaNames.INVALD_VIDEO_PATH, false);      
+        assertTrue("Invalid outputFile Path", isTestInvalidVideoPathSuccessful);
+    }
+    
+    @Suppress
+    public void testInvalidVideoSize() throws Exception {       
+        boolean isTestInvalidVideoSizeSuccessful = false;
+        isTestInvalidVideoSizeSuccessful = invalidRecordSetting(15, 800, 600, MediaRecorder.VideoEncoder.H263, 
+               MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false);      
+        assertTrue("Invalid video Size", isTestInvalidVideoSizeSuccessful);
+    }
+    
+    @LargeTest
+    public void testInvalidFrameRate() throws Exception {       
+        boolean isTestInvalidFrameRateSuccessful = false;
+        isTestInvalidFrameRateSuccessful = invalidRecordSetting(50, 176, 144, MediaRecorder.VideoEncoder.H263, 
+               MediaRecorder.OutputFormat.THREE_GPP, MediaNames.RECORDED_VIDEO_3GP, false);      
+        assertTrue("Invalid FrameRate", isTestInvalidFrameRateSuccessful);
+    }
+    
 }
 
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
new file mode 100644
index 0000000..dbf937c
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mediaframeworktest.stress;
+
+import com.android.mediaframeworktest.MediaFrameworkTest;
+
+import android.hardware.Camera;
+import android.media.MediaPlayer;
+import android.media.MediaRecorder;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.suitebuilder.annotation.LargeTest;
+import android.util.Log;
+import android.view.SurfaceHolder;
+
+/**
+ * Junit / Instrumentation test case for the media player api
+ 
+ */  
+public class MediaRecorderStressTest extends ActivityInstrumentationTestCase2<MediaFrameworkTest> {    
+    
+  
+    private String TAG = "MediaRecorderStressTest";
+    private MediaRecorder mRecorder;
+    private Camera mCamera;
+   
+    private static final int NUMBER_OF_CAMERA_STRESS_LOOPS = 100;
+    private static final int NUMBER_OF_RECORDER_STRESS_LOOPS = 100;
+    private static final int NUMBER_OF_RECORDERANDPLAY_STRESS_LOOPS = 50;
+    private static final int NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER = 200;
+    private static final long WAIT_TIME_CAMERA_TEST = 3000;  // 3 second
+    private static final long WAIT_TIME_RECORDER_TEST = 60000;  // 6 second
+    private static final long WAIT_TIME_RECORD = 100000;  // 10 seconds
+    private static final long WAIT_TIME_PLAYBACK = 60000;  // 6 second
+    private static final String OUTPUT_FILE = "/sdcard/temp";
+    private static final String OUTPUT_FILE_EXT = ".3gp";
+    
+    public MediaRecorderStressTest() {
+        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
+    }
+
+    protected void setUp() throws Exception {
+        getActivity();
+        super.setUp();      
+    }
+       
+    //Test case for stressing the camera preview.
+    @LargeTest
+    public void testStressCamera() throws Exception {
+        SurfaceHolder mSurfaceHolder;             
+        mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+        try {        
+            Log.v(TAG, "Start preview");
+            for (int i = 0; i< NUMBER_OF_CAMERA_STRESS_LOOPS; i++){
+                mCamera = Camera.open();
+                mCamera.setPreviewDisplay(mSurfaceHolder);
+                mCamera.startPreview();
+                Thread.sleep(WAIT_TIME_CAMERA_TEST);
+                mCamera.stopPreview();
+                mCamera.release();
+            }
+        } catch (Exception e) {
+                Log.v(TAG, e.toString());
+        }
+    }
+    
+    //Test case for stressing the camera preview.
+    @LargeTest
+    public void testStressRecorder() throws Exception {
+        String filename;
+        SurfaceHolder mSurfaceHolder;             
+        mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+        try {    
+            Log.v(TAG, "Start preview");
+            for (int i = 0; i < NUMBER_OF_RECORDER_STRESS_LOOPS; i++){
+                Log.v(TAG, "counter = " + i);
+                filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
+                Log.v(TAG, filename);
+                mRecorder = new MediaRecorder();
+                mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
+                mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);          
+                mRecorder.setOutputFile(filename);
+                mRecorder.setVideoFrameRate(20);
+                mRecorder.setVideoSize(176,144);
+                Log.v(TAG, "setEncoder");
+                mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
+                mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+                Log.v(TAG, "setPreview");
+                mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
+                Log.v(TAG, "prepare");
+                mRecorder.prepare();
+                Log.v(TAG, "before release");
+                Thread.sleep(WAIT_TIME_RECORDER_TEST);  
+                mRecorder.reset();
+                mRecorder.release();
+            }
+        } catch (Exception e) {
+                Log.v(TAG, e.toString());
+        }
+    }
+    
+    
+    //Stress test case for switching camera and video recorder preview.
+    @LargeTest
+    public void testStressCameraSwitchRecorder() throws Exception {
+        String filename;
+        SurfaceHolder mSurfaceHolder;             
+        mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+        try {    
+            Log.v(TAG, "Start preview");
+            for (int i = 0; i < NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER; i++){
+                mCamera = Camera.open();
+                mCamera.setPreviewDisplay(mSurfaceHolder);
+                mCamera.startPreview();
+                Thread.sleep(WAIT_TIME_CAMERA_TEST);
+                mCamera.stopPreview();
+                mCamera.release();
+                mCamera = null;
+                Log.v(TAG, "release camera");
+                filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
+                Log.v(TAG, filename);
+                mRecorder = new MediaRecorder();
+                mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
+                mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);          
+                mRecorder.setOutputFile(filename);
+                mRecorder.setVideoFrameRate(20);
+                mRecorder.setVideoSize(176,144);
+                Log.v(TAG, "Media recorder setEncoder");
+                mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
+                Log.v(TAG, "mediaRecorder setPreview");
+                mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
+                Log.v(TAG, "prepare");
+                mRecorder.prepare();
+                Log.v(TAG, "before release");
+                Thread.sleep(WAIT_TIME_CAMERA_TEST);  
+                mRecorder.release();
+                Log.v(TAG, "release video recorder");                
+            }
+        } catch (Exception e) {
+                Log.v(TAG, e.toString());
+        }
+    }
+    
+    //Stress test case for record a video and play right away.
+    @LargeTest
+    public void testStressRecordVideoAndPlayback() throws Exception {
+        String filename;
+        SurfaceHolder mSurfaceHolder;             
+        mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+        try {    
+            for (int i = 0; i < NUMBER_OF_RECORDERANDPLAY_STRESS_LOOPS; i++){
+                filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
+                Log.v(TAG, filename);
+                mRecorder = new MediaRecorder();
+                mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
+                mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+                mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);          
+                mRecorder.setOutputFile(filename);
+                mRecorder.setVideoFrameRate(20);
+                mRecorder.setVideoSize(352,288);
+                mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
+                mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+                Log.v(TAG, "mediaRecorder setPreview");
+                mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
+                mRecorder.prepare();
+                mRecorder.start();               
+                Thread.sleep(WAIT_TIME_RECORD);
+                Log.v(TAG, "Before stop");
+                mRecorder.stop();
+                mRecorder.release();
+                //start the playback
+                MediaPlayer mp = new MediaPlayer();
+                mp.setDataSource(filename);
+                mp.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
+                mp.prepare();
+                mp.start();
+                Thread.sleep(WAIT_TIME_PLAYBACK);
+                mp.release();
+            }
+        } catch (Exception e) {
+                Log.v(TAG, e.toString());
+        }
+    }   
+}
+
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java
index 366b6ff..dfd544a 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderPrepareStateUnitTest.java
@@ -59,9 +59,6 @@
         }
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testPrepare() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderResetStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderResetStateUnitTest.java
index a45f7ba..cae9e31 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderResetStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderResetStateUnitTest.java
@@ -54,9 +54,6 @@
         recorder.reset();
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testReset() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioEncoderStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioEncoderStateUnitTest.java
index f17d017..4b5a818 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioEncoderStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioEncoderStateUnitTest.java
@@ -54,9 +54,6 @@
         recorder.setAudioEncoder(MediaRecorderStateUnitTestTemplate.AUDIO_ENCODER);
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testSetAudioEncoder() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioSourceStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioSourceStateUnitTest.java
index a972dae..f8ab48cf 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioSourceStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetAudioSourceStateUnitTest.java
@@ -54,9 +54,6 @@
         recorder.setAudioSource(MediaRecorderStateUnitTestTemplate.AUDIO_SOURCE);
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testSetAudioSource() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java
index b5e7bb7..50e235b 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFileStateUnitTest.java
@@ -53,9 +53,6 @@
         recorder.setOutputFile(MediaRecorderStateUnitTestTemplate.RECORD_OUTPUT_PATH);
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testSetOutputFile() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFormatStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFormatStateUnitTest.java
index 3d6f87f..cacdd87 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFormatStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderSetOutputFormatStateUnitTest.java
@@ -54,9 +54,6 @@
         recorder.setOutputFormat(MediaRecorderStateUnitTestTemplate.OUTPUT_FORMAT);
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testSetOutputFormat() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStartStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStartStateUnitTest.java
index 03180d5..d1232fc 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStartStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStartStateUnitTest.java
@@ -54,9 +54,6 @@
         recorder.start();
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testStart() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStopStateUnitTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStopStateUnitTest.java
index 330e8ab..8737595 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStopStateUnitTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaRecorderStopStateUnitTest.java
@@ -54,9 +54,6 @@
         recorder.stop();
     }
 
-    //TODO(elaurent)
-    //reactivate the test until bug#1495237 fix
-    @Suppress
     @MediumTest
     public void testStop() {
         mTestTemplate.runTestOnMethod(this);
diff --git a/opengl/include/EGL/egl.h b/opengl/include/EGL/egl.h
new file mode 100644
index 0000000..c269976
--- /dev/null
+++ b/opengl/include/EGL/egl.h
@@ -0,0 +1,330 @@
+/* -*- mode: c; tab-width: 8; -*- */
+/* vi: set sw=4 ts=8: */
+/* Reference version of egl.h for EGL 1.4.
+ * $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $
+ */
+
+/*
+** Copyright (c) 2007-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+#ifndef __egl_h_
+#define __egl_h_
+
+/* All platform-dependent types and macro boilerplate (such as EGLAPI
+ * and EGLAPIENTRY) should go in eglplatform.h.
+ */
+#include <EGL/eglplatform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* EGL Types */
+/* EGLint is defined in eglplatform.h */
+typedef unsigned int EGLBoolean;
+typedef unsigned int EGLenum;
+typedef void *EGLConfig;
+typedef void *EGLContext;
+typedef void *EGLDisplay;
+typedef void *EGLSurface;
+typedef void *EGLClientBuffer;
+
+/* EGL Versioning */
+#define EGL_VERSION_1_0			1
+#define EGL_VERSION_1_1			1
+#define EGL_VERSION_1_2			1
+#define EGL_VERSION_1_3			1
+#define EGL_VERSION_1_4			1
+
+/* EGL Enumerants. Bitmasks and other exceptional cases aside, most
+ * enums are assigned unique values starting at 0x3000.
+ */
+
+/* EGL aliases */
+#define EGL_FALSE			0
+#define EGL_TRUE			1
+
+/* Out-of-band handle values */
+#define EGL_DEFAULT_DISPLAY		((EGLNativeDisplayType)0)
+#define EGL_NO_CONTEXT			((EGLContext)0)
+#define EGL_NO_DISPLAY			((EGLDisplay)0)
+#define EGL_NO_SURFACE			((EGLSurface)0)
+
+/* Out-of-band attribute value */
+#define EGL_DONT_CARE			((EGLint)-1)
+
+/* Errors / GetError return values */
+#define EGL_SUCCESS			0x3000
+#define EGL_NOT_INITIALIZED		0x3001
+#define EGL_BAD_ACCESS			0x3002
+#define EGL_BAD_ALLOC			0x3003
+#define EGL_BAD_ATTRIBUTE		0x3004
+#define EGL_BAD_CONFIG			0x3005
+#define EGL_BAD_CONTEXT			0x3006
+#define EGL_BAD_CURRENT_SURFACE		0x3007
+#define EGL_BAD_DISPLAY			0x3008
+#define EGL_BAD_MATCH			0x3009
+#define EGL_BAD_NATIVE_PIXMAP		0x300A
+#define EGL_BAD_NATIVE_WINDOW		0x300B
+#define EGL_BAD_PARAMETER		0x300C
+#define EGL_BAD_SURFACE			0x300D
+#define EGL_CONTEXT_LOST		0x300E	/* EGL 1.1 - IMG_power_management */
+
+/* Reserved 0x300F-0x301F for additional errors */
+
+/* Config attributes */
+#define EGL_BUFFER_SIZE			0x3020
+#define EGL_ALPHA_SIZE			0x3021
+#define EGL_BLUE_SIZE			0x3022
+#define EGL_GREEN_SIZE			0x3023
+#define EGL_RED_SIZE			0x3024
+#define EGL_DEPTH_SIZE			0x3025
+#define EGL_STENCIL_SIZE		0x3026
+#define EGL_CONFIG_CAVEAT		0x3027
+#define EGL_CONFIG_ID			0x3028
+#define EGL_LEVEL			0x3029
+#define EGL_MAX_PBUFFER_HEIGHT		0x302A
+#define EGL_MAX_PBUFFER_PIXELS		0x302B
+#define EGL_MAX_PBUFFER_WIDTH		0x302C
+#define EGL_NATIVE_RENDERABLE		0x302D
+#define EGL_NATIVE_VISUAL_ID		0x302E
+#define EGL_NATIVE_VISUAL_TYPE		0x302F
+#define EGL_PRESERVED_RESOURCES		0x3030
+#define EGL_SAMPLES			0x3031
+#define EGL_SAMPLE_BUFFERS		0x3032
+#define EGL_SURFACE_TYPE		0x3033
+#define EGL_TRANSPARENT_TYPE		0x3034
+#define EGL_TRANSPARENT_BLUE_VALUE	0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE	0x3036
+#define EGL_TRANSPARENT_RED_VALUE	0x3037
+#define EGL_NONE			0x3038	/* Attrib list terminator */
+#define EGL_BIND_TO_TEXTURE_RGB		0x3039
+#define EGL_BIND_TO_TEXTURE_RGBA	0x303A
+#define EGL_MIN_SWAP_INTERVAL		0x303B
+#define EGL_MAX_SWAP_INTERVAL		0x303C
+#define EGL_LUMINANCE_SIZE		0x303D
+#define EGL_ALPHA_MASK_SIZE		0x303E
+#define EGL_COLOR_BUFFER_TYPE		0x303F
+#define EGL_RENDERABLE_TYPE		0x3040
+#define EGL_MATCH_NATIVE_PIXMAP		0x3041	/* Pseudo-attribute (not queryable) */
+#define EGL_CONFORMANT			0x3042
+
+/* Reserved 0x3041-0x304F for additional config attributes */
+
+/* Config attribute values */
+#define EGL_SLOW_CONFIG			0x3050	/* EGL_CONFIG_CAVEAT value */
+#define EGL_NON_CONFORMANT_CONFIG	0x3051	/* EGL_CONFIG_CAVEAT value */
+#define EGL_TRANSPARENT_RGB		0x3052	/* EGL_TRANSPARENT_TYPE value */
+#define EGL_RGB_BUFFER			0x308E	/* EGL_COLOR_BUFFER_TYPE value */
+#define EGL_LUMINANCE_BUFFER		0x308F	/* EGL_COLOR_BUFFER_TYPE value */
+
+/* More config attribute values, for EGL_TEXTURE_FORMAT */
+#define EGL_NO_TEXTURE			0x305C
+#define EGL_TEXTURE_RGB			0x305D
+#define EGL_TEXTURE_RGBA		0x305E
+#define EGL_TEXTURE_2D			0x305F
+
+/* Config attribute mask bits */
+#define EGL_PBUFFER_BIT			0x0001	/* EGL_SURFACE_TYPE mask bits */
+#define EGL_PIXMAP_BIT			0x0002	/* EGL_SURFACE_TYPE mask bits */
+#define EGL_WINDOW_BIT			0x0004	/* EGL_SURFACE_TYPE mask bits */
+#define EGL_VG_COLORSPACE_LINEAR_BIT	0x0020	/* EGL_SURFACE_TYPE mask bits */
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT	0x0040	/* EGL_SURFACE_TYPE mask bits */
+#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200	/* EGL_SURFACE_TYPE mask bits */
+#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400	/* EGL_SURFACE_TYPE mask bits */
+
+#define EGL_OPENGL_ES_BIT		0x0001	/* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENVG_BIT			0x0002	/* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENGL_ES2_BIT		0x0004	/* EGL_RENDERABLE_TYPE mask bits */
+#define EGL_OPENGL_BIT			0x0008	/* EGL_RENDERABLE_TYPE mask bits */
+
+/* QueryString targets */
+#define EGL_VENDOR			0x3053
+#define EGL_VERSION			0x3054
+#define EGL_EXTENSIONS			0x3055
+#define EGL_CLIENT_APIS			0x308D
+
+/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */
+#define EGL_HEIGHT			0x3056
+#define EGL_WIDTH			0x3057
+#define EGL_LARGEST_PBUFFER		0x3058
+#define EGL_TEXTURE_FORMAT		0x3080
+#define EGL_TEXTURE_TARGET		0x3081
+#define EGL_MIPMAP_TEXTURE		0x3082
+#define EGL_MIPMAP_LEVEL		0x3083
+#define EGL_RENDER_BUFFER		0x3086
+#define EGL_VG_COLORSPACE		0x3087
+#define EGL_VG_ALPHA_FORMAT		0x3088
+#define EGL_HORIZONTAL_RESOLUTION	0x3090
+#define EGL_VERTICAL_RESOLUTION		0x3091
+#define EGL_PIXEL_ASPECT_RATIO		0x3092
+#define EGL_SWAP_BEHAVIOR		0x3093
+#define EGL_MULTISAMPLE_RESOLVE		0x3099
+
+/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */
+#define EGL_BACK_BUFFER			0x3084
+#define EGL_SINGLE_BUFFER		0x3085
+
+/* OpenVG color spaces */
+#define EGL_VG_COLORSPACE_sRGB		0x3089	/* EGL_VG_COLORSPACE value */
+#define EGL_VG_COLORSPACE_LINEAR	0x308A	/* EGL_VG_COLORSPACE value */
+
+/* OpenVG alpha formats */
+#define EGL_VG_ALPHA_FORMAT_NONPRE	0x308B	/* EGL_ALPHA_FORMAT value */
+#define EGL_VG_ALPHA_FORMAT_PRE		0x308C	/* EGL_ALPHA_FORMAT value */
+
+/* Constant scale factor by which fractional display resolutions &
+ * aspect ratio are scaled when queried as integer values.
+ */
+#define EGL_DISPLAY_SCALING		10000
+
+/* Unknown display resolution/aspect ratio */
+#define EGL_UNKNOWN			((EGLint)-1)
+
+/* Back buffer swap behaviors */
+#define EGL_BUFFER_PRESERVED		0x3094	/* EGL_SWAP_BEHAVIOR value */
+#define EGL_BUFFER_DESTROYED		0x3095	/* EGL_SWAP_BEHAVIOR value */
+
+/* CreatePbufferFromClientBuffer buffer types */
+#define EGL_OPENVG_IMAGE		0x3096
+
+/* QueryContext targets */
+#define EGL_CONTEXT_CLIENT_TYPE		0x3097
+
+/* CreateContext attributes */
+#define EGL_CONTEXT_CLIENT_VERSION	0x3098
+
+/* Multisample resolution behaviors */
+#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A	/* EGL_MULTISAMPLE_RESOLVE value */
+#define EGL_MULTISAMPLE_RESOLVE_BOX	0x309B	/* EGL_MULTISAMPLE_RESOLVE value */
+
+/* BindAPI/QueryAPI targets */
+#define EGL_OPENGL_ES_API		0x30A0
+#define EGL_OPENVG_API			0x30A1
+#define EGL_OPENGL_API			0x30A2
+
+/* GetCurrentSurface targets */
+#define EGL_DRAW			0x3059
+#define EGL_READ			0x305A
+
+/* WaitNative engines */
+#define EGL_CORE_NATIVE_ENGINE		0x305B
+
+/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */
+#define EGL_COLORSPACE			EGL_VG_COLORSPACE
+#define EGL_ALPHA_FORMAT		EGL_VG_ALPHA_FORMAT
+#define EGL_COLORSPACE_sRGB		EGL_VG_COLORSPACE_sRGB
+#define EGL_COLORSPACE_LINEAR		EGL_VG_COLORSPACE_LINEAR
+#define EGL_ALPHA_FORMAT_NONPRE		EGL_VG_ALPHA_FORMAT_NONPRE
+#define EGL_ALPHA_FORMAT_PRE		EGL_VG_ALPHA_FORMAT_PRE
+
+/* EGL extensions must request enum blocks from the Khronos
+ * API Registrar, who maintains the enumerant registry. Submit
+ * a bug in Khronos Bugzilla against task "Registry".
+ */
+
+
+
+/* EGL Functions */
+
+EGLAPI EGLint EGLAPIENTRY eglGetError(void);
+
+EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
+EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
+EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
+
+EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
+			 EGLint config_size, EGLint *num_config);
+EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
+			   EGLConfig *configs, EGLint config_size,
+			   EGLint *num_config);
+EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
+			      EGLint attribute, EGLint *value);
+
+EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
+				  EGLNativeWindowType win,
+				  const EGLint *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
+				   const EGLint *attrib_list);
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
+				  EGLNativePixmapType pixmap,
+				  const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface);
+EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
+			   EGLint attribute, EGLint *value);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api);
+EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void);
+
+EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(
+	      EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer,
+	      EGLConfig config, const EGLint *attrib_list);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
+			    EGLint attribute, EGLint value);
+EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+
+
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
+
+
+EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config,
+			    EGLContext share_context,
+			    const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx);
+EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw,
+			  EGLSurface read, EGLContext ctx);
+
+EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
+EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
+EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
+EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx,
+			   EGLint attribute, EGLint *value);
+
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void);
+EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine);
+EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
+EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface,
+			  EGLNativePixmapType target);
+
+/* This is a generic function pointer type, whose name indicates it must
+ * be cast to the proper type *and calling convention* before use.
+ */
+typedef void (*__eglMustCastToProperFunctionPointerType)(void);
+
+/* Now, define eglGetProcAddress using the generic function ptr. type */
+EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY
+       eglGetProcAddress(const char *procname);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __egl_h_ */
diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h
new file mode 100644
index 0000000..25cfcb8
--- /dev/null
+++ b/opengl/include/EGL/eglext.h
@@ -0,0 +1,138 @@
+#ifndef __eglext_h_
+#define __eglext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+#include <EGL/eglplatform.h>
+
+/*************************************************************/
+
+/* Header file version number */
+/* Current version at http://www.khronos.org/registry/egl/ */
+/* $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $ */
+#define EGL_EGLEXT_VERSION 3
+
+#ifndef EGL_KHR_config_attribs
+#define EGL_KHR_config_attribs 1
+#define EGL_CONFORMANT_KHR			0x3042	/* EGLConfig attribute */
+#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR	0x0020	/* EGL_SURFACE_TYPE bitfield */
+#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR		0x0040	/* EGL_SURFACE_TYPE bitfield */
+#endif
+
+#ifndef EGL_KHR_lock_surface
+#define EGL_KHR_lock_surface 1
+#define EGL_READ_SURFACE_BIT_KHR		0x0001	/* EGL_LOCK_USAGE_HINT_KHR bitfield */
+#define EGL_WRITE_SURFACE_BIT_KHR		0x0002	/* EGL_LOCK_USAGE_HINT_KHR bitfield */
+#define EGL_LOCK_SURFACE_BIT_KHR		0x0080	/* EGL_SURFACE_TYPE bitfield */
+#define EGL_OPTIMAL_FORMAT_BIT_KHR		0x0100	/* EGL_SURFACE_TYPE bitfield */
+#define EGL_MATCH_FORMAT_KHR			0x3043	/* EGLConfig attribute */
+#define EGL_FORMAT_RGB_565_EXACT_KHR		0x30C0	/* EGL_MATCH_FORMAT_KHR value */
+#define EGL_FORMAT_RGB_565_KHR			0x30C1	/* EGL_MATCH_FORMAT_KHR value */
+#define EGL_FORMAT_RGBA_8888_EXACT_KHR		0x30C2	/* EGL_MATCH_FORMAT_KHR value */
+#define EGL_FORMAT_RGBA_8888_KHR		0x30C3	/* EGL_MATCH_FORMAT_KHR value */
+#define EGL_MAP_PRESERVE_PIXELS_KHR		0x30C4	/* eglLockSurfaceKHR attribute */
+#define EGL_LOCK_USAGE_HINT_KHR			0x30C5	/* eglLockSurfaceKHR attribute */
+#define EGL_BITMAP_POINTER_KHR			0x30C6	/* eglQuerySurface attribute */
+#define EGL_BITMAP_PITCH_KHR			0x30C7	/* eglQuerySurface attribute */
+#define EGL_BITMAP_ORIGIN_KHR			0x30C8	/* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR		0x30C9	/* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR	0x30CA	/* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR	0x30CB	/* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR	0x30CC	/* eglQuerySurface attribute */
+#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR	0x30CD	/* eglQuerySurface attribute */
+#define EGL_LOWER_LEFT_KHR			0x30CE	/* EGL_BITMAP_ORIGIN_KHR value */
+#define EGL_UPPER_LEFT_KHR			0x30CF	/* EGL_BITMAP_ORIGIN_KHR value */
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface);
+#endif
+
+#ifndef EGL_KHR_image
+#define EGL_KHR_image 1
+#define EGL_NATIVE_PIXMAP_KHR			0x30B0	/* eglCreateImageKHR target */
+typedef void *EGLImageKHR;
+#define EGL_NO_IMAGE_KHR			((EGLImageKHR)0)
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
+#endif /* EGL_EGLEXT_PROTOTYPES */
+typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
+#endif
+
+#ifndef EGL_KHR_vg_parent_image
+#define EGL_KHR_vg_parent_image 1
+#define EGL_VG_PARENT_IMAGE_KHR			0x30BA	/* eglCreateImageKHR target */
+#endif
+
+#ifndef EGL_KHR_gl_texture_2D_image
+#define EGL_KHR_gl_texture_2D_image 1
+#define EGL_GL_TEXTURE_2D_KHR			0x30B1	/* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_LEVEL_KHR		0x30BC	/* eglCreateImageKHR attribute */
+#endif
+
+#ifndef EGL_KHR_gl_texture_cubemap_image
+#define EGL_KHR_gl_texture_cubemap_image 1
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR	0x30B3	/* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR	0x30B4	/* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR	0x30B5	/* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR	0x30B6	/* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR	0x30B7	/* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR	0x30B8	/* eglCreateImageKHR target */
+#endif
+
+#ifndef EGL_KHR_gl_texture_3D_image
+#define EGL_KHR_gl_texture_3D_image 1
+#define EGL_GL_TEXTURE_3D_KHR			0x30B2	/* eglCreateImageKHR target */
+#define EGL_GL_TEXTURE_ZOFFSET_KHR		0x30BD	/* eglCreateImageKHR attribute */
+#endif
+
+#ifndef EGL_KHR_gl_renderbuffer_image
+#define EGL_KHR_gl_renderbuffer_image 1
+#define EGL_GL_RENDERBUFFER_KHR			0x30B9	/* eglCreateImageKHR target */
+#endif
+
+#ifndef EGL_KHR_image_base
+#define EGL_KHR_image_base 1
+/* Most interfaces defined by EGL_KHR_image_pixmap above */
+#define EGL_IMAGE_PRESERVED_KHR			0x30D2	/* eglCreateImageKHR attribute */
+#endif
+
+#ifndef EGL_KHR_image_pixmap
+#define EGL_KHR_image_pixmap 1
+/* Interfaces defined by EGL_KHR_image above */
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/GLES/eglnatives.h b/opengl/include/EGL/eglnatives.h
similarity index 86%
rename from include/GLES/eglnatives.h
rename to opengl/include/EGL/eglnatives.h
index 1cd57d0..21622dc 100644
--- a/include/GLES/eglnatives.h
+++ b/opengl/include/EGL/eglnatives.h
@@ -22,24 +22,9 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 /*****************************************************************************/
 
-struct egl_native_window_t;
-struct egl_native_pixmap_t;
-
-
-typedef struct egl_native_window_t*     NativeWindowType;
-typedef struct egl_native_pixmap_t*     NativePixmapType;
-typedef void*                           NativeDisplayType;
-
-/* 
- * This a convenience function to create a NativeWindowType surface
- * that maps to the whole screen
- * This function is actually implemented in libui.so
- */
-
-NativeWindowType android_createDisplaySurface();
-
 /* flags returned from swapBuffer */
 #define EGL_NATIVES_FLAG_SIZE_CHANGED       0x00000001
 
@@ -151,48 +136,46 @@
     /*
      * Hook called by EGL to hold a reference on this structure
      */
-    void        (*incRef)(NativeWindowType window);
+    void        (*incRef)(struct egl_native_window_t* window);
 
     /*
      * Hook called by EGL to release a reference on this structure
      */
-    void        (*decRef)(NativeWindowType window);
+    void        (*decRef)(struct egl_native_window_t* window);
 
     /*
      * Hook called by EGL to perform a page flip. This function
      * may update the size attributes above, in which case it returns
      * the EGL_NATIVES_FLAG_SIZE_CHANGED bit set.
      */
-    uint32_t    (*swapBuffers)(NativeWindowType window);
+    uint32_t    (*swapBuffers)(struct egl_native_window_t* window);
     
     /*
-     * Hook called by EGL to set the swap rectangle. this hook can be 
-     * null (operation not supported) 
-     */
-    void        (*setSwapRectangle)(NativeWindowType window, int l, int t, int w, int h);
-
-    /*
      * Reserved for future use. MUST BE ZERO.
      */
     void        (*reserved_proc_0)(void);
-    
+
+    /*
+     * Reserved for future use. MUST BE ZERO.
+     */
+    void        (*reserved_proc_1)(void);
     
     /*
-     * Hook called by EGL to retrieve the next buffer to render into. 
-     * This call updates this structure.
+     * Reserved for future use. MUST BE ZERO.
      */
-    uint32_t    (*nextBuffer)(NativeWindowType window);
+    void        (*reserved_proc_2)(void);
 
+    
     /*
      * Hook called by EGL when the native surface is associated to EGL
      * (eglCreateWindowSurface). Can be NULL.
      */
-    void        (*connect)(NativeWindowType window);
+    void        (*connect)(struct egl_native_window_t* window);
 
     /*
      * Hook called by EGL when eglDestroySurface is called.  Can be NULL.
      */
-    void        (*disconnect)(NativeWindowType window);
+    void        (*disconnect)(struct egl_native_window_t* window);
     
     /*
      * Reserved for future use. MUST BE ZERO.
@@ -224,6 +207,17 @@
 
 /*****************************************************************************/
 
+/* 
+ * This a convenience function to create a NativeWindowType surface
+ * that maps to the whole screen
+ * This function is actually implemented in libui.so
+ */
+
+struct egl_native_window_t* android_createDisplaySurface();
+
+/*****************************************************************************/
+
+
 /*
  * OEM's egl's library (libhgl.so) must imlement these hooks to allocate
  * the GPU memory they need  
diff --git a/opengl/include/EGL/eglplatform.h b/opengl/include/EGL/eglplatform.h
new file mode 100644
index 0000000..ac009010
--- /dev/null
+++ b/opengl/include/EGL/eglplatform.h
@@ -0,0 +1,117 @@
+#ifndef __eglplatform_h_
+#define __eglplatform_h_
+
+/*
+** Copyright (c) 2007-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Platform-specific types and definitions for egl.h
+ * $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product "EGL" component "Registry".
+ */
+
+#include <KHR/khrplatform.h>
+
+/* Macros used in EGL function prototype declarations.
+ *
+ * EGL functions should be prototyped as:
+ *
+ * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
+ * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
+ *
+ * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
+ */
+
+#ifndef EGLAPI
+#define EGLAPI KHRONOS_APICALL
+#endif
+
+#define EGLAPIENTRY  KHRONOS_APIENTRY
+#define EGLAPIENTRYP KHRONOS_APIENTRY*
+
+/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
+ * are aliases of window-system-dependent types, such as X Display * or
+ * Windows Device Context. They must be defined in platform-specific
+ * code below. The EGL-prefixed versions of Native*Type are the same
+ * types, renamed in EGL 1.3 so all types in the API start with "EGL".
+ */
+
+#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#include <windows.h>
+
+typedef HDC     EGLNativeDisplayType;
+typedef HBITMAP EGLNativePixmapType;
+typedef HWND    EGLNativeWindowType;
+
+#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
+
+typedef int   EGLNativeDisplayType;
+typedef void *EGLNativeWindowType;
+typedef void *EGLNativePixmapType;
+
+#elif defined(__unix__) && !defined(ANDROID)
+
+/* X11 (tentative)  */
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+typedef Display *EGLNativeDisplayType;
+typedef Pixmap   EGLNativePixmapType;
+typedef Window   EGLNativeWindowType;
+
+
+#elif defined(ANDROID)
+
+#include <EGL/eglnatives.h>
+
+typedef struct egl_native_window_t*     EGLNativeWindowType;
+typedef struct egl_native_pixmap_t*     EGLNativePixmapType;
+typedef void*                           EGLNativeDisplayType;
+
+#else
+#error "Platform not recognized"
+#endif
+
+/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
+typedef EGLNativeDisplayType NativeDisplayType;
+typedef EGLNativePixmapType  NativePixmapType;
+typedef EGLNativeWindowType  NativeWindowType;
+
+
+/* Define EGLint. This must be a signed integral type large enough to contain
+ * all legal attribute names and values passed into and out of EGL, whether
+ * their type is boolean, bitmask, enumerant (symbolic constant), integer,
+ * handle, or other.  While in general a 32-bit integer will suffice, if
+ * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
+ * integer type.
+ */
+typedef khronos_int32_t EGLint;
+
+#endif /* __eglplatform_h */
diff --git a/opengl/include/GLES/egl.h b/opengl/include/GLES/egl.h
new file mode 100644
index 0000000..5778e00
--- /dev/null
+++ b/opengl/include/GLES/egl.h
@@ -0,0 +1,15 @@
+/*
+ * Skeleton egl.h to provide compatibility for early GLES 1.0
+ * applications. Several early implementations included gl.h
+ * in egl.h leading applications to include only egl.h
+ *
+ * $Revision: 6252 $ on $Date:: 2008-08-06 16:35:08 -0700 #$
+ */
+
+#ifndef __legacy_egl_h_
+#define __legacy_egl_h_
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+#endif /* __legacy_egl_h_ */
diff --git a/opengl/include/GLES/gl.h b/opengl/include/GLES/gl.h
new file mode 100644
index 0000000..2e8b971
--- /dev/null
+++ b/opengl/include/GLES/gl.h
@@ -0,0 +1,769 @@
+#ifndef __gl_h_
+#define __gl_h_
+
+/* $Revision: 7172 $ on $Date:: 2009-01-09 11:17:41 -0800 #$ */
+
+#include <GLES/glplatform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+typedef void             GLvoid;
+typedef unsigned int     GLenum;
+typedef unsigned char    GLboolean;
+typedef unsigned int     GLbitfield;
+typedef khronos_int8_t   GLbyte;
+typedef short            GLshort;
+typedef int              GLint;
+typedef int              GLsizei;
+typedef khronos_uint8_t  GLubyte;
+typedef unsigned short   GLushort;
+typedef unsigned int     GLuint;
+typedef khronos_float_t  GLfloat;
+typedef khronos_float_t  GLclampf;
+typedef khronos_int32_t  GLfixed;
+typedef khronos_int32_t  GLclampx;
+
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t  GLsizeiptr;
+
+
+/*************************************************************/
+
+/* OpenGL ES core versions */
+#define GL_VERSION_ES_CM_1_0          1
+#define GL_VERSION_ES_CL_1_0          1
+#define GL_VERSION_ES_CM_1_1          1
+#define GL_VERSION_ES_CL_1_1          1
+
+/* ClearBufferMask */
+#define GL_DEPTH_BUFFER_BIT               0x00000100
+#define GL_STENCIL_BUFFER_BIT             0x00000400
+#define GL_COLOR_BUFFER_BIT               0x00004000
+
+/* Boolean */
+#define GL_FALSE                          0
+#define GL_TRUE                           1
+
+/* BeginMode */
+#define GL_POINTS                         0x0000
+#define GL_LINES                          0x0001
+#define GL_LINE_LOOP                      0x0002
+#define GL_LINE_STRIP                     0x0003
+#define GL_TRIANGLES                      0x0004
+#define GL_TRIANGLE_STRIP                 0x0005
+#define GL_TRIANGLE_FAN                   0x0006
+
+/* AlphaFunction */
+#define GL_NEVER                          0x0200
+#define GL_LESS                           0x0201
+#define GL_EQUAL                          0x0202
+#define GL_LEQUAL                         0x0203
+#define GL_GREATER                        0x0204
+#define GL_NOTEQUAL                       0x0205
+#define GL_GEQUAL                         0x0206
+#define GL_ALWAYS                         0x0207
+
+/* BlendingFactorDest */
+#define GL_ZERO                           0
+#define GL_ONE                            1
+#define GL_SRC_COLOR                      0x0300
+#define GL_ONE_MINUS_SRC_COLOR            0x0301
+#define GL_SRC_ALPHA                      0x0302
+#define GL_ONE_MINUS_SRC_ALPHA            0x0303
+#define GL_DST_ALPHA                      0x0304
+#define GL_ONE_MINUS_DST_ALPHA            0x0305
+
+/* BlendingFactorSrc */
+/*      GL_ZERO */
+/*      GL_ONE */
+#define GL_DST_COLOR                      0x0306
+#define GL_ONE_MINUS_DST_COLOR            0x0307
+#define GL_SRC_ALPHA_SATURATE             0x0308
+/*      GL_SRC_ALPHA */
+/*      GL_ONE_MINUS_SRC_ALPHA */
+/*      GL_DST_ALPHA */
+/*      GL_ONE_MINUS_DST_ALPHA */
+
+/* ClipPlaneName */
+#define GL_CLIP_PLANE0                    0x3000
+#define GL_CLIP_PLANE1                    0x3001
+#define GL_CLIP_PLANE2                    0x3002
+#define GL_CLIP_PLANE3                    0x3003
+#define GL_CLIP_PLANE4                    0x3004
+#define GL_CLIP_PLANE5                    0x3005
+
+/* ColorMaterialFace */
+/*      GL_FRONT_AND_BACK */
+
+/* ColorMaterialParameter */
+/*      GL_AMBIENT_AND_DIFFUSE */
+
+/* ColorPointerType */
+/*      GL_UNSIGNED_BYTE */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+
+/* CullFaceMode */
+#define GL_FRONT                          0x0404
+#define GL_BACK                           0x0405
+#define GL_FRONT_AND_BACK                 0x0408
+
+/* DepthFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* EnableCap */
+#define GL_FOG                            0x0B60
+#define GL_LIGHTING                       0x0B50
+#define GL_TEXTURE_2D                     0x0DE1
+#define GL_CULL_FACE                      0x0B44
+#define GL_ALPHA_TEST                     0x0BC0
+#define GL_BLEND                          0x0BE2
+#define GL_COLOR_LOGIC_OP                 0x0BF2
+#define GL_DITHER                         0x0BD0
+#define GL_STENCIL_TEST                   0x0B90
+#define GL_DEPTH_TEST                     0x0B71
+/*      GL_LIGHT0 */
+/*      GL_LIGHT1 */
+/*      GL_LIGHT2 */
+/*      GL_LIGHT3 */
+/*      GL_LIGHT4 */
+/*      GL_LIGHT5 */
+/*      GL_LIGHT6 */
+/*      GL_LIGHT7 */
+#define GL_POINT_SMOOTH                   0x0B10
+#define GL_LINE_SMOOTH                    0x0B20
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_COLOR_MATERIAL                 0x0B57
+#define GL_NORMALIZE                      0x0BA1
+#define GL_RESCALE_NORMAL                 0x803A
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_VERTEX_ARRAY                   0x8074
+#define GL_NORMAL_ARRAY                   0x8075
+#define GL_COLOR_ARRAY                    0x8076
+#define GL_TEXTURE_COORD_ARRAY            0x8078
+#define GL_MULTISAMPLE                    0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE            0x809F
+#define GL_SAMPLE_COVERAGE                0x80A0
+
+/* ErrorCode */
+#define GL_NO_ERROR                       0
+#define GL_INVALID_ENUM                   0x0500
+#define GL_INVALID_VALUE                  0x0501
+#define GL_INVALID_OPERATION              0x0502
+#define GL_STACK_OVERFLOW                 0x0503
+#define GL_STACK_UNDERFLOW                0x0504
+#define GL_OUT_OF_MEMORY                  0x0505
+
+/* FogMode */
+/*      GL_LINEAR */
+#define GL_EXP                            0x0800
+#define GL_EXP2                           0x0801
+
+/* FogParameter */
+#define GL_FOG_DENSITY                    0x0B62
+#define GL_FOG_START                      0x0B63
+#define GL_FOG_END                        0x0B64
+#define GL_FOG_MODE                       0x0B65
+#define GL_FOG_COLOR                      0x0B66
+
+/* FrontFaceDirection */
+#define GL_CW                             0x0900
+#define GL_CCW                            0x0901
+
+/* GetPName */
+#define GL_CURRENT_COLOR                  0x0B00
+#define GL_CURRENT_NORMAL                 0x0B02
+#define GL_CURRENT_TEXTURE_COORDS         0x0B03
+#define GL_POINT_SIZE                     0x0B11
+#define GL_POINT_SIZE_MIN                 0x8126
+#define GL_POINT_SIZE_MAX                 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE      0x8128
+#define GL_POINT_DISTANCE_ATTENUATION     0x8129
+#define GL_SMOOTH_POINT_SIZE_RANGE        0x0B12
+#define GL_LINE_WIDTH                     0x0B21
+#define GL_SMOOTH_LINE_WIDTH_RANGE        0x0B22
+#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
+#define GL_CULL_FACE_MODE                 0x0B45
+#define GL_FRONT_FACE                     0x0B46
+#define GL_SHADE_MODEL                    0x0B54
+#define GL_DEPTH_RANGE                    0x0B70
+#define GL_DEPTH_WRITEMASK                0x0B72
+#define GL_DEPTH_CLEAR_VALUE              0x0B73
+#define GL_DEPTH_FUNC                     0x0B74
+#define GL_STENCIL_CLEAR_VALUE            0x0B91
+#define GL_STENCIL_FUNC                   0x0B92
+#define GL_STENCIL_VALUE_MASK             0x0B93
+#define GL_STENCIL_FAIL                   0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL        0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS        0x0B96
+#define GL_STENCIL_REF                    0x0B97
+#define GL_STENCIL_WRITEMASK              0x0B98
+#define GL_MATRIX_MODE                    0x0BA0
+#define GL_VIEWPORT                       0x0BA2
+#define GL_MODELVIEW_STACK_DEPTH          0x0BA3
+#define GL_PROJECTION_STACK_DEPTH         0x0BA4
+#define GL_TEXTURE_STACK_DEPTH            0x0BA5
+#define GL_MODELVIEW_MATRIX               0x0BA6
+#define GL_PROJECTION_MATRIX              0x0BA7
+#define GL_TEXTURE_MATRIX                 0x0BA8
+#define GL_ALPHA_TEST_FUNC                0x0BC1
+#define GL_ALPHA_TEST_REF                 0x0BC2
+#define GL_BLEND_DST                      0x0BE0
+#define GL_BLEND_SRC                      0x0BE1
+#define GL_LOGIC_OP_MODE                  0x0BF0
+#define GL_SCISSOR_BOX                    0x0C10
+#define GL_SCISSOR_TEST                   0x0C11
+#define GL_COLOR_CLEAR_VALUE              0x0C22
+#define GL_COLOR_WRITEMASK                0x0C23
+#define GL_UNPACK_ALIGNMENT               0x0CF5
+#define GL_PACK_ALIGNMENT                 0x0D05
+#define GL_MAX_LIGHTS                     0x0D31
+#define GL_MAX_CLIP_PLANES                0x0D32
+#define GL_MAX_TEXTURE_SIZE               0x0D33
+#define GL_MAX_MODELVIEW_STACK_DEPTH      0x0D36
+#define GL_MAX_PROJECTION_STACK_DEPTH     0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH        0x0D39
+#define GL_MAX_VIEWPORT_DIMS              0x0D3A
+#define GL_MAX_TEXTURE_UNITS              0x84E2
+#define GL_SUBPIXEL_BITS                  0x0D50
+#define GL_RED_BITS                       0x0D52
+#define GL_GREEN_BITS                     0x0D53
+#define GL_BLUE_BITS                      0x0D54
+#define GL_ALPHA_BITS                     0x0D55
+#define GL_DEPTH_BITS                     0x0D56
+#define GL_STENCIL_BITS                   0x0D57
+#define GL_POLYGON_OFFSET_UNITS           0x2A00
+#define GL_POLYGON_OFFSET_FILL            0x8037
+#define GL_POLYGON_OFFSET_FACTOR          0x8038
+#define GL_TEXTURE_BINDING_2D             0x8069
+#define GL_VERTEX_ARRAY_SIZE              0x807A
+#define GL_VERTEX_ARRAY_TYPE              0x807B
+#define GL_VERTEX_ARRAY_STRIDE            0x807C
+#define GL_NORMAL_ARRAY_TYPE              0x807E
+#define GL_NORMAL_ARRAY_STRIDE            0x807F
+#define GL_COLOR_ARRAY_SIZE               0x8081
+#define GL_COLOR_ARRAY_TYPE               0x8082
+#define GL_COLOR_ARRAY_STRIDE             0x8083
+#define GL_TEXTURE_COORD_ARRAY_SIZE       0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE       0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE     0x808A
+#define GL_VERTEX_ARRAY_POINTER           0x808E
+#define GL_NORMAL_ARRAY_POINTER           0x808F
+#define GL_COLOR_ARRAY_POINTER            0x8090
+#define GL_TEXTURE_COORD_ARRAY_POINTER    0x8092
+#define GL_SAMPLE_BUFFERS                 0x80A8
+#define GL_SAMPLES                        0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE          0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT         0x80AB
+
+/* GetTextureParameter */
+/*      GL_TEXTURE_MAG_FILTER */
+/*      GL_TEXTURE_MIN_FILTER */
+/*      GL_TEXTURE_WRAP_S */
+/*      GL_TEXTURE_WRAP_T */
+
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
+
+/* HintMode */
+#define GL_DONT_CARE                      0x1100
+#define GL_FASTEST                        0x1101
+#define GL_NICEST                         0x1102
+
+/* HintTarget */
+#define GL_PERSPECTIVE_CORRECTION_HINT    0x0C50
+#define GL_POINT_SMOOTH_HINT              0x0C51
+#define GL_LINE_SMOOTH_HINT               0x0C52
+#define GL_FOG_HINT                       0x0C54
+#define GL_GENERATE_MIPMAP_HINT           0x8192
+
+/* LightModelParameter */
+#define GL_LIGHT_MODEL_AMBIENT            0x0B53
+#define GL_LIGHT_MODEL_TWO_SIDE           0x0B52
+
+/* LightParameter */
+#define GL_AMBIENT                        0x1200
+#define GL_DIFFUSE                        0x1201
+#define GL_SPECULAR                       0x1202
+#define GL_POSITION                       0x1203
+#define GL_SPOT_DIRECTION                 0x1204
+#define GL_SPOT_EXPONENT                  0x1205
+#define GL_SPOT_CUTOFF                    0x1206
+#define GL_CONSTANT_ATTENUATION           0x1207
+#define GL_LINEAR_ATTENUATION             0x1208
+#define GL_QUADRATIC_ATTENUATION          0x1209
+
+/* DataType */
+#define GL_BYTE                           0x1400
+#define GL_UNSIGNED_BYTE                  0x1401
+#define GL_SHORT                          0x1402
+#define GL_UNSIGNED_SHORT                 0x1403
+#define GL_FLOAT                          0x1406
+#define GL_FIXED                          0x140C
+
+/* LogicOp */
+#define GL_CLEAR                          0x1500
+#define GL_AND                            0x1501
+#define GL_AND_REVERSE                    0x1502
+#define GL_COPY                           0x1503
+#define GL_AND_INVERTED                   0x1504
+#define GL_NOOP                           0x1505
+#define GL_XOR                            0x1506
+#define GL_OR                             0x1507
+#define GL_NOR                            0x1508
+#define GL_EQUIV                          0x1509
+#define GL_INVERT                         0x150A
+#define GL_OR_REVERSE                     0x150B
+#define GL_COPY_INVERTED                  0x150C
+#define GL_OR_INVERTED                    0x150D
+#define GL_NAND                           0x150E
+#define GL_SET                            0x150F
+
+/* MaterialFace */
+/*      GL_FRONT_AND_BACK */
+
+/* MaterialParameter */
+#define GL_EMISSION                       0x1600
+#define GL_SHININESS                      0x1601
+#define GL_AMBIENT_AND_DIFFUSE            0x1602
+/*      GL_AMBIENT */
+/*      GL_DIFFUSE */
+/*      GL_SPECULAR */
+
+/* MatrixMode */
+#define GL_MODELVIEW                      0x1700
+#define GL_PROJECTION                     0x1701
+#define GL_TEXTURE                        0x1702
+
+/* NormalPointerType */
+/*      GL_BYTE */
+/*      GL_SHORT */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+
+/* PixelFormat */
+#define GL_ALPHA                          0x1906
+#define GL_RGB                            0x1907
+#define GL_RGBA                           0x1908
+#define GL_LUMINANCE                      0x1909
+#define GL_LUMINANCE_ALPHA                0x190A
+
+/* PixelStoreParameter */
+#define GL_UNPACK_ALIGNMENT               0x0CF5
+#define GL_PACK_ALIGNMENT                 0x0D05
+
+/* PixelType */
+/*      GL_UNSIGNED_BYTE */
+#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
+#define GL_UNSIGNED_SHORT_5_6_5           0x8363
+
+/* ShadingModel */
+#define GL_FLAT                           0x1D00
+#define GL_SMOOTH                         0x1D01
+
+/* StencilFunction */
+/*      GL_NEVER */
+/*      GL_LESS */
+/*      GL_EQUAL */
+/*      GL_LEQUAL */
+/*      GL_GREATER */
+/*      GL_NOTEQUAL */
+/*      GL_GEQUAL */
+/*      GL_ALWAYS */
+
+/* StencilOp */
+/*      GL_ZERO */
+#define GL_KEEP                           0x1E00
+#define GL_REPLACE                        0x1E01
+#define GL_INCR                           0x1E02
+#define GL_DECR                           0x1E03
+/*      GL_INVERT */
+
+/* StringName */
+#define GL_VENDOR                         0x1F00
+#define GL_RENDERER                       0x1F01
+#define GL_VERSION                        0x1F02
+#define GL_EXTENSIONS                     0x1F03
+
+/* TexCoordPointerType */
+/*      GL_SHORT */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+/*      GL_BYTE */
+
+/* TextureEnvMode */
+#define GL_MODULATE                       0x2100
+#define GL_DECAL                          0x2101
+/*      GL_BLEND */
+#define GL_ADD                            0x0104
+/*      GL_REPLACE */
+
+/* TextureEnvParameter */
+#define GL_TEXTURE_ENV_MODE               0x2200
+#define GL_TEXTURE_ENV_COLOR              0x2201
+
+/* TextureEnvTarget */
+#define GL_TEXTURE_ENV                    0x2300
+
+/* TextureMagFilter */
+#define GL_NEAREST                        0x2600
+#define GL_LINEAR                         0x2601
+
+/* TextureMinFilter */
+/*      GL_NEAREST */
+/*      GL_LINEAR */
+#define GL_NEAREST_MIPMAP_NEAREST         0x2700
+#define GL_LINEAR_MIPMAP_NEAREST          0x2701
+#define GL_NEAREST_MIPMAP_LINEAR          0x2702
+#define GL_LINEAR_MIPMAP_LINEAR           0x2703
+
+/* TextureParameterName */
+#define GL_TEXTURE_MAG_FILTER             0x2800
+#define GL_TEXTURE_MIN_FILTER             0x2801
+#define GL_TEXTURE_WRAP_S                 0x2802
+#define GL_TEXTURE_WRAP_T                 0x2803
+#define GL_GENERATE_MIPMAP                0x8191
+
+/* TextureTarget */
+/*      GL_TEXTURE_2D */
+
+/* TextureUnit */
+#define GL_TEXTURE0                       0x84C0
+#define GL_TEXTURE1                       0x84C1
+#define GL_TEXTURE2                       0x84C2
+#define GL_TEXTURE3                       0x84C3
+#define GL_TEXTURE4                       0x84C4
+#define GL_TEXTURE5                       0x84C5
+#define GL_TEXTURE6                       0x84C6
+#define GL_TEXTURE7                       0x84C7
+#define GL_TEXTURE8                       0x84C8
+#define GL_TEXTURE9                       0x84C9
+#define GL_TEXTURE10                      0x84CA
+#define GL_TEXTURE11                      0x84CB
+#define GL_TEXTURE12                      0x84CC
+#define GL_TEXTURE13                      0x84CD
+#define GL_TEXTURE14                      0x84CE
+#define GL_TEXTURE15                      0x84CF
+#define GL_TEXTURE16                      0x84D0
+#define GL_TEXTURE17                      0x84D1
+#define GL_TEXTURE18                      0x84D2
+#define GL_TEXTURE19                      0x84D3
+#define GL_TEXTURE20                      0x84D4
+#define GL_TEXTURE21                      0x84D5
+#define GL_TEXTURE22                      0x84D6
+#define GL_TEXTURE23                      0x84D7
+#define GL_TEXTURE24                      0x84D8
+#define GL_TEXTURE25                      0x84D9
+#define GL_TEXTURE26                      0x84DA
+#define GL_TEXTURE27                      0x84DB
+#define GL_TEXTURE28                      0x84DC
+#define GL_TEXTURE29                      0x84DD
+#define GL_TEXTURE30                      0x84DE
+#define GL_TEXTURE31                      0x84DF
+#define GL_ACTIVE_TEXTURE                 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE          0x84E1
+
+/* TextureWrapMode */
+#define GL_REPEAT                         0x2901
+#define GL_CLAMP_TO_EDGE                  0x812F
+
+/* VertexPointerType */
+/*      GL_SHORT */
+/*      GL_FLOAT */
+/*      GL_FIXED */
+/*      GL_BYTE */
+
+/* LightName */
+#define GL_LIGHT0                         0x4000
+#define GL_LIGHT1                         0x4001
+#define GL_LIGHT2                         0x4002
+#define GL_LIGHT3                         0x4003
+#define GL_LIGHT4                         0x4004
+#define GL_LIGHT5                         0x4005
+#define GL_LIGHT6                         0x4006
+#define GL_LIGHT7                         0x4007
+
+/* Buffer Objects */
+#define GL_ARRAY_BUFFER                   0x8892
+#define GL_ELEMENT_ARRAY_BUFFER           0x8893
+
+#define GL_ARRAY_BUFFER_BINDING               0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING       0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING        0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING        0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING         0x8898
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
+
+#define GL_STATIC_DRAW                    0x88E4
+#define GL_DYNAMIC_DRAW                   0x88E8
+
+#define GL_BUFFER_SIZE                    0x8764
+#define GL_BUFFER_USAGE                   0x8765
+
+/* Texture combine + dot3 */
+#define GL_SUBTRACT                       0x84E7
+#define GL_COMBINE                        0x8570
+#define GL_COMBINE_RGB                    0x8571
+#define GL_COMBINE_ALPHA                  0x8572
+#define GL_RGB_SCALE                      0x8573
+#define GL_ADD_SIGNED                     0x8574
+#define GL_INTERPOLATE                    0x8575
+#define GL_CONSTANT                       0x8576
+#define GL_PRIMARY_COLOR                  0x8577
+#define GL_PREVIOUS                       0x8578
+#define GL_OPERAND0_RGB                   0x8590
+#define GL_OPERAND1_RGB                   0x8591
+#define GL_OPERAND2_RGB                   0x8592
+#define GL_OPERAND0_ALPHA                 0x8598
+#define GL_OPERAND1_ALPHA                 0x8599
+#define GL_OPERAND2_ALPHA                 0x859A
+
+#define GL_ALPHA_SCALE                    0x0D1C
+
+#define GL_SRC0_RGB                       0x8580
+#define GL_SRC1_RGB                       0x8581
+#define GL_SRC2_RGB                       0x8582
+#define GL_SRC0_ALPHA                     0x8588
+#define GL_SRC1_ALPHA                     0x8589
+#define GL_SRC2_ALPHA                     0x858A
+
+#define GL_DOT3_RGB                       0x86AE
+#define GL_DOT3_RGBA                      0x86AF
+
+/*------------------------------------------------------------------------*
+ * required OES extension tokens
+ *------------------------------------------------------------------------*/
+
+/* OES_read_format */
+#ifndef GL_OES_read_format
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES                   0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES                 0x8B9B
+#endif
+
+/* GL_OES_compressed_paletted_texture */
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_PALETTE4_RGB8_OES                                    0x8B90
+#define GL_PALETTE4_RGBA8_OES                                   0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES                                0x8B92
+#define GL_PALETTE4_RGBA4_OES                                   0x8B93
+#define GL_PALETTE4_RGB5_A1_OES                                 0x8B94
+#define GL_PALETTE8_RGB8_OES                                    0x8B95
+#define GL_PALETTE8_RGBA8_OES                                   0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES                                0x8B97
+#define GL_PALETTE8_RGBA4_OES                                   0x8B98
+#define GL_PALETTE8_RGB5_A1_OES                                 0x8B99
+#endif
+
+/* OES_point_size_array */
+#ifndef GL_OES_point_size_array
+#define GL_POINT_SIZE_ARRAY_OES                                 0x8B9C
+#define GL_POINT_SIZE_ARRAY_TYPE_OES                            0x898A
+#define GL_POINT_SIZE_ARRAY_STRIDE_OES                          0x898B
+#define GL_POINT_SIZE_ARRAY_POINTER_OES                         0x898C
+#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES                  0x8B9F
+#endif
+
+/* GL_OES_point_sprite */
+#ifndef GL_OES_point_sprite
+#define GL_POINT_SPRITE_OES                                     0x8861
+#define GL_COORD_REPLACE_OES                                    0x8862
+#endif
+
+/*************************************************************/
+
+/* Available only in Common profile */
+GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref);
+GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+GL_API void GL_APIENTRY glClearDepthf (GLclampf depth);
+GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation);
+GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
+GL_API void GL_APIENTRY glFogf (GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]);
+GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetTexEnvfv (GLenum env, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glLightModelf (GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glLightModelfv (GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glLineWidth (GLfloat width);
+GL_API void GL_APIENTRY glLoadMatrixf (const GLfloat *m);
+GL_API void GL_APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glMultMatrixf (const GLfloat *m);
+GL_API void GL_APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GL_API void GL_APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz);
+GL_API void GL_APIENTRY glOrthof (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glPointParameterf (GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glPointSize (GLfloat size);
+GL_API void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GL_API void GL_APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+GL_API void GL_APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z);
+GL_API void GL_APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z);
+
+/* Available in both Common and Common-Lite profiles */
+GL_API void GL_APIENTRY glActiveTexture (GLenum texture);
+GL_API void GL_APIENTRY glAlphaFuncx (GLenum func, GLclampx ref);
+GL_API void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GL_API void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
+GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GL_API void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+GL_API void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+GL_API void GL_APIENTRY glClear (GLbitfield mask);
+GL_API void GL_APIENTRY glClearColorx (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+GL_API void GL_APIENTRY glClearDepthx (GLclampx depth);
+GL_API void GL_APIENTRY glClearStencil (GLint s);
+GL_API void GL_APIENTRY glClientActiveTexture (GLenum texture);
+GL_API void GL_APIENTRY glClipPlanex (GLenum plane, const GLfixed *equation);
+GL_API void GL_APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+GL_API void GL_APIENTRY glColor4x (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GL_API void GL_APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+GL_API void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+GL_API void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_API void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glCullFace (GLenum mode);
+GL_API void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
+GL_API void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
+GL_API void GL_APIENTRY glDepthFunc (GLenum func);
+GL_API void GL_APIENTRY glDepthMask (GLboolean flag);
+GL_API void GL_APIENTRY glDepthRangex (GLclampx zNear, GLclampx zFar);
+GL_API void GL_APIENTRY glDisable (GLenum cap);
+GL_API void GL_APIENTRY glDisableClientState (GLenum array);
+GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
+GL_API void GL_APIENTRY glEnable (GLenum cap);
+GL_API void GL_APIENTRY glEnableClientState (GLenum array);
+GL_API void GL_APIENTRY glFinish (void);
+GL_API void GL_APIENTRY glFlush (void);
+GL_API void GL_APIENTRY glFogx (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glFogxv (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glFrontFace (GLenum mode);
+GL_API void GL_APIENTRY glFrustumx (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params);
+GL_API void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetClipPlanex (GLenum pname, GLfixed eqn[4]);
+GL_API void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
+GL_API void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
+GL_API GLenum GL_APIENTRY glGetError (void);
+GL_API void GL_APIENTRY glGetFixedv (GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetLightxv (GLenum light, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetMaterialxv (GLenum face, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetPointerv (GLenum pname, void **params);
+GL_API const GLubyte * GL_APIENTRY glGetString (GLenum name);
+GL_API void GL_APIENTRY glGetTexEnviv (GLenum env, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetTexEnvxv (GLenum env, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetTexParameterxv (GLenum target, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glHint (GLenum target, GLenum mode);
+GL_API GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
+GL_API GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
+GL_API GLboolean GL_APIENTRY glIsTexture (GLuint texture);
+GL_API void GL_APIENTRY glLightModelx (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightModelxv (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLightx (GLenum light, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightxv (GLenum light, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLineWidthx (GLfixed width);
+GL_API void GL_APIENTRY glLoadIdentity (void);
+GL_API void GL_APIENTRY glLoadMatrixx (const GLfixed *m);
+GL_API void GL_APIENTRY glLogicOp (GLenum opcode);
+GL_API void GL_APIENTRY glMaterialx (GLenum face, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glMaterialxv (GLenum face, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glMatrixMode (GLenum mode);
+GL_API void GL_APIENTRY glMultMatrixx (const GLfixed *m);
+GL_API void GL_APIENTRY glMultiTexCoord4x (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+GL_API void GL_APIENTRY glNormal3x (GLfixed nx, GLfixed ny, GLfixed nz);
+GL_API void GL_APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glOrthox (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
+GL_API void GL_APIENTRY glPointParameterx (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glPointParameterxv (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glPointSizex (GLfixed size);
+GL_API void GL_APIENTRY glPolygonOffsetx (GLfixed factor, GLfixed units);
+GL_API void GL_APIENTRY glPopMatrix (void);
+GL_API void GL_APIENTRY glPushMatrix (void);
+GL_API void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
+GL_API void GL_APIENTRY glRotatex (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
+GL_API void GL_APIENTRY glSampleCoveragex (GLclampx value, GLboolean invert);
+GL_API void GL_APIENTRY glScalex (GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glShadeModel (GLenum mode);
+GL_API void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GL_API void GL_APIENTRY glStencilMask (GLuint mask);
+GL_API void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GL_API void GL_APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param);
+GL_API void GL_APIENTRY glTexEnvx (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params);
+GL_API void GL_APIENTRY glTexEnvxv (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+GL_API void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GL_API void GL_APIENTRY glTexParameterx (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
+GL_API void GL_APIENTRY glTexParameterxv (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+GL_API void GL_APIENTRY glTranslatex (GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+
+/*------------------------------------------------------------------------*
+ * Required OES extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_read_format */
+#ifndef GL_OES_read_format
+#define GL_OES_read_format 1
+#endif
+
+/* GL_OES_compressed_paletted_texture */
+#ifndef GL_OES_compressed_paletted_texture
+#define GL_OES_compressed_paletted_texture 1
+#endif
+
+/* GL_OES_point_size_array */
+#ifndef GL_OES_point_size_array
+#define GL_OES_point_size_array 1
+GL_API void GL_APIENTRY glPointSizePointerOES (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+/* GL_OES_point_sprite */
+#ifndef GL_OES_point_sprite
+#define GL_OES_point_sprite 1
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl_h_ */
+
diff --git a/opengl/include/GLES/glext.h b/opengl/include/GLES/glext.h
new file mode 100644
index 0000000..4c01871a
--- /dev/null
+++ b/opengl/include/GLES/glext.h
@@ -0,0 +1,622 @@
+#ifndef __glext_h_
+#define __glext_h_
+
+/* $Revision: 7172 $ on $Date:: 2009-01-09 11:17:41 -0800 #$ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+#ifndef GL_APIENTRYP
+#   define GL_APIENTRYP GL_APIENTRY*
+#endif
+
+/*------------------------------------------------------------------------*
+ * OES extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_blend_equation_separate */
+#ifndef GL_OES_blend_equation_separate
+/* BLEND_EQUATION_RGB_OES same as BLEND_EQUATION_OES */
+#define GL_BLEND_EQUATION_RGB_OES                               0x8009
+#define GL_BLEND_EQUATION_ALPHA_OES                             0x883D
+#endif
+
+/* GL_OES_blend_func_separate */
+#ifndef GL_OES_blend_func_separate
+#define GL_BLEND_DST_RGB_OES                                    0x80C8
+#define GL_BLEND_SRC_RGB_OES                                    0x80C9
+#define GL_BLEND_DST_ALPHA_OES                                  0x80CA
+#define GL_BLEND_SRC_ALPHA_OES                                  0x80CB
+#endif
+
+/* GL_OES_blend_subtract */
+#ifndef GL_OES_blend_subtract
+#define GL_BLEND_EQUATION_OES                                   0x8009
+#define GL_FUNC_ADD_OES                                         0x8006
+#define GL_FUNC_SUBTRACT_OES                                    0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_OES                            0x800B
+#endif
+
+/* GL_OES_compressed_ETC1_RGB8_texture */
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_ETC1_RGB8_OES                                        0x8D64
+#endif
+
+/* GL_OES_depth24 */
+#ifndef GL_OES_depth24
+#define GL_DEPTH_COMPONENT24_OES                                0x81A6
+#endif
+
+/* GL_OES_depth32 */
+#ifndef GL_OES_depth32
+#define GL_DEPTH_COMPONENT32_OES                                0x81A7
+#endif
+
+/* GL_OES_draw_texture */
+#ifndef GL_OES_draw_texture
+#define GL_TEXTURE_CROP_RECT_OES                                0x8B9D
+#endif
+
+/* GL_OES_EGL_image */
+#ifndef GL_OES_EGL_image
+typedef void* GLeglImageOES;
+#endif
+
+/* GL_OES_fixed_point */
+#ifndef GL_OES_fixed_point
+#define GL_FIXED_OES                                            0x140C
+#endif
+
+/* GL_OES_framebuffer_object */
+#ifndef GL_OES_framebuffer_object
+#define GL_NONE_OES                                             0
+#define GL_FRAMEBUFFER_OES                                      0x8D40
+#define GL_RENDERBUFFER_OES                                     0x8D41
+#define GL_RGBA4_OES                                            0x8056
+#define GL_RGB5_A1_OES                                          0x8057
+#define GL_RGB565_OES                                           0x8D62
+#define GL_DEPTH_COMPONENT16_OES                                0x81A5
+#define GL_RENDERBUFFER_WIDTH_OES                               0x8D42
+#define GL_RENDERBUFFER_HEIGHT_OES                              0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES                     0x8D44
+#define GL_RENDERBUFFER_RED_SIZE_OES                            0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_OES                          0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_OES                           0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_OES                          0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_OES                          0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_OES                        0x8D55
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES               0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES               0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES             0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES     0x8CD3
+#define GL_COLOR_ATTACHMENT0_OES                                0x8CE0
+#define GL_DEPTH_ATTACHMENT_OES                                 0x8D00
+#define GL_STENCIL_ATTACHMENT_OES                               0x8D20
+#define GL_FRAMEBUFFER_COMPLETE_OES                             0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES                0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES        0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES                0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES                   0x8CDA
+#define GL_FRAMEBUFFER_UNSUPPORTED_OES                          0x8CDD
+#define GL_FRAMEBUFFER_BINDING_OES                              0x8CA6
+#define GL_RENDERBUFFER_BINDING_OES                             0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE_OES                            0x84E8
+#define GL_INVALID_FRAMEBUFFER_OPERATION_OES                    0x0506
+#endif
+
+/* GL_OES_mapbuffer */
+#ifndef GL_OES_mapbuffer
+#define GL_WRITE_ONLY_OES                                       0x88B9
+#define GL_BUFFER_ACCESS_OES                                    0x88BB
+#define GL_BUFFER_MAPPED_OES                                    0x88BC
+#define GL_BUFFER_MAP_POINTER_OES                               0x88BD
+#endif
+
+/* GL_OES_matrix_get */
+#ifndef GL_OES_matrix_get
+#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES               0x898D
+#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES              0x898E
+#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES                 0x898F
+#endif
+
+/* GL_OES_matrix_palette */
+#ifndef GL_OES_matrix_palette
+#define GL_MAX_VERTEX_UNITS_OES                                 0x86A4
+#define GL_MAX_PALETTE_MATRICES_OES                             0x8842
+#define GL_MATRIX_PALETTE_OES                                   0x8840
+#define GL_MATRIX_INDEX_ARRAY_OES                               0x8844
+#define GL_WEIGHT_ARRAY_OES                                     0x86AD
+#define GL_CURRENT_PALETTE_MATRIX_OES                           0x8843
+#define GL_MATRIX_INDEX_ARRAY_SIZE_OES                          0x8846
+#define GL_MATRIX_INDEX_ARRAY_TYPE_OES                          0x8847
+#define GL_MATRIX_INDEX_ARRAY_STRIDE_OES                        0x8848
+#define GL_MATRIX_INDEX_ARRAY_POINTER_OES                       0x8849
+#define GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES                0x8B9E
+#define GL_WEIGHT_ARRAY_SIZE_OES                                0x86AB
+#define GL_WEIGHT_ARRAY_TYPE_OES                                0x86A9
+#define GL_WEIGHT_ARRAY_STRIDE_OES                              0x86AA
+#define GL_WEIGHT_ARRAY_POINTER_OES                             0x86AC
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_OES                      0x889E
+#endif
+
+/* GL_OES_packed_depth_stencil */
+#ifndef GL_OES_packed_depth_stencil
+#define GL_DEPTH_STENCIL_OES                                    0x84F9
+#define GL_UNSIGNED_INT_24_8_OES                                0x84FA
+#define GL_DEPTH24_STENCIL8_OES                                 0x88F0
+#endif
+
+/* GL_OES_rgb8_rgba8 */
+#ifndef GL_OES_rgb8_rgba8
+#define GL_RGB8_OES                                             0x8051
+#define GL_RGBA8_OES                                            0x8058
+#endif
+
+/* GL_OES_stencil1 */
+#ifndef GL_OES_stencil1
+#define GL_STENCIL_INDEX1_OES                                   0x8D46
+#endif
+
+/* GL_OES_stencil4 */
+#ifndef GL_OES_stencil4
+#define GL_STENCIL_INDEX4_OES                                   0x8D47
+#endif
+
+/* GL_OES_stencil8 */
+#ifndef GL_OES_stencil8
+#define GL_STENCIL_INDEX8_OES                                   0x8D48
+#endif
+
+/* GL_OES_stencil_wrap */
+#ifndef GL_OES_stencil_wrap
+#define GL_INCR_WRAP_OES                                        0x8507
+#define GL_DECR_WRAP_OES                                        0x8508
+#endif
+
+/* GL_OES_texture_cube_map */
+#ifndef GL_OES_texture_cube_map
+#define GL_NORMAL_MAP_OES                                       0x8511
+#define GL_REFLECTION_MAP_OES                                   0x8512
+#define GL_TEXTURE_CUBE_MAP_OES                                 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_OES                         0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES                      0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES                      0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES                      0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES                      0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES                      0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES                      0x851A
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES                        0x851C
+#define GL_TEXTURE_GEN_MODE_OES                                 0x2500
+#define GL_TEXTURE_GEN_STR_OES                                  0x8D60
+#endif
+
+/* GL_OES_texture_mirrored_repeat */
+#ifndef GL_OES_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_OES                                  0x8370
+#endif
+
+/*------------------------------------------------------------------------*
+ * AMD extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_AMD_compressed_3DC_texture */
+#ifndef GL_AMD_compressed_3DC_texture
+#define GL_3DC_X_AMD                                            0x87F9
+#define GL_3DC_XY_AMD                                           0x87FA
+#endif
+
+/* GL_AMD_compressed_ATC_texture */
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_ATC_RGB_AMD                                          0x8C92
+#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD                          0x8C93
+#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD                      0x87EE
+#endif
+
+/*------------------------------------------------------------------------*
+ * EXT extension tokens
+ *------------------------------------------------------------------------*/
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT                           0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT                       0x84FF
+#endif
+
+/*------------------------------------------------------------------------*
+ * OES extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_OES_blend_equation_separate */
+#ifndef GL_OES_blend_equation_separate
+#define GL_OES_blend_equation_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glBlendEquationSeparateOES (GLenum modeRGB, GLenum modeAlpha);
+#endif
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEOESPROC) (GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+/* GL_OES_blend_func_separate */
+#ifndef GL_OES_blend_func_separate
+#define GL_OES_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glBlendFuncSeparateOES (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEOESPROC) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+#endif
+
+/* GL_OES_blend_subtract */
+#ifndef GL_OES_blend_subtract
+#define GL_OES_blend_subtract 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glBlendEquationOES (GLenum mode);
+#endif
+typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONOESPROC) (GLenum mode);
+#endif
+
+/* GL_OES_byte_coordinates */
+#ifndef GL_OES_byte_coordinates
+#define GL_OES_byte_coordinates 1
+#endif
+
+/* GL_OES_compressed_ETC1_RGB8_texture */
+#ifndef GL_OES_compressed_ETC1_RGB8_texture
+#define GL_OES_compressed_ETC1_RGB8_texture 1
+#endif
+
+/* GL_OES_depth24 */
+#ifndef GL_OES_depth24
+#define GL_OES_depth24 1
+#endif
+
+/* GL_OES_depth32 */
+#ifndef GL_OES_depth32
+#define GL_OES_depth32 1
+#endif
+
+/* GL_OES_draw_texture */
+#ifndef GL_OES_draw_texture
+#define GL_OES_draw_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
+GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height);
+GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
+GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords);
+GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords);
+GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords);
+GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
+GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords);
+#endif
+typedef void (GL_APIENTRYP PFNGLDRAWTEXSOESPROC) (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXIOESPROC) (GLint x, GLint y, GLint z, GLint width, GLint height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXXOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXSVOESPROC) (const GLshort *coords);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXIVOESPROC) (const GLint *coords);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXXVOESPROC) (const GLfixed *coords);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXFOESPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
+typedef void (GL_APIENTRYP PFNGLDRAWTEXFVOESPROC) (const GLfloat *coords);
+#endif
+
+/* GL_OES_EGL_image */
+#ifndef GL_OES_EGL_image
+#define GL_OES_EGL_image 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
+#endif
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
+#endif
+
+/* GL_OES_element_index_uint */
+#ifndef GL_OES_element_index_uint
+#define GL_OES_element_index_uint 1
+#endif
+
+/* GL_OES_extended_matrix_palette */
+#ifndef GL_OES_extended_matrix_palette
+#define GL_OES_extended_matrix_palette 1
+#endif
+
+/* GL_OES_fbo_render_mipmap */
+#ifndef GL_OES_fbo_render_mipmap
+#define GL_OES_fbo_render_mipmap 1
+#endif
+
+/* GL_OES_fixed_point */
+#ifndef GL_OES_fixed_point
+#define GL_OES_fixed_point 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glAlphaFuncxOES (GLenum func, GLclampx ref);
+GL_API void GL_APIENTRY glClearColorxOES (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+GL_API void GL_APIENTRY glClearDepthxOES (GLclampx depth);
+GL_API void GL_APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation);
+GL_API void GL_APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+GL_API void GL_APIENTRY glDepthRangexOES (GLclampx zNear, GLclampx zFar);
+GL_API void GL_APIENTRY glFogxOES (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glFogxvOES (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glFrustumxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glGetClipPlanexOES (GLenum pname, GLfixed eqn[4]);
+GL_API void GL_APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetLightxvOES (GLenum light, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetMaterialxvOES (GLenum face, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetTexEnvxvOES (GLenum env, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params);
+GL_API void GL_APIENTRY glLightModelxOES (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glLineWidthxOES (GLfixed width);
+GL_API void GL_APIENTRY glLoadMatrixxOES (const GLfixed *m);
+GL_API void GL_APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glMultMatrixxOES (const GLfixed *m);
+GL_API void GL_APIENTRY glMultiTexCoord4xOES (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+GL_API void GL_APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz);
+GL_API void GL_APIENTRY glOrthoxOES (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+GL_API void GL_APIENTRY glPointParameterxOES (GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glPointSizexOES (GLfixed size);
+GL_API void GL_APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units);
+GL_API void GL_APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glSampleCoveragexOES (GLclampx value, GLboolean invert);
+GL_API void GL_APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z);
+GL_API void GL_APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z);
+#endif
+typedef void (GL_APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLclampx ref);
+typedef void (GL_APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha);
+typedef void (GL_APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLclampx depth);
+typedef void (GL_APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation);
+typedef void (GL_APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha);
+typedef void (GL_APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLclampx zNear, GLclampx zFar);
+typedef void (GL_APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum pname, GLfixed eqn[4]);
+typedef void (GL_APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETLIGHTXVOESPROC) (GLenum light, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETMATERIALXVOESPROC) (GLenum face, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum env, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width);
+typedef void (GL_APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m);
+typedef void (GL_APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m);
+typedef void (GL_APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q);
+typedef void (GL_APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz);
+typedef void (GL_APIENTRYP PFNGLORTHOXOESPROC) (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar);
+typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXOESPROC) (GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size);
+typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units);
+typedef void (GL_APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z);
+typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEXOESPROC) (GLclampx value, GLboolean invert);
+typedef void (GL_APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+typedef void (GL_APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z);
+#endif
+
+/* GL_OES_framebuffer_object */
+#ifndef GL_OES_framebuffer_object
+#define GL_OES_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLboolean GL_APIENTRY glIsRenderbufferOES (GLuint renderbuffer);
+GL_API void GL_APIENTRY glBindRenderbufferOES (GLenum target, GLuint renderbuffer);
+GL_API void GL_APIENTRY glDeleteRenderbuffersOES (GLsizei n, const GLuint* renderbuffers);
+GL_API void GL_APIENTRY glGenRenderbuffersOES (GLsizei n, GLuint* renderbuffers);
+GL_API void GL_APIENTRY glRenderbufferStorageOES (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GL_API void GL_APIENTRY glGetRenderbufferParameterivOES (GLenum target, GLenum pname, GLint* params);
+GL_API GLboolean GL_APIENTRY glIsFramebufferOES (GLuint framebuffer);
+GL_API void GL_APIENTRY glBindFramebufferOES (GLenum target, GLuint framebuffer);
+GL_API void GL_APIENTRY glDeleteFramebuffersOES (GLsizei n, const GLuint* framebuffers);
+GL_API void GL_APIENTRY glGenFramebuffersOES (GLsizei n, GLuint* framebuffers);
+GL_API GLenum GL_APIENTRY glCheckFramebufferStatusOES (GLenum target);
+GL_API void GL_APIENTRY glFramebufferRenderbufferOES (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GL_API void GL_APIENTRY glFramebufferTexture2DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GL_API void GL_APIENTRY glGetFramebufferAttachmentParameterivOES (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+GL_API void GL_APIENTRY glGenerateMipmapOES (GLenum target);
+#endif
+typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFEROESPROC) (GLuint renderbuffer);
+typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFEROESPROC) (GLenum target, GLuint renderbuffer);
+typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSOESPROC) (GLsizei n, const GLuint* renderbuffers);
+typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSOESPROC) (GLsizei n, GLuint* renderbuffers);
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVOESPROC) (GLenum target, GLenum pname, GLint* params);
+typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFEROESPROC) (GLuint framebuffer);
+typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFEROESPROC) (GLenum target, GLuint framebuffer);
+typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSOESPROC) (GLsizei n, const GLuint* framebuffers);
+typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSOESPROC) (GLsizei n, GLuint* framebuffers);
+typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSOESPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEROESPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOESPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params);
+typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPOESPROC) (GLenum target);
+#endif
+
+/* GL_OES_mapbuffer */
+#ifndef GL_OES_mapbuffer
+#define GL_OES_mapbuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
+GL_API GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
+GL_API void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void** params);
+#endif
+typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
+typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void** params);
+#endif
+
+/* GL_OES_matrix_get */
+#ifndef GL_OES_matrix_get
+#define GL_OES_matrix_get 1
+#endif
+
+/* GL_OES_matrix_palette */
+#ifndef GL_OES_matrix_palette
+#define GL_OES_matrix_palette 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glCurrentPaletteMatrixOES (GLuint matrixpaletteindex);
+GL_API void GL_APIENTRY glLoadPaletteFromModelViewMatrixOES (void);
+GL_API void GL_APIENTRY glMatrixIndexPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+GL_API void GL_APIENTRY glWeightPointerOES (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+typedef void (GL_APIENTRYP PFNGLCURRENTPALETTEMATRIXOESPROC) (GLuint matrixpaletteindex);
+typedef void (GL_APIENTRYP PFNGLLOADPALETTEFROMMODELVIEWMATRIXOESPROC) (void);
+typedef void (GL_APIENTRYP PFNGLMATRIXINDEXPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+/* GL_OES_packed_depth_stencil */
+#ifndef GL_OES_packed_depth_stencil
+#define GL_OES_packed_depth_stencil 1
+#endif
+
+/* GL_OES_query_matrix */
+#ifndef GL_OES_query_matrix
+#define GL_OES_query_matrix 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES (GLfixed mantissa[16], GLint exponent[16]);
+#endif
+typedef GLbitfield (GL_APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed mantissa[16], GLint exponent[16]);
+#endif
+
+/* GL_OES_rgb8_rgba8 */
+#ifndef GL_OES_rgb8_rgba8
+#define GL_OES_rgb8_rgba8 1
+#endif
+
+/* GL_OES_single_precision */
+#ifndef GL_OES_single_precision
+#define GL_OES_single_precision 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar);
+GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);
+GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]);
+GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth);
+#endif
+typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar);
+typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+typedef void (GL_APIENTRYP PFNGLORTHOFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
+typedef void (GL_APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation);
+typedef void (GL_APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum pname, GLfloat eqn[4]);
+typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth);
+#endif
+
+/* GL_OES_stencil1 */
+#ifndef GL_OES_stencil1
+#define GL_OES_stencil1 1
+#endif
+
+/* GL_OES_stencil4 */
+#ifndef GL_OES_stencil4
+#define GL_OES_stencil4 1
+#endif
+
+/* GL_OES_stencil8 */
+#ifndef GL_OES_stencil8
+#define GL_OES_stencil8 1
+#endif
+
+/* GL_OES_stencil_wrap */
+#ifndef GL_OES_stencil_wrap
+#define GL_OES_stencil_wrap 1
+#endif
+
+/* GL_OES_texture_cube_map */
+#ifndef GL_OES_texture_cube_map
+#define GL_OES_texture_cube_map 1
+#ifdef GL_GLEXT_PROTOTYPES
+GL_API void GL_APIENTRY glTexGenfOES (GLenum coord, GLenum pname, GLfloat param);
+GL_API void GL_APIENTRY glTexGenfvOES (GLenum coord, GLenum pname, const GLfloat *params);
+GL_API void GL_APIENTRY glTexGeniOES (GLenum coord, GLenum pname, GLint param);
+GL_API void GL_APIENTRY glTexGenivOES (GLenum coord, GLenum pname, const GLint *params);
+GL_API void GL_APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param);
+GL_API void GL_APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params);
+GL_API void GL_APIENTRY glGetTexGenfvOES (GLenum coord, GLenum pname, GLfloat *params);
+GL_API void GL_APIENTRY glGetTexGenivOES (GLenum coord, GLenum pname, GLint *params);
+GL_API void GL_APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params);
+#endif
+typedef void (GL_APIENTRYP PFNGLTEXGENFOESPROC) (GLenum coord, GLenum pname, GLfloat param);
+typedef void (GL_APIENTRYP PFNGLTEXGENFVOESPROC) (GLenum coord, GLenum pname, const GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLTEXGENIOESPROC) (GLenum coord, GLenum pname, GLint param);
+typedef void (GL_APIENTRYP PFNGLTEXGENIVOESPROC) (GLenum coord, GLenum pname, const GLint *params);
+typedef void (GL_APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param);
+typedef void (GL_APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXGENFVOESPROC) (GLenum coord, GLenum pname, GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXGENIVOESPROC) (GLenum coord, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params);
+#endif
+
+/* GL_OES_texture_env_crossbar */
+#ifndef GL_OES_texture_env_crossbar
+#define GL_OES_texture_env_crossbar 1
+#endif
+
+/* GL_OES_texture_mirrored_repeat */
+#ifndef GL_OES_texture_mirrored_repeat
+#define GL_OES_texture_mirrored_repeat 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * AMD extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_AMD_compressed_3DC_texture */
+#ifndef GL_AMD_compressed_3DC_texture
+#define GL_AMD_compressed_3DC_texture 1
+#endif
+
+/* GL_AMD_compressed_ATC_texture */
+#ifndef GL_AMD_compressed_ATC_texture
+#define GL_AMD_compressed_ATC_texture 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * EXT extension functions
+ *------------------------------------------------------------------------*/
+
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#endif
+
+/*------------------------------------------------------------------------*
+ * dalvik extension functions
+ *------------------------------------------------------------------------*/
+#ifdef ANDROID
+void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count);
+void glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count);
+void glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+void glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __glext_h_ */
+
diff --git a/opengl/include/GLES/glplatform.h b/opengl/include/GLES/glplatform.h
new file mode 100644
index 0000000..0924cae
--- /dev/null
+++ b/opengl/include/GLES/glplatform.h
@@ -0,0 +1,39 @@
+#ifndef __glplatform_h_
+#define __glplatform_h_
+
+/* $Revision: 7172 $ on $Date:: 2009-01-09 11:17:41 -0800 #$ */
+
+/*
+ * This document is licensed under the SGI Free Software B License Version
+ * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
+ */
+
+/* Platform-specific types and definitions for OpenGL ES 1.X  gl.h
+ * Last modified on 2008/12/19
+ *
+ * Adopters may modify khrplatform.h and this file to suit their platform.
+ * You are encouraged to submit all modifications to the Khronos group so that
+ * they can be included in future versions of this file.  Please submit changes
+ * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
+ * by filing a bug against product "OpenGL-ES" component "Registry".
+ */
+
+#include <KHR/khrplatform.h>
+
+#ifndef GL_API
+#define GL_API      KHRONOS_APICALL
+#endif
+
+#if defined(ANDROID)
+
+#define GL_APIENTRY KHRONOS_APIENTRY
+
+// XXX: this should probably not be here
+#define GL_DIRECT_TEXTURE_2D_QUALCOMM               0x7E80
+
+// XXX: not sure how this is intended to be used
+#define GL_GLEXT_PROTOTYPES
+
+#endif
+
+#endif /* __glplatform_h_ */
diff --git a/opengl/include/KHR/khrplatform.h b/opengl/include/KHR/khrplatform.h
new file mode 100644
index 0000000..4cc27c5
--- /dev/null
+++ b/opengl/include/KHR/khrplatform.h
@@ -0,0 +1,241 @@
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Platform-specific types and definitions.
+ * $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $
+ * 
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by sending them to the public Khronos Bugzilla
+ * (http://khronos.org/bugzilla) by filing a bug against product
+ * "Khronos (general)" component "Registry".
+ *
+ * A predefined template which fills in some of the bug fields can be
+ * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
+ * must create a Bugzilla login first.
+ * 
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system.
+ *    http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * 
+ * This file should be included as
+ *        #include <KHR/khrplatform.h>
+ * by the Khronos API header file that uses its types and defines.
+ *
+ * The types in this file should only be used to define API-specific types.
+ * Types defined in this file:
+ *    khronos_int8_t              signed   8  bit
+ *    khronos_uint8_t             unsigned 8  bit
+ *    khronos_int16_t             signed   16 bit
+ *    khronos_uint16_t            unsigned 16 bit
+ *    khronos_int32_t             signed   32 bit
+ *    khronos_uint32_t            unsigned 32 bit
+ *    khronos_int64_t             signed   64 bit
+ *    khronos_uint64_t            unsigned 64 bit
+ *    khronos_intptr_t            signed   same number of bits as a pointer
+ *    khronos_uintptr_t           unsigned same number of bits as a pointer
+ *    khronos_ssize_t             signed   size
+ *    khronos_usize_t             unsigned size
+ *    khronos_float_t             signed   32 bit floating point
+ *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
+ *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ *                                         nanoseconds
+ *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ *
+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ * 
+ *
+ * Macros defined in this file:
+ *    KHRONOS_APICALL
+ *    KHRONOS_APIENTRY
+ *    KHRONOS_APIATTRIBUTES
+ * These may be used in function prototypes as:
+ *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
+ *                                  int arg1,
+ *                                  int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
+#   define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+#   define KHRONOS_APICALL IMPORT_C
+#else
+#   define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIENTRY
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function  and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
+    /* Win32 but not WinCE */
+#   define KHRONOS_APIENTRY __stdcall
+#else
+#   define KHRONOS_APIENTRY
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using <stdint.h>
+ */
+#include <stdint.h>
+typedef int32_t                 khronos_int32_t;
+typedef uint32_t                khronos_uint32_t;
+typedef int64_t                 khronos_int64_t;
+typedef uint64_t                khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using <inttypes.h>
+ */
+#include <inttypes.h>
+typedef int32_t                 khronos_int32_t;
+typedef uint32_t                khronos_uint32_t;
+typedef int64_t                 khronos_int64_t;
+typedef uint64_t                khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32                 khronos_int32_t;
+typedef unsigned __int32        khronos_uint32_t;
+typedef __int64                 khronos_int64_t;
+typedef unsigned __int64        khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int                     khronos_int32_t;
+typedef unsigned int            khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int                khronos_int64_t;
+typedef unsigned long int       khronos_uint64_t;
+#else
+typedef long long int           khronos_int64_t;
+typedef unsigned long long int  khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int                     khronos_int32_t;
+typedef unsigned int            khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64   0
+#define KHRONOS_SUPPORT_FLOAT   0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include <stdint.h>
+typedef int32_t                 khronos_int32_t;
+typedef uint32_t                khronos_uint32_t;
+typedef int64_t                 khronos_int64_t;
+typedef uint64_t                khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64   1
+#define KHRONOS_SUPPORT_FLOAT   1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed   char          khronos_int8_t;
+typedef unsigned char          khronos_uint8_t;
+typedef signed   short int     khronos_int16_t;
+typedef unsigned short int     khronos_uint16_t;
+typedef signed   long  int     khronos_intptr_t;
+typedef unsigned long  int     khronos_uintptr_t;
+typedef signed   long  int     khronos_ssize_t;
+typedef unsigned long  int     khronos_usize_t;
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef          float         khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or 
+ * an absolute Unadjusted System Time.  Unadjusted System Time is the number 
+ * of nanoseconds since some arbitrary system event (e.g. since the last 
+ * time the system booted).  The Unadjusted System Time is an unsigned 
+ * 64 bit value that wraps back to 0 every 584 years.  Time intervals 
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t       khronos_utime_nanoseconds_t;
+typedef khronos_int64_t        khronos_stime_nanoseconds_t;
+#endif
+
+
+#endif /* __khrplatform_h_ */
diff --git a/opengl/libGLES_CM/Android.mk b/opengl/libGLES_CM/Android.mk
deleted file mode 100644
index e350e02..0000000
--- a/opengl/libGLES_CM/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-# Build the wrapper OpenGL ES library
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= gl_wrapper.cpp.arm gl_logger.cpp
-
-LOCAL_SHARED_LIBRARIES += libcutils libutils libui
-LOCAL_LDLIBS := -lpthread -ldl
-LOCAL_MODULE:= libGLES_CM
-
-# needed on sim build because of weird logging issues
-ifeq ($(TARGET_SIMULATOR),true)
-else
-    LOCAL_SHARED_LIBRARIES += libdl
-    # we need to access the Bionic private header <bionic_tls.h>
-    LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 3e8dca9..1446fb2 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -33,7 +33,10 @@
 
 #include <utils/threads.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
 
 #include <pixelflinger/format.h>
 #include <pixelflinger/pixelflinger.h>
@@ -149,7 +152,6 @@
     virtual     EGLint      getRefreshRate() const;
     virtual     EGLint      getSwapBehavior() const;
     virtual     EGLBoolean  swapBuffers();
-    virtual     EGLBoolean  swapRectangle(EGLint l, EGLint t, EGLint w, EGLint h);
 protected:
     GGLSurface              depth;
 };
@@ -171,10 +173,6 @@
 EGLBoolean egl_surface_t::swapBuffers() {
     return EGL_FALSE;
 }
-EGLBoolean egl_surface_t::swapRectangle(
-        EGLint l, EGLint t, EGLint w, EGLint h) {
-    return EGL_FALSE;
-}
 EGLint egl_surface_t::getHorizontalResolution() const {
     return (0 * EGL_DISPLAY_SCALING) * (1.0f / 25.4f);
 }
@@ -201,7 +199,6 @@
 
     virtual     bool        isValid() const { return nativeWindow->magic == 0x600913; }    
     virtual     EGLBoolean  swapBuffers();
-    virtual     EGLBoolean  swapRectangle(EGLint l, EGLint t, EGLint w, EGLint h);
     virtual     EGLBoolean  bindDrawSurface(ogles_context_t* gl);
     virtual     EGLBoolean  bindReadSurface(ogles_context_t* gl);
     virtual     EGLint      getWidth() const    { return nativeWindow->width;  }
@@ -243,7 +240,6 @@
     if (flags & EGL_NATIVES_FLAG_SIZE_CHANGED) {
         // TODO: we probably should reset the swap rect here
         // if the window size has changed
-        //    window->setSwapRectangle(Rect(info.w, info.h));
         if (depth.data) {
             free(depth.data);
             depth.width   = nativeWindow->width;
@@ -259,12 +255,6 @@
     return EGL_TRUE;
 }
 
-EGLBoolean egl_window_surface_t::swapRectangle(
-        EGLint l, EGLint t, EGLint w, EGLint h)
-{
-    nativeWindow->setSwapRectangle(nativeWindow, l, t, w, h);
-    return EGL_TRUE;
-}
 EGLBoolean egl_window_surface_t::bindDrawSurface(ogles_context_t* gl)
 {
     GGLSurface buffer;
@@ -476,21 +466,16 @@
 static char const * const gVendorString     = "Google Inc.";
 static char const * const gVersionString    = "1.2 Android Driver";
 static char const * const gClientApiString  = "OpenGL ES";
-static char const * const gExtensionsString =
-    "EGL_ANDROID_swap_rectangle"                " "
-    "EGL_ANDROID_copy_front_to_back"            " "
-    "EGL_ANDROID_get_render_buffer_address"
-    ;
+static char const * const gExtensionsString = "";
 
 // ----------------------------------------------------------------------------
 
 struct extention_map_t {
     const char * const name;
-    void (*address)(void);
+    __eglMustCastToProperFunctionPointerType address;
 };
 
 static const extention_map_t gExtentionMap[] = {
-    { "eglSwapRectangleANDROID",    (void(*)())&eglSwapRectangleANDROID },
     { "glDrawTexsOES",              (void(*)())&glDrawTexsOES },
     { "glDrawTexiOES",              (void(*)())&glDrawTexiOES },
     { "glDrawTexfOES",              (void(*)())&glDrawTexfOES },
@@ -1554,15 +1539,3 @@
     }
     return NULL;
 }
-
-EGLBoolean eglSwapRectangleANDROID(
-        EGLDisplay dpy, EGLSurface draw,
-        EGLint l, EGLint t, EGLint w, EGLint h)
-{    
-    if (egl_display_t::is_valid(dpy) == EGL_FALSE)
-        return setError(EGL_BAD_DISPLAY, EGL_FALSE);
-    egl_surface_t* surface = (egl_surface_t*)draw;
-    if (surface->dpy != dpy)
-        return setError(EGL_BAD_DISPLAY, EGL_FALSE);
-    return surface->swapRectangle(l, t, w, h);
-}
diff --git a/opengl/libagl/state.cpp b/opengl/libagl/state.cpp
index c2f9f12..5cbabea 100644
--- a/opengl/libagl/state.cpp
+++ b/opengl/libagl/state.cpp
@@ -403,12 +403,6 @@
     case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
         params[0] = GL_UNSIGNED_SHORT_5_6_5;
         break;
-    case GL_MAX_ELEMENTS_INDICES:
-        params[0] = 65536;
-        break;
-    case GL_MAX_ELEMENTS_VERTICES:
-        params[0] = 0x7FFFFFFF;
-        break;
     case GL_MAX_LIGHTS:
         params[0] = OGLES_MAX_LIGHTS;
         break;
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index 6b2640a..b6f534b 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -526,7 +526,7 @@
 static void texParameterx(
         GLenum target, GLenum pname, GLfixed param, ogles_context_t* c)
 {
-    if (target != GGL_TEXTURE_2D) {
+    if (target != GL_TEXTURE_2D) {
         ogles_error(c, GL_INVALID_ENUM);
         return;
     }
@@ -534,8 +534,7 @@
     EGLTextureObject* textureObject = c->textures.tmu[c->textures.active].texture;    
     switch (pname) {
     case GL_TEXTURE_WRAP_S:
-        if ((param == GL_CLAMP) ||
-            (param == GL_REPEAT) ||
+        if ((param == GL_REPEAT) ||
             (param == GL_CLAMP_TO_EDGE)) {
             textureObject->wraps = param;
         } else {
@@ -543,9 +542,8 @@
         }
         break;
     case GL_TEXTURE_WRAP_T:
-        if ((param == GGL_CLAMP) ||
-            (param == GGL_REPEAT) ||
-            (param == GGL_CLAMP_TO_EDGE)) {
+        if ((param == GL_REPEAT) ||
+            (param == GL_CLAMP_TO_EDGE)) {
             textureObject->wrapt = param;
         } else {
             goto invalid_enum;
@@ -1006,7 +1004,7 @@
 
 
 void glTexImage2D(
-        GLenum target, GLint level, GLenum internalformat,
+        GLenum target, GLint level, GLint internalformat,
         GLsizei width, GLsizei height, GLint border,
         GLenum format, GLenum type, const GLvoid *pixels)
 {
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
new file mode 100644
index 0000000..2ecc7768
--- /dev/null
+++ b/opengl/libs/Android.mk
@@ -0,0 +1,53 @@
+LOCAL_PATH:= $(call my-dir)
+
+#
+# Build META EGL library
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= 	\
+	EGL/egl.cpp 		\
+	EGL/gpu.cpp			\
+#
+
+LOCAL_SHARED_LIBRARIES += libcutils libutils libui
+LOCAL_LDLIBS := -lpthread -ldl
+LOCAL_MODULE:= libEGL
+
+# needed on sim build because of weird logging issues
+ifeq ($(TARGET_SIMULATOR),true)
+else
+    LOCAL_SHARED_LIBRARIES += libdl
+    # we need to access the Bionic private header <bionic_tls.h>
+    LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
+endif
+
+include $(BUILD_SHARED_LIBRARY)
+
+
+
+#
+# Build the wrapper OpenGL ES library
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= 	\
+	GLES_CM/gl.cpp.arm 		\
+	GLES_CM/gl_logger.cpp 	\
+#
+
+LOCAL_SHARED_LIBRARIES += libcutils libutils libui libEGL
+LOCAL_LDLIBS := -lpthread -ldl
+LOCAL_MODULE:= libGLESv1_CM
+
+# needed on sim build because of weird logging issues
+ifeq ($(TARGET_SIMULATOR),true)
+else
+    LOCAL_SHARED_LIBRARIES += libdl
+    # we need to access the Bionic private header <bionic_tls.h>
+    LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../bionic/libc/private
+endif
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/opengl/libGLES_CM/gl_wrapper.cpp b/opengl/libs/EGL/egl.cpp
similarity index 71%
rename from opengl/libGLES_CM/gl_wrapper.cpp
rename to opengl/libs/EGL/egl.cpp
index 3197535..3f33b67 100644
--- a/opengl/libGLES_CM/gl_wrapper.cpp
+++ b/opengl/libs/EGL/egl.cpp
@@ -27,31 +27,22 @@
 #include <linux/android_pmem.h>
 #endif
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
 
 #include <cutils/log.h>
 #include <cutils/atomic.h>
 #include <cutils/properties.h>
 #include <cutils/memory.h>
 
-#include <utils/IMemory.h>
-#include <utils/KeyedVector.h>
-#include <utils/threads.h>
-#include <utils/IServiceManager.h>
-#include <utils/IPCThreadState.h>
-#include <utils/Parcel.h>
+#include <utils/RefBase.h>
 
-#include <ui/EGLDisplaySurface.h>
-#include <ui/ISurfaceComposer.h>
+#include "hooks.h"
+#include "egl_impl.h"
 
-#include "gl_logger.h"
 
-#undef NELEM
-
-#define GL_LOGGER                   0
-#define USE_SLOW_BINDING            0
-#define NELEM(x)                    (sizeof(x)/sizeof(*(x)))
-#define MAX_NUMBER_OF_GL_EXTENSIONS 32
 #define MAKE_CONFIG(_impl, _index)  ((EGLConfig)(((_impl)<<24) | (_index)))
 #define setError(_e, _r) setErrorEtc(__FUNCTION__, __LINE__, _e, _r)
 
@@ -59,26 +50,12 @@
 namespace android {
 // ----------------------------------------------------------------------------
 
-//  EGLDisplay are global, not attached to a given thread
-static const unsigned int NUM_DISPLAYS = 1;
-static const unsigned int IMPL_HARDWARE                 = 0;
-static const unsigned int IMPL_SOFTWARE                 = 1;
-static const unsigned int IMPL_HARDWARE_CONTEXT_LOST    = 2;
-static const unsigned int IMPL_SOFTWARE_CONTEXT_LOST    = 3;
-static const unsigned int IMPL_NO_CONTEXT               = 4;
-
-// ----------------------------------------------------------------------------
-
-struct gl_hooks_t;
-
-struct egl_connection_t
-{
-    void volatile *     dso;
-    gl_hooks_t *        hooks;
-    EGLint              major;
-    EGLint              minor;
-    int                 unavailable;
-};
+#define VERSION_MINOR 1
+#define VERSION_MAJOR 4
+static char const * const gVendorString     = "Android";
+static char const * const gVersionString    = "1.31 Android META-EGL";
+static char const * const gClientApiString  = "OpenGL ES";
+static char const * const gExtensionString  = "";
 
 template <int MAGIC>
 struct egl_object_t
@@ -103,7 +80,6 @@
         char const * version;
         char const * clientApi;
         char const * extensions;
-        char const * extensions_config;
     };
     strings_t   queryString[2];
 };
@@ -152,82 +128,45 @@
     EGLContext  ctx;
 };
 
-
-// GL / EGL hooks
-
-typedef void(*proc_t)();
-
-struct gl_hooks_t {
-    struct gl_t {
-        #define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
-        #include "gl_entries.cpp"
-        #undef GL_ENTRY
-    } gl;
-    struct egl_t {
-        #define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
-        #include "egl_entries.cpp"
-        #undef EGL_ENTRY
-    } egl;
-    struct gl_ext_t {
-        void (*extensions[MAX_NUMBER_OF_GL_EXTENSIONS])(void);
-    } ext;
-};
-
-static char const * const gl_names[] = {
-    #define GL_ENTRY(_r, _api, ...) #_api,
-    #include "gl_entries.cpp"
-    #undef GL_ENTRY
-    NULL
-};
-
-static char const * const egl_names[] = {
-    #define EGL_ENTRY(_r, _api, ...) #_api,
-    #include "egl_entries.cpp"
-    #undef EGL_ENTRY
-    NULL
-};
-
 static void gl_unimplemented() {
     LOGE("called unimplemented OpenGL ES API");
 }
 
 // ----------------------------------------------------------------------------
+// GL / EGL hooks
+// ----------------------------------------------------------------------------
 
-static egl_connection_t gEGLImpl[2];
+#undef GL_ENTRY
+#undef EGL_ENTRY
+#define GL_ENTRY(_r, _api, ...) #_api,
+#define EGL_ENTRY(_r, _api, ...) #_api,
+
+static char const * const gl_names[] = {
+    #include "gl_entries.in"
+    NULL
+};
+
+static char const * const egl_names[] = {
+    #include "egl_entries.in"
+    NULL
+};
+
+#undef GL_ENTRY
+#undef EGL_ENTRY
+
+// ----------------------------------------------------------------------------
+
+egl_connection_t gEGLImpl[2];
 static egl_display_t gDisplay[NUM_DISPLAYS];
-static gl_hooks_t gHooks[5];
 static pthread_mutex_t gThreadLocalStorageKeyMutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_key_t gEGLThreadLocalStorageKey = -1;
 
 // ----------------------------------------------------------------------------
 
-#if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && !GL_LOGGER
+gl_hooks_t gHooks[IMPL_NUM_IMPLEMENTATIONS];
+pthread_key_t gGLWrapperKey = -1;
 
-/* special private C library header */
-#include <bionic_tls.h>
-// We have a dedicated TLS slot in bionic
-static inline void setGlThreadSpecific(gl_hooks_t const *value) {
-    ((uint32_t *)__get_tls())[TLS_SLOT_OPENGL_API] = (uint32_t)value;
-}
-static gl_hooks_t const* getGlThreadSpecific() {
-    gl_hooks_t const* hooks = (gl_hooks_t const *)(((unsigned const *)__get_tls())[TLS_SLOT_OPENGL_API]);
-    if (hooks) return hooks;
-    return &gHooks[IMPL_NO_CONTEXT];
-}
-
-#else
-
-static pthread_key_t gGLWrapperKey = -1;
-static inline void setGlThreadSpecific(gl_hooks_t const *value) {
-    pthread_setspecific(gGLWrapperKey, value);
-}
-static gl_hooks_t const* getGlThreadSpecific() {
-    gl_hooks_t const* hooks =  static_cast<gl_hooks_t*>(pthread_getspecific(gGLWrapperKey));
-    if (hooks) return hooks;
-    return &gHooks[IMPL_NO_CONTEXT];
-}
-
-#endif
+// ----------------------------------------------------------------------------
 
 static __attribute__((noinline))
 const char *egl_strerror(EGLint err)
@@ -322,170 +261,14 @@
     return tls->ctx;
 }
 
-/*****************************************************************************/
-
-/*
- * we provide our own allocators for the GPU regions, these
- * allocators go through surfaceflinger 
- */
-
-static Mutex                            gRegionsLock;
-static request_gpu_t                    gRegions;
-static sp<ISurfaceComposer>             gSurfaceManager;
-ISurfaceComposer*                       GLES_localSurfaceManager = 0;
-
-const sp<ISurfaceComposer>& getSurfaceFlinger()
-{
-    Mutex::Autolock _l(gRegionsLock);
-
-    /*
-     * There is a little bit of voodoo magic here. We want to access
-     * surfaceflinger for allocating GPU regions, however, when we are
-     * running as part of surfaceflinger, we want to bypass the
-     * service manager because surfaceflinger might not be registered yet.
-     * SurfaceFlinger will populate "GLES_localSurfaceManager" with its
-     * own address, so we can just use that.
-     */
-    if (gSurfaceManager == 0) {
-        if (GLES_localSurfaceManager) {
-            // we're running in SurfaceFlinger's context
-            gSurfaceManager =  GLES_localSurfaceManager;
-        } else {
-            // we're a remote process or not part of surfaceflinger,
-            // go through the service manager
-            sp<IServiceManager> sm = defaultServiceManager();
-            if (sm != NULL) {
-                sp<IBinder> binder = sm->getService(String16("SurfaceFlinger"));
-                gSurfaceManager = interface_cast<ISurfaceComposer>(binder);
-            }
-        }
-    }
-    return gSurfaceManager;
-}
-
-class GPURevokeRequester : public BnGPUCallback
-{
-public:
-    virtual void gpuLost() {
-        LOGD("CONTEXT_LOST: Releasing GPU upon request from SurfaceFlinger.");
-        gEGLImpl[IMPL_HARDWARE].hooks = &gHooks[IMPL_HARDWARE_CONTEXT_LOST];
-    }
-};
-
-static sp<GPURevokeRequester> gRevokerCallback;
-
-
-static request_gpu_t* gpu_acquire(void* user)
-{
-    sp<ISurfaceComposer> server( getSurfaceFlinger() );
-
-    Mutex::Autolock _l(gRegionsLock);
-    if (server == NULL) {
-        return 0;
-    }
-    
-    ISurfaceComposer::gpu_info_t info;
-    
-    if (gRevokerCallback == 0)
-        gRevokerCallback = new GPURevokeRequester();
-
-    status_t err = server->requestGPU(gRevokerCallback, &info);
-    if (err != NO_ERROR) {
-        LOGD("requestGPU returned %d", err);
-        return 0;
-    }
-
-    bool failed = false;
-    request_gpu_t* gpu = &gRegions;
-    memset(gpu, 0, sizeof(*gpu));
-    
-    if (info.regs != 0) {
-        sp<IMemoryHeap> heap(info.regs->getMemory());
-        if (heap != 0) {
-            int fd = heap->heapID();
-            gpu->regs.fd = fd;
-            gpu->regs.base = info.regs->pointer(); 
-            gpu->regs.size = info.regs->size(); 
-            gpu->regs.user = info.regs.get();
-#if HAVE_ANDROID_OS
-            struct pmem_region region;
-            if (ioctl(fd, PMEM_GET_PHYS, &region) >= 0)
-                gpu->regs.phys = (void*)region.offset;
-#endif
-            info.regs->incStrong(gpu);
-        } else {
-            LOGE("GPU register handle %p is invalid!", info.regs.get());
-            failed = true;
-        }
-    }
-
-    for (size_t i=0 ; i<info.count && !failed ; i++) {
-        sp<IMemory>& region(info.regions[i].region);
-        if (region != 0) {
-            sp<IMemoryHeap> heap(region->getMemory());
-            if (heap != 0) {
-                const int fd = heap->heapID();
-                gpu->gpu[i].fd = fd;
-                gpu->gpu[i].base = region->pointer(); 
-                gpu->gpu[i].size = region->size(); 
-                gpu->gpu[i].user = region.get();
-                gpu->gpu[i].offset = info.regions[i].reserved;
-#if HAVE_ANDROID_OS
-                struct pmem_region reg;
-                if (ioctl(fd, PMEM_GET_PHYS, &reg) >= 0)
-                    gpu->gpu[i].phys = (void*)reg.offset;
-#endif
-                region->incStrong(gpu);
-            } else {
-                LOGE("GPU region handle [%d, %p] is invalid!", i, region.get());
-                failed = true;
-            }
-        }
-    }
-    
-    if (failed) {
-        // something went wrong, clean up everything!
-        if (gpu->regs.user) {
-            static_cast<IMemory*>(gpu->regs.user)->decStrong(gpu);
-            for (size_t i=0 ; i<info.count ; i++) {
-                if (gpu->gpu[i].user) {
-                    static_cast<IMemory*>(gpu->gpu[i].user)->decStrong(gpu);
-                }
-            }
-        }
-    }
-    
-    gpu->count = info.count;
-    return gpu;
-}
-
-static int gpu_release(void*, request_gpu_t* gpu)
-{
-    sp<IMemory> regs;
-
-    { // scope for lock
-        Mutex::Autolock _l(gRegionsLock);
-        regs = static_cast<IMemory*>(gpu->regs.user);   
-        gpu->regs.user = 0;
-        if (regs != 0) regs->decStrong(gpu);
-        
-        for (int i=0 ; i<gpu->count ; i++) {
-            sp<IMemory> r(static_cast<IMemory*>(gpu->gpu[i].user));
-            gpu->gpu[i].user = 0;
-            if (r != 0) r->decStrong(gpu);
-        }
-    }
-    
-    // there is a special transaction to relinquish the GPU
-    // (it will happen automatically anyway if we don't do this)
-    Parcel data, reply;
-    // NOTE: this transaction does not require an interface token
-    regs->asBinder()->transact(1000, data, &reply);
-    return 1;
-}
 
 /*****************************************************************************/
 
+class ISurfaceComposer;
+const sp<ISurfaceComposer>& getSurfaceFlinger();
+request_gpu_t* gpu_acquire(void* user);
+int gpu_release(void*, request_gpu_t* gpu);
+
 static __attribute__((noinline))
 void *load_driver(const char* driver, gl_hooks_t* hooks)
 {
@@ -576,18 +359,12 @@
     return c0<c1 ? -1 : (c0>c1 ? 1 : 0);
 }
 
-static char const * const gVendorString     = "Android";
-static char const * const gVersionString    = "1.3 Android META-EGL";
-static char const * const gClientApiString  = "OpenGL ES";
-
 struct extention_map_t {
     const char* name;
-    void (*address)(void);
+    __eglMustCastToProperFunctionPointerType address;
 };
 
 static const extention_map_t gExtentionMap[] = {
-    { "eglSwapRectangleANDROID",         (void(*)())&eglSwapRectangleANDROID },
-    { "eglQueryStringConfigANDROID",     (void(*)())&eglQueryStringConfigANDROID },
 };
 
 static extention_map_t gGLExtentionMap[MAX_NUMBER_OF_GL_EXTENSIONS];
@@ -604,109 +381,18 @@
 }
 
 // ----------------------------------------------------------------------------
-}; // namespace android
-// ----------------------------------------------------------------------------
-
-using namespace android;
-
-
-// ----------------------------------------------------------------------------
-// extensions for the framework
-// ----------------------------------------------------------------------------
-
-void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
-        const GLvoid *ptr, GLsizei count) {
-    glColorPointer(size, type, stride, ptr);
-}
-void glNormalPointerBounds(GLenum type, GLsizei stride,
-        const GLvoid *pointer, GLsizei count) {
-    glNormalPointer(type, stride, pointer);
-}
-void glTexCoordPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count) {
-    glTexCoordPointer(size, type, stride, pointer);
-}
-void glVertexPointerBounds(GLint size, GLenum type,
-        GLsizei stride, const GLvoid *pointer, GLsizei count) {
-    glVertexPointer(size, type, stride, pointer);
-}
-
-
-// ----------------------------------------------------------------------------
-// Actual GL wrappers
-// ----------------------------------------------------------------------------
-
-#if __OPTIMIZE__ && defined(__arm__) && !defined(__thumb__) && !USE_SLOW_BINDING && !GL_LOGGER
-
-    #define API_ENTRY(_api) __attribute__((naked)) _api
-    #define CALL_GL_API(_api, ...)                              \
-         asm volatile(                                          \
-            "mov   r12, #0xFFFF0FFF   \n"                       \
-            "ldr   r12, [r12, #-15]   \n"                       \
-            "ldr   r12, [r12, %[tls]] \n"                       \
-            "cmp   r12, #0            \n"                       \
-            "ldrne pc,  [r12, %[api]] \n"                       \
-            "bx    lr                 \n"                       \
-            :                                                   \
-            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
-              [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \
-            :                                                   \
-            );
-    
-    #define CALL_GL_API_RETURN(_api, ...) \
-        CALL_GL_API(_api, __VA_ARGS__) \
-        return 0; // placate gcc's warnings. never reached.
-
-#else
-
-    #define API_ENTRY(_api) _api
-    #if GL_LOGGER
-
-        #define CALL_GL_API(_api, ...)          \
-            gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
-            log_##_api(__VA_ARGS__); \
-            _c->_api(__VA_ARGS__);
-        
-        #define CALL_GL_API_RETURN(_api, ...)   \
-            gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
-            log_##_api(__VA_ARGS__); \
-            return _c->_api(__VA_ARGS__)
-
-    #else
-
-        #define CALL_GL_API(_api, ...)          \
-            gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
-            _c->_api(__VA_ARGS__);
-        
-        #define CALL_GL_API_RETURN(_api, ...)   \
-            gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
-            return _c->_api(__VA_ARGS__)
-
-    #endif
-
-#endif
-
-#include "gl_api.cpp"
-
-#undef API_ENTRY
-#undef CALL_GL_API
-#undef CALL_GL_API_RETURN
-
-// ----------------------------------------------------------------------------
-namespace android {
-// ----------------------------------------------------------------------------
 
 static int gl_context_lost() {
-    setGlThreadSpecific(&gHooks[IMPL_HARDWARE_CONTEXT_LOST]);
+    setGlThreadSpecific(&gHooks[IMPL_CONTEXT_LOST]);
     return 0;
 }
 static int egl_context_lost() {
-    setGlThreadSpecific(&gHooks[IMPL_HARDWARE_CONTEXT_LOST]);
+    setGlThreadSpecific(&gHooks[IMPL_CONTEXT_LOST]);
     return EGL_FALSE;
 }
 static EGLBoolean egl_context_lost_swap_buffers(void*, void*) {
     usleep(100000); // don't use all the CPU
-    setGlThreadSpecific(&gHooks[IMPL_HARDWARE_CONTEXT_LOST]);
+    setGlThreadSpecific(&gHooks[IMPL_CONTEXT_LOST]);
     return EGL_FALSE;
 }
 static GLint egl_context_lost_get_error() {
@@ -721,11 +407,14 @@
 }
 static void early_egl_init(void) 
 {
-#if !defined(HAVE_ANDROID_OS) || USE_SLOW_BINDING || GL_LOGGER
+#if !USE_FAST_TLS_KEY
     pthread_key_create(&gGLWrapperKey, NULL);
 #endif
     uint32_t addr = (uint32_t)((void*)gl_no_context);
-    android_memset32((uint32_t*)(void*)&gHooks[IMPL_NO_CONTEXT], addr, sizeof(gHooks[IMPL_NO_CONTEXT]));
+    android_memset32(
+            (uint32_t*)(void*)&gHooks[IMPL_NO_CONTEXT], 
+            addr, 
+            sizeof(gHooks[IMPL_NO_CONTEXT]));
     setGlThreadSpecific(&gHooks[IMPL_NO_CONTEXT]);
 }
 
@@ -802,25 +491,12 @@
     return EGL_TRUE;
 }
 
-static void add_extension(egl_display_t* dp, char const*& p, const char* ext)
-{
-    if (!strstr(p, ext)) {
-        p = (char const*)realloc((void*)p, strlen(p) + 1 + strlen(ext) + 1);
-        strcat((char*)p, " ");
-        strcat((char*)p, ext);
-    }
-    if (!strstr(dp->extensionsString, ext)) {
-        char const*& es = dp->extensionsString;
-        es = (char const*)realloc((void*)es, strlen(es) + 1 + strlen(ext) + 1);
-        strcat((char*)es, " ");
-        strcat((char*)es, ext);
-    }    
-}
-
 // ----------------------------------------------------------------------------
 }; // namespace android
 // ----------------------------------------------------------------------------
 
+using namespace android;
+
 EGLDisplay eglGetDisplay(NativeDisplayType display)
 {
     if (sEarlyInitState) {
@@ -867,25 +543,25 @@
     }
     if (cnx->dso && d->dpys[IMPL_HARDWARE]==EGL_NO_DISPLAY) {
         android_memset32(
-                (uint32_t*)(void*)&gHooks[IMPL_HARDWARE_CONTEXT_LOST].gl,
+                (uint32_t*)(void*)&gHooks[IMPL_CONTEXT_LOST].gl,
                 (uint32_t)((void*)gl_context_lost),
-                sizeof(gHooks[IMPL_HARDWARE_CONTEXT_LOST].gl));
+                sizeof(gHooks[IMPL_CONTEXT_LOST].gl));
         android_memset32(
-                (uint32_t*)(void*)&gHooks[IMPL_HARDWARE_CONTEXT_LOST].egl,
+                (uint32_t*)(void*)&gHooks[IMPL_CONTEXT_LOST].egl,
                 (uint32_t)((void*)egl_context_lost),
-                sizeof(gHooks[IMPL_HARDWARE_CONTEXT_LOST].egl));
+                sizeof(gHooks[IMPL_CONTEXT_LOST].egl));
         android_memset32(
-                (uint32_t*)(void*)&gHooks[IMPL_HARDWARE_CONTEXT_LOST].ext,
+                (uint32_t*)(void*)&gHooks[IMPL_CONTEXT_LOST].ext,
                 (uint32_t)((void*)ext_context_lost),
-                sizeof(gHooks[IMPL_HARDWARE_CONTEXT_LOST].ext));
+                sizeof(gHooks[IMPL_CONTEXT_LOST].ext));
 
-        gHooks[IMPL_HARDWARE_CONTEXT_LOST].egl.eglSwapBuffers =
+        gHooks[IMPL_CONTEXT_LOST].egl.eglSwapBuffers =
                 egl_context_lost_swap_buffers;
         
-        gHooks[IMPL_HARDWARE_CONTEXT_LOST].egl.eglGetError =
+        gHooks[IMPL_CONTEXT_LOST].egl.eglGetError =
                 egl_context_lost_get_error;
 
-        gHooks[IMPL_HARDWARE_CONTEXT_LOST].egl.eglTerminate =
+        gHooks[IMPL_CONTEXT_LOST].egl.eglTerminate =
                 gHooks[IMPL_HARDWARE].egl.eglTerminate;
         
         d->dpys[IMPL_HARDWARE] = cnx->hooks->egl.eglGetDisplay(display);
@@ -913,8 +589,8 @@
     if (!dp) return setError(EGL_BAD_DISPLAY, EGL_FALSE);
 
     if (android_atomic_inc(&dp->refs) > 0) {
-        if (major != NULL) *major = 1;
-        if (minor != NULL) *minor = 2;
+        if (major != NULL) *major = VERSION_MAJOR;
+        if (minor != NULL) *minor = VERSION_MINOR;
         return EGL_TRUE;
     }
     
@@ -923,7 +599,7 @@
     // initialize each EGL and
     // build our own extension string first, based on the extension we know
     // and the extension supported by our client implementation
-    dp->extensionsString = strdup("EGL_ANDROID_query_string_config");
+    dp->extensionsString = strdup(gExtensionString);
     for (int i=0 ; i<2 ; i++) {
         egl_connection_t* const cnx = &gEGLImpl[i];
         cnx->major = -1;
@@ -947,54 +623,16 @@
             dp->queryString[i].clientApi =
                 cnx->hooks->egl.eglQueryString(dp->dpys[i], EGL_CLIENT_APIS);
 
-            // Dynamically insert extensions we know about
-            if (cnx->hooks->egl.eglSwapRectangleANDROID)
-                add_extension(dp, dp->queryString[i].extensions,
-                        "EGL_ANDROID_swap_rectangle");
-
-            if (cnx->hooks->egl.eglQueryStringConfigANDROID)
-                add_extension(dp, dp->queryString[i].extensions,
-                        "EGL_ANDROID_query_string_config");
         } else {
             LOGD("%d: eglInitialize() failed (%s)", 
                     i, egl_strerror(cnx->hooks->egl.eglGetError()));
         }
     }
 
-    // Build the extension list that depends on the current config.
-    // It is the intersection of our extension list and the
-    // underlying EGL's extensions list
     EGLBoolean res = EGL_FALSE;
     for (int i=0 ; i<2 ; i++) {
         egl_connection_t* const cnx = &gEGLImpl[i];
         if (cnx->dso && cnx->major>=0 && cnx->minor>=0) {
-            char const* const their_extensions = dp->queryString[i].extensions;            
-            char* our_extensions = strdup(dp->extensionsString);
-            char* const our_extensions_org = our_extensions;
-            char* extensions_config = (char*)calloc(strlen(our_extensions)+2, 1);
-            char* p;
-            do {
-                p = strchr(our_extensions, ' ');
-                if (p)  *p++ = 0;
-                else    p = strchr(our_extensions, 0);
-                if (strstr(their_extensions, our_extensions)) {
-                    strcat(extensions_config, our_extensions);
-                    strcat(extensions_config, " ");
-                }
-                our_extensions = p;
-            } while (*p);
-            free((void*)our_extensions_org);
-
-            // remove the trailing white space
-            if (extensions_config[0] != 0) {
-                size_t l = strlen(extensions_config) - 1; // new size
-                extensions_config[l] = 0; // remove the trailing white space
-                extensions_config = (char*)realloc(extensions_config, l+1);
-            } else {
-                extensions_config = (char*)realloc(extensions_config, 1);
-            }
-            dp->queryString[i].extensions_config = extensions_config;
-
             EGLint n;
             if (cnx->hooks->egl.eglGetConfigs(dp->dpys[i], 0, 0, &n)) {
                 dp->configs[i] = (EGLConfig*)malloc(sizeof(EGLConfig)*n);
@@ -1042,7 +680,6 @@
              * threads around). */
             
             free(dp->configs[i]);
-            free((void*)dp->queryString[i].extensions_config);
             free((void*)dp->queryString[i].extensions);
             dp->numConfigs[i] = 0;
             dp->dpys[i] = EGL_NO_DISPLAY;
@@ -1486,7 +1123,7 @@
 
 void (*eglGetProcAddress(const char *procname))()
 {
-    void (*addr)();
+    __eglMustCastToProperFunctionPointerType addr;
     addr = findProcAddress(procname, gExtentionMap, NELEM(gExtentionMap));
     if (addr) return addr;
 
@@ -1570,7 +1207,7 @@
         case EGL_VERSION:
             return gVersionString;
         case EGL_EXTENSIONS:
-            return dp->extensionsString;
+            return gExtensionString;
         case EGL_CLIENT_APIS:
             return gClientApiString;
     }
@@ -1730,34 +1367,3 @@
     }
     return setError(EGL_BAD_CONFIG, EGL_NO_SURFACE);
 }
-
-// ----------------------------------------------------------------------------
-// Android extentions
-// ----------------------------------------------------------------------------
-
-EGLBoolean eglSwapRectangleANDROID(
-        EGLDisplay dpy, EGLSurface draw,
-        EGLint l, EGLint t, EGLint w, EGLint h)
-{    
-    if (!validate_display_surface(dpy, draw))
-        return EGL_FALSE;    
-    egl_display_t const * const dp = get_display(dpy);
-    egl_surface_t const * const s = get_surface(draw);
-    if (s->cnx->hooks->egl.eglSwapRectangleANDROID) {
-        return s->cnx->hooks->egl.eglSwapRectangleANDROID(
-                dp->dpys[s->impl], s->surface, l, t, w, h);
-    }
-    return setError(EGL_BAD_SURFACE, EGL_FALSE);
-}
-
-const char* eglQueryStringConfigANDROID(
-        EGLDisplay dpy, EGLConfig config, EGLint name)
-{
-    egl_display_t const* dp = 0;
-    int i=0, index=0;
-    egl_connection_t* cnx = validate_display_config(dpy, config, dp, i, index);
-    if (cnx) {
-        return dp->queryString[i].extensions_config;
-    }
-    return setError(EGL_BAD_PARAMETER, (const char *)0);
-}
diff --git a/opengl/libs/EGL/gpu.cpp b/opengl/libs/EGL/gpu.cpp
new file mode 100644
index 0000000..3f9fd63
--- /dev/null
+++ b/opengl/libs/EGL/gpu.cpp
@@ -0,0 +1,212 @@
+/* 
+ ** Copyright 2007, The Android Open Source Project
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License"); 
+ ** you may not use this file except in compliance with the License. 
+ ** You may obtain a copy of the License at 
+ **
+ **     http://www.apache.org/licenses/LICENSE-2.0 
+ **
+ ** Unless required by applicable law or agreed to in writing, software 
+ ** distributed under the License is distributed on an "AS IS" BASIS, 
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ ** See the License for the specific language governing permissions and 
+ ** limitations under the License.
+ */
+
+#define LOG_TAG "EGL"
+
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+
+#if HAVE_ANDROID_OS
+#include <linux/android_pmem.h>
+#endif
+
+#include <cutils/log.h>
+#include <cutils/properties.h>
+
+#include <utils/IMemory.h>
+#include <utils/threads.h>
+#include <utils/IServiceManager.h>
+#include <utils/IPCThreadState.h>
+#include <utils/Parcel.h>
+
+#include <ui/EGLDisplaySurface.h>
+#include <ui/ISurfaceComposer.h>
+
+#include "hooks.h"
+#include "egl_impl.h"
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+/*
+ * we provide our own allocators for the GPU regions, these
+ * allocators go through surfaceflinger 
+ */
+
+static Mutex                            gRegionsLock;
+static request_gpu_t                    gRegions;
+static sp<ISurfaceComposer>             gSurfaceManager;
+ISurfaceComposer*                       GLES_localSurfaceManager = 0;
+
+extern egl_connection_t gEGLImpl[2];
+
+const sp<ISurfaceComposer>& getSurfaceFlinger()
+{
+    Mutex::Autolock _l(gRegionsLock);
+
+    /*
+     * There is a little bit of voodoo magic here. We want to access
+     * surfaceflinger for allocating GPU regions, however, when we are
+     * running as part of surfaceflinger, we want to bypass the
+     * service manager because surfaceflinger might not be registered yet.
+     * SurfaceFlinger will populate "GLES_localSurfaceManager" with its
+     * own address, so we can just use that.
+     */
+    if (gSurfaceManager == 0) {
+        if (GLES_localSurfaceManager) {
+            // we're running in SurfaceFlinger's context
+            gSurfaceManager =  GLES_localSurfaceManager;
+        } else {
+            // we're a remote process or not part of surfaceflinger,
+            // go through the service manager
+            sp<IServiceManager> sm = defaultServiceManager();
+            if (sm != NULL) {
+                sp<IBinder> binder = sm->getService(String16("SurfaceFlinger"));
+                gSurfaceManager = interface_cast<ISurfaceComposer>(binder);
+            }
+        }
+    }
+    return gSurfaceManager;
+}
+
+class GPURevokeRequester : public BnGPUCallback
+{
+public:
+    virtual void gpuLost() {
+        LOGD("CONTEXT_LOST: Releasing GPU upon request from SurfaceFlinger.");
+        gEGLImpl[IMPL_HARDWARE].hooks = &gHooks[IMPL_CONTEXT_LOST];
+    }
+};
+
+static sp<GPURevokeRequester> gRevokerCallback;
+
+
+request_gpu_t* gpu_acquire(void* user)
+{
+    sp<ISurfaceComposer> server( getSurfaceFlinger() );
+
+    Mutex::Autolock _l(gRegionsLock);
+    if (server == NULL) {
+        return 0;
+    }
+    
+    ISurfaceComposer::gpu_info_t info;
+    
+    if (gRevokerCallback == 0)
+        gRevokerCallback = new GPURevokeRequester();
+
+    status_t err = server->requestGPU(gRevokerCallback, &info);
+    if (err != NO_ERROR) {
+        LOGD("requestGPU returned %d", err);
+        return 0;
+    }
+
+    bool failed = false;
+    request_gpu_t* gpu = &gRegions;
+    memset(gpu, 0, sizeof(*gpu));
+    
+    if (info.regs != 0) {
+        sp<IMemoryHeap> heap(info.regs->getMemory());
+        if (heap != 0) {
+            int fd = heap->heapID();
+            gpu->regs.fd = fd;
+            gpu->regs.base = info.regs->pointer(); 
+            gpu->regs.size = info.regs->size(); 
+            gpu->regs.user = info.regs.get();
+#if HAVE_ANDROID_OS
+            struct pmem_region region;
+            if (ioctl(fd, PMEM_GET_PHYS, &region) >= 0)
+                gpu->regs.phys = (void*)region.offset;
+#endif
+            info.regs->incStrong(gpu);
+        } else {
+            LOGE("GPU register handle %p is invalid!", info.regs.get());
+            failed = true;
+        }
+    }
+
+    for (size_t i=0 ; i<info.count && !failed ; i++) {
+        sp<IMemory>& region(info.regions[i].region);
+        if (region != 0) {
+            sp<IMemoryHeap> heap(region->getMemory());
+            if (heap != 0) {
+                const int fd = heap->heapID();
+                gpu->gpu[i].fd = fd;
+                gpu->gpu[i].base = region->pointer(); 
+                gpu->gpu[i].size = region->size(); 
+                gpu->gpu[i].user = region.get();
+                gpu->gpu[i].offset = info.regions[i].reserved;
+#if HAVE_ANDROID_OS
+                struct pmem_region reg;
+                if (ioctl(fd, PMEM_GET_PHYS, &reg) >= 0)
+                    gpu->gpu[i].phys = (void*)reg.offset;
+#endif
+                region->incStrong(gpu);
+            } else {
+                LOGE("GPU region handle [%d, %p] is invalid!", i, region.get());
+                failed = true;
+            }
+        }
+    }
+    
+    if (failed) {
+        // something went wrong, clean up everything!
+        if (gpu->regs.user) {
+            static_cast<IMemory*>(gpu->regs.user)->decStrong(gpu);
+            for (size_t i=0 ; i<info.count ; i++) {
+                if (gpu->gpu[i].user) {
+                    static_cast<IMemory*>(gpu->gpu[i].user)->decStrong(gpu);
+                }
+            }
+        }
+    }
+    
+    gpu->count = info.count;
+    return gpu;
+}
+
+int gpu_release(void*, request_gpu_t* gpu)
+{
+    sp<IMemory> regs;
+
+    { // scope for lock
+        Mutex::Autolock _l(gRegionsLock);
+        regs = static_cast<IMemory*>(gpu->regs.user);   
+        gpu->regs.user = 0;
+        if (regs != 0) regs->decStrong(gpu);
+        
+        for (int i=0 ; i<gpu->count ; i++) {
+            sp<IMemory> r(static_cast<IMemory*>(gpu->gpu[i].user));
+            gpu->gpu[i].user = 0;
+            if (r != 0) r->decStrong(gpu);
+        }
+    }
+    
+    // there is a special transaction to relinquish the GPU
+    // (it will happen automatically anyway if we don't do this)
+    Parcel data, reply;
+    // NOTE: this transaction does not require an interface token
+    regs->asBinder()->transact(1000, data, &reply);
+    return 1;
+}
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+// ----------------------------------------------------------------------------
diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp
new file mode 100644
index 0000000..865cf44
--- /dev/null
+++ b/opengl/libs/GLES_CM/gl.cpp
@@ -0,0 +1,116 @@
+/* 
+ ** Copyright 2007, The Android Open Source Project
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License"); 
+ ** you may not use this file except in compliance with the License. 
+ ** You may obtain a copy of the License at 
+ **
+ **     http://www.apache.org/licenses/LICENSE-2.0 
+ **
+ ** Unless required by applicable law or agreed to in writing, software 
+ ** distributed under the License is distributed on an "AS IS" BASIS, 
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ ** See the License for the specific language governing permissions and 
+ ** limitations under the License.
+ */
+
+#define LOG_TAG "GLES_CM"
+
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sys/ioctl.h>
+
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
+#include <cutils/log.h>
+#include <cutils/properties.h>
+
+#include "hooks.h"
+
+using namespace android;
+
+// ----------------------------------------------------------------------------
+// extensions for the framework
+// ----------------------------------------------------------------------------
+
+void glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
+        const GLvoid *ptr, GLsizei count) {
+    glColorPointer(size, type, stride, ptr);
+}
+void glNormalPointerBounds(GLenum type, GLsizei stride,
+        const GLvoid *pointer, GLsizei count) {
+    glNormalPointer(type, stride, pointer);
+}
+void glTexCoordPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    glTexCoordPointer(size, type, stride, pointer);
+}
+void glVertexPointerBounds(GLint size, GLenum type,
+        GLsizei stride, const GLvoid *pointer, GLsizei count) {
+    glVertexPointer(size, type, stride, pointer);
+}
+
+// ----------------------------------------------------------------------------
+// Actual GL entry-points
+// ----------------------------------------------------------------------------
+
+#if GL_LOGGER
+#   include "gl_logger.h"
+#   define GL_LOGGER_IMPL(_x) _x
+#else
+#   define GL_LOGGER_IMPL(_x)
+#endif
+
+#undef API_ENTRY
+#undef CALL_GL_API
+#undef CALL_GL_API_RETURN
+
+#if USE_FAST_TLS_KEY
+
+    #define API_ENTRY(_api) __attribute__((naked)) _api
+
+    #define CALL_GL_API(_api, ...)                              \
+         asm volatile(                                          \
+            "mov   r12, #0xFFFF0FFF   \n"                       \
+            "ldr   r12, [r12, #-15]   \n"                       \
+            "ldr   r12, [r12, %[tls]] \n"                       \
+            "cmp   r12, #0            \n"                       \
+            "ldrne pc,  [r12, %[api]] \n"                       \
+            "bx    lr                 \n"                       \
+            :                                                   \
+            : [tls] "J"(TLS_SLOT_OPENGL_API*4),                 \
+              [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api))    \
+            :                                                   \
+            );
+    
+    #define CALL_GL_API_RETURN(_api, ...) \
+        CALL_GL_API(_api, __VA_ARGS__) \
+        return 0; // placate gcc's warnings. never reached.
+
+#else
+
+    #define API_ENTRY(_api) _api
+
+    #define CALL_GL_API(_api, ...)                                      \
+        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
+        GL_LOGGER_IMPL( log_##_api(__VA_ARGS__); )                      \
+        _c->_api(__VA_ARGS__)
+    
+    #define CALL_GL_API_RETURN(_api, ...)                               \
+        gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
+        GL_LOGGER_IMPL( log_##_api(__VA_ARGS__); )                      \
+        return _c->_api(__VA_ARGS__)
+
+#endif
+
+extern "C" {
+#include "gl_api.in"
+}
+
+#undef API_ENTRY
+#undef CALL_GL_API
+#undef CALL_GL_API_RETURN
+
diff --git a/opengl/libGLES_CM/gl_api.cpp b/opengl/libs/GLES_CM/gl_api.in
similarity index 98%
rename from opengl/libGLES_CM/gl_api.cpp
rename to opengl/libs/GLES_CM/gl_api.in
index ed3bdaa..9234ef2 100644
--- a/opengl/libGLES_CM/gl_api.cpp
+++ b/opengl/libs/GLES_CM/gl_api.in
@@ -415,7 +415,7 @@
     CALL_GL_API(glTexEnvxv, target, pname, params);
 }
 
-void API_ENTRY(glTexImage2D)(  GLenum target, GLint level, GLenum internalformat,
+void API_ENTRY(glTexImage2D)(  GLenum target, GLint level, GLint internalformat,
                     GLsizei width, GLsizei height, GLint border, GLenum format,
                     GLenum type, const GLvoid *pixels) {
     CALL_GL_API(glTexImage2D, target, level, internalformat, width, height,
diff --git a/opengl/libGLES_CM/gl_logger.cpp b/opengl/libs/GLES_CM/gl_logger.cpp
similarity index 99%
rename from opengl/libGLES_CM/gl_logger.cpp
rename to opengl/libs/GLES_CM/gl_logger.cpp
index 14b5a39..27be5c9 100644
--- a/opengl/libGLES_CM/gl_logger.cpp
+++ b/opengl/libs/GLES_CM/gl_logger.cpp
@@ -23,7 +23,10 @@
 
 #include <sys/ioctl.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
 
 #include <cutils/log.h>
 #include <cutils/atomic.h>
@@ -33,13 +36,13 @@
 
 #include "gl_logger.h"
 
+#undef NELEM
+#define NELEM(x) (sizeof(x)/sizeof(*(x)))
+
 // ----------------------------------------------------------------------------
 namespace android {
 // ----------------------------------------------------------------------------
 
-#undef NELEM
-#define NELEM(x) (sizeof(x)/sizeof(*(x)))
-
 template<typename T>
 static int binarySearch(T const sortedArray[], int first, int last, EGLint key)
 {
@@ -226,12 +229,6 @@
     int mNumParams;
 };
 
-// ----------------------------------------------------------------------------
-}; // namespace android
-// ----------------------------------------------------------------------------
-
-using namespace android;
-
 #define API_ENTRY(api)                      log_##api
 #define CALL_GL_API(_x, ...)
 #define CALL_GL_API_RETURN(_x, ...)         return(0);
@@ -785,7 +782,7 @@
     GLLog("glTexEnvxv") << GLLogEnum(target) << GLLogEnum(pname) << GLLogBuffer<GLfixed>(params);
 }
 
-void API_ENTRY(glTexImage2D)(  GLenum target, GLint level, GLenum internalformat,
+void API_ENTRY(glTexImage2D)(  GLenum target, GLint level, GLint internalformat,
                     GLsizei width, GLsizei height, GLint border, GLenum format,
                     GLenum type, const GLvoid *pixels) {
     CALL_GL_API(glTexImage2D, target, level, internalformat, width, height,
@@ -1057,3 +1054,7 @@
     GLLog("glQueryMatrixxOES") << GLLogBuffer<GLfixed>(mantissa, 16) << GLLogBuffer<GLfixed>(exponent, 16);
     CALL_GL_API_RETURN(glQueryMatrixxOES, mantissa, exponent);
 }
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+// ----------------------------------------------------------------------------
diff --git a/opengl/libGLES_CM/egl_entries.cpp b/opengl/libs/egl_entries.in
similarity index 88%
rename from opengl/libGLES_CM/egl_entries.cpp
rename to opengl/libs/egl_entries.in
index ba46f40..33b4c65 100644
--- a/opengl/libGLES_CM/egl_entries.cpp
+++ b/opengl/libs/egl_entries.in
@@ -23,7 +23,7 @@
 EGL_ENTRY(EGLBoolean, eglCopyBuffers, EGLDisplay, EGLSurface, NativePixmapType)
 EGL_ENTRY(EGLint, eglGetError, void)
 EGL_ENTRY(const char*, eglQueryString, EGLDisplay, EGLint)
-EGL_ENTRY(proc_t, eglGetProcAddress, const char *)
+EGL_ENTRY(__eglMustCastToProperFunctionPointerType, eglGetProcAddress, const char *)
 
 /* EGL 1.1 */
 
@@ -40,7 +40,6 @@
 EGL_ENTRY(EGLBoolean, eglReleaseThread, void)
 EGL_ENTRY(EGLSurface, eglCreatePbufferFromClientBuffer, EGLDisplay, EGLenum, EGLClientBuffer, EGLConfig, const EGLint *)
 
-/* Android extentions */
+/* EGL 1.3 */
 
-EGL_ENTRY(EGLBoolean, eglSwapRectangleANDROID, EGLDisplay, EGLSurface , EGLint, EGLint, EGLint, EGLint)
-EGL_ENTRY(const char*, eglQueryStringConfigANDROID, EGLDisplay, EGLConfig, EGLint)
+/* EGL 1.4 */
diff --git a/opengl/libs/egl_impl.h b/opengl/libs/egl_impl.h
new file mode 100644
index 0000000..62ce3fc
--- /dev/null
+++ b/opengl/libs/egl_impl.h
@@ -0,0 +1,43 @@
+/* 
+ ** Copyright 2007, The Android Open Source Project
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License"); 
+ ** you may not use this file except in compliance with the License. 
+ ** You may obtain a copy of the License at 
+ **
+ **     http://www.apache.org/licenses/LICENSE-2.0 
+ **
+ ** Unless required by applicable law or agreed to in writing, software 
+ ** distributed under the License is distributed on an "AS IS" BASIS, 
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ ** See the License for the specific language governing permissions and 
+ ** limitations under the License.
+ */
+
+#ifndef ANDROID_EGL_IMPL_H
+#define ANDROID_EGL_IMPL_H
+
+#include <ctype.h>
+
+#include <EGL/egl.h>
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+struct gl_hooks_t;
+
+struct egl_connection_t
+{
+    void volatile *     dso;
+    gl_hooks_t *        hooks;
+    EGLint              major;
+    EGLint              minor;
+    int                 unavailable;
+};
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+// ----------------------------------------------------------------------------
+
+#endif /* ANDROID_EGL_IMPL_H */
diff --git a/opengl/libGLES_CM/gl_entries.cpp b/opengl/libs/gl_entries.in
similarity index 97%
rename from opengl/libGLES_CM/gl_entries.cpp
rename to opengl/libs/gl_entries.in
index 3279322..b97e8fe 100644
--- a/opengl/libGLES_CM/gl_entries.cpp
+++ b/opengl/libs/gl_entries.in
@@ -101,7 +101,7 @@
 GL_ENTRY(void, glCompressedTexSubImage2D, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*)
 GL_ENTRY(void, glCopyTexImage2D, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint)
 GL_ENTRY(void, glCopyTexSubImage2D, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei)
-GL_ENTRY(void, glTexImage2D, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*)
+GL_ENTRY(void, glTexImage2D, GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*)
 GL_ENTRY(void, glTexSubImage2D, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*)
 GL_ENTRY(void, glReadPixels, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *)
 
diff --git a/opengl/libGLES_CM/gl_enums.in b/opengl/libs/gl_enums.in
similarity index 100%
rename from opengl/libGLES_CM/gl_enums.in
rename to opengl/libs/gl_enums.in
diff --git a/opengl/libGLES_CM/gl_logger.h b/opengl/libs/gl_logger.h
similarity index 91%
rename from opengl/libGLES_CM/gl_logger.h
rename to opengl/libs/gl_logger.h
index 59e31c7..ce85dd1 100644
--- a/opengl/libGLES_CM/gl_logger.h
+++ b/opengl/libs/gl_logger.h
@@ -17,10 +17,10 @@
 #ifndef ANDROID_GL_LOGGER_H
 #define ANDROID_GL_LOGGER_H
 
-extern "C" {
+namespace android {
 #define GL_ENTRY(r, api, ...) r log_##api(__VA_ARGS__);
-#include "gl_entries.cpp"
+#include "gl_entries.in"
 #undef GL_ENTRY
-};
+}; // namespace android
 
 #endif /* ANDROID_GL_LOGGER_H */
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h
new file mode 100644
index 0000000..63fb017
--- /dev/null
+++ b/opengl/libs/hooks.h
@@ -0,0 +1,134 @@
+/* 
+ ** Copyright 2007, The Android Open Source Project
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License"); 
+ ** you may not use this file except in compliance with the License. 
+ ** You may obtain a copy of the License at 
+ **
+ **     http://www.apache.org/licenses/LICENSE-2.0 
+ **
+ ** Unless required by applicable law or agreed to in writing, software 
+ ** distributed under the License is distributed on an "AS IS" BASIS, 
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ ** See the License for the specific language governing permissions and 
+ ** limitations under the License.
+ */
+
+#ifndef ANDROID_GLES_CM_HOOKS_H
+#define ANDROID_GLES_CM_HOOKS_H
+
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
+#define GL_LOGGER                   0
+#if !defined(__arm__)
+#define USE_SLOW_BINDING            1
+#else
+#define USE_SLOW_BINDING            0
+#endif
+#undef NELEM
+#define NELEM(x)                    (sizeof(x)/sizeof(*(x)))
+#define MAX_NUMBER_OF_GL_EXTENSIONS 32
+
+
+#if defined(HAVE_ANDROID_OS) && !USE_SLOW_BINDING && !GL_LOGGER && __OPTIMIZE__
+#define USE_FAST_TLS_KEY            1
+#else
+#define USE_FAST_TLS_KEY            0
+#endif
+
+#if USE_FAST_TLS_KEY
+#   include <bionic_tls.h>  /* special private C library header */
+#endif
+
+// ----------------------------------------------------------------------------
+namespace android {
+// ----------------------------------------------------------------------------
+
+//  EGLDisplay are global, not attached to a given thread
+const unsigned int NUM_DISPLAYS = 1;
+
+enum {
+    IMPL_HARDWARE = 0,
+    IMPL_SOFTWARE,
+    IMPL_CONTEXT_LOST,
+    IMPL_NO_CONTEXT,
+    
+    IMPL_NUM_IMPLEMENTATIONS
+};
+
+// ----------------------------------------------------------------------------
+
+// GL / EGL hooks
+
+#undef GL_ENTRY
+#undef EGL_ENTRY
+#define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
+#define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
+
+struct gl_hooks_t {
+    struct gl_t {
+        #include "gl_entries.in"
+    } gl;
+    struct egl_t {
+        #include "egl_entries.in"
+    } egl;
+    struct gl_ext_t {
+        void (*extensions[MAX_NUMBER_OF_GL_EXTENSIONS])(void);
+    } ext;
+};
+#undef GL_ENTRY
+#undef EGL_ENTRY
+
+
+// ----------------------------------------------------------------------------
+
+extern gl_hooks_t gHooks[IMPL_NUM_IMPLEMENTATIONS];
+extern pthread_key_t gGLWrapperKey;
+
+#if USE_FAST_TLS_KEY
+
+// We have a dedicated TLS slot in bionic
+static inline gl_hooks_t const * volatile * get_tls_hooks() {
+    volatile void *tls_base = __get_tls();
+    gl_hooks_t const * volatile * tls_hooks = 
+            reinterpret_cast<gl_hooks_t const * volatile *>(tls_base);
+    return tls_hooks;
+}
+
+static inline void setGlThreadSpecific(gl_hooks_t const *value) {
+    gl_hooks_t const * volatile * tls_hooks = get_tls_hooks();
+    tls_hooks[TLS_SLOT_OPENGL_API] = value;
+}
+
+static gl_hooks_t const* getGlThreadSpecific() {
+    gl_hooks_t const * volatile * tls_hooks = get_tls_hooks();
+    gl_hooks_t const* hooks = tls_hooks[TLS_SLOT_OPENGL_API];
+    if (hooks) return hooks;
+    return &gHooks[IMPL_NO_CONTEXT];
+}
+
+#else
+
+static inline void setGlThreadSpecific(gl_hooks_t const *value) {
+    pthread_setspecific(gGLWrapperKey, value);
+}
+
+static gl_hooks_t const* getGlThreadSpecific() {
+    gl_hooks_t const* hooks =  static_cast<gl_hooks_t*>(pthread_getspecific(gGLWrapperKey));
+    if (hooks) return hooks;
+    return &gHooks[IMPL_NO_CONTEXT];
+}
+
+#endif
+
+
+// ----------------------------------------------------------------------------
+}; // namespace android
+// ----------------------------------------------------------------------------
+
+#endif /* ANDROID_GLES_CM_HOOKS_H */
diff --git a/opengl/libGLES_CM/enumextract.sh b/opengl/libs/tools/enumextract.sh
similarity index 100%
rename from opengl/libGLES_CM/enumextract.sh
rename to opengl/libs/tools/enumextract.sh
diff --git a/opengl/tests/angeles/Android.mk b/opengl/tests/angeles/Android.mk
index 41673cb..46958d3 100644
--- a/opengl/tests/angeles/Android.mk
+++ b/opengl/tests/angeles/Android.mk
@@ -3,7 +3,7 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES:= app-linux.c demo.c.arm
-LOCAL_SHARED_LIBRARIES := libGLES_CM libui
+LOCAL_SHARED_LIBRARIES := libEGL libGLESv1_CM libui
 LOCAL_MODULE:= angeles
 LOCAL_MODULE_TAGS := tests
 include $(BUILD_EXECUTABLE)
@@ -11,7 +11,7 @@
 
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES:= gpustate.c
-LOCAL_SHARED_LIBRARIES := libGLES_CM
+LOCAL_SHARED_LIBRARIES := libEGL libGLESv1_CM
 LOCAL_MODULE:= gpustate
 LOCAL_MODULE_TAGS := tests
 include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/angeles/app-linux.c b/opengl/tests/angeles/app-linux.c
index d439eb2..7d0d320 100644
--- a/opengl/tests/angeles/app-linux.c
+++ b/opengl/tests/angeles/app-linux.c
@@ -49,7 +49,8 @@
 #include <stdio.h>
 #include <sys/time.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
 
 #include "app.h"
 
diff --git a/opengl/tests/filter/Android.mk b/opengl/tests/filter/Android.mk
index 1c4253c..a448f0d 100644
--- a/opengl/tests/filter/Android.mk
+++ b/opengl/tests/filter/Android.mk
@@ -6,7 +6,8 @@
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
-    libGLES_CM \
+    libEGL \
+    libGLESv1_CM \
     libui
 
 LOCAL_MODULE:= test-opengl-filter
diff --git a/opengl/tests/filter/filter.c b/opengl/tests/filter/filter.c
index c8bac06..de97119 100644
--- a/opengl/tests/filter/filter.c
+++ b/opengl/tests/filter/filter.c
@@ -1,7 +1,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
 
 int main(int argc, char** argv)
 {
@@ -40,6 +42,9 @@
          printf("using pbuffer\n");
          EGLint attribs[] = { EGL_WIDTH, 320, EGL_HEIGHT, 480, EGL_NONE };
          surface = eglCreatePbufferSurface(dpy, config, attribs);
+         if (surface == EGL_NO_SURFACE) {
+             printf("eglCreatePbufferSurface error %x\n", eglGetError());
+         }
      }
      context = eglCreateContext(dpy, config, NULL, NULL);
      eglMakeCurrent(dpy, surface, surface, context);   
diff --git a/opengl/tests/finish/Android.mk b/opengl/tests/finish/Android.mk
index f7b95ed..26836c1 100644
--- a/opengl/tests/finish/Android.mk
+++ b/opengl/tests/finish/Android.mk
@@ -6,7 +6,8 @@
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
-    libGLES_CM \
+    libEGL \
+    libGLESv1_CM \
     libui
 
 LOCAL_MODULE:= test-opengl-finish
diff --git a/opengl/tests/finish/finish.c b/opengl/tests/finish/finish.c
index 3afe227..45fc758 100644
--- a/opengl/tests/finish/finish.c
+++ b/opengl/tests/finish/finish.c
@@ -20,7 +20,10 @@
 #include <sched.h>
 #include <sys/resource.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
+
 
 long long systemTime()
 {
diff --git a/opengl/tests/sfsim/Android.mk b/opengl/tests/sfsim/Android.mk
deleted file mode 100644
index 8a1a03c..0000000
--- a/opengl/tests/sfsim/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
-	egl_surface.cpp \
-	sfsim.c
-
-LOCAL_SHARED_LIBRARIES := \
-    libGLES_CM
-
-LOCAL_MODULE:= test-opengl-sfsim
-
-LOCAL_MODULE_TAGS := tests
-
-include $(BUILD_EXECUTABLE)
diff --git a/opengl/tests/sfsim/egl_surface.cpp b/opengl/tests/sfsim/egl_surface.cpp
deleted file mode 100644
index b0777f8..0000000
--- a/opengl/tests/sfsim/egl_surface.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/* 
- **
- ** Copyright 2008 The Android Open Source Project
- **
- ** Licensed under the Apache License Version 2.0(the "License"); 
- ** you may not use this file except in compliance with the License. 
- ** You may obtain a copy of the License at 
- **
- **     http://www.apache.org/licenses/LICENSE-2.0 
- **
- ** Unless required by applicable law or agreed to in writing software 
- ** distributed under the License is distributed on an "AS IS" BASIS 
- ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. 
- ** See the License for the specific language governing permissions and 
- ** limitations under the License.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-
-#include <GLES/egl.h>
-
-#include "egl_surface.h"
-
-#define LOGI(x...) do { printf("INFO: " x); } while (0)
-#define LOGW(x...) do { printf("WARN: " x); } while (0)
-#define LOGE(x...) do { printf("ERR: " x); } while (0)
-
-// ----------------------------------------------------------------------------
-
-egl_native_window_t* android_createDisplaySurface()
-{
-    egl_native_window_t* s = new android::EGLDisplaySurface();
-    s->memory_type = NATIVE_MEMORY_TYPE_GPU;
-    return s;
-}
-
-#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
-#define UNLIKELY( exp )     (__builtin_expect( (exp) != 0, false ))
-
-// ----------------------------------------------------------------------------
-namespace android {
-// ----------------------------------------------------------------------------
-
-EGLDisplaySurface::EGLDisplaySurface()
-    : EGLNativeSurface<EGLDisplaySurface>()
-{
-    egl_native_window_t::version = sizeof(egl_native_window_t);
-    egl_native_window_t::ident = 0;
-    egl_native_window_t::incRef = &EGLDisplaySurface::hook_incRef;
-    egl_native_window_t::decRef = &EGLDisplaySurface::hook_decRef;
-    egl_native_window_t::swapBuffers = &EGLDisplaySurface::hook_swapBuffers;
-    egl_native_window_t::setSwapRectangle = &EGLDisplaySurface::hook_setSwapRectangle;
-    egl_native_window_t::nextBuffer = &EGLDisplaySurface::hook_nextBuffer;
-    egl_native_window_t::connect = 0;
-    egl_native_window_t::disconnect = 0;
-
-    mFb[0].data = 0;
-    mFb[1].data = 0;
-    egl_native_window_t::fd = mapFrameBuffer();
-    if (egl_native_window_t::fd >= 0) {
-        const float in2mm = 25.4f;
-        float refreshRate = 1000000000000000LLU / (
-                float( mInfo.upper_margin + mInfo.lower_margin + mInfo.yres ) 
-                * ( mInfo.left_margin  + mInfo.right_margin + mInfo.xres )
-                * mInfo.pixclock);
-
-        const GGLSurface& buffer = mFb[1 - mIndex];
-        egl_native_window_t::width  = buffer.width;
-        egl_native_window_t::height = buffer.height;
-        egl_native_window_t::stride = buffer.stride;
-        egl_native_window_t::format = buffer.format;
-        egl_native_window_t::base   = intptr_t(mFb[0].data);
-        egl_native_window_t::offset =
-            intptr_t(buffer.data) - egl_native_window_t::base;
-        egl_native_window_t::flags  = 0;
-        egl_native_window_t::xdpi = (mInfo.xres * in2mm) / mInfo.width;
-        egl_native_window_t::ydpi = (mInfo.yres * in2mm) / mInfo.height;
-        egl_native_window_t::fps  = refreshRate;
-        egl_native_window_t::memory_type = NATIVE_MEMORY_TYPE_FB;
-        // no error, set the magic word
-        egl_native_window_t::magic = 0x600913;
-    }
-    mSwapCount = -1;
-    mPageFlipCount = 0;
-}
-
-EGLDisplaySurface::~EGLDisplaySurface()
-{
-    magic = 0;
-    close(egl_native_window_t::fd);
-    munmap(mFb[0].data, mSize);
-    if (!(mFlags & PAGE_FLIP))
-        free((void*)mFb[1].data);
-}
-
-void EGLDisplaySurface::hook_incRef(NativeWindowType window) {
-    EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
-    that->incStrong(that);
-}
-void EGLDisplaySurface::hook_decRef(NativeWindowType window) {
-    EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
-    that->decStrong(that);
-}
-uint32_t EGLDisplaySurface::hook_swapBuffers(NativeWindowType window) {
-    EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
-    return that->swapBuffers();
-}
-uint32_t EGLDisplaySurface::hook_nextBuffer(NativeWindowType window) {
-    EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
-    return that->nextBuffer();
-}
-void EGLDisplaySurface::hook_setSwapRectangle(NativeWindowType window,
-        int l, int t, int w, int h) {
-    EGLDisplaySurface* that = static_cast<EGLDisplaySurface*>(window);
-    that->setSwapRectangle(l, t, w, h);
-}
-
-void EGLDisplaySurface::setSwapRectangle(int l, int t, int w, int h)
-{
-    mInfo.reserved[0] = 0x54445055; // "UPDT";
-    mInfo.reserved[1] = (uint16_t)l | ((uint32_t)t << 16);
-    mInfo.reserved[2] = (uint16_t)(l+w) | ((uint32_t)(t+h) << 16);
-}
-
-uint32_t EGLDisplaySurface::swapBuffers()
-{
-    if (!(mFlags & PAGE_FLIP))
-        return 0;
-
-    // do the actual flip
-    mIndex = 1 - mIndex;
-    mInfo.activate = FB_ACTIVATE_VBL;
-    mInfo.yoffset = mIndex ? mInfo.yres : 0;
-    if (ioctl(egl_native_window_t::fd, FBIOPUT_VSCREENINFO, &mInfo) == -1) {
-        LOGE("FBIOPUT_VSCREENINFO failed");
-        return 0;
-    }
-
-    /*
-     * this is a monstruous hack: Because the h/w accelerator is not able
-     * to render directly into the framebuffer, we need to copy its
-     * internal framebuffer out to the fb. the base address of the internal fb
-     * is given in oem[0]. 
-     * All this is needed only in standalone mode, in SurfaceFlinger mode
-     * we control where the GPU renders.
-     */
-    if (egl_native_window_t::memory_type == NATIVE_MEMORY_TYPE_GPU && oem[0]) {
-        // could use MDP here, but that's tricky because we need
-        // /dev/pmem_gpu* filedescriptor
-        const GGLSurface& buffer = mFb[mIndex];
-        memcpy( buffer.data,
-                (void*)(oem[0] + egl_native_window_t::offset),
-                buffer.stride*buffer.height*2);
-    }
-
-    // update the address of the buffer to draw to next
-    const GGLSurface& buffer = mFb[1 - mIndex];
-    egl_native_window_t::offset =
-        intptr_t(buffer.data) - egl_native_window_t::base;
-
-    mPageFlipCount++;
-
-    // We don't support screen-size changes for now
-    return 0;
-}
-
-int32_t EGLDisplaySurface::getPageFlipCount() const
-{
-    return mPageFlipCount;
-}
-
-uint32_t EGLDisplaySurface::nextBuffer()
-{
-    // update the address of the buffer to draw to next
-    const GGLSurface& buffer = mFb[mIndex];
-    egl_native_window_t::offset =
-        intptr_t(buffer.data) - egl_native_window_t::base;
-    return 0;
-}
-
-int EGLDisplaySurface::mapFrameBuffer()
-{
-    char const * const device_template[] = {
-            "/dev/graphics/fb%u",
-            "/dev/fb%u",
-            0 };
-    int fd = -1;
-    int i=0;
-    char name[64];
-    while ((fd==-1) && device_template[i]) {
-        snprintf(name, 64, device_template[i], 0);
-        fd = open(name, O_RDWR, 0);
-        i++;
-    }
-    if (fd < 0)
-        return -errno;
-
-    struct fb_fix_screeninfo finfo;
-    if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1)
-        return -errno;
-
-    struct fb_var_screeninfo info;
-    if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1)
-        return -errno;
-
-    info.reserved[0] = 0;
-    info.reserved[1] = 0;
-    info.reserved[2] = 0;
-    info.xoffset = 0;
-    info.yoffset = 0;
-    info.yres_virtual = info.yres * 2;
-    info.bits_per_pixel = 16;
-    info.activate = FB_ACTIVATE_NOW;
-
-    uint32_t flags = PAGE_FLIP;
-    if (ioctl(fd, FBIOPUT_VSCREENINFO, &info) == -1) {
-        info.yres_virtual = info.yres;
-        flags &= ~PAGE_FLIP;
-        LOGW("FBIOPUT_VSCREENINFO failed, page flipping not supported");
-    }
-
-    if (info.yres_virtual < info.yres * 2) {
-        info.yres_virtual = info.yres;
-        flags &= ~PAGE_FLIP;
-        LOGW("page flipping not supported (yres_virtual=%d, requested=%d)",
-                info.yres_virtual, info.yres*2);
-    }
-
-    if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1)
-        return -errno;    
-
-    int refreshRate = 1000000000000000LLU / 
-    (
-            uint64_t( info.upper_margin + info.lower_margin + info.yres ) 
-            * ( info.left_margin  + info.right_margin + info.xres )
-            * info.pixclock
-    );
-
-    if (refreshRate == 0) {
-        // bleagh, bad info from the driver
-        refreshRate = 60*1000;  // 60 Hz
-    }
-
-    if (int(info.width) <= 0 || int(info.height) <= 0) {
-        // stupid driver, doesn't return that information
-        // default to Sooner's screen size (160 dpi)
-        info.width  = 51;
-        info.height = 38;
-    }
-
-    float xdpi = (info.xres * 25.4f) / info.width; 
-    float ydpi = (info.yres * 25.4f) / info.height;
-    float fps  = refreshRate / 1000.0f; 
-
-    LOGI(   "using (fd=%d)\n"
-            "id           = %s\n"
-            "xres         = %d px\n"
-            "yres         = %d px\n"
-            "xres_virtual = %d px\n"
-            "yres_virtual = %d px\n"
-            "bpp          = %d\n"
-            "r            = %2u:%u\n"
-            "g            = %2u:%u\n"
-            "b            = %2u:%u\n",
-            fd,
-            finfo.id,
-            info.xres,
-            info.yres,
-            info.xres_virtual,
-            info.yres_virtual,
-            info.bits_per_pixel,
-            info.red.offset, info.red.length,
-            info.green.offset, info.green.length,
-            info.blue.offset, info.blue.length
-    );
-
-    LOGI(   "width        = %d mm (%f dpi)\n"
-            "height       = %d mm (%f dpi)\n"
-            "refresh rate = %.2f Hz\n",
-            info.width,  xdpi,
-            info.height, ydpi,
-            fps
-    );
-
-    
-    if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1)
-        return -errno;
-
-    if (finfo.smem_len <= 0)
-        return -errno;
-
-    /*
-     * Open and map the display.
-     */
-
-    void* buffer  = (uint16_t*) mmap(
-            0, finfo.smem_len,
-            PROT_READ | PROT_WRITE,
-            MAP_SHARED,
-            fd, 0);
-
-    if (buffer == MAP_FAILED)
-        return -errno;
-
-    // at least for now, always clear the fb
-    memset(buffer, 0, finfo.smem_len);
-
-    uint8_t* offscreen[2];
-    offscreen[0] = (uint8_t*)buffer;
-    if (flags & PAGE_FLIP) {
-        offscreen[1] = (uint8_t*)buffer + finfo.line_length*info.yres;
-    } else {
-        offscreen[1] = (uint8_t*)malloc(finfo.smem_len);
-        if (offscreen[1] == 0) {
-            munmap(buffer, finfo.smem_len);
-            return -ENOMEM;
-        }
-    }
-
-    mFlags = flags;
-    mInfo = info;
-    mFinfo = finfo;
-    mSize = finfo.smem_len;
-    mIndex = 0;
-    for (int i=0 ; i<2 ; i++) {
-        mFb[i].version = sizeof(GGLSurface);
-        mFb[i].width   = info.xres;
-        mFb[i].height  = info.yres;
-        mFb[i].stride  = finfo.line_length / (info.bits_per_pixel >> 3);
-        mFb[i].data    = (uint8_t*)(offscreen[i]);
-        mFb[i].format  = NATIVE_PIXEL_FORMAT_RGB_565;
-    }
-    return fd;
-}
-
-// ----------------------------------------------------------------------------
-}; // namespace android
-// ----------------------------------------------------------------------------
diff --git a/opengl/tests/sfsim/egl_surface.h b/opengl/tests/sfsim/egl_surface.h
deleted file mode 100644
index 70a94fc..0000000
--- a/opengl/tests/sfsim/egl_surface.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_SIM_EGL_SURFACE_H
-#define ANDROID_SIM_EGL_SURFACE_H
-
-#include <stdint.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#include <GLES/eglnatives.h>
-
-#include <linux/fb.h>
-
-typedef struct {
-    ssize_t    version;    // always set to sizeof(GGLSurface)
-    uint32_t   width;      // width in pixels
-    uint32_t   height;     // height in pixels
-    int32_t    stride;     // stride in pixels
-    uint8_t*   data;       // pointer to the bits
-    uint8_t    format;     // pixel format
-    uint8_t    rfu[3];     // must be zero
-    void*      reserved;
-} GGLSurface;
-
-// ---------------------------------------------------------------------------
-namespace android {
-// ---------------------------------------------------------------------------
-
-template <class TYPE>
-class EGLNativeSurface : public egl_native_window_t
-{
-public:
-    EGLNativeSurface() : mCount(0) { 
-        memset(egl_native_window_t::reserved, 0, 
-                sizeof(egl_native_window_t::reserved));
-        memset(egl_native_window_t::reserved_proc, 0, 
-                sizeof(egl_native_window_t::reserved_proc));
-        memset(egl_native_window_t::oem, 0, 
-                sizeof(egl_native_window_t::oem));
-    }
-    inline void incStrong(void*) const {
-        /* in a real implementation, the inc must be atomic */
-        mCount++;
-    }
-    inline void decStrong(void*) const {
-        /* in a real implementation, the dec must be atomic */
-        if (--mCount == 1) {
-             delete static_cast<const TYPE*>(this);
-         }
-    }
-protected:
-    EGLNativeSurface& operator = (const EGLNativeSurface& rhs);
-    EGLNativeSurface(const EGLNativeSurface& rhs);
-    inline ~EGLNativeSurface() { };
-    mutable volatile int32_t mCount;
-};
-
-
-class EGLDisplaySurface : public EGLNativeSurface<EGLDisplaySurface>
-{
-public:
-    EGLDisplaySurface();
-    ~EGLDisplaySurface();
-
-    int32_t getPageFlipCount() const;
-
-private:
-    static void         hook_incRef(NativeWindowType window);
-    static void         hook_decRef(NativeWindowType window);
-    static uint32_t     hook_swapBuffers(NativeWindowType window);
-    static void         hook_setSwapRectangle(NativeWindowType window, int l, int t, int w, int h);
-    static uint32_t     hook_nextBuffer(NativeWindowType window);
-
-    uint32_t    swapBuffers();
-    uint32_t    nextBuffer();
-    void        setSwapRectangle(int l, int t, int w, int h);
-
-    int    mapFrameBuffer();
-
-    enum {
-        PAGE_FLIP = 0x00000001
-    };
-    GGLSurface          mFb[2];
-    int                 mIndex;
-    uint32_t            mFlags;
-    size_t              mSize;
-    fb_var_screeninfo   mInfo;
-    fb_fix_screeninfo   mFinfo;
-    int32_t             mPageFlipCount;
-    int32_t             mSwapCount;
-    uint32_t            mFeatureFlags;
-};
-
-// ---------------------------------------------------------------------------
-}; // namespace android
-// ---------------------------------------------------------------------------
-
-#endif // ANDROID_SIM_EGL_SURFACE_H
-
diff --git a/opengl/tests/sfsim/sfsim.c b/opengl/tests/sfsim/sfsim.c
deleted file mode 100644
index 14ba490..0000000
--- a/opengl/tests/sfsim/sfsim.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <GLES/egl.h>
-
-int main(int argc, char** argv)
-{
-    if (argc != 2) {
-        printf("usage: %s <0-6>\n", argv[0]);
-        return 0;
-    }
-    
-    const int test = atoi(argv[1]);
-
-    EGLint s_configAttribs[] = {
-         EGL_RED_SIZE,       5,
-         EGL_GREEN_SIZE,     6,
-         EGL_BLUE_SIZE,      5,
-         EGL_NONE
-     };
-     
-     EGLint numConfigs = -1;
-     EGLint majorVersion;
-     EGLint minorVersion;
-     EGLConfig config;
-     EGLContext context;
-     EGLSurface surface;
-     EGLint w, h;
-     
-     EGLDisplay dpy;
-
-     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-     eglInitialize(dpy, &majorVersion, &minorVersion);
-     eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
-     surface = eglCreateWindowSurface(dpy, config,
-             android_createDisplaySurface(), NULL);
-     context = eglCreateContext(dpy, config, NULL, NULL);
-     eglMakeCurrent(dpy, surface, surface, context);   
-     eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
-     eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
-     GLint dim = w<h ? w : h;
-
-     glClear(GL_COLOR_BUFFER_BIT);
-
-     GLint crop[4] = { 0, 4, 4, -4 };
-     glBindTexture(GL_TEXTURE_2D, 0);
-     glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop);
-     glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-     glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-     glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-     glEnable(GL_TEXTURE_2D);
-     glColor4f(1,1,1,1);
-
-     // packing is always 4
-     uint8_t t8[]  = { 
-             0x00, 0x55, 0x00, 0x55, 
-             0xAA, 0xFF, 0xAA, 0xFF,
-             0x00, 0x55, 0x00, 0x55, 
-             0xAA, 0xFF, 0xAA, 0xFF  };
-
-     uint16_t t16[]  = { 
-             0x0000, 0x5555, 0x0000, 0x5555, 
-             0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF,
-             0x0000, 0x5555, 0x0000, 0x5555, 
-             0xAAAA, 0xFFFF, 0xAAAA, 0xFFFF  };
-
-     uint16_t t5551[]  = { 
-             0x0000, 0xFFFF, 0x0000, 0xFFFF, 
-             0xFFFF, 0x0000, 0xFFFF, 0x0000,
-             0x0000, 0xFFFF, 0x0000, 0xFFFF, 
-             0xFFFF, 0x0000, 0xFFFF, 0x0000  };
-
-     uint32_t t32[]  = { 
-             0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFFFF0000, 
-             0xFF00FF00, 0xFFFF0000, 0xFF000000, 0xFF0000FF, 
-             0xFF00FFFF, 0xFF00FF00, 0x00FF00FF, 0xFFFFFF00, 
-             0xFF000000, 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFFFF
-     };
-
-     switch(test) 
-     {
-     case 1:
-         glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE,
-                 4, 4, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, t8);
-         break;
-     case 2:
-         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
-                 4, 4, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, t16);
-         break;
-     case 3:
-         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
-                 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, t16);
-         break;
-     case 4:
-         glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA,
-                 4, 4, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, t16);
-         break;
-     case 5:
-         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
-                 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, t5551);
-         break;
-     case 6:
-         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
-                 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, t32);
-         break;
-     }
-
-     glDrawTexiOES(0, 0, 0, dim, dim);
-
-     eglSwapBuffers(dpy, surface);
-     return 0;
-}
diff --git a/opengl/tests/textures/Android.mk b/opengl/tests/textures/Android.mk
index b0c9021..a8c62209 100644
--- a/opengl/tests/textures/Android.mk
+++ b/opengl/tests/textures/Android.mk
@@ -6,7 +6,8 @@
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
-    libGLES_CM \
+    libEGL \
+    libGLESv1_CM \
     libui
 
 LOCAL_MODULE:= test-opengl-textures
diff --git a/opengl/tests/textures/textures.c b/opengl/tests/textures/textures.c
index 98e3be1..214291b 100644
--- a/opengl/tests/textures/textures.c
+++ b/opengl/tests/textures/textures.c
@@ -18,7 +18,9 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include <GLES/egl.h>
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+#include <GLES/glext.h>
 
 int main(int argc, char** argv)
 {
diff --git a/opengl/tests/tritex/Android.mk b/opengl/tests/tritex/Android.mk
index 4edac4c..5cd1f04 100644
--- a/opengl/tests/tritex/Android.mk
+++ b/opengl/tests/tritex/Android.mk
@@ -6,7 +6,8 @@
 
 LOCAL_SHARED_LIBRARIES := \
 	libcutils \
-    libGLES_CM \
+    libEGL \
+    libGLESv1_CM \
     libui
 
 LOCAL_MODULE:= test-opengl-tritex
diff --git a/opengl/tests/tritex/tritex.c b/opengl/tests/tritex/tritex.c
index 8ebe7d4..60a7feb 100644
--- a/opengl/tests/tritex/tritex.c
+++ b/opengl/tests/tritex/tritex.c
@@ -4,7 +4,9 @@
 //
 // Ported from a Java version by Google.
 
-#include <GLES/egl.h>

+#include <EGL/egl.h>

+#include <GLES/gl.h>
+
 #include <stdio.h>

 #include <stdlib.h>
 #include <math.h>
diff --git a/packages/SettingsProvider/etc/bookmarks.xml b/packages/SettingsProvider/etc/bookmarks.xml
index 235e2ed..5fb6608 100644
--- a/packages/SettingsProvider/etc/bookmarks.xml
+++ b/packages/SettingsProvider/etc/bookmarks.xml
@@ -15,14 +15,44 @@
 -->
 
 <bookmarks>
-    <bookmark package="com.android.browser" class="com.android.browser.BrowserActivity" shortcut="b" />
-    <bookmark package="com.android.calendar" class="com.android.calendar.LaunchActivity" shortcut="l" />
-    <bookmark package="com.android.contacts" class="com.android.contacts.DialtactsContactsEntryActivity" shortcut="c" />
-    <bookmark package="com.google.android.gm" class="com.google.android.gm.ConversationListActivityGmail" shortcut="g" />
-    <bookmark package="com.android.email" class="com.android.email.activity.Welcome" shortcut="e" />
-    <bookmark package="com.android.im" class="com.android.im.app.ChooseAccountActivity" shortcut="i" />
-    <bookmark package="com.google.android.apps.maps" class="com.google.android.maps.MapsActivity" shortcut="m" />
-    <bookmark package="com.android.music" class="com.android.music.MusicBrowserActivity" shortcut="p" />
-    <bookmark package="com.android.mms" class="com.android.mms.ui.ConversationList" shortcut="s" />
-    <bookmark package="com.google.android.youtube" class="com.google.android.youtube.HomePage" shortcut="y" />
-</bookmarks>
+    <bookmark
+        package="com.android.browser"
+        class="com.android.browser.BrowserActivity"
+        shortcut="b" />
+    <bookmark
+        package="com.android.contacts"
+        class="com.android.contacts.DialtactsContactsEntryActivity"
+        shortcut="c" />
+    <bookmark
+        package="com.android.email"
+        class="com.android.email.activity.Welcome"
+        shortcut="e" />
+    <bookmark
+        package="com.google.android.gm"
+        class="com.google.android.gm.ConversationListActivityGmail"
+        shortcut="g" />
+    <bookmark
+        package="com.android.providers.im"
+        class="com.android.providers.im.LandingPage"
+        shortcut="i" />
+    <bookmark
+        package="com.android.calendar"
+        class="com.android.calendar.LaunchActivity"
+        shortcut="l" />
+    <bookmark
+        package="com.google.android.apps.maps"
+        class="com.google.android.maps.MapsActivity"
+        shortcut="m" />
+    <bookmark
+        package="com.android.music"
+        class="com.android.music.MusicBrowserActivity"
+        shortcut="p" />
+    <bookmark
+        package="com.android.mms"
+        class="com.android.mms.ui.ConversationList"
+        shortcut="s" />
+    <bookmark
+        package="com.google.android.youtube"
+        class="com.google.android.youtube.HomePage"
+        shortcut="y" />
+</bookmarks>
\ No newline at end of file
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
new file mode 100644
index 0000000..72d88e2
--- /dev/null
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2009, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ *
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+-->
+<resources>
+    <bool name="def_dim_screen">true</bool>
+    <integer name="def_screen_off_timeout">60000</integer>
+    <bool name="def_airplane_mode_on">false</bool>
+    <!-- Comma-separated list of bluetooth, wifi, and cell. -->
+    <string name="def_airplane_mode_radios">cell,bluetooth,wifi</string>
+    <bool name="def_auto_time">true</bool>
+    <bool name="def_accelerometer_rotation">true</bool>
+    <!-- Default screen brightness, from 0 to 255.  102 is 40%. -->
+    <integer name="def_screen_brightness">102</integer>
+    <fraction name="def_window_animation_scale">0%</fraction>
+    <fraction name="def_window_transition_scale">0%</fraction>
+    
+    <bool name="def_bluetooth_on">false</bool>
+    <bool name="def_install_non_market_apps">false</bool>
+    <!-- Comma-separated list of providers. -->
+    <string name="def_location_providers_allowed">network</string>
+    <!--  0 == mobile, 1 == wifi. -->
+    <integer name="def_network_preference">1</integer>
+    <bool name="def_usb_mass_storage_enabled">true</bool>
+    <bool name="def_wifi_on">false</bool>
+    <bool name="def_networks_available_notification_on">true</bool>
+</resources>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index e2ea85b..90acd41 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -22,6 +22,7 @@
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
+import android.content.res.Resources;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
@@ -63,7 +64,7 @@
 
     private static final String TAG = "SettingsProvider";
     private static final String DATABASE_NAME = "settings.db";
-    private static final int DATABASE_VERSION = 31;
+    private static final int DATABASE_VERSION = 32;
     
     private Context mContext;
 
@@ -332,6 +333,27 @@
             upgradeVersion = 31;
         }
 
+        if (upgradeVersion == 31) {
+            /*
+             * Animations are now turned off by default.
+             */
+            db.beginTransaction();
+            try {
+                db.execSQL("DELETE FROM system WHERE name='"
+                        + Settings.System.WINDOW_ANIMATION_SCALE + "'");
+                db.execSQL("DELETE FROM system WHERE name='"
+                        + Settings.System.TRANSITION_ANIMATION_SCALE + "'");
+                SQLiteStatement stmt = db.compileStatement("INSERT INTO system(name,value)"
+                        + " VALUES(?,?);");
+                loadDefaultAnimationSettings(stmt);
+                stmt.close();
+                db.setTransactionSuccessful();
+            } finally {
+                db.endTransaction();
+            }
+            upgradeVersion = 32;
+        }
+
         if (upgradeVersion != currentVersion) {
             Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion
                     + ", must wipe the settings provider");
@@ -529,28 +551,31 @@
         SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO system(name,value)"
                 + " VALUES(?,?);");
         
-        loadSetting(stmt, Settings.System.DIM_SCREEN, 1);
+        Resources r = mContext.getResources();
+        loadBooleanSetting(stmt, Settings.System.DIM_SCREEN,
+                R.bool.def_dim_screen);
         loadSetting(stmt, Settings.System.STAY_ON_WHILE_PLUGGED_IN, 
                 "1".equals(SystemProperties.get("ro.kernel.qemu")) ? 1 : 0);
-        loadSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT, 60000);
-        // Allow airplane mode to turn off cell radio
-        loadSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS, 
-                Settings.System.RADIO_CELL + ","
-                + Settings.System.RADIO_BLUETOOTH + "," + Settings.System.RADIO_WIFI);
+        loadIntegerSetting(stmt, Settings.System.SCREEN_OFF_TIMEOUT,
+                R.integer.def_screen_off_timeout);
         
-        loadSetting(stmt, Settings.System.AIRPLANE_MODE_ON, 0);
+        loadBooleanSetting(stmt, Settings.System.AIRPLANE_MODE_ON,
+                R.bool.def_airplane_mode_on);
         
-        loadSetting(stmt, Settings.System.AUTO_TIME, 1); // Sync time to NITZ
+        loadStringSetting(stmt, Settings.System.AIRPLANE_MODE_RADIOS,
+                R.string.def_airplane_mode_radios);
         
-        // Set default brightness to 40%
-        loadSetting(stmt, Settings.System.SCREEN_BRIGHTNESS, 
-                (int) (android.os.Power.BRIGHTNESS_ON * 0.4f));
+        loadBooleanSetting(stmt, Settings.System.AUTO_TIME,
+                R.bool.def_auto_time); // Sync time to NITZ
         
-        // Enable normal window animations (menus, toasts); disable
-        // activity transition animations.
-        loadSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE, "1");
-        loadSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE, "1");
+        loadIntegerSetting(stmt, Settings.System.SCREEN_BRIGHTNESS,
+                R.integer.def_screen_brightness);
+        
+        loadDefaultAnimationSettings(stmt);
 
+        loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
+                R.bool.def_accelerometer_rotation);
+        
         // Default date format based on build
         loadSetting(stmt, Settings.System.DATE_FORMAT,
                 SystemProperties.get("ro.com.android.dateformat", 
@@ -558,12 +583,19 @@
         stmt.close();
     }
     
+    private void loadDefaultAnimationSettings(SQLiteStatement stmt) {
+        loadFractionSetting(stmt, Settings.System.WINDOW_ANIMATION_SCALE,
+                R.fraction.def_window_animation_scale, 1);
+        loadFractionSetting(stmt, Settings.System.TRANSITION_ANIMATION_SCALE,
+                R.fraction.def_window_transition_scale, 1);
+    }
+    
     private void loadSecureSettings(SQLiteDatabase db) {
         SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
                 + " VALUES(?,?);");
         
-        // Bluetooth off
-        loadSetting(stmt, Settings.Secure.BLUETOOTH_ON, 0);
+        loadBooleanSetting(stmt, Settings.Secure.BLUETOOTH_ON,
+                R.bool.def_bluetooth_on);
         
         // Data roaming default, based on build
         loadSetting(stmt, Settings.Secure.DATA_ROAMING, 
@@ -571,22 +603,22 @@
                         SystemProperties.get("ro.com.android.dataroaming", 
                                 "false")) ? 1 : 0);        
         
-        // Don't allow non-market apps to be installed
-        loadSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS, 0);
+        loadBooleanSetting(stmt, Settings.Secure.INSTALL_NON_MARKET_APPS,
+                R.bool.def_install_non_market_apps);
         
-        // Set the default location providers to network based (cell-id)
-        loadSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, 
-                LocationManager.NETWORK_PROVIDER);
+        loadStringSetting(stmt, Settings.Secure.LOCATION_PROVIDERS_ALLOWED,
+                R.string.def_location_providers_allowed);
         
-        loadSetting(stmt, Settings.Secure.NETWORK_PREFERENCE,
-            ConnectivityManager.DEFAULT_NETWORK_PREFERENCE);
-
-        // USB mass storage on by default
-        loadSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED, 1);
+        loadIntegerSetting(stmt, Settings.Secure.NETWORK_PREFERENCE,
+                R.integer.def_network_preference);
         
-        // WIFI on, notify about available networks
-        loadSetting(stmt, Settings.Secure.WIFI_ON, 0);
-        loadSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 1);
+        loadBooleanSetting(stmt, Settings.Secure.USB_MASS_STORAGE_ENABLED,
+                R.bool.def_usb_mass_storage_enabled);
+        
+        loadBooleanSetting(stmt, Settings.Secure.WIFI_ON,
+                R.bool.def_wifi_on);
+        loadBooleanSetting(stmt, Settings.Secure.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON,
+                R.bool.def_networks_available_notification_on);
         
         // Don't do this.  The SystemServer will initialize ADB_ENABLED from a
         // persistent system property instead.
@@ -600,4 +632,23 @@
         stmt.bindString(2, value.toString());
         stmt.execute();
     }
+    
+    private void loadStringSetting(SQLiteStatement stmt, String key, int resid) {
+        loadSetting(stmt, key, mContext.getResources().getString(resid));
+    }
+    
+    private void loadBooleanSetting(SQLiteStatement stmt, String key, int resid) {
+        loadSetting(stmt, key,
+                mContext.getResources().getBoolean(resid) ? "1" : "0");
+    }
+    
+    private void loadIntegerSetting(SQLiteStatement stmt, String key, int resid) {
+        loadSetting(stmt, key,
+                Integer.toString(mContext.getResources().getInteger(resid)));
+    }
+    
+    private void loadFractionSetting(SQLiteStatement stmt, String key, int resid, int base) {
+        loadSetting(stmt, key,
+                Float.toString(mContext.getResources().getFraction(resid, base, base)));
+    }
 }
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 35bf6b0..333a450 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -40,6 +40,9 @@
     private static final String TAG = "SettingsProvider";
     private static final boolean LOCAL_LOGV = false;
 
+    private static final String TABLE_FAVORITES = "favorites";
+    private static final String TABLE_OLD_FAVORITES = "old_favorites";
+
     private DatabaseHelper mOpenHelper;
 
     /**
@@ -47,7 +50,7 @@
      * used to access the corresponding database rows.
      */
     private static class SqlArguments {
-        public final String table;
+        public String table;
         public final String where;
         public final String[] args;
 
@@ -175,17 +178,30 @@
     @Override
     public Cursor query(Uri url, String[] select, String where, String[] whereArgs, String sort) {
         SqlArguments args = new SqlArguments(url, where, whereArgs);
+        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+
         // The favorites table was moved from this provider to a provider inside Home
         // Home still need to query this table to upgrade from pre-cupcake builds
         // However, a cupcake+ build with no data does not contain this table which will
         // cause an exception in the SQL stack. The following line is a special case to
         // let the caller of the query have a chance to recover and avoid the exception
-        if ("favorites".equals(args.table)) return null;
+        if (TABLE_FAVORITES.equals(args.table)) {
+            return null;
+        } else if (TABLE_OLD_FAVORITES.equals(args.table)) {
+            args.table = TABLE_FAVORITES;
+            Cursor cursor = db.rawQuery("PRAGMA table_info(favorites);", null);
+            if (cursor != null) {
+                boolean exists = cursor.getCount() > 0;
+                cursor.close();
+                if (!exists) return null;
+            } else {
+                return null;
+            }
+        }
 
         SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
         qb.setTables(args.table);
 
-        SQLiteDatabase db = mOpenHelper.getReadableDatabase();
         Cursor ret = qb.query(db, select, args.where, args.args, null, null, sort);
         ret.setNotificationUri(getContext().getContentResolver(), url);
         return ret;
@@ -206,6 +222,9 @@
     @Override
     public int bulkInsert(Uri uri, ContentValues[] values) {
         SqlArguments args = new SqlArguments(uri);
+        if (TABLE_FAVORITES.equals(args.table)) {
+            return 0;
+        }
         checkWritePermissions(args);
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -228,6 +247,9 @@
     @Override
     public Uri insert(Uri url, ContentValues initialValues) {
         SqlArguments args = new SqlArguments(url);
+        if (TABLE_FAVORITES.equals(args.table)) {
+            return null;
+        }
         checkWritePermissions(args);
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -243,6 +265,11 @@
     @Override
     public int delete(Uri url, String where, String[] whereArgs) {
         SqlArguments args = new SqlArguments(url, where, whereArgs);
+        if (TABLE_FAVORITES.equals(args.table)) {
+            return 0;
+        } else if (TABLE_OLD_FAVORITES.equals(args.table)) {
+            args.table = TABLE_FAVORITES;
+        }
         checkWritePermissions(args);
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
@@ -255,6 +282,9 @@
     @Override
     public int update(Uri url, ContentValues initialValues, String where, String[] whereArgs) {
         SqlArguments args = new SqlArguments(url, where, whereArgs);
+        if (TABLE_FAVORITES.equals(args.table)) {
+            return 0;
+        }
         checkWritePermissions(args);
 
         SQLiteDatabase db = mOpenHelper.getWritableDatabase();
diff --git a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java
index 4a1de59..8d6e2723 100644
--- a/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java
+++ b/packages/SubscribedFeedsProvider/src/com/android/providers/subscribedfeeds/SubscribedFeedsService.java
@@ -25,6 +25,7 @@
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.database.Cursor;
+import android.database.sqlite.SQLiteFullException;
 import android.net.Uri;
 import android.os.Bundle;
 import android.provider.SubscribedFeeds;
@@ -189,11 +190,15 @@
 
         // mark the feeds dirty, by setting the accounts to the same value,
         //  which will trigger a sync.
-        ContentValues values = new ContentValues();
-        for (String account : accounts) {
-            values.put(SyncConstValue._SYNC_ACCOUNT, account);
-            contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values,
-                    SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?", new String[] {account});
+        try {
+            ContentValues values = new ContentValues();
+            for (String account : accounts) {
+                values.put(SyncConstValue._SYNC_ACCOUNT, account);
+                contentResolver.update(SubscribedFeeds.Feeds.CONTENT_URI, values,
+                        SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?", new String[] {account});
+            }
+        } catch (SQLiteFullException e) {
+            Log.w(TAG, "disk full while trying to mark the feeds as dirty, skipping");
         }
 
         // Schedule a refresh.
diff --git a/preloaded-classes b/preloaded-classes
index 160ebef..1ace628 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -160,7 +160,7 @@
 android.graphics.drawable.GradientDrawable
 android.graphics.drawable.LayerDrawable
 android.graphics.drawable.LayerDrawable$LayerState
-android.graphics.drawable.LayerDrawable$Rec
+android.graphics.drawable.LayerDrawable$ChildDrawable
 android.graphics.drawable.NinePatchDrawable
 android.graphics.drawable.NinePatchDrawable$NinePatchState
 android.graphics.drawable.PaintDrawable
@@ -366,7 +366,6 @@
 android.view.inputmethod.BaseInputConnection
 android.view.inputmethod.CompletionInfo$1
 android.view.inputmethod.CompletionInfo
-android.view.inputmethod.DefaultInputMethod
 android.view.inputmethod.EditorInfo$1
 android.view.inputmethod.EditorInfo
 android.view.inputmethod.ExtractedText$1
@@ -376,23 +375,16 @@
 android.view.inputmethod.InputBinding$1
 android.view.inputmethod.InputBinding
 android.view.inputmethod.InputConnection
-android.view.inputmethod.InputConnectionWrapper
 android.view.inputmethod.InputMethod$SessionCallback
 android.view.inputmethod.InputMethod
 android.view.inputmethod.InputMethodInfo$1
 android.view.inputmethod.InputMethodInfo
 android.view.inputmethod.InputMethodManager$1
 android.view.inputmethod.InputMethodManager$2
-android.view.inputmethod.InputMethodManager$3
-android.view.inputmethod.InputMethodManager$NoOpInputConnection
+android.view.inputmethod.InputMethodManager$ControlledInputConnectionWrapper
 android.view.inputmethod.InputMethodManager
 android.view.inputmethod.InputMethodSession$EventCallback
 android.view.inputmethod.InputMethodSession
-android.view.inputmethod.MutableInputConnectionWrapper
-android.view.inputmethod.SimpleInputMethod$InputMethodSessionCallbackWrapper
-android.view.inputmethod.SimpleInputMethod$Session$InputMethodEventCallbackWrapper
-android.view.inputmethod.SimpleInputMethod$Session
-android.view.inputmethod.SimpleInputMethod
 android.webkit.BrowserFrame
 android.webkit.CacheManager
 android.webkit.CallbackProxy
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java
index 1625853..d8012b2 100644
--- a/services/java/com/android/server/AlarmManagerService.java
+++ b/services/java/com/android/server/AlarmManagerService.java
@@ -382,7 +382,7 @@
     
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission("android.permission.DUMP")
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump AlarmManager from from pid="
                     + Binder.getCallingPid()
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java
index dba8fca..e4fdd0c1 100644
--- a/services/java/com/android/server/BatteryService.java
+++ b/services/java/com/android/server/BatteryService.java
@@ -26,6 +26,7 @@
 import android.os.BatteryManager;
 import android.os.Binder;
 import android.os.RemoteException;
+import android.os.SystemClock;
 import android.os.UEventObserver;
 import android.util.EventLog;
 import android.util.Log;
@@ -61,9 +62,13 @@
     
     static final int LOG_BATTERY_LEVEL = 2722;
     static final int LOG_BATTERY_STATUS = 2723;
+    static final int LOG_BATTERY_DISCHARGE_STATUS = 2730;
     
     static final int BATTERY_SCALE = 100;    // battery capacity is a percentage
 
+    // This should probably be exposed in the API, though it's not critical
+    private static final int BATTERY_PLUGGED_NONE = 0;
+
     private final Context mContext;
     private final IBatteryStats mBatteryStats;
     
@@ -85,7 +90,10 @@
     private int mLastBatteryTemperature;
     
     private int mPlugType;
-    private int mLastPlugType;
+    private int mLastPlugType = -1; // Extra state so we can detect first run
+    
+    private long mDischargeStartTime;
+    private int mDischargeStartLevel;
     
     public BatteryService(Context context) {
         mContext = context;
@@ -145,7 +153,7 @@
         } else if (mUsbOnline) {
             mPlugType = BatteryManager.BATTERY_PLUGGED_USB;
         } else {
-            mPlugType = 0;
+            mPlugType = BATTERY_PLUGGED_NONE;
         }
         if (mBatteryStatus != mLastBatteryStatus ||
                 mBatteryHealth != mLastBatteryHealth ||
@@ -155,6 +163,25 @@
                 mBatteryVoltage != mLastBatteryVoltage ||
                 mBatteryTemperature != mLastBatteryTemperature) {
             
+            if (mPlugType != mLastPlugType) {
+                if (mLastPlugType == BATTERY_PLUGGED_NONE) {
+                    // discharging -> charging
+                    
+                    // There's no value in this data unless we've discharged at least once and the
+                    // battery level has changed; so don't log until it does.
+                    if (mDischargeStartTime != 0 && mDischargeStartLevel != mBatteryLevel) {
+                        long duration = SystemClock.elapsedRealtime() - mDischargeStartTime;
+                        EventLog.writeEvent(LOG_BATTERY_DISCHARGE_STATUS, duration,
+                                mDischargeStartLevel, mBatteryLevel);
+                        // make sure we see a discharge event before logging again
+                        mDischargeStartTime = 0; 
+                    }
+                } else if (mPlugType == BATTERY_PLUGGED_NONE) {
+                    // charging -> discharging or we just powered up
+                    mDischargeStartTime = SystemClock.elapsedRealtime();
+                    mDischargeStartLevel = mBatteryLevel;
+                }
+            }
             if (mBatteryStatus != mLastBatteryStatus ||
                     mBatteryHealth != mLastBatteryHealth ||
                     mBatteryPresent != mLastBatteryPresent ||
@@ -187,7 +214,7 @@
         Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED);
         intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
         try {
-            mBatteryStats.setOnBattery(mPlugType == 0);
+            mBatteryStats.setOnBattery(mPlugType == BATTERY_PLUGGED_NONE);
         } catch (RemoteException e) {
             // Should never happen.
         }
@@ -233,7 +260,7 @@
 
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission("android.permission.DUMP")
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             
             pw.println("Permission Denial: can't dump Battery service from from pid="
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 65e3650..760988d 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -35,6 +35,7 @@
 import android.os.ServiceManager;
 import android.os.SystemProperties;
 import android.provider.Settings;
+import android.provider.Sync;
 import android.util.EventLog;
 import android.util.Log;
 
@@ -333,6 +334,32 @@
         }
     }
 
+    /**
+     * @see ConnectivityManager#getBackgroundDataSetting()
+     */
+    public boolean getBackgroundDataSetting() {
+        return Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.BACKGROUND_DATA, 1) == 1;
+    }
+    
+    /**
+     * @see ConnectivityManager#setBackgroundDataSetting(boolean)
+     */
+    public void setBackgroundDataSetting(boolean allowBackgroundDataUsage) {
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.CHANGE_BACKGROUND_DATA_SETTING,
+                "ConnectivityService");
+        
+        if (getBackgroundDataSetting() == allowBackgroundDataUsage) return;
+
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.BACKGROUND_DATA, allowBackgroundDataUsage ? 1 : 0);
+        
+        Intent broadcast = new Intent(
+                ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
+        mContext.sendBroadcast(broadcast);
+    }    
+    
     private int getNumConnectedNetworks() {
         int numConnectedNets = 0;
 
@@ -632,7 +659,7 @@
 
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DUMP)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump ConnectivityService from from pid="
                     + Binder.getCallingPid()
diff --git a/services/java/com/android/server/FallbackCheckinService.java b/services/java/com/android/server/FallbackCheckinService.java
new file mode 100644
index 0000000..cf22446
--- /dev/null
+++ b/services/java/com/android/server/FallbackCheckinService.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Binder;
+import android.os.ICheckinService;
+import android.os.IParentalControlCallback;
+import android.util.Log;
+
+import java.io.IOException;
+
+import com.android.internal.os.RecoverySystem;
+import com.google.android.net.ParentalControlState;
+
+/**
+ * @hide
+ */
+public final class FallbackCheckinService extends ICheckinService.Stub {
+    static final String TAG = "FallbackCheckinService";
+    final Context mContext;
+    
+    public FallbackCheckinService(Context context) {
+        mContext = context;
+    }
+
+    public boolean checkin() {
+        return false;  // failure, because not implemented
+    }
+
+    public void reportCrashSync(byte[] crashData) {
+    }
+
+    public void reportCrashAsync(byte[] crashData) {
+    }
+
+    public void masterClear() {
+        if (mContext.checkCallingOrSelfPermission("android.permission.MASTER_CLEAR") !=
+                PackageManager.PERMISSION_GRANTED) {
+            Log.e(TAG, "Permission Denial: can't invoke masterClear from "
+                    + "pid=" + Binder.getCallingPid() + ", "
+                    + "uid=" + Binder.getCallingUid());
+            return;
+        }
+
+        // Save the android ID so the new system can get it erased.
+        try {
+            RecoverySystem.rebootAndWipe();
+        } catch (IOException e) {
+            Log.e(TAG, "Reboot for masterClear() failed", e);
+        }
+    }
+
+    public void getParentalControlState(IParentalControlCallback p, String requestingApp)
+            throws android.os.RemoteException {
+        ParentalControlState state = new ParentalControlState();
+        state.isEnabled = false;
+        p.onResult(state);
+    }
+}
diff --git a/services/java/com/android/server/GadgetService.java b/services/java/com/android/server/GadgetService.java
index 4be9ed5..5ef0fb9 100644
--- a/services/java/com/android/server/GadgetService.java
+++ b/services/java/com/android/server/GadgetService.java
@@ -16,57 +16,127 @@
 
 package com.android.server;
 
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageInfo;
 import android.content.pm.ResolveInfo;
 import android.content.pm.PackageItemInfo;
 import android.content.res.TypedArray;
 import android.content.res.XmlResourceParser;
 import android.gadget.GadgetManager;
 import android.gadget.GadgetInfo;
+import android.net.Uri;
 import android.os.Binder;
+import android.os.RemoteException;
+import android.os.SystemClock;
 import android.util.AttributeSet;
+import android.util.Config;
 import android.util.Log;
 import android.util.Xml;
+import android.widget.RemoteViews;
 
+import java.io.IOException;
+import java.io.File;
 import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
 
 import com.android.internal.gadget.IGadgetService;
+import com.android.internal.gadget.IGadgetHost;
+import com.android.internal.util.XmlUtils;
+import com.android.internal.util.FastXmlSerializer;
 
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlSerializer;
 
 class GadgetService extends IGadgetService.Stub
 {
     private static final String TAG = "GadgetService";
+    private static final boolean LOGD = Config.LOGD || false;
+
+    private static final String SETTINGS_FILENAME = "gadgets.xml";
+    private static final String SETTINGS_TMP_FILENAME = SETTINGS_FILENAME + ".tmp";
+
+    /*
+     * When identifying a Host or Provider based on the calling process, use the uid field.
+     * When identifying a Host or Provider based on a package manager broadcast, use the
+     * package given.
+     */
+
+    static class Provider {
+        int uid;
+        GadgetInfo info;
+        ArrayList<GadgetId> instances = new ArrayList();
+        PendingIntent broadcast;
+        
+        int tag;    // for use while saving state (the index)
+    }
+
+    static class Host {
+        int uid;
+        int hostId;
+        String packageName;
+        ArrayList<GadgetId> instances = new ArrayList();
+        IGadgetHost callbacks;
+        
+        int tag;    // for use while saving state (the index)
+    }
 
     static class GadgetId {
         int gadgetId;
-        String hostPackage;
-        GadgetInfo info;
+        Provider provider;
+        RemoteViews views;
+        Host host;
     }
 
     Context mContext;
     PackageManager mPackageManager;
-    ArrayList<GadgetInfo> mInstalledProviders;
+    AlarmManager mAlarmManager;
+    ArrayList<Provider> mInstalledProviders = new ArrayList();
     int mNextGadgetId = 1;
     ArrayList<GadgetId> mGadgetIds = new ArrayList();
+    ArrayList<Host> mHosts = new ArrayList();
 
     GadgetService(Context context) {
         mContext = context;
         mPackageManager = context.getPackageManager();
-        mInstalledProviders = getGadgetList();
+        mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
+        
+        getGadgetList();
+        loadStateLocked();
+
+        // Register for the boot completed broadcast, so we can send the
+        // ENABLE broacasts.  If we try to send them now, they time out,
+        // because the system isn't ready to handle them yet.
+        mContext.registerReceiver(mBroadcastReceiver,
+                new IntentFilter(Intent.ACTION_BOOT_COMPLETED), null, null);
+
+        // Register for broadcasts about package install, etc., so we can
+        // update the provider list.
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(Intent.ACTION_PACKAGE_ADDED);
+        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
+        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+        filter.addDataScheme("package");
+        mContext.registerReceiver(mBroadcastReceiver, filter);
     }
 
     @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DUMP)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump from from pid="
                     + Binder.getCallingPid()
@@ -78,7 +148,7 @@
             int N = mInstalledProviders.size();
             pw.println("Providers: (size=" + N + ")");
             for (int i=0; i<N; i++) {
-                GadgetInfo info = mInstalledProviders.get(i);
+                GadgetInfo info = mInstalledProviders.get(i).info;
                 pw.println("  [" + i + "] provder=" + info.provider
                         + " min=(" + info.minWidth + "x" + info.minHeight + ")"
                         + " updatePeriodMillis=" + info.updatePeriodMillis
@@ -89,58 +159,175 @@
             pw.println("GadgetIds: (size=" + N + ")");
             for (int i=0; i<N; i++) {
                 GadgetId id = mGadgetIds.get(i);
-                pw.println("  [" + i + "] gadgetId=" + id.gadgetId + " host=" + id.hostPackage
-                        + " provider=" + (id.info == null ? "null" : id.info.provider));
+                pw.println("  [" + i + "] gadgetId=" + id.gadgetId
+                        + " host=" + id.host.hostId + "/" + id.host.packageName + " provider="
+                        + (id.provider == null ? "null" : id.provider.info.provider)
+                        + " host.callbacks=" + (id.host != null ? id.host.callbacks : "(no host)")
+                        + " views=" + id.views);
+            }
+
+            N = mHosts.size();
+            pw.println("Hosts: (size=" + N + ")");
+            for (int i=0; i<N; i++) {
+                Host host = mHosts.get(i);
+                pw.println("  [" + i + "] packageName=" + host.packageName + " uid=" + host.uid
+                        + " hostId=" + host.hostId + " callbacks=" + host.callbacks
+                        + " instances.size=" + host.instances.size());
             }
         }
     }
 
-    public int allocateGadgetId(String hostPackage) {
+    public int allocateGadgetId(String packageName, int hostId) {
+        int callingUid = enforceCallingUid(packageName);
         synchronized (mGadgetIds) {
-            // TODO: Check for pick permission
             int gadgetId = mNextGadgetId++;
 
+            Host host = lookupOrAddHostLocked(callingUid, packageName, hostId);
+
             GadgetId id = new GadgetId();
             id.gadgetId = gadgetId;
-            id.hostPackage = hostPackage;
+            id.host = host;
 
+            host.instances.add(id);
             mGadgetIds.add(id);
 
+            saveStateLocked();
+
             return gadgetId;
         }
     }
 
     public void deleteGadgetId(int gadgetId) {
         synchronized (mGadgetIds) {
-            String callingPackage = getCallingPackage();
+            int callingUid = getCallingUid();
             final int N = mGadgetIds.size();
             for (int i=0; i<N; i++) {
                 GadgetId id = mGadgetIds.get(i);
-                if (canAccessGadgetId(id, callingPackage)) {
-                    mGadgetIds.remove(i);
-                    // TODO: Notify someone?
+                if (id.provider != null && canAccessGadgetId(id, callingUid)) {
+                    deleteGadgetLocked(id);
+
+                    saveStateLocked();
                     return;
                 }
             }
         }
     }
 
+    public void deleteHost(int hostId) {
+        synchronized (mGadgetIds) {
+            int callingUid = getCallingUid();
+            Host host = lookupHostLocked(callingUid, hostId);
+            if (host != null) {
+                deleteHostLocked(host);
+                saveStateLocked();
+            }
+        }
+    }
+
+    public void deleteAllHosts() {
+        synchronized (mGadgetIds) {
+            int callingUid = getCallingUid();
+            final int N = mHosts.size();
+            boolean changed = false;
+            for (int i=0; i<N; i++) {
+                Host host = mHosts.get(i);
+                if (host.uid == callingUid) {
+                    deleteHostLocked(host);
+                    changed = true;
+                }
+            }
+            if (changed) {
+                saveStateLocked();
+            }
+        }
+    }
+
+    void deleteHostLocked(Host host) {
+        final int N = host.instances.size();
+        for (int i=0; i<N; i++) {
+            GadgetId id = host.instances.get(i);
+            deleteGadgetLocked(id);
+        }
+        host.instances.clear();
+        mHosts.remove(host);
+        // it's gone or going away, abruptly drop the callback connection
+        host.callbacks = null;
+    }
+
+    void deleteGadgetLocked(GadgetId id) {
+        Host host = id.host;
+        host.instances.remove(id);
+        pruneHostLocked(host);
+
+        mGadgetIds.remove(id);
+
+        Provider p = id.provider;
+        if (p != null) {
+            p.instances.remove(id);
+            // send the broacast saying that this gadgetId has been deleted
+            Intent intent = new Intent(GadgetManager.GADGET_DELETED_ACTION);
+            intent.setComponent(p.info.provider);
+            intent.putExtra(GadgetManager.EXTRA_GADGET_ID, id.gadgetId);
+            mContext.sendBroadcast(intent);
+            if (p.instances.size() == 0) {
+                // cancel the future updates
+                cancelBroadcasts(p);
+
+                // send the broacast saying that the provider is not in use any more
+                intent = new Intent(GadgetManager.GADGET_DISABLED_ACTION);
+                intent.setComponent(p.info.provider);
+                mContext.sendBroadcast(intent);
+            }
+        }
+    }
+
+    void cancelBroadcasts(Provider p) {
+        if (p.broadcast != null) {
+            mAlarmManager.cancel(p.broadcast);
+            long token = Binder.clearCallingIdentity();
+            try {
+                p.broadcast.cancel();
+            } finally {
+                Binder.restoreCallingIdentity(token);
+            }
+            p.broadcast = null;
+        }
+    }
+
     public void bindGadgetId(int gadgetId, ComponentName provider) {
+        mContext.enforceCallingPermission(android.Manifest.permission.BIND_GADGET,
+                "bindGagetId gadgetId=" + gadgetId + " provider=" + provider);
         synchronized (mGadgetIds) {
             GadgetId id = lookupGadgetIdLocked(gadgetId);
             if (id == null) {
-                throw new IllegalArgumentException("bad gadgetId"); // TODO: use a better exception
+                throw new IllegalArgumentException("bad gadgetId");
             }
-            if (id.info != null) {
+            if (id.provider != null) {
                 throw new IllegalArgumentException("gadgetId " + gadgetId + " already bound to "
-                        + id.info.provider);
+                        + id.provider.info.provider);
             }
-            GadgetInfo info = lookupGadgetInfoLocked(provider);
-            if (info == null) {
+            Provider p = lookupProviderLocked(provider);
+            if (p == null) {
                 throw new IllegalArgumentException("not a gadget provider: " + provider);
             }
 
-            id.info = info;
+            id.provider = p;
+            p.instances.add(id);
+            int instancesSize = p.instances.size();
+            if (instancesSize == 1) {
+                // tell the provider that it's ready
+                sendEnableIntentLocked(p);
+            }
+
+            // send an update now -- We need this update now, and just for this gadgetId.
+            // It's less critical when the next one happens, so when we schdule the next one,
+            // we add updatePeriodMillis to its start time.  That time will have some slop,
+            // but that's okay.
+            sendUpdateIntentLocked(p, new int[] { gadgetId });
+
+            // schedule the future updates
+            registerForBroadcastsLocked(p, getGadgetIds(p));
+            saveStateLocked();
         }
     }
 
@@ -148,7 +335,17 @@
         synchronized (mGadgetIds) {
             GadgetId id = lookupGadgetIdLocked(gadgetId);
             if (id != null) {
-                return id.info;
+                return id.provider.info;
+            }
+            return null;
+        }
+    }
+
+    public RemoteViews getGadgetViews(int gadgetId) {
+        synchronized (mGadgetIds) {
+            GadgetId id = lookupGadgetIdLocked(gadgetId);
+            if (id != null) {
+                return id.views;
             }
             return null;
         }
@@ -156,49 +353,175 @@
 
     public List<GadgetInfo> getInstalledProviders() {
         synchronized (mGadgetIds) {
-            return new ArrayList<GadgetInfo>(mInstalledProviders);
+            final int N = mInstalledProviders.size();
+            ArrayList<GadgetInfo> result = new ArrayList(N);
+            for (int i=0; i<N; i++) {
+                result.add(mInstalledProviders.get(i).info);
+            }
+            return result;
         }
     }
 
-    boolean canAccessGadgetId(GadgetId id, String callingPackage) {
-        if (id.hostPackage.equals(callingPackage)) {
+    public void updateGadgetIds(int[] gadgetIds, RemoteViews views) {
+        if (gadgetIds == null) {
+            throw new IllegalArgumentException("bad gadgetIds");
+        }
+        if (gadgetIds.length == 0) {
+            return;
+        }
+        final int N = gadgetIds.length;
+
+        synchronized (mGadgetIds) {
+            for (int i=0; i<N; i++) {
+                GadgetId id = lookupGadgetIdLocked(gadgetIds[i]);
+                updateGadgetInstanceLocked(id, views);
+            }
+        }
+    }
+
+    public void updateGadgetProvider(ComponentName provider, RemoteViews views) {
+        synchronized (mGadgetIds) {
+            Provider p = lookupProviderLocked(provider);
+            if (p == null) {
+                Log.w(TAG, "updateGadget: provider doesn't exist: " + provider);
+                return;
+            }
+            ArrayList<GadgetId> instances = p.instances;
+            final int N = instances.size();
+            for (int i=0; i<N; i++) {
+                GadgetId id = instances.get(i);
+                updateGadgetInstanceLocked(id, views);
+            }
+        }
+    }
+
+    void updateGadgetInstanceLocked(GadgetId id, RemoteViews views) {
+        // allow for stale gadgetIds and other badness
+        // lookup also checks that the calling process can access the gadget id
+        // drop unbound gadget ids (shouldn't be possible under normal circumstances)
+        if (id != null && id.provider != null) {
+            id.views = views;
+
+            // is anyone listening?
+            if (id.host.callbacks != null) {
+                try {
+                    // the lock is held, but this is a oneway call
+                    id.host.callbacks.updateGadget(id.gadgetId, views);
+                } catch (RemoteException e) {
+                    // It failed, remove the callback. No need to prune because
+                    // we know that this host is still referenced by this instance.
+                    id.host.callbacks = null;
+                }
+            }
+        }
+    }
+
+    public int[] startListening(IGadgetHost callbacks, String packageName, int hostId,
+            List<RemoteViews> updatedViews) {
+        int callingUid = enforceCallingUid(packageName);
+        synchronized (mGadgetIds) {
+            Host host = lookupOrAddHostLocked(callingUid, packageName, hostId);
+            host.callbacks = callbacks;
+
+            updatedViews.clear();
+
+            ArrayList<GadgetId> instances = host.instances;
+            int N = instances.size();
+            int[] updatedIds = new int[N];
+            for (int i=0; i<N; i++) {
+                GadgetId id = instances.get(i);
+                updatedIds[i] = id.gadgetId;
+                updatedViews.add(id.views);
+            }
+            return updatedIds;
+        }
+    }
+
+    public void stopListening(int hostId) {
+        synchronized (mGadgetIds) {
+            Host host = lookupHostLocked(getCallingUid(), hostId);
+            host.callbacks = null;
+            pruneHostLocked(host);
+        }
+    }
+
+    boolean canAccessGadgetId(GadgetId id, int callingUid) {
+        if (id.host.uid == callingUid) {
+            // Apps hosting the gadget have access to it.
             return true;
         }
-        if (id.info != null && id.info.provider.getPackageName().equals(callingPackage)) {
+        if (id.provider != null && id.provider.uid == callingUid) {
+            // Apps providing the gadget have access to it (if the gadgetId has been bound)
             return true;
         }
-        // TODO: Check for the pick permission
-        //if (has permission) {
-        //    return true;
-        //}
-        //return false;
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.BIND_GADGET)
+                == PackageManager.PERMISSION_GRANTED) {
+            // Apps that can bind have access to all gadgetIds.
+            return true;
+        }
+        // Nobody else can access it.
+        // TODO: convert callingPackage over to use UID-based checking instead
+        // TODO: our temp solution is to short-circuit this security check
         return true;
     }
 
-    private GadgetId lookupGadgetIdLocked(int gadgetId) {
-        String callingPackage = getCallingPackage();
+   GadgetId lookupGadgetIdLocked(int gadgetId) {
+        int callingUid = getCallingUid();
         final int N = mGadgetIds.size();
         for (int i=0; i<N; i++) {
             GadgetId id = mGadgetIds.get(i);
-            if (canAccessGadgetId(id, callingPackage)) {
+            if (id.gadgetId == gadgetId && canAccessGadgetId(id, callingUid)) {
                 return id;
             }
         }
         return null;
     }
 
-    GadgetInfo lookupGadgetInfoLocked(ComponentName provider) {
+    Provider lookupProviderLocked(ComponentName provider) {
         final int N = mInstalledProviders.size();
         for (int i=0; i<N; i++) {
-            GadgetInfo info = mInstalledProviders.get(i);
-            if (info.provider.equals(provider)) {
-                return info;
+            Provider p = mInstalledProviders.get(i);
+            if (p.info.provider.equals(provider)) {
+                return p;
             }
         }
         return null;
     }
 
-    ArrayList<GadgetInfo> getGadgetList() {
+    Host lookupHostLocked(int uid, int hostId) {
+        final int N = mHosts.size();
+        for (int i=0; i<N; i++) {
+            Host h = mHosts.get(i);
+            if (h.uid == uid && h.hostId == hostId) {
+                return h;
+            }
+        }
+        return null;
+    }
+
+    Host lookupOrAddHostLocked(int uid, String packageName, int hostId) {
+        final int N = mHosts.size();
+        for (int i=0; i<N; i++) {
+            Host h = mHosts.get(i);
+            if (h.hostId == hostId && h.packageName.equals(packageName)) {
+                return h;
+            }
+        }
+        Host host = new Host();
+        host.packageName = packageName;
+        host.uid = uid;
+        host.hostId = hostId;
+        mHosts.add(host);
+        return host;
+    }
+
+    void pruneHostLocked(Host host) {
+        if (host.instances.size() == 0 && host.callbacks == null) {
+            mHosts.remove(host);
+        }
+    }
+
+    void getGadgetList() {
         PackageManager pm = mPackageManager;
 
         // TODO: We have these as different actions.  I wonder if it makes more sense to
@@ -208,29 +531,96 @@
         List<ResolveInfo> broadcastReceivers = pm.queryBroadcastReceivers(intent,
                 PackageManager.GET_META_DATA);
 
-        ArrayList<GadgetInfo> result = new ArrayList<GadgetInfo>();
-
         final int N = broadcastReceivers.size();
         for (int i=0; i<N; i++) {
             ResolveInfo ri = broadcastReceivers.get(i);
-            ActivityInfo ai = ri.activityInfo;
-            GadgetInfo gi = parseGadgetInfoXml(new ComponentName(ai.packageName, ai.name),
-                    ri.activityInfo);
-            if (gi != null) {
-                result.add(gi);
-            }
+            addProviderLocked(ri);
         }
-
-        return result;
     }
 
-    private GadgetInfo parseGadgetInfoXml(ComponentName component,
-            PackageItemInfo packageItemInfo) {
-        GadgetInfo gi = null;
+    void addProviderLocked(ResolveInfo ri) {
+        Provider p = parseGadgetInfoXml(new ComponentName(ri.activityInfo.packageName,
+                    ri.activityInfo.name), ri);
+        if (p != null) {
+            mInstalledProviders.add(p);
+        }
+    }
 
+    void removeProviderLocked(int index, Provider p) {
+        int N = p.instances.size();
+        for (int i=0; i<N; i++) {
+            GadgetId id = p.instances.get(i);
+            // Call back with empty RemoteViews
+            updateGadgetInstanceLocked(id, null);
+            // Stop telling the host about updates for this from now on
+            cancelBroadcasts(p);
+            // clear out references to this gadgetID
+            id.host.instances.remove(id);
+            mGadgetIds.remove(id);
+            id.provider = null;
+            pruneHostLocked(id.host);
+            id.host = null;
+        }
+        p.instances.clear();
+        mInstalledProviders.remove(index);
+        // no need to send the DISABLE broadcast, since the receiver is gone anyway
+        cancelBroadcasts(p);
+    }
+
+    void sendEnableIntentLocked(Provider p) {
+        Intent intent = new Intent(GadgetManager.GADGET_ENABLED_ACTION);
+        intent.setComponent(p.info.provider);
+        mContext.sendBroadcast(intent);
+    }
+
+    void sendUpdateIntentLocked(Provider p, int[] gadgetIds) {
+        Intent intent = new Intent(GadgetManager.GADGET_UPDATE_ACTION);
+        intent.putExtra(GadgetManager.EXTRA_GADGET_IDS, gadgetIds);
+        intent.setComponent(p.info.provider);
+        mContext.sendBroadcast(intent);
+    }
+
+    void registerForBroadcastsLocked(Provider p, int[] gadgetIds) {
+        if (p.info.updatePeriodMillis > 0) {
+            // if this is the first instance, set the alarm.  otherwise,
+            // rely on the fact that we've already set it and that
+            // PendingIntent.getBroadcast will update the extras.
+            boolean alreadyRegistered = p.broadcast != null;
+            int instancesSize = p.instances.size();
+            Intent intent = new Intent(GadgetManager.GADGET_UPDATE_ACTION);
+            intent.putExtra(GadgetManager.EXTRA_GADGET_IDS, gadgetIds);
+            intent.setComponent(p.info.provider);
+            long token = Binder.clearCallingIdentity();
+            try {
+                p.broadcast = PendingIntent.getBroadcast(mContext, 1, intent,
+                        PendingIntent.FLAG_UPDATE_CURRENT);
+            } finally {
+                Binder.restoreCallingIdentity(token);
+            }
+            if (!alreadyRegistered) {
+                mAlarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+                        SystemClock.elapsedRealtime() + p.info.updatePeriodMillis,
+                        p.info.updatePeriodMillis, p.broadcast);
+            }
+        }
+    }
+    
+    static int[] getGadgetIds(Provider p) {
+        int instancesSize = p.instances.size();
+        int gadgetIds[] = new int[instancesSize];
+        for (int i=0; i<instancesSize; i++) {
+            gadgetIds[i] = p.instances.get(i).gadgetId;
+        }
+        return gadgetIds;
+    }
+
+    private Provider parseGadgetInfoXml(ComponentName component, ResolveInfo ri) {
+        Provider p = null;
+
+        ActivityInfo activityInfo = ri.activityInfo;
         XmlResourceParser parser = null;
         try {
-            parser = packageItemInfo.loadXmlMetaData(mPackageManager,
+            parser = activityInfo.loadXmlMetaData(mPackageManager,
                     GadgetManager.GADGET_PROVIDER_META_DATA);
             if (parser == null) {
                 Log.w(TAG, "No " + GadgetManager.GADGET_PROVIDER_META_DATA + " meta-data for "
@@ -253,20 +643,29 @@
                 return null;
             }
 
-            gi = new GadgetInfo();
+            p = new Provider();
+            GadgetInfo info = p.info = new GadgetInfo();
 
-            gi.provider = component;
+            info.provider = component;
+            p.uid = activityInfo.applicationInfo.uid;
 
             TypedArray sa = mContext.getResources().obtainAttributes(attrs,
                     com.android.internal.R.styleable.GadgetProviderInfo);
-            gi.minWidth = sa.getDimensionPixelSize(
+            info.minWidth = sa.getDimensionPixelSize(
                     com.android.internal.R.styleable.GadgetProviderInfo_minWidth, 0);
-            gi.minHeight = sa.getDimensionPixelSize(
+            info.minHeight = sa.getDimensionPixelSize(
                     com.android.internal.R.styleable.GadgetProviderInfo_minHeight, 0);
-            gi.updatePeriodMillis = sa.getInt(
+            info.updatePeriodMillis = sa.getInt(
                     com.android.internal.R.styleable.GadgetProviderInfo_updatePeriodMillis, 0);
-            gi.initialLayout = sa.getResourceId(
+            info.initialLayout = sa.getResourceId(
                     com.android.internal.R.styleable.GadgetProviderInfo_initialLayout, 0);
+            String className = sa.getString(
+                    com.android.internal.R.styleable.GadgetProviderInfo_configure);
+            if (className != null) {
+                info.configure = new ComponentName(component.getPackageName(), className);
+            }
+            info.label = activityInfo.loadLabel(mPackageManager).toString();
+            info.icon = ri.getIconResource();
             sa.recycle();
         } catch (Exception e) {
             // Ok to catch Exception here, because anything going wrong because
@@ -276,17 +675,401 @@
         } finally {
             if (parser != null) parser.close();
         }
-        return gi;
+        return p;
     }
 
-    void sendEnabled(ComponentName provider) {
-        Intent intent = new Intent(GadgetManager.GADGET_ENABLE_ACTION);
-        intent.setComponent(provider);
-        mContext.sendBroadcast(intent);
+    int getUidForPackage(String packageName) throws PackageManager.NameNotFoundException {
+        PackageInfo pkgInfo = mPackageManager.getPackageInfo(packageName, 0);
+        if (pkgInfo == null || pkgInfo.applicationInfo == null) {
+            throw new PackageManager.NameNotFoundException();
+        }
+        return pkgInfo.applicationInfo.uid;
     }
 
-    String getCallingPackage() {
-        return mPackageManager.getNameForUid(getCallingUid());
+    int enforceCallingUid(String packageName) throws IllegalArgumentException {
+        int callingUid = getCallingUid();
+        int packageUid;
+        try {
+            packageUid = getUidForPackage(packageName);
+        } catch (PackageManager.NameNotFoundException ex) {
+            throw new IllegalArgumentException("packageName and uid don't match packageName="
+                    + packageName);
+        }
+        if (callingUid != packageUid) {
+            throw new IllegalArgumentException("packageName and uid don't match packageName="
+                    + packageName);
+        }
+        return callingUid;
+    }
+
+    void sendInitialBroadcasts() {
+        synchronized (mGadgetIds) {
+            final int N = mInstalledProviders.size();
+            for (int i=0; i<N; i++) {
+                Provider p = mInstalledProviders.get(i);
+                if (p.instances.size() > 0) {
+                    sendEnableIntentLocked(p);
+                    int[] gadgetIds = getGadgetIds(p);
+                    sendUpdateIntentLocked(p, gadgetIds);
+                    registerForBroadcastsLocked(p, gadgetIds);
+                }
+            }
+        }
+    }
+
+    // only call from initialization -- it assumes that the data structures are all empty
+    void loadStateLocked() {
+        File temp = savedStateTempFile();
+        File real = savedStateRealFile();
+
+        // prefer the real file.  If it doesn't exist, use the temp one, and then copy it to the
+        // real one.  if there is both a real file and a temp one, assume that the temp one isn't
+        // fully written and delete it.
+        if (real.exists()) {
+            readStateFromFileLocked(real);
+            if (temp.exists()) {
+                temp.delete();
+            }
+        } else if (temp.exists()) {
+            readStateFromFileLocked(temp);
+            temp.renameTo(real);
+        }
+    }
+    
+    void saveStateLocked() {
+        File temp = savedStateTempFile();
+        File real = savedStateRealFile();
+
+        if (!real.exists()) {
+            // If the real one doesn't exist, it's either because this is the first time
+            // or because something went wrong while copying them.  In this case, we can't
+            // trust anything that's in temp.  In order to have the loadState code not
+            // use the temporary one until it's fully written, create an empty file
+            // for real, which will we'll shortly delete.
+            try {
+                real.createNewFile();
+            } catch (IOException e) {
+            }
+        }
+
+        if (temp.exists()) {
+            temp.delete();
+        }
+
+        writeStateToFileLocked(temp);
+
+        real.delete();
+        temp.renameTo(real);
+    }
+
+    void writeStateToFileLocked(File file) {
+        FileOutputStream stream = null;
+        int N;
+
+        try {
+            stream = new FileOutputStream(file, false);
+            XmlSerializer out = new FastXmlSerializer();
+            out.setOutput(stream, "utf-8");
+            out.startDocument(null, true);
+
+            
+            out.startTag(null, "gs");
+
+            int providerIndex = 0;
+            N = mInstalledProviders.size();
+            for (int i=0; i<N; i++) {
+                Provider p = mInstalledProviders.get(i);
+                if (p.instances.size() > 0) {
+                    out.startTag(null, "p");
+                    out.attribute(null, "pkg", p.info.provider.getPackageName());
+                    out.attribute(null, "cl", p.info.provider.getClassName());
+                    out.endTag(null, "h");
+                    p.tag = providerIndex;
+                    providerIndex++;
+                }
+            }
+
+            N = mHosts.size();
+            for (int i=0; i<N; i++) {
+                Host host = mHosts.get(i);
+                out.startTag(null, "h");
+                out.attribute(null, "pkg", host.packageName);
+                out.attribute(null, "id", Integer.toHexString(host.hostId));
+                out.endTag(null, "h");
+                host.tag = i;
+            }
+
+            N = mGadgetIds.size();
+            for (int i=0; i<N; i++) {
+                GadgetId id = mGadgetIds.get(i);
+                out.startTag(null, "g");
+                out.attribute(null, "id", Integer.toHexString(id.gadgetId));
+                out.attribute(null, "h", Integer.toHexString(id.host.tag));
+                if (id.provider != null) {
+                    out.attribute(null, "p", Integer.toHexString(id.provider.tag));
+                }
+                out.endTag(null, "g");
+            }
+
+            out.endTag(null, "gs");
+
+            out.endDocument();
+            stream.close();
+        } catch (IOException e) {
+            try {
+                if (stream != null) {
+                    stream.close();
+                }
+            } catch (IOException ex) {
+            }
+            if (file.exists()) {
+                file.delete();
+            }
+        }
+    }
+
+    void readStateFromFileLocked(File file) {
+        FileInputStream stream = null;
+
+        boolean success = false;
+
+        try {
+            stream = new FileInputStream(file);
+            XmlPullParser parser = Xml.newPullParser();
+            parser.setInput(stream, null);
+
+            int type;
+            int providerIndex = 0;
+            HashMap<Integer,Provider> loadedProviders = new HashMap();
+            do {
+                type = parser.next();
+                if (type == XmlPullParser.START_TAG) {
+                    String tag = parser.getName();
+                    if ("p".equals(tag)) {
+                        // TODO: do we need to check that this package has the same signature
+                        // as before?
+                        String pkg = parser.getAttributeValue(null, "pkg");
+                        String cl = parser.getAttributeValue(null, "cl");
+                        Provider p = lookupProviderLocked(new ComponentName(pkg, cl));
+                        // if it wasn't uninstalled or something
+                        if (p != null) {
+                            loadedProviders.put(providerIndex, p);
+                        }
+                        providerIndex++;
+                    }
+                    else if ("h".equals(tag)) {
+                        Host host = new Host();
+
+                        // TODO: do we need to check that this package has the same signature
+                        // as before?
+                        host.packageName = parser.getAttributeValue(null, "pkg");
+                        try {
+                            host.uid = getUidForPackage(host.packageName);
+                            host.hostId = Integer.parseInt(
+                                    parser.getAttributeValue(null, "id"), 16);
+                            mHosts.add(host);
+                        } catch (PackageManager.NameNotFoundException ex) {
+                            // Just ignore drop this entry, as if it has been uninstalled.
+                            // We need to deal with this case because of safe mode, but there's
+                            // a bug filed about it.
+                        }
+                    }
+                    else if ("g".equals(tag)) {
+                        GadgetId id = new GadgetId();
+                        id.gadgetId = Integer.parseInt(parser.getAttributeValue(null, "id"), 16);
+                        if (id.gadgetId >= mNextGadgetId) {
+                            mNextGadgetId = id.gadgetId + 1;
+                        }
+
+                        String providerString = parser.getAttributeValue(null, "p");
+                        if (providerString != null) {
+                            // there's no provider if it hasn't been bound yet.
+                            // maybe we don't have to save this, but it brings the system
+                            // to the state it was in.
+                            int pIndex = Integer.parseInt(providerString, 16);
+                            id.provider = loadedProviders.get(pIndex);
+                            if (false) {
+                                Log.d(TAG, "bound gadgetId=" + id.gadgetId + " to provider "
+                                        + pIndex + " which is " + id.provider);
+                            }
+                            if (id.provider == null) {
+                                // This provider is gone.  We just let the host figure out
+                                // that this happened when it fails to load it.
+                                continue;
+                            }
+                        }
+
+                        int hIndex = Integer.parseInt(parser.getAttributeValue(null, "h"), 16);
+                        id.host = mHosts.get(hIndex);
+                        if (id.host == null) {
+                            // This host is gone.
+                            continue;
+                        }
+
+                        if (id.provider != null) {
+                            id.provider.instances.add(id);
+                        }
+                        id.host.instances.add(id);
+                        mGadgetIds.add(id);
+                    }
+                }
+            } while (type != XmlPullParser.END_DOCUMENT);
+            success = true;
+        } catch (NullPointerException e) {
+            Log.w(TAG, "failed parsing " + file, e);
+        } catch (NumberFormatException e) {
+            Log.w(TAG, "failed parsing " + file, e);
+        } catch (XmlPullParserException e) {
+            Log.w(TAG, "failed parsing " + file, e);
+        } catch (IOException e) {
+            Log.w(TAG, "failed parsing " + file, e);
+        } catch (IndexOutOfBoundsException e) {
+            Log.w(TAG, "failed parsing " + file, e);
+        }
+        try {
+            if (stream != null) {
+                stream.close();
+            }
+        } catch (IOException e) {
+        }
+
+        if (success) {
+            // delete any hosts that didn't manage to get connected (should happen)
+            // if it matters, they'll be reconnected.
+            final int N = mHosts.size();
+            for (int i=0; i<N; i++) {
+                pruneHostLocked(mHosts.get(i));
+            }
+        } else {
+            // failed reading, clean up
+            mGadgetIds.clear();
+            mHosts.clear();
+            final int N = mInstalledProviders.size();
+            for (int i=0; i<N; i++) {
+                mInstalledProviders.get(i).instances.clear();
+            }
+        }
+    }
+
+    File savedStateTempFile() {
+        return new File("/data/system/" + SETTINGS_TMP_FILENAME);
+        //return new File(mContext.getFilesDir(), SETTINGS_FILENAME);
+    }
+
+    File savedStateRealFile() {
+        return new File("/data/system/" + SETTINGS_FILENAME);
+        //return new File(mContext.getFilesDir(), SETTINGS_TMP_FILENAME);
+    }
+
+    BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            //Log.d(TAG, "received " + action);
+            if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
+                sendInitialBroadcasts();
+            } else {
+                Uri uri = intent.getData();
+                if (uri == null) {
+                    return;
+                }
+                String pkgName = uri.getSchemeSpecificPart();
+                if (pkgName == null) {
+                    return;
+                }
+                
+                if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
+                    synchronized (mGadgetIds) {
+                        addProvidersForPackageLocked(pkgName);
+                        saveStateLocked();
+                    }
+                }
+                else if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {
+                    synchronized (mGadgetIds) {
+                        updateProvidersForPackageLocked(pkgName);
+                        saveStateLocked();
+                    }
+                }
+                else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
+                    synchronized (mGadgetIds) {
+                        removeProvidersForPackageLocked(pkgName);
+                        saveStateLocked();
+                    }
+                }
+            }
+        }
+    };
+
+    // TODO: If there's a better way of matching an intent filter against the
+    // packages for a given package, use that.
+    void addProvidersForPackageLocked(String pkgName) {
+        Intent intent = new Intent(GadgetManager.GADGET_UPDATE_ACTION);
+        List<ResolveInfo> broadcastReceivers = mPackageManager.queryBroadcastReceivers(intent,
+                PackageManager.GET_META_DATA);
+
+        final int N = broadcastReceivers.size();
+        for (int i=0; i<N; i++) {
+            ResolveInfo ri = broadcastReceivers.get(i);
+            ActivityInfo ai = ri.activityInfo;
+            
+            if (pkgName.equals(ai.packageName)) {
+                addProviderLocked(ri);
+            }
+        }
+    }
+
+    // TODO: If there's a better way of matching an intent filter against the
+    // packages for a given package, use that.
+    void updateProvidersForPackageLocked(String pkgName) {
+        HashSet<String> keep = new HashSet();
+        Intent intent = new Intent(GadgetManager.GADGET_UPDATE_ACTION);
+        List<ResolveInfo> broadcastReceivers = mPackageManager.queryBroadcastReceivers(intent,
+                PackageManager.GET_META_DATA);
+
+        // add the missing ones and collect which ones to keep
+        int N = broadcastReceivers.size();
+        for (int i=0; i<N; i++) {
+            ResolveInfo ri = broadcastReceivers.get(i);
+            ActivityInfo ai = ri.activityInfo;
+            if (pkgName.equals(ai.packageName)) {
+                Provider p = lookupProviderLocked(new ComponentName(ai.packageName, ai.name));
+                if (p == null) {
+                    addProviderLocked(ri);
+                }
+                keep.add(ai.name);
+            }
+        }
+
+        // prune the ones we don't want to keep
+        N = mInstalledProviders.size();
+        for (int i=0; i<N; i++) {
+            Provider p = mInstalledProviders.get(i);
+            if (pkgName.equals(p.info.provider.getPackageName())
+                    && !keep.contains(p.info.provider.getClassName())) {
+                removeProviderLocked(i, p);
+            }
+        }
+    }
+
+    void removeProvidersForPackageLocked(String pkgName) {
+        int N = mInstalledProviders.size();
+        for (int i=0; i<N; i++) {
+            Provider p = mInstalledProviders.get(i);
+            if (pkgName.equals(p.info.provider.getPackageName())) {
+                removeProviderLocked(i, p);
+            }
+        }
+
+        // Delete the hosts for this package too
+        //
+        // By now, we have removed any gadgets that were in any hosts here,
+        // so we don't need to worry about sending DISABLE broadcasts to them.
+        N = mHosts.size();
+        for (int i=0; i<N; i++) {
+            Host host = mHosts.get(i);
+            if (pkgName.equals(host.packageName)) {
+                deleteHostLocked(host);
+            }
+        }
     }
 }
 
diff --git a/services/java/com/android/server/HardwareService.java b/services/java/com/android/server/HardwareService.java
index 22ad7bd..40456ff 100755
--- a/services/java/com/android/server/HardwareService.java
+++ b/services/java/com/android/server/HardwareService.java
@@ -35,6 +35,10 @@
     private static final String TAG = "HardwareService";
 
     HardwareService(Context context) {
+        // Reset the hardware to a default state, in case this is a runtime
+        // restart instead of a fresh boot.
+        vibratorOff();
+
         mContext = context;
         PowerManager pm = (PowerManager)context.getSystemService(
                 Context.POWER_SERVICE);
@@ -201,7 +205,7 @@
                     mThread.notify();
                 }
                 mThread = null;
-                off();
+                vibratorOff();
             }
         }
     }
@@ -217,49 +221,65 @@
             mWakeLock.acquire();
         }
 
+        private void delay(long duration) {
+            if (duration > 0) {
+                long bedtime = SystemClock.uptimeMillis();
+                do {
+                    try {
+                        this.wait(duration);
+                    }
+                    catch (InterruptedException e) {
+                    }
+                    if (mDone) {
+                        break;
+                    }
+                    duration = duration
+                            - SystemClock.uptimeMillis() - bedtime;
+                } while (duration > 0);
+            }
+        }
+
         public void run() {
             synchronized (this) {
                 int index = 0;
-                boolean nextState = false;
                 long[] pattern = mPattern;
-                if (pattern[0] == 0) {
-                    index++;
-                    nextState = true;
-                }
                 int len = pattern.length;
-                long start = SystemClock.uptimeMillis();
+                long duration = 0;
 
                 while (!mDone) {
-                    if (nextState) {
-                        HardwareService.this.on();
-                    } else {
-                        HardwareService.this.off();
+                    // add off-time duration to any accumulated on-time duration 
+                    if (index < len) {
+                        duration += pattern[index++];
                     }
-                    nextState = !nextState;
-                    long bedtime = SystemClock.uptimeMillis();
-                    long duration = pattern[index];
-                    do {
-                        try {
-                            this.wait(duration);
+
+                    // sleep until it is time to start the vibrator
+                    delay(duration);
+                    if (mDone) {
+                        break;
+                    }
+
+                    if (index < len) {
+                        // read on-time duration and start the vibrator
+                        // duration is saved for delay() at top of loop
+                        duration = pattern[index++];
+                        if (duration > 0) {
+                            HardwareService.this.vibratorOn(duration);
                         }
-                        catch (InterruptedException e) {
-                        }
-                        if (mDone) {
-                            break;
-                        }
-                        duration = duration
-                                - SystemClock.uptimeMillis() - bedtime;
-                    } while (duration > 0);
-                    index++;
-                    if (index >= len) {
+                    } else {
                         if (mRepeat < 0) {
-                            HardwareService.this.off();
                             break;
                         } else {
                             index = mRepeat;
+                            duration = 0;
                         }
                     }
                 }
+                if (mDone) {
+                    // make sure vibrator is off if we were cancelled.
+                    // otherwise, it will turn off automatically 
+                    // when the last timeout expires.
+                    HardwareService.this.vibratorOff();
+                }
                 mWakeLock.release();
             }
             synchronized (HardwareService.this) {
@@ -301,6 +321,6 @@
     volatile Death mDeath;
     volatile IBinder mToken;
 
-    native static void on();
-    native static void off();
+    native static void vibratorOn(long milliseconds);
+    native static void vibratorOff();
 }
diff --git a/services/java/com/android/server/HeadsetObserver.java b/services/java/com/android/server/HeadsetObserver.java
index 2bea731..855734d 100644
--- a/services/java/com/android/server/HeadsetObserver.java
+++ b/services/java/com/android/server/HeadsetObserver.java
@@ -19,6 +19,8 @@
 import android.app.ActivityManagerNative;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Handler;
+import android.os.Message;
 import android.os.UEventObserver;
 import android.util.Log;
 import android.media.AudioManager;
@@ -40,6 +42,8 @@
 
     private int mHeadsetState;
     private String mHeadsetName;
+    private boolean mAudioRouteNeedsUpdate;
+    private AudioManager mAudioManager;
 
     public HeadsetObserver(Context context) {
         mContext = context;
@@ -60,7 +64,7 @@
         }
     }
 
-    private final void init() {
+    private synchronized final void init() {
         char[] buffer = new char[1024];
 
         String newName = mHeadsetName;
@@ -80,21 +84,33 @@
             Log.e(TAG, "" , e);
         }
 
+        mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
         update(newName, newState);
     }
 
     private synchronized final void update(String newName, int newState) {
         if (newName != mHeadsetName || newState != mHeadsetState) {
+            boolean isUnplug = (newState == 0 && mHeadsetState == 1);
             mHeadsetName = newName;
             mHeadsetState = newState;
-            AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+            mAudioRouteNeedsUpdate = true;
 
-            audioManager.setWiredHeadsetOn(mHeadsetState == 1);
-            sendIntent();
+            sendIntent(isUnplug);
+
+            if (isUnplug) {
+                // It often takes >200ms to flush the audio pipeline after apps
+                // pause audio playback, but audio route changes are immediate,
+                // so delay the route change by 400ms.
+                // This could be improved once the audio sub-system provides an
+                // interface to clear the audio pipeline.
+                mHandler.sendEmptyMessageDelayed(0, 400);
+            } else {
+                updateAudioRoute();
+            }
         }
     }
 
-    private synchronized final void sendIntent() {
+    private synchronized final void sendIntent(boolean isUnplug) {
         //  Pack up the values and broadcast them to everyone
         Intent intent = new Intent(Intent.ACTION_HEADSET_PLUG);
         intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
@@ -104,5 +120,25 @@
 
         // TODO: Should we require a permission?
         ActivityManagerNative.broadcastStickyIntent(intent, null);
+
+        if (isUnplug) {
+            intent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
+            mContext.sendBroadcast(intent);
+        }
     }
+
+    private synchronized final void updateAudioRoute() {
+        if (mAudioRouteNeedsUpdate) {
+            mAudioManager.setWiredHeadsetOn(mHeadsetState == 1);
+            mAudioRouteNeedsUpdate = false;
+        }
+    }
+
+    private final Handler mHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            updateAudioRoute();
+        }
+    };        
+
 }
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 139aaa3..ee49365 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -30,6 +30,7 @@
 
 import org.xmlpull.v1.XmlPullParserException;
 
+import android.app.ActivityManagerNative;
 import android.app.AlertDialog;
 import android.content.ComponentName;
 import android.content.ContentResolver;
@@ -61,7 +62,6 @@
 import android.util.Printer;
 import android.view.IWindowManager;
 import android.view.WindowManager;
-import android.view.inputmethod.DefaultInputMethod;
 import android.view.inputmethod.InputBinding;
 import android.view.inputmethod.InputMethod;
 import android.view.inputmethod.InputMethodInfo;
@@ -189,6 +189,11 @@
     ClientState mCurClient;
     
     /**
+     * The input context last provided by the current client.
+     */
+    IInputContext mCurInputContext;
+    
+    /**
      * The attributes last provided by the current client.
      */
     EditorInfo mCurAttribute;
@@ -216,6 +221,11 @@
     boolean mShowExplicitlyRequested;
     
     /**
+     * Set if we were forced to be shown.
+     */
+    boolean mShowForced;
+    
+    /**
      * Set if we last told the input method to show itself.
      */
     boolean mInputShown;
@@ -281,7 +291,7 @@
             } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
                 mScreenOn = false;
             } else {
-                Log.e(TAG, "Unexpected intent " + intent);
+                Log.w(TAG, "Unexpected intent " + intent);
             }
 
             // Inform the current client of the change in active status
@@ -290,7 +300,8 @@
                     mCurClient.client.setActive(mScreenOn);
                 }
             } catch (RemoteException e) {
-                Log.e(TAG, "Got RemoteException sending 'screen on/off' notification", e);
+                Log.w(TAG, "Got RemoteException sending 'screen on/off' notification to pid "
+                        + mCurClient.pid + " uid " + mCurClient.uid);
             }
         }
     }
@@ -553,12 +564,24 @@
             try {
                 mCurClient.client.setActive(false);
             } catch (RemoteException e) {
-                Log.e(TAG, "Got RemoteException sending setActive(false) notification", e);
+                Log.w(TAG, "Got RemoteException sending setActive(false) notification to pid "
+                        + mCurClient.pid + " uid " + mCurClient.uid);
             }
             mCurClient = null;
         }
     }
     
+    private int getShowFlags() {
+        int flags = 0;
+        if (mShowForced) {
+            flags |= InputMethod.SHOW_FORCED
+                    | InputMethod.SHOW_EXPLICIT;
+        } else if (mShowExplicitlyRequested) {
+            flags |= InputMethod.SHOW_EXPLICIT;
+        }
+        return flags;
+    }
+    
     InputBindResult attachNewInputLocked(boolean initial, boolean needResult) {
         if (!mBoundToMethod) {
             executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO(
@@ -567,16 +590,15 @@
         }
         final SessionState session = mCurClient.curSession;
         if (initial) {
-            executeOrSendMessage(session.method, mCaller.obtainMessageOO(
-                    MSG_START_INPUT, session, mCurAttribute));
+            executeOrSendMessage(session.method, mCaller.obtainMessageOOO(
+                    MSG_START_INPUT, session, mCurInputContext, mCurAttribute));
         } else {
-            executeOrSendMessage(session.method, mCaller.obtainMessageOO(
-                    MSG_RESTART_INPUT, session, mCurAttribute));
+            executeOrSendMessage(session.method, mCaller.obtainMessageOOO(
+                    MSG_RESTART_INPUT, session, mCurInputContext, mCurAttribute));
         }
         if (mShowRequested) {
             if (DEBUG) Log.v(TAG, "Attach new input asks to show input");
-            showCurrentInputLocked(mShowExplicitlyRequested
-                    ? 0 : InputMethodManager.SHOW_IMPLICIT);
+            showCurrentInputLocked(getShowFlags());
         }
         return needResult
                 ? new InputBindResult(session.session, mCurId, mCurSeq)
@@ -584,7 +606,8 @@
     }
     
     InputBindResult startInputLocked(IInputMethodClient client,
-            EditorInfo attribute, boolean initial, boolean needResult) {
+            IInputContext inputContext, EditorInfo attribute,
+            boolean initial, boolean needResult) {
         // If no method is currently selected, do nothing.
         if (mCurMethodId == null) {
             return mNoBinding;
@@ -622,7 +645,8 @@
                 try {
                     cs.client.setActive(mScreenOn);
                 } catch (RemoteException e) {
-                    Log.e(TAG, "Got RemoteException sending setActive notification", e);
+                    Log.w(TAG, "Got RemoteException sending setActive notification to pid "
+                            + cs.pid + " uid " + cs.uid);
                 }
             }
         }
@@ -631,6 +655,7 @@
         mCurSeq++;
         if (mCurSeq <= 0) mCurSeq = 1;
         mCurClient = cs;
+        mCurInputContext = inputContext;
         mCurAttribute = attribute;
         
         // Check if the input method is changing.
@@ -659,6 +684,7 @@
         
         if (mCurToken != null) {
             try {
+                if (DEBUG) Log.v(TAG, "Removing window token: " + mCurToken);
                 mIWindowManager.removeWindowToken(mCurToken);
             } catch (RemoteException e) {
             }
@@ -679,6 +705,7 @@
             mCurId = info.getId();
             mCurToken = new Binder();
             try {
+                if (DEBUG) Log.v(TAG, "Adding window token: " + mCurToken);
                 mIWindowManager.addWindowToken(mCurToken,
                         WindowManager.LayoutParams.TYPE_INPUT_METHOD);
             } catch (RemoteException e) {
@@ -686,18 +713,20 @@
             return new InputBindResult(null, mCurId, mCurSeq);
         } else {
             mCurIntent = null;
-            Log.e(TAG, "Failure connecting to input method service: "
+            Log.w(TAG, "Failure connecting to input method service: "
                     + mCurIntent);
         }
         return null;
     }
     
     public InputBindResult startInput(IInputMethodClient client,
-            EditorInfo attribute, boolean initial, boolean needResult) {
+            IInputContext inputContext, EditorInfo attribute,
+            boolean initial, boolean needResult) {
         synchronized (mMethodMap) {
             final long ident = Binder.clearCallingIdentity();
             try {
-                return startInputLocked(client, attribute, initial, needResult);
+                return startInputLocked(client, inputContext, attribute,
+                        initial, needResult);
             } finally {
                 Binder.restoreCallingIdentity(ident);
             }
@@ -712,6 +741,7 @@
             if (mCurIntent != null && name.equals(mCurIntent.getComponent())) {
                 mCurMethod = IInputMethod.Stub.asInterface(service);
                 if (mCurClient != null) {
+                    if (DEBUG) Log.v(TAG, "Initiating attach with token: " + mCurToken);
                     executeOrSendMessage(mCurMethod, mCaller.obtainMessageOO(
                             MSG_ATTACH_TOKEN, mCurMethod, mCurToken));
                     if (mCurClient != null) {
@@ -817,10 +847,12 @@
             mCurMethodId = id;
             Settings.Secure.putString(mContext.getContentResolver(),
                 Settings.Secure.DEFAULT_INPUT_METHOD, id);
-                    
-            Intent intent = new Intent(Intent.ACTION_INPUT_METHOD_CHANGED);
-            intent.putExtra("input_method_id", id);
-            mContext.sendBroadcast(intent);
+
+            if (ActivityManagerNative.isSystemReady()) {
+                Intent intent = new Intent(Intent.ACTION_INPUT_METHOD_CHANGED);
+                intent.putExtra("input_method_id", id);
+                mContext.sendBroadcast(intent);
+            }
             unbindCurrentInputLocked();
         } finally {
             Binder.restoreCallingIdentity(ident);
@@ -853,10 +885,13 @@
         if ((flags&InputMethodManager.SHOW_IMPLICIT) == 0) {
             mShowExplicitlyRequested = true;
         }
+        if ((flags&InputMethodManager.SHOW_FORCED) != 0) {
+            mShowExplicitlyRequested = true;
+            mShowForced = true;
+        }
         if (mCurMethod != null) {
             executeOrSendMessage(mCurMethod, mCaller.obtainMessageIO(
-                    MSG_SHOW_SOFT_INPUT, mShowExplicitlyRequested ? 1 : 0,
-                            mCurMethod));
+                    MSG_SHOW_SOFT_INPUT, getShowFlags(), mCurMethod));
             mInputShown = true;
         }
     }
@@ -884,11 +919,16 @@
     
     void hideCurrentInputLocked(int flags) {
         if ((flags&InputMethodManager.HIDE_IMPLICIT_ONLY) != 0
-                && mShowExplicitlyRequested) {
+                && (mShowExplicitlyRequested || mShowForced)) {
             if (DEBUG) Log.v(TAG,
                     "Not hiding: explicit show not cancelled by non-explicit hide");
             return;
         }
+        if (mShowForced && (flags&InputMethodManager.HIDE_NOT_ALWAYS) != 0) {
+            if (DEBUG) Log.v(TAG,
+                    "Not hiding: forced show not cancelled by not-always hide");
+            return;
+        }
         if (mInputShown && mCurMethod != null) {
             executeOrSendMessage(mCurMethod, mCaller.obtainMessageO(
                     MSG_HIDE_SOFT_INPUT, mCurMethod));
@@ -896,6 +936,7 @@
         mInputShown = false;
         mShowRequested = false;
         mShowExplicitlyRequested = false;
+        mShowForced = false;
     }
     
     public void windowGainedFocus(IInputMethodClient client,
@@ -933,7 +974,7 @@
                             // be behind any soft input window, so hide the
                             // soft input window if it is shown.
                             if (DEBUG) Log.v(TAG, "Unspecified window will hide input");
-                            hideCurrentInputLocked(0);
+                            hideCurrentInputLocked(InputMethodManager.HIDE_NOT_ALWAYS);
                         }
                     } else if (isTextEditor && (softInputMode &
                             WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST)
@@ -1052,7 +1093,7 @@
                 return true;
             case MSG_SHOW_SOFT_INPUT:
                 try {
-                    ((IInputMethod)msg.obj).showSoftInput(msg.arg1 != 0);
+                    ((IInputMethod)msg.obj).showSoftInput(msg.arg1);
                 } catch (RemoteException e) {
                 }
                 return true;
@@ -1065,6 +1106,7 @@
             case MSG_ATTACH_TOKEN:
                 args = (HandlerCaller.SomeArgs)msg.obj;
                 try {
+                    if (DEBUG) Log.v(TAG, "Sending attach of token: " + args.arg2);
                     ((IInputMethod)args.arg1).attachToken((IBinder)args.arg2);
                 } catch (RemoteException e) {
                 }
@@ -1085,7 +1127,8 @@
                 try {
                     SessionState session = (SessionState)args.arg1;
                     setEnabledSessionInMainThread(session);
-                    session.method.startInput((EditorInfo)args.arg2);
+                    session.method.startInput((IInputContext)args.arg2,
+                            (EditorInfo)args.arg3);
                 } catch (RemoteException e) {
                 }
                 return true;
@@ -1094,7 +1137,8 @@
                 try {
                     SessionState session = (SessionState)args.arg1;
                     setEnabledSessionInMainThread(session);
-                    session.method.restartInput((EditorInfo)args.arg2);
+                    session.method.restartInput((IInputContext)args.arg2,
+                            (EditorInfo)args.arg3);
                 } catch (RemoteException e) {
                 }
                 return true;
@@ -1128,10 +1172,6 @@
         
         PackageManager pm = mContext.getPackageManager();
 
-        Object[][] buildin = {{
-                DefaultInputMethod.class.getName(),
-                DefaultInputMethod.getMetaInfo()}};
-
         List<ResolveInfo> services = pm.queryIntentServices(
                 new Intent(InputMethod.SERVICE_INTERFACE),
                 PackageManager.GET_META_DATA);
@@ -1150,39 +1190,6 @@
 
             if (DEBUG) Log.d(TAG, "Checking " + compName);
 
-            /* Built-in input methods are not currently supported... this will
-             * need to be reworked to bring them back (all input methods must
-             * now be published in a manifest).
-             */
-            /*
-            if (compName.getPackageName().equals(
-                    InputMethodManager.BUILDIN_INPUTMETHOD_PACKAGE)) {
-                // System build-in input methods;
-                String inputMethodName = null;
-                int kbType = 0;
-                String skbName = null;
-
-                for (int j = 0; j < buildin.length; ++j) {
-                    Object[] obj = buildin[j];
-                    if (compName.getClassName().equals(obj[0])) {
-                        InputMethodMetaInfo imp = (InputMethodMetaInfo) obj[1];
-                        inputMethodName = imp.inputMethodName;
-                    }
-                }
-
-                InputMethodMetaInfo p = new InputMethodMetaInfo(compName,
-                        inputMethodName, "");
-
-                list.add(p);
-
-                if (DEBUG) {
-                    Log.d(TAG, "Found a build-in input method " + p);
-                }
-
-                continue;
-            }
-            */
-
             try {
                 InputMethodInfo p = new InputMethodInfo(mContext, ri);
                 list.add(p);
@@ -1386,7 +1393,7 @@
     
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission("android.permission.DUMP")
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             
             pw.println("Permission Denial: can't dump InputMethodManager from from pid="
@@ -1395,8 +1402,12 @@
             return;
         }
 
+        IInputMethod method;
+        ClientState client;
+        
+        final Printer p = new PrintWriterPrinter(pw);
+        
         synchronized (mMethodMap) {
-            final Printer p = new PrintWriterPrinter(pw);
             p.println("Current Input Method Manager state:");
             int N = mMethodList.size();
             p.println("  Input Methods:");
@@ -1416,17 +1427,40 @@
             p.println("  mInputMethodIcon=" + mInputMethodIcon);
             p.println("  mInputMethodData=" + mInputMethodData);
             p.println("  mCurrentMethod=" + mCurMethodId);
-            p.println("  mCurSeq=" + mCurSeq + " mCurClient=" + mCurClient);
+            client = mCurClient;
+            p.println("  mCurSeq=" + mCurSeq + " mCurClient=" + client);
             p.println("  mCurId=" + mCurId + " mHaveConnect=" + mHaveConnection
                     + " mBoundToMethod=" + mBoundToMethod);
             p.println("  mCurToken=" + mCurToken);
             p.println("  mCurIntent=" + mCurIntent);
+            method = mCurMethod;
             p.println("  mCurMethod=" + mCurMethod);
             p.println("  mEnabledSession=" + mEnabledSession);
             p.println("  mShowRequested=" + mShowRequested
                     + " mShowExplicitlyRequested=" + mShowExplicitlyRequested
+                    + " mShowForced=" + mShowForced
                     + " mInputShown=" + mInputShown);
             p.println("  mScreenOn=" + mScreenOn);
         }
+        
+        if (client != null) {
+            p.println(" ");
+            pw.flush();
+            try {
+                client.client.asBinder().dump(fd, args);
+            } catch (RemoteException e) {
+                p.println("Input method client dead: " + e);
+            }
+        }
+        
+        if (method != null) {
+            p.println(" ");
+            pw.flush();
+            try {
+                method.asBinder().dump(fd, args);
+            } catch (RemoteException e) {
+                p.println("Input method service dead: " + e);
+            }
+        }
     }
 }
diff --git a/services/java/com/android/server/KeyInputQueue.java b/services/java/com/android/server/KeyInputQueue.java
index 9874042..63b486c 100644
--- a/services/java/com/android/server/KeyInputQueue.java
+++ b/services/java/com/android/server/KeyInputQueue.java
@@ -165,6 +165,7 @@
     public static native int getScancodeState(int deviceId, int sw);
     public static native int getKeycodeState(int sw);
     public static native int getKeycodeState(int deviceId, int sw);
+    public static native boolean hasKeys(int[] keycodes, boolean[] keyExists);
     
     public static KeyEvent newKeyEvent(InputDevice device, long downTime,
             long eventTime, boolean down, int keycode, int repeatCount,
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index ed9ee79..bc6fd71 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -64,12 +64,14 @@
 import android.util.Config;
 import android.util.Log;
 
+import com.android.internal.app.IBatteryStats;
 import com.android.internal.location.CellState;
 import com.android.internal.location.GpsLocationProvider;
-import com.android.internal.location.LocationCollector;
-import com.android.internal.location.LocationMasfClient;
-import com.android.internal.location.NetworkLocationProvider;
+import com.android.internal.location.ILocationCollector;
+import com.android.internal.location.INetworkLocationManager;
+import com.android.internal.location.INetworkLocationProvider;
 import com.android.internal.location.TrackProvider;
+import com.android.server.am.BatteryStatsService;
 
 /**
  * The service class that manages LocationProviders and issues location
@@ -77,7 +79,8 @@
  *
  * {@hide}
  */
-public class LocationManagerService extends ILocationManager.Stub {
+public class LocationManagerService extends ILocationManager.Stub
+        implements INetworkLocationManager {
     private static final String TAG = "LocationManagerService";
 
     // Minimum time interval between last known location writes, in milliseconds.
@@ -121,13 +124,15 @@
 
     private final Context mContext;
     private GpsLocationProvider mGpsLocationProvider;
-    private NetworkLocationProvider mNetworkLocationProvider;
+    private LocationProviderImpl mNetworkLocationProvider;
+    private INetworkLocationProvider mNetworkLocationInterface;
     private LocationWorkerHandler mLocationHandler;
 
     // Handler messages
     private static final int MESSAGE_HEARTBEAT = 1;
     private static final int MESSAGE_ACQUIRE_WAKE_LOCK = 2;
     private static final int MESSAGE_RELEASE_WAKE_LOCK = 3;
+    private static final int MESSAGE_SET_NETWORK_LOCATION_PROVIDER = 4;
 
     // Alarm manager and wakelock variables
     private final static String ALARM_INTENT = "com.android.location.ALARM_INTENT";
@@ -143,6 +148,11 @@
     private boolean mWakeLockNetworkReceived = true;
     private boolean mWifiWakeLockAcquired = false;
     private boolean mCellWakeLockAcquired = false;
+    
+    private final IBatteryStats mBatteryStats;
+    
+    // The calling UID when we are in a clearCallingIdentity/restoreCallingIdentity block, or -1
+    private int mCallingUid = -1;
 
     /**
      * Mapping from listener IBinder/PendingIntent to local Listener wrappers.
@@ -199,10 +209,7 @@
     private int mSignalStrength = -1;
 
     // Location collector
-    private LocationCollector mCollector;
-
-    // Location MASF service
-    private LocationMasfClient mMasfClient;
+    private ILocationCollector mCollector;
 
     // Wifi Manager
     private WifiManager mWifiManager;
@@ -417,15 +424,9 @@
 
     private void _loadProvidersNoSync() {
         // Attempt to load "real" providers first
-        if (NetworkLocationProvider.isSupported()) {
-            // Create a network location provider
-            mNetworkLocationProvider = new NetworkLocationProvider(mContext, mMasfClient);
-            LocationProviderImpl.addProvider(mNetworkLocationProvider);
-        }
-
         if (GpsLocationProvider.isSupported()) {
             // Create a gps location provider
-            mGpsLocationProvider = new GpsLocationProvider(mContext, mCollector);
+            mGpsLocationProvider = new GpsLocationProvider(mContext);
             LocationProviderImpl.addProvider(mGpsLocationProvider);
         }
 
@@ -509,18 +510,15 @@
             Log.d(TAG, "Constructed LocationManager Service");
         }
 
-        // Initialize the LocationMasfClient
-        mMasfClient = new LocationMasfClient(mContext);
-
-        // Create location collector
-        mCollector = new LocationCollector(mMasfClient);
-
         // Alarm manager, needs to be done before calling loadProviders() below
         mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
 
         // Create a wake lock, needs to be done before calling loadProviders() below
         PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
         mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY);
+        
+        // Battery statistics service to be notified when GPS turns on or off
+        mBatteryStats = BatteryStatsService.getService();
 
         // Load providers
         loadProviders();
@@ -560,13 +558,27 @@
         if (mWifiManager != null) {
             List<ScanResult> wifiScanResults = mWifiManager.getScanResults();
             if (wifiScanResults != null && wifiScanResults.size() != 0) {
-                if (mNetworkLocationProvider != null) {
-                    mNetworkLocationProvider.updateWifiScanResults(wifiScanResults);
+                if (mNetworkLocationInterface != null) {
+                    mNetworkLocationInterface.updateWifiScanResults(wifiScanResults);
                 }
             }
         }
     }
 
+    public void setNetworkLocationProvider(INetworkLocationProvider provider) {
+        mLocationHandler.removeMessages(MESSAGE_SET_NETWORK_LOCATION_PROVIDER);
+        Message m = Message.obtain(mLocationHandler, 
+                MESSAGE_SET_NETWORK_LOCATION_PROVIDER, provider);
+        mLocationHandler.sendMessageAtFrontOfQueue(m);
+    }
+
+    public void setLocationCollector(ILocationCollector collector) {
+        mCollector = collector;
+        if (mGpsLocationProvider != null) {
+                mGpsLocationProvider.setLocationCollector(mCollector);
+        }
+    }
+
     private WifiManager.WifiLock getWifiWakelock() {
         if (mWifiLock == null && mWifiManager != null) {
             mWifiLock = mWifiManager.createWifiLock(WifiManager.WIFI_MODE_SCAN_ONLY, WIFILOCK_KEY);
@@ -690,7 +702,8 @@
             boolean shouldBeEnabled = isAllowedBySettings(name);
 
             // Collection is only allowed when network provider is being used
-            if (p.getName().equals(LocationManager.NETWORK_PROVIDER)) {
+            if (mCollector != null &&
+                    p.getName().equals(LocationManager.NETWORK_PROVIDER)) {
                 mCollector.updateNetworkProviderStatus(shouldBeEnabled);
             }
 
@@ -847,7 +860,7 @@
         }
     }
 
-    private void _requestLocationUpdates(String provider,
+    private synchronized void _requestLocationUpdates(String provider,
             long minTime, float minDistance, Receiver receiver) {
         Object key = receiver.getKey();
         if (Config.LOGD) {
@@ -864,6 +877,7 @@
         String[] packages = getPackageNames();
 
         // so wakelock calls will succeed
+        mCallingUid = getCallingUid();
         long identity = Binder.clearCallingIdentity();
         try {
             UpdateRecord r = new UpdateRecord(provider, minTime, minDistance, receiver, packages);
@@ -889,12 +903,16 @@
                     oldRecord.dispose();
                 }
 
-                if (impl instanceof NetworkLocationProvider) {
-                    ((NetworkLocationProvider) impl).addListener(packages);
-                }
-
                 boolean isProviderEnabled = isAllowedBySettings(provider);
                 if (isProviderEnabled) {
+                    if (provider.equals(LocationManager.GPS_PROVIDER)) {
+                        try {
+                            mBatteryStats.noteRequestGpsOn(mCallingUid);
+                        } catch (RemoteException e) {
+                            Log.w(TAG, "Got RemoteException calling noteRequestGpsOff", e);
+                        }
+                    }
+                    
                     long minTimeForProvider = getMinTime(provider);
                     impl.setMinTime(minTimeForProvider);
                     impl.enableLocationTracking(true);
@@ -904,7 +922,6 @@
                     mLocationHandler.removeMessages(MESSAGE_HEARTBEAT, provider);
                     Message m = Message.obtain(mLocationHandler, MESSAGE_HEARTBEAT, provider);
                     mLocationHandler.sendMessageAtTime(m, SystemClock.uptimeMillis() + 1000);
-
                 } else {
                     try {
                         // Notify the listener that updates are currently disabled
@@ -919,6 +936,7 @@
             }
         } finally {
             Binder.restoreCallingIdentity(identity);
+            mCallingUid = -1;
         }
     }
 
@@ -942,13 +960,14 @@
         }
     }
 
-    private void _removeUpdates(Receiver receiver) {
+    private synchronized void _removeUpdates(Receiver receiver) {
         Object key = receiver.getKey();
         if (Config.LOGD) {
             Log.d(TAG, "_removeUpdates: listener = " + key);
         }
 
         // so wakelock calls will succeed
+        mCallingUid = getCallingUid();
         long identity = Binder.clearCallingIdentity();
         try {
             synchronized (mLocationListeners) {
@@ -964,8 +983,8 @@
                     // Call dispose() on the obsolete update records.
                     for (UpdateRecord record : oldRecords.values()) {
                         if (record.mProvider.equals(LocationManager.NETWORK_PROVIDER)) {
-                            if (mNetworkLocationProvider != null) {
-                                mNetworkLocationProvider.removeListener(record.mPackages);
+                            if (mNetworkLocationInterface != null) {
+                                mNetworkLocationInterface.removeListener(record.mPackages);
                             }
                         }
                         record.dispose();
@@ -973,6 +992,14 @@
                     // Accumulate providers
                     providers.addAll(oldRecords.keySet());
                 }
+                
+                if (providers.contains("gps")) {
+                    try {
+                        mBatteryStats.noteRequestGpsOff(mCallingUid);
+                    } catch (RemoteException e) {
+                        Log.w(TAG, "Got RemoteException calling noteRequestGpsOff", e);
+                    }
+                }
 
                 mLocationListeners.remove(key);
                 mLastFixBroadcast.remove(key);
@@ -1010,6 +1037,7 @@
             }
         } finally {
             Binder.restoreCallingIdentity(identity);
+            mCallingUid = -1;
         }
     }
 
@@ -1426,7 +1454,7 @@
             }
             writeLastKnownLocation(provider, loc);
 
-            if (p instanceof NetworkLocationProvider) {
+            if (p instanceof INetworkLocationProvider) {
                 mWakeLockNetworkReceived = true;
             } else if (p instanceof GpsLocationProvider) {
                 // Gps location received signal is in NetworkStateBroadcastReceiver
@@ -1570,6 +1598,17 @@
                     // Update wakelock status so the next alarm is set before releasing wakelock
                     updateWakelockStatus(mScreenOn);
                     releaseWakeLock();
+                } else if (msg.what == MESSAGE_SET_NETWORK_LOCATION_PROVIDER) {
+                    synchronized (LocationManagerService.class) {
+                        Log.d(TAG, "adding network location provider");
+                        mNetworkLocationInterface = 
+                                (INetworkLocationProvider)msg.obj;
+                        mNetworkLocationInterface.addListener(getPackageNames());
+                        mNetworkLocationProvider = 
+                                (LocationProviderImpl)mNetworkLocationInterface;
+                        LocationProviderImpl.addProvider(mNetworkLocationProvider);
+                        updateProviders();
+                    }
                 }
             } catch (Exception e) {
                 // Log, don't crash!
@@ -1590,7 +1629,9 @@
                 mLastCellState = new CellState(mTelephonyManager, cellLocation, asu);
 
                 // Notify collector
-                mCollector.updateCellState(mLastCellState);
+                if (mCollector != null) {
+                    mCollector.updateCellState(mLastCellState);
+                }
 
                 // Updates providers
                 List<LocationProviderImpl> providers = LocationProviderImpl.getProviders();
@@ -1648,7 +1689,9 @@
                 boolean plugged = intent.getIntExtra(BATTERY_EXTRA_PLUGGED, 0) != 0;
 
                 // Notify collector battery state
-                mCollector.updateBatteryState(scale, level, plugged);
+                if (mCollector != null) {
+                    mCollector.updateBatteryState(scale, level, plugged);
+                }
             }
         }
     }
@@ -1666,9 +1709,11 @@
                 }
 
                 // Notify provider and collector of Wifi scan results
-                mCollector.updateWifiScanResults(wifiScanResults);
-                if (mNetworkLocationProvider != null) {
-                    mNetworkLocationProvider.updateWifiScanResults(wifiScanResults);
+                if (mCollector != null) {
+                    mCollector.updateWifiScanResults(wifiScanResults);
+                }
+                if (mNetworkLocationInterface != null) {
+                    mNetworkLocationInterface.updateWifiScanResults(wifiScanResults);
                 }
 
             } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
@@ -1702,8 +1747,8 @@
                 }
 
                 // Notify network provider of current wifi enabled state
-                if (mNetworkLocationProvider != null) {
-                    mNetworkLocationProvider.updateWifiEnabledState(enabled);
+                if (mNetworkLocationInterface != null) {
+                    mNetworkLocationInterface.updateWifiEnabledState(enabled);
                 }
 
             } else if (action.equals(GpsLocationProvider.GPS_ENABLED_CHANGE_ACTION)) {
@@ -1821,8 +1866,8 @@
         }
 
         // Notify NetworkLocationProvider
-        if (mNetworkLocationProvider != null) {
-            mNetworkLocationProvider.updateCellLockStatus(mCellWakeLockAcquired);
+        if (mNetworkLocationInterface != null) {
+            mNetworkLocationInterface.updateCellLockStatus(mCellWakeLockAcquired);
         }
 
         // Acquire wifi lock
@@ -1845,6 +1890,14 @@
                     && mGpsLocationProvider.isLocationTracking();
         if (gpsActive) {
             mGpsLocationProvider.startNavigating();
+            long identity = Binder.clearCallingIdentity();
+            try {
+                mBatteryStats.noteStartGps(mCallingUid == -1 ? getCallingUid() : mCallingUid);
+            } catch (RemoteException e) {
+                Log.w(TAG, "RemoteException calling noteStartGps on BatteryStatsService", e);
+            } finally {
+                Binder.restoreCallingIdentity(identity);
+            }
         }
     }
 
@@ -1853,6 +1906,14 @@
                     && mGpsLocationProvider.isLocationTracking();
         if (gpsActive) {
             mGpsLocationProvider.stopNavigating();
+            long identity = Binder.clearCallingIdentity();
+            try {
+                mBatteryStats.noteStopGps(mCallingUid == -1 ? getCallingUid() : mCallingUid);
+            } catch (RemoteException e) {
+                Log.w(TAG, "RemoteException calling noteStopGps on BatteryStatsService", e);
+            } finally {
+                Binder.restoreCallingIdentity(identity);
+            }
         }
     }
 
@@ -1877,7 +1938,6 @@
         }
 
         if (!mScreenOn) {
-
             // Stop the gps
             stopGps();
         }
@@ -1889,8 +1949,8 @@
         }
 
         // Notify NetworkLocationProvider
-        if (mNetworkLocationProvider != null) {
-            mNetworkLocationProvider.updateCellLockStatus(mCellWakeLockAcquired);
+        if (mNetworkLocationInterface != null) {
+            mNetworkLocationInterface.updateCellLockStatus(mCellWakeLockAcquired);
         }
 
         // Release wake lock
@@ -1907,14 +1967,10 @@
 
     public String getFromLocation(double latitude, double longitude, int maxResults,
         String language, String country, String variant, String appName, List<Address> addrs) {
-        try {
-            Locale locale = new Locale(language, country, variant);
-            mMasfClient.reverseGeocode(locale, appName, latitude, longitude, maxResults, addrs);
-            return null;
-        } catch(IOException e) {
-            return e.getMessage();
-        } catch(Exception e) {
-            Log.e(TAG, "getFromLocation got exception:", e);
+        if (mNetworkLocationInterface != null) {
+            return mNetworkLocationInterface.getFromLocation(latitude, longitude, maxResults,
+                    language, country, variant, appName, addrs);
+        } else {
             return null;
         }
     }
@@ -1923,17 +1979,11 @@
         double lowerLeftLatitude, double lowerLeftLongitude,
         double upperRightLatitude, double upperRightLongitude, int maxResults,
         String language, String country, String variant, String appName, List<Address> addrs) {
-
-        try {
-            Locale locale = new Locale(language, country, variant);
-            mMasfClient.forwardGeocode(locale, appName, locationName,
-                lowerLeftLatitude, lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
-                maxResults, addrs);
-            return null;
-        } catch(IOException e) {
-            return e.getMessage();
-        } catch(Exception e) {
-            Log.e(TAG, "getFromLocationName got exception:", e);
+        if (mNetworkLocationInterface != null) {
+            return mNetworkLocationInterface.getFromLocationName(locationName, lowerLeftLatitude, 
+                    lowerLeftLongitude, upperRightLatitude, upperRightLongitude, maxResults,
+                    language, country, variant, appName, addrs);
+        } else {
             return null;
         }
     }
diff --git a/services/java/com/android/server/MountListener.java b/services/java/com/android/server/MountListener.java
index 40d1b72..2e430c8 100644
--- a/services/java/com/android/server/MountListener.java
+++ b/services/java/com/android/server/MountListener.java
@@ -30,7 +30,7 @@
 import java.net.Socket;
 
 /**
- * Thread for communicating with the mount service daemon via a local socket.
+ * Thread for communicating with the vol service daemon via a local socket.
  * Events received from the daemon are passed to the MountService instance, 
  * and the MountService instance calls MountListener to send commands to the daemon.
  */
@@ -38,39 +38,43 @@
 
     private static final String TAG = "MountListener";
 
-    // ** THE FOLLOWING STRING CONSTANTS MUST MATCH VALUES IN system/mountd/mountd.h
+    // ** THE FOLLOWING STRING CONSTANTS MUST MATCH VALUES IN system/vold/
     
-    // socket name for connecting to mountd
-    private static final String MOUNTD_SOCKET = "mountd";
+    // socket name for connecting to vold
+    private static final String VOLD_SOCKET = "vold";
     
-    // mountd commands
-    private static final String MOUNTD_ENABLE_UMS = "enable_ums";
-    private static final String MOUNTD_DISABLE_UMS = "disable_ums";
-    private static final String MOUNTD_SEND_STATUS = "send_status";
-    private static final String MOUNTD_MOUNT_MEDIA = "mount_media:";
-    private static final String MOUNTD_EJECT_MEDIA = "eject_media:";
+    // vold commands
+    private static final String VOLD_CMD_ENABLE_UMS = "enable_ums";
+    private static final String VOLD_CMD_DISABLE_UMS = "disable_ums";
+    private static final String VOLD_CMD_SEND_UMS_STATUS = "send_ums_status";
+    private static final String VOLD_CMD_MOUNT_VOLUME = "mount_volume:";
+    private static final String VOLD_CMD_EJECT_MEDIA = "eject_media:";
+    private static final String VOLD_CMD_FORMAT_MEDIA = "format_media:";
 
-    // mountd events
-    private static final String MOUNTD_UMS_ENABLED = "ums_enabled";
-    private static final String MOUNTD_UMS_DISABLED = "ums_disabled";
-    private static final String MOUNTD_UMS_CONNECTED = "ums_connected";
-    private static final String MOUNTD_UMS_DISCONNECTED = "ums_disconnected";
-    private static final String MOUNTD_MEDIA_REMOVED = "media_removed:";
-    private static final String MOUNTD_MEDIA_UNMOUNTED = "media_unmounted:";
-    private static final String MOUNTD_MEDIA_MOUNTED = "media_mounted:";
-    private static final String MOUNTD_MEDIA_MOUNTED_READ_ONLY = "media_mounted_ro:";
-    private static final String MOUNTD_MEDIA_SHARED = "media_shared:";
-    private static final String MOUNTD_MEDIA_BAD_REMOVAL = "media_bad_removal:";
-    private static final String MOUNTD_MEDIA_UNMOUNTABLE = "media_unmountable:";
-    private static final String MOUNTD_REQUEST_EJECT = "request_eject:";
+    // vold events
+    private static final String VOLD_EVT_UMS_ENABLED = "ums_enabled";
+    private static final String VOLD_EVT_UMS_DISABLED = "ums_disabled";
+    private static final String VOLD_EVT_UMS_CONNECTED = "ums_connected";
+    private static final String VOLD_EVT_UMS_DISCONNECTED = "ums_disconnected";
+
+    private static final String VOLD_EVT_NOMEDIA = "volume_nomedia:";
+    private static final String VOLD_EVT_UNMOUNTED = "volume_unmounted:";
+    private static final String VOLD_EVT_MOUNTED = "volume_mounted:";
+    private static final String VOLD_EVT_MOUNTED_RO = "volume_mounted_ro:";
+    private static final String VOLD_EVT_UMS = "volume_ums";
+    private static final String VOLD_EVT_BAD_REMOVAL = "volume_badremoval:";
+    private static final String VOLD_EVT_DAMAGED = "volume_damaged:";
+    private static final String VOLD_EVT_CHECKING = "volume_checking:";
+    private static final String VOLD_EVT_NOFS = "volume_nofs:";
+    private static final String VOLD_EVT_EJECTING = "volume_ejecting:";
 
     /**
-     * MountService that handles events received from the mount service daemon
+     * MountService that handles events received from the vol service daemon
      */
     private MountService mService;
     
     /**
-     * Stream for sending commands to the mount service daemon.
+     * Stream for sending commands to the vol service daemon.
      */
     private OutputStream mOutputStream;
     
@@ -95,9 +99,9 @@
     }
 
     /**
-     * Process and dispatches events received from the mount service daemon
+     * Process and dispatches events received from the vol service daemon
      * 
-     * @param event  An event received from the mount service daemon
+     * @param event  An event received from the vol service daemon
      */
     private void handleEvent(String event) {
         if (Config.LOGD) Log.d(TAG, "handleEvent " + event);
@@ -105,34 +109,38 @@
         int colonIndex = event.indexOf(':');
         String path = (colonIndex > 0 ? event.substring(colonIndex + 1) : null);
         
-        if (event.equals(MOUNTD_UMS_ENABLED)) {
+        if (event.equals(VOLD_EVT_UMS_ENABLED)) {
             mUmsEnabled = true;
-        } else if (event.equals(MOUNTD_UMS_DISABLED)) {
+        } else if (event.equals(VOLD_EVT_UMS_DISABLED)) {
             mUmsEnabled = false;
-        } else if (event.equals(MOUNTD_UMS_CONNECTED)) {
+        } else if (event.equals(VOLD_EVT_UMS_CONNECTED)) {
             mUmsConnected = true;
             mService.notifyUmsConnected();
-        } else if (event.equals(MOUNTD_UMS_DISCONNECTED)) {
+        } else if (event.equals(VOLD_EVT_UMS_DISCONNECTED)) {
             mUmsConnected = false;        
             mService.notifyUmsDisconnected();
-        } else if (event.startsWith(MOUNTD_MEDIA_REMOVED)) {
+        } else if (event.startsWith(VOLD_EVT_NOMEDIA)) {
             mService.notifyMediaRemoved(path);
-        } else if (event.startsWith(MOUNTD_MEDIA_UNMOUNTED)) {
+        } else if (event.startsWith(VOLD_EVT_UNMOUNTED)) {
             mService.notifyMediaUnmounted(path);
-        } else if (event.startsWith(MOUNTD_MEDIA_MOUNTED)) {
+        } else if (event.startsWith(VOLD_EVT_CHECKING)) {
+            mService.notifyMediaChecking(path);
+        } else if (event.startsWith(VOLD_EVT_NOFS)) {
+            mService.notifyMediaNoFs(path);
+        } else if (event.startsWith(VOLD_EVT_MOUNTED)) {
             mService.notifyMediaMounted(path, false);
-        } else if (event.startsWith(MOUNTD_MEDIA_MOUNTED_READ_ONLY)) {
+        } else if (event.startsWith(VOLD_EVT_MOUNTED_RO)) {
             mService.notifyMediaMounted(path, true);
-        } else if (event.startsWith(MOUNTD_MEDIA_SHARED)) {
+        } else if (event.startsWith(VOLD_EVT_UMS)) {
             mService.notifyMediaShared(path);
-        } else if (event.startsWith(MOUNTD_MEDIA_BAD_REMOVAL)) {
+        } else if (event.startsWith(VOLD_EVT_BAD_REMOVAL)) {
             mService.notifyMediaBadRemoval(path);
             // also send media eject intent, to notify apps to close any open
             // files on the media.
             mService.notifyMediaEject(path);
-        } else if (event.startsWith(MOUNTD_MEDIA_UNMOUNTABLE)) {
+        } else if (event.startsWith(VOLD_EVT_DAMAGED)) {
             mService.notifyMediaUnmountable(path);
-        } else if (event.startsWith(MOUNTD_REQUEST_EJECT)) {
+        } else if (event.startsWith(VOLD_EVT_EJECTING)) {
             mService.notifyMediaEject(path);
         }    
     }
@@ -156,7 +164,7 @@
     private void writeCommand2(String command, String argument) {
         synchronized (this) {
             if (mOutputStream == null) {
-                Log.e(TAG, "No connection to mountd", new IllegalStateException());
+                Log.e(TAG, "No connection to vold", new IllegalStateException());
             } else {
                 StringBuilder builder = new StringBuilder(command);
                 if (argument != null) {
@@ -183,7 +191,7 @@
 
         try {
             socket = new LocalSocket();
-            LocalSocketAddress address = new LocalSocketAddress(MOUNTD_SOCKET, 
+            LocalSocketAddress address = new LocalSocketAddress(VOLD_SOCKET, 
                     LocalSocketAddress.Namespace.RESERVED);
 
             socket.connect(address);
@@ -193,7 +201,7 @@
 
             byte[] buffer = new byte[100];
 
-            writeCommand(MOUNTD_SEND_STATUS);
+            writeCommand(VOLD_CMD_SEND_UMS_STATUS);
             
             while (true) {
                 int count = inputStream.read(buffer);
@@ -242,7 +250,7 @@
          * create tons of throwaway LocalSockets, making
          * system_server GC constantly.
          */
-        Log.e(TAG, "Failed to connect to mountd", new IllegalStateException());
+        Log.e(TAG, "Failed to connect to vold", new IllegalStateException());
         SystemClock.sleep(2000);
     }
 
@@ -283,7 +291,7 @@
      * @param enable  true to enable USB mass storage support
      */
     void setMassStorageEnabled(boolean enable) {
-        writeCommand(enable ? MOUNTD_ENABLE_UMS : MOUNTD_DISABLE_UMS);
+        writeCommand(enable ? VOLD_CMD_ENABLE_UMS : VOLD_CMD_DISABLE_UMS);
     }
 
     /**
@@ -297,14 +305,20 @@
      * Mount media at given mount point.
      */
     public void mountMedia(String mountPoint) {
-        writeCommand2(MOUNTD_MOUNT_MEDIA, mountPoint);
+        writeCommand2(VOLD_CMD_MOUNT_VOLUME, mountPoint);
     }
 
     /**
      * Unmount media at given mount point.
      */
     public void ejectMedia(String mountPoint) {
-        writeCommand2(MOUNTD_EJECT_MEDIA, mountPoint);
+        writeCommand2(VOLD_CMD_EJECT_MEDIA, mountPoint);
+    }
+
+    /**
+     * Format media at given mount point.
+     */
+    public void formatMedia(String mountPoint) {
+        writeCommand2(VOLD_CMD_FORMAT_MEDIA, mountPoint);
     }
 }
-
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 002ebed..0feb1da 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -19,15 +19,19 @@
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.net.Uri;
 import android.os.IMountService;
 import android.os.Environment;
 import android.os.RemoteException;
+import android.os.SystemProperties;
 import android.os.UEventObserver;
+import android.text.TextUtils;
 import android.util.Log;
 
 import java.io.File;
@@ -52,24 +56,32 @@
     private MountListener mListener;
 
     /**
-     * The notification that is shown when USB is connected. It leads the user
-     * to a dialog to enable mass storage mode.
+     * The notification that is shown when a USB mass storage host
+     * is connected. 
      * <p>
-     * This is lazily created, so use {@link #getUsbStorageNotification()}.
+     * This is lazily created, so use {@link #setUsbStorageNotification()}.
      */
     private Notification mUsbStorageNotification;
 
-    private class SdDoorListener extends UEventObserver {    
-        static final String SD_DOOR_UEVENT_MATCH = "DEVPATH=/devices/virtual/switch/sd-door";
-        static final String SD_DOOR_SWITCH_NAME = "sd-door";
 
-        public void onUEvent(UEvent event) {
-            if (SD_DOOR_SWITCH_NAME.equals(event.get("SWITCH_NAME"))) {
-                sdDoorStateChanged(event.get("SWITCH_STATE"));
-            }
-        }
-    };
+    /**
+     * The notification that is shown when the following media events occur:
+     *     - Media is being checked
+     *     - Media is blank (or unknown filesystem)
+     *     - Media is corrupt
+     *     - Media is safe to unmount
+     *     - Media is missing
+     * <p>
+     * This is lazily created, so use {@link #setMediaStorageNotification()}.
+     */
+    private Notification mMediaStorageNotification;
     
+    private boolean mShowSafeUnmountNotificationWhenUnmounted;
+
+    private boolean mPlaySounds;
+
+    private boolean mMounted;
+
     /**
      * Constructs a new MountService instance
      * 
@@ -77,13 +89,28 @@
      */
     public MountService(Context context) {
         mContext = context;
+
+        // Register a BOOT_COMPLETED handler so that we can start
+        // MountListener. We defer the startup so that we don't
+        // start processing events before we ought-to
+        mContext.registerReceiver(mBroadcastReceiver,
+                new IntentFilter(Intent.ACTION_BOOT_COMPLETED), null, null);
+
         mListener =  new MountListener(this);       
-        Thread thread = new Thread(mListener, MountListener.class.getName());
-        thread.start();
-        SdDoorListener sdDoorListener = new SdDoorListener();
-        sdDoorListener.startObserving(SdDoorListener.SD_DOOR_UEVENT_MATCH);
+        mShowSafeUnmountNotificationWhenUnmounted = false;
+
+        mPlaySounds = SystemProperties.get("persist.service.mount.playsnd", "1").equals("1");
     }
 
+    BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
+                Thread thread = new Thread(mListener, MountListener.class.getName());
+                thread.start();
+            }
+        }
+    };
+
     /**
      * @return true if USB mass storage support is enabled.
      */
@@ -129,19 +156,92 @@
             throw new SecurityException("Requires MOUNT_UNMOUNT_FILESYSTEMS permission");
         }
 
+        // Set a flag so that when we get the unmounted event, we know
+        // to display the notification
+        mShowSafeUnmountNotificationWhenUnmounted = true;
+
         // tell mountd to unmount the media
         mListener.ejectMedia(mountPath);
     }
 
     /**
+     * Attempt to format external media
+     */
+    public void formatMedia(String formatPath) throws RemoteException {
+        if (mContext.checkCallingOrSelfPermission(
+                android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS) 
+                != PackageManager.PERMISSION_GRANTED) {
+            throw new SecurityException("Requires MOUNT_FORMAT_FILESYSTEMS permission");
+        }
+
+        mListener.formatMedia(formatPath);
+    }
+
+    /**
+     * Returns true if we're playing media notification sounds.
+     */
+    public boolean getPlayNotificationSounds() {
+        return mPlaySounds;
+    }
+
+    /**
+     * Set whether or not we're playing media notification sounds.
+     */
+    public void setPlayNotificationSounds(boolean enabled) {
+        if (mContext.checkCallingOrSelfPermission(
+                android.Manifest.permission.WRITE_SETTINGS) 
+                != PackageManager.PERMISSION_GRANTED) {
+            throw new SecurityException("Requires WRITE_SETTINGS permission");
+        }
+        mPlaySounds = enabled;
+        SystemProperties.set("persist.service.mount.playsnd", (enabled ? "1" : "0"));
+    }
+
+    /**
+     * Update the state of the USB mass storage notification
+     */
+    void updateUsbMassStorageNotification(boolean suppressIfConnected, boolean sound) {
+
+        try {
+
+            if (getMassStorageConnected() && !suppressIfConnected) {
+                Intent intent = new Intent();
+                intent.setClass(mContext, com.android.internal.app.UsbStorageActivity.class);
+                PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
+                setUsbStorageNotification(
+                        com.android.internal.R.string.usb_storage_notification_title,
+                        com.android.internal.R.string.usb_storage_notification_message,
+                        com.android.internal.R.drawable.stat_sys_data_usb,
+                        sound, true, pi);
+            } else {
+                setUsbStorageNotification(0, 0, 0, false, false, null);
+            }
+        } catch (RemoteException e) {
+            // Nothing to do
+        }
+    }
+
+    void handlePossibleExplicitUnmountBroadcast(String path) {
+        if (mMounted) {
+            mMounted = false;
+            Intent intent = new Intent(Intent.ACTION_MEDIA_UNMOUNTED, 
+                    Uri.parse("file://" + path));
+            mContext.sendBroadcast(intent);
+        }
+    }
+
+    /**
      * Broadcasts the USB mass storage connected event to all clients.
      */
     void notifyUmsConnected() {
         String storageState = Environment.getExternalStorageState();
         if (!storageState.equals(Environment.MEDIA_REMOVED) &&
-                !storageState.equals(Environment.MEDIA_BAD_REMOVAL)) {
-            setUsbStorageNotificationVisibility(true);
+            !storageState.equals(Environment.MEDIA_BAD_REMOVAL) &&
+            !storageState.equals(Environment.MEDIA_CHECKING)) {
+
+            updateUsbMassStorageNotification(false, true);
         }
+
         Intent intent = new Intent(Intent.ACTION_UMS_CONNECTED);
         mContext.sendBroadcast(intent);
     }
@@ -150,7 +250,7 @@
      * Broadcasts the USB mass storage disconnected event to all clients.
      */
     void notifyUmsDisconnected() {
-        setUsbStorageNotificationVisibility(false);
+        updateUsbMassStorageNotification(false, false);
         Intent intent = new Intent(Intent.ACTION_UMS_DISCONNECTED);
         mContext.sendBroadcast(intent);
     }
@@ -159,6 +259,15 @@
      * Broadcasts the media removed event to all clients.
      */
     void notifyMediaRemoved(String path) {
+        updateUsbMassStorageNotification(true, false);
+
+        setMediaStorageNotification(
+                com.android.internal.R.string.ext_media_nomedia_notification_title,
+                com.android.internal.R.string.ext_media_nomedia_notification_message,
+                com.android.internal.R.drawable.stat_sys_no_sim,
+                true, false, null);
+        handlePossibleExplicitUnmountBroadcast(path);
+
         Intent intent = new Intent(Intent.ACTION_MEDIA_REMOVED, 
                 Uri.parse("file://" + path));
         mContext.sendBroadcast(intent);
@@ -168,18 +277,68 @@
      * Broadcasts the media unmounted event to all clients.
      */
     void notifyMediaUnmounted(String path) {
+        if (mShowSafeUnmountNotificationWhenUnmounted) {
+            setMediaStorageNotification(
+                    com.android.internal.R.string.ext_media_safe_unmount_notification_title,
+                    com.android.internal.R.string.ext_media_safe_unmount_notification_message,
+                    com.android.internal.R.drawable.stat_notify_sim_toolkit,
+                    true, true, null);
+            mShowSafeUnmountNotificationWhenUnmounted = false;
+        } else {
+            setMediaStorageNotification(0, 0, 0, false, false, null);
+        }
+        updateUsbMassStorageNotification(false, false);
+
         Intent intent = new Intent(Intent.ACTION_MEDIA_UNMOUNTED, 
                 Uri.parse("file://" + path));
         mContext.sendBroadcast(intent);
     }
 
     /**
+     * Broadcasts the media checking event to all clients.
+     */
+    void notifyMediaChecking(String path) {
+        setMediaStorageNotification(
+                com.android.internal.R.string.ext_media_checking_notification_title,
+                com.android.internal.R.string.ext_media_checking_notification_message,
+                com.android.internal.R.drawable.stat_notify_sim_toolkit,
+                true, false, null);
+
+        updateUsbMassStorageNotification(true, false);
+        Intent intent = new Intent(Intent.ACTION_MEDIA_CHECKING, 
+                Uri.parse("file://" + path));
+        mContext.sendBroadcast(intent);
+    }
+
+    /**
+     * Broadcasts the media nofs event to all clients.
+     */
+    void notifyMediaNoFs(String path) {
+        
+        Intent intent = new Intent();
+        intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class);
+        PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
+
+        setMediaStorageNotification(com.android.internal.R.string.ext_media_nofs_notification_title,
+                                    com.android.internal.R.string.ext_media_nofs_notification_message,
+                                    com.android.internal.R.drawable.stat_sys_no_sim,
+                                    true, false, pi);
+        updateUsbMassStorageNotification(false, false);
+        intent = new Intent(Intent.ACTION_MEDIA_NOFS, 
+                Uri.parse("file://" + path));
+        mContext.sendBroadcast(intent);
+    }
+
+    /**
      * Broadcasts the media mounted event to all clients.
      */
     void notifyMediaMounted(String path, boolean readOnly) {
+        setMediaStorageNotification(0, 0, 0, false, false, null);
+        updateUsbMassStorageNotification(false, false);
         Intent intent = new Intent(Intent.ACTION_MEDIA_MOUNTED, 
                 Uri.parse("file://" + path));
         intent.putExtra("read-only", readOnly);
+        mMounted = true;
         mContext.sendBroadcast(intent);
     }
 
@@ -187,7 +346,15 @@
      * Broadcasts the media shared event to all clients.
      */
     void notifyMediaShared(String path) {
-        Intent intent = new Intent(Intent.ACTION_MEDIA_SHARED, 
+        Intent intent = new Intent();
+        intent.setClass(mContext, com.android.internal.app.UsbStorageStopActivity.class);
+        PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
+        setUsbStorageNotification(com.android.internal.R.string.usb_storage_stop_notification_title,
+                                  com.android.internal.R.string.usb_storage_stop_notification_message,
+                                  com.android.internal.R.drawable.stat_sys_warning,
+                                  false, true, pi);
+        handlePossibleExplicitUnmountBroadcast(path);
+        intent = new Intent(Intent.ACTION_MEDIA_SHARED, 
                 Uri.parse("file://" + path));
         mContext.sendBroadcast(intent);
     }
@@ -196,16 +363,39 @@
      * Broadcasts the media bad removal event to all clients.
      */
     void notifyMediaBadRemoval(String path) {
+        updateUsbMassStorageNotification(true, false);
+        setMediaStorageNotification(com.android.internal.R.string.ext_media_badremoval_notification_title,
+                                    com.android.internal.R.string.ext_media_badremoval_notification_message,
+                                    com.android.internal.R.drawable.stat_sys_warning,
+                                    true, true, null);
+
+        handlePossibleExplicitUnmountBroadcast(path);
         Intent intent = new Intent(Intent.ACTION_MEDIA_BAD_REMOVAL, 
                 Uri.parse("file://" + path));
         mContext.sendBroadcast(intent);
+
+        intent = new Intent(Intent.ACTION_MEDIA_REMOVED, 
+                Uri.parse("file://" + path));
+        mContext.sendBroadcast(intent);
     }
 
     /**
      * Broadcasts the media unmountable event to all clients.
      */
     void notifyMediaUnmountable(String path) {
-        Intent intent = new Intent(Intent.ACTION_MEDIA_UNMOUNTABLE, 
+        Intent intent = new Intent();
+        intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class);
+        PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
+
+        setMediaStorageNotification(com.android.internal.R.string.ext_media_unmountable_notification_title,
+                                    com.android.internal.R.string.ext_media_unmountable_notification_message,
+                                    com.android.internal.R.drawable.stat_sys_no_sim,
+                                    true, false, pi); 
+        updateUsbMassStorageNotification(false, false);
+
+        handlePossibleExplicitUnmountBroadcast(path);
+
+        intent = new Intent(Intent.ACTION_MEDIA_UNMOUNTABLE, 
                 Uri.parse("file://" + path));
         mContext.sendBroadcast(intent);
     }
@@ -219,90 +409,129 @@
         mContext.sendBroadcast(intent);
     }
     
-    private void sdDoorStateChanged(String doorState) {
-        File directory = Environment.getExternalStorageDirectory();
-        String storageState = Environment.getExternalStorageState();
-        
-        if (directory != null) {
-            try {
-                if (doorState.equals("open") && (storageState.equals(Environment.MEDIA_MOUNTED) ||
-                        storageState.equals(Environment.MEDIA_MOUNTED_READ_ONLY))) {
-                    // request SD card unmount if SD card door is opened
-                    unmountMedia(directory.getPath());
-                } else if (doorState.equals("closed") && storageState.equals(Environment.MEDIA_UNMOUNTED)) {
-                    // attempt to remount SD card
-                    mountMedia(directory.getPath());
-                }
-            } catch (RemoteException e) {
-                // Nothing to do.
-            }
-        }
-    }
-
     /**
-     * Sets the visibility of the USB storage notification. This should be
-     * called when a USB cable is connected and also when it is disconnected.
-     * 
-     * @param visible Whether to show or hide the notification.
+     * Sets the USB storage notification.
      */
-    private void setUsbStorageNotificationVisibility(boolean visible) {
-        NotificationManager notificationManager = (NotificationManager) mContext
-                .getSystemService(Context.NOTIFICATION_SERVICE);
-        if (notificationManager == null) {
+    private synchronized void setUsbStorageNotification(int titleId, int messageId, int icon, boolean sound, boolean visible,
+                                                        PendingIntent pi) {
+
+        if (!visible && mUsbStorageNotification == null) {
             return;
         }
 
-        /*
-         * The convention for notification IDs is to use the icon's resource ID
-         * when the icon is only used by a single notification type, which is
-         * the case here.
-         */
-        Notification notification = getUsbStorageNotification();
-        final int notificationId = notification.icon;
+        NotificationManager notificationManager = (NotificationManager) mContext
+                .getSystemService(Context.NOTIFICATION_SERVICE);
+
+        if (notificationManager == null) {
+            return;
+        }
         
         if (visible) {
-            notificationManager.notify(notificationId, notification);
+            Resources r = Resources.getSystem();
+            CharSequence title = r.getText(titleId);
+            CharSequence message = r.getText(messageId);
+
+            if (mUsbStorageNotification == null) {
+                mUsbStorageNotification = new Notification();
+                mUsbStorageNotification.icon = icon;
+                mUsbStorageNotification.when = 0;
+            }
+
+            if (sound && mPlaySounds) {
+                mUsbStorageNotification.defaults |= Notification.DEFAULT_SOUND;
+            } else {
+                mUsbStorageNotification.defaults &= ~Notification.DEFAULT_SOUND;
+            }
+                
+            mUsbStorageNotification.flags = Notification.FLAG_ONGOING_EVENT;
+
+            mUsbStorageNotification.tickerText = title;
+            if (pi == null) {
+                Intent intent = new Intent();
+                pi = PendingIntent.getBroadcast(mContext, 0, intent, 0);
+            }
+
+            mUsbStorageNotification.setLatestEventInfo(mContext, title, message, pi);
+        }
+    
+        final int notificationId = mUsbStorageNotification.icon;
+        if (visible) {
+            notificationManager.notify(notificationId, mUsbStorageNotification);
         } else {
             notificationManager.cancel(notificationId);
         }
     }
 
-    /**
-     * Gets the USB storage notification.
-     * 
-     * @return A {@link Notification} that leads to the dialog to enable USB storage.
-     */
-    private synchronized Notification getUsbStorageNotification() {
-        Resources r = Resources.getSystem();
-        CharSequence title =
-                r.getText(com.android.internal.R.string.usb_storage_notification_title);
-        CharSequence message =
-                r.getText(com.android.internal.R.string.usb_storage_notification_message);
+    private synchronized boolean getMediaStorageNotificationDismissable() {
+        if ((mMediaStorageNotification != null) &&
+            ((mMediaStorageNotification.flags & Notification.FLAG_AUTO_CANCEL) ==
+                    Notification.FLAG_AUTO_CANCEL))
+            return true;
 
-        if (mUsbStorageNotification == null) {
-            mUsbStorageNotification = new Notification();
-            mUsbStorageNotification.icon = com.android.internal.R.drawable.stat_sys_data_usb;
-            mUsbStorageNotification.when = 0;
-            mUsbStorageNotification.flags = Notification.FLAG_AUTO_CANCEL;
-            mUsbStorageNotification.defaults |= Notification.DEFAULT_SOUND;
+        return false;
+    }
+
+    /**
+     * Sets the media storage notification.
+     */
+    private synchronized void setMediaStorageNotification(int titleId, int messageId, int icon, boolean visible,
+                                                          boolean dismissable, PendingIntent pi) {
+
+        if (!visible && mMediaStorageNotification == null) {
+            return;
         }
 
-        mUsbStorageNotification.tickerText = title;
-        mUsbStorageNotification.setLatestEventInfo(mContext, title, message,
-                getUsbStorageDialogIntent());
+        NotificationManager notificationManager = (NotificationManager) mContext
+                .getSystemService(Context.NOTIFICATION_SERVICE);
 
-        return mUsbStorageNotification;
-    }
+        if (notificationManager == null) {
+            return;
+        }
+
+        if (mMediaStorageNotification != null && visible) {
+            /*
+             * Dismiss the previous notification - we're about to
+             * re-use it.
+             */
+            final int notificationId = mMediaStorageNotification.icon;
+            notificationManager.cancel(notificationId);
+        }
+        
+        if (visible) {
+            Resources r = Resources.getSystem();
+            CharSequence title = r.getText(titleId);
+            CharSequence message = r.getText(messageId);
+
+            if (mMediaStorageNotification == null) {
+                mMediaStorageNotification = new Notification();
+                mMediaStorageNotification.when = 0;
+                if (mPlaySounds) {
+                    mMediaStorageNotification.defaults |= Notification.DEFAULT_SOUND;
+                }
+            }
+
+            if (dismissable) {
+                mMediaStorageNotification.flags = Notification.FLAG_AUTO_CANCEL;
+            } else {
+                mMediaStorageNotification.flags = Notification.FLAG_ONGOING_EVENT;
+            }
+
+            mMediaStorageNotification.tickerText = title;
+            if (pi == null) {
+                Intent intent = new Intent();
+                pi = PendingIntent.getBroadcast(mContext, 0, intent, 0);
+            }
+
+            mMediaStorageNotification.icon = icon;
+            mMediaStorageNotification.setLatestEventInfo(mContext, title, message, pi);
+        }
     
-    /**
-     * Creates a pending intent to start the USB storage activity.
-     * 
-     * @return A {@link PendingIntent} that start the USB storage activity.
-     */
-    private PendingIntent getUsbStorageDialogIntent() {
-        Intent intent = new Intent();
-        intent.setClass(mContext, com.android.internal.app.UsbStorageActivity.class);
-        return PendingIntent.getActivity(mContext, 0, intent, 0);
+        final int notificationId = mMediaStorageNotification.icon;
+        if (visible) {
+            notificationManager.notify(notificationId, mMediaStorageNotification);
+        } else {
+            notificationManager.cancel(notificationId);
+        }
     }
 }
 
diff --git a/services/java/com/android/server/NetStatService.java b/services/java/com/android/server/NetStatService.java
index 11dbe63..1ea0bac 100644
--- a/services/java/com/android/server/NetStatService.java
+++ b/services/java/com/android/server/NetStatService.java
@@ -26,20 +26,35 @@
 
     }
 
-    public int getTxPackets() {
-        return NetStat.netStatGetTxPkts();
+    public long getMobileTxPackets() {
+        return NetStat.getMobileTxPkts();
     }
 
-    public int getRxPackets() {
-        return NetStat.netStatGetRxPkts();
+    public long getMobileRxPackets() {
+        return NetStat.getMobileRxPkts();
     }
 
-    public int getTxBytes() {
-        return NetStat.netStatGetTxBytes();
+    public long getMobileTxBytes() {
+        return NetStat.getMobileTxBytes();
     }
 
-    public int getRxBytes() {
-        return NetStat.netStatGetRxBytes();
+    public long getMobileRxBytes() {
+        return NetStat.getMobileRxBytes();
     }
 
+    public long getTotalTxPackets() {
+        return NetStat.getTotalTxPkts();
+    }
+
+    public long getTotalRxPackets() {
+        return NetStat.getTotalRxPkts();
+    }
+
+    public long getTotalTxBytes() {
+        return NetStat.getTotalTxBytes();
+    }
+
+    public long getTotalRxBytes() {
+        return NetStat.getTotalRxBytes();
+    }
 }
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index eb9ebe9..e5de7f9 100644
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -865,7 +865,7 @@
     // ======================================================================
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission("android.permission.DUMP")
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump NotificationManager from from pid="
                     + Binder.getCallingPid()
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 58ad426..221ba46 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -97,6 +97,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipOutputStream;
@@ -983,6 +984,20 @@
         }
         return null;
     }
+    
+    public String[] getSystemSharedLibraryNames() {
+        Set<String> libSet;
+        synchronized (mPackages) {
+            libSet = mSharedLibraries.keySet();
+        }
+        int size = libSet.size();
+        if (size > 0) {
+            String[] libs = new String[size];
+            libSet.toArray(libs);
+            return libs;
+        }
+        return null;
+    }
 
     public int checkPermission(String permName, String pkgName) {
         synchronized (mPackages) {
@@ -2678,7 +2693,7 @@
             grantPermissionsLP(pkg, false);
         }
     }
-
+    
     private void grantPermissionsLP(PackageParser.Package pkg, boolean replace) {
         final PackageSetting ps = (PackageSetting)pkg.mExtras;
         if (ps == null) {
@@ -2724,7 +2739,19 @@
                                     == PackageManager.SIGNATURE_MATCH);
                     if (p.info.protectionLevel == PermissionInfo.PROTECTION_SIGNATURE_OR_SYSTEM) {
                         if ((pkg.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) != 0) {
-                            allowed = true;
+                            // For updated system applications, the signatureOrSystem permission
+                            // is granted only if it had been defined by the original application.
+                            if ((pkg.applicationInfo.flags 
+                                    & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)  != 0) {
+                                PackageSetting sysPs = mSettings.getDisabledSystemPkg(pkg.packageName);
+                                if(sysPs.grantedPermissions.contains(perm)) {
+                                    allowed = true;
+                                } else {
+                                    allowed = false;
+                                }
+                            } else {
+                                allowed = true;
+                            }
                         }
                     }
                 } else {
@@ -3157,6 +3184,7 @@
             if (removedPackage != null) {
                 Bundle extras = new Bundle(1);
                 extras.putInt(Intent.EXTRA_UID, removedUid);
+                extras.putBoolean(Intent.EXTRA_DATA_REMOVED, false);
                 sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED, removedPackage, extras);
             }
             if (addedPackage != null) {
@@ -3194,7 +3222,7 @@
                 // There appears to be a subtle deadlock condition if the sendPackageBroadcast call appears
                 // in the synchronized block above.
                 if (res.returnCode == PackageManager.INSTALL_SUCCEEDED) {
-                    res.removedInfo.sendBroadcast();
+                    res.removedInfo.sendBroadcast(false, true);
                     Bundle extras = new Bundle(1);
                     extras.putInt(Intent.EXTRA_UID, res.uid);
                     sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED,
@@ -3842,7 +3870,7 @@
         }
         
         if(res && sendBroadCast) {
-            info.sendBroadcast();
+            info.sendBroadcast(deleteCodeAndResources, false);
         }
         return res;
     }
@@ -3852,9 +3880,13 @@
         int uid = -1;
         int removedUid = -1;
         
-        void sendBroadcast() {
+        void sendBroadcast(boolean fullRemove, boolean replacing) {
             Bundle extras = new Bundle(1);
             extras.putInt(Intent.EXTRA_UID, removedUid >= 0 ? removedUid : uid);
+            extras.putBoolean(Intent.EXTRA_DATA_REMOVED, fullRemove);
+            if (replacing) {
+                extras.putBoolean(Intent.EXTRA_REPLACING, true);
+            }
             if (removedPackage != null) {
                 sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED, removedPackage, extras);
             }
@@ -4463,6 +4495,10 @@
         mSystemReady = true;
     }
 
+    public boolean isSafeMode() {
+        return mSafeMode;
+    }
+
     public boolean hasSystemUidErrors() {
         return mHasSystemUidErrors;
     }
@@ -4482,7 +4518,7 @@
     
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DUMP)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump ActivityManager from from pid="
                     + Binder.getCallingPid()
@@ -5637,23 +5673,8 @@
                 }
                 
                 for (PackageSetting pkg : mDisabledSysPackages.values()) {
-                    serializer.startTag(null, "updated-package");
-                    serializer.attribute(null, "name", pkg.name);
-                    serializer.attribute(null, "codePath", pkg.codePathString);
-                    serializer.attribute(null, "ts", pkg.getTimeStampStr());
-                    if (!pkg.resourcePathString.equals(pkg.codePathString)) {
-                        serializer.attribute(null, "resourcePath", pkg.resourcePathString);
-                    }
-                    if (pkg.sharedUser == null) {
-                        serializer.attribute(null, "userId",
-                                Integer.toString(pkg.userId));
-                    } else {
-                        serializer.attribute(null, "sharedUserId",
-                                Integer.toString(pkg.userId));
-                    }
-                    serializer.endTag(null, "updated-package");
+                    writeDisabledSysPackage(serializer, pkg);
                 }
-                
 
                 serializer.startTag(null, "preferred-packages");
                 int N = mPreferredPackages.size();
@@ -5716,6 +5737,43 @@
             //Debug.stopMethodTracing();
         }
        
+        void writeDisabledSysPackage(XmlSerializer serializer, final PackageSetting pkg) 
+        throws java.io.IOException {
+            serializer.startTag(null, "updated-package");
+            serializer.attribute(null, "name", pkg.name);
+            serializer.attribute(null, "codePath", pkg.codePathString);
+            serializer.attribute(null, "ts", pkg.getTimeStampStr());
+            if (!pkg.resourcePathString.equals(pkg.codePathString)) {
+                serializer.attribute(null, "resourcePath", pkg.resourcePathString);
+            }
+            if (pkg.sharedUser == null) {
+                serializer.attribute(null, "userId",
+                        Integer.toString(pkg.userId));
+            } else {
+                serializer.attribute(null, "sharedUserId",
+                        Integer.toString(pkg.userId));
+            }
+            serializer.startTag(null, "perms");
+            if (pkg.sharedUser == null) {
+                // If this is a shared user, the permissions will
+                // be written there.  We still need to write an
+                // empty permissions list so permissionsFixed will
+                // be set.
+                for (final String name : pkg.grantedPermissions) {
+                    BasePermission bp = mPermissions.get(name);
+                    if ((bp != null) && (bp.perm != null) && (bp.perm.info != null)) {
+                        // We only need to write signature or system permissions but this wont
+                        // match the semantics of grantedPermissions. So write all permissions.
+                        serializer.startTag(null, "item");
+                        serializer.attribute(null, "name", name);
+                        serializer.endTag(null, "item");
+                    }
+                }
+            }
+            serializer.endTag(null, "perms");
+            serializer.endTag(null, "updated-package");
+        }
+        
         void writePackage(XmlSerializer serializer, final PackageSetting pkg) 
         throws java.io.IOException {
             serializer.startTag(null, "package");
@@ -5892,33 +5950,7 @@
                     } else if (tagName.equals("preferred-activities")) {
                         readPreferredActivitiesLP(parser);
                     } else if(tagName.equals("updated-package")) {
-                        String name = parser.getAttributeValue(null, "name");
-                        String codePathStr = parser.getAttributeValue(null, "codePath");
-                        String resourcePathStr = parser.getAttributeValue(null, "resourcePath");
-                        if(resourcePathStr == null) {
-                            resourcePathStr = codePathStr;
-                        }
-                        
-                        int pkgFlags = 0;
-                        pkgFlags |= ApplicationInfo.FLAG_SYSTEM;
-                        PackageSetting ps = new PackageSetting(name, 
-                                new File(codePathStr), 
-                                new File(resourcePathStr), pkgFlags);
-                        String timeStampStr = parser.getAttributeValue(null, "ts");
-                        if (timeStampStr != null) {
-                            try {
-                                long timeStamp = Long.parseLong(timeStampStr);
-                                ps.setTimeStamp(timeStamp, timeStampStr);
-                            } catch (NumberFormatException e) {
-                            }
-                        }
-                        String idStr = parser.getAttributeValue(null, "userId");
-                        ps.userId = idStr != null ? Integer.parseInt(idStr) : 0;
-                        if(ps.userId <= 0) {
-                            String sharedIdStr = parser.getAttributeValue(null, "sharedUserId");
-                            ps.userId = sharedIdStr != null ? Integer.parseInt(sharedIdStr) : 0;
-                        }
-                        mDisabledSysPackages.put(name, ps);
+                        readDisabledSysPackageLP(parser);
                     } else {
                         Log.w(TAG, "Unknown element under <packages>: "
                               + parser.getName());
@@ -6056,6 +6088,58 @@
             }
         }
         
+        private void readDisabledSysPackageLP(XmlPullParser parser)
+        throws XmlPullParserException, IOException {
+            String name = parser.getAttributeValue(null, "name");
+            String codePathStr = parser.getAttributeValue(null, "codePath");
+            String resourcePathStr = parser.getAttributeValue(null, "resourcePath");
+            if(resourcePathStr == null) {
+                resourcePathStr = codePathStr;
+            }
+            
+            int pkgFlags = 0;
+            pkgFlags |= ApplicationInfo.FLAG_SYSTEM;
+            PackageSetting ps = new PackageSetting(name, 
+                    new File(codePathStr), 
+                    new File(resourcePathStr), pkgFlags);
+            String timeStampStr = parser.getAttributeValue(null, "ts");
+            if (timeStampStr != null) {
+                try {
+                    long timeStamp = Long.parseLong(timeStampStr);
+                    ps.setTimeStamp(timeStamp, timeStampStr);
+                } catch (NumberFormatException e) {
+                }
+            }
+            String idStr = parser.getAttributeValue(null, "userId");
+            ps.userId = idStr != null ? Integer.parseInt(idStr) : 0;
+            if(ps.userId <= 0) {
+                String sharedIdStr = parser.getAttributeValue(null, "sharedUserId");
+                ps.userId = sharedIdStr != null ? Integer.parseInt(sharedIdStr) : 0;
+            }
+            int outerDepth = parser.getDepth();
+            int type;
+            while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
+                   && (type != XmlPullParser.END_TAG
+                           || parser.getDepth() > outerDepth)) {
+                if (type == XmlPullParser.END_TAG
+                        || type == XmlPullParser.TEXT) {
+                    continue;
+                }
+
+                String tagName = parser.getName();
+                if (tagName.equals("perms")) {
+                    readGrantedPermissionsLP(parser,
+                            ps.grantedPermissions);
+                } else {
+                    reportSettingsProblem(Log.WARN,
+                            "Unknown element under <updated-package>: "
+                            + parser.getName());
+                    XmlUtils.skipCurrentTag(parser);
+                }
+            }
+            mDisabledSysPackages.put(name, ps);
+        }
+        
         private void readPackageLP(XmlPullParser parser)
                 throws XmlPullParserException, IOException {
             String name = null;
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index ca0ad1a..7c111d3 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -486,8 +486,13 @@
 
     public void acquireWakeLock(int flags, IBinder lock, String tag) {
         mContext.enforceCallingOrSelfPermission(android.Manifest.permission.WAKE_LOCK, null);
-        synchronized (mLocks) {
-            acquireWakeLockLocked(flags, lock, tag);
+        long ident = Binder.clearCallingIdentity();
+        try {
+            synchronized (mLocks) {
+                acquireWakeLockLocked(flags, lock, tag);
+            }
+        } finally {
+            Binder.restoreCallingIdentity(ident);
         }
     }
 
@@ -572,12 +577,13 @@
         }
 
         if (acquireType >= 0) {
+            long origId = Binder.clearCallingIdentity();
             try {
-                long origId = Binder.clearCallingIdentity();
                 mBatteryStats.noteStartWakelock(acquireUid, acquireName, acquireType);
-                Binder.restoreCallingIdentity(origId);
             } catch (RemoteException e) {
                 // Ignore
+            } finally {
+                Binder.restoreCallingIdentity(origId);
             }
         }
     }
@@ -627,12 +633,13 @@
         releaseType = wl.monitorType;
 
         if (releaseType >= 0) {
+            long origId = Binder.clearCallingIdentity();
             try {
-                long origId = Binder.clearCallingIdentity();
                 mBatteryStats.noteStopWakelock(releaseUid, releaseName, releaseType);
-                Binder.restoreCallingIdentity(origId);
             } catch (RemoteException e) {
                 // Ignore
+            } finally {
+                Binder.restoreCallingIdentity(origId);
             }
         }
     }
@@ -757,7 +764,7 @@
 
     @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DUMP)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump PowerManager from from pid="
                     + Binder.getCallingPid()
@@ -960,8 +967,10 @@
                     Log.d(TAG, "mBroadcastWakeLock=" + mBroadcastWakeLock);
                 }
                 if (mContext != null) {
-                    mContext.sendOrderedBroadcast(mScreenOnIntent, null,
-                            mScreenOnBroadcastDone, mHandler, 0, null, null);
+                    if (ActivityManagerNative.isSystemReady()) {
+                        mContext.sendOrderedBroadcast(mScreenOnIntent, null,
+                                mScreenOnBroadcastDone, mHandler, 0, null, null);
+                    }
                 } else {
                     synchronized (mLocks) {
                         EventLog.writeEvent(LOG_POWER_SCREEN_BROADCAST_STOP, 2,
@@ -1232,6 +1241,14 @@
                     }
                     if (reallyTurnScreenOn) {
                         err = Power.setScreenState(true);
+                        long identity = Binder.clearCallingIdentity();
+                        try {
+                            mBatteryStats.noteScreenOn();
+                        } catch (RemoteException e) {
+                            Log.w(TAG, "RemoteException calling noteScreenOn on BatteryStatsService", e);
+                        } finally {
+                            Binder.restoreCallingIdentity(identity);
+                        }
                     } else {
                         Power.setScreenState(false);
                         // But continue as if we really did turn the screen on...
@@ -1250,6 +1267,14 @@
                     }
                 } else {
                     mScreenOffTime = SystemClock.elapsedRealtime();
+                    long identity = Binder.clearCallingIdentity();
+                    try {
+                        mBatteryStats.noteScreenOff();
+                    } catch (RemoteException e) {
+                        Log.w(TAG, "RemoteException calling noteScreenOff on BatteryStatsService", e);
+                    } finally {
+                        Binder.restoreCallingIdentity(identity);
+                    }
                     if (!mScreenBrightness.animating) {
                         err = turnScreenOffLocked(becauseOfUser);
                     } else {
diff --git a/services/java/com/android/server/SensorService.java b/services/java/com/android/server/SensorService.java
index f56088c..461b006 100644
--- a/services/java/com/android/server/SensorService.java
+++ b/services/java/com/android/server/SensorService.java
@@ -105,17 +105,17 @@
         return _sensors_control_open();
     }
     
-    public boolean enableSensor(IBinder binder, int sensor, int enable)
+    public boolean enableSensor(IBinder binder, String name, int sensor, int enable)
              throws RemoteException {
-        if (localLOGV) Log.d(TAG, "enableSensor " + sensor + " " + enable);
+        if (localLOGV) Log.d(TAG, "enableSensor " + name + "(#" + sensor + ") " + enable);
         
         // Inform battery statistics service of status change
         int uid = Binder.getCallingUid();
         long identity = Binder.clearCallingIdentity();
         if (enable == SENSOR_DISABLE) {
-            mBatteryStats.noteStopSensor(uid, sensor);
+            mBatteryStats.noteStopSensor(uid, name, sensor);
         } else {
-            mBatteryStats.noteStartSensor(uid, sensor);
+            mBatteryStats.noteStartSensor(uid, name, sensor);
         }
         Binder.restoreCallingIdentity(identity);
 
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 7f7a52e..d624573 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -16,35 +16,36 @@
 
 package com.android.server;
 
+import com.android.server.am.ActivityManagerService;
+import com.android.server.status.StatusBarService;
+
+import dalvik.system.PathClassLoader;
+import dalvik.system.VMRuntime;
+
 import android.app.ActivityManagerNative;
+import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.ContentService;
 import android.content.Context;
+import android.content.Intent;
 import android.content.pm.IPackageManager;
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.media.AudioService;
+import android.os.IBinder;
 import android.os.Looper;
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.SystemClock;
 import android.os.SystemProperties;
-import android.os.IBinder;
-import android.provider.Settings;
 import android.provider.Contacts.People;
-import android.server.BluetoothDeviceService;
+import android.provider.Settings;
 import android.server.BluetoothA2dpService;
-import android.server.checkin.FallbackCheckinService;
+import android.server.BluetoothDeviceService;
 import android.server.search.SearchManagerService;
 import android.util.EventLog;
 import android.util.Log;
 
-import dalvik.system.TouchDex;
-import dalvik.system.VMRuntime;
-
-import com.android.server.am.ActivityManagerService;
-import com.android.server.status.StatusBarService;
-
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 
@@ -180,7 +181,7 @@
 
         StatusBarService statusBar = null;
         InputMethodManagerService imm = null;
-        
+
         if (factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL) {
             try {
                 Log.i(TAG, "Starting Status Bar Service.");
@@ -205,7 +206,7 @@
             } catch (Throwable e) {
                 Log.e(TAG, "Failure starting Input Manager Service", e);
             }
-            
+
             try {
                 Log.i(TAG, "Starting Hardware Service.");
                 ServiceManager.addService("hardware", new HardwareService(context));
@@ -272,9 +273,14 @@
             }
 
             try {
-                Log.i(TAG, "Starting Checkin Service");
-                addService(context, "checkin", "com.google.android.server.checkin.CheckinService",
-                        FallbackCheckinService.class);
+                Log.i(TAG, "Starting Checkin Service.");
+                Intent intent = new Intent().setComponent(new ComponentName(
+                        "com.google.android.server.checkin",
+                        "com.google.android.server.checkin.CheckinService"));
+                if (context.startService(intent) == null) {
+                    Log.w(TAG, "Using fallback Checkin Service.");
+                    ServiceManager.addService("checkin", new FallbackCheckinService(context));
+                }
             } catch (Throwable e) {
                 Log.e(TAG, "Failure starting Checkin Service", e);
             }
@@ -318,6 +324,7 @@
                 false, new AdbSettingsObserver());
 
         // It is now time to start up the app processes...
+        boolean safeMode = wm.detectSafeMode();
         if (statusBar != null) {
             statusBar.systemReady();
         }
@@ -342,51 +349,6 @@
         Looper.loop();
         Log.d(TAG, "System ServerThread is exiting!");
     }
-
-    private void addService(Context context, String name, String serviceClass,
-            Class<? extends IBinder> fallback) {
-
-        final IBinder service = findService(context, serviceClass, fallback);
-        if (service != null) {
-            ServiceManager.addService(name, service);
-        } else {
-            Log.e(TAG, "Failure starting service '" + name + "' with class " + serviceClass);
-        }
-    }
-
-    private IBinder findService(Context context, String serviceClass,
-            Class<? extends IBinder> fallback) {
-
-        IBinder service = null;
-        try {
-            Class<?> klass = Class.forName(serviceClass);
-            Constructor<?> c = klass.getConstructor(Context.class);
-            service = (IBinder) c.newInstance(context);
-        } catch (ClassNotFoundException e) {
-            // Ignore
-        } catch (IllegalAccessException e) {
-            // Ignore
-        } catch (NoSuchMethodException e) {
-            // Ignore
-        } catch (InvocationTargetException e) {
-            // Ignore
-        } catch (InstantiationException e) {
-            // Ignore
-        }
-
-        if (service == null && fallback != null) {
-            Log.w(TAG, "Could not find " + serviceClass + ", trying fallback");
-            try {
-                service = fallback.newInstance();
-            } catch (IllegalAccessException e) {
-                // Ignore
-            } catch (InstantiationException e) {
-                // Ignore
-            }
-        }
-
-        return service;
-    }
 }
 
 class DemoThread extends Thread
diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java
index dbaf086..b5cf1aa 100644
--- a/services/java/com/android/server/TelephonyRegistry.java
+++ b/services/java/com/android/server/TelephonyRegistry.java
@@ -363,7 +363,7 @@
 
     @Override
     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DUMP)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump telephony.registry from from pid="
                     + Binder.getCallingPid()
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 2d61b1e..c009fac 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -22,6 +22,7 @@
 import static android.net.wifi.WifiManager.WIFI_STATE_ENABLING;
 import static android.net.wifi.WifiManager.WIFI_STATE_UNKNOWN;
 
+import android.app.ActivityManagerNative;
 import android.app.AlarmManager;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
@@ -204,8 +205,6 @@
                         mWifiHandler.removeMessages(MESSAGE_RELEASE_WAKELOCK);
                         synchronized (sDriverStopWakeLock) {
                             if (sDriverStopWakeLock.isHeld()) {
-                                if (DBG) Log.d(TAG, "Releasing driver-stop wakelock " +
-                                        sDriverStopWakeLock);
                                 sDriverStopWakeLock.release();
                             }
                         }
@@ -213,9 +212,18 @@
                 }
         );
 
-        Log.d(TAG, "WifiService starting up with Wi-Fi " +
-            (wifiEnabled ? "enabled" : "disabled"));
-        registerForBroadcasts();
+        Log.i(TAG, "WifiService starting up with Wi-Fi " +
+                (wifiEnabled ? "enabled" : "disabled"));
+
+        mContext.registerReceiver(
+                new BroadcastReceiver() {
+                    @Override
+                    public void onReceive(Context context, Intent intent) {
+                        updateWifiState();
+                    }
+                },
+                new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
+
         setWifiEnabledBlocking(wifiEnabled, false);
     }
 
@@ -293,7 +301,7 @@
                         decrementHiddentNetworkPresentCounter();
                     }
                 }
-                mIsHiddenNetworkPresent.put(netId, new Boolean(present));
+                mIsHiddenNetworkPresent.put(netId, present);
             }
         } else {
             Log.e(TAG, "addOrUpdateHiddenNetwork(): Invalid (negative) network id!");
@@ -422,6 +430,7 @@
 
     /**
      * see {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)}
+     * @param enable {@code true} to enable, {@code false} to disable.
      * @return {@code true} if the enable/disable operation was
      *         started or is already in the queue.
      */
@@ -429,10 +438,6 @@
         enforceChangePermission();
         if (mWifiHandler == null) return false;
 
-        /*
-         * Remove any enable/disable Wi-Fi messages we may have in the queue
-         * before adding a new one
-         */
         synchronized (mWifiHandler) {
             sWakeLock.acquire();
             sendEnableMessage(enable, true);
@@ -458,40 +463,42 @@
             return false;
         }
 
-        updateWifiState(enable ? WIFI_STATE_ENABLING : WIFI_STATE_DISABLING);
+        setWifiEnabledState(enable ? WIFI_STATE_ENABLING : WIFI_STATE_DISABLING);
 
         if (enable) {
             if (!WifiNative.loadDriver()) {
                 Log.e(TAG, "Failed to load Wi-Fi driver.");
-                updateWifiState(WIFI_STATE_UNKNOWN);
+                setWifiEnabledState(WIFI_STATE_UNKNOWN);
                 return false;
             }
             if (!WifiNative.startSupplicant()) {
                 WifiNative.unloadDriver();
                 Log.e(TAG, "Failed to start supplicant daemon.");
-                updateWifiState(WIFI_STATE_UNKNOWN);
+                setWifiEnabledState(WIFI_STATE_UNKNOWN);
                 return false;
             }
+            registerForBroadcasts();
             mWifiStateTracker.startEventLoop();
         } else {
 
-            // Remove notification (it will no-op if it isn't visible)
+            mContext.unregisterReceiver(mReceiver);
+           // Remove notification (it will no-op if it isn't visible)
             mWifiStateTracker.setNotificationVisible(false, 0, false, 0);
 
             boolean failedToStopSupplicantOrUnloadDriver = false;
             if (!WifiNative.stopSupplicant()) {
                 Log.e(TAG, "Failed to stop supplicant daemon.");
-                updateWifiState(WIFI_STATE_UNKNOWN);
+                setWifiEnabledState(WIFI_STATE_UNKNOWN);
                 failedToStopSupplicantOrUnloadDriver = true;
             }
-            
+
             // We must reset the interface before we unload the driver
             mWifiStateTracker.resetInterface();
-            
+
             if (!WifiNative.unloadDriver()) {
                 Log.e(TAG, "Failed to unload Wi-Fi driver.");
                 if (!failedToStopSupplicantOrUnloadDriver) {
-                    updateWifiState(WIFI_STATE_UNKNOWN);
+                    setWifiEnabledState(WIFI_STATE_UNKNOWN);
                     failedToStopSupplicantOrUnloadDriver = true;
                 }
             }
@@ -505,7 +512,7 @@
         if (persist) {
             persistWifiEnabled(enable);
         }
-        updateWifiState(eventualWifiState);
+        setWifiEnabledState(eventualWifiState);
 
         /*
          * Initialize the hidden networks state and the number of allowed
@@ -519,7 +526,7 @@
         return true;
     }
 
-    private void updateWifiState(int wifiState) {
+    private void setWifiEnabledState(int wifiState) {
         final int previousWifiState = mWifiState;
 
         // Update state
@@ -527,6 +534,7 @@
 
         // Broadcast
         final Intent intent = new Intent(WifiManager.WIFI_STATE_CHANGED_ACTION);
+        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
         intent.putExtra(WifiManager.EXTRA_WIFI_STATE, wifiState);
         intent.putExtra(WifiManager.EXTRA_PREVIOUS_WIFI_STATE, previousWifiState);
         mContext.sendStickyBroadcast(intent);
@@ -551,7 +559,7 @@
      *         {@link WifiManager#WIFI_STATE_ENABLING},
      *         {@link WifiManager#WIFI_STATE_UNKNOWN}
      */
-    public int getWifiState() {
+    public int getWifiEnabledState() {
         enforceAccessPermission();
         return mWifiState;
     }
@@ -1082,9 +1090,7 @@
          */
         removeNetworkIfHidden(netId);
 
-        synchronized (mWifiStateTracker) {
-            return WifiNative.removeNetworkCommand(netId);
-        }
+        return mWifiStateTracker.removeNetwork(netId);
     }
 
     /**
@@ -1221,7 +1227,6 @@
                             if (scanResult != null) {
                               scanResult.level = -scanResultLevel;
                               scanList.add(scanResult);
-                              //if (DBG) Log.d(TAG, "ScanResult: " + scanResult);
                             }
                         } else if (DBG) {
                             Log.w(TAG,
@@ -1344,7 +1349,7 @@
             if (result && mNeedReconfig) {
                 mNeedReconfig = false;
                 result = WifiNative.reloadConfigCommand();
-                
+
                 if (result) {
                     Intent intent = new Intent(WifiManager.NETWORK_IDS_CHANGED_ACTION);
                     mContext.sendBroadcast(intent);
@@ -1446,9 +1451,7 @@
             int stayAwakeConditions =
                     Settings.System.getInt(mContext.getContentResolver(),
                                            Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0);
-            if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
-                /* do nothing, we'll check isAirplaneModeOn later. */
-            } else if (action.equals(Intent.ACTION_SCREEN_ON)) {
+            if (action.equals(Intent.ACTION_SCREEN_ON)) {
                 mAlarmManager.cancel(mIdleIntent);
                 mDeviceIdle = false;
                 mScreenOff = false;
@@ -1543,7 +1546,6 @@
     }
 
     private void sendStartMessage(boolean scanOnlyMode) {
-        if (DBG) Log.d(TAG, "sendStartMessage(" + scanOnlyMode + ")");
         Message.obtain(mWifiHandler, MESSAGE_START_WIFI, scanOnlyMode ? 1 : 0, 0).sendToTarget();
     }
 
@@ -1561,6 +1563,9 @@
         }
 
         synchronized (mWifiHandler) {
+            if (mWifiState == WIFI_STATE_ENABLING && !airplaneMode) {
+                return;
+            }
             if (wifiShouldBeEnabled) {
                 if (wifiShouldBeStarted) {
                     sWakeLock.acquire();
@@ -1573,6 +1578,15 @@
                                     mContext.getContentResolver(),
                                     Settings.Secure.WIFI_MOBILE_DATA_TRANSITION_WAKELOCK_TIMEOUT_MS,
                                     DEFAULT_WAKELOCK_TIMEOUT);
+                    /*
+                     * The following wakelock is held in order to ensure
+                     * that the connectivity manager has time to fail over
+                     * to the mobile data network. The connectivity manager
+                     * releases it once mobile data connectivity has been
+                     * established. If connectivity cannot be established,
+                     * the wakelock is released after wakeLockTimeout
+                     * milliseconds have elapsed.
+                     */
                     sDriverStopWakeLock.acquire();
                     mWifiHandler.sendEmptyMessage(MESSAGE_STOP_WIFI);
                     mWifiHandler.sendEmptyMessageDelayed(MESSAGE_RELEASE_WAKELOCK, wakeLockTimeout);
@@ -1585,18 +1599,15 @@
     }
 
     private void registerForBroadcasts() {
+        IntentFilter intentFilter = new IntentFilter();
         if (isAirplaneSensitive()) {
-            mContext.registerReceiver(mReceiver,
-                new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED));
+            intentFilter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
         }
-        mContext.registerReceiver(mReceiver,
-                new IntentFilter(Intent.ACTION_SCREEN_ON));
-        mContext.registerReceiver(mReceiver,
-                new IntentFilter(Intent.ACTION_SCREEN_OFF));
-        mContext.registerReceiver(mReceiver,
-                new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
-        mContext.registerReceiver(mReceiver,
-                new IntentFilter(ACTION_DEVICE_IDLE));
+        intentFilter.addAction(Intent.ACTION_SCREEN_ON);
+        intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
+        intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
+        intentFilter.addAction(ACTION_DEVICE_IDLE);
+        mContext.registerReceiver(mReceiver, intentFilter);
     }
     
     private boolean isAirplaneSensitive() {
@@ -1664,7 +1675,7 @@
 
     @Override
     protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DUMP)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
                 != PackageManager.PERMISSION_GRANTED) {
             pw.println("Permission Denial: can't dump WifiService from from pid="
                     + Binder.getCallingPid()
@@ -1672,11 +1683,14 @@
             return;
         }
         pw.println("Wi-Fi is " + stateName(mWifiState));
-        pw.println("stay-awake conditions: " +
+        pw.println("Stay-awake conditions: " +
                 Settings.System.getInt(mContext.getContentResolver(),
                                        Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0));
         pw.println();
 
+        pw.println("Internal state:");
+        pw.println(mWifiStateTracker);
+        pw.println();
         pw.println("Latest scan results:");
         List<ScanResult> scanResults = mWifiStateTracker.getScanResultsList();
         if (scanResults != null && scanResults.size() != 0) {
@@ -1786,13 +1800,6 @@
             return -1;
         }
 
-        private synchronized void clear() {
-            if (!mList.isEmpty()) {
-                mList.clear();
-                updateWifiState();
-            }
-        }
-
         private void dump(PrintWriter pw) {
             for (WifiLock l : mList) {
                 pw.print("    ");
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 7ed0aec..09f5d8f 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -122,7 +122,9 @@
     static final boolean DEBUG = false;
     static final boolean DEBUG_FOCUS = false;
     static final boolean DEBUG_ANIM = false;
+    static final boolean DEBUG_LAYERS = false;
     static final boolean DEBUG_INPUT = false;
+    static final boolean DEBUG_INPUT_METHOD = false;
     static final boolean DEBUG_VISIBILITY = false;
     static final boolean DEBUG_ORIENTATION = false;
     static final boolean DEBUG_APP_TRANSITIONS = false;
@@ -202,6 +204,8 @@
 
     final boolean mHaveInputMethods;
     
+    final boolean mLimitedAlphaCompositing;
+    
     final WindowManagerPolicy mPolicy = PolicyManager.makeNewWindowManager();
 
     final IActivityManager mActivityManager;
@@ -306,6 +310,7 @@
     
     final float[] mTmpFloats = new float[9];
 
+    boolean mSafeMode;
     boolean mDisplayEnabled = false;
     boolean mSystemBooted = false;
     int mRotation = 0;
@@ -316,7 +321,6 @@
     
     boolean mLayoutNeeded = true;
     boolean mAnimationPending = false;
-    boolean mSurfacesChanged = false;
     boolean mDisplayFrozen = false;
     boolean mWindowsFreezingScreen = false;
     long mFreezeGcPending = 0;
@@ -347,6 +351,8 @@
     // This just indicates the window the input method is on top of, not
     // necessarily the window its input is going to.
     WindowState mInputMethodTarget = null;
+    boolean mInputMethodTargetWaitingAnim;
+    int mInputMethodAnimLayerAdjustment;
     
     WindowState mInputMethodWindow = null;
     final ArrayList<WindowState> mInputMethodDialogs = new ArrayList<WindowState>();
@@ -461,6 +467,8 @@
             boolean haveInputMethods) {
         mContext = context;
         mHaveInputMethods = haveInputMethods;
+        mLimitedAlphaCompositing = context.getResources().getBoolean(
+                com.android.internal.R.bool.config_sf_limitedAlpha);
         
         mPowerManager = pm;
         mPowerManager.setPolicy(mPolicy);
@@ -734,7 +742,7 @@
         }
     }
     
-    int findDesiredInputMethodWindowIndexLocked() {
+    int findDesiredInputMethodWindowIndexLocked(boolean willMove) {
         final ArrayList localmWindows = mWindows;
         final int N = localmWindows.size();
         WindowState w = null;
@@ -753,17 +761,67 @@
                 }
             }
         }
+        
+        if (DEBUG_INPUT_METHOD) Log.v(TAG, "Desired input method target="
+                + w + " willMove=" + willMove);
+        
+        if (willMove && w != null) {
+            final WindowState curTarget = mInputMethodTarget;
+            if (curTarget != null && curTarget.mAppToken != null) {
+                int curIndex = -1;
+                if (DEBUG_INPUT_METHOD) Log.v(TAG, "mNextAppTransition=" 
+                        + mNextAppTransition + " curTarget animating="
+                        + curTarget.isAnimating()
+                        + " layer=" + curTarget.mAnimLayer
+                        + " new layer=" + w.mAnimLayer);
+                if (mNextAppTransition != WindowManagerPolicy.TRANSIT_NONE) {
+                    // If we are currently setting up for an animation,
+                    // hold everything until we can find out what will happen.
+                    mInputMethodTargetWaitingAnim = true;
+                    curIndex = localmWindows.indexOf(curTarget);
+                } else if (curTarget.isAnimating() &&
+                        curTarget.mAnimLayer > w.mAnimLayer) {
+                    // If the window we are currently targeting is involved
+                    // with an animation, and it is on top of the next target
+                    // we will be over, then hold off on moving until
+                    // that is done.
+                    curIndex = localmWindows.indexOf(curTarget);
+                }
+                if (curIndex >= 0) {
+                    return curIndex + 1;
+                }
+            }
+        }
+        
         //Log.i(TAG, "Placing input method @" + (i+1));
         if (w != null) {
-            mInputMethodTarget = w;
+            if (willMove) {
+                RuntimeException e = new RuntimeException();
+                e.fillInStackTrace();
+                if (DEBUG_INPUT_METHOD) Log.w(TAG, "Moving IM target from "
+                        + mInputMethodTarget + " to " + w, e);
+                mInputMethodTarget = w;
+                if (w.mAppToken != null) {
+                    setInputMethodAnimLayerAdjustment(w.mAppToken.animLayerAdjustment);
+                } else {
+                    setInputMethodAnimLayerAdjustment(0);
+                }
+            }
             return i+1;
         }
-        mInputMethodTarget = null;
+        if (willMove) {
+            RuntimeException e = new RuntimeException();
+            e.fillInStackTrace();
+            if (DEBUG_INPUT_METHOD) Log.w(TAG, "Moving IM target from "
+                    + mInputMethodTarget + " to null", e);
+            mInputMethodTarget = null;
+            setInputMethodAnimLayerAdjustment(0);
+        }
         return -1;
     }
     
     void addInputMethodWindowToListLocked(WindowState win) {
-        int pos = findDesiredInputMethodWindowIndexLocked();
+        int pos = findDesiredInputMethodWindowIndexLocked(true);
         if (pos >= 0) {
             win.mTargetAppToken = mInputMethodTarget.mAppToken;
             mWindows.add(pos, win);
@@ -775,6 +833,33 @@
         moveInputMethodDialogsLocked(pos);
     }
     
+    void setInputMethodAnimLayerAdjustment(int adj) {
+        if (DEBUG_LAYERS) Log.v(TAG, "Setting im layer adj to " + adj);
+        mInputMethodAnimLayerAdjustment = adj;
+        WindowState imw = mInputMethodWindow;
+        if (imw != null) {
+            imw.mAnimLayer = imw.mLayer + adj;
+            if (DEBUG_LAYERS) Log.v(TAG, "IM win " + imw
+                    + " anim layer: " + imw.mAnimLayer);
+            int wi = imw.mChildWindows.size();
+            while (wi > 0) {
+                wi--;
+                WindowState cw = (WindowState)imw.mChildWindows.get(wi);
+                cw.mAnimLayer = cw.mLayer + adj;
+                if (DEBUG_LAYERS) Log.v(TAG, "IM win " + cw
+                        + " anim layer: " + cw.mAnimLayer);
+            }
+        }
+        int di = mInputMethodDialogs.size();
+        while (di > 0) {
+            di --;
+            imw = mInputMethodDialogs.get(di);
+            imw.mAnimLayer = imw.mLayer + adj;
+            if (DEBUG_LAYERS) Log.v(TAG, "IM win " + imw
+                    + " anim layer: " + imw.mAnimLayer);
+        }
+    }
+    
     private int tmpRemoveWindowLocked(int interestingPos, WindowState win) {
         int wpos = mWindows.indexOf(win);
         if (wpos >= 0) {
@@ -814,9 +899,11 @@
         }
         if (pos >= 0) {
             final AppWindowToken targetAppToken = mInputMethodTarget.mAppToken;
-            WindowState wp = (WindowState)mWindows.get(pos);
-            if (wp == mInputMethodWindow) {
-                pos++;
+            if (pos < mWindows.size()) {
+                WindowState wp = (WindowState)mWindows.get(pos);
+                if (wp == mInputMethodWindow) {
+                    pos++;
+                }
             }
             for (int i=0; i<N; i++) {
                 WindowState win = dialogs.get(i);
@@ -839,7 +926,7 @@
             return false;
         }
         
-        int imPos = findDesiredInputMethodWindowIndexLocked();
+        int imPos = findDesiredInputMethodWindowIndexLocked(true);
         if (imPos >= 0) {
             // In this case, the input method windows are to be placed
             // immediately above the window they are targeting.
@@ -915,7 +1002,7 @@
     }
     
     void adjustInputMethodDialogsLocked() {
-        moveInputMethodDialogsLocked(findDesiredInputMethodWindowIndexLocked());
+        moveInputMethodDialogsLocked(findDesiredInputMethodWindowIndexLocked(true));
     }
     
     public int addWindow(Session session, IWindow client,
@@ -975,7 +1062,7 @@
                           + attrs.token + ".  Aborting.");
                     return WindowManagerImpl.ADD_BAD_APP_TOKEN;
                 }
-                token = new WindowToken(attrs.token, -1);
+                token = new WindowToken(attrs.token, -1, false);
                 addToken = true;
             } else if (attrs.type >= FIRST_APPLICATION_WINDOW
                     && attrs.type <= LAST_APPLICATION_WINDOW) {
@@ -1087,11 +1174,23 @@
                 + ": window=" + win);
         }
 
+        // sendNewConfiguration() checks caller permissions so we must call it with
+        // privilege.  updateOrientationFromAppTokens() clears and resets the caller
+        // identity anyway, so it's safe to just clear & restore around this whole
+        // block.
+        final long origId = Binder.clearCallingIdentity();
         if (reportNewConfig) {
-            final long origId = Binder.clearCallingIdentity();
             sendNewConfiguration();
-            Binder.restoreCallingIdentity(origId);
+        } else {
+            // Update Orientation after adding a window, only if the window needs to be
+            // displayed right away
+            if (win.isVisibleOrAdding()) {
+                if (updateOrientationFromAppTokens(null) != null) {
+                    sendNewConfiguration();
+                }
+            }
         }
+        Binder.restoreCallingIdentity(origId);
         
         return res;
     }
@@ -1125,7 +1224,8 @@
                 + " inPendingTransaction="
                 + (win.mAppToken != null ? win.mAppToken.inPendingTransaction : false)
                 + " mDisplayFrozen=" + mDisplayFrozen);
-        
+        // Visibility of the removed window. Will be used later to update orientation later on.
+        boolean wasVisible = false;
         // First, see if we need to run an animation.  If we do, we have
         // to hold off on removing the window until the animation is done.
         // If the display is frozen, just remove immediately, since the
@@ -1133,7 +1233,8 @@
         if (win.mSurface != null && !mDisplayFrozen) {
             // If we are not currently running the exit animation, we
             // need to see about starting one.
-            if (win.isVisibleLw()) {
+            if (wasVisible=win.isVisibleLw()) {
+                
                 int transit = WindowManagerPolicy.TRANSIT_EXIT;
                 if (win.getAttrs().type == TYPE_APPLICATION_STARTING) {
                     transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
@@ -1161,6 +1262,13 @@
         }
 
         removeWindowInnerLocked(session, win);
+        // Removing a visible window will effect the computed orientation
+        // So just update orientation if needed.
+        if (wasVisible) {
+            if (updateOrientationFromAppTokens(null) != null) {
+                sendNewConfiguration();
+            }
+        }
         updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL);
         Binder.restoreCallingIdentity(origId);
     }
@@ -1191,10 +1299,10 @@
                 TAG, "**** Removing window " + win + ": count="
                 + token.windows.size());
         if (token.windows.size() == 0) {
-            if (atoken != token) {
+            if (!token.explicit) {
                 mTokenMap.remove(token.token);
                 mTokenList.remove(token);
-            } else {
+            } else if (atoken != null) {
                 atoken.firstWindowDrawn = false;
             }
         }
@@ -1287,7 +1395,7 @@
             Surface outSurface) {
         boolean displayed = false;
         boolean inTouchMode;
-
+        Configuration newConfig = null;
         long origId = Binder.clearCallingIdentity();
         
         synchronized(mWindowMap) {
@@ -1435,6 +1543,7 @@
             if (assignLayers) {
                 assignLayersLocked();
             }
+            newConfig = updateOrientationFromAppTokensLocked(null);
             performLayoutAndPlaceSurfacesLocked();
             if (win.mAppToken != null) {
                 win.mAppToken.updateReportedVisibilityLocked();
@@ -1456,6 +1565,10 @@
             inTouchMode = mInTouchMode;
         }
 
+        if (newConfig != null) {
+            sendNewConfiguration();
+        }
+        
         Binder.restoreCallingIdentity(origId);
         
         return (inTouchMode ? WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE : 0)
@@ -1708,7 +1821,7 @@
                 Log.w(TAG, "Attempted to add existing input method token: " + token);
                 return;
             }
-            wtoken = new WindowToken(token, type);
+            wtoken = new WindowToken(token, type, true);
             mTokenMap.put(token, wtoken);
             mTokenList.add(wtoken);
         }
@@ -1812,12 +1925,32 @@
         }
     }
     
-    public Configuration updateOrientationFromAppTokens(
-            IBinder freezeThisOneIfNeeded) {
-        boolean changed = false;
-        synchronized(mWindowMap) {
+    public int getOrientationFromWindowsLocked() {
+        int pos = mWindows.size() - 1;
+        while (pos >= 0) {
+            WindowState wtoken = (WindowState) mWindows.get(pos);
+            pos--;
+            if (wtoken.mAppToken != null) {
+                // We hit an application window. so the orientation will be determined by the
+                // app window. No point in continuing further.
+                return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+            }
+            if (!wtoken.isVisibleLw()) {
+                continue;
+            }
+            int req = wtoken.mAttrs.screenOrientation;
+            if((req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) ||
+                    (req == ActivityInfo.SCREEN_ORIENTATION_BEHIND)){
+                continue;
+            } else {
+                return req;
+            }
+        }
+        return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+    }
+    
+    public int getOrientationFromAppTokensLocked() {
             int pos = mAppTokens.size() - 1;
-            int req = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
             int curGroup = 0;
             int lastOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
             boolean haveGroup = false;
@@ -1838,7 +1971,7 @@
                     // the orientation behind it, then we'll stick with the
                     // user's orientation.
                     if (lastOrientation != ActivityInfo.SCREEN_ORIENTATION_BEHIND) {
-                        break;
+                        return lastOrientation;
                     }
                 }
                 int or = wtoken.requestedOrientation;
@@ -1849,10 +1982,45 @@
                         or == ActivityInfo.SCREEN_ORIENTATION_SENSOR ||
                         or == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR ||
                         or == ActivityInfo.SCREEN_ORIENTATION_USER) {
-                    req = or;
-                    break;
+                    return or;
                 }
             }
+            return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+    }
+    
+    public Configuration updateOrientationFromAppTokens(
+        IBinder freezeThisOneIfNeeded) {
+        Configuration config;
+        long ident = Binder.clearCallingIdentity();
+        synchronized(mWindowMap) {
+            config = updateOrientationFromAppTokensLocked(freezeThisOneIfNeeded);
+        }
+        if (config != null) {
+            mLayoutNeeded = true;
+            performLayoutAndPlaceSurfacesLocked();
+        }
+        Binder.restoreCallingIdentity(ident);
+        return config;
+    }
+    
+    /*
+     * The orientation is computed from non-application windows first. If none of
+     * the non-application windows specify orientation, the orientation is computed from
+     * application tokens. 
+     * @see android.view.IWindowManager#updateOrientationFromAppTokens(
+     * android.os.IBinder)
+     */
+    public Configuration updateOrientationFromAppTokensLocked(
+            IBinder freezeThisOneIfNeeded) {
+        boolean changed = false;
+        Configuration config = null;
+        long ident = Binder.clearCallingIdentity();
+        try {
+            int req = getOrientationFromWindowsLocked();
+            if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
+                req = getOrientationFromAppTokensLocked();
+            }
+            
             if (req != mForcedAppOrientation) {
                 changed = true;
                 mForcedAppOrientation = req;
@@ -1873,14 +2041,11 @@
                                     ActivityInfo.CONFIG_ORIENTATION);
                         }
                     }
-                    Configuration config = computeNewConfigurationLocked();
-                    if (config != null) {
-                        mLayoutNeeded = true;
-                        performLayoutAndPlaceSurfacesLocked();
-                    }
-                    return config;
+                    return computeNewConfiguration();
                 }
             }
+        } finally {
+            Binder.restoreCallingIdentity(ident);
         }
         
         return null;
@@ -2871,6 +3036,10 @@
         return KeyInputQueue.getKeycodeState(devid, sw);
     }
     
+    public boolean hasKeys(int[] keycodes, boolean[] keyExists) {
+        return KeyInputQueue.hasKeys(keycodes, keyExists);
+    }
+    
     public void enableScreenAfterBoot() {
         synchronized(mWindowMap) {
             if (mSystemBooted) {
@@ -2987,18 +3156,19 @@
         } else {
             mRequestedRotation = rotation;
         }
-        if (DEBUG_ORIENTATION) Log.v(TAG, "Overwriting rotation value from "+rotation);
-        rotation = mPolicy.rotationForOrientation(mForcedAppOrientation);
-        if (DEBUG_ORIENTATION) Log.v(TAG, "new rotation is set to "+rotation);
+        if (DEBUG_ORIENTATION) Log.v(TAG, "Overwriting rotation value from " + rotation);
+        rotation = mPolicy.rotationForOrientation(mForcedAppOrientation,
+                mRotation, mDisplayEnabled);
+        if (DEBUG_ORIENTATION) Log.v(TAG, "new rotation is set to " + rotation);
         changed = mDisplayEnabled && mRotation != rotation;
         
         if (changed) {
-            mRotation = rotation;
             if (DEBUG_ORIENTATION) Log.v(TAG, 
                     "Rotation changed to " + rotation
                     + " from " + mRotation
                     + " (forceApp=" + mForcedAppOrientation
                     + ", req=" + mRequestedRotation + ")");
+            mRotation = rotation;
             mWindowsFreezingScreen = true;
             mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
             mH.sendMessageDelayed(mH.obtainMessage(H.WINDOW_FREEZE_TIMEOUT),
@@ -3298,21 +3468,18 @@
         return null;
     }
 
+    /*
+     * Instruct the Activity Manager to fetch the current configuration and broadcast
+     * that to config-changed listeners if appropriate.
+     */
     void sendNewConfiguration() {
-        Configuration config;
-        synchronized (mWindowMap) {
-            config = computeNewConfigurationLocked();
-        }
-        
-        if (config != null) {
-            try {
-                mActivityManager.updateConfiguration(config);
-            } catch (RemoteException e) {
-            }
+        try {
+            mActivityManager.updateConfiguration(null);
+        } catch (RemoteException e) {
         }
     }
     
-    Configuration computeNewConfigurationLocked() {
+    public Configuration computeNewConfiguration() {
         synchronized (mWindowMap) {
             if (mDisplay == null) {
                 return null;
@@ -4610,6 +4777,11 @@
         }
     };
 
+    public boolean detectSafeMode() {
+        mSafeMode = mPolicy.detectSafeMode();
+        return mSafeMode;
+    }
+    
     public void systemReady() {
         mPolicy.systemReady();
     }
@@ -5639,6 +5811,11 @@
             mAnimating = false;
             mAnimation = null;
             mAnimLayer = mLayer;
+            if (mIsImWindow) {
+                mAnimLayer += mInputMethodAnimLayerAdjustment;
+            }
+            if (DEBUG_LAYERS) Log.v(TAG, "Stepping win " + this
+                    + " anim layer: " + mAnimLayer);
             mHasTransformation = false;
             mPolicyVisibility = mPolicyVisibilityAfterAnim;
             mTransformation.clear();
@@ -5755,7 +5932,8 @@
                 // transforming since it is more important to have that
                 // animation be smooth.
                 mShownAlpha = mAlpha;
-                if (false && (!PixelFormat.formatHasAlpha(mAttrs.format)
+                if (!mLimitedAlphaCompositing
+                        || (!PixelFormat.formatHasAlpha(mAttrs.format)
                         || (isIdentityMatrix(mDsDx, mDtDx, mDsDy, mDtDy)
                                 && x == frame.left && y == frame.top))) {
                     //Log.i(TAG, "Applying alpha transform");
@@ -5944,21 +6122,23 @@
             return mHasDrawn;
         }
 
-        public void showLw(boolean doAnimation) {
+        public boolean showLw(boolean doAnimation) {
             if (!mPolicyVisibility || !mPolicyVisibilityAfterAnim) {
-                mSurfacesChanged = true;
                 mPolicyVisibility = true;
                 mPolicyVisibilityAfterAnim = true;
                 if (doAnimation) {
                     applyAnimationLocked(this, WindowManagerPolicy.TRANSIT_ENTER, true);
                 }
                 requestAnimationLocked(0);
+                return true;
             }
+            return false;
         }
 
-        public void hideLw(boolean doAnimation) {
-            if (mPolicyVisibility || mPolicyVisibilityAfterAnim) {
-                mSurfacesChanged = true;
+        public boolean hideLw(boolean doAnimation) {
+            boolean current = doAnimation ? mPolicyVisibilityAfterAnim
+                    : mPolicyVisibility;
+            if (current) {
                 if (doAnimation) {
                     applyAnimationLocked(this, WindowManagerPolicy.TRANSIT_EXIT, false);
                     if (mAnimation == null) {
@@ -5968,10 +6148,13 @@
                 if (doAnimation) {
                     mPolicyVisibilityAfterAnim = false;
                 } else {
+                    mPolicyVisibilityAfterAnim = false;
                     mPolicyVisibility = false;
                 }
                 requestAnimationLocked(0);
+                return true;
             }
+            return false;
         }
 
         void dump(PrintWriter pw, String prefix) {
@@ -6054,6 +6237,10 @@
         // The type of window this token is for, as per WindowManager.LayoutParams.
         final int windowType;
         
+        // Set if this token was explicitly added by a client, so should
+        // not be removed when all windows are removed.
+        final boolean explicit;
+        
         // If this is an AppWindowToken, this is non-null.
         AppWindowToken appWindowToken;
         
@@ -6069,9 +6256,10 @@
         // Temporary for finding which tokens no longer have visible windows.
         boolean hasVisible;
 
-        WindowToken(IBinder _token, int type) {
+        WindowToken(IBinder _token, int type, boolean _explicit) {
             token = _token;
             windowType = type;
+            explicit = _explicit;
         }
 
         void dump(PrintWriter pw, String prefix) {
@@ -6151,7 +6339,8 @@
         boolean firstWindowDrawn;
 
         AppWindowToken(IApplicationToken _token) {
-            super(_token.asBinder(), WindowManager.LayoutParams.TYPE_APPLICATION);
+            super(_token.asBinder(),
+                    WindowManager.LayoutParams.TYPE_APPLICATION, true);
             appWindowToken = this;
             appToken = _token;
         }
@@ -6198,17 +6387,10 @@
             for (int i=0; i<N; i++) {
                 WindowState w = allAppWindows.get(i);
                 w.mAnimLayer = w.mLayer + adj;
+                if (DEBUG_LAYERS) Log.v(TAG, "Updating layer " + w + ": "
+                        + w.mAnimLayer);
                 if (w == mInputMethodTarget) {
-                    WindowState imw = mInputMethodWindow;
-                    if (imw != null) {
-                        imw.mAnimLayer = imw.mLayer + adj;
-                    }
-                    int di = mInputMethodDialogs.size();
-                    while (di > 0) {
-                        di --;
-                        imw = mInputMethodDialogs.get(di);
-                        imw.mAnimLayer = imw.mLayer + adj;
-                    }
+                    setInputMethodAnimLayerAdjustment(adj);
                 }
             }
         }
@@ -6295,7 +6477,10 @@
 
             clearAnimation();
             animating = false;
-
+            if (mInputMethodTarget != null && mInputMethodTarget.mAppToken == this) {
+                moveInputMethodWindowsIfNeededLocked(true);
+            }
+            
             if (DEBUG_ANIM) Log.v(
                     TAG, "Animation done in " + this
                     + ": reportedVisible=" + reportedVisible);
@@ -6519,6 +6704,10 @@
                     synchronized(mWindowMap) {
                         lastFocus = mLastFocus;
                         newFocus = mCurrentFocus;
+                        if (lastFocus == newFocus) {
+                            // Focus is not changing, so nothing to do.
+                            return;
+                        }
                         mLastFocus = newFocus;
                         //Log.i(TAG, "Focus moving from " + lastFocus
                         //        + " to " + newFocus);
@@ -6848,7 +7037,7 @@
         synchronized (mWindowMap) {
             // The focus for the client is the window immediately below
             // where we would place the input method window.
-            int idx = findDesiredInputMethodWindowIndexLocked();
+            int idx = findDesiredInputMethodWindowIndexLocked(false);
             if (idx > 0) {
                 WindowState imFocus = (WindowState)mWindows.get(idx-1);
                 if (imFocus != null && imFocus.mSession.mClient != null &&
@@ -6888,13 +7077,6 @@
     }
 
     private final void assignLayersLocked() {
-        if (mInLayout) {
-            if (Config.DEBUG) {
-                throw new RuntimeException("Recursive call!");
-            }
-            return;
-        }
-
         int N = mWindows.size();
         int curBaseLayer = 0;
         int curLayer = 0;
@@ -6916,6 +7098,11 @@
             } else {
                 w.mAnimLayer = w.mLayer;
             }
+            if (w.mIsImWindow) {
+                w.mAnimLayer += mInputMethodAnimLayerAdjustment;
+            }
+            if (DEBUG_LAYERS) Log.v(TAG, "Assign layer " + w + ": "
+                    + w.mAnimLayer);
             //System.out.println(
             //    "Assigned layer " + curLayer + " to " + w.mClient.asBinder());
         }
@@ -6927,6 +7114,7 @@
             if (Config.DEBUG) {
                 throw new RuntimeException("Recursive call!");
             }
+            Log.w(TAG, "performLayoutAndPlaceSurfacesLocked called while in layout");
             return;
         }
 
@@ -6999,7 +7187,8 @@
                 WindowState win = (WindowState) mWindows.get(i);
     
                 boolean gone = win.mViewVisibility == View.GONE
-                        || !win.mRelayoutCalled;
+                        || !win.mRelayoutCalled
+                        || win.mToken.hidden;
 
                 // If this view is GONE, then skip it -- keep the current
                 // frame, and let the caller know so they can ignore it
@@ -7285,6 +7474,7 @@
                         // This has changed the visibility of windows, so perform
                         // a new layout to get them all up-to-date.
                         mLayoutNeeded = true;
+                        moveInputMethodWindowsIfNeededLocked(true);
                         performLayoutLockedInner();
                         updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES);
 
@@ -7297,7 +7487,6 @@
 
             final boolean someoneLosingFocus = mLosingFocus.size() != 0;
 
-            mSurfacesChanged = false;
             boolean obscured = false;
             boolean blurring = false;
             boolean dimming = false;
@@ -7673,7 +7862,10 @@
                 mDimCurrentAlpha += mDimDeltaPerMs
                         * (currentTime-mLastDimAnimTime);
                 boolean more = true;
-                if (mDimDeltaPerMs > 0) {
+                if (mDisplayFrozen) {
+                    // If the display is frozen, there is no reason to animate.
+                    more = false;
+                } else if (mDimDeltaPerMs > 0) {
                     if (mDimCurrentAlpha > mDimTargetAlpha) {
                         more = false;
                     }
@@ -7811,7 +8003,7 @@
     }
     
     /**
-     * Have the surface flinger show a surface, robustly dealing wit
+     * Have the surface flinger show a surface, robustly dealing with
      * error conditions.  In particular, if there is not enough memory
      * to show the surface, then we will try to get rid of other surfaces
      * in order to succeed.
@@ -7925,9 +8117,8 @@
         if (mCurrentFocus != newFocus) {
             // This check makes sure that we don't already have the focus
             // change message pending.
-            if (mLastFocus == mCurrentFocus) {
-                mH.sendEmptyMessage(H.REPORT_FOCUS_CHANGE);
-            }
+            mH.removeMessages(H.REPORT_FOCUS_CHANGE);
+            mH.sendEmptyMessage(H.REPORT_FOCUS_CHANGE);
             if (localLOGV) Log.v(
                 TAG, "Changing focus from " + mCurrentFocus + " to " + newFocus);
             final WindowState oldFocus = mCurrentFocus;
@@ -8218,13 +8409,14 @@
             pw.println("  mSystemBooted=" + mSystemBooted
                     + " mDisplayEnabled=" + mDisplayEnabled);
             pw.println("  mLayoutNeeded=" + mLayoutNeeded
-                    + " mSurfacesChanged=" + mSurfacesChanged
                     + " mBlurShown=" + mBlurShown);
             pw.println("  mDimShown=" + mDimShown
                     + " current=" + mDimCurrentAlpha
                     + " target=" + mDimTargetAlpha
                     + " delta=" + mDimDeltaPerMs
                     + " lastAnimTime=" + mLastDimAnimTime);
+            pw.println("  mInputMethodAnimLayerAdjustment="
+                    + mInputMethodAnimLayerAdjustment);
             pw.println("  mDisplayFrozen=" + mDisplayFrozen
                     + " mWindowsFreezingScreen=" + mWindowsFreezingScreen
                     + " mAppsFreezingScreen=" + mAppsFreezingScreen);
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 361c7f7..f5efe4b 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -48,6 +48,7 @@
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.ConfigurationInfo;
 import android.content.pm.IPackageDataObserver;
 import android.content.pm.IPackageManager;
 import android.content.pm.InstrumentationInfo;
@@ -96,6 +97,7 @@
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.PrintWriter;
+import java.lang.IllegalStateException;
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -631,6 +633,11 @@
      * any user id that can impact battery performance.
      */
     final BatteryStatsService mBatteryStatsService;
+    
+    /**
+     * information about component usage
+     */
+    final UsageStatsService mUsageStatsService;
 
     /**
      * Current configuration information.  HistoryRecord objects are given
@@ -1053,6 +1060,7 @@
         m.mLaunchingActivity.setReferenceCounted(false);
         
         m.mBatteryStatsService.publish(context);
+        m.mUsageStatsService.publish(context);
         
         synchronized (thr) {
             thr.mReady = true;
@@ -1186,8 +1194,7 @@
                     procs = service.mLRUProcesses;
                 }
             }
-            pw.println("Applications Memory Usage (kB):");
-            dumpApplicationMemoryUsage(fd, pw, procs, "  ");
+            dumpApplicationMemoryUsage(fd, pw, procs, "  ", args);
         }
     }
 
@@ -1224,6 +1231,9 @@
                 systemDir, "batterystats.bin").toString());
         mBatteryStatsService.getActiveStatistics().readLocked();
         mBatteryStatsService.getActiveStatistics().writeLocked();
+        
+        mUsageStatsService = new UsageStatsService( new File(
+                systemDir, "usagestats.bin").toString());
 
         mConfiguration.makeDefault();
         mProcessStats.init();
@@ -1522,6 +1532,8 @@
             app.thread.scheduleLaunchActivity(new Intent(r.intent), r,
                     r.info, r.icicle, results, newIntents, !andResume,
                     isNextTransitionForward());
+            // Update usage stats for launched activity
+            updateUsageStats(r, true);
         } catch (RemoteException e) {
             if (r.launchFailed) {
                 // This is the second time we failed -- finish activity
@@ -1804,6 +1816,7 @@
                         prev.shortComponentName);
                 prev.app.thread.schedulePauseActivity(prev, prev.finishing, userLeaving,
                         prev.configChangeFlags);
+                updateUsageStats(prev, false);
             } catch (Exception e) {
                 // Ignore exception, if process died other code will cleanup.
                 Log.w(TAG, "Exception thrown during pause", e);
@@ -1848,6 +1861,7 @@
     private final void completePauseLocked() {
         HistoryRecord prev = mPausingActivity;
         if (DEBUG_PAUSE) Log.v(TAG, "Complete pause: " + prev);
+        
         if (prev != null) {
             if (prev.finishing) {
                 if (DEBUG_PAUSE) Log.v(TAG, "Executing finish of activity: " + prev);
@@ -2085,6 +2099,14 @@
             ensureActivitiesVisibleLocked(r, starting, null, configChanges);
         }
     }
+    
+    private void updateUsageStats(HistoryRecord resumedComponent, boolean resumed) {
+        if (resumed) {
+            mUsageStatsService.noteResumeComponent(resumedComponent.realActivity);
+        } else {
+            mUsageStatsService.notePauseComponent(resumedComponent.realActivity);
+        }
+    }
 
     /**
      * Ensure that the top activity in the stack is resumed.
@@ -2290,6 +2312,7 @@
                 EventLog.writeEvent(LOG_AM_RESUME_ACTIVITY,
                         System.identityHashCode(next),
                         next.task.taskId, next.shortComponentName);
+                updateUsageStats(next, true);
                 
                 next.app.thread.scheduleResumeActivity(next,
                         isNextTransitionForward());
@@ -2453,9 +2476,7 @@
                     // We don't want to reuse the previous starting preview if:
                     // (1) The current activity is in a different task.
                     if (prev.task != r.task) prev = null;
-                    // (2) The current activity is not the first in the task.
-                    else if (!prev.frontOfTask) prev = null;
-                    // (3) The current activity is already displayed.
+                    // (2) The current activity is already displayed.
                     else if (prev.nowVisible) prev = null;
                 }
                 mWindowManager.setAppStartingWindow(
@@ -2537,6 +2558,40 @@
     }
 
     /**
+     * Find the activity in the history stack within the given task.  Returns
+     * the index within the history at which it's found, or < 0 if not found.
+     */
+    private final int findActivityInHistoryLocked(HistoryRecord r, int task) {
+        int i = mHistory.size();
+        while (i > 0) {
+            i--;
+            HistoryRecord candidate = (HistoryRecord)mHistory.get(i);
+            if (candidate.task.taskId != task) {
+                break;
+            }
+            if (candidate.realActivity.equals(r.realActivity)) {
+                return i;
+            }
+        }
+
+        return -1;
+    }
+
+    /**
+     * Reorder the history stack so that the activity at the given index is
+     * brought to the front.
+     */
+    private final HistoryRecord moveActivityToFrontLocked(int where) {
+        HistoryRecord newTop = (HistoryRecord)mHistory.remove(where);
+        int top = mHistory.size();
+        HistoryRecord oldTop = (HistoryRecord)mHistory.get(top-1);
+        mHistory.add(top, newTop);
+        oldTop.frontOfTask = false;
+        newTop.frontOfTask = true;
+        return newTop;
+    }
+
+    /**
      * Deliver a new Intent to an existing activity, so that its onNewIntent()
      * method will be called at the proper time.
      */
@@ -2969,6 +3024,19 @@
                     resumeTopActivityLocked(null);
                     return START_DELIVERED_TO_TOP;
                 }
+            } else if (!addingToTask &&
+                    (launchFlags&Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) != 0) {
+                // In this case, we are launching an activity in our own task
+                // that may already be running somewhere in the history, and
+                // we want to shuffle it to the front of the stack if so.
+                int where = findActivityInHistoryLocked(r, sourceRecord.task.taskId);
+                if (where >= 0) {
+                    HistoryRecord top = moveActivityToFrontLocked(where);
+                    logStartActivity(LOG_AM_NEW_INTENT, r, top.task);
+                    deliverNewIntentLocked(top, r.intent);
+                    resumeTopActivityLocked(null);
+                    return START_DELIVERED_TO_TOP;
+                }
             }
             // An existing activity is starting this new activity, so we want
             // to keep the new one in the same task as the one that is starting
@@ -4142,8 +4210,8 @@
         long callingId = Binder.clearCallingIdentity();
         try {
             IPackageManager pm = ActivityThread.getPackageManager();
+            int pkgUid = -1;
             synchronized(this) {
-                int pkgUid = -1;
                 try {
                     pkgUid = pm.getPackageUid(packageName);
                 } catch (RemoteException e) {
@@ -4156,7 +4224,7 @@
                         android.Manifest.permission.CLEAR_APP_USER_DATA,
                         pid, uid, -1)
                         == PackageManager.PERMISSION_GRANTED) {
-                    uninstallPackageLocked(packageName, pkgUid, false);
+                    restartPackageLocked(packageName, pkgUid);
                 } else {
                     throw new SecurityException(pid+" does not have permission:"+
                             android.Manifest.permission.CLEAR_APP_USER_DATA+" to clear data" +
@@ -4167,6 +4235,12 @@
             try {
                 //clear application user data
                 pm.clearApplicationUserData(packageName, observer);
+                Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED,
+                        Uri.fromParts("package", packageName, null));
+                intent.putExtra(Intent.EXTRA_UID, pkgUid);
+                broadcastIntentLocked(null, null, intent,
+                        null, null, 0, null, null, null,
+                        false, false, MY_PID, Process.SYSTEM_UID);
             } catch (RemoteException e) {
             }
         } finally {
@@ -4188,25 +4262,48 @@
         
         long callingId = Binder.clearCallingIdentity();
         try {
+            IPackageManager pm = ActivityThread.getPackageManager();
+            int pkgUid = -1;
             synchronized(this) {
-                uninstallPackageLocked(packageName, -1, false);
-                broadcastIntentLocked(null, null,
-                        new Intent(Intent.ACTION_PACKAGE_RESTARTED,
-                                Uri.fromParts("package", packageName, null)),
-                        null, null, 0, null, null, null,
-                        false, false, MY_PID, Process.SYSTEM_UID);
+                try {
+                    pkgUid = pm.getPackageUid(packageName);
+                } catch (RemoteException e) {
+                }
+                if (pkgUid == -1) {
+                    Log.w(TAG, "Invalid packageName:"+packageName);
+                    return;
+                }
+                restartPackageLocked(packageName, pkgUid);
             }
         } finally {
             Binder.restoreCallingIdentity(callingId);
         }
     }
     
+    private void restartPackageLocked(final String packageName, int uid) {
+        uninstallPackageLocked(packageName, uid, false);
+        Intent intent = new Intent(Intent.ACTION_PACKAGE_RESTARTED,
+                Uri.fromParts("package", packageName, null));
+        intent.putExtra(Intent.EXTRA_UID, uid);
+        broadcastIntentLocked(null, null, intent,
+                null, null, 0, null, null, null,
+                false, false, MY_PID, Process.SYSTEM_UID);
+    }
+    
     private final void uninstallPackageLocked(String name, int uid,
             boolean callerWillRestart) {
         if (Config.LOGD) Log.d(TAG, "Uninstalling process " + name);
 
         int i, N;
 
+        final String procNamePrefix = name + ":";
+        if (uid < 0) {
+            try {
+                uid = ActivityThread.getPackageManager().getPackageUid(name);
+            } catch (RemoteException e) {
+            }
+        }
+
         Iterator<SparseArray<Long>> badApps = mProcessCrashTimes.getMap().values().iterator();
         while (badApps.hasNext()) {
             SparseArray<Long> ba = badApps.next();
@@ -4217,14 +4314,6 @@
 
         ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>();
 
-        final String procNamePrefix = name + ":";
-        if (uid < 0) {
-            try {
-                uid = ActivityThread.getPackageManager().getPackageUid(name);
-            } catch (RemoteException e) {
-            }
-        }
-
         // Remove all processes this package may have touched: all with the
         // same UID (except for the system or root user), and all whose name
         // matches the package name.
@@ -7226,6 +7315,11 @@
         }
     }
 
+    public boolean testIsSystemReady() {
+        // no need to synchronize(this) just to read & return the value
+        return mSystemReady;
+    }
+    
     public void systemReady() {
         // In the simulator, startRunning will never have been called, which
         // normally sets a few crucial variables. Do it here instead.
@@ -7628,6 +7722,21 @@
                     ActivityManager.RunningAppProcessInfo currApp = 
                         new ActivityManager.RunningAppProcessInfo(app.processName,
                                 app.pid, app.getPackageList());
+                    int adj = app.curAdj;
+                    if (adj >= CONTENT_PROVIDER_ADJ) {
+                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY;
+                    } else if (adj >= HIDDEN_APP_MIN_ADJ) {
+                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND;
+                        currApp.lru = adj - HIDDEN_APP_MIN_ADJ;
+                    } else if (adj >= SECONDARY_SERVER_ADJ) {
+                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE;
+                    } else if (adj >= VISIBLE_APP_ADJ) {
+                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE;
+                    } else {
+                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
+                    }
+                    //Log.v(TAG, "Proc " + app.processName + ": imp=" + currApp.importance
+                    //        + " lru=" + currApp.lru);
                     if (runList == null) {
                         runList = new ArrayList<ActivityManager.RunningAppProcessInfo>();
                     }
@@ -8176,30 +8285,55 @@
     }
 
     private static final void dumpApplicationMemoryUsage(FileDescriptor fd,
-            PrintWriter pw, List list, String prefix) {
+            PrintWriter pw, List list, String prefix, String[] args) {
+        final boolean isCheckinRequest = scanArgs(args, "-c");
+        long uptime = SystemClock.uptimeMillis();
+        long realtime = SystemClock.elapsedRealtime();
+        
+        if (isCheckinRequest) {
+            // short checkin version
+            pw.println(uptime + "," + realtime);
+            pw.flush();
+        } else {
+            pw.println("Applications Memory Usage (kB):");
+            pw.println("Uptime: " + uptime + " Realtime: " + realtime);
+        }
         for (int i = list.size() - 1 ; i >= 0 ; i--) {
             ProcessRecord r = (ProcessRecord)list.get(i);
             if (r.thread != null) {
-                pw.println("\n** MEMINFO in pid " + r.pid + " [" + r.processName + "] **");
-                pw.flush();
-
-                Parcel data = Parcel.obtain();
-                Parcel reply = Parcel.obtain();
-                try {
-                    data.writeFileDescriptor(fd);
-                    r.thread.asBinder().transact(IBinder.DUMP_TRANSACTION, data, reply, 0);
-
-                } catch (RemoteException e) {
-                    pw.println("Got RemoteException!");
+                if (!isCheckinRequest) {
+                    pw.println("\n** MEMINFO in pid " + r.pid + " [" + r.processName + "] **");
                     pw.flush();
                 }
-
-                data.recycle();
-                reply.recycle();
+                try {
+                    r.thread.asBinder().dump(fd, args);
+                } catch (RemoteException e) {
+                    if (!isCheckinRequest) {
+                        pw.println("Got RemoteException!");
+                        pw.flush();
+                    }
+                }
             }
         }
     }
 
+    /**
+     * Searches array of arguments for the specified string
+     * @param args array of argument strings
+     * @param value value to search for
+     * @return true if the value is contained in the array
+     */
+    private static boolean scanArgs(String[] args, String value) {
+        if (args != null) {
+            for (String arg : args) {
+                if (value.equals(arg)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     private final int indexOfTokenLocked(IBinder token, boolean required) {
         int count = mHistory.size();
 
@@ -9120,6 +9254,36 @@
         return 0;
     }
 
+    public IBinder peekService(Intent service, String resolvedType) {
+        // Refuse possible leaked file descriptors
+        if (service != null && service.hasFileDescriptors() == true) {
+            throw new IllegalArgumentException("File descriptors passed in Intent");
+        }
+
+        IBinder ret = null;
+
+        synchronized(this) {
+            ServiceLookupResult r = findServiceLocked(service, resolvedType);
+            
+            if (r != null) {
+                // r.record is null if findServiceLocked() failed the caller permission check
+                if (r.record == null) {
+                    throw new SecurityException(
+                            "Permission Denial: Accessing service " + r.record.name
+                            + " from pid=" + Binder.getCallingPid()
+                            + ", uid=" + Binder.getCallingUid()
+                            + " requires " + r.permission);
+                }
+                IntentBindRecord ib = r.record.bindings.get(r.record.intent);
+                if (ib != null) {
+                    ret = ib.binder;
+                }
+            }
+        }
+
+        return ret;
+    }
+    
     public boolean stopServiceToken(ComponentName className, IBinder token,
             int startId) {
         synchronized(this) {
@@ -9928,6 +10092,20 @@
         }
 
         synchronized(this) {
+            if (!mSystemReady) {
+                // if the caller really truly claims to know what they're doing, go
+                // ahead and allow the broadcast without launching any receivers
+                int flags = intent.getFlags();
+                if ((flags&Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT) != 0) {
+                    intent = new Intent(intent);
+                    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
+                } else if ((flags&Intent.FLAG_RECEIVER_REGISTERED_ONLY) == 0){
+                    Log.e(TAG, "Attempt to launch receivers of broadcast intent " + intent
+                            + " before boot completion");
+                    throw new IllegalStateException("Cannot broadcast before boot completed");
+                }
+            }
+            
             final ProcessRecord callerApp = getRecordForAppLocked(caller);
             final int callingPid = Binder.getCallingPid();
             final int callingUid = Binder.getCallingUid();
@@ -10639,6 +10817,22 @@
     // =========================================================
     // CONFIGURATION
     // =========================================================
+    
+    public ConfigurationInfo getDeviceConfigurationInfo() {
+        ConfigurationInfo config = new ConfigurationInfo();
+        synchronized (this) {
+            config.reqTouchScreen = mConfiguration.touchscreen;
+            config.reqKeyboardType = mConfiguration.keyboard;
+            config.reqNavigation = mConfiguration.navigation;
+            if (mConfiguration.navigation != Configuration.NAVIGATION_NONAV) {
+                config.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV;
+            }
+            if (mConfiguration.keyboard != Configuration.KEYBOARD_UNDEFINED) {
+                config.reqInputFeatures |= ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD;
+            }
+        }
+        return config;
+    }
 
     public Configuration getConfiguration() {
         Configuration ci;
@@ -10653,6 +10847,11 @@
                 "updateConfiguration()");
 
         synchronized(this) {
+            if (values == null && mWindowManager != null) {
+                // sentinel: fetch the current configuration from the window manager
+                values = mWindowManager.computeNewConfiguration();
+            }
+            
             final long origId = Binder.clearCallingIdentity();
             updateConfigurationLocked(values, null);
             Binder.restoreCallingIdentity(origId);
diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java
index bf1bc8c6..1cd6298 100644
--- a/services/java/com/android/server/am/BatteryStatsService.java
+++ b/services/java/com/android/server/am/BatteryStatsService.java
@@ -65,6 +65,8 @@
     }
     
     public BatteryStatsImpl getStatistics() {
+        mContext.enforceCallingPermission(
+                android.Manifest.permission.BATTERY_STATS, null);
         return mStats;
     }
     
@@ -82,17 +84,59 @@
         }
     }
 
-    public void noteStartSensor(int uid, int sensor) {
+    public void noteStartSensor(int uid, String name, int sensor) {
         enforceCallingPermission();
         synchronized (mStats) {
-            mStats.getUidStatsLocked(uid).noteStartSensor(sensor);
+            mStats.getUidStatsLocked(uid).noteStartSensor(name, sensor);
         }
     }
     
-    public void noteStopSensor(int uid, int sensor) {
+    public void noteStopSensor(int uid, String name, int sensor) {
         enforceCallingPermission();
         synchronized (mStats) {
-            mStats.getUidStatsLocked(uid).noteStopSensor(sensor);
+            mStats.getUidStatsLocked(uid).noteStopSensor(name, sensor);
+        }
+    }
+    
+    public void noteStartGps(int uid) {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteStartGps(uid);
+        }
+    }
+    
+    public void noteStopGps(int uid) {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteStopGps(uid);
+        }
+    }
+    
+    public void noteRequestGpsOn(int uid) {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteRequestGpsOn(uid);
+        }
+    }
+    
+    public void noteRequestGpsOff(int uid) {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteRequestGpsOff(uid);
+        }
+    }
+    
+    public void noteScreenOn() {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteScreenOn();
+        }
+    }
+    
+    public void noteScreenOff() {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteScreenOff();
         }
     }
 
@@ -106,10 +150,14 @@
     }
     
     public long getAwakeTimeBattery() {
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.BATTERY_STATS, null);
         return mStats.getAwakeTimeBattery();
     }
 
     public long getAwakeTimePlugged() {
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.BATTERY_STATS, null);
         return mStats.getAwakeTimePlugged();
     }
 
@@ -117,7 +165,7 @@
         if (Binder.getCallingPid() == Process.myPid()) {
             return;
         }
-        mContext.enforcePermission(android.Manifest.permission.BATTERY_STATS,
+        mContext.enforcePermission(android.Manifest.permission.UPDATE_DEVICE_STATS,
                 Binder.getCallingPid(), Binder.getCallingUid(), null);
     }
     
diff --git a/services/java/com/android/server/am/HistoryRecord.java b/services/java/com/android/server/am/HistoryRecord.java
index b370b1c..b407208 100644
--- a/services/java/com/android/server/am/HistoryRecord.java
+++ b/services/java/com/android/server/am/HistoryRecord.java
@@ -23,6 +23,7 @@
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
 import android.content.res.Configuration;
 import android.graphics.Bitmap;
 import android.os.Bundle;
@@ -184,6 +185,11 @@
             dataDir = aInfo.applicationInfo.dataDir;
             nonLocalizedLabel = aInfo.nonLocalizedLabel;
             labelRes = aInfo.labelRes;
+            if (nonLocalizedLabel == null && labelRes == 0) {
+                ApplicationInfo app = aInfo.applicationInfo;
+                nonLocalizedLabel = app.nonLocalizedLabel;
+                labelRes = app.labelRes;
+            }
             icon = aInfo.getIconResource();
             theme = aInfo.getThemeResource();
             if ((aInfo.flags&ActivityInfo.FLAG_MULTIPROCESS) != 0
diff --git a/services/java/com/android/server/am/UsageStatsService.java b/services/java/com/android/server/am/UsageStatsService.java
new file mode 100755
index 0000000..001987f
--- /dev/null
+++ b/services/java/com/android/server/am/UsageStatsService.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2006-2007 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.am;
+
+import com.android.internal.app.IUsageStats;
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.Binder;
+import android.os.IBinder;
+import com.android.internal.os.PkgUsageStats;
+import android.os.Process;
+import android.os.ServiceManager;
+import android.os.SystemClock;
+import android.util.Log;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This service collects the statistics associated with usage
+ * of various components, like when a particular package is launched or
+ * paused and aggregates events like number of time a component is launched
+ * total duration of a component launch.
+ */
+public final class UsageStatsService extends IUsageStats.Stub {
+    public static final String SERVICE_NAME = "usagestats";
+    private static final boolean localLOGV = false;
+    private static final String TAG = "UsageStats";
+    static IUsageStats sService;
+    private Context mContext;
+    private String mFileName;
+    final private Map<String, PkgUsageStatsExtended> mStats;
+    private String mResumedPkg;
+    
+    private class PkgUsageStatsExtended {
+        int mLaunchCount;
+        long mUsageTime;
+        long mChgTime;
+        PkgUsageStatsExtended() {
+            mLaunchCount = 0;
+            mUsageTime = 0;
+            mChgTime =  SystemClock.elapsedRealtime();
+        }
+        void updateResume() {
+            mLaunchCount ++;
+            mChgTime = SystemClock.elapsedRealtime();
+        }
+        void updatePause() {
+            long currTime = SystemClock.elapsedRealtime();
+            mUsageTime += (currTime - mChgTime);
+            mChgTime = currTime;
+        }
+    }
+    
+    UsageStatsService(String filename) {
+        mFileName = filename;
+        mStats = new HashMap<String, PkgUsageStatsExtended>();
+    }
+    
+    public void publish(Context context) {
+        mContext = context;
+        ServiceManager.addService(SERVICE_NAME, asBinder());
+    }
+    
+    public static IUsageStats getService() {
+        if (sService != null) {
+            return sService;
+        }
+        IBinder b = ServiceManager.getService(SERVICE_NAME);
+        sService = asInterface(b);
+        return sService;
+    }
+    
+    public void noteResumeComponent(ComponentName componentName) {
+        enforceCallingPermission();
+        String pkgName;
+        if ((componentName == null) ||
+                ((pkgName = componentName.getPackageName()) == null)) {
+            return;
+        }
+        if ((mResumedPkg != null) && (mResumedPkg.equalsIgnoreCase(pkgName))) {
+            // Moving across activities in same package. just return
+            return;
+        } 
+        if (localLOGV) Log.i(TAG, "started component:"+pkgName);
+        PkgUsageStatsExtended pus = mStats.get(pkgName);
+        if (pus == null) {
+            pus = new PkgUsageStatsExtended();
+            mStats.put(pkgName, pus);
+        }
+        pus.updateResume();
+        mResumedPkg = pkgName;
+    }
+
+    public void notePauseComponent(ComponentName componentName) {
+        enforceCallingPermission();
+        String pkgName;
+        if ((componentName == null) ||
+                ((pkgName = componentName.getPackageName()) == null)) {
+            return;
+        }
+        if ((mResumedPkg == null) || (!pkgName.equalsIgnoreCase(mResumedPkg))) {
+            Log.w(TAG, "Something wrong here, Didn't expect "+pkgName+" to be paused");
+            return;
+        }
+        if (localLOGV) Log.i(TAG, "paused component:"+pkgName);
+        PkgUsageStatsExtended pus = mStats.get(pkgName);
+        if (pus == null) {
+            // Weird some error here
+            Log.w(TAG, "No package stats for pkg:"+pkgName);
+            return;
+        }
+        pus.updatePause();
+    }
+    
+    public void enforceCallingPermission() {
+        if (Binder.getCallingPid() == Process.myPid()) {
+            return;
+        }
+        mContext.enforcePermission(android.Manifest.permission.UPDATE_DEVICE_STATS,
+                Binder.getCallingPid(), Binder.getCallingUid(), null);
+    }
+    
+    public PkgUsageStats getPkgUsageStats(ComponentName componentName) {
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.PACKAGE_USAGE_STATS, null);
+        String pkgName;
+        if ((componentName == null) ||
+                ((pkgName = componentName.getPackageName()) == null)) {
+            return null;
+        }
+        PkgUsageStatsExtended pus = mStats.get(pkgName);
+        if (pus == null) {
+            return null;
+        }
+        return new PkgUsageStats(pkgName, pus.mLaunchCount, pus.mUsageTime);
+    }
+    
+    public PkgUsageStats[] getAllPkgUsageStats() {
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.PACKAGE_USAGE_STATS, null);
+        synchronized (mStats) {
+            Set<String> keys = mStats.keySet();
+            int size = keys.size();
+            if (size <= 0) {
+                return null;
+            }
+            PkgUsageStats retArr[] = new PkgUsageStats[size];
+            int i = 0;
+            for (String key: keys) {
+                PkgUsageStatsExtended pus = mStats.get(key);
+                retArr[i] = new PkgUsageStats(key, pus.mLaunchCount, pus.mUsageTime);
+                i++;
+            }
+            return retArr;
+        }
+    }
+    
+    @Override
+    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        StringBuilder sb = new StringBuilder();
+        synchronized (mStats) {
+            Set<String> keys = mStats.keySet();
+            for (String key: keys) {
+                PkgUsageStatsExtended ps = mStats.get(key);
+                sb.append("pkg="); 
+                sb.append(key);
+                sb.append(", launchCount=");
+                sb.append(ps.mLaunchCount);
+                sb.append(", usageTime=");
+                sb.append(ps.mUsageTime+" ms\n");
+            }
+        }
+        pw.write(sb.toString());
+    }
+}
diff --git a/services/java/com/android/server/status/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java
index 00ff7be..3a5b13c 100644
--- a/services/java/com/android/server/status/StatusBarPolicy.java
+++ b/services/java/com/android/server/status/StatusBarPolicy.java
@@ -157,6 +157,7 @@
     private IconData mBluetoothData;
     private int mBluetoothHeadsetState;
     private int mBluetoothA2dpState;
+    private boolean mBluetoothEnabled;
 
     // wifi
     private static final int[] sWifiSignalImages = new int[] {
@@ -286,7 +287,16 @@
         mBluetoothData = IconData.makeIcon("bluetooth",
                 null, com.android.internal.R.drawable.stat_sys_data_bluetooth, 0, 0);
         mBluetoothIcon = service.addIcon(mBluetoothData, null);
-        updateBluetooth(null);
+        BluetoothDevice bluetooth =
+                (BluetoothDevice) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
+        if (bluetooth != null) {
+            mBluetoothEnabled = bluetooth.isEnabled();
+        } else {
+            mBluetoothEnabled = false;
+        }
+        mBluetoothA2dpState = BluetoothA2dp.STATE_DISCONNECTED;
+        mBluetoothHeadsetState = BluetoothHeadset.STATE_DISCONNECTED;
+        mService.setIconVisibility(mBluetoothIcon, mBluetoothEnabled);
 
         // Gps status
         mGpsEnabledIconData = IconData.makeIcon("gps",
@@ -767,30 +777,17 @@
     }
 
     private final void updateBluetooth(Intent intent) {
-        boolean visible = false;
-        if (intent == null) {  // Initialize
-            BluetoothDevice bluetooth =
-                (BluetoothDevice) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
-            if (bluetooth != null) {
-                visible = bluetooth.isEnabled();
-            }
-            mService.setIconVisibility(mBluetoothIcon, visible);
-            return;
-        }
-
         int iconId = com.android.internal.R.drawable.stat_sys_data_bluetooth;
-        String action = intent.getAction();
 
+        String action = intent.getAction();
         if (action.equals(BluetoothIntent.DISABLED_ACTION)) {
-            visible = false;
+            mBluetoothEnabled = false;
         } else if (action.equals(BluetoothIntent.ENABLED_ACTION)) {
-            visible = true;
+            mBluetoothEnabled = true;
         } else if (action.equals(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION)) {
-            visible = true;
             mBluetoothHeadsetState = intent.getIntExtra(BluetoothIntent.HEADSET_STATE,
                     BluetoothHeadset.STATE_ERROR);
         } else if (action.equals(BluetoothA2dp.SINK_STATE_CHANGED_ACTION)) {
-            visible = true;
             mBluetoothA2dpState = intent.getIntExtra(BluetoothA2dp.SINK_STATE,
                     BluetoothA2dp.STATE_DISCONNECTED);
         } else {
@@ -805,7 +802,7 @@
 
         mBluetoothData.iconId = iconId;
         mService.updateIcon(mBluetoothIcon, mBluetoothData, null);
-        mService.setIconVisibility(mBluetoothIcon, visible);
+        mService.setIconVisibility(mBluetoothIcon, mBluetoothEnabled);
     }
 
     private final void updateWifi(Intent intent) {
diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java
index 3b6e354..a4844b1 100644
--- a/services/java/com/android/server/status/StatusBarService.java
+++ b/services/java/com/android/server/status/StatusBarService.java
@@ -322,9 +322,11 @@
     }
 
     public void systemReady() {
+        final StatusBarView view = mStatusBarView;
         WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                 ViewGroup.LayoutParams.FILL_PARENT,
-                25,
+                view.getContext().getResources().getDimensionPixelSize(
+                        com.android.internal.R.dimen.status_bar_height),
                 WindowManager.LayoutParams.TYPE_STATUS_BAR,
                 WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
                 WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING,
@@ -333,7 +335,7 @@
         lp.setTitle("StatusBar");
         lp.windowAnimations = R.style.Animation_StatusBar;
 
-        WindowManagerImpl.getDefault().addView(mStatusBarView, lp);
+        WindowManagerImpl.getDefault().addView(view, lp);
     }
     
     // ================================================================================
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 374a703..c5b1b73 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -252,10 +252,7 @@
      */
     public List<NeighboringCellInfo> getNeighboringCellInfo() {
        try {
-           ITelephony tel = getITelephony(); 
-           if (tel != null) {
-               return tel.getNeighboringCellInfo();
-           }
+           return getITelephony().getNeighboringCellInfo();
        } catch (RemoteException ex) {
        }
        return null;
@@ -683,7 +680,8 @@
     public void listen(PhoneStateListener listener, int events) {
         String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
         try {
-            mRegistry.listen(pkgForDebug, listener.callback, events, true);
+            Boolean notifyNow = (getITelephony() != null);
+            mRegistry.listen(pkgForDebug, listener.callback, events, notifyNow);
         } catch (RemoteException ex) {
             // system process dead
         }
diff --git a/telephony/java/com/android/internal/telephony/gsm/CallTracker.java b/telephony/java/com/android/internal/telephony/gsm/CallTracker.java
index afd11c4..2d716bb 100644
--- a/telephony/java/com/android/internal/telephony/gsm/CallTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/CallTracker.java
@@ -51,10 +51,7 @@
     private static final boolean REPEAT_POLLING = false;
 
     private static final boolean DBG_POLL = false;
-    
-    // Event Log Tags
-    private static final int EVENT_LOG_CALL_DROP = 50106;
-    
+
     //***** Constants
 
     static final int POLL_DELAY_MSEC = 250;
@@ -62,17 +59,17 @@
     static final int MAX_CONNECTIONS_PER_CALL = 5; // only 5 connections allowed per call
 
     //***** Instance Variables
-    
+
     GSMConnection connections[] = new GSMConnection[MAX_CONNECTIONS];
     RegistrantList voiceCallEndedRegistrants = new RegistrantList();
     RegistrantList voiceCallStartedRegistrants = new RegistrantList();
 
 
     // connections dropped durin last poll
-    ArrayList<GSMConnection> droppedDuringPoll 
-        = new ArrayList<GSMConnection>(MAX_CONNECTIONS); 
+    ArrayList<GSMConnection> droppedDuringPoll
+        = new ArrayList<GSMConnection>(MAX_CONNECTIONS);
 
-    GSMCall ringingCall = new GSMCall(this); 
+    GSMCall ringingCall = new GSMCall(this);
             // A call that is ringing or (call) waiting
     GSMCall foregroundCall = new GSMCall(this);
     GSMCall backgroundCall = new GSMCall(this);
@@ -172,13 +169,13 @@
             // for the newly dialed connection
             switchWaitingOrHoldingAndActive();
 
-            // Fake local state so that 
+            // Fake local state so that
             // a) foregroundCall is empty for the newly dialed connection
             // b) hasNonHangupStateChanged remains false in the
             // next poll, so that we don't clear a failed dialing call
             fakeHoldForegroundBeforeDial();
-        } 
-        
+        }
+
         if (foregroundCall.getState() != Call.State.IDLE) {
             //we should have failed in !canDial() above before we get here
             throw new CallStateException("cannot dial in current state");
@@ -194,22 +191,22 @@
             pendingMO.cause = Connection.DisconnectCause.INVALID_NUMBER;
 
             // handlePollCalls() will notice this call not present
-            // and will mark it as dropped. 
+            // and will mark it as dropped.
             pollCallsWhenSafe();
         } else {
             // Always unmute when initiating a new call
             setMute(false);
 
-            cm.dial(pendingMO.address, clirMode, obtainCompleteMessage()); 
+            cm.dial(pendingMO.address, clirMode, obtainCompleteMessage());
         }
 
         updatePhoneState();
         phone.notifyCallStateChanged();
-        
+
         return pendingMO;
     }
 
-    
+
     Connection
     dial (String dialString) throws CallStateException
     {
@@ -222,7 +219,7 @@
         // FIXME if SWITCH fails, should retry with ANSWER
         // in case the active/holding call disappeared and this
         // is no longer call waiting
-        
+
         if (ringingCall.getState() == Call.State.INCOMING) {
             Log.i("phone", "acceptCall: incoming...");
             // Always unmute when answering a new call
@@ -270,7 +267,7 @@
     {
         cm.explicitCallTransfer(obtainCompleteMessage(EVENT_ECT_RESULT));
     }
-    
+
     void
     clearDisconnected()
     {
@@ -280,7 +277,7 @@
         phone.notifyCallStateChanged();
     }
 
-    boolean 
+    boolean
     canConference()
     {
         return foregroundCall.getState() == Call.State.ACTIVE
@@ -312,13 +309,13 @@
     }
 
     //***** Private Instance Methods
-    
+
     private void
     internalClearDisconnected()
     {
         ringingCall.clearDisconnected();
         foregroundCall.clearDisconnected();
-        backgroundCall.clearDisconnected();    
+        backgroundCall.clearDisconnected();
     }
 
     /**
@@ -364,7 +361,7 @@
     /**
      * Obtain a complete message that indicates that this operation
      * does not require polling of getCurrentCalls(). However, if other
-     * operations that do need getCurrentCalls() are pending or are 
+     * operations that do need getCurrentCalls() are pending or are
      * scheduled while this operation is pending, the invocatoin
      * of getCurrentCalls() will be postponed until this
      * operation is also complete.
@@ -382,20 +379,20 @@
     operationComplete()
     {
         pendingOperations--;
-        
+
         if (DBG_POLL) log("operationComplete: pendingOperations=" +
                 pendingOperations + ", needsPoll=" + needsPoll);
 
         if (pendingOperations == 0 && needsPoll) {
             lastRelevantPoll = obtainMessage(EVENT_POLL_CALLS_RESULT);
-            cm.getCurrentCalls(lastRelevantPoll);            
+            cm.getCurrentCalls(lastRelevantPoll);
         } else if (pendingOperations < 0) {
             // this should never happen
             Log.e(LOG_TAG,"CallTracker.pendingOperations < 0");
             pendingOperations = 0;
         }
     }
-    
+
     private void
     pollCallsWhenSafe()
     {
@@ -403,10 +400,10 @@
 
         if (checkNoOperationsPending()) {
             lastRelevantPoll = obtainMessage(EVENT_POLL_CALLS_RESULT);
-            cm.getCurrentCalls(lastRelevantPoll);            
+            cm.getCurrentCalls(lastRelevantPoll);
         }
     }
-    
+
     private void
     pollCallsAfterDelay()
     {
@@ -428,7 +425,7 @@
     updatePhoneState()
     {
         Phone.State oldState = state;
-    
+
         if (ringingCall.isRinging()) {
             state = Phone.State.RINGING;
         } else if (pendingMO != null ||
@@ -436,7 +433,7 @@
             state = Phone.State.OFFHOOK;
         } else {
             state = Phone.State.IDLE;
-        }        
+        }
 
         if (state == Phone.State.IDLE && oldState != state) {
             voiceCallEndedRegistrants.notifyRegistrants(
@@ -475,7 +472,7 @@
         boolean needsPollDelay = false;
         boolean unknownConnectionAppeared = false;
 
-        for (int i = 0, curDC = 0, dcSize = polledCalls.size() 
+        for (int i = 0, curDC = 0, dcSize = polledCalls.size()
                 ; i < connections.length; i++) {
             GSMConnection conn = connections[i];
             DriverCall dc = null;
@@ -532,7 +529,7 @@
                         // which is neither a ringing call or one we created.
                         // Either we've crashed and re-attached to an existing
                         // call, or something else (eg, SIM) initiated the call.
-                
+
                         Log.i(LOG_TAG,"Phantom call appeared " + dc);
 
                         // If it's a connected call, set the connect time so that
@@ -549,8 +546,8 @@
                 hasNonHangupStateChanged = true;
             } else if (conn != null && dc == null) {
                 // Connection missing in CLCC response that we were
-                // tracking. 
-                droppedDuringPoll.add(conn); 
+                // tracking.
+                droppedDuringPoll.add(conn);
                 // Dropped connections are removed from the CallTracker
                 // list but kept in the GSMCall list
                 connections[i] = null;
@@ -558,7 +555,7 @@
                 // Connection in CLCC response does not match what
                 // we were tracking. Assume dropped call and new call
 
-                droppedDuringPoll.add(conn); 
+                droppedDuringPoll.add(conn);
                 connections[i] = new GSMConnection (phone.getContext(), dc, this, i);
 
                 if (connections[i].getCall() == ringingCall) {
@@ -594,11 +591,11 @@
         // This is the first poll after an ATD.
         // We expect the pending call to appear in the list
         // If it does not, we land here
-        if (pendingMO != null) {            
-            Log.d(LOG_TAG,"Pending MO dropped before poll fg state:" 
+        if (pendingMO != null) {
+            Log.d(LOG_TAG,"Pending MO dropped before poll fg state:"
                             + foregroundCall.getState());
 
-            droppedDuringPoll.add(pendingMO); 
+            droppedDuringPoll.add(pendingMO);
             pendingMO = null;
             hangupPendingMO = false;
         }
@@ -619,7 +616,7 @@
                 if (conn.cause == Connection.DisconnectCause.LOCAL) {
                     cause = Connection.DisconnectCause.INCOMING_REJECTED;
                 } else {
-                    cause = Connection.DisconnectCause.INCOMING_MISSED;                    
+                    cause = Connection.DisconnectCause.INCOMING_MISSED;
                 }
 
                 if (Phone.DEBUG_PHONE) {
@@ -690,7 +687,7 @@
     dumpState()
     {
         List l;
-        
+
         Log.i(LOG_TAG,"Phone State:" + state);
 
         Log.i(LOG_TAG,"Ringing call: " + ringingCall.toString());
@@ -722,7 +719,7 @@
     hangup (GSMConnection conn) throws CallStateException
     {
         if (conn.owner != this) {
-            throw new CallStateException ("Connection " + conn 
+            throw new CallStateException ("Connection " + conn
                                     + "does not belong to CallTracker " + this);
         }
 
@@ -731,14 +728,14 @@
             // GSM index assigned yet
 
             if (Phone.DEBUG_PHONE) log("hangup: set hangupPendingMO to true");
-            hangupPendingMO = true;           
+            hangupPendingMO = true;
         } else {
-            try {            
+            try {
                 cm.hangupConnection (conn.getGSMIndex(), obtainCompleteMessage());
             } catch (CallStateException ex) {
                 // Ignore "connection not found"
                 // Call may have hung up already
-                Log.w(LOG_TAG,"CallTracker WARN: hangup() on absent connection " 
+                Log.w(LOG_TAG,"CallTracker WARN: hangup() on absent connection "
                                 + conn);
             }
         }
@@ -750,16 +747,16 @@
     separate (GSMConnection conn) throws CallStateException
     {
         if (conn.owner != this) {
-            throw new CallStateException ("Connection " + conn 
+            throw new CallStateException ("Connection " + conn
                                     + "does not belong to CallTracker " + this);
         }
         try {
-            cm.separateConnection (conn.getGSMIndex(), 
+            cm.separateConnection (conn.getGSMIndex(),
                 obtainCompleteMessage(EVENT_SEPARATE_RESULT));
         } catch (CallStateException ex) {
             // Ignore "connection not found"
             // Call may have hung up already
-            Log.w(LOG_TAG,"CallTracker WARN: separate() on absent connection " 
+            Log.w(LOG_TAG,"CallTracker WARN: separate() on absent connection "
                           + conn);
         }
     }
@@ -772,14 +769,14 @@
         desiredMute = mute;
         cm.setMute(desiredMute, null);
     }
-        
+
     /*package*/ boolean
     getMute()
     {
         return desiredMute;
     }
 
-    
+
     //***** Called from GSMCall
 
     /* package */ void
@@ -886,11 +883,11 @@
 
     //****** Overridden from Handler
 
-    public void 
+    public void
     handleMessage (Message msg)
     {
         AsyncResult ar;
-        
+
         switch (msg.what) {
             case EVENT_POLL_CALLS_RESULT:
                 ar = (AsyncResult)msg.obj;
@@ -924,7 +921,7 @@
                 int causeCode;
                 ar = (AsyncResult)msg.obj;
 
-                operationComplete(); 
+                operationComplete();
 
                 if (ar.exception != null) {
                     // An exception occurred...just treat the disconnect
@@ -936,7 +933,7 @@
                     causeCode = ((int[])ar.result)[0];
                 }
                 // Log the causeCode if its not normal
-                if (causeCode == CallFailCause.NO_CIRCUIT_AVAIL ||                    
+                if (causeCode == CallFailCause.NO_CIRCUIT_AVAIL ||
                     causeCode == CallFailCause.TEMPORARY_FAILURE ||
                     causeCode == CallFailCause.SWITCHING_CONGESTION ||
                     causeCode == CallFailCause.CHANNEL_NOT_AVAIL ||
@@ -946,12 +943,12 @@
                     int cid = -1;
                     GsmCellLocation loc = ((GsmCellLocation)phone.getCellLocation());
                     if (loc != null) cid = loc.getCid();
-                  
-                    EventLog.List val = new EventLog.List(causeCode, cid, 
+
+                    EventLog.List val = new EventLog.List(causeCode, cid,
                         TelephonyManager.getDefault().getNetworkType());
-                    EventLog.writeEvent(EVENT_LOG_CALL_DROP, val);                   
+                    EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_CALL_DROP, val);
                 }
-                
+
                 for (int i = 0, s =  droppedDuringPoll.size()
                         ; i < s ; i++
                 ) {
diff --git a/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
index b0b8cdc..b115713 100644
--- a/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
@@ -16,11 +16,6 @@
 
 package com.android.internal.telephony.gsm;
 
-import static com.android.internal.telephony.TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE;
-import static com.android.internal.telephony.gsm.ServiceStateTracker.DATA_ACCESS_EDGE;
-import static com.android.internal.telephony.gsm.ServiceStateTracker.DATA_ACCESS_GPRS;
-import static com.android.internal.telephony.gsm.ServiceStateTracker.DATA_ACCESS_UMTS;
-import static com.android.internal.telephony.gsm.ServiceStateTracker.DATA_ACCESS_UNKNOWN;
 import android.app.AlarmManager;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
@@ -31,6 +26,8 @@
 import android.content.SharedPreferences;
 import android.database.ContentObserver;
 import android.database.Cursor;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.INetStatService;
@@ -50,13 +47,10 @@
 import android.text.TextUtils;
 import android.util.EventLog;
 import android.util.Log;
-import android.util.EventLog.List;
 
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.gsm.PdpConnection.PdpFailCause;
-import android.net.wifi.WifiManager;
-import android.net.NetworkInfo;
-                                                                    
+
 import java.io.IOException;
 import java.util.ArrayList;
 
@@ -128,7 +122,8 @@
     Handler mDataConnectionTracker = null;
     private ContentResolver mResolver;
 
-    int txPkts, rxPkts, sentSinceLastRecv, netStatPollPeriod;
+    long txPkts, rxPkts, sentSinceLastRecv;
+    int netStatPollPeriod;
     private int mNoRecvPollCount = 0;
     private boolean mPingTestActive = false;
     // Count of PDP reset attempts; reset when we see incoming,
@@ -161,7 +156,7 @@
 
     /** CID of active PDP */
     int cidActive;
-    
+
     /** Currently requested APN type */
     private String mRequestedApnType = Phone.APN_TYPE_DEFAULT;
 
@@ -232,13 +227,6 @@
     private static final String INTENT_RECONNECT_ALARM_EXTRA_REASON = "reason";
 
 
-    //***** Tag IDs for EventLog
-    private static final int EVENT_LOG_RADIO_RESET_COUNTDOWN_TRIGGERED = 50101;
-    private static final int EVENT_LOG_RADIO_RESET = 50102;
-    private static final int EVENT_LOG_PDP_RESET = 50103;
-    private static final int EVENT_LOG_REREGISTER_NETWORK = 50104;
-    private static final int EVENT_LOG_RADIO_PDP_SETUP_FAIL = 50105;
-
     //***** Event Codes
     static final int EVENT_DATA_SETUP_COMPLETE = 1;
     static final int EVENT_RADIO_AVAILABLE = 3;
@@ -500,7 +488,7 @@
         }
         return true;
     }
-    
+
     private boolean isApnTypeActive(String type) {
         // TODO: to support simultaneous, mActiveApn can be a List instead.
         return mActiveApn != null && mActiveApn.canHandleType(type);
@@ -537,7 +525,7 @@
         Log.d(LOG_TAG, "dataEnabled[DEFAULT_APN]=" + dataEnabled[APN_DEFAULT_ID] +
                 " dataEnabled[MMS_APN]=" + dataEnabled[APN_MMS_ID]);
     }
-    
+
     /**
      * Prevent mobile data connections from being established,
      * or once again allow mobile data connections. If the state
@@ -605,7 +593,7 @@
     //Retrieve the data roaming setting from the shared preferences.
     public boolean getDataOnRoamingEnabled() {
         try {
-            return Settings.Secure.getInt(phone.getContext().getContentResolver(), 
+            return Settings.Secure.getInt(phone.getContext().getContentResolver(),
                 Settings.Secure.DATA_ROAMING) > 0;
         } catch (SettingNotFoundException snfe) {
             return false;
@@ -636,7 +624,7 @@
         stopNetStatPoll();
         phone.notifyDataConnection(Phone.REASON_GPRS_DETACHED);
     }
-    
+
     private void onGprsAttached() {
         if (state == State.CONNECTED) {
             startNetStatPoll();
@@ -746,7 +734,7 @@
          * IDLE before the code below runs. If we didn't check
          * for that, future calls to trySetupData would fail,
          * and we would never get out of the DISCONNECTING state.
-         */ 
+         */
         if (!tearDown) {
             setState(State.IDLE);
             phone.notifyDataConnection(reason);
@@ -932,6 +920,16 @@
 
             Log.i(LOG_TAG, "PDP connection has dropped. Reconnecting");
 
+            // Add an event log when the network drops PDP
+            int cid = -1;
+            GsmCellLocation loc = ((GsmCellLocation)phone.getCellLocation());
+            if (loc != null) cid = loc.getCid();
+
+            EventLog.List val = new EventLog.List(cid,
+                    TelephonyManager.getDefault().getNetworkType());
+
+            EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_PDP_NETWORK_DROP, val);
+
             cleanUpConnection(true, null);
 
             return;
@@ -964,6 +962,16 @@
                     Log.i(LOG_TAG, "PDP connection has dropped (active=false case). "
                                     + " Reconnecting");
 
+                    // Log the network drop on the event log.
+                    int cid = -1;
+                    GsmCellLocation loc = ((GsmCellLocation)phone.getCellLocation());
+                    if (loc != null) cid = loc.getCid();
+
+                    EventLog.List val = new EventLog.List(cid,
+                            TelephonyManager.getDefault().getNetworkType());
+
+                    EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_PDP_NETWORK_DROP, val);
+
                     cleanUpConnection(true, null);
                 }
             }
@@ -1040,14 +1048,14 @@
         if (state == State.CONNECTED) {
             int maxPdpReset = Settings.Gservices.getInt(mResolver,
                     Settings.Gservices.PDP_WATCHDOG_MAX_PDP_RESET_FAIL_COUNT,
-                    DEFAULT_MAX_PDP_RESET_FAIL); 
+                    DEFAULT_MAX_PDP_RESET_FAIL);
             if (mPdpResetCount < maxPdpReset) {
                 mPdpResetCount++;
-                EventLog.writeEvent(EVENT_LOG_PDP_RESET, sentSinceLastRecv);
+                EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_PDP_RESET, sentSinceLastRecv);
                 cleanUpConnection(true, Phone.REASON_PDP_RESET);
             } else {
                 mPdpResetCount = 0;
-                EventLog.writeEvent(EVENT_LOG_REREGISTER_NETWORK, sentSinceLastRecv);
+                EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_REREGISTER_NETWORK, sentSinceLastRecv);
                 phone.mSST.reRegisterNetwork(null);
             }
             // TODO: Add increasingly drastic recovery steps, eg,
@@ -1096,8 +1104,8 @@
     {
 
         public void run() {
-            int sent, received;
-            int preTxPkts = -1, preRxPkts = -1;
+            long sent, received;
+            long preTxPkts = -1, preRxPkts = -1;
 
             Activity newActivity;
 
@@ -1105,8 +1113,8 @@
             preRxPkts = rxPkts;
 
             try {
-                txPkts = netstat.getTxPackets();
-                rxPkts = netstat.getRxPackets();
+                txPkts = netstat.getMobileTxPackets();
+                rxPkts = netstat.getMobileRxPackets();
             } catch (RemoteException e) {
                 txPkts = 0;
                 rxPkts = 0;
@@ -1152,7 +1160,7 @@
             if (sentSinceLastRecv >= watchdogTrigger) {
                 // we already have NUMBER_SENT_PACKETS sent without ack
                 if (mNoRecvPollCount == 0) {
-                    EventLog.writeEvent(EVENT_LOG_RADIO_RESET_COUNTDOWN_TRIGGERED,
+                    EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_RADIO_RESET_COUNTDOWN_TRIGGERED,
                             sentSinceLastRecv);
                 }
 
@@ -1220,11 +1228,11 @@
         } catch (Exception e) {
             Log.w(LOG_TAG, "exception trying to ping");
         }
-        
+
         if (status == 0) {
             // ping succeeded.  False alarm.  Reset netStatPoll.
             // ("-1" for this event indicates a false alarm)
-            EventLog.writeEvent(EVENT_LOG_PDP_RESET, -1);
+            EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_PDP_RESET, -1);
             mPdpResetCount = 0;
             sendMessage(obtainMessage(EVENT_START_NETSTAT_POLL));
         } else {
@@ -1335,7 +1343,7 @@
             case EVENT_GPRS_ATTACHED:
                 onGprsAttached();
                 break;
-                
+
             case EVENT_ROAMING_ON:
                 if (getDataOnRoamingEnabled()) {
                     trySetupData(Phone.REASON_ROAMING_ON);
@@ -1410,7 +1418,7 @@
                         SystemProperties.set("gsm.defaultpdpcontext.active", "false");
                     }
                     notifyDefaultData(reason);
-                    
+
                     // TODO: For simultaneous PDP support, we need to build another
                     // trigger another TRY_SETUP_DATA for the next APN type.  (Note
                     // that the existing connection may service that type, in which
@@ -1421,7 +1429,7 @@
                     if(DBG)
                         log("PDP setup failed " + cause);
                     // Log this failure to the Event Logs.
-                    if (cause == PdpConnection.PdpFailCause.BAD_APN || 
+                    if (cause == PdpConnection.PdpFailCause.BAD_APN ||
                         cause == PdpConnection.PdpFailCause.BAD_PAP_SECRET ||
                         cause == PdpConnection.PdpFailCause.BARRED ||
                         cause == PdpConnection.PdpFailCause.RADIO_ERROR_RETRY ||
@@ -1431,12 +1439,12 @@
                         int cid = -1;
                         GsmCellLocation loc = ((GsmCellLocation)phone.getCellLocation());
                         if (loc != null) cid = loc.getCid();
-    
+
                         EventLog.List val = new EventLog.List(
-                            cause.ordinal(), cid, 
-                            TelephonyManager.getDefault().getNetworkType());                    
-                        EventLog.writeEvent(EVENT_LOG_RADIO_PDP_SETUP_FAIL, val);
-                    }                                                    
+                            cause.ordinal(), cid,
+                            TelephonyManager.getDefault().getNetworkType());
+                        EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_RADIO_PDP_SETUP_FAIL, val);
+                    }
                     // No try for permanent failure
                     if (cause.isPermanentFail()) {
                         notifyNoData(cause);
@@ -1575,7 +1583,7 @@
             if (cursor != null) {
                 if (cursor.getCount() > 0) {
                     allApns = createApnList(cursor);
-                    // TODO: Figure out where this fits in.  This basically just 
+                    // TODO: Figure out where this fits in.  This basically just
                     // writes the pap-secrets file.  No longer tied to PdpConnection
                     // object.  Not used on current platform (no ppp).
                     //PdpConnection pdp = pdpList.get(pdp_name);
@@ -1622,7 +1630,7 @@
     }
 
     /**
-     * Get next apn in waitingApns 
+     * Get next apn in waitingApns
      * @return the first apn found in waitingApns, null if none
      */
     private ApnSetting getNextApn() {
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMConnection.java b/telephony/java/com/android/internal/telephony/gsm/GSMConnection.java
index 43930c1..a503766 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GSMConnection.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMConnection.java
@@ -77,15 +77,15 @@
     private PowerManager.WakeLock mPartialWakeLock;
 
     //***** Event Constants
-
     static final int EVENT_DTMF_DONE = 1;
     static final int EVENT_PAUSE_DONE = 2;
     static final int EVENT_NEXT_POST_DIAL = 3;
-
+    static final int EVENT_WAKE_LOCK_TIMEOUT = 4;
+    
     //***** Constants
-
     static final int PAUSE_DELAY_FIRST_MILLIS = 100;
     static final int PAUSE_DELAY_MILLIS = 3 * 1000;
+    static final int WAKE_LOCK_TIMEOUT_MILLIS = 60*1000;
 
     //***** Inner Classes
 
@@ -100,8 +100,10 @@
                 case EVENT_DTMF_DONE:
                 case EVENT_PAUSE_DONE:
                     processNextPostDialChar();
-                break;
-
+                    break;
+                case EVENT_WAKE_LOCK_TIMEOUT:
+                    releaseWakeLock();
+                    break;
             }
         }
     }
@@ -279,7 +281,7 @@
             return;
         }
 
-        postDialState = PostDialState.STARTED;
+        setPostDialState(PostDialState.STARTED);
 
         processNextPostDialChar();
     }
@@ -291,7 +293,7 @@
             return;
         }
 
-        postDialState = PostDialState.STARTED;
+        setPostDialState(PostDialState.STARTED);
 
         if (false) {
             boolean playedTone = false;
@@ -333,7 +335,7 @@
     
     public void cancelPostDial()
     {
-        postDialState = PostDialState.CANCELLED;
+        setPostDialState(PostDialState.CANCELLED);
     }
 
     /** 
@@ -562,9 +564,9 @@
                                             PAUSE_DELAY_MILLIS);
             }
         } else if (c == PhoneNumberUtils.WAIT) {
-            postDialState = PostDialState.WAIT;
+            setPostDialState(PostDialState.WAIT);
         } else if (c == PhoneNumberUtils.WILD) {
-            postDialState = PostDialState.WILD;
+            setPostDialState(PostDialState.WILD);
         } else {
             return false;
         }
@@ -614,14 +616,14 @@
 
         if (postDialString == null ||
                 postDialString.length() <= nextPostDialChar) {
-            postDialState = PostDialState.COMPLETE;
+            setPostDialState(PostDialState.COMPLETE);
 
             // notifyMessage.arg1 is 0 on complete
             c = 0;
         } else {
             boolean isValid;
             
-            postDialState = PostDialState.STARTED;
+            setPostDialState(PostDialState.STARTED);
 
             c = postDialString.charAt(nextPostDialChar++);
 
@@ -699,6 +701,26 @@
         }
     }
 
+    /**
+     * Set post dial state and acquire wake lock while switching to "started" 
+     * state, the wake lock will be released if state switches out of "started" 
+     * state or after WAKE_LOCK_TIMEOUT_MILLIS. 
+     * @param s new PostDialState
+     */
+    private void setPostDialState(PostDialState s) {
+        if (postDialState != PostDialState.STARTED 
+                && s == PostDialState.STARTED) {
+            acquireWakeLock();
+            Message msg = h.obtainMessage(EVENT_WAKE_LOCK_TIMEOUT);
+            h.sendMessageDelayed(msg, WAKE_LOCK_TIMEOUT_MILLIS);
+        } else if (postDialState == PostDialState.STARTED 
+                && s != PostDialState.STARTED) {
+            h.removeMessages(EVENT_WAKE_LOCK_TIMEOUT);
+            releaseWakeLock();
+        }
+        postDialState = s;
+    }
+    
     private void
     createWakeLock(Context context) {
         PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index f314944..bd6d41e 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -108,6 +108,8 @@
     SimPhoneBookInterfaceManager mSimPhoneBookIntManager;
     SimSmsInterfaceManager mSimSmsIntManager;
     PhoneSubInfo mSubInfo;
+    boolean mDnsCheckDisabled = false;
+
 
     Registrant mPostDialHandler;
 
@@ -1151,6 +1153,22 @@
         return mDataConnection.getAllPdps();
     }
 
+    /**
+     * Disables the DNS check (i.e., allows "0.0.0.0").
+     * Useful for lab testing environment.
+     * @param b true disables the check, false enables.
+     */
+    public void disableDnsCheck(boolean b) {
+        mDnsCheckDisabled = b;
+    }
+
+    /**
+     * Returns true if the DNS check is currently disabled.
+     */
+    public boolean isDnsCheckDisabled() {
+        return mDnsCheckDisabled;
+    }
+
     public void updateServiceLocation(Message response) {
         mSST.getLacAndCid(response);
     }
diff --git a/telephony/java/com/android/internal/telephony/gsm/MccTable.java b/telephony/java/com/android/internal/telephony/gsm/MccTable.java
index 8f6b22e..57a54c4 100644
--- a/telephony/java/com/android/internal/telephony/gsm/MccTable.java
+++ b/telephony/java/com/android/internal/telephony/gsm/MccTable.java
@@ -283,8 +283,8 @@
 		table.add(new MccEntry(436,"tj",2));	//Tajikistan (Republic of)
 		table.add(new MccEntry(437,"kg",2));	//Kyrgyz Republic
 		table.add(new MccEntry(438,"tm",2));	//Turkmenistan
-		table.add(new MccEntry(440,"jp",2));	//Japan
-		table.add(new MccEntry(441,"jp",2));	//Japan
+		table.add(new MccEntry(440,"jp",2,"Asia/Tokyo","ja"));	//Japan
+		table.add(new MccEntry(441,"jp",2,"Asia/Tokyo","ja"));	//Japan
 		table.add(new MccEntry(450,"kr",2));	//Korea (Republic of)
 		table.add(new MccEntry(452,"vn",2));	//Viet Nam (Socialist Republic of)
 		table.add(new MccEntry(454,"hk",2));	//"Hong Kong, China"
diff --git a/telephony/java/com/android/internal/telephony/gsm/PdpConnection.java b/telephony/java/com/android/internal/telephony/gsm/PdpConnection.java
index 6428f70..66f8b72 100644
--- a/telephony/java/com/android/internal/telephony/gsm/PdpConnection.java
+++ b/telephony/java/com/android/internal/telephony/gsm/PdpConnection.java
@@ -114,9 +114,6 @@
     private static final int EVENT_DEACTIVATE_DONE = 4;
     private static final int EVENT_FORCE_RETRY = 5;
 
-    //***** Tag IDs for EventLog
-    private static final int EVENT_LOG_BAD_DNS_ADDRESS = 50100;
-
     //***** Instance Variables
     private GSMPhone phone;
     private String pdp_name;
@@ -301,7 +298,7 @@
 
     private void notifyDisconnect(Message msg) {
         if (DBG) log("Notify PDP disconnect");
-        
+
         if (msg != null) {
             AsyncResult.forMessage(msg);
             msg.sendToTarget();
@@ -378,7 +375,7 @@
 
                 if (ar.exception != null) {
                     Log.e(LOG_TAG, "PDP Context Init failed " + ar.exception);
-                    
+
                     if (receivedDisconnectReq) {
                         // Don't bother reporting the error if there's already a
                         // pending disconnect request, since DataConnectionTracker
@@ -406,7 +403,7 @@
                     } else {
                         String[] response = ((String[]) ar.result);
                         cid = Integer.parseInt(response[0]);
-                        
+
                         if (response.length > 2) {
                             interfaceName = response[1];
                             ipAddress = response[2];
@@ -420,7 +417,8 @@
                                     + " DNS2=" + dnsServers[1]);
                             }
 
-                            if (NULL_IP.equals(dnsServers[0]) && NULL_IP.equals(dnsServers[1])) {
+                            if (NULL_IP.equals(dnsServers[0]) && NULL_IP.equals(dnsServers[1])
+                                    && !phone.isDnsCheckDisabled()) {
                                 // Work around a race condition where QMI does not fill in DNS:
                                 // Deactivate PDP and let DataConnectionTracker retry.
                                 // Do not apply the race condition workaround for MMS APN
@@ -428,20 +426,21 @@
                                 // Otherwise, the default APN will not be restored anymore.
                                 if (!apn.types[0].equals(Phone.APN_TYPE_MMS)
                                         || !isIpAddress(apn.mmsProxy)) {
-                                    EventLog.writeEvent(EVENT_LOG_BAD_DNS_ADDRESS, dnsServers[0]);
+                                    EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_BAD_DNS_ADDRESS,
+                                            dnsServers[0]);
                                     phone.mCM.deactivateDefaultPDP(cid,
                                             obtainMessage(EVENT_FORCE_RETRY));
                                     break;
                                 }
                             }
                         }
-                        
+
                         if (dataLink != null) {
                             dataLink.connect();
                         } else {
                             onLinkStateChanged(DataLink.LinkState.LINK_UP);
                         }
-                        
+
                         if (DBG) log("PDP setup on cid = " + cid);
                     }
                 }
@@ -463,7 +462,7 @@
                 } else {
                     ar = (AsyncResult) msg.obj;
                     PdpFailCause cause = PdpFailCause.UNKNOWN;
-                    
+
                     if (ar.exception == null) {
                         int rilFailCause = ((int[]) (ar.result))[0];
                         cause = getFailCauseFromRequest(rilFailCause);
diff --git a/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java b/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java
index daf4b9c..0ab4a0e 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SMSDispatcher.java
@@ -135,7 +135,9 @@
     /** Maximum number of times to retry sending a failed SMS. */
     private static final int MAX_SEND_RETRIES = 3;
     /** Delay before next send attempt on a failed SMS, in milliseconds. */
-    private static final int SEND_RETRY_DELAY = 2000; // ms
+    private static final int SEND_RETRY_DELAY = 2000; 
+    /** single part SMS */
+    private static final int SINGLE_PART_SMS = 1;
 
     /**
      * Message reference for a CONCATENATED_8_BIT_REFERENCE or
@@ -169,15 +171,23 @@
             mSmsStamp = new HashMap<String, ArrayList<Long>> ();
         }
 
-        boolean check(String appName) {
+        /**
+         * Check to see if an application allow to send new SMS messages
+         *  
+         * @param appName is the application sending sms
+         * @param smsWaiting is the number of new sms wants to be sent
+         * @return true if application is allowed to send the requested number 
+         *         of new sms messages 
+         */
+        boolean check(String appName, int smsWaiting) {
             if (!mSmsStamp.containsKey(appName)) {
                 mSmsStamp.put(appName, new ArrayList<Long>());
             }
 
-            return isUnderLimit(mSmsStamp.get(appName));
+            return isUnderLimit(mSmsStamp.get(appName), smsWaiting);
         }
 
-        private boolean isUnderLimit(ArrayList<Long> sent) {
+        private boolean isUnderLimit(ArrayList<Long> sent, int smsWaiting) {
             Long ct =  System.currentTimeMillis();
 
             Log.d(TAG, "SMS send size=" + sent.size() + "time=" + ct);
@@ -185,9 +195,11 @@
             while (sent.size() > 0 && (ct - sent.get(0)) > mCheckPeriod ) {
                     sent.remove(0);
             }
-
-            if (sent.size() < mMaxAllowed) {
-                sent.add(ct);
+            
+            if ( (sent.size() + smsWaiting) <= mMaxAllowed) {
+                for (int i = 0; i < smsWaiting; i++ ) {
+                    sent.add(ct);
+                }
                 return true;
             }
             return false;
@@ -290,8 +302,11 @@
 
         case EVENT_SEND_CONFIRMED_SMS:
             if (mSTracker!=null) {
-                Log.d(TAG, "Ready to send SMS again.");
-                sendSms(mSTracker);
+                if (isMultipartTracker(mSTracker)) {
+                    sendMultipartSms(mSTracker);
+                } else {
+                    sendSms(mSTracker);
+                } 
                 mSTracker = null;
             }
             break;
@@ -786,6 +801,81 @@
     void sendMultipartText(String destinationAddress, String scAddress, ArrayList<String> parts,
             ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
 
+        PendingIntent sentIntent = null;
+        
+        
+        int ss = mPhone.getServiceState().getState();
+        
+        if (ss == ServiceState.STATE_IN_SERVICE) {
+            // Only check SMS sending limit while in service
+            if (sentIntents != null && sentIntents.size() > 0) {
+                sentIntent = sentIntents.get(0);
+            }
+            String appName = getAppNameByIntent(sentIntent);
+            if ( !mCounter.check(appName, parts.size())) {
+                HashMap<String, Object> map = new HashMap<String, Object>();
+                map.put("destination", destinationAddress);
+                map.put("scaddress", scAddress);
+                map.put("parts", parts);
+                map.put("sentIntents", sentIntents);
+                map.put("deliveryIntents", deliveryIntents);
+                
+                SmsTracker multipartParameter = new SmsTracker(map, null, null);
+
+                sendMessage(obtainMessage(EVENT_POST_ALERT, multipartParameter));
+                return;
+            }
+        }
+        
+        sendMultipartTextWithPermit(destinationAddress, 
+                scAddress, parts, sentIntents, deliveryIntents);
+    }
+
+    /**
+     * Send a multi-part text based SMS which already passed SMS control check.
+     *
+     * It is the working function for sendMultipartText().
+     * 
+     * @param destinationAddress the address to send the message to
+     * @param scAddress is the service center address or null to use
+     *   the current default SMSC
+     * @param parts an <code>ArrayList</code> of strings that, in order,
+     *   comprise the original message
+     * @param sentIntents if not null, an <code>ArrayList</code> of
+     *   <code>PendingIntent</code>s (one for each message part) that is
+     *   broadcast when the corresponding message part has been sent.
+     *   The result code will be <code>Activity.RESULT_OK<code> for success,
+     *   or one of these errors:
+     *   <code>RESULT_ERROR_GENERIC_FAILURE</code>
+     *   <code>RESULT_ERROR_RADIO_OFF</code>
+     *   <code>RESULT_ERROR_NULL_PDU</code>.
+     * @param deliveryIntents if not null, an <code>ArrayList</code> of
+     *   <code>PendingIntent</code>s (one for each message part) that is
+     *   broadcast when the corresponding message part has been delivered
+     *   to the recipient.  The raw pdu of the status report is in the
+     *   extended data ("pdu").
+     */
+    private void sendMultipartTextWithPermit(String destinationAddress, 
+            String scAddress, ArrayList<String> parts,
+            ArrayList<PendingIntent> sentIntents, 
+            ArrayList<PendingIntent> deliveryIntents) {
+        
+        PendingIntent sentIntent = null;
+        PendingIntent deliveryIntent = null;
+        
+        // check if in service
+        int ss = mPhone.getServiceState().getState();
+        if (ss != ServiceState.STATE_IN_SERVICE) {
+            for (int i = 0, count = parts.size(); i < count; i++) {
+                if (sentIntents != null && sentIntents.size() > i) {
+                    sentIntent = sentIntents.get(i);
+                }
+                SmsTracker tracker = new SmsTracker(null, sentIntent, null);
+                handleNotInService(ss, tracker);
+            }
+            return;
+        }
+
         int ref = ++sConcatenatedRef & 0xff;
 
         for (int i = 0, count = parts.size(); i < count; i++) {
@@ -796,9 +886,7 @@
             data[2] = (byte) (i + 1);  // 1-based sequence
             SmsHeader header = new SmsHeader();
             header.add(new SmsHeader.Element(SmsHeader.CONCATENATED_8_BIT_REFERENCE, data));
-            PendingIntent sentIntent = null;
-            PendingIntent deliveryIntent = null;
-
+ 
             if (sentIntents != null && sentIntents.size() > i) {
                 sentIntent = sentIntents.get(i);
             }
@@ -809,10 +897,16 @@
             SmsMessage.SubmitPdu pdus = SmsMessage.getSubmitPdu(scAddress, destinationAddress,
                     parts.get(i), deliveryIntent != null, header.toByteArray());
 
-            sendRawPdu(pdus.encodedScAddress, pdus.encodedMessage, sentIntent, deliveryIntent);
-        }
-    }
+            HashMap<String, Object> map = new HashMap<String, Object>();
+            map.put("smsc", pdus.encodedScAddress);
+            map.put("pdu", pdus.encodedMessage);
 
+            SmsTracker tracker = new SmsTracker(map, sentIntent,
+                    deliveryIntent);
+            sendSms(tracker);
+        }        
+    }
+    
     /**
      * Send a SMS
      *
@@ -856,7 +950,7 @@
             handleNotInService(ss, tracker);
         } else {
             String appName = getAppNameByIntent(sentIntent);
-            if (mCounter.check(appName)) {
+            if (mCounter.check(appName, SINGLE_PART_SMS)) {
                 sendSms(tracker);
             } else {
                 sendMessage(obtainMessage(EVENT_POST_ALERT, tracker));
@@ -913,6 +1007,41 @@
     }
 
     /**
+     * Send the multi-part SMS based on multipart Sms tracker
+     * 
+     * @param tracker holds the multipart Sms tracker ready to be sent
+     */
+    private void sendMultipartSms (SmsTracker tracker) {
+        ArrayList<String> parts;
+        ArrayList<PendingIntent> sentIntents;
+        ArrayList<PendingIntent> deliveryIntents;
+        
+        HashMap map = tracker.mData;
+        
+        String destinationAddress = (String) map.get("destination");
+        String scAddress = (String) map.get("scaddress");
+        
+        parts = (ArrayList<String>) map.get("parts");
+        sentIntents = (ArrayList<PendingIntent>) map.get("sentIntents");
+        deliveryIntents = (ArrayList<PendingIntent>) map.get("deliveryIntents");
+     
+        sendMultipartTextWithPermit(destinationAddress, 
+                scAddress, parts, sentIntents, deliveryIntents);
+
+    }
+    
+    /**
+     * Check if a SmsTracker holds multi-part Sms
+     * 
+     * @param tracker a SmsTracker could hold a multi-part Sms
+     * @return true for tracker holds Multi-parts Sms
+     */
+    private boolean isMultipartTracker (SmsTracker tracker) {
+        HashMap map = tracker.mData;
+        return ( map.get("parts") != null);
+    }
+    
+    /**
      * Keeps track of an SMS that has been sent to the RIL, until it it has
      * successfully been sent, or we're done trying.
      *
@@ -939,7 +1068,7 @@
             new DialogInterface.OnClickListener() {
 
                 public void onClick(DialogInterface dialog, int which) {
-                    if (which == DialogInterface.BUTTON1) {
+                    if (which == DialogInterface.BUTTON_POSITIVE) {
                         Log.d(TAG, "click YES to send out sms");
                         sendMessage(obtainMessage(EVENT_SEND_CONFIRMED_SMS));
                     }
diff --git a/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
index d3a19c5..10baa1b 100644
--- a/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/ServiceStateTracker.java
@@ -122,7 +122,7 @@
     private boolean mZoneDst;
     private long mZoneTime;
     private boolean mGotCountryCode = false;
-    
+
     String mSavedTimeZone;
     long mSavedTime;
     long mSavedAtTime;
@@ -154,7 +154,6 @@
     static final int DEFAULT_GPRS_CHECK_PERIOD_MILLIS = 60 * 1000;
 
     //***** Events
-    
     static final int EVENT_RADIO_STATE_CHANGED       = 1;
     static final int EVENT_NETWORK_STATE_CHANGED        = 2;
     static final int EVENT_GET_SIGNAL_STRENGTH  = 3;
@@ -175,10 +174,6 @@
     static final int EVENT_RESET_PREFERRED_NETWORK_TYPE = 21;
     static final int EVENT_CHECK_REPORT_GPRS = 22;
 
-    // Event Log Tags
-    private static final int EVENT_LOG_CGREG_FAIL = 50107;
-    private static final int EVENT_DATA_STATE_RADIO_OFF = 50108;
-
   //***** Time Zones
 
     private static final String TIMEZONE_PROPERTY = "persist.sys.timezone";
@@ -209,7 +204,7 @@
         "tg", // Togo
         "uk", // U.K
     };
-        
+
     private ContentObserver mAutoTimeObserver = new ContentObserver(new Handler()) {
         @Override
         public void onChange(boolean selfChange) {
@@ -230,7 +225,7 @@
         cellLoc = new GsmCellLocation();
         newCellLoc = new GsmCellLocation();
 
-        cm.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);        
+        cm.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
         cm.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
 
         cm.registerForNetworkStateChanged(this, EVENT_NETWORK_STATE_CHANGED, null);
@@ -238,16 +233,16 @@
         cm.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
 
         cm.registerForSIMReady(this, EVENT_SIM_READY, null);
-        
+
         // system setting property AIRPLANE_MODE_ON is set in Settings.
         int airplaneMode = Settings.System.getInt(
                 phone.getContext().getContentResolver(),
                 Settings.System.AIRPLANE_MODE_ON, 0);
-        mDesiredPowerState = ! (airplaneMode > 0);        
+        mDesiredPowerState = ! (airplaneMode > 0);
 
         ContentResolver cr = phone.getContext().getContentResolver();
         cr.registerContentObserver(
-                Settings.System.getUriFor(Settings.System.AUTO_TIME), true, 
+                Settings.System.getUriFor(Settings.System.AUTO_TIME), true,
                 mAutoTimeObserver);
         setRssiDefaultValues();
         mNeedToRegForSimLoaded = true;
@@ -272,7 +267,7 @@
     void registerForNetworkAttach(Handler h, int what, Object obj) {
         Registrant r = new Registrant(h, what, obj);
         networkAttachedRegistrants.add(r);
-        
+
         if (ss.getState() == ServiceState.STATE_IN_SERVICE) {
             r.notifyRegistrant();
         }
@@ -360,7 +355,7 @@
     /*package*/ void enableLocationUpdates() {
         cm.setLocationUpdates(true, obtainMessage(EVENT_LOCATION_UPDATES_ENABLED));
     }
-    
+
     /*package*/ void disableLocationUpdates() {
         cm.setLocationUpdates(false, null);
     }
@@ -407,7 +402,7 @@
                 pollState();
                 break;
 
-            case EVENT_GET_SIGNAL_STRENGTH: 
+            case EVENT_GET_SIGNAL_STRENGTH:
                 // This callback is called when signal strength is polled
                 // all by itself
 
@@ -418,7 +413,7 @@
                 ar = (AsyncResult) msg.obj;
                 onSignalStrengthResult(ar);
                 queueNextSignalStrengthPoll();
-                
+
                 break;
 
             case EVENT_GET_LOC_DONE:
@@ -503,7 +498,7 @@
                     getLacAndCid(null);
                 }
                 break;
-            
+
             case EVENT_SET_PREFERRED_NETWORK_TYPE:
                 ar = (AsyncResult) msg.obj;
                 // Don't care the result, only use for dereg network (COPS=2)
@@ -548,7 +543,7 @@
                     if (loc != null) cid = loc.getCid();
 
                     EventLog.List val = new EventLog.List(ss.getOperatorNumeric(), cid);
-                    EventLog.writeEvent(EVENT_LOG_CGREG_FAIL, val);
+                    EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_CGREG_FAIL, val);
                     mReportedGprsNoReg = true;
                 }
                 mStartedGprsRegCheck = false;
@@ -598,7 +593,7 @@
                 EventLog.List val = new EventLog.List(
                         dcTracker.getStateInString(),
                         (dcTracker.getAnyDataEnabled() ? 1 : 0) );
-                EventLog.writeEvent(EVENT_DATA_STATE_RADIO_OFF, val);
+                EventLog.writeEvent(TelephonyEventLog.EVENT_DATA_STATE_RADIO_OFF, val);
             }
             // If it's on and available and we want it off..
             cm.setRadioPower(false, null);
@@ -689,7 +684,7 @@
                     if (states.length > 0) {
                         try {
                             regState = Integer.parseInt(states[0]);
-                            
+
                             // states[3] (if present) is the current radio technology
                             if (states.length >= 4 && states[3] != null) {
                                 type = Integer.parseInt(states[3]);
@@ -1038,7 +1033,7 @@
                 break;
             }
         }
-        
+
         return guess;
     }
 
@@ -1147,7 +1142,7 @@
 
         String simNumeric = SystemProperties.get(PROPERTY_SIM_OPERATOR_NUMERIC, "");
         String  operatorNumeric = s.getOperatorNumeric();
-        
+
         boolean equalsMcc = true;
         try {
             equalsMcc = simNumeric.substring(0, 3).
@@ -1329,7 +1324,7 @@
                 }
                 saveNitzTimeZone(zone.getID());
             }
-            
+
             String ignore = SystemProperties.get("gsm.ignore-nitz");
             if (ignore != null && ignore.equals("yes")) {
                 Log.i(LOG_TAG, "NITZ: Not setting clock because gsm.ignore-nitz is set");
@@ -1339,7 +1334,7 @@
             if (getAutoTime()) {
                 long millisSinceNitzReceived
                         = SystemClock.elapsedRealtime() - nitzReceiveTime;
-        
+
                 if (millisSinceNitzReceived < 0) {
                     // Sanity check: something is wrong
                     Log.i(LOG_TAG, "NITZ: not setting time, clock has rolled "
@@ -1347,7 +1342,7 @@
                                         + nitz);
                     return;
                 }
-        
+
                 if (millisSinceNitzReceived > Integer.MAX_VALUE) {
                     // If the time is this far off, something is wrong > 24 days!
                     Log.i(LOG_TAG, "NITZ: not setting time, processing has taken "
@@ -1355,10 +1350,10 @@
                                     + " days");
                     return;
                 }
-        
+
                 // Note: with range checks above, cast to int is safe
                 c.add(Calendar.MILLISECOND, (int)millisSinceNitzReceived);
-        
+
                 Log.i(LOG_TAG, "NITZ: Setting time of day to " + c.getTime()
                     + " NITZ receive delay(ms): " + millisSinceNitzReceived
                     + " gained(ms): "
@@ -1399,11 +1394,11 @@
     /**
      * Set the timezone and send out a sticky broadcast so the system can
      * determine if the timezone was set by the carrier.
-     * 
+     *
      * @param zoneId timezone set by carrier
      */
     private void setAndBroadcastNetworkSetTimeZone(String zoneId) {
-        AlarmManager alarm = 
+        AlarmManager alarm =
             (AlarmManager) phone.getContext().getSystemService(Context.ALARM_SERVICE);
         alarm.setTimeZone(zoneId);
         Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE);
@@ -1414,9 +1409,9 @@
     /**
      * Set the time and Send out a sticky broadcast so the system can determine
      * if the time was set by the carrier.
-     * 
+     *
      * @param time time set by network
-     */ 
+     */
     private void setAndBroadcastNetworkSetTime(long time) {
         SystemClock.setCurrentTimeMillis(time);
         Intent intent = new Intent(TelephonyIntents.ACTION_NETWORK_SET_TIME);
diff --git a/telephony/java/com/android/internal/telephony/gsm/TelephonyEventLog.java b/telephony/java/com/android/internal/telephony/gsm/TelephonyEventLog.java
new file mode 100644
index 0000000..1e583f0
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/gsm/TelephonyEventLog.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.telephony.gsm;
+
+/* This class contains the details related to Telephony Event Logging */
+public final class TelephonyEventLog {
+
+    /* Event log tags */
+    public static final int EVENT_LOG_BAD_DNS_ADDRESS = 50100;
+    public static final int EVENT_LOG_RADIO_RESET_COUNTDOWN_TRIGGERED = 50101;
+    public static final int EVENT_LOG_RADIO_RESET = 50102;
+    public static final int EVENT_LOG_PDP_RESET = 50103;
+    public static final int EVENT_LOG_REREGISTER_NETWORK = 50104;
+    public static final int EVENT_LOG_RADIO_PDP_SETUP_FAIL = 50105;
+    public static final int EVENT_LOG_CALL_DROP = 50106;
+    public static final int EVENT_LOG_CGREG_FAIL = 50107;
+    public static final int EVENT_DATA_STATE_RADIO_OFF = 50108;
+    public static final int EVENT_LOG_PDP_NETWORK_DROP = 50109;
+}
diff --git a/test-runner/android/test/InstrumentationTestRunner.java b/test-runner/android/test/InstrumentationTestRunner.java
index 8b8d472..f038612 100644
--- a/test-runner/android/test/InstrumentationTestRunner.java
+++ b/test-runner/android/test/InstrumentationTestRunner.java
@@ -148,6 +148,8 @@
     public static final String ARGUMENT_TEST_SIZE_PREDICATE = "size";
     /** @hide */
     public static final String ARGUMENT_INCLUDE_PERF = "perf";
+    /** @hide */
+    public static final String ARGUMENT_DELAY_MSEC = "delay_msec";
 
     private static final String SMALL_SUITE = "small";
     private static final String MEDIUM_SUITE = "medium";  
@@ -249,6 +251,7 @@
     private String mPackageOfTests;
     private boolean mCoverage;
     private String mCoverageFilePath;
+    private int mDelayMsec;
 
     @Override
     public void onCreate(Bundle arguments) {
@@ -277,11 +280,18 @@
             logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
             mCoverage = getBooleanArgument(arguments, "coverage");
             mCoverageFilePath = arguments.getString("coverageFile");
+
+            try {
+                Object delay = arguments.get(ARGUMENT_DELAY_MSEC);  // Accept either string or int
+                if (delay != null) mDelayMsec = Integer.parseInt(delay.toString());
+            } catch (NumberFormatException e) {
+                Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
+            }
         }
-        
+
         TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(),
                 getTargetContext().getClassLoader());
-        
+
         if (testSizePredicate != null) {
             testSuiteBuilder.addRequirements(testSizePredicate);
         }
@@ -600,6 +610,18 @@
             } else {
                 mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "");
             }
+
+            // The delay_msec parameter is normally used to provide buffers of idle time
+            // for power measurement purposes.  To make sure there is a delay before and after
+            // every test in a suite, we delay *after* every test (see endTest below) and also
+            // delay *before* the first test.  So, delay test1 delay test2 delay.
+
+            try {
+                if (mTestNum == 1) Thread.sleep(mDelayMsec);
+            } catch (InterruptedException e) {
+                throw new IllegalStateException(e);
+            }
+
             sendStatus(REPORT_VALUE_RESULT_START, mTestResult);
             mTestResultCode = 0;
         }
@@ -636,10 +658,15 @@
                 mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, ".");
             }
             sendStatus(mTestResultCode, mTestResult);
+
+            try {  // Sleep after every test, if specified
+                Thread.sleep(mDelayMsec);
+            } catch (InterruptedException e) {
+                throw new IllegalStateException(e);
+            }
         }
 
         // TODO report the end of the cycle
         // TODO report runtime for each test
     }
 }
-
diff --git a/test-runner/android/test/TouchUtils.java b/test-runner/android/test/TouchUtils.java
index c4bca41..52d2ee8 100644
--- a/test-runner/android/test/TouchUtils.java
+++ b/test-runner/android/test/TouchUtils.java
@@ -73,7 +73,7 @@
      */
     @Deprecated
     public static void dragQuarterScreenUp(ActivityInstrumentationTestCase test) {
-        dragQuarterScreenDown(test, test.getActivity());
+        dragQuarterScreenUp(test, test.getActivity());
     }
     
     /**
@@ -269,9 +269,9 @@
         inst.waitForIdleSync();
 
         eventTime = SystemClock.uptimeMillis();
-        event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, 
-                x + (ViewConfiguration.getTouchSlop() / 2.0f),
-                y + (ViewConfiguration.getTouchSlop() / 2.0f), 0);
+        final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
+        event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
+                x + (touchSlop / 2.0f), y + (touchSlop / 2.0f), 0);
         inst.sendPointerSync(event);
         inst.waitForIdleSync();
 
@@ -309,9 +309,9 @@
         inst.waitForIdleSync();
 
         eventTime = SystemClock.uptimeMillis();
+        final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
         event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_CANCEL,
-                x + (ViewConfiguration.getTouchSlop() / 2.0f),
-                y + (ViewConfiguration.getTouchSlop() / 2.0f), 0);
+                x + (touchSlop / 2.0f), y + (touchSlop / 2.0f), 0);
         inst.sendPointerSync(event);
         inst.waitForIdleSync();
 
@@ -345,9 +345,9 @@
         
 
         eventTime = SystemClock.uptimeMillis();
-        event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, 
-                x + (ViewConfiguration.getTouchSlop() / 2.0f),
-                y + (ViewConfiguration.getTouchSlop() / 2.0f), 0);
+        final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
+        event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
+                x + (touchSlop / 2.0f), y + (touchSlop / 2.0f), 0);
         inst.sendPointerSync(event);
         inst.waitForIdleSync();
 
@@ -405,9 +405,9 @@
         inst.waitForIdleSync();
 
         eventTime = SystemClock.uptimeMillis();
-        event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, 
-                x + ViewConfiguration.getTouchSlop() / 2,
-                y + ViewConfiguration.getTouchSlop() / 2, 0);
+        final int touchSlop = ViewConfiguration.get(v.getContext()).getScaledTouchSlop();
+        event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE,
+                x + touchSlop / 2, y + touchSlop / 2, 0);
         inst.sendPointerSync(event);
         inst.waitForIdleSync();
         
diff --git a/test-runner/android/test/mock/MockPackageManager.java b/test-runner/android/test/mock/MockPackageManager.java
index f131bf2..57e7e41 100644
--- a/test-runner/android/test/mock/MockPackageManager.java
+++ b/test-runner/android/test/mock/MockPackageManager.java
@@ -393,4 +393,14 @@
             List<ComponentName> outActivities, String packageName) {
         throw new UnsupportedOperationException();
     }
+    
+    @Override
+    public String[] getSystemSharedLibraryNames() {
+        throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public boolean isSafeMode() {
+        throw new UnsupportedOperationException();
+    }
 }
diff --git a/tests/AndroidTests/AndroidManifest.xml b/tests/AndroidTests/AndroidManifest.xml
index f126b8c..230456a 100644
--- a/tests/AndroidTests/AndroidManifest.xml
+++ b/tests/AndroidTests/AndroidManifest.xml
@@ -48,6 +48,7 @@
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.WRITE_GSERVICES" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
 
     <uses-permission android:name="com.android.unit_tests.permission.TEST_GRANTED" />
 
diff --git a/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java b/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java
index 6a9ac86..f9af436 100755
--- a/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/AppCacheTest.java
@@ -44,7 +44,7 @@
 import android.os.StatFs;
 
 public class AppCacheTest extends AndroidTestCase {
-    private static final boolean localLOGV = true;
+    private static final boolean localLOGV = false;
     public static final String TAG="AppCacheTest";
     public final long MAX_WAIT_TIME=60*1000;
     public final long WAIT_TIME_INCR=10*1000;
@@ -593,6 +593,20 @@
                 ", cache="+stats.cacheSize);
     }
     
+    @SmallTest
+    public void testGetSystemSharedLibraryNames() throws Exception {
+        try {
+            String[] sharedLibs = getPm().getSystemSharedLibraryNames();
+            if (localLOGV) {
+                for (String str : sharedLibs) {
+                    Log.i(TAG, str);
+                }
+            }
+        } catch (RemoteException e) {
+            fail("Failed invoking getSystemSharedLibraryNames with exception:" + e);
+        }   
+    }
+    
     class FreeStorageReceiver extends BroadcastReceiver {
         public static final String ACTION_FREE = "com.android.unit_tests.testcallback";
         private boolean doneFlag = false;
diff --git a/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java b/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java
index 21fb94b..0a60319 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/BluetoothTest.java
@@ -336,7 +336,6 @@
             filter.addAction(BluetoothIntent.ENABLED_ACTION);
             filter.addAction(BluetoothIntent.DISABLED_ACTION);
             filter.addAction(BluetoothIntent.NAME_CHANGED_ACTION);
-            filter.addAction(BluetoothIntent.MODE_CHANGED_ACTION);
             filter.addAction(BluetoothIntent.DISCOVERY_STARTED_ACTION);
             filter.addAction(BluetoothIntent.DISCOVERY_COMPLETED_ACTION);
             filter.addAction(BluetoothIntent.PAIRING_REQUEST_ACTION);
@@ -349,8 +348,6 @@
             filter.addAction(BluetoothIntent.REMOTE_DEVICE_DISCONNECTED_ACTION);
             filter.addAction(BluetoothIntent.REMOTE_NAME_UPDATED_ACTION);
             filter.addAction(BluetoothIntent.REMOTE_NAME_FAILED_ACTION);
-            filter.addAction(BluetoothIntent.REMOTE_ALIAS_CHANGED_ACTION);
-            filter.addAction(BluetoothIntent.REMOTE_ALIAS_CLEARED_ACTION);
             filter.addAction(BluetoothIntent.BOND_STATE_CHANGED_ACTION);
             filter.addAction(BluetoothIntent.HEADSET_STATE_CHANGED_ACTION);
             getContext().registerReceiver(
@@ -386,16 +383,6 @@
                 msg += " name=" + name;
             }
 
-            String alias = intent.getStringExtra(BluetoothIntent.ALIAS);
-            if (alias != null) {
-                msg += " alias=" + alias;
-            }
-
-            int mode = intent.getIntExtra(BluetoothIntent.MODE, -10);
-            if (mode != -10) {
-                msg += " mode=" + mode;
-            }
-
             int state = intent.getIntExtra(BluetoothIntent.HEADSET_STATE, -10);
             if (state != -10) {
                 msg += " headset state=" + state;
diff --git a/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java b/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java
index a8c51f4..dbfd0e7 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/BuildTest.java
@@ -55,6 +55,7 @@
     @SmallTest
     public void testBuildFields() throws Exception {
         assertNotEmpty("ID", Build.ID);
+        assertNotEmpty("DISPLAY", Build.DISPLAY);
         assertNotEmpty("PRODUCT", Build.PRODUCT);
         assertNotEmpty("DEVICE", Build.DEVICE);
         assertNotEmpty("BOARD", Build.BOARD);
diff --git a/tests/AndroidTests/src/com/android/unit_tests/CheckinProviderTest.java b/tests/AndroidTests/src/com/android/unit_tests/CheckinProviderTest.java
deleted file mode 100644
index f9a2ec0..0000000
--- a/tests/AndroidTests/src/com/android/unit_tests/CheckinProviderTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.unit_tests;
-
-import org.apache.commons.codec.binary.Base64;
-
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.ContentUris;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.Checkin;
-import android.server.checkin.CheckinProvider;
-import android.server.data.BuildData;
-import android.server.data.CrashData;
-import android.server.data.ThrowableData;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import java.io.DataInputStream;
-import java.io.ByteArrayInputStream;
-
-/** Unit test for {@link CheckinProvider}. */
-public class CheckinProviderTest extends AndroidTestCase {
-    @MediumTest
-    public void testEventReport() {
-        long start = System.currentTimeMillis();
-        ContentResolver r = getContext().getContentResolver();
-        Checkin.logEvent(r, Checkin.Events.Tag.TEST, "Test Value");
-
-        Cursor c = r.query(Checkin.Events.CONTENT_URI,
-                null,
-                Checkin.Events.TAG + "=?",
-                new String[] { Checkin.Events.Tag.TEST.toString() },
-                null);
-
-        long id = -1;
-        while (c.moveToNext()) {
-            String tag = c.getString(c.getColumnIndex(Checkin.Events.TAG));
-            String value = c.getString(c.getColumnIndex(Checkin.Events.VALUE));
-            long date = c.getLong(c.getColumnIndex(Checkin.Events.DATE));
-            assertEquals(Checkin.Events.Tag.TEST.toString(), tag);
-            if ("Test Value".equals(value) && date >= start) {
-                assertTrue(id < 0);
-                id = c.getInt(c.getColumnIndex(Checkin.Events._ID));
-            }
-        }
-        assertTrue(id > 0);
-
-        int rows = r.delete(ContentUris.withAppendedId(Checkin.Events.CONTENT_URI, id), null, null);
-        assertEquals(1, rows);
-        c.requery();
-        while (c.moveToNext()) {
-            long date = c.getLong(c.getColumnIndex(Checkin.Events.DATE));
-            assertTrue(date < start);  // Have deleted the only newer TEST.
-        }
-
-        c.close();
-    }
-
-    @MediumTest
-    public void testStatsUpdate() {
-        ContentResolver r = getContext().getContentResolver();
-
-        // First, delete any existing data associated with the TEST tag.
-        Uri uri = Checkin.updateStats(r, Checkin.Stats.Tag.TEST, 0, 0);
-        assertNotNull(uri);
-        assertEquals(1, r.delete(uri, null, null));
-        assertFalse(r.query(uri, null, null, null, null).moveToNext());
-
-        // Now, add a known quantity to the TEST tag.
-        Uri u2 = Checkin.updateStats(r, Checkin.Stats.Tag.TEST, 1, 0.5);
-        assertFalse(uri.equals(u2));
-
-        Cursor c = r.query(u2, null, null, null, null);
-        assertTrue(c.moveToNext());
-        assertEquals(1, c.getInt(c.getColumnIndex(Checkin.Stats.COUNT)));
-        assertEquals(0.5, c.getDouble(c.getColumnIndex(Checkin.Stats.SUM)));
-        assertFalse(c.moveToNext());  // Only one.
-
-        // Add another known quantity to TEST (should sum with the first).
-        Uri u3 = Checkin.updateStats(r, Checkin.Stats.Tag.TEST, 2, 1.0);
-        assertEquals(u2, u3);
-        c.requery();
-        assertTrue(c.moveToNext());
-        assertEquals(3, c.getInt(c.getColumnIndex(Checkin.Stats.COUNT)));
-        assertEquals(1.5, c.getDouble(c.getColumnIndex(Checkin.Stats.SUM)));
-        assertFalse(c.moveToNext());  // Only one.
-
-        // Now subtract the values; the whole row should disappear.
-        Uri u4 = Checkin.updateStats(r, Checkin.Stats.Tag.TEST, -3, -1.5);
-        assertNull(u4);
-        c.requery();
-        assertFalse(c.moveToNext());  // Row has been deleted.
-        c.close();
-    }
-
-    @MediumTest
-    public void testCrashReport() throws Exception {
-        long start = System.currentTimeMillis();
-        ContentResolver r = getContext().getContentResolver();
-
-        // Log a test (fake) crash report.
-        Checkin.reportCrash(r, new CrashData(
-                "Test",
-                "Test Activity",
-                new BuildData("Test Build", "123", start),
-                new ThrowableData(new RuntimeException("Test Exception"))));
-
-
-        // Crashes aren't indexed; go through them all to find the one we added.
-        Cursor c = r.query(Checkin.Crashes.CONTENT_URI, null, null, null, null);
-
-        Uri uri = null;
-        while (c.moveToNext()) {
-            String coded = c.getString(c.getColumnIndex(Checkin.Crashes.DATA));
-            byte[] bytes = Base64.decodeBase64(coded.getBytes());
-            CrashData crash = new CrashData(
-                    new DataInputStream(new ByteArrayInputStream(bytes)));
-
-            // Should be exactly one recently added "Test" crash.
-            if (crash.getId().equals("Test") && crash.getTime() > start) {
-                assertEquals("Test Activity", crash.getActivity());
-                assertEquals("Test Build", crash.getBuildData().getFingerprint());
-                assertEquals("Test Exception",
-                        crash.getThrowableData().getMessage());
-
-                assertNull(uri);
-                uri = ContentUris.withAppendedId(Checkin.Crashes.CONTENT_URI, c.getInt(c.getColumnIndex(Checkin.Crashes._ID)));
-            }
-        }
-        assertNotNull(uri);
-        c.close();
-
-        // Update the "logs" column.
-        ContentValues values = new ContentValues();
-        values.put(Checkin.Crashes.LOGS, "Test Logs");
-        assertEquals(1, r.update(uri, values, null, null));
-
-        c = r.query(uri, null, null, null, null);
-        assertTrue(c.moveToNext());
-        String logs = c.getString(c.getColumnIndex(Checkin.Crashes.LOGS));
-        assertEquals("Test Logs", logs);
-        c.deleteRow();
-        c.close();
-
-        c.requery();
-        assertFalse(c.moveToNext());
-        c.close();
-    }
-
-    @MediumTest
-    public void testPropertiesRestricted() throws Exception {
-        ContentResolver r = getContext().getContentResolver();
-
-        // The test app doesn't have the permission to access properties,
-        // so any attempt to do so should fail.
-        try {
-            r.insert(Checkin.Properties.CONTENT_URI, new ContentValues());
-            fail("SecurityException expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-
-        try {
-            r.query(Checkin.Properties.CONTENT_URI, null, null, null, null);
-            fail("SecurityException expected");
-        } catch (SecurityException e) {
-            // expected
-        }
-    }
-}
diff --git a/tests/AndroidTests/src/com/android/unit_tests/HtmlTest.java b/tests/AndroidTests/src/com/android/unit_tests/HtmlTest.java
index 26a3ae0..27da4f1 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/HtmlTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/HtmlTest.java
@@ -61,6 +61,10 @@
 
         s = new SpannableString("Hello world\n\n\nor something");
         assertEquals(Html.toHtml(s), "<p>Hello world<br></p>\n<p>or something</p>\n");
+
+        assertEquals("foo\nbar", Html.fromHtml("foo<br>bar").toString());
+        assertEquals("foo\nbar", Html.fromHtml("foo<br>\nbar").toString());
+        assertEquals("foo\nbar", Html.fromHtml("foo<br>\n \nbar").toString());
     }
 
     @SmallTest
diff --git a/tests/AndroidTests/src/com/android/unit_tests/activity/ActivityManagerTest.java b/tests/AndroidTests/src/com/android/unit_tests/activity/ActivityManagerTest.java
index d7d8c89..ab91761 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/activity/ActivityManagerTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/activity/ActivityManagerTest.java
@@ -18,6 +18,8 @@
 
 import android.app.ActivityManager;
 import android.content.Context;
+import android.content.pm.ConfigurationInfo;
+import android.content.res.Configuration;
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 import android.test.suitebuilder.annotation.Suppress;
@@ -90,6 +92,24 @@
         // test: confirm our ANR'ing application shows up in the list
     }
     
+    @SmallTest
+    public void testGetDeviceConfigurationInfo() throws Exception {
+        ConfigurationInfo config = mActivityManager.getDeviceConfigurationInfo();
+        assertNotNull(config);
+        // Validate values against configuration retrieved from resources
+        Configuration vconfig = mContext.getResources().getConfiguration();
+        assertNotNull(vconfig);
+        assertEquals(config.reqKeyboardType, vconfig.keyboard);
+        assertEquals(config.reqTouchScreen, vconfig.touchscreen);
+        assertEquals(config.reqNavigation, vconfig.navigation);
+        if (vconfig.navigation == Configuration.NAVIGATION_NONAV) {
+            assertNotNull(config.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV);
+        }
+        if (vconfig.keyboard != Configuration.KEYBOARD_UNDEFINED) {
+            assertNotNull(config.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD);
+        }    
+    }
+    
     // If any entries in appear in the list, sanity check them against all running applications
     private void checkErrorListSanity(List<ActivityManager.ProcessErrorStateInfo> errList) {
         if (errList == null) return;
diff --git a/tests/CoreTests/android/test/InstrumentationTestRunnerTest.java b/tests/CoreTests/android/test/InstrumentationTestRunnerTest.java
index 359c902..d9afd54 100644
--- a/tests/CoreTests/android/test/InstrumentationTestRunnerTest.java
+++ b/tests/CoreTests/android/test/InstrumentationTestRunnerTest.java
@@ -89,6 +89,26 @@
         
     }
 
+    public void testDelayParameter() throws Exception {
+        int delayMsec = 1000;
+        Bundle args = new Bundle();
+        args.putInt(InstrumentationTestRunner.ARGUMENT_DELAY_MSEC, delayMsec);
+        args.putString(InstrumentationTestRunner.ARGUMENT_TEST_CLASS,
+                PlaceHolderTest.class.getName() + "," +
+                PlaceHolderTest2.class.getName());
+        mInstrumentationTestRunner.onCreate(args);
+        Thread t = new Thread() { public void run() { mInstrumentationTestRunner.onStart(); } };
+
+        // Should delay three times: before, between, and after the two tests.
+        long beforeTest = System.currentTimeMillis();
+        t.start();
+        t.join();
+        assertTrue(System.currentTimeMillis() > beforeTest + delayMsec * 3);
+        assertTrue(mInstrumentationTestRunner.isStarted());
+        assertTrue(mInstrumentationTestRunner.isFinished());
+        assertTrue(mStubAndroidTestRunner.isRun());
+    }
+
     private void assertContentsInOrder(List<TestDescriptor> actual, TestDescriptor... source) {
         TestDescriptor[] clonedSource = source.clone();
         assertEquals("Unexpected number of items.", clonedSource.length, actual.size());
@@ -217,6 +237,7 @@
         }
 
         public void runTest() {
+            super.runTest();
             mRun = true;
         }
     }
diff --git a/tests/DpiTest/Android.mk b/tests/DpiTest/Android.mk
new file mode 100644
index 0000000..3596c39
--- /dev/null
+++ b/tests/DpiTest/Android.mk
@@ -0,0 +1,10 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := DensityTest
+
+LOCAL_MODULE_TAGS := tests
+
+include $(BUILD_PACKAGE)
diff --git a/tests/DpiTest/AndroidManifest.xml b/tests/DpiTest/AndroidManifest.xml
new file mode 100644
index 0000000..f71cff2
--- /dev/null
+++ b/tests/DpiTest/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+  
+          http://www.apache.org/licenses/LICENSE-2.0
+  
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.google.android.test.dpi">
+    <application android:label="DpiTest">
+        <activity android:name="DpiTestActivity" android:label="DpiTest">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+</manifest>
diff --git a/tests/DpiTest/res/drawable-120dpi/logo120dpi.png b/tests/DpiTest/res/drawable-120dpi/logo120dpi.png
new file mode 100644
index 0000000..46bbd5b
--- /dev/null
+++ b/tests/DpiTest/res/drawable-120dpi/logo120dpi.png
Binary files differ
diff --git a/tests/DpiTest/res/drawable-240dpi/logo240dpi.png b/tests/DpiTest/res/drawable-240dpi/logo240dpi.png
new file mode 100644
index 0000000..4d717a8
--- /dev/null
+++ b/tests/DpiTest/res/drawable-240dpi/logo240dpi.png
Binary files differ
diff --git a/tests/DpiTest/res/drawable/logo160dpi.png b/tests/DpiTest/res/drawable/logo160dpi.png
new file mode 100644
index 0000000..c23b2ce
--- /dev/null
+++ b/tests/DpiTest/res/drawable/logo160dpi.png
Binary files differ
diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
new file mode 100644
index 0000000..3759622
--- /dev/null
+++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.android.test.dpi;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.view.View;
+import android.content.Context;
+
+public class DpiTestActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        LinearLayout root = new LinearLayout(this);
+        root.setOrientation(LinearLayout.VERTICAL);
+
+        LinearLayout layout = new LinearLayout(this);
+        addBitmapDrawable(layout, R.drawable.logo120dpi, true);
+        addBitmapDrawable(layout, R.drawable.logo160dpi, true);
+        addBitmapDrawable(layout, R.drawable.logo240dpi, true);
+        addLabelToRoot(root, "Prescaled bitmap in drawable");
+        addChildToRoot(root, layout);
+
+        layout = new LinearLayout(this);
+        addBitmapDrawable(layout, R.drawable.logo120dpi, false);
+        addBitmapDrawable(layout, R.drawable.logo160dpi, false);
+        addBitmapDrawable(layout, R.drawable.logo240dpi, false);
+        addLabelToRoot(root, "Autoscaled bitmap in drawable");
+        addChildToRoot(root, layout);
+
+        layout = new LinearLayout(this);
+        addResourceDrawable(layout, R.drawable.logo120dpi);
+        addResourceDrawable(layout, R.drawable.logo160dpi);
+        addResourceDrawable(layout, R.drawable.logo240dpi);
+        addLabelToRoot(root, "Prescaled resource drawable");
+        addChildToRoot(root, layout);
+
+        layout = new LinearLayout(this);
+        addCanvasBitmap(layout, R.drawable.logo120dpi, true);
+        addCanvasBitmap(layout, R.drawable.logo160dpi, true);
+        addCanvasBitmap(layout, R.drawable.logo240dpi, true);
+        addLabelToRoot(root, "Prescaled bitmap");
+        addChildToRoot(root, layout);
+
+        layout = new LinearLayout(this);
+        addCanvasBitmap(layout, R.drawable.logo120dpi, false);
+        addCanvasBitmap(layout, R.drawable.logo160dpi, false);
+        addCanvasBitmap(layout, R.drawable.logo240dpi, false);
+        addLabelToRoot(root, "Autoscaled bitmap");
+        addChildToRoot(root, layout);
+
+        setContentView(scrollWrap(root));
+    }
+
+    private View scrollWrap(View view) {
+        ScrollView scroller = new ScrollView(this);
+        scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.FILL_PARENT,
+                ScrollView.LayoutParams.FILL_PARENT));
+        return scroller;
+    }
+
+    private void addLabelToRoot(LinearLayout root, String text) {
+        TextView label = new TextView(this);
+        label.setText(text);
+        root.addView(label, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
+                LinearLayout.LayoutParams.WRAP_CONTENT));
+    }
+
+    private void addChildToRoot(LinearLayout root, LinearLayout layout) {
+        root.addView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
+                LinearLayout.LayoutParams.WRAP_CONTENT));
+    }
+
+    private void addBitmapDrawable(LinearLayout layout, int resource, boolean scale) {
+        Bitmap bitmap;
+        bitmap = loadAndPrintDpi(resource, scale);
+
+        View view = new View(this);
+
+        final BitmapDrawable d = new BitmapDrawable(bitmap);
+        if (!scale) d.setDensityScale(getResources().getDisplayMetrics());
+        view.setBackgroundDrawable(d);
+
+        view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(),
+                d.getIntrinsicHeight()));
+        layout.addView(view);
+    }
+
+    private void addResourceDrawable(LinearLayout layout, int resource) {
+        View view = new View(this);
+
+        final Drawable d = getResources().getDrawable(resource);
+        view.setBackgroundDrawable(d);
+
+        view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(),
+                d.getIntrinsicHeight()));
+        layout.addView(view);
+    }
+
+    private void addCanvasBitmap(LinearLayout layout, int resource, boolean scale) {
+        Bitmap bitmap;
+        bitmap = loadAndPrintDpi(resource, scale);
+
+        ScaledBitmapView view = new ScaledBitmapView(this, bitmap);
+
+        view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
+                LinearLayout.LayoutParams.WRAP_CONTENT));
+        layout.addView(view);
+    }
+
+    private Bitmap loadAndPrintDpi(int id, boolean scale) {
+        Bitmap bitmap;
+        if (scale) {
+            bitmap = BitmapFactory.decodeResource(getResources(), id);
+        } else {
+            BitmapFactory.Options opts = new BitmapFactory.Options();
+            opts.inScaled = false;
+            bitmap = BitmapFactory.decodeResource(getResources(), id, opts);
+        }
+        return bitmap;
+    }
+
+    private class ScaledBitmapView extends View {
+        private Bitmap mBitmap;
+
+        public ScaledBitmapView(Context context, Bitmap bitmap) {
+            super(context);
+            mBitmap = bitmap;
+        }
+
+        @Override
+        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+            setMeasuredDimension(mBitmap.getScaledWidth(), mBitmap.getScaledHeight());
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+
+            canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
+        }
+    }
+}
diff --git a/tests/DumpRenderTree/compare_layout_results.py b/tests/DumpRenderTree/compare_layout_results.py
new file mode 100644
index 0000000..4383dbb
--- /dev/null
+++ b/tests/DumpRenderTree/compare_layout_results.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+"""
+Compares results of two webkit layout test runs and writes
+results to a file.
+"""
+
+import optparse
+import os
+
+def DiffResults(marker, new_results, old_results, diff_results, strip_reason):
+   """ Given two result files, generate diff and
+       write to diff_results file. All arguments are absolute paths
+       to files.
+   """
+   old_file = open(old_results, "r")
+   new_file = open(new_results, "r")
+   diff_file = open(diff_results, "a") 
+
+   # Read lines from each file
+   ndict = new_file.readlines()
+   cdict = old_file.readlines()
+
+   # Write marker to diff file
+   diff_file.writelines(marker + "\n")
+   diff_file.writelines("###############\n")
+
+   # Strip reason from result lines
+   if strip_reason is True:
+     for i in range(0, len(ndict)):
+       ndict[i] = ndict[i].split(' ')[0] + "\n"
+     for i in range(0, len(cdict)):
+       cdict[i] = cdict[i].split(' ')[0] + "\n"
+
+   # Find results in new_results missing in old_results
+   new_count=0
+   for line in ndict:
+     if line not in cdict:
+       diff_file.writelines("+ " + line)
+       new_count += 1
+
+   # Find results in old_results missing in new_results
+   missing_count=0
+   for line in cdict:
+     if line not in ndict:
+       diff_file.writelines("- " + line)
+       missing_count += 1
+
+   print marker + "  >>> New = " + str(new_count) + " , Missing = " + str(missing_count) 
+
+   diff_file.writelines("\n\n")
+
+   old_file.close()
+   new_file.close()
+   diff_file.close()
+   return
+
+def main(options, args):
+  results_dir = options.results_directory
+  ref_dir = options.ref_directory
+  if os.path.exists(results_dir + "/layout_tests_diff.txt"):
+    os.remove(results_dir + "/layout_tests_diff.txt")
+
+  files=["passed", "nontext", "crashed"]
+  for f in files:
+    DiffResults(f, results_dir + "layout_tests_" + f + ".txt",
+              ref_dir + "layout_tests_" + f + ".txt", results_dir + "layout_tests_diff.txt", False)
+
+  for f in ["failed"]:
+    DiffResults(f, results_dir + "layout_tests_" + f + ".txt",
+              ref_dir + "layout_tests_" + f + ".txt", results_dir + "layout_tests_diff.txt", True)
+
+if '__main__' == __name__:
+  option_parser = optparse.OptionParser()
+  option_parser.add_option("", "--ref-directory",
+                           default="results/",
+                           dest="ref_directory",
+                           help="directory name under which results are stored.")
+
+  option_parser.add_option("", "--results-directory",
+                           default="layout-test-results/",
+                           dest="results_directory",
+                           help="directory name under which results are stored.")
+  options, args = option_parser.parse_args()
+  main(options, args)
diff --git a/tests/DumpRenderTree/results/layout_tests_crashed.txt b/tests/DumpRenderTree/results/layout_tests_crashed.txt
new file mode 100644
index 0000000..1859f07
--- /dev/null
+++ b/tests/DumpRenderTree/results/layout_tests_crashed.txt
@@ -0,0 +1,2 @@
+/sdcard/android/layout_tests/fast/js/regexp-charclass-crash.html
+/sdcard/android/layout_tests/fast/canvas/gradient-add-second-start-end-stop.html
diff --git a/tests/DumpRenderTree/results/layout_tests_failed.txt b/tests/DumpRenderTree/results/layout_tests_failed.txt
new file mode 100644
index 0000000..5a20b52
--- /dev/null
+++ b/tests/DumpRenderTree/results/layout_tests_failed.txt
@@ -0,0 +1,283 @@
+/sdcard/android/layout_tests/fast/text/zero-width-characters.html :  different length
+/sdcard/android/layout_tests/fast/text/reset-drag-on-mouse-down.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/text/plain-text-line-breaks.html :  different length
+/sdcard/android/layout_tests/fast/replaced/table-percent-height.html :  different length
+/sdcard/android/layout_tests/fast/replaced/image-map.html :  different length
+/sdcard/android/layout_tests/fast/replaced/image-map-bug16782.html :  different length
+/sdcard/android/layout_tests/fast/parser/xml-declaration-missing-ending-mark.html :  different length
+/sdcard/android/layout_tests/fast/parser/tabindex-parsing.html :  different length
+/sdcard/android/layout_tests/fast/parser/script-tag-with-trailing-slash.html :  different length
+/sdcard/android/layout_tests/fast/parser/external-entities.xml :  different length
+/sdcard/android/layout_tests/fast/parser/entity-end-script-tag.html :  different length
+/sdcard/android/layout_tests/fast/parser/entity-comment-in-iframe.html :   @offset: 0
+/sdcard/android/layout_tests/fast/parser/comment-in-iframe.html :   @offset: 0
+/sdcard/android/layout_tests/fast/overflow/scroll-vertical-not-horizontal.html :  different length
+/sdcard/android/layout_tests/fast/loader/xmlhttprequest-missing-file-exception.html :  different length
+/sdcard/android/layout_tests/fast/loader/stop-provisional-loads.html :  different length
+/sdcard/android/layout_tests/fast/loader/plain-text-document.html :  different length
+/sdcard/android/layout_tests/fast/loader/opaque-base-url.html :   @offset: 129
+/sdcard/android/layout_tests/fast/loader/onunload-form-submit-crash.html :  different length
+/sdcard/android/layout_tests/fast/loader/onunload-form-submit-crash-2.html :  different length
+/sdcard/android/layout_tests/fast/loader/local-JavaScript-from-local.html :  different length
+/sdcard/android/layout_tests/fast/loader/local-image-from-local.html :  different length
+/sdcard/android/layout_tests/fast/loader/local-iFrame-source-from-local.html :  different length
+/sdcard/android/layout_tests/fast/loader/local-CSS-from-local.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/loader/data-url-encoding-svg.html :  different length
+/sdcard/android/layout_tests/fast/loader/cancel-load-during-port-block-timer.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/var-shadows-arg-gc-crash.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/try-catch-crash.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/toString-and-valueOf-override.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/recursion-limit-equal.html :  different length
+/sdcard/android/layout_tests/fast/js/navigator-mimeTypes-length.html :  different length
+/sdcard/android/layout_tests/fast/js/math-transforms.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/global-recursion-on-full-stack.html :  different length
+/sdcard/android/layout_tests/fast/js/global-constructors.html :  different length
+/sdcard/android/layout_tests/fast/js/exceptions-thrown-in-callbacks.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/exception-sequencing.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/exception-sequencing-binops2.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/exception-sequencing-binops.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/js/exception-codegen-crash.html :  different length
+/sdcard/android/layout_tests/fast/js/duplicate-param-gc-crash.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/html/tab-order.html :   @offset: 246
+/sdcard/android/layout_tests/fast/history/subframe-is-visited.html :  different length
+/sdcard/android/layout_tests/fast/history/go-back-to-changed-name.html :  different length
+/sdcard/android/layout_tests/fast/frames/viewsource-empty-attribute-value.html :  different length
+/sdcard/android/layout_tests/fast/frames/removal-before-attach-crash.html :  different length
+/sdcard/android/layout_tests/fast/frames/iframe-window-focus.html :  different length
+/sdcard/android/layout_tests/fast/frames/frameElement-widthheight.html :  different length
+/sdcard/android/layout_tests/fast/frames/frame-js-url-clientWidth.html :  different length
+/sdcard/android/layout_tests/fast/frames/frame-base-url.html :  different length
+/sdcard/android/layout_tests/fast/frames/empty-frame-src.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/forms/mailto/post-text-plain.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/post-text-plain-with-accept-charset.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/post-multiple-items.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/post-multiple-items-text-plain.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/post-multiple-items-multipart-form-data.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/post-append-query.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-overwrite-query.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-non-ascii.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-non-ascii-text-plain.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-non-ascii-text-plain-latin-1.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-non-ascii-always-utf-8.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-multiple-items.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/get-multiple-items-text-plain.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/advanced-put.html :  different length
+/sdcard/android/layout_tests/fast/forms/mailto/advanced-get.html :  different length
+/sdcard/android/layout_tests/fast/forms/textfield-to-password-on-focus.html :  different length
+/sdcard/android/layout_tests/fast/forms/textfield-onchange-deletion.html :  different length
+/sdcard/android/layout_tests/fast/forms/textfield-inside-anchor.html :  different length
+/sdcard/android/layout_tests/fast/forms/textarea-type-spaces.html :  different length
+/sdcard/android/layout_tests/fast/forms/textarea-scrolled-endline-caret.html :  different length
+/sdcard/android/layout_tests/fast/forms/textarea-paste-newline.html :  different length
+/sdcard/android/layout_tests/fast/forms/textarea-no-scroll-on-blur.html :   @offset: 79
+/sdcard/android/layout_tests/fast/forms/textarea-initial-caret-position.html :  different length
+/sdcard/android/layout_tests/fast/forms/textarea-hard-linewrap.html :  different length
+/sdcard/android/layout_tests/fast/forms/textarea-default-value-leading-newline.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/forms/textarea-appearance-wrap.html :  different length
+/sdcard/android/layout_tests/fast/forms/text-field-setvalue-crash.html :  different length
+/sdcard/android/layout_tests/fast/forms/stuff-on-my-optgroup.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/forms/slider-onchange-event.html :  different length
+/sdcard/android/layout_tests/fast/forms/slider-mouse-events.html :  different length
+/sdcard/android/layout_tests/fast/forms/selection-functions.html :   @offset: 306
+/sdcard/android/layout_tests/fast/forms/select-type-ahead-non-latin.html :  different length
+/sdcard/android/layout_tests/fast/forms/select-enter-key.html :  different length
+/sdcard/android/layout_tests/fast/forms/select-empty-list.html :  different length
+/sdcard/android/layout_tests/fast/forms/select-double-onchange.html :  different length
+/sdcard/android/layout_tests/fast/forms/select-accesskey.html :  different length
+/sdcard/android/layout_tests/fast/forms/search-hidden-cancel-button.html :  different length
+/sdcard/android/layout_tests/fast/forms/search-event-delay.html :  different length
+/sdcard/android/layout_tests/fast/forms/search-click-in-placeholder.html :   @offset: 1
+/sdcard/android/layout_tests/fast/forms/search-cancel-button-mouseup.html :  different length
+/sdcard/android/layout_tests/fast/forms/plaintext-mode-1.html :  different length
+/sdcard/android/layout_tests/fast/forms/password-doubleclick-selection.html :  different length
+/sdcard/android/layout_tests/fast/forms/onselect-textfield.html :  different length
+/sdcard/android/layout_tests/fast/forms/onselect-textarea.html :  different length
+/sdcard/android/layout_tests/fast/forms/onselect-selectall.html :  different length
+/sdcard/android/layout_tests/fast/forms/onchange-enter-submit.html :  different length
+/sdcard/android/layout_tests/fast/forms/listbox-typeahead-scroll.html :  different length
+/sdcard/android/layout_tests/fast/forms/listbox-selection.html :  different length
+/sdcard/android/layout_tests/fast/forms/listbox-select-all.html :  different length
+/sdcard/android/layout_tests/fast/forms/listbox-onchange.html :  different length
+/sdcard/android/layout_tests/fast/forms/legend-access-key.html :  different length
+/sdcard/android/layout_tests/fast/forms/input-select-on-click.html :  different length
+/sdcard/android/layout_tests/fast/forms/input-radio-checked-tab.html :   @offset: 115
+/sdcard/android/layout_tests/fast/forms/input-maxlength.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/forms/input-implicit-length-limit.html :  different length
+/sdcard/android/layout_tests/fast/forms/input-first-letter.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/forms/input-delete.html :  different length
+/sdcard/android/layout_tests/fast/forms/form-element-geometry.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/forms/form-collection-lookup.html :  different length
+/sdcard/android/layout_tests/fast/forms/form-and-frame-interaction-retains-values.html :  different length
+/sdcard/android/layout_tests/fast/forms/focus2.html :  different length
+/sdcard/android/layout_tests/fast/forms/focus.html :  different length
+/sdcard/android/layout_tests/fast/forms/focus-selection-textarea.html :  different length
+/sdcard/android/layout_tests/fast/forms/focus-selection-input.html :  different length
+/sdcard/android/layout_tests/fast/forms/focus-control-to-page.html :  different length
+/sdcard/android/layout_tests/fast/forms/enter-clicks-buttons.html :  different length
+/sdcard/android/layout_tests/fast/forms/drag-out-of-textarea.html :  different length
+/sdcard/android/layout_tests/fast/forms/drag-into-textarea.html :  different length
+/sdcard/android/layout_tests/fast/forms/check-box-enter-key.html :  different length
+/sdcard/android/layout_tests/fast/forms/button-state-restore.html :  different length
+/sdcard/android/layout_tests/fast/forms/button-spacebar-click.html :  different length
+/sdcard/android/layout_tests/fast/forms/button-enter-click.html :  different length
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-003.html :   @offset: 51
+/sdcard/android/layout_tests/fast/forms/access-key.html :  different length
+/sdcard/android/layout_tests/fast/events/window-events-capture.html :  different length
+/sdcard/android/layout_tests/fast/events/window-events-bubble2.html :  different length
+/sdcard/android/layout_tests/fast/events/window-events-bubble.html :  different length
+/sdcard/android/layout_tests/fast/events/tabindex-focus-chain.html :   @offset: 0
+/sdcard/android/layout_tests/fast/events/scrollbar-double-click.html :  different length
+/sdcard/android/layout_tests/fast/events/scroll-to-anchor-in-overflow-hidden.html :  different length
+/sdcard/android/layout_tests/fast/events/scroll-event-does-not-bubble.html :  different length
+/sdcard/android/layout_tests/fast/events/related-target.html :  different length
+/sdcard/android/layout_tests/fast/events/option-tab.html :  different length
+/sdcard/android/layout_tests/fast/events/open-window-from-another-frame.html :  different length
+/sdcard/android/layout_tests/fast/events/onunload.html :  different length
+/sdcard/android/layout_tests/fast/events/onunload-window-property.html :  different length
+/sdcard/android/layout_tests/fast/events/onunload-not-on-body.html :  different length
+/sdcard/android/layout_tests/fast/events/onunload-clears-onbeforeunload.html :  different length
+/sdcard/android/layout_tests/fast/events/onsearch-enter.html :  different length
+/sdcard/android/layout_tests/fast/events/onload-webkit-before-webcore.html :   @offset: 105
+/sdcard/android/layout_tests/fast/events/ondragenter.html :  different length
+/sdcard/android/layout_tests/fast/events/onclick-list-marker.html :  different length
+/sdcard/android/layout_tests/fast/events/onchange-textfield.html :  different length
+/sdcard/android/layout_tests/fast/events/onchange-select-popup.html :  different length
+/sdcard/android/layout_tests/fast/events/onchange-searchfield.html :  different length
+/sdcard/android/layout_tests/fast/events/onchange-passwordfield.html :  different length
+/sdcard/android/layout_tests/fast/events/onchange-click-hang.html :  different length
+/sdcard/android/layout_tests/fast/events/mouseup-outside-document.html :  different length
+/sdcard/android/layout_tests/fast/events/mouseup-from-button2.html :  different length
+/sdcard/android/layout_tests/fast/events/mouseover-mouseout2.html :  different length
+/sdcard/android/layout_tests/fast/events/mouseover-mouseout.html :  different length
+/sdcard/android/layout_tests/fast/events/mouseout-on-window.html :  different length
+/sdcard/android/layout_tests/fast/events/mouseout-dead-subframe.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/events/mousemove-after-drag-over-scrollbar.html :  different length
+/sdcard/android/layout_tests/fast/events/mouseclick-target-and-positioning.html :  different length
+/sdcard/android/layout_tests/fast/events/mouse-click-events.html :  different length
+/sdcard/android/layout_tests/fast/events/keypress-insert-tab.html :   @offset: 85
+/sdcard/android/layout_tests/fast/events/keypress-focus-change.html :  different length
+/sdcard/android/layout_tests/fast/events/keydown-keypress-preventDefault.html :   @offset: 228
+/sdcard/android/layout_tests/fast/events/keydown-keypress-focus-change.html :   @offset: 172
+/sdcard/android/layout_tests/fast/events/key-events-in-input-text.html :  different length
+/sdcard/android/layout_tests/fast/events/key-events-in-input-button.html :  different length
+/sdcard/android/layout_tests/fast/events/js-keyboard-event-creation.html :  different length
+/sdcard/android/layout_tests/fast/events/input-image-scrolled-x-y.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/events/iframe-object-onload.html :  different length
+/sdcard/android/layout_tests/fast/events/frame-tab-focus.html :  different length
+/sdcard/android/layout_tests/fast/events/frame-programmatic-focus.html :  different length
+/sdcard/android/layout_tests/fast/events/frame-click-focus.html :  different length
+/sdcard/android/layout_tests/fast/events/fire-scroll-event.html :  different length
+/sdcard/android/layout_tests/fast/events/event-view-toString.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/events/drag-outside-window.html :   @offset: 20
+/sdcard/android/layout_tests/fast/events/drag-in-frames.html :  different length
+/sdcard/android/layout_tests/fast/events/dblclick-addEventListener.html :  different length
+/sdcard/android/layout_tests/fast/events/contextmenu-scrolled-page-with-frame.html :  different length
+/sdcard/android/layout_tests/fast/events/content-changed-during-drop.html :  different length
+/sdcard/android/layout_tests/fast/events/click-count.html :  different length
+/sdcard/android/layout_tests/fast/events/capture-on-target.html :  different length
+/sdcard/android/layout_tests/fast/events/autoscroll-with-non-scrollable-parent.html :  different length
+/sdcard/android/layout_tests/fast/events/autoscroll-nonscrollable-iframe-in-scrollable-div.html :  different length
+/sdcard/android/layout_tests/fast/events/autoscroll-in-textfield.html :  different length
+/sdcard/android/layout_tests/fast/events/arrow-navigation.html :  different length
+/sdcard/android/layout_tests/fast/events/arrow-keys-on-body.html :  different length
+/sdcard/android/layout_tests/fast/events/anchor-image-scrolled-x-y.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/events/access-key-self-destruct.html :  different length
+/sdcard/android/layout_tests/fast/encoding/xml-utf-8-default.xml :  different length
+/sdcard/android/layout_tests/fast/encoding/url-host-name-non-ascii.html :  different length
+/sdcard/android/layout_tests/fast/encoding/percent-escaping.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/encoding/mailto-always-utf-8.html :  different length
+/sdcard/android/layout_tests/fast/encoding/invalid-xml.html :  different length
+/sdcard/android/layout_tests/fast/encoding/idn-security.html :  different length
+/sdcard/android/layout_tests/fast/encoding/frame-default-enc.html :   @offset: 0
+/sdcard/android/layout_tests/fast/encoding/charset-koi8-u.html :   @offset: 147
+/sdcard/android/layout_tests/fast/encoding/char-encoding.html :  different length
+/sdcard/android/layout_tests/fast/encoding/char-decoding.html :  different length
+/sdcard/android/layout_tests/fast/dynamic/paused-event-dispatch.html :   @offset: 117
+/sdcard/android/layout_tests/fast/dom/Window/window-xy-properties.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-scroll-arguments.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-screen-properties.html :   @offset: 65
+/sdcard/android/layout_tests/fast/dom/Window/window-resize.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-resize-and-move-arguments.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-property-clearing.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-properties.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/Window/window-open-pending-url.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-onFocus.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-function-name-getter-precedence.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/window-early-properties.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/setting-properties-on-closed-window.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/Window/redirect-with-timer.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/Plug-ins.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/orphaned-frame-access.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/new-window-opener.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/Window/get-set-properties.html :   @offset: 0
+/sdcard/android/layout_tests/fast/dom/Window/dom-access-from-closure-window.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/dom-access-from-closure-iframe.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/console-functions.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/closure-access-after-navigation-window.html :  different length
+/sdcard/android/layout_tests/fast/dom/Window/clear-timeout.html :  different length
+/sdcard/android/layout_tests/fast/dom/StyleSheet/ownerNode-lifetime-2.html :  different length
+/sdcard/android/layout_tests/fast/dom/HTMLSelectElement/listbox-select-reset.html :  different length
+/sdcard/android/layout_tests/fast/dom/HTMLObjectElement/object-as-frame.html :  different length
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/hasFocus.html :  different length
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/activeElement.html :  different length
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/011.xml :  different length
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/010.xml :  different length
+/sdcard/android/layout_tests/fast/dom/Element/offsetLeft-offsetTop-body-quirk.html :  different length
+/sdcard/android/layout_tests/fast/dom/DOMException/XPathException.html :  different length
+/sdcard/android/layout_tests/fast/dom/wrapper-classes.html :  different length
+/sdcard/android/layout_tests/fast/dom/tabindex-clamp.html :  different length
+/sdcard/android/layout_tests/fast/dom/simultaneouslyRegsiteredTimerFireOrder.html :  different length
+/sdcard/android/layout_tests/fast/dom/set-frame-src-while-running-script-in-frame.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/select-selectedIndex.html :  different length
+/sdcard/android/layout_tests/fast/dom/open-and-close-by-DOM.html :  different length
+/sdcard/android/layout_tests/fast/dom/onerror-img.html :  different length
+/sdcard/android/layout_tests/fast/dom/object-plugin-hides-properties.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/object-embed-plugin-scripting.html :  different length
+/sdcard/android/layout_tests/fast/dom/null-document-window-open-crash.html :  different length
+/sdcard/android/layout_tests/fast/dom/null-document-location-replace-crash.html :  different length
+/sdcard/android/layout_tests/fast/dom/null-document-location-put-crash.html :  different length
+/sdcard/android/layout_tests/fast/dom/null-document-location-href-put-crash.html :  different length
+/sdcard/android/layout_tests/fast/dom/null-document-location-assign-crash.html :  different length
+/sdcard/android/layout_tests/fast/dom/null-chardata-crash.html :  different length
+/sdcard/android/layout_tests/fast/dom/noscript-style.html :  different length
+/sdcard/android/layout_tests/fast/dom/noscript-canvas-in-created-html-document.html :  different length
+/sdcard/android/layout_tests/fast/dom/non-numeric-values-numeric-parameters.html :  different length
+/sdcard/android/layout_tests/fast/dom/node-item.html :  different length
+/sdcard/android/layout_tests/fast/dom/node-filter-gc.html :   @offset: 1
+/sdcard/android/layout_tests/fast/dom/no-elements.html :  different length
+/sdcard/android/layout_tests/fast/dom/navigator-vendorSub.html :  different length
+/sdcard/android/layout_tests/fast/dom/namespaces-1.html :  different length
+/sdcard/android/layout_tests/fast/dom/NamedNodeMap-setNamedItem-crash.html :  different length
+/sdcard/android/layout_tests/fast/dom/namednodemap-namelookup.html :  different length
+/sdcard/android/layout_tests/fast/dom/mutation-event-remove-inserted-node.html :  different length
+/sdcard/android/layout_tests/fast/dom/location-hash.html :  different length
+/sdcard/android/layout_tests/fast/dom/length-attribute-mapping.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/javascript-url-crash-function.html :  different length
+/sdcard/android/layout_tests/fast/dom/inner-text-001.html :  different length
+/sdcard/android/layout_tests/fast/dom/global-constructors.html :  different length
+/sdcard/android/layout_tests/fast/dom/gc-acid3.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/gc-9.html :  different length
+/sdcard/android/layout_tests/fast/dom/gc-8.html :  different length
+/sdcard/android/layout_tests/fast/dom/frame-loading-via-document-write.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/dom/documenturi-not-affected-by-base-tag.html :  different length
+/sdcard/android/layout_tests/fast/dom/documenturi-can-hold-arbitrary-string.html :  different length
+/sdcard/android/layout_tests/fast/dom/document-width-height-force-layout.html :   @offset: 142
+/sdcard/android/layout_tests/fast/dom/constructors-cached.html :  different length
+/sdcard/android/layout_tests/fast/dom/constructors-cached-navigate.html :  different length
+/sdcard/android/layout_tests/fast/dom/client-width-height.html :   @offset: 119
+/sdcard/android/layout_tests/fast/dom/client-width-height-quirks.html :   @offset: 115
+/sdcard/android/layout_tests/fast/dom/assign-to-window-status.html :  different length
+/sdcard/android/layout_tests/fast/css/variables/color-hex-test.html :  different length
+/sdcard/android/layout_tests/fast/css/html-attr-case-sensitivity.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/css/hover-affects-child.html :  different length
+/sdcard/android/layout_tests/fast/css/getComputedStyle-transform.html :  different length
+/sdcard/android/layout_tests/fast/css/dashboard-region-parser.html :  different length
+/sdcard/android/layout_tests/fast/css/computed-style.html :  different length
+/sdcard/android/layout_tests/fast/css/computed-style-without-renderer.html :  different length
+/sdcard/android/layout_tests/fast/canvas/toDataURL-supportedTypes.html :  different length
+/sdcard/android/layout_tests/fast/canvas/canvas-save-restore-with-path.html :  different length
+/sdcard/android/layout_tests/fast/canvas/canvas-longlived-context.html : TIMEDOUT
+/sdcard/android/layout_tests/fast/canvas/canvas-getImageData.html :  different length
+/sdcard/android/layout_tests/fast/canvas/canvas-alphaImageData-behavior.html :  different length
diff --git a/tests/DumpRenderTree/results/layout_tests_nontext.txt b/tests/DumpRenderTree/results/layout_tests_nontext.txt
new file mode 100644
index 0000000..0355cb72
--- /dev/null
+++ b/tests/DumpRenderTree/results/layout_tests_nontext.txt
@@ -0,0 +1,1658 @@
+/sdcard/android/layout_tests/fast/transforms/transforms-with-opacity.html
+/sdcard/android/layout_tests/fast/transforms/transform-positioned-ancestor.html
+/sdcard/android/layout_tests/fast/transforms/transform-overflow.html
+/sdcard/android/layout_tests/fast/transforms/skew-with-unitless-zero.html
+/sdcard/android/layout_tests/fast/transforms/shadows.html
+/sdcard/android/layout_tests/fast/transforms/overflow-with-transform.html
+/sdcard/android/layout_tests/fast/transforms/matrix-02.html
+/sdcard/android/layout_tests/fast/transforms/matrix-01.html
+/sdcard/android/layout_tests/fast/transforms/identity-matrix.html
+/sdcard/android/layout_tests/fast/transforms/diamond.html
+/sdcard/android/layout_tests/fast/tokenizer/script_extra_close.html
+/sdcard/android/layout_tests/fast/tokenizer/script-after-frameset.html
+/sdcard/android/layout_tests/fast/tokenizer/missing-title-end-tag-2.html
+/sdcard/android/layout_tests/fast/tokenizer/missing-title-end-tag-1.html
+/sdcard/android/layout_tests/fast/tokenizer/missing-style-end-tag-2.html
+/sdcard/android/layout_tests/fast/tokenizer/missing-style-end-tag-1.html
+/sdcard/android/layout_tests/fast/tokenizer/external-script-document-write_2.html
+/sdcard/android/layout_tests/fast/tokenizer/external-script-document-write.html
+/sdcard/android/layout_tests/fast/tokenizer/003.html
+/sdcard/android/layout_tests/fast/tokenizer/002.html
+/sdcard/android/layout_tests/fast/tokenizer/001.html
+/sdcard/android/layout_tests/fast/text/whitespace/tab-character-basics.html
+/sdcard/android/layout_tests/fast/text/whitespace/span-in-word-space-causes-overflow.html
+/sdcard/android/layout_tests/fast/text/whitespace/pre-wrap-spaces-after-newline.html
+/sdcard/android/layout_tests/fast/text/whitespace/pre-wrap-overflow-selection.html
+/sdcard/android/layout_tests/fast/text/whitespace/pre-wrap-line-test.html
+/sdcard/android/layout_tests/fast/text/whitespace/pre-wrap-last-char.html
+/sdcard/android/layout_tests/fast/text/whitespace/pre-newline-box-test.html
+/sdcard/android/layout_tests/fast/text/whitespace/pre-break-word.html
+/sdcard/android/layout_tests/fast/text/whitespace/nowrap-clear-float.html
+/sdcard/android/layout_tests/fast/text/whitespace/normal-after-nowrap-breaking.html
+/sdcard/android/layout_tests/fast/text/whitespace/nbsp-mode-and-linewraps.html
+/sdcard/android/layout_tests/fast/text/whitespace/030.html
+/sdcard/android/layout_tests/fast/text/whitespace/029.html
+/sdcard/android/layout_tests/fast/text/whitespace/028.html
+/sdcard/android/layout_tests/fast/text/whitespace/027.html
+/sdcard/android/layout_tests/fast/text/whitespace/026.html
+/sdcard/android/layout_tests/fast/text/whitespace/025.html
+/sdcard/android/layout_tests/fast/text/whitespace/024.html
+/sdcard/android/layout_tests/fast/text/whitespace/023.html
+/sdcard/android/layout_tests/fast/text/whitespace/022.html
+/sdcard/android/layout_tests/fast/text/whitespace/021.html
+/sdcard/android/layout_tests/fast/text/whitespace/020.html
+/sdcard/android/layout_tests/fast/text/whitespace/019.html
+/sdcard/android/layout_tests/fast/text/whitespace/018.html
+/sdcard/android/layout_tests/fast/text/whitespace/017.html
+/sdcard/android/layout_tests/fast/text/whitespace/016.html
+/sdcard/android/layout_tests/fast/text/whitespace/015.html
+/sdcard/android/layout_tests/fast/text/whitespace/014.html
+/sdcard/android/layout_tests/fast/text/whitespace/013.html
+/sdcard/android/layout_tests/fast/text/whitespace/012.html
+/sdcard/android/layout_tests/fast/text/whitespace/011.html
+/sdcard/android/layout_tests/fast/text/whitespace/010.html
+/sdcard/android/layout_tests/fast/text/whitespace/009.html
+/sdcard/android/layout_tests/fast/text/whitespace/008.html
+/sdcard/android/layout_tests/fast/text/whitespace/007.html
+/sdcard/android/layout_tests/fast/text/whitespace/006.html
+/sdcard/android/layout_tests/fast/text/whitespace/005.html
+/sdcard/android/layout_tests/fast/text/whitespace/004.html
+/sdcard/android/layout_tests/fast/text/whitespace/003.html
+/sdcard/android/layout_tests/fast/text/whitespace/002.html
+/sdcard/android/layout_tests/fast/text/whitespace/001.html
+/sdcard/android/layout_tests/fast/text/international/wrap-CJK-001.html
+/sdcard/android/layout_tests/fast/text/international/thai-line-breaks.html
+/sdcard/android/layout_tests/fast/text/international/rtl-white-space-pre-wrap.html
+/sdcard/android/layout_tests/fast/text/international/rtl-caret.html
+/sdcard/android/layout_tests/fast/text/international/hindi-spacing.html
+/sdcard/android/layout_tests/fast/text/international/complex-character-based-fallback.html
+/sdcard/android/layout_tests/fast/text/international/bidi-override.html
+/sdcard/android/layout_tests/fast/text/international/bidi-neutral-run.html
+/sdcard/android/layout_tests/fast/text/international/bidi-neutral-directionality-paragraph-start.html
+/sdcard/android/layout_tests/fast/text/international/bidi-menulist.html
+/sdcard/android/layout_tests/fast/text/international/bidi-listbox.html
+/sdcard/android/layout_tests/fast/text/international/bidi-listbox-atsui.html
+/sdcard/android/layout_tests/fast/text/international/bidi-LDB-2-HTML.html
+/sdcard/android/layout_tests/fast/text/international/bidi-LDB-2-formatting-characters.html
+/sdcard/android/layout_tests/fast/text/international/bidi-LDB-2-CSS.html
+/sdcard/android/layout_tests/fast/text/international/bidi-layout-across-linebreak.html
+/sdcard/android/layout_tests/fast/text/international/bidi-L2-run-reordering.html
+/sdcard/android/layout_tests/fast/text/international/bidi-innertext.html
+/sdcard/android/layout_tests/fast/text/international/bidi-ignored-for-first-child-inline.html
+/sdcard/android/layout_tests/fast/text/international/bidi-explicit-embedding.html
+/sdcard/android/layout_tests/fast/text/international/bidi-european-terminators.html
+/sdcard/android/layout_tests/fast/text/international/bidi-CS-after-AN.html
+/sdcard/android/layout_tests/fast/text/international/bidi-control-chars-treated-as-ZWS.html
+/sdcard/android/layout_tests/fast/text/international/bidi-AN-after-L.html
+/sdcard/android/layout_tests/fast/text/international/bidi-AN-after-empty-run.html
+/sdcard/android/layout_tests/fast/text/international/003.html
+/sdcard/android/layout_tests/fast/text/international/002.html
+/sdcard/android/layout_tests/fast/text/international/001.html
+/sdcard/android/layout_tests/fast/text/firstline/003.html
+/sdcard/android/layout_tests/fast/text/firstline/002.html
+/sdcard/android/layout_tests/fast/text/firstline/001.html
+/sdcard/android/layout_tests/fast/text/basic/generic-family-reset.html
+/sdcard/android/layout_tests/fast/text/basic/generic-family-changes.html
+/sdcard/android/layout_tests/fast/text/basic/015.html
+/sdcard/android/layout_tests/fast/text/basic/014.html
+/sdcard/android/layout_tests/fast/text/basic/013.html
+/sdcard/android/layout_tests/fast/text/basic/012.html
+/sdcard/android/layout_tests/fast/text/basic/011.html
+/sdcard/android/layout_tests/fast/text/basic/009.html
+/sdcard/android/layout_tests/fast/text/basic/008.html
+/sdcard/android/layout_tests/fast/text/basic/007.html
+/sdcard/android/layout_tests/fast/text/basic/006.html
+/sdcard/android/layout_tests/fast/text/basic/005.html
+/sdcard/android/layout_tests/fast/text/basic/004.html
+/sdcard/android/layout_tests/fast/text/basic/003.html
+/sdcard/android/layout_tests/fast/text/basic/002.html
+/sdcard/android/layout_tests/fast/text/basic/001.html
+/sdcard/android/layout_tests/fast/text/word-space.html
+/sdcard/android/layout_tests/fast/text/word-break.html
+/sdcard/android/layout_tests/fast/text/word-break-soft-hyphen.html
+/sdcard/android/layout_tests/fast/text/word-break-run-rounding.html
+/sdcard/android/layout_tests/fast/text/wide-zero-width-space.html
+/sdcard/android/layout_tests/fast/text/wbr.html
+/sdcard/android/layout_tests/fast/text/wbr-styled.html
+/sdcard/android/layout_tests/fast/text/wbr-pre.html
+/sdcard/android/layout_tests/fast/text/wbr-in-pre-crash.html
+/sdcard/android/layout_tests/fast/text/updateNewFont.html
+/sdcard/android/layout_tests/fast/text/trailing-white-space.html
+/sdcard/android/layout_tests/fast/text/trailing-white-space-2.html
+/sdcard/android/layout_tests/fast/text/textIteratorNilRenderer.html
+/sdcard/android/layout_tests/fast/text/stroking.html
+/sdcard/android/layout_tests/fast/text/stroking-decorations.html
+/sdcard/android/layout_tests/fast/text/stripNullFromText.html
+/sdcard/android/layout_tests/fast/text/softHyphen.html
+/sdcard/android/layout_tests/fast/text/soft-hyphen-3.html
+/sdcard/android/layout_tests/fast/text/soft-hyphen-2.html
+/sdcard/android/layout_tests/fast/text/should-use-atsui.html
+/sdcard/android/layout_tests/fast/text/shadow-no-blur.html
+/sdcard/android/layout_tests/fast/text/selection-painted-separately.html
+/sdcard/android/layout_tests/fast/text/selection-hard-linebreak.html
+/sdcard/android/layout_tests/fast/text/reset-emptyRun.html
+/sdcard/android/layout_tests/fast/text/monospace-width-cache.html
+/sdcard/android/layout_tests/fast/text/midword-break-hang.html
+/sdcard/android/layout_tests/fast/text/midword-break-after-breakable-char.html
+/sdcard/android/layout_tests/fast/text/line-breaks.html
+/sdcard/android/layout_tests/fast/text/line-breaks-after-white-space.html
+/sdcard/android/layout_tests/fast/text/letter-spacing-negative-opacity.html
+/sdcard/android/layout_tests/fast/text/large-text-composed-char.html
+/sdcard/android/layout_tests/fast/text/justified-selection.html
+/sdcard/android/layout_tests/fast/text/justified-selection-at-edge.html
+/sdcard/android/layout_tests/fast/text/in-rendered-text-rtl.html
+/sdcard/android/layout_tests/fast/text/font-initial.html
+/sdcard/android/layout_tests/fast/text/fixed-pitch-control-characters.html
+/sdcard/android/layout_tests/fast/text/embed-at-end-of-pre-wrap-line.html
+/sdcard/android/layout_tests/fast/text/drawBidiText.html
+/sdcard/android/layout_tests/fast/text/delete-hard-break-character.html
+/sdcard/android/layout_tests/fast/text/cg-vs-atsui.html
+/sdcard/android/layout_tests/fast/text/cg-fallback-bolding.html
+/sdcard/android/layout_tests/fast/text/capitalize-preserve-nbsp.html
+/sdcard/android/layout_tests/fast/text/capitalize-empty-generated-string.html
+/sdcard/android/layout_tests/fast/text/capitalize-boundaries.html
+/sdcard/android/layout_tests/fast/text/break-word.html
+/sdcard/android/layout_tests/fast/text/bidi-embedding-pop-and-push-same.html
+/sdcard/android/layout_tests/fast/text/atsui-spacing-features.html
+/sdcard/android/layout_tests/fast/text/atsui-small-caps-punctuation-size.html
+/sdcard/android/layout_tests/fast/text/atsui-rtl-override-selection.html
+/sdcard/android/layout_tests/fast/text/atsui-pointtooffset-calls-cg.html
+/sdcard/android/layout_tests/fast/text/atsui-partial-selection.html
+/sdcard/android/layout_tests/fast/text/atsui-multiple-renderers.html
+/sdcard/android/layout_tests/fast/text/atsui-kerning-and-ligatures.html
+/sdcard/android/layout_tests/fast/text/apply-start-width-after-skipped-text.html
+/sdcard/android/layout_tests/fast/text/align-center-rtl-spill.html
+/sdcard/android/layout_tests/fast/table/border-collapsing/rtl-border-collapsing.html
+/sdcard/android/layout_tests/fast/table/border-collapsing/equal-precedence-resolution.html
+/sdcard/android/layout_tests/fast/table/border-collapsing/border-collapsing-head-foot.html
+/sdcard/android/layout_tests/fast/table/border-collapsing/004.html
+/sdcard/android/layout_tests/fast/table/border-collapsing/003.html
+/sdcard/android/layout_tests/fast/table/border-collapsing/002.html
+/sdcard/android/layout_tests/fast/table/border-collapsing/001.html
+/sdcard/android/layout_tests/fast/table/wide-column.html
+/sdcard/android/layout_tests/fast/table/wide-colspan.html
+/sdcard/android/layout_tests/fast/table/vertical-align-baseline.html
+/sdcard/android/layout_tests/fast/table/vertical-align-baseline-readjust.html
+/sdcard/android/layout_tests/fast/table/unused-percent-heights.html
+/sdcard/android/layout_tests/fast/table/unbreakable-images-quirk.html
+/sdcard/android/layout_tests/fast/table/text-field-baseline.html
+/sdcard/android/layout_tests/fast/table/tableInsideCaption.html
+/sdcard/android/layout_tests/fast/table/table-hspace-align-center.html
+/sdcard/android/layout_tests/fast/table/table-display-types.html
+/sdcard/android/layout_tests/fast/table/table-display-types-strict.html
+/sdcard/android/layout_tests/fast/table/stale-grid-crash.html
+/sdcard/android/layout_tests/fast/table/spanOverlapRepaint.html
+/sdcard/android/layout_tests/fast/table/rules-attr-dynchange2.html
+/sdcard/android/layout_tests/fast/table/rules-attr-dynchange1.html
+/sdcard/android/layout_tests/fast/table/rtl-cell-display-none-assert.html
+/sdcard/android/layout_tests/fast/table/rowspan-paint-order.html
+/sdcard/android/layout_tests/fast/table/rowindex.html
+/sdcard/android/layout_tests/fast/table/row-height-recalc.html
+/sdcard/android/layout_tests/fast/table/replaced-percent-height.html
+/sdcard/android/layout_tests/fast/table/remove-td-display-none.html
+/sdcard/android/layout_tests/fast/table/prepend-in-anonymous-table.html
+/sdcard/android/layout_tests/fast/table/percent-widths-stretch.html
+/sdcard/android/layout_tests/fast/table/percent-heights.html
+/sdcard/android/layout_tests/fast/table/overflowHidden.html
+/sdcard/android/layout_tests/fast/table/nobr.html
+/sdcard/android/layout_tests/fast/table/nested-percent-height-table.html
+/sdcard/android/layout_tests/fast/table/multiple-percent-height-rows.html
+/sdcard/android/layout_tests/fast/table/max-width-integer-overflow.html
+/sdcard/android/layout_tests/fast/table/large-width.html
+/sdcard/android/layout_tests/fast/table/invisible-cell-background.html
+/sdcard/android/layout_tests/fast/table/insert-row-before-form.html
+/sdcard/android/layout_tests/fast/table/insert-cell-before-form.html
+/sdcard/android/layout_tests/fast/table/insert-before-anonymous-ancestors.html
+/sdcard/android/layout_tests/fast/table/inline-form-assert.html
+/sdcard/android/layout_tests/fast/table/height-percent-test.html
+/sdcard/android/layout_tests/fast/table/growCellForImageQuirk.html
+/sdcard/android/layout_tests/fast/table/giantRowspan2.html
+/sdcard/android/layout_tests/fast/table/giantRowspan.html
+/sdcard/android/layout_tests/fast/table/giantCellspacing.html
+/sdcard/android/layout_tests/fast/table/generated-caption.html
+/sdcard/android/layout_tests/fast/table/frame-and-rules.html
+/sdcard/android/layout_tests/fast/table/form-with-table-style.html
+/sdcard/android/layout_tests/fast/table/floating-th.html
+/sdcard/android/layout_tests/fast/table/fixed-with-auto-with-colspan.html
+/sdcard/android/layout_tests/fast/table/fixed-table-non-cell-in-row.html
+/sdcard/android/layout_tests/fast/table/fixed-nested.html
+/sdcard/android/layout_tests/fast/table/empty-table-percent-height.html
+/sdcard/android/layout_tests/fast/table/empty-section-crash.html
+/sdcard/android/layout_tests/fast/table/empty-row-crash.html
+/sdcard/android/layout_tests/fast/table/empty-cells.html
+/sdcard/android/layout_tests/fast/table/edge-offsets.html
+/sdcard/android/layout_tests/fast/table/dynamic-cellpadding.html
+/sdcard/android/layout_tests/fast/table/div-as-col-span.html
+/sdcard/android/layout_tests/fast/table/colgroup-spanning-groups-rules.html
+/sdcard/android/layout_tests/fast/table/colgroup-preceded-by-caption.html
+/sdcard/android/layout_tests/fast/table/click-near-anonymous-table.html
+/sdcard/android/layout_tests/fast/table/cellindex.html
+/sdcard/android/layout_tests/fast/table/cell-pref-width-invalidation.html
+/sdcard/android/layout_tests/fast/table/cell-width-auto.html
+/sdcard/android/layout_tests/fast/table/cell-absolute-child.html
+/sdcard/android/layout_tests/fast/table/caption-relayout.html
+/sdcard/android/layout_tests/fast/table/auto-with-percent-height.html
+/sdcard/android/layout_tests/fast/table/append-cells2.html
+/sdcard/android/layout_tests/fast/table/append-cells.html
+/sdcard/android/layout_tests/fast/table/add-before-anonymous-child.html
+/sdcard/android/layout_tests/fast/table/absolute-table-at-bottom.html
+/sdcard/android/layout_tests/fast/table/100-percent-cell-width.html
+/sdcard/android/layout_tests/fast/table/041.html
+/sdcard/android/layout_tests/fast/table/040.html
+/sdcard/android/layout_tests/fast/table/039.html
+/sdcard/android/layout_tests/fast/table/038.html
+/sdcard/android/layout_tests/fast/table/037.xml
+/sdcard/android/layout_tests/fast/table/036.html
+/sdcard/android/layout_tests/fast/table/035.html
+/sdcard/android/layout_tests/fast/table/034.html
+/sdcard/android/layout_tests/fast/table/033.html
+/sdcard/android/layout_tests/fast/table/032.html
+/sdcard/android/layout_tests/fast/table/031.html
+/sdcard/android/layout_tests/fast/table/030.html
+/sdcard/android/layout_tests/fast/table/029.html
+/sdcard/android/layout_tests/fast/table/028.html
+/sdcard/android/layout_tests/fast/table/027.html
+/sdcard/android/layout_tests/fast/table/026.html
+/sdcard/android/layout_tests/fast/table/025.html
+/sdcard/android/layout_tests/fast/table/024.html
+/sdcard/android/layout_tests/fast/table/023.html
+/sdcard/android/layout_tests/fast/table/022.html
+/sdcard/android/layout_tests/fast/table/021.html
+/sdcard/android/layout_tests/fast/table/020.html
+/sdcard/android/layout_tests/fast/table/018.html
+/sdcard/android/layout_tests/fast/table/017.html
+/sdcard/android/layout_tests/fast/table/016.html
+/sdcard/android/layout_tests/fast/table/015.html
+/sdcard/android/layout_tests/fast/table/014.html
+/sdcard/android/layout_tests/fast/table/013.html
+/sdcard/android/layout_tests/fast/table/012.html
+/sdcard/android/layout_tests/fast/table/011.html
+/sdcard/android/layout_tests/fast/table/010.html
+/sdcard/android/layout_tests/fast/table/009.html
+/sdcard/android/layout_tests/fast/table/008.html
+/sdcard/android/layout_tests/fast/table/007.html
+/sdcard/android/layout_tests/fast/table/006.html
+/sdcard/android/layout_tests/fast/table/005.html
+/sdcard/android/layout_tests/fast/table/004.html
+/sdcard/android/layout_tests/fast/table/003.html
+/sdcard/android/layout_tests/fast/table/002.html
+/sdcard/android/layout_tests/fast/table/001.html
+/sdcard/android/layout_tests/fast/selectors/unqualified-hover-strict.html
+/sdcard/android/layout_tests/fast/selectors/unqualified-hover-quirks.html
+/sdcard/android/layout_tests/fast/selectors/nondeterministic-combinators.html
+/sdcard/android/layout_tests/fast/selectors/lang-vs-xml-lang.html
+/sdcard/android/layout_tests/fast/selectors/lang-inheritance2.html
+/sdcard/android/layout_tests/fast/selectors/lang-inheritance.html
+/sdcard/android/layout_tests/fast/selectors/177b.html
+/sdcard/android/layout_tests/fast/selectors/177a.html
+/sdcard/android/layout_tests/fast/selectors/175c.html
+/sdcard/android/layout_tests/fast/selectors/175b.html
+/sdcard/android/layout_tests/fast/selectors/175a.html
+/sdcard/android/layout_tests/fast/selectors/170d.html
+/sdcard/android/layout_tests/fast/selectors/170c.html
+/sdcard/android/layout_tests/fast/selectors/170b.html
+/sdcard/android/layout_tests/fast/selectors/170a.html
+/sdcard/android/layout_tests/fast/selectors/170.html
+/sdcard/android/layout_tests/fast/selectors/169a.html
+/sdcard/android/layout_tests/fast/selectors/169.html
+/sdcard/android/layout_tests/fast/selectors/168a.html
+/sdcard/android/layout_tests/fast/selectors/168.html
+/sdcard/android/layout_tests/fast/selectors/167a.html
+/sdcard/android/layout_tests/fast/selectors/167.html
+/sdcard/android/layout_tests/fast/selectors/166a.html
+/sdcard/android/layout_tests/fast/selectors/166.html
+/sdcard/android/layout_tests/fast/selectors/160.html
+/sdcard/android/layout_tests/fast/selectors/159.html
+/sdcard/android/layout_tests/fast/selectors/158.html
+/sdcard/android/layout_tests/fast/selectors/157.html
+/sdcard/android/layout_tests/fast/selectors/156b.html
+/sdcard/android/layout_tests/fast/selectors/155d.html
+/sdcard/android/layout_tests/fast/selectors/155c.html
+/sdcard/android/layout_tests/fast/selectors/155b.html
+/sdcard/android/layout_tests/fast/selectors/155a.html
+/sdcard/android/layout_tests/fast/selectors/155.html
+/sdcard/android/layout_tests/fast/selectors/154.html
+/sdcard/android/layout_tests/fast/selectors/090b.html
+/sdcard/android/layout_tests/fast/selectors/089.html
+/sdcard/android/layout_tests/fast/selectors/088b.html
+/sdcard/android/layout_tests/fast/selectors/087b.html
+/sdcard/android/layout_tests/fast/selectors/083.html
+/sdcard/android/layout_tests/fast/selectors/078b.html
+/sdcard/android/layout_tests/fast/selectors/077b.html
+/sdcard/android/layout_tests/fast/selectors/077.html
+/sdcard/android/layout_tests/fast/selectors/072b.html
+/sdcard/android/layout_tests/fast/selectors/072.html
+/sdcard/android/layout_tests/fast/selectors/066b.html
+/sdcard/android/layout_tests/fast/selectors/066.html
+/sdcard/android/layout_tests/fast/selectors/065.html
+/sdcard/android/layout_tests/fast/selectors/064.html
+/sdcard/android/layout_tests/fast/selectors/063.html
+/sdcard/android/layout_tests/fast/selectors/062.html
+/sdcard/android/layout_tests/fast/selectors/061.html
+/sdcard/android/layout_tests/fast/selectors/060.html
+/sdcard/android/layout_tests/fast/selectors/059.html
+/sdcard/android/layout_tests/fast/selectors/058.html
+/sdcard/android/layout_tests/fast/selectors/056.html
+/sdcard/android/layout_tests/fast/selectors/054.html
+/sdcard/android/layout_tests/fast/selectors/046.html
+/sdcard/android/layout_tests/fast/selectors/045c.html
+/sdcard/android/layout_tests/fast/selectors/045b.html
+/sdcard/android/layout_tests/fast/selectors/045.html
+/sdcard/android/layout_tests/fast/selectors/044d.html
+/sdcard/android/layout_tests/fast/selectors/044c.html
+/sdcard/android/layout_tests/fast/selectors/044b.html
+/sdcard/android/layout_tests/fast/selectors/044.html
+/sdcard/android/layout_tests/fast/selectors/043b.html
+/sdcard/android/layout_tests/fast/selectors/043.html
+/sdcard/android/layout_tests/fast/selectors/042.html
+/sdcard/android/layout_tests/fast/selectors/041.html
+/sdcard/android/layout_tests/fast/selectors/040.html
+/sdcard/android/layout_tests/fast/selectors/039b.html
+/sdcard/android/layout_tests/fast/selectors/039.html
+/sdcard/android/layout_tests/fast/selectors/038.html
+/sdcard/android/layout_tests/fast/selectors/034.html
+/sdcard/android/layout_tests/fast/selectors/032.html
+/sdcard/android/layout_tests/fast/selectors/027.html
+/sdcard/android/layout_tests/fast/selectors/021b.html
+/sdcard/android/layout_tests/fast/selectors/021.html
+/sdcard/android/layout_tests/fast/selectors/020.html
+/sdcard/android/layout_tests/fast/selectors/019.html
+/sdcard/android/layout_tests/fast/selectors/018b.html
+/sdcard/android/layout_tests/fast/selectors/018.html
+/sdcard/android/layout_tests/fast/selectors/017.html
+/sdcard/android/layout_tests/fast/selectors/016.html
+/sdcard/android/layout_tests/fast/selectors/015.html
+/sdcard/android/layout_tests/fast/selectors/014.html
+/sdcard/android/layout_tests/fast/selectors/013.html
+/sdcard/android/layout_tests/fast/selectors/012.html
+/sdcard/android/layout_tests/fast/selectors/011.html
+/sdcard/android/layout_tests/fast/selectors/010.html
+/sdcard/android/layout_tests/fast/selectors/009.html
+/sdcard/android/layout_tests/fast/selectors/008.html
+/sdcard/android/layout_tests/fast/selectors/007b.html
+/sdcard/android/layout_tests/fast/selectors/007a.html
+/sdcard/android/layout_tests/fast/selectors/006.html
+/sdcard/android/layout_tests/fast/selectors/005.html
+/sdcard/android/layout_tests/fast/selectors/004.html
+/sdcard/android/layout_tests/fast/selectors/003.html
+/sdcard/android/layout_tests/fast/selectors/002.html
+/sdcard/android/layout_tests/fast/selectors/001.html
+/sdcard/android/layout_tests/fast/runin/001.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-textfield.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-textarea.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-searchfield.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-radio.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-menulist.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-image.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-checkbox.html
+/sdcard/android/layout_tests/fast/replaced/width100percent-button.html
+/sdcard/android/layout_tests/fast/replaced/three-selects-break.html
+/sdcard/android/layout_tests/fast/replaced/selection-rect.html
+/sdcard/android/layout_tests/fast/replaced/selection-rect-in-table-cell.html
+/sdcard/android/layout_tests/fast/replaced/replaced-child-of-absolute-with-auto-height.html
+/sdcard/android/layout_tests/fast/replaced/replaced-breaking.html
+/sdcard/android/layout_tests/fast/replaced/replaced-breaking-mixture.html
+/sdcard/android/layout_tests/fast/replaced/percent-height-in-anonymous-block.html
+/sdcard/android/layout_tests/fast/replaced/percent-height-in-anonymous-block-widget.html
+/sdcard/android/layout_tests/fast/replaced/pdf-as-image.html
+/sdcard/android/layout_tests/fast/replaced/object-align-hspace-vspace.html
+/sdcard/android/layout_tests/fast/replaced/minwidth-pxs.html
+/sdcard/android/layout_tests/fast/replaced/minwidth-percent.html
+/sdcard/android/layout_tests/fast/replaced/minheight-pxs.html
+/sdcard/android/layout_tests/fast/replaced/minheight-percent.html
+/sdcard/android/layout_tests/fast/replaced/maxwidth-pxs.html
+/sdcard/android/layout_tests/fast/replaced/maxwidth-percent.html
+/sdcard/android/layout_tests/fast/replaced/maxheight-pxs.html
+/sdcard/android/layout_tests/fast/replaced/maxheight-percent.html
+/sdcard/android/layout_tests/fast/replaced/max-width-percent.html
+/sdcard/android/layout_tests/fast/replaced/inline-box-wrapper-handover.html
+/sdcard/android/layout_tests/fast/replaced/image-tag.html
+/sdcard/android/layout_tests/fast/replaced/image-solid-color-with-alpha.html
+/sdcard/android/layout_tests/fast/replaced/image-sizing.html
+/sdcard/android/layout_tests/fast/replaced/image-resize-width.html
+/sdcard/android/layout_tests/fast/replaced/image-onload.html
+/sdcard/android/layout_tests/fast/replaced/applet-rendering-java-disabled.html
+/sdcard/android/layout_tests/fast/replaced/applet-disabled-positioned.html
+/sdcard/android/layout_tests/fast/replaced/absolute-position-with-auto-width-and-left-and-right.html
+/sdcard/android/layout_tests/fast/replaced/absolute-position-with-auto-height-and-top-and-bottom.html
+/sdcard/android/layout_tests/fast/replaced/absolute-position-percentage-width.html
+/sdcard/android/layout_tests/fast/replaced/absolute-position-percentage-height.html
+/sdcard/android/layout_tests/fast/replaced/absolute-image-sizing.html
+/sdcard/android/layout_tests/fast/replaced/008.html
+/sdcard/android/layout_tests/fast/replaced/007.html
+/sdcard/android/layout_tests/fast/replaced/006.html
+/sdcard/android/layout_tests/fast/replaced/005.html
+/sdcard/android/layout_tests/fast/replaced/004.html
+/sdcard/android/layout_tests/fast/replaced/003.html
+/sdcard/android/layout_tests/fast/replaced/002.html
+/sdcard/android/layout_tests/fast/replaced/001.html
+/sdcard/android/layout_tests/fast/repaint/transform-translate.html
+/sdcard/android/layout_tests/fast/repaint/text-shadow.html
+/sdcard/android/layout_tests/fast/repaint/text-shadow-horizontal.html
+/sdcard/android/layout_tests/fast/repaint/text-selection-rect-in-overflow.html
+/sdcard/android/layout_tests/fast/repaint/text-selection-rect-in-overflow-2.html
+/sdcard/android/layout_tests/fast/repaint/table-two-pass-layout-overpaint.html
+/sdcard/android/layout_tests/fast/repaint/table-section-repaint.html
+/sdcard/android/layout_tests/fast/repaint/table-section-overflow.html
+/sdcard/android/layout_tests/fast/repaint/table-row.html
+/sdcard/android/layout_tests/fast/repaint/table-outer-border.html
+/sdcard/android/layout_tests/fast/repaint/table-extra-bottom-grow.html
+/sdcard/android/layout_tests/fast/repaint/table-collapsed-border.html
+/sdcard/android/layout_tests/fast/repaint/table-col-background.html
+/sdcard/android/layout_tests/fast/repaint/table-cell-vertical-overflow.html
+/sdcard/android/layout_tests/fast/repaint/table-cell-move.html
+/sdcard/android/layout_tests/fast/repaint/table-cell-collapsed-border.html
+/sdcard/android/layout_tests/fast/repaint/subtree-root-skipped.html
+/sdcard/android/layout_tests/fast/repaint/subtree-root-clip.html
+/sdcard/android/layout_tests/fast/repaint/subtree-root-clip-3.html
+/sdcard/android/layout_tests/fast/repaint/subtree-root-clip-2.html
+/sdcard/android/layout_tests/fast/repaint/static-to-positioned.html
+/sdcard/android/layout_tests/fast/repaint/shadow-multiple-vertical.html
+/sdcard/android/layout_tests/fast/repaint/shadow-multiple-strict-vertical.html
+/sdcard/android/layout_tests/fast/repaint/shadow-multiple-strict-horizontal.html
+/sdcard/android/layout_tests/fast/repaint/shadow-multiple-horizontal.html
+/sdcard/android/layout_tests/fast/repaint/selection-gap-overflow-scroll.html
+/sdcard/android/layout_tests/fast/repaint/selection-after-remove.html
+/sdcard/android/layout_tests/fast/repaint/selection-after-delete.html
+/sdcard/android/layout_tests/fast/repaint/repaint-resized-overflow.html
+/sdcard/android/layout_tests/fast/repaint/renderer-destruction-by-invalidateSelection-crash.html
+/sdcard/android/layout_tests/fast/repaint/overflow-scroll-delete.html
+/sdcard/android/layout_tests/fast/repaint/overflow-outline-repaint.html
+/sdcard/android/layout_tests/fast/repaint/overflow-into-content.html
+/sdcard/android/layout_tests/fast/repaint/overflow-delete-line.html
+/sdcard/android/layout_tests/fast/repaint/overflow-clip-subtree-layout.html
+/sdcard/android/layout_tests/fast/repaint/outline-shrinking.html
+/sdcard/android/layout_tests/fast/repaint/outline-repaint-glitch.html
+/sdcard/android/layout_tests/fast/repaint/outline-inset.html
+/sdcard/android/layout_tests/fast/repaint/make-children-non-inline.html
+/sdcard/android/layout_tests/fast/repaint/list-marker.html
+/sdcard/android/layout_tests/fast/repaint/list-marker-2.html
+/sdcard/android/layout_tests/fast/repaint/lines-with-layout-delta.html
+/sdcard/android/layout_tests/fast/repaint/line-overflow.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-9.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-8.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-7.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-6.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-5.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-4.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-3.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-2.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-10.html
+/sdcard/android/layout_tests/fast/repaint/line-flow-with-floats-1.html
+/sdcard/android/layout_tests/fast/repaint/layout-state-relative.html
+/sdcard/android/layout_tests/fast/repaint/layout-state-only-positioned.html
+/sdcard/android/layout_tests/fast/repaint/layer-visibility.html
+/sdcard/android/layout_tests/fast/repaint/layer-outline.html
+/sdcard/android/layout_tests/fast/repaint/layer-outline-horizontal.html
+/sdcard/android/layout_tests/fast/repaint/layer-hide-when-needs-layout.html
+/sdcard/android/layout_tests/fast/repaint/layer-full-repaint.html
+/sdcard/android/layout_tests/fast/repaint/layer-child-outline.html
+/sdcard/android/layout_tests/fast/repaint/invisible-objects.html
+/sdcard/android/layout_tests/fast/repaint/intermediate-layout-position.html
+/sdcard/android/layout_tests/fast/repaint/intermediate-layout-position-clip.html
+/sdcard/android/layout_tests/fast/repaint/inline-outline-repaint.html
+/sdcard/android/layout_tests/fast/repaint/inline-block-overflow.html
+/sdcard/android/layout_tests/fast/repaint/focus-ring.html
+/sdcard/android/layout_tests/fast/repaint/focus-layers.html
+/sdcard/android/layout_tests/fast/repaint/float-overflow.html
+/sdcard/android/layout_tests/fast/repaint/float-overflow-right.html
+/sdcard/android/layout_tests/fast/repaint/float-move-during-layout.html
+/sdcard/android/layout_tests/fast/repaint/flexible-box-overflow.html
+/sdcard/android/layout_tests/fast/repaint/flexible-box-overflow-horizontal.html
+/sdcard/android/layout_tests/fast/repaint/fixed.html
+/sdcard/android/layout_tests/fast/repaint/erase-overflow.html
+/sdcard/android/layout_tests/fast/repaint/delete-into-nested-block.html
+/sdcard/android/layout_tests/fast/repaint/control-clip.html
+/sdcard/android/layout_tests/fast/repaint/continuation-after-outline.html
+/sdcard/android/layout_tests/fast/repaint/content-into-overflow.html
+/sdcard/android/layout_tests/fast/repaint/containing-block-position-change.html
+/sdcard/android/layout_tests/fast/repaint/clipped-relative.html
+/sdcard/android/layout_tests/fast/repaint/clip-with-layout-delta.html
+/sdcard/android/layout_tests/fast/repaint/caret-outside-block.html
+/sdcard/android/layout_tests/fast/repaint/button-spurious-layout-hint.html
+/sdcard/android/layout_tests/fast/repaint/bugzilla-7235.html
+/sdcard/android/layout_tests/fast/repaint/bugzilla-6473.html
+/sdcard/android/layout_tests/fast/repaint/bugzilla-6388.html
+/sdcard/android/layout_tests/fast/repaint/bugzilla-6278.html
+/sdcard/android/layout_tests/fast/repaint/bugzilla-5699.html
+/sdcard/android/layout_tests/fast/repaint/bugzilla-3509.html
+/sdcard/android/layout_tests/fast/repaint/box-shadow-v.html
+/sdcard/android/layout_tests/fast/repaint/box-shadow-h.html
+/sdcard/android/layout_tests/fast/repaint/box-shadow-dynamic.html
+/sdcard/android/layout_tests/fast/repaint/border-repaint-glitch.html
+/sdcard/android/layout_tests/fast/repaint/border-radius-repaint.html
+/sdcard/android/layout_tests/fast/repaint/border-fit-lines.html
+/sdcard/android/layout_tests/fast/repaint/body-background-image.html
+/sdcard/android/layout_tests/fast/repaint/backgroundSizeRepaint.html
+/sdcard/android/layout_tests/fast/repaint/4776765.html
+/sdcard/android/layout_tests/fast/repaint/4774354.html
+/sdcard/android/layout_tests/fast/reflections/table-cell.html
+/sdcard/android/layout_tests/fast/reflections/reflection-nesting.html
+/sdcard/android/layout_tests/fast/reflections/reflection-direction.html
+/sdcard/android/layout_tests/fast/reflections/inline-crash.html
+/sdcard/android/layout_tests/fast/parser/title-error-test.html
+/sdcard/android/layout_tests/fast/parser/style-script-head-test.html
+/sdcard/android/layout_tests/fast/parser/parseCommentsInTitles.html
+/sdcard/android/layout_tests/fast/parser/open-comment-in-textarea.html
+/sdcard/android/layout_tests/fast/parser/open-comment-in-style.html
+/sdcard/android/layout_tests/fast/parser/fonts.html
+/sdcard/android/layout_tests/fast/parser/external-entities-in-xslt.xml
+/sdcard/android/layout_tests/fast/parser/entity-comment-in-textarea.html
+/sdcard/android/layout_tests/fast/parser/entity-comment-in-style.html
+/sdcard/android/layout_tests/fast/parser/document-write-option.html
+/sdcard/android/layout_tests/fast/parser/comments.html
+/sdcard/android/layout_tests/fast/parser/comment-in-style.html
+/sdcard/android/layout_tests/fast/parser/comment-in-script.html
+/sdcard/android/layout_tests/fast/parser/broken-comments-vs-parsing-mode.html
+/sdcard/android/layout_tests/fast/parser/bad-xml-slash.html
+/sdcard/android/layout_tests/fast/parser/001.html
+/sdcard/android/layout_tests/fast/overflow/unreachable-overflow-rtl-bug.html
+/sdcard/android/layout_tests/fast/overflow/unreachable-content-test.html
+/sdcard/android/layout_tests/fast/overflow/table-overflow-float.html
+/sdcard/android/layout_tests/fast/overflow/scrollRevealButton.html
+/sdcard/android/layout_tests/fast/overflow/scrollbar-position-update.html
+/sdcard/android/layout_tests/fast/overflow/scroll-nested-positioned-layer-in-overflow.html
+/sdcard/android/layout_tests/fast/overflow/position-relative.html
+/sdcard/android/layout_tests/fast/overflow/overflow_hidden.html
+/sdcard/android/layout_tests/fast/overflow/overflow-x-y.html
+/sdcard/android/layout_tests/fast/overflow/overflow-text-hit-testing.html
+/sdcard/android/layout_tests/fast/overflow/overflow-rtl.html
+/sdcard/android/layout_tests/fast/overflow/overflow-rtl-inline-scrollbar.html
+/sdcard/android/layout_tests/fast/overflow/overflow-focus-ring.html
+/sdcard/android/layout_tests/fast/overflow/overflow-auto-table.html
+/sdcard/android/layout_tests/fast/overflow/overflow-auto-position-absolute.html
+/sdcard/android/layout_tests/fast/overflow/infiniteRecursionGuard.html
+/sdcard/android/layout_tests/fast/overflow/infiniteRecursion.html
+/sdcard/android/layout_tests/fast/overflow/image-selection-highlight.html
+/sdcard/android/layout_tests/fast/overflow/hit-test-overflow-controls.html
+/sdcard/android/layout_tests/fast/overflow/hidden-scrollbar-resize.html
+/sdcard/android/layout_tests/fast/overflow/float-in-relpositioned.html
+/sdcard/android/layout_tests/fast/overflow/dynamic-hidden.html
+/sdcard/android/layout_tests/fast/overflow/clip-rects-fixed-ancestor.html
+/sdcard/android/layout_tests/fast/overflow/childFocusRingClip.html
+/sdcard/android/layout_tests/fast/overflow/008.html
+/sdcard/android/layout_tests/fast/overflow/007.html
+/sdcard/android/layout_tests/fast/overflow/006.html
+/sdcard/android/layout_tests/fast/overflow/005.html
+/sdcard/android/layout_tests/fast/overflow/004.html
+/sdcard/android/layout_tests/fast/overflow/003.xml
+/sdcard/android/layout_tests/fast/overflow/002.html
+/sdcard/android/layout_tests/fast/overflow/001.html
+/sdcard/android/layout_tests/fast/multicol/zeroColumnCount.html
+/sdcard/android/layout_tests/fast/multicol/negativeColumnWidth.html
+/sdcard/android/layout_tests/fast/multicol/float-multicol.html
+/sdcard/android/layout_tests/fast/multicol/float-avoidance.html
+/sdcard/android/layout_tests/fast/multicol/columns-shorthand-parsing.html
+/sdcard/android/layout_tests/fast/multicol/column-rules.html
+/sdcard/android/layout_tests/fast/media/viewport-media-query.html
+/sdcard/android/layout_tests/fast/media/mq-width-absolute-04.html
+/sdcard/android/layout_tests/fast/media/mq-width-absolute-03.html
+/sdcard/android/layout_tests/fast/media/mq-width-absolute-02.html
+/sdcard/android/layout_tests/fast/media/mq-width-absolute-01.html
+/sdcard/android/layout_tests/fast/media/mq-valueless.html
+/sdcard/android/layout_tests/fast/media/mq-simple-query-05.html
+/sdcard/android/layout_tests/fast/media/mq-simple-query-04.html
+/sdcard/android/layout_tests/fast/media/mq-simple-query-03.html
+/sdcard/android/layout_tests/fast/media/mq-simple-query-02.html
+/sdcard/android/layout_tests/fast/media/mq-simple-query-01.html
+/sdcard/android/layout_tests/fast/media/mq-simple-neg-query-05.html
+/sdcard/android/layout_tests/fast/media/mq-simple-neg-query-04.html
+/sdcard/android/layout_tests/fast/media/mq-simple-neg-query-03.html
+/sdcard/android/layout_tests/fast/media/mq-simple-neg-query-02.html
+/sdcard/android/layout_tests/fast/media/mq-simple-neg-query-01.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-09.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-08.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-07.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-06.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-05.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-04.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-03.html
+/sdcard/android/layout_tests/fast/media/mq-relative-constraints-02.html
+/sdcard/android/layout_tests/fast/media/mq-pixel-ratio.html
+/sdcard/android/layout_tests/fast/media/mq-min-pixel-ratio.html
+/sdcard/android/layout_tests/fast/media/mq-min-constraint.html
+/sdcard/android/layout_tests/fast/media/mq-max-pixel-ratio.html
+/sdcard/android/layout_tests/fast/media/mq-js-stylesheet-media-04.html
+/sdcard/android/layout_tests/fast/media/mq-js-stylesheet-media-03.html
+/sdcard/android/layout_tests/fast/media/mq-js-stylesheet-media-02.html
+/sdcard/android/layout_tests/fast/media/mq-js-stylesheet-media-01.html
+/sdcard/android/layout_tests/fast/media/mq-js-media-forward-syntax.html
+/sdcard/android/layout_tests/fast/media/mq-js-media-except-03.html
+/sdcard/android/layout_tests/fast/media/mq-js-media-except-02.html
+/sdcard/android/layout_tests/fast/media/mq-js-media-except-01.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-syntax-05.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-syntax-04.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-syntax-03.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-syntax-02.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-syntax-01.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-media-feature-04.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-media-feature-03.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-media-feature-02.html
+/sdcard/android/layout_tests/fast/media/mq-invalid-media-feature-01.html
+/sdcard/android/layout_tests/fast/media/mq-grid-02.html
+/sdcard/android/layout_tests/fast/media/mq-grid-01.html
+/sdcard/android/layout_tests/fast/media/mq-compound-query-05.html
+/sdcard/android/layout_tests/fast/media/mq-compound-query-04.html
+/sdcard/android/layout_tests/fast/media/mq-compound-query-03.html
+/sdcard/android/layout_tests/fast/media/mq-compound-query-02.html
+/sdcard/android/layout_tests/fast/media/mq-compound-query-01.html
+/sdcard/android/layout_tests/fast/media/monochrome.html
+/sdcard/android/layout_tests/fast/media/media-type-syntax-02.html
+/sdcard/android/layout_tests/fast/media/media-type-syntax-01.html
+/sdcard/android/layout_tests/fast/media/media-descriptor-syntax-06.html
+/sdcard/android/layout_tests/fast/media/media-descriptor-syntax-05.html
+/sdcard/android/layout_tests/fast/media/media-descriptor-syntax-04.html
+/sdcard/android/layout_tests/fast/media/media-descriptor-syntax-03.html
+/sdcard/android/layout_tests/fast/media/media-descriptor-syntax-02.html
+/sdcard/android/layout_tests/fast/media/media-descriptor-syntax-01.html
+/sdcard/android/layout_tests/fast/media/implicit-media-all.html
+/sdcard/android/layout_tests/fast/loader/text-document-wrapping.html
+/sdcard/android/layout_tests/fast/loader/start-load-in-unload.html
+/sdcard/android/layout_tests/fast/lists/w3-list-styles.html
+/sdcard/android/layout_tests/fast/lists/scrolled-marker-paint.html
+/sdcard/android/layout_tests/fast/lists/ordered-list-with-no-ol-tag.html
+/sdcard/android/layout_tests/fast/lists/olstart.html
+/sdcard/android/layout_tests/fast/lists/ol-start-dynamic.html
+/sdcard/android/layout_tests/fast/lists/ol-display-types.html
+/sdcard/android/layout_tests/fast/lists/numeric-markers-outside-list.html
+/sdcard/android/layout_tests/fast/lists/markers-in-selection.html
+/sdcard/android/layout_tests/fast/lists/marker-image-error.html
+/sdcard/android/layout_tests/fast/lists/marker-before-empty-inline.html
+/sdcard/android/layout_tests/fast/lists/list-style-type-dynamic-change.html
+/sdcard/android/layout_tests/fast/lists/list-style-none-crash.html
+/sdcard/android/layout_tests/fast/lists/list-item-line-height.html
+/sdcard/android/layout_tests/fast/lists/li-values.html
+/sdcard/android/layout_tests/fast/lists/li-style-alpha-huge-value-crash.html
+/sdcard/android/layout_tests/fast/lists/li-br.html
+/sdcard/android/layout_tests/fast/lists/item-not-in-list-line-wrapping.html
+/sdcard/android/layout_tests/fast/lists/inlineBoxWrapperNullCheck.html
+/sdcard/android/layout_tests/fast/lists/dynamic-marker-crash.html
+/sdcard/android/layout_tests/fast/lists/drag-into-marker.html
+/sdcard/android/layout_tests/fast/lists/decimal-leading-zero.html
+/sdcard/android/layout_tests/fast/lists/big-list-marker.html
+/sdcard/android/layout_tests/fast/lists/alpha-list-wrap.html
+/sdcard/android/layout_tests/fast/lists/009.html
+/sdcard/android/layout_tests/fast/lists/008.html
+/sdcard/android/layout_tests/fast/lists/007.html
+/sdcard/android/layout_tests/fast/lists/006.html
+/sdcard/android/layout_tests/fast/lists/005.html
+/sdcard/android/layout_tests/fast/lists/004.html
+/sdcard/android/layout_tests/fast/lists/003.html
+/sdcard/android/layout_tests/fast/lists/002.html
+/sdcard/android/layout_tests/fast/lists/001.html
+/sdcard/android/layout_tests/fast/layers/zindex-ridonkulous.html
+/sdcard/android/layout_tests/fast/layers/zindex-inherit.html
+/sdcard/android/layout_tests/fast/layers/scroll-rect-to-visible.html
+/sdcard/android/layout_tests/fast/layers/remove-layer-with-nested-stacking.html
+/sdcard/android/layout_tests/fast/layers/positioned-inside-root-with-margins.html
+/sdcard/android/layout_tests/fast/layers/overflow-scroll-auto-switch.html
+/sdcard/android/layout_tests/fast/layers/opacity-stacking.html
+/sdcard/android/layout_tests/fast/layers/opacity-outline.html
+/sdcard/android/layout_tests/fast/layers/layer-visibility.html
+/sdcard/android/layout_tests/fast/layers/layer-visibility-sublayer.html
+/sdcard/android/layout_tests/fast/layers/layer-content-visibility-change.html
+/sdcard/android/layout_tests/fast/layers/add-layer-with-nested-stacking.html
+/sdcard/android/layout_tests/fast/js/missing-style-end-tag-js.html
+/sdcard/android/layout_tests/fast/invalid/td-inside-object.html
+/sdcard/android/layout_tests/fast/invalid/table-residual-style-crash.html
+/sdcard/android/layout_tests/fast/invalid/table-inside-stray-table-content.html
+/sdcard/android/layout_tests/fast/invalid/residual-style.html
+/sdcard/android/layout_tests/fast/invalid/nestedh3s.html
+/sdcard/android/layout_tests/fast/invalid/missing-font-end-tag.html
+/sdcard/android/layout_tests/fast/invalid/missing-dt-end-tag.html
+/sdcard/android/layout_tests/fast/invalid/missing-dl-end-tag.html
+/sdcard/android/layout_tests/fast/invalid/missing-address-end-tag.html
+/sdcard/android/layout_tests/fast/invalid/junk-data.xml
+/sdcard/android/layout_tests/fast/invalid/021.html
+/sdcard/android/layout_tests/fast/invalid/020.xml
+/sdcard/android/layout_tests/fast/invalid/019.html
+/sdcard/android/layout_tests/fast/invalid/018.html
+/sdcard/android/layout_tests/fast/invalid/017.html
+/sdcard/android/layout_tests/fast/invalid/016.html
+/sdcard/android/layout_tests/fast/invalid/015.html
+/sdcard/android/layout_tests/fast/invalid/014.html
+/sdcard/android/layout_tests/fast/invalid/013.html
+/sdcard/android/layout_tests/fast/invalid/012.html
+/sdcard/android/layout_tests/fast/invalid/011.html
+/sdcard/android/layout_tests/fast/invalid/010.html
+/sdcard/android/layout_tests/fast/invalid/009.html
+/sdcard/android/layout_tests/fast/invalid/008.html
+/sdcard/android/layout_tests/fast/invalid/007.html
+/sdcard/android/layout_tests/fast/invalid/006.html
+/sdcard/android/layout_tests/fast/invalid/005.html
+/sdcard/android/layout_tests/fast/invalid/004.html
+/sdcard/android/layout_tests/fast/invalid/003.html
+/sdcard/android/layout_tests/fast/invalid/002.html
+/sdcard/android/layout_tests/fast/invalid/001.html
+/sdcard/android/layout_tests/fast/inspector/style.html
+/sdcard/android/layout_tests/fast/inspector/matchedrules.html
+/sdcard/android/layout_tests/fast/innerHTML/006.html
+/sdcard/android/layout_tests/fast/innerHTML/003.html
+/sdcard/android/layout_tests/fast/innerHTML/002.html
+/sdcard/android/layout_tests/fast/innerHTML/001.html
+/sdcard/android/layout_tests/fast/inline-block/tricky-baseline.html
+/sdcard/android/layout_tests/fast/inline-block/overflow-clip.html
+/sdcard/android/layout_tests/fast/inline-block/inline-block-vertical-align.html
+/sdcard/android/layout_tests/fast/inline-block/contenteditable-baseline.html
+/sdcard/android/layout_tests/fast/inline-block/14498-positionForCoordinates.html
+/sdcard/android/layout_tests/fast/inline-block/006.html
+/sdcard/android/layout_tests/fast/inline-block/005.html
+/sdcard/android/layout_tests/fast/inline-block/004.html
+/sdcard/android/layout_tests/fast/inline-block/003.html
+/sdcard/android/layout_tests/fast/inline-block/002.html
+/sdcard/android/layout_tests/fast/inline-block/001.html
+/sdcard/android/layout_tests/fast/inline/styledEmptyInlinesWithBRs.html
+/sdcard/android/layout_tests/fast/inline/positionedLifetime.html
+/sdcard/android/layout_tests/fast/inline/percentage-margins.html
+/sdcard/android/layout_tests/fast/inline/outline-continuations.html
+/sdcard/android/layout_tests/fast/inline/inline-text-quirk-bpm.html
+/sdcard/android/layout_tests/fast/inline/inline-padding-disables-text-quirk.html
+/sdcard/android/layout_tests/fast/inline/inline-borders-with-bidi-override.html
+/sdcard/android/layout_tests/fast/inline/emptyInlinesWithinLists.html
+/sdcard/android/layout_tests/fast/inline/drawStyledEmptyInlinesWithWS.html
+/sdcard/android/layout_tests/fast/inline/drawStyledEmptyInlines.html
+/sdcard/android/layout_tests/fast/inline/dirtyLinesForInline.html
+/sdcard/android/layout_tests/fast/inline/continuation-outlines.html
+/sdcard/android/layout_tests/fast/inline/continuation-outlines-with-layers.html
+/sdcard/android/layout_tests/fast/inline/002.html
+/sdcard/android/layout_tests/fast/inline/001.html
+/sdcard/android/layout_tests/fast/images/svg-as-tiled-background.html
+/sdcard/android/layout_tests/fast/images/svg-as-relative-image.html
+/sdcard/android/layout_tests/fast/images/svg-as-image.html
+/sdcard/android/layout_tests/fast/images/svg-as-background.html
+/sdcard/android/layout_tests/fast/images/pdf-as-tiled-background.html
+/sdcard/android/layout_tests/fast/images/pdf-as-image.html
+/sdcard/android/layout_tests/fast/images/pdf-as-image-landscape.html
+/sdcard/android/layout_tests/fast/images/pdf-as-background.html
+/sdcard/android/layout_tests/fast/images/object-image.html
+/sdcard/android/layout_tests/fast/images/image-map-anchor-children.html
+/sdcard/android/layout_tests/fast/images/image-in-map.html
+/sdcard/android/layout_tests/fast/images/favicon-as-image.html
+/sdcard/android/layout_tests/fast/images/embed-image.html
+/sdcard/android/layout_tests/fast/images/animated-gif-with-offsets.html
+/sdcard/android/layout_tests/fast/html/marquee-scroll.html
+/sdcard/android/layout_tests/fast/html/listing.html
+/sdcard/android/layout_tests/fast/html/link-rel-stylesheet.html
+/sdcard/android/layout_tests/fast/html/keygen.html
+/sdcard/android/layout_tests/fast/history/history_reload.html
+/sdcard/android/layout_tests/fast/history/clicked-link-is-visited.html
+/sdcard/android/layout_tests/fast/frames/viewsource-attribute.html
+/sdcard/android/layout_tests/fast/frames/valid.html
+/sdcard/android/layout_tests/fast/frames/onlyCommentInIFrame.html
+/sdcard/android/layout_tests/fast/frames/no-frame-borders.html
+/sdcard/android/layout_tests/fast/frames/invalid.html
+/sdcard/android/layout_tests/fast/frames/inline-object-inside-frameset.html
+/sdcard/android/layout_tests/fast/frames/iframe-with-frameborder.html
+/sdcard/android/layout_tests/fast/frames/iframe-text-contents.html
+/sdcard/android/layout_tests/fast/frames/iframe-scrolling-attribute.html
+/sdcard/android/layout_tests/fast/frames/frameset-style-recalc.html
+/sdcard/android/layout_tests/fast/frames/frameElement-iframe.html
+/sdcard/android/layout_tests/fast/frames/frameElement-frame.html
+/sdcard/android/layout_tests/fast/frames/frame-src-attribute.html
+/sdcard/android/layout_tests/fast/frames/frame-set-whitespace-attributes.html
+/sdcard/android/layout_tests/fast/frames/frame-scrolling-attribute.html
+/sdcard/android/layout_tests/fast/frames/frame-navigation.html
+/sdcard/android/layout_tests/fast/frames/frame-length-fractional.html
+/sdcard/android/layout_tests/fast/frames/frame-element-name.html
+/sdcard/android/layout_tests/fast/frames/empty-cols-attribute.html
+/sdcard/android/layout_tests/fast/frames/contentWindow_iFrame.html
+/sdcard/android/layout_tests/fast/frames/contentWindow_Frame.html
+/sdcard/android/layout_tests/fast/frames/calculate-round.html
+/sdcard/android/layout_tests/fast/frames/calculate-relative.html
+/sdcard/android/layout_tests/fast/frames/calculate-percentage.html
+/sdcard/android/layout_tests/fast/frames/calculate-order.html
+/sdcard/android/layout_tests/fast/frames/calculate-fixed.html
+/sdcard/android/layout_tests/fast/frames/002.html
+/sdcard/android/layout_tests/fast/frames/001.html
+/sdcard/android/layout_tests/fast/forms/thumbslider-no-parent-slider.html
+/sdcard/android/layout_tests/fast/forms/thumbslider-crash.html
+/sdcard/android/layout_tests/fast/forms/textfield-outline.html
+/sdcard/android/layout_tests/fast/forms/textfield-drag-into-disabled.html
+/sdcard/android/layout_tests/fast/forms/textAreaLineHeight.html
+/sdcard/android/layout_tests/fast/forms/textarea-width.html
+/sdcard/android/layout_tests/fast/forms/textarea-setinnerhtml.html
+/sdcard/android/layout_tests/fast/forms/textarea-scrolled-type.html
+/sdcard/android/layout_tests/fast/forms/textarea-rows-cols.html
+/sdcard/android/layout_tests/fast/forms/slider-thumb-shared-style.html
+/sdcard/android/layout_tests/fast/forms/slider-padding.html
+/sdcard/android/layout_tests/fast/forms/select-writing-direction-natural.html
+/sdcard/android/layout_tests/fast/forms/select-size.html
+/sdcard/android/layout_tests/fast/forms/select-selected.html
+/sdcard/android/layout_tests/fast/forms/select-list-box-with-height.html
+/sdcard/android/layout_tests/fast/forms/select-initial-position.html
+/sdcard/android/layout_tests/fast/forms/select-display-none-style-resolve.html
+/sdcard/android/layout_tests/fast/forms/select-disabled-appearance.html
+/sdcard/android/layout_tests/fast/forms/select-change-popup-to-listbox.html
+/sdcard/android/layout_tests/fast/forms/select-change-listbox-to-popup.html
+/sdcard/android/layout_tests/fast/forms/select-change-listbox-size.html
+/sdcard/android/layout_tests/fast/forms/select-block-background.html
+/sdcard/android/layout_tests/fast/forms/select-baseline.html
+/sdcard/android/layout_tests/fast/forms/select-align.html
+/sdcard/android/layout_tests/fast/forms/search-placeholder-value-changed.html
+/sdcard/android/layout_tests/fast/forms/search-display-none-cancel-button.html
+/sdcard/android/layout_tests/fast/forms/radio_checked_dynamic.html
+/sdcard/android/layout_tests/fast/forms/radio_checked.html
+/sdcard/android/layout_tests/fast/forms/radio-nested-labels.html
+/sdcard/android/layout_tests/fast/forms/radio-attr-order.html
+/sdcard/android/layout_tests/fast/forms/preserveFormDuringResidualStyle.html
+/sdcard/android/layout_tests/fast/forms/plaintext-mode-2.html
+/sdcard/android/layout_tests/fast/forms/placeholder-set-attribute.html
+/sdcard/android/layout_tests/fast/forms/placeholder-pseudo-style.html
+/sdcard/android/layout_tests/fast/forms/password-placeholder.html
+/sdcard/android/layout_tests/fast/forms/password-placeholder-text-security.html
+/sdcard/android/layout_tests/fast/forms/option-text-clip.html
+/sdcard/android/layout_tests/fast/forms/option-strip-whitespace.html
+/sdcard/android/layout_tests/fast/forms/option-script.html
+/sdcard/android/layout_tests/fast/forms/option-index.html
+/sdcard/android/layout_tests/fast/forms/negativeLineHeight.html
+/sdcard/android/layout_tests/fast/forms/minWidthPercent.html
+/sdcard/android/layout_tests/fast/forms/menulist-width-change.html
+/sdcard/android/layout_tests/fast/forms/menulist-separator-painting.html
+/sdcard/android/layout_tests/fast/forms/menulist-restrict-line-height.html
+/sdcard/android/layout_tests/fast/forms/menulist-option-wrap.html
+/sdcard/android/layout_tests/fast/forms/menulist-no-overflow.html
+/sdcard/android/layout_tests/fast/forms/menulist-narrow-width.html
+/sdcard/android/layout_tests/fast/forms/menulist-deselect-update.html
+/sdcard/android/layout_tests/fast/forms/menulist-clip.html
+/sdcard/android/layout_tests/fast/forms/listbox-width-change.html
+/sdcard/android/layout_tests/fast/forms/listbox-selection-2.html
+/sdcard/android/layout_tests/fast/forms/listbox-scrollbar-incremental-load.html
+/sdcard/android/layout_tests/fast/forms/listbox-deselect-scroll.html
+/sdcard/android/layout_tests/fast/forms/listbox-clip.html
+/sdcard/android/layout_tests/fast/forms/input-width.html
+/sdcard/android/layout_tests/fast/forms/input-value.html
+/sdcard/android/layout_tests/fast/forms/input-type-text-min-width.html
+/sdcard/android/layout_tests/fast/forms/input-type-change2.html
+/sdcard/android/layout_tests/fast/forms/input-type-change.html
+/sdcard/android/layout_tests/fast/forms/input-text-word-wrap.html
+/sdcard/android/layout_tests/fast/forms/input-text-self-emptying-click.html
+/sdcard/android/layout_tests/fast/forms/input-text-scroll-left-on-blur.html
+/sdcard/android/layout_tests/fast/forms/input-text-paste-maxlength.html
+/sdcard/android/layout_tests/fast/forms/input-text-option-delete.html
+/sdcard/android/layout_tests/fast/forms/input-text-maxlength.html
+/sdcard/android/layout_tests/fast/forms/input-text-drag-down.html
+/sdcard/android/layout_tests/fast/forms/input-text-double-click.html
+/sdcard/android/layout_tests/fast/forms/input-text-click-outside.html
+/sdcard/android/layout_tests/fast/forms/input-text-click-inside.html
+/sdcard/android/layout_tests/fast/forms/input-table.html
+/sdcard/android/layout_tests/fast/forms/input-spaces.html
+/sdcard/android/layout_tests/fast/forms/input-readonly-empty.html
+/sdcard/android/layout_tests/fast/forms/input-readonly-dimmed.html
+/sdcard/android/layout_tests/fast/forms/input-readonly-autoscroll.html
+/sdcard/android/layout_tests/fast/forms/input-paste-undo.html
+/sdcard/android/layout_tests/fast/forms/input-no-renderer.html
+/sdcard/android/layout_tests/fast/forms/input-field-text-truncated.html
+/sdcard/android/layout_tests/fast/forms/input-double-click-selection-gap-bug.html
+/sdcard/android/layout_tests/fast/forms/input-disabled-color.html
+/sdcard/android/layout_tests/fast/forms/input-baseline.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-width.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-visibility.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-selection.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-readonly.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-preventDefault.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-height.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-focus.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-default-bkcolor.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-bkcolor.html
+/sdcard/android/layout_tests/fast/forms/input-align.html
+/sdcard/android/layout_tests/fast/forms/input-align-image.html
+/sdcard/android/layout_tests/fast/forms/indeterminate.html
+/sdcard/android/layout_tests/fast/forms/image-border.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_label07.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_label06.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_label05.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_label04.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_label03.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_label02.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_label01.html
+/sdcard/android/layout_tests/fast/forms/hidden-listbox.html
+/sdcard/android/layout_tests/fast/forms/hidden-input-file.html
+/sdcard/android/layout_tests/fast/forms/formmove3.html
+/sdcard/android/layout_tests/fast/forms/formmove2.html
+/sdcard/android/layout_tests/fast/forms/formmove.html
+/sdcard/android/layout_tests/fast/forms/form-hides-table.html
+/sdcard/android/layout_tests/fast/forms/float-before-fieldset.html
+/sdcard/android/layout_tests/fast/forms/file-input-disabled.html
+/sdcard/android/layout_tests/fast/forms/file-input-direction.html
+/sdcard/android/layout_tests/fast/forms/fieldset-with-float.html
+/sdcard/android/layout_tests/fast/forms/fieldset-align.html
+/sdcard/android/layout_tests/fast/forms/dragging-to-file-input.html
+/sdcard/android/layout_tests/fast/forms/dragging-to-disabled-file-input.html
+/sdcard/android/layout_tests/fast/forms/disabled-select-change-index.html
+/sdcard/android/layout_tests/fast/forms/control-restrict-line-height.html
+/sdcard/android/layout_tests/fast/forms/control-clip.html
+/sdcard/android/layout_tests/fast/forms/control-clip-overflow.html
+/sdcard/android/layout_tests/fast/forms/checkbox-radio-onchange.html
+/sdcard/android/layout_tests/fast/forms/button-white-space.html
+/sdcard/android/layout_tests/fast/forms/button-text-transform.html
+/sdcard/android/layout_tests/fast/forms/button-table-styles.html
+/sdcard/android/layout_tests/fast/forms/button-submit.html
+/sdcard/android/layout_tests/fast/forms/button-sizes.html
+/sdcard/android/layout_tests/fast/forms/button-positioned.html
+/sdcard/android/layout_tests/fast/forms/button-inner-block-reuse.html
+/sdcard/android/layout_tests/fast/forms/button-generated-content.html
+/sdcard/android/layout_tests/fast/forms/button-default-title.html
+/sdcard/android/layout_tests/fast/forms/button-cannot-be-nested.html
+/sdcard/android/layout_tests/fast/forms/button-align.html
+/sdcard/android/layout_tests/fast/forms/box-shadow-override.html
+/sdcard/android/layout_tests/fast/forms/blankbuttons.html
+/sdcard/android/layout_tests/fast/forms/006.html
+/sdcard/android/layout_tests/fast/forms/005.html
+/sdcard/android/layout_tests/fast/forms/004.html
+/sdcard/android/layout_tests/fast/forms/003.html
+/sdcard/android/layout_tests/fast/forms/002.html
+/sdcard/android/layout_tests/fast/forms/001.html
+/sdcard/android/layout_tests/fast/flexbox/flex-hang.html
+/sdcard/android/layout_tests/fast/flexbox/026.html
+/sdcard/android/layout_tests/fast/flexbox/025.html
+/sdcard/android/layout_tests/fast/flexbox/024.html
+/sdcard/android/layout_tests/fast/flexbox/023.html
+/sdcard/android/layout_tests/fast/flexbox/022.html
+/sdcard/android/layout_tests/fast/flexbox/021.html
+/sdcard/android/layout_tests/fast/flexbox/020.html
+/sdcard/android/layout_tests/fast/flexbox/019.html
+/sdcard/android/layout_tests/fast/flexbox/018.html
+/sdcard/android/layout_tests/fast/flexbox/017.html
+/sdcard/android/layout_tests/fast/flexbox/016.html
+/sdcard/android/layout_tests/fast/flexbox/015.html
+/sdcard/android/layout_tests/fast/flexbox/014.html
+/sdcard/android/layout_tests/fast/flexbox/013.html
+/sdcard/android/layout_tests/fast/flexbox/012.html
+/sdcard/android/layout_tests/fast/flexbox/011.html
+/sdcard/android/layout_tests/fast/flexbox/010.html
+/sdcard/android/layout_tests/fast/flexbox/009.html
+/sdcard/android/layout_tests/fast/flexbox/008.html
+/sdcard/android/layout_tests/fast/flexbox/007.html
+/sdcard/android/layout_tests/fast/flexbox/006.html
+/sdcard/android/layout_tests/fast/flexbox/005.html
+/sdcard/android/layout_tests/fast/flexbox/004.html
+/sdcard/android/layout_tests/fast/flexbox/003.html
+/sdcard/android/layout_tests/fast/flexbox/002.html
+/sdcard/android/layout_tests/fast/flexbox/001.html
+/sdcard/android/layout_tests/fast/events/updateLayoutForHitTest.html
+/sdcard/android/layout_tests/fast/events/standalone-image-drag-to-editable.html
+/sdcard/android/layout_tests/fast/events/reveal-link-when-focused.html
+/sdcard/android/layout_tests/fast/events/onloadFrameCrash.html
+/sdcard/android/layout_tests/fast/events/onload-re-entry.html
+/sdcard/android/layout_tests/fast/events/mouseout-dead-node.html
+/sdcard/android/layout_tests/fast/events/label-focus.html
+/sdcard/android/layout_tests/fast/events/keydown-1.html
+/sdcard/android/layout_tests/fast/events/focusingUnloadedFrame.html
+/sdcard/android/layout_tests/fast/events/event-sender-mouse-moved.html
+/sdcard/android/layout_tests/fast/events/event-listener-on-link.html
+/sdcard/android/layout_tests/fast/events/context-onmousedown-event.html
+/sdcard/android/layout_tests/fast/events/autoscroll.html
+/sdcard/android/layout_tests/fast/events/attempt-scroll-with-no-scrollbars.html
+/sdcard/android/layout_tests/fast/events/5056619.html
+/sdcard/android/layout_tests/fast/encoding/xmacroman-encoding-test.html
+/sdcard/android/layout_tests/fast/encoding/utf-16-no-bom.xml
+/sdcard/android/layout_tests/fast/encoding/utf-16-little-endian.html
+/sdcard/android/layout_tests/fast/encoding/utf-16-big-endian.html
+/sdcard/android/layout_tests/fast/encoding/invalid-UTF-8.html
+/sdcard/android/layout_tests/fast/encoding/denormalised-voiced-japanese-chars.html
+/sdcard/android/layout_tests/fast/dynamic/view-overflow.html
+/sdcard/android/layout_tests/fast/dynamic/subtree-table-cell-height.html
+/sdcard/android/layout_tests/fast/dynamic/subtree-parent-static-y.html
+/sdcard/android/layout_tests/fast/dynamic/subtree-no-common-root-static-y.html
+/sdcard/android/layout_tests/fast/dynamic/subtree-boundary-percent-height.html
+/sdcard/android/layout_tests/fast/dynamic/staticY.html
+/sdcard/android/layout_tests/fast/dynamic/staticY-marking-parents-regression.html
+/sdcard/android/layout_tests/fast/dynamic/selection-highlight-adjust.html
+/sdcard/android/layout_tests/fast/dynamic/positioned-movement-with-positioned-children.html
+/sdcard/android/layout_tests/fast/dynamic/outerHTML-img.html
+/sdcard/android/layout_tests/fast/dynamic/outerHTML-doc.html
+/sdcard/android/layout_tests/fast/dynamic/noninlinebadness.html
+/sdcard/android/layout_tests/fast/dynamic/move-node-with-selection.html
+/sdcard/android/layout_tests/fast/dynamic/link-href-change.html
+/sdcard/android/layout_tests/fast/dynamic/layer-hit-test-crash.html
+/sdcard/android/layout_tests/fast/dynamic/insert-before-table-part-in-continuation.html
+/sdcard/android/layout_tests/fast/dynamic/genContentDestroyChildren.html
+/sdcard/android/layout_tests/fast/dynamic/floating-to-positioned.html
+/sdcard/android/layout_tests/fast/dynamic/floating-to-positioned-2.html
+/sdcard/android/layout_tests/fast/dynamic/float-withdrawal.html
+/sdcard/android/layout_tests/fast/dynamic/float-withdrawal-2.html
+/sdcard/android/layout_tests/fast/dynamic/float-no-longer-overhanging.html
+/sdcard/android/layout_tests/fast/dynamic/float-in-trailing-whitespace-after-last-line-break.html
+/sdcard/android/layout_tests/fast/dynamic/flash-replacement-test.html
+/sdcard/android/layout_tests/fast/dynamic/create-renderer-for-whitespace-only-text.html
+/sdcard/android/layout_tests/fast/dynamic/containing-block-change.html
+/sdcard/android/layout_tests/fast/dynamic/anonymous-block-orphaned-lines.html
+/sdcard/android/layout_tests/fast/dynamic/anonymous-block-layer-lost.html
+/sdcard/android/layout_tests/fast/dynamic/015.html
+/sdcard/android/layout_tests/fast/dynamic/014.html
+/sdcard/android/layout_tests/fast/dynamic/013.html
+/sdcard/android/layout_tests/fast/dynamic/012.html
+/sdcard/android/layout_tests/fast/dynamic/011.html
+/sdcard/android/layout_tests/fast/dynamic/010.html
+/sdcard/android/layout_tests/fast/dynamic/009.html
+/sdcard/android/layout_tests/fast/dynamic/008.html
+/sdcard/android/layout_tests/fast/dynamic/007.html
+/sdcard/android/layout_tests/fast/dynamic/006.html
+/sdcard/android/layout_tests/fast/dynamic/005.html
+/sdcard/android/layout_tests/fast/dynamic/004.html
+/sdcard/android/layout_tests/fast/dynamic/002.html
+/sdcard/android/layout_tests/fast/dynamic/001.html
+/sdcard/android/layout_tests/fast/dom/Window/open-existing-pop-up-blocking.html
+/sdcard/android/layout_tests/fast/dom/Window/btoa-pnglet.html
+/sdcard/android/layout_tests/fast/dom/Range/surroundContents-1.html
+/sdcard/android/layout_tests/fast/dom/Range/create-contextual-fragment.html
+/sdcard/android/layout_tests/fast/dom/HTMLTextAreaElement/reset-textarea.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/createCaption.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/colSpan.html
+/sdcard/android/layout_tests/fast/dom/HTMLStyleElement/insert-parser-generated.html
+/sdcard/android/layout_tests/fast/dom/HTMLObjectElement/vspace-hspace-as-number.html
+/sdcard/android/layout_tests/fast/dom/HTMLHeadElement/textInHead5.html
+/sdcard/android/layout_tests/fast/dom/HTMLHeadElement/textInHead4.html
+/sdcard/android/layout_tests/fast/dom/HTMLHeadElement/textInHead3.html
+/sdcard/android/layout_tests/fast/dom/HTMLHeadElement/textInHead2.html
+/sdcard/android/layout_tests/fast/dom/HTMLHeadElement/textInHead1.html
+/sdcard/android/layout_tests/fast/dom/HTMLHeadElement/head-link-style-href-check.html
+/sdcard/android/layout_tests/fast/dom/HTMLElement/bdo.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/frameless-location-bugzilla10837.html
+/sdcard/android/layout_tests/fast/dom/Element/null-offset-parent.html
+/sdcard/android/layout_tests/fast/dom/Document/early-document-access.html
+/sdcard/android/layout_tests/fast/dom/row-inner-text.html
+/sdcard/android/layout_tests/fast/dom/replaceChild.html
+/sdcard/android/layout_tests/fast/dom/outerText.html
+/sdcard/android/layout_tests/fast/dom/isindex-002.html
+/sdcard/android/layout_tests/fast/dom/isindex-001.html
+/sdcard/android/layout_tests/fast/dom/focus-contenteditable.html
+/sdcard/android/layout_tests/fast/dom/dom-parse-serialize-display.html
+/sdcard/android/layout_tests/fast/dom/delete-contents.html
+/sdcard/android/layout_tests/fast/dom/css-rule-functions.html
+/sdcard/android/layout_tests/fast/dom/css-mediarule-insertRule-update.html
+/sdcard/android/layout_tests/fast/dom/css-mediarule-deleteRule-update.html
+/sdcard/android/layout_tests/fast/dom/css-inline-style-important.html
+/sdcard/android/layout_tests/fast/dom/css-cached-import-rule.html
+/sdcard/android/layout_tests/fast/dom/clone-node-dynamic-style.html
+/sdcard/android/layout_tests/fast/dom/clone-contents-0-end-offset.html
+/sdcard/android/layout_tests/fast/dom/clientWidthAfterDocumentIsRemoved.html
+/sdcard/android/layout_tests/fast/dom/children-nodes.html
+/sdcard/android/layout_tests/fast/dom/blur-contenteditable.html
+/sdcard/android/layout_tests/fast/dom/attr_dead_doc.html
+/sdcard/android/layout_tests/fast/doctypes/004.html
+/sdcard/android/layout_tests/fast/doctypes/003.html
+/sdcard/android/layout_tests/fast/doctypes/002.html
+/sdcard/android/layout_tests/fast/doctypes/001.html
+/sdcard/android/layout_tests/fast/css-generated-content/wbr-with-before-content.html
+/sdcard/android/layout_tests/fast/css-generated-content/visibleContentHiddenParent.html
+/sdcard/android/layout_tests/fast/css-generated-content/table-with-before.html
+/sdcard/android/layout_tests/fast/css-generated-content/table-row-with-before.html
+/sdcard/android/layout_tests/fast/css-generated-content/table-row-group-with-before.html
+/sdcard/android/layout_tests/fast/css-generated-content/table-row-group-to-inline.html
+/sdcard/android/layout_tests/fast/css-generated-content/table-cell-before-content.html
+/sdcard/android/layout_tests/fast/css-generated-content/spellingToolTip-assert.html
+/sdcard/android/layout_tests/fast/css-generated-content/positioned-background-hit-test-crash.html
+/sdcard/android/layout_tests/fast/css-generated-content/no-openclose-quote.html
+/sdcard/android/layout_tests/fast/css-generated-content/inline-display-types.html
+/sdcard/android/layout_tests/fast/css-generated-content/hover-style-change.html
+/sdcard/android/layout_tests/fast/css-generated-content/before-with-first-letter.html
+/sdcard/android/layout_tests/fast/css-generated-content/after-order.html
+/sdcard/android/layout_tests/fast/css-generated-content/absolute-position-inside-inline.html
+/sdcard/android/layout_tests/fast/css-generated-content/016.html
+/sdcard/android/layout_tests/fast/css-generated-content/015.html
+/sdcard/android/layout_tests/fast/css-generated-content/014.html
+/sdcard/android/layout_tests/fast/css-generated-content/013.html
+/sdcard/android/layout_tests/fast/css-generated-content/012.html
+/sdcard/android/layout_tests/fast/css-generated-content/011.html
+/sdcard/android/layout_tests/fast/css-generated-content/010.html
+/sdcard/android/layout_tests/fast/css-generated-content/009.html
+/sdcard/android/layout_tests/fast/css-generated-content/008.html
+/sdcard/android/layout_tests/fast/css-generated-content/007.html
+/sdcard/android/layout_tests/fast/css-generated-content/005.html
+/sdcard/android/layout_tests/fast/css-generated-content/004.html
+/sdcard/android/layout_tests/fast/css-generated-content/003.html
+/sdcard/android/layout_tests/fast/css-generated-content/002.html
+/sdcard/android/layout_tests/fast/css-generated-content/001.html
+/sdcard/android/layout_tests/fast/css/variables/variable-iteration-test.html
+/sdcard/android/layout_tests/fast/css/variables/shorthand-test.html
+/sdcard/android/layout_tests/fast/css/variables/set-variable-test.html
+/sdcard/android/layout_tests/fast/css/variables/remove-variable-test.html
+/sdcard/android/layout_tests/fast/css/variables/print-test.html
+/sdcard/android/layout_tests/fast/css/variables/override-test.html
+/sdcard/android/layout_tests/fast/css/variables/multiple-term-test.html
+/sdcard/android/layout_tests/fast/css/variables/multiple-blocks-test.html
+/sdcard/android/layout_tests/fast/css/variables/misplaced-variables-test.html
+/sdcard/android/layout_tests/fast/css/variables/misplaced-import-test.html
+/sdcard/android/layout_tests/fast/css/variables/margin-test.html
+/sdcard/android/layout_tests/fast/css/variables/invalid-variable-test.html
+/sdcard/android/layout_tests/fast/css/variables/inline-style-test.html
+/sdcard/android/layout_tests/fast/css/variables/import-test.html
+/sdcard/android/layout_tests/fast/css/variables/image-test.html
+/sdcard/android/layout_tests/fast/css/variables/font-test.html
+/sdcard/android/layout_tests/fast/css/variables/declaration-block-test.html
+/sdcard/android/layout_tests/fast/css/variables/colors-test.html
+/sdcard/android/layout_tests/fast/css/variables/block-cycle-test.html
+/sdcard/android/layout_tests/fast/css/namespaces/007.xml
+/sdcard/android/layout_tests/fast/css/namespaces/006.xml
+/sdcard/android/layout_tests/fast/css/namespaces/005.xml
+/sdcard/android/layout_tests/fast/css/namespaces/004.xml
+/sdcard/android/layout_tests/fast/css/namespaces/003.xml
+/sdcard/android/layout_tests/fast/css/namespaces/002.xml
+/sdcard/android/layout_tests/fast/css/namespaces/001.xml
+/sdcard/android/layout_tests/fast/css/counters/invalidate-cached-counter-node.html
+/sdcard/android/layout_tests/fast/css/counters/counter-text-transform.html
+/sdcard/android/layout_tests/fast/css/counters/counter-text-security.html
+/sdcard/android/layout_tests/fast/css/zoom-property-parsing.html
+/sdcard/android/layout_tests/fast/css/zoom-font-size.html
+/sdcard/android/layout_tests/fast/css/ZeroOpacityLayers2.html
+/sdcard/android/layout_tests/fast/css/ZeroOpacityLayers.html
+/sdcard/android/layout_tests/fast/css/xml-stylesheet-pi-not-in-prolog.xml
+/sdcard/android/layout_tests/fast/css/word-space-extra.html
+/sdcard/android/layout_tests/fast/css/visibility-hit-test.html
+/sdcard/android/layout_tests/fast/css/vertical-align-lengths.html
+/sdcard/android/layout_tests/fast/css/value-list-out-of-bounds-crash.html
+/sdcard/android/layout_tests/fast/css/universal-hover-quirk.html
+/sdcard/android/layout_tests/fast/css/transition-color-unspecified.html
+/sdcard/android/layout_tests/fast/css/transform-default-parameter.html
+/sdcard/android/layout_tests/fast/css/textCapitalizeEdgeCases.html
+/sdcard/android/layout_tests/fast/css/text-security.html
+/sdcard/android/layout_tests/fast/css/text-align.html
+/sdcard/android/layout_tests/fast/css/target-fragment-match.html
+/sdcard/android/layout_tests/fast/css/table-text-align-strict.html
+/sdcard/android/layout_tests/fast/css/table-text-align-quirk.html
+/sdcard/android/layout_tests/fast/css/style-parsed-outside-head.html
+/sdcard/android/layout_tests/fast/css/style-outside-head.html
+/sdcard/android/layout_tests/fast/css/simple-selector-chain-parsing.html
+/sdcard/android/layout_tests/fast/css/shadow-multiple.html
+/sdcard/android/layout_tests/fast/css/selector-set-attribute.html
+/sdcard/android/layout_tests/fast/css/rtl-ordering.html
+/sdcard/android/layout_tests/fast/css/rgb-float.html
+/sdcard/android/layout_tests/fast/css/resize-corner-tracking.html
+/sdcard/android/layout_tests/fast/css/quirk-orphaned-units.html
+/sdcard/android/layout_tests/fast/css/position-negative-top-margin.html
+/sdcard/android/layout_tests/fast/css/percentage-non-integer.html
+/sdcard/android/layout_tests/fast/css/pendingStylesheetFontSize.html
+/sdcard/android/layout_tests/fast/css/outline-auto-location.html
+/sdcard/android/layout_tests/fast/css/outline-auto-empty-rects.html
+/sdcard/android/layout_tests/fast/css/only-of-type-pseudo-class.html
+/sdcard/android/layout_tests/fast/css/only-child-pseudo-class.html
+/sdcard/android/layout_tests/fast/css/negative-nth-child.html
+/sdcard/android/layout_tests/fast/css/max-height-none.html
+/sdcard/android/layout_tests/fast/css/MarqueeLayoutTest.html
+/sdcard/android/layout_tests/fast/css/marginComputedStyle.html
+/sdcard/android/layout_tests/fast/css/margin-top-bottom-dynamic.html
+/sdcard/android/layout_tests/fast/css/margin-bottom-form-element-strict.html
+/sdcard/android/layout_tests/fast/css/margin-bottom-form-element-quirk.html
+/sdcard/android/layout_tests/fast/css/live-cssrules.html
+/sdcard/android/layout_tests/fast/css/list-outline.html
+/sdcard/android/layout_tests/fast/css/link-outside-head.html
+/sdcard/android/layout_tests/fast/css/line-height.html
+/sdcard/android/layout_tests/fast/css/line-height-overflow.html
+/sdcard/android/layout_tests/fast/css/line-height-negative.html
+/sdcard/android/layout_tests/fast/css/line-height-font-order.html
+/sdcard/android/layout_tests/fast/css/layerZOrderCrash.html
+/sdcard/android/layout_tests/fast/css/last-of-type-pseudo-class.html
+/sdcard/android/layout_tests/fast/css/last-child-style-sharing.html
+/sdcard/android/layout_tests/fast/css/last-child-pseudo-class.html
+/sdcard/android/layout_tests/fast/css/invalidation-errors.html
+/sdcard/android/layout_tests/fast/css/invalidation-errors-3.html
+/sdcard/android/layout_tests/fast/css/invalidation-errors-2.html
+/sdcard/android/layout_tests/fast/css/invalid-pseudo-classes.html
+/sdcard/android/layout_tests/fast/css/invalid-percentage-property.html
+/sdcard/android/layout_tests/fast/css/inline-properties-important.html
+/sdcard/android/layout_tests/fast/css/import_with_baseurl.html
+/sdcard/android/layout_tests/fast/css/import-rule-regression-11590.html
+/sdcard/android/layout_tests/fast/css/imageTileOpacity.html
+/sdcard/android/layout_tests/fast/css/ignore-text-zoom.html
+/sdcard/android/layout_tests/fast/css/hsla-color.html
+/sdcard/android/layout_tests/fast/css/hsl-color.html
+/sdcard/android/layout_tests/fast/css/hover-subselector.html
+/sdcard/android/layout_tests/fast/css/font_property_normal.html
+/sdcard/android/layout_tests/fast/css/font-weight-1.html
+/sdcard/android/layout_tests/fast/css/font-size-negative.html
+/sdcard/android/layout_tests/fast/css/font-shorthand-weight-only.html
+/sdcard/android/layout_tests/fast/css/font-face-unicode-range.html
+/sdcard/android/layout_tests/fast/css/font-face-remote.html
+/sdcard/android/layout_tests/fast/css/font-face-multiple-remote-sources.html
+/sdcard/android/layout_tests/fast/css/font-face-multiple-faces.html
+/sdcard/android/layout_tests/fast/css/font-face-descriptor-multiple-values.html
+/sdcard/android/layout_tests/fast/css/font-face-in-media-rule.html
+/sdcard/android/layout_tests/fast/css/font-face-default-font.html
+/sdcard/android/layout_tests/fast/css/first-of-type-pseudo-class.html
+/sdcard/android/layout_tests/fast/css/first-letter-visibility.html
+/sdcard/android/layout_tests/fast/css/first-letter-skip-out-of-flow.html
+/sdcard/android/layout_tests/fast/css/first-letter-recalculation.html
+/sdcard/android/layout_tests/fast/css/first-letter-hover.html
+/sdcard/android/layout_tests/fast/css/first-letter-float.html
+/sdcard/android/layout_tests/fast/css/first-letter-float-after-float.html
+/sdcard/android/layout_tests/fast/css/first-letter-detach.html
+/sdcard/android/layout_tests/fast/css/first-letter-capitalized.html
+/sdcard/android/layout_tests/fast/css/first-child-pseudo-class.html
+/sdcard/android/layout_tests/fast/css/find-next-layer.html
+/sdcard/android/layout_tests/fast/css/fieldset-display-row.html
+/sdcard/android/layout_tests/fast/css/ex-after-font-variant.html
+/sdcard/android/layout_tests/fast/css/error-in-last-decl.html
+/sdcard/android/layout_tests/fast/css/empty-pseudo-class.html
+/sdcard/android/layout_tests/fast/css/empty-generated-content.html
+/sdcard/android/layout_tests/fast/css/empty-body-test.html
+/sdcard/android/layout_tests/fast/css/dynamic-sibling-selector.html
+/sdcard/android/layout_tests/fast/css/disabled-author-styles.html
+/sdcard/android/layout_tests/fast/css/css3-nth-child.html
+/sdcard/android/layout_tests/fast/css/css3-modsel-22.html
+/sdcard/android/layout_tests/fast/css/css2-system-fonts.html
+/sdcard/android/layout_tests/fast/css/css-imports.html
+/sdcard/android/layout_tests/fast/css/continuationCrash.html
+/sdcard/android/layout_tests/fast/css/contentImage.html
+/sdcard/android/layout_tests/fast/css/contentDivWithChildren.html
+/sdcard/android/layout_tests/fast/css/contentDiv.html
+/sdcard/android/layout_tests/fast/css/content-dynamic.html
+/sdcard/android/layout_tests/fast/css/color-quirk.html
+/sdcard/android/layout_tests/fast/css/border-height.html
+/sdcard/android/layout_tests/fast/css/begin-end-contain-selector-empty-value.html
+/sdcard/android/layout_tests/fast/css/background-shorthand-invalid-url.html
+/sdcard/android/layout_tests/fast/css/background-image-with-baseurl.html
+/sdcard/android/layout_tests/fast/css/attribute-selector-empty-value.html
+/sdcard/android/layout_tests/fast/css/apple-prefix.html
+/sdcard/android/layout_tests/fast/css/affected-by-hover-after-style-change.html
+/sdcard/android/layout_tests/fast/css/acid2.html
+/sdcard/android/layout_tests/fast/css/acid2-pixel.html
+/sdcard/android/layout_tests/fast/css/absolute-poition-in-rtl-parent.html
+/sdcard/android/layout_tests/fast/css/008.html
+/sdcard/android/layout_tests/fast/css/007.html
+/sdcard/android/layout_tests/fast/css/006.html
+/sdcard/android/layout_tests/fast/css/005.html
+/sdcard/android/layout_tests/fast/css/004.html
+/sdcard/android/layout_tests/fast/css/003.html
+/sdcard/android/layout_tests/fast/css/002.html
+/sdcard/android/layout_tests/fast/css/001.html
+/sdcard/android/layout_tests/fast/compact/003.html
+/sdcard/android/layout_tests/fast/compact/002.html
+/sdcard/android/layout_tests/fast/compact/001.html
+/sdcard/android/layout_tests/fast/clip/outline-overflowClip.html
+/sdcard/android/layout_tests/fast/clip/nestedTransparencyClip.html
+/sdcard/android/layout_tests/fast/clip/017.html
+/sdcard/android/layout_tests/fast/clip/016.html
+/sdcard/android/layout_tests/fast/clip/015.html
+/sdcard/android/layout_tests/fast/clip/014.html
+/sdcard/android/layout_tests/fast/clip/013.html
+/sdcard/android/layout_tests/fast/clip/012.html
+/sdcard/android/layout_tests/fast/clip/011.html
+/sdcard/android/layout_tests/fast/clip/010.html
+/sdcard/android/layout_tests/fast/clip/009.html
+/sdcard/android/layout_tests/fast/clip/008.html
+/sdcard/android/layout_tests/fast/clip/007.html
+/sdcard/android/layout_tests/fast/clip/006.html
+/sdcard/android/layout_tests/fast/clip/005.html
+/sdcard/android/layout_tests/fast/clip/004.html
+/sdcard/android/layout_tests/fast/clip/003.html
+/sdcard/android/layout_tests/fast/clip/002.html
+/sdcard/android/layout_tests/fast/clip/001.html
+/sdcard/android/layout_tests/fast/canvas/zero-size-fill-rect.html
+/sdcard/android/layout_tests/fast/canvas/shadow-offset-7.html
+/sdcard/android/layout_tests/fast/canvas/shadow-offset-6.html
+/sdcard/android/layout_tests/fast/canvas/shadow-offset-5.html
+/sdcard/android/layout_tests/fast/canvas/shadow-offset-4.html
+/sdcard/android/layout_tests/fast/canvas/shadow-offset-3.html
+/sdcard/android/layout_tests/fast/canvas/shadow-offset-2.html
+/sdcard/android/layout_tests/fast/canvas/shadow-offset-1.html
+/sdcard/android/layout_tests/fast/canvas/quadraticCurveTo.xml
+/sdcard/android/layout_tests/fast/canvas/patternfill-repeat.html
+/sdcard/android/layout_tests/fast/canvas/image-object-in-canvas.html
+/sdcard/android/layout_tests/fast/canvas/gradient-empty-path.html
+/sdcard/android/layout_tests/fast/canvas/fillrect_gradient.html
+/sdcard/android/layout_tests/fast/canvas/fillrect-gradient-zero-stops.html
+/sdcard/android/layout_tests/fast/canvas/fill-stroke-clip-reset-path.html
+/sdcard/android/layout_tests/fast/canvas/drawImage.html
+/sdcard/android/layout_tests/fast/canvas/canvasDrawingIntoSelf.html
+/sdcard/android/layout_tests/fast/canvas/canvas-transforms-during-path.html
+/sdcard/android/layout_tests/fast/canvas/canvas-transform-skewed.html
+/sdcard/android/layout_tests/fast/canvas/canvas-transform-non-invertible.html
+/sdcard/android/layout_tests/fast/canvas/canvas-transform-nan.html
+/sdcard/android/layout_tests/fast/canvas/canvas-transform-multiply.html
+/sdcard/android/layout_tests/fast/canvas/canvas-transform-infinity.html
+/sdcard/android/layout_tests/fast/canvas/canvas-transform-identity.html
+/sdcard/android/layout_tests/fast/canvas/canvas-text-baseline.html
+/sdcard/android/layout_tests/fast/canvas/canvas-text-alignment.html
+/sdcard/android/layout_tests/fast/canvas/canvas-size-change-after-layout.html
+/sdcard/android/layout_tests/fast/canvas/canvas-resize-reset.html
+/sdcard/android/layout_tests/fast/canvas/canvas-bg.html
+/sdcard/android/layout_tests/fast/canvas/canvas-before-css.html
+/sdcard/android/layout_tests/fast/box-sizing/panels-two.html
+/sdcard/android/layout_tests/fast/box-sizing/panels-one.html
+/sdcard/android/layout_tests/fast/box-sizing/box-sizing.html
+/sdcard/android/layout_tests/fast/box-shadow/border-radius-big.html
+/sdcard/android/layout_tests/fast/box-shadow/basic-shadows.html
+/sdcard/android/layout_tests/fast/borders/svg-as-border-image.html
+/sdcard/android/layout_tests/fast/borders/svg-as-border-image-2.html
+/sdcard/android/layout_tests/fast/borders/outline-offset-min-assert.html
+/sdcard/android/layout_tests/fast/borders/inline-mask-overlay-image.html
+/sdcard/android/layout_tests/fast/borders/fieldsetBorderRadius.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusSolid04.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusSolid03.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusSolid02.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusSolid01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusRidge01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusOutset01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusInvalidColor.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusInset01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusGroove02.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusGroove01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDouble03.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDouble02.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDouble01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDotted03.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDotted02.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDotted01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDashed03.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDashed02.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusDashed01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusArcs01.html
+/sdcard/android/layout_tests/fast/borders/borderRadiusAllStylesAllCorners.html
+/sdcard/android/layout_tests/fast/borders/border-radius-huge-assert.html
+/sdcard/android/layout_tests/fast/borders/border-image-scale-transform.html
+/sdcard/android/layout_tests/fast/borders/border-image-rotate-transform.html
+/sdcard/android/layout_tests/fast/borders/border-image-omit-right-slice.html
+/sdcard/android/layout_tests/fast/borders/border-image-01.html
+/sdcard/android/layout_tests/fast/borders/border-fit.html
+/sdcard/android/layout_tests/fast/borders/border-color-inherit.html
+/sdcard/android/layout_tests/fast/borders/block-mask-overlay-image.html
+/sdcard/android/layout_tests/fast/body-propagation/overflow/007.html
+/sdcard/android/layout_tests/fast/body-propagation/overflow/006.html
+/sdcard/android/layout_tests/fast/body-propagation/overflow/005.html
+/sdcard/android/layout_tests/fast/body-propagation/overflow/004.html
+/sdcard/android/layout_tests/fast/body-propagation/overflow/003.html
+/sdcard/android/layout_tests/fast/body-propagation/overflow/002.html
+/sdcard/android/layout_tests/fast/body-propagation/overflow/001.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/010.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/009.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/008.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/007.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/006.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/005.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/004.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/003.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/002.html
+/sdcard/android/layout_tests/fast/body-propagation/background-image/001.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/008.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/007.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/006.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/005.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/004.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/003.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/002.html
+/sdcard/android/layout_tests/fast/body-propagation/background-color/001.html
+/sdcard/android/layout_tests/fast/block/positioning/auto/007.html
+/sdcard/android/layout_tests/fast/block/positioning/auto/006.html
+/sdcard/android/layout_tests/fast/block/positioning/auto/005.html
+/sdcard/android/layout_tests/fast/block/positioning/auto/004.html
+/sdcard/android/layout_tests/fast/block/positioning/auto/003.html
+/sdcard/android/layout_tests/fast/block/positioning/auto/002.html
+/sdcard/android/layout_tests/fast/block/positioning/auto/001.html
+/sdcard/android/layout_tests/fast/block/positioning/window-height-change.html
+/sdcard/android/layout_tests/fast/block/positioning/replaced-inside-fixed-top-bottom.html
+/sdcard/android/layout_tests/fast/block/positioning/relayout-on-position-change.html
+/sdcard/android/layout_tests/fast/block/positioning/relative-overflow-replaced.html
+/sdcard/android/layout_tests/fast/block/positioning/relative-overflow-replaced-float.html
+/sdcard/android/layout_tests/fast/block/positioning/relative-overflow-block.html
+/sdcard/android/layout_tests/fast/block/positioning/relative-overconstrained.html
+/sdcard/android/layout_tests/fast/block/positioning/pref-width-change.html
+/sdcard/android/layout_tests/fast/block/positioning/padding-percent.html
+/sdcard/android/layout_tests/fast/block/positioning/offsetLeft-offsetTop-borders.html
+/sdcard/android/layout_tests/fast/block/positioning/negative-right-pos.html
+/sdcard/android/layout_tests/fast/block/positioning/move-with-auto-width.html
+/sdcard/android/layout_tests/fast/block/positioning/leftmargin-topmargin.html
+/sdcard/android/layout_tests/fast/block/positioning/inline-block-relposition.html
+/sdcard/android/layout_tests/fast/block/positioning/height-change.html
+/sdcard/android/layout_tests/fast/block/positioning/complex-percentage-height.html
+/sdcard/android/layout_tests/fast/block/positioning/child-of-absolute-with-auto-height.html
+/sdcard/android/layout_tests/fast/block/positioning/auto-height-with-top-and-bottom.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-with-html-border-strict.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-with-html-border-quirks.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-positioned-overconstrained.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-position-direction-strict.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-position-direction-quirk.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-length-of-neg-666666.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-short-rtl.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-short-ltr.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-rtl.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-rtl-3.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-rtl-2.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-ltr.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-ltr-3.html
+/sdcard/android/layout_tests/fast/block/positioning/absolute-in-inline-ltr-2.html
+/sdcard/android/layout_tests/fast/block/positioning/abs-inside-inline-rel.html
+/sdcard/android/layout_tests/fast/block/positioning/062.html
+/sdcard/android/layout_tests/fast/block/positioning/061.html
+/sdcard/android/layout_tests/fast/block/positioning/060.html
+/sdcard/android/layout_tests/fast/block/positioning/059.html
+/sdcard/android/layout_tests/fast/block/positioning/058.html
+/sdcard/android/layout_tests/fast/block/positioning/057.html
+/sdcard/android/layout_tests/fast/block/positioning/056.html
+/sdcard/android/layout_tests/fast/block/positioning/055.html
+/sdcard/android/layout_tests/fast/block/positioning/054.html
+/sdcard/android/layout_tests/fast/block/positioning/053.html
+/sdcard/android/layout_tests/fast/block/positioning/052.html
+/sdcard/android/layout_tests/fast/block/positioning/051.html
+/sdcard/android/layout_tests/fast/block/positioning/050.html
+/sdcard/android/layout_tests/fast/block/positioning/049.html
+/sdcard/android/layout_tests/fast/block/positioning/048.html
+/sdcard/android/layout_tests/fast/block/positioning/047.html
+/sdcard/android/layout_tests/fast/block/positioning/046.html
+/sdcard/android/layout_tests/fast/block/positioning/045.html
+/sdcard/android/layout_tests/fast/block/positioning/044.html
+/sdcard/android/layout_tests/fast/block/positioning/043.html
+/sdcard/android/layout_tests/fast/block/positioning/042.html
+/sdcard/android/layout_tests/fast/block/positioning/041.html
+/sdcard/android/layout_tests/fast/block/positioning/040.html
+/sdcard/android/layout_tests/fast/block/positioning/039.html
+/sdcard/android/layout_tests/fast/block/positioning/038.html
+/sdcard/android/layout_tests/fast/block/positioning/037.html
+/sdcard/android/layout_tests/fast/block/positioning/036.html
+/sdcard/android/layout_tests/fast/block/positioning/035.html
+/sdcard/android/layout_tests/fast/block/positioning/034.html
+/sdcard/android/layout_tests/fast/block/positioning/033.html
+/sdcard/android/layout_tests/fast/block/positioning/032.html
+/sdcard/android/layout_tests/fast/block/positioning/031.html
+/sdcard/android/layout_tests/fast/block/positioning/030.html
+/sdcard/android/layout_tests/fast/block/positioning/029.html
+/sdcard/android/layout_tests/fast/block/positioning/028.html
+/sdcard/android/layout_tests/fast/block/positioning/027.html
+/sdcard/android/layout_tests/fast/block/positioning/026.html
+/sdcard/android/layout_tests/fast/block/positioning/025.html
+/sdcard/android/layout_tests/fast/block/positioning/024.html
+/sdcard/android/layout_tests/fast/block/positioning/023.html
+/sdcard/android/layout_tests/fast/block/positioning/022.html
+/sdcard/android/layout_tests/fast/block/positioning/021.html
+/sdcard/android/layout_tests/fast/block/positioning/020.html
+/sdcard/android/layout_tests/fast/block/positioning/019.html
+/sdcard/android/layout_tests/fast/block/positioning/018.html
+/sdcard/android/layout_tests/fast/block/positioning/017.html
+/sdcard/android/layout_tests/fast/block/positioning/016.html
+/sdcard/android/layout_tests/fast/block/positioning/015.html
+/sdcard/android/layout_tests/fast/block/positioning/014.html
+/sdcard/android/layout_tests/fast/block/positioning/013.html
+/sdcard/android/layout_tests/fast/block/positioning/012.html
+/sdcard/android/layout_tests/fast/block/positioning/011.html
+/sdcard/android/layout_tests/fast/block/positioning/010.html
+/sdcard/android/layout_tests/fast/block/positioning/009.html
+/sdcard/android/layout_tests/fast/block/positioning/008.html
+/sdcard/android/layout_tests/fast/block/positioning/007.html
+/sdcard/android/layout_tests/fast/block/positioning/006.html
+/sdcard/android/layout_tests/fast/block/positioning/005.html
+/sdcard/android/layout_tests/fast/block/positioning/004.html
+/sdcard/android/layout_tests/fast/block/positioning/003.html
+/sdcard/android/layout_tests/fast/block/positioning/002.html
+/sdcard/android/layout_tests/fast/block/positioning/001.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/negative-margins.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/empty-clear-blocks.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/104.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/103.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/102.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/101.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/100.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/063.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/062.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/059.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/058.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/057.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/056.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/055.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/045.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/044.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/043.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/042.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/041.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/040.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/039.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/038.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/037.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/035.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/034.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/033.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/032.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/031.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/030.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/029.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/028.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/027.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/026.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/025.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/022.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/021.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/020.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/019.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/018.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/017.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/016.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/015.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/012.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/011.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/010.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/006.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/005.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/004.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/003.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/002.html
+/sdcard/android/layout_tests/fast/block/margin-collapse/001.html
+/sdcard/android/layout_tests/fast/block/float/width-update-after-clear.html
+/sdcard/android/layout_tests/fast/block/float/vertical-move-relayout.html
+/sdcard/android/layout_tests/fast/block/float/tableshifting.html
+/sdcard/android/layout_tests/fast/block/float/table-relayout.html
+/sdcard/android/layout_tests/fast/block/float/shrink-to-fit-width.html
+/sdcard/android/layout_tests/fast/block/float/relative-painted-twice.html
+/sdcard/android/layout_tests/fast/block/float/overhanging-after-height-decrease.html
+/sdcard/android/layout_tests/fast/block/float/overhanging-after-height-decrease-offsets.html
+/sdcard/android/layout_tests/fast/block/float/nowrap-clear-min-width.html
+/sdcard/android/layout_tests/fast/block/float/nopaint-after-layer-destruction2.html
+/sdcard/android/layout_tests/fast/block/float/nopaint-after-layer-destruction.html
+/sdcard/android/layout_tests/fast/block/float/nestedAnonymousBlocks2.html
+/sdcard/android/layout_tests/fast/block/float/nestedAnonymousBlocks.html
+/sdcard/android/layout_tests/fast/block/float/negative-margin-clear.html
+/sdcard/android/layout_tests/fast/block/float/narrow-after-wide.html
+/sdcard/android/layout_tests/fast/block/float/multiple-float-positioning.html
+/sdcard/android/layout_tests/fast/block/float/marquee-shrink-to-avoid-floats.html
+/sdcard/android/layout_tests/fast/block/float/intruding-painted-twice.html
+/sdcard/android/layout_tests/fast/block/float/independent-align-positioning.html
+/sdcard/android/layout_tests/fast/block/float/float-on-zero-height-line.html
+/sdcard/android/layout_tests/fast/block/float/float-in-float-painting.html
+/sdcard/android/layout_tests/fast/block/float/float-in-float-hit-testing.html
+/sdcard/android/layout_tests/fast/block/float/float-avoidance.html
+/sdcard/android/layout_tests/fast/block/float/editable-text-overlapping-float.html
+/sdcard/android/layout_tests/fast/block/float/dynamic-unfloat-pref-width.html
+/sdcard/android/layout_tests/fast/block/float/clamped-right-float.html
+/sdcard/android/layout_tests/fast/block/float/br-with-clear.html
+/sdcard/android/layout_tests/fast/block/float/br-with-clear-2.html
+/sdcard/android/layout_tests/fast/block/float/4145535Crash.html
+/sdcard/android/layout_tests/fast/block/float/035.html
+/sdcard/android/layout_tests/fast/block/float/034.html
+/sdcard/android/layout_tests/fast/block/float/033.html
+/sdcard/android/layout_tests/fast/block/float/032.html
+/sdcard/android/layout_tests/fast/block/float/031.html
+/sdcard/android/layout_tests/fast/block/float/030.html
+/sdcard/android/layout_tests/fast/block/float/029.html
+/sdcard/android/layout_tests/fast/block/float/028.html
+/sdcard/android/layout_tests/fast/block/float/027.html
+/sdcard/android/layout_tests/fast/block/float/026.html
+/sdcard/android/layout_tests/fast/block/float/025.html
+/sdcard/android/layout_tests/fast/block/float/024.html
+/sdcard/android/layout_tests/fast/block/float/023.html
+/sdcard/android/layout_tests/fast/block/float/022.html
+/sdcard/android/layout_tests/fast/block/float/021.html
+/sdcard/android/layout_tests/fast/block/float/020.html
+/sdcard/android/layout_tests/fast/block/float/019.html
+/sdcard/android/layout_tests/fast/block/float/018.html
+/sdcard/android/layout_tests/fast/block/float/017.html
+/sdcard/android/layout_tests/fast/block/float/016.html
+/sdcard/android/layout_tests/fast/block/float/015.html
+/sdcard/android/layout_tests/fast/block/float/014.html
+/sdcard/android/layout_tests/fast/block/float/013.html
+/sdcard/android/layout_tests/fast/block/float/012.html
+/sdcard/android/layout_tests/fast/block/float/011.html
+/sdcard/android/layout_tests/fast/block/float/010.html
+/sdcard/android/layout_tests/fast/block/float/009.html
+/sdcard/android/layout_tests/fast/block/float/008.html
+/sdcard/android/layout_tests/fast/block/float/007.html
+/sdcard/android/layout_tests/fast/block/float/006.html
+/sdcard/android/layout_tests/fast/block/float/005.html
+/sdcard/android/layout_tests/fast/block/float/004.html
+/sdcard/android/layout_tests/fast/block/float/003.html
+/sdcard/android/layout_tests/fast/block/float/002.html
+/sdcard/android/layout_tests/fast/block/float/001.html
+/sdcard/android/layout_tests/fast/block/basic/white-space-pre-wraps.html
+/sdcard/android/layout_tests/fast/block/basic/text-indent-rtl.html
+/sdcard/android/layout_tests/fast/block/basic/quirk-percent-height-grandchild.html
+/sdcard/android/layout_tests/fast/block/basic/quirk-height.html
+/sdcard/android/layout_tests/fast/block/basic/minheight.html
+/sdcard/android/layout_tests/fast/block/basic/min-pref-width-nowrap-floats.html
+/sdcard/android/layout_tests/fast/block/basic/fieldset-stretch-to-legend.html
+/sdcard/android/layout_tests/fast/block/basic/adding-near-anonymous-block.html
+/sdcard/android/layout_tests/fast/block/basic/021.html
+/sdcard/android/layout_tests/fast/block/basic/020.html
+/sdcard/android/layout_tests/fast/block/basic/019.html
+/sdcard/android/layout_tests/fast/block/basic/018.html
+/sdcard/android/layout_tests/fast/block/basic/016.html
+/sdcard/android/layout_tests/fast/block/basic/015.html
+/sdcard/android/layout_tests/fast/block/basic/014.html
+/sdcard/android/layout_tests/fast/block/basic/013.html
+/sdcard/android/layout_tests/fast/block/basic/012.html
+/sdcard/android/layout_tests/fast/block/basic/011.html
+/sdcard/android/layout_tests/fast/block/basic/010.html
+/sdcard/android/layout_tests/fast/block/basic/009.html
+/sdcard/android/layout_tests/fast/block/basic/008.html
+/sdcard/android/layout_tests/fast/block/basic/007.html
+/sdcard/android/layout_tests/fast/block/basic/006.html
+/sdcard/android/layout_tests/fast/block/basic/005.html
+/sdcard/android/layout_tests/fast/block/basic/004.html
+/sdcard/android/layout_tests/fast/block/basic/003.html
+/sdcard/android/layout_tests/fast/block/basic/002.html
+/sdcard/android/layout_tests/fast/block/basic/001.html
+/sdcard/android/layout_tests/fast/backgrounds/size/zero.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize19.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize18.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize17.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize16.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize15.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize14.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize13.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize12.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize11.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize10.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize09.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize08.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize07.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize06.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize05.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize04.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize03.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize02.html
+/sdcard/android/layout_tests/fast/backgrounds/size/backgroundSize01.html
+/sdcard/android/layout_tests/fast/backgrounds/repeat/noRepeatCorrectClip.html
+/sdcard/android/layout_tests/fast/backgrounds/repeat/negative-offset-repeat.html
+/sdcard/android/layout_tests/fast/backgrounds/repeat/negative-offset-repeat-transformed.html
+/sdcard/android/layout_tests/fast/backgrounds/repeat/mask-negative-offset-repeat.html
+/sdcard/android/layout_tests/fast/backgrounds/svg-as-mask.html
+/sdcard/android/layout_tests/fast/backgrounds/svg-as-background-6.html
+/sdcard/android/layout_tests/fast/backgrounds/svg-as-background-5.html
+/sdcard/android/layout_tests/fast/backgrounds/svg-as-background-4.html
+/sdcard/android/layout_tests/fast/backgrounds/svg-as-background-3.html
+/sdcard/android/layout_tests/fast/backgrounds/svg-as-background-2.html
+/sdcard/android/layout_tests/fast/backgrounds/svg-as-background-1.html
+/sdcard/android/layout_tests/fast/backgrounds/solid-color-context-restore.html
+/sdcard/android/layout_tests/fast/backgrounds/mask-composite.html
+/sdcard/android/layout_tests/fast/backgrounds/bgCompositeCopy.html
+/sdcard/android/layout_tests/fast/backgrounds/background-position-rounding.html
+/sdcard/android/layout_tests/fast/backgrounds/background-position-1.html
+/sdcard/android/layout_tests/fast/backgrounds/background-origin-root-element.html
+/sdcard/android/layout_tests/fast/backgrounds/background-inherit-color-bug.html
+/sdcard/android/layout_tests/fast/backgrounds/001.html
diff --git a/tests/DumpRenderTree/results/layout_tests_passed.txt b/tests/DumpRenderTree/results/layout_tests_passed.txt
new file mode 100644
index 0000000..03e920e
--- /dev/null
+++ b/tests/DumpRenderTree/results/layout_tests_passed.txt
@@ -0,0 +1,990 @@
+/sdcard/android/layout_tests/fast/transforms/container-transform-crash.html
+/sdcard/android/layout_tests/fast/tokenizer/write-unclosed-script.html
+/sdcard/android/layout_tests/fast/tokenizer/write-partial-entity.html
+/sdcard/android/layout_tests/fast/tokenizer/write-inline-script-open.html
+/sdcard/android/layout_tests/fast/tokenizer/write-external-script-open.html
+/sdcard/android/layout_tests/fast/tokenizer/nested-multiple-scripts.html
+/sdcard/android/layout_tests/fast/tokenizer/nested-cached-scripts.html
+/sdcard/android/layout_tests/fast/tokenizer/lessthan-terminates-tags-and-attrs.html
+/sdcard/android/layout_tests/fast/tokenizer/image-empty-crash.html
+/sdcard/android/layout_tests/fast/tokenizer/ignore-tags-in-iframe.html
+/sdcard/android/layout_tests/fast/tokenizer/external-script-document-open.html
+/sdcard/android/layout_tests/fast/tokenizer/doctype-search-reset.html
+/sdcard/android/layout_tests/fast/tokenizer/badscript.html
+/sdcard/android/layout_tests/fast/tokenizer/ampersand-in-special-tag.html
+/sdcard/android/layout_tests/fast/tokenizer/004.html
+/sdcard/android/layout_tests/fast/text/line-breaks-after-ideographic-comma-or-full-stop.html
+/sdcard/android/layout_tests/fast/text/large-text-composed-char-dos.html
+/sdcard/android/layout_tests/fast/text/find-case-folding.html
+/sdcard/android/layout_tests/fast/table/td-display-nowrap.html
+/sdcard/android/layout_tests/fast/table/section-in-table-before-misnested-text-crash-css.html
+/sdcard/android/layout_tests/fast/table/rowindex-comment-nodes.html
+/sdcard/android/layout_tests/fast/table/row-in-tbody-before-misnested-text-crash-css.html
+/sdcard/android/layout_tests/fast/table/large-rowspan-crash.html
+/sdcard/android/layout_tests/fast/table/incomplete-table-in-fragment-hang.html
+/sdcard/android/layout_tests/fast/table/incomplete-table-in-fragment-2.html
+/sdcard/android/layout_tests/fast/table/form-in-tbody-before-misnested-text-crash-css.html
+/sdcard/android/layout_tests/fast/table/form-in-table-before-misnested-text-crash-css.html
+/sdcard/android/layout_tests/fast/table/form-in-row-before-misnested-text-crash-css.html
+/sdcard/android/layout_tests/fast/table/empty-auto-column-zero-divide.html
+/sdcard/android/layout_tests/fast/table/destroy-cell-with-selection-crash.html
+/sdcard/android/layout_tests/fast/table/colgroup-relative.html
+/sdcard/android/layout_tests/fast/table/cell-in-row-before-misnested-text-crash-css.html
+/sdcard/android/layout_tests/fast/table/border-changes.html
+/sdcard/android/layout_tests/fast/replaced/object-param-no-name.html
+/sdcard/android/layout_tests/fast/regex/test4.html
+/sdcard/android/layout_tests/fast/regex/test1.html
+/sdcard/android/layout_tests/fast/regex/slow.html
+/sdcard/android/layout_tests/fast/regex/early-acid3-86.html
+/sdcard/android/layout_tests/fast/reflections/teardown-crash.html
+/sdcard/android/layout_tests/fast/reflections/reflection-computed-style.html
+/sdcard/android/layout_tests/fast/parser/test-unicode-characters-in-attribute-name.html
+/sdcard/android/layout_tests/fast/parser/tag-with-exclamation-point.html
+/sdcard/android/layout_tests/fast/parser/strict-img-in-map.html
+/sdcard/android/layout_tests/fast/parser/script-after-frameset-assert.html
+/sdcard/android/layout_tests/fast/parser/rewrite-map.html
+/sdcard/android/layout_tests/fast/parser/rewrite-form.html
+/sdcard/android/layout_tests/fast/parser/residual-style-close-across-removed-block.html
+/sdcard/android/layout_tests/fast/parser/residual-style-close-across-n-blocks.html
+/sdcard/android/layout_tests/fast/parser/remove-parser-current-node.html
+/sdcard/android/layout_tests/fast/parser/remove-node-stack.html
+/sdcard/android/layout_tests/fast/parser/remove-current-node-parent.html
+/sdcard/android/layout_tests/fast/parser/pre-first-line-break.html
+/sdcard/android/layout_tests/fast/parser/parse-wbr.html
+/sdcard/android/layout_tests/fast/parser/p-in-scope.html
+/sdcard/android/layout_tests/fast/parser/p-in-scope-strict.html
+/sdcard/android/layout_tests/fast/parser/open-comment-in-script-tricky.html
+/sdcard/android/layout_tests/fast/parser/number-sign-in-map-name.html
+/sdcard/android/layout_tests/fast/parser/nsup-entity.html
+/sdcard/android/layout_tests/fast/parser/input-textarea-inside-select-element.html
+/sdcard/android/layout_tests/fast/parser/html-whitespace.html
+/sdcard/android/layout_tests/fast/parser/hex-entities-length.html
+/sdcard/android/layout_tests/fast/parser/head-comment.html
+/sdcard/android/layout_tests/fast/parser/entity-surrogate-pairs.html
+/sdcard/android/layout_tests/fast/parser/entity-end-xmp-tag.html
+/sdcard/android/layout_tests/fast/parser/entity-end-title-tag.html
+/sdcard/android/layout_tests/fast/parser/entity-end-textarea-tag.html
+/sdcard/android/layout_tests/fast/parser/entity-end-style-tag.html
+/sdcard/android/layout_tests/fast/parser/entity-end-iframe-tag.html
+/sdcard/android/layout_tests/fast/parser/entity-comment-in-title.html
+/sdcard/android/layout_tests/fast/parser/entity-comment-in-script-tricky.html
+/sdcard/android/layout_tests/fast/parser/entities-in-html.html
+/sdcard/android/layout_tests/fast/parser/duplicate-html-body-element-IDs.html
+/sdcard/android/layout_tests/fast/parser/comment-in-title.html
+/sdcard/android/layout_tests/fast/parser/comment-in-script-tricky.html
+/sdcard/android/layout_tests/fast/parser/assertion-empty-attribute.html
+/sdcard/android/layout_tests/fast/parser/area-in-div.html
+/sdcard/android/layout_tests/fast/overflow/onscroll-layer-self-destruct.html
+/sdcard/android/layout_tests/fast/overflow/generated-content-crash.html
+/sdcard/android/layout_tests/fast/multicol/gap-non-negative.html
+/sdcard/android/layout_tests/fast/multicol/content-height-zero-crash.html
+/sdcard/android/layout_tests/fast/loader/xmlhttprequest-bad-mimetype.html
+/sdcard/android/layout_tests/fast/loader/window-clearing.html
+/sdcard/android/layout_tests/fast/loader/user-style-sheet-resource-load-callbacks.html
+/sdcard/android/layout_tests/fast/loader/url-strip-cr-lf-tab.html
+/sdcard/android/layout_tests/fast/loader/url-parse-1.html
+/sdcard/android/layout_tests/fast/loader/url-data-replace-backslash.html
+/sdcard/android/layout_tests/fast/loader/unloadable-script.html
+/sdcard/android/layout_tests/fast/loader/simultaneous-reloads-assert.html
+/sdcard/android/layout_tests/fast/loader/redirect-with-open-subframe.html
+/sdcard/android/layout_tests/fast/loader/redirect-with-open-subframe-2.html
+/sdcard/android/layout_tests/fast/loader/meta-refresh-vs-open.html
+/sdcard/android/layout_tests/fast/loader/local-css-allowed-in-strict-mode.html
+/sdcard/android/layout_tests/fast/loader/loadInProgress.html
+/sdcard/android/layout_tests/fast/loader/link-no-URL.html
+/sdcard/android/layout_tests/fast/loader/javascript-url-encoding.html
+/sdcard/android/layout_tests/fast/loader/invalid-charset-on-script-crashes-loader.html
+/sdcard/android/layout_tests/fast/loader/inherit-charset-to-empty-frame.html
+/sdcard/android/layout_tests/fast/loader/iframe-recursive-synchronous-load.html
+/sdcard/android/layout_tests/fast/loader/font-face-empty.html
+/sdcard/android/layout_tests/fast/loader/file-URL-with-port-number.html
+/sdcard/android/layout_tests/fast/loader/external-script-URL-location.html
+/sdcard/android/layout_tests/fast/loader/empty-ref-versus-no-ref.html
+/sdcard/android/layout_tests/fast/loader/early-load-cancel.html
+/sdcard/android/layout_tests/fast/loader/data-url-encoding-html.html
+/sdcard/android/layout_tests/fast/loader/charset-parse.html
+/sdcard/android/layout_tests/fast/leaks/002.html
+/sdcard/android/layout_tests/fast/leaks/001.html
+/sdcard/android/layout_tests/fast/layers/resize-layer-deletion-crash.html
+/sdcard/android/layout_tests/fast/layers/removed-by-scroll-handler.html
+/sdcard/android/layout_tests/fast/layers/generated-layer-scrollbar-crash.html
+/sdcard/android/layout_tests/fast/js/pic/rehash-poisons-structure.html
+/sdcard/android/layout_tests/fast/js/pic/get-set-proxy-object.html
+/sdcard/android/layout_tests/fast/js/pic/get-empty-string.html
+/sdcard/android/layout_tests/fast/js/pic/dictionary-prototype.html
+/sdcard/android/layout_tests/fast/js/pic/cached-single-entry-transition.html
+/sdcard/android/layout_tests/fast/js/pic/cached-prototype-setter.html
+/sdcard/android/layout_tests/fast/js/pic/cached-getter-setter.html
+/sdcard/android/layout_tests/fast/js/pic/cached-getter-dictionary-and-proto.html
+/sdcard/android/layout_tests/fast/js/pic/cached-deleted-properties.html
+/sdcard/android/layout_tests/fast/js/window-location-href-file-urls.html
+/sdcard/android/layout_tests/fast/js/while-expression-value.html
+/sdcard/android/layout_tests/fast/js/vardecl-preserve-vardecl.html
+/sdcard/android/layout_tests/fast/js/vardecl-preserve-parameters.html
+/sdcard/android/layout_tests/fast/js/vardecl-preserve-arguments.html
+/sdcard/android/layout_tests/fast/js/vardecl-blocks-init.html
+/sdcard/android/layout_tests/fast/js/var-shadows-arg-crash.html
+/sdcard/android/layout_tests/fast/js/var-declarations.html
+/sdcard/android/layout_tests/fast/js/var-declarations-shadowing.html
+/sdcard/android/layout_tests/fast/js/unmatching-argument-count.html
+/sdcard/android/layout_tests/fast/js/unexpected-constant-crash.html
+/sdcard/android/layout_tests/fast/js/typeof-syntax.html
+/sdcard/android/layout_tests/fast/js/typeof-codegen-crash.html
+/sdcard/android/layout_tests/fast/js/toString-try-else.html
+/sdcard/android/layout_tests/fast/js/toString-prefix-postfix-preserve-parens.html
+/sdcard/android/layout_tests/fast/js/toString-overrides.html
+/sdcard/android/layout_tests/fast/js/toString-number-dot-expr.html
+/sdcard/android/layout_tests/fast/js/toString-for-var-decl.html
+/sdcard/android/layout_tests/fast/js/toString-exception.html
+/sdcard/android/layout_tests/fast/js/tostring-exception-in-property-access.html
+/sdcard/android/layout_tests/fast/js/toString-elision-trailing-comma.html
+/sdcard/android/layout_tests/fast/js/toString-dontEnum.html
+/sdcard/android/layout_tests/fast/js/throw-from-array-sort.html
+/sdcard/android/layout_tests/fast/js/this-non-object-proto.html
+/sdcard/android/layout_tests/fast/js/switch-behaviour.html
+/sdcard/android/layout_tests/fast/js/string_replace.html
+/sdcard/android/layout_tests/fast/js/string-substr.html
+/sdcard/android/layout_tests/fast/js/string-split-ignore-case.html
+/sdcard/android/layout_tests/fast/js/string-sort.html
+/sdcard/android/layout_tests/fast/js/string-slice-abnormal-values.html
+/sdcard/android/layout_tests/fast/js/string-replace-exception-crash.html
+/sdcard/android/layout_tests/fast/js/string-replace-3.html
+/sdcard/android/layout_tests/fast/js/string-replace-2.html
+/sdcard/android/layout_tests/fast/js/string-property-iteration.html
+/sdcard/android/layout_tests/fast/js/string-index-overflow.html
+/sdcard/android/layout_tests/fast/js/string-from-char-code.html
+/sdcard/android/layout_tests/fast/js/string-capitalization.html
+/sdcard/android/layout_tests/fast/js/static-scope-object.html
+/sdcard/android/layout_tests/fast/js/statement-list-register-crash.html
+/sdcard/android/layout_tests/fast/js/stack-unwinding.html
+/sdcard/android/layout_tests/fast/js/sparse-array.html
+/sdcard/android/layout_tests/fast/js/sort-stability.html
+/sdcard/android/layout_tests/fast/js/sort-randomly.html
+/sdcard/android/layout_tests/fast/js/sort-large-array.html
+/sdcard/android/layout_tests/fast/js/slash-lineterminator-parse.html
+/sdcard/android/layout_tests/fast/js/select-options-remove.html
+/sdcard/android/layout_tests/fast/js/select-options-remove-gc.html
+/sdcard/android/layout_tests/fast/js/select-options-add.html
+/sdcard/android/layout_tests/fast/js/resize-array-assign.html
+/sdcard/android/layout_tests/fast/js/reserved-words.html
+/sdcard/android/layout_tests/fast/js/removing-Cf-characters.html
+/sdcard/android/layout_tests/fast/js/rehash-assign.html
+/sdcard/android/layout_tests/fast/js/regexp-unicode-overflow.html
+/sdcard/android/layout_tests/fast/js/regexp-unicode-handling.html
+/sdcard/android/layout_tests/fast/js/regexp-stack-overflow.html
+/sdcard/android/layout_tests/fast/js/regexp-ranges-and-escaped-hyphens.html
+/sdcard/android/layout_tests/fast/js/regexp-range-out-of-order.html
+/sdcard/android/layout_tests/fast/js/regexp-overflow.html
+/sdcard/android/layout_tests/fast/js/regexp-non-character.html
+/sdcard/android/layout_tests/fast/js/regexp-non-capturing-groups.html
+/sdcard/android/layout_tests/fast/js/regexp-non-bmp.html
+/sdcard/android/layout_tests/fast/js/regexp-no-extensions.html
+/sdcard/android/layout_tests/fast/js/regexp-negative-special-characters.html
+/sdcard/android/layout_tests/fast/js/regexp-many-brackets.html
+/sdcard/android/layout_tests/fast/js/regexp-lastindex.html
+/sdcard/android/layout_tests/fast/js/regexp-find-first-asserted.html
+/sdcard/android/layout_tests/fast/js/regexp-extended-characters-more.html
+/sdcard/android/layout_tests/fast/js/regexp-extended-characters-match.html
+/sdcard/android/layout_tests/fast/js/regexp-extended-characters-crash.html
+/sdcard/android/layout_tests/fast/js/regexp-divequal.html
+/sdcard/android/layout_tests/fast/js/regexp-compile.html
+/sdcard/android/layout_tests/fast/js/regexp-compile-crash.html
+/sdcard/android/layout_tests/fast/js/regexp-char-insensitive.html
+/sdcard/android/layout_tests/fast/js/regexp-caching.html
+/sdcard/android/layout_tests/fast/js/reentrant-call-unwind.html
+/sdcard/android/layout_tests/fast/js/read-modify-eval.html
+/sdcard/android/layout_tests/fast/js/propertyIsEnumerable.html
+/sdcard/android/layout_tests/fast/js/property-getters-and-setters.html
+/sdcard/android/layout_tests/fast/js/primitive-method-this.html
+/sdcard/android/layout_tests/fast/js/pretty-print.html
+/sdcard/android/layout_tests/fast/js/prefix-syntax.html
+/sdcard/android/layout_tests/fast/js/postfix-syntax.html
+/sdcard/android/layout_tests/fast/js/parse-backslash-before-newline.html
+/sdcard/android/layout_tests/fast/js/order-of-operations.html
+/sdcard/android/layout_tests/fast/js/object-prototype-toLocaleString.html
+/sdcard/android/layout_tests/fast/js/object-prototype-constructor.html
+/sdcard/android/layout_tests/fast/js/object-extra-comma.html
+/sdcard/android/layout_tests/fast/js/numeric-conversion.html
+/sdcard/android/layout_tests/fast/js/number-toString.html
+/sdcard/android/layout_tests/fast/js/number-toprecision.html
+/sdcard/android/layout_tests/fast/js/number-tofixed.html
+/sdcard/android/layout_tests/fast/js/number-toExponential.html
+/sdcard/android/layout_tests/fast/js/null-char-in-string.html
+/sdcard/android/layout_tests/fast/js/non-object-proto.html
+/sdcard/android/layout_tests/fast/js/nested-function-scope.html
+/sdcard/android/layout_tests/fast/js/navigator-plugins-crash.html
+/sdcard/android/layout_tests/fast/js/named-function-expression.html
+/sdcard/android/layout_tests/fast/js/modify-non-references.html
+/sdcard/android/layout_tests/fast/js/mod-crash.html
+/sdcard/android/layout_tests/fast/js/missing-title-end-tag-js.html
+/sdcard/android/layout_tests/fast/js/math.html
+/sdcard/android/layout_tests/fast/js/logical-or-jless.html
+/sdcard/android/layout_tests/fast/js/lexical-lookup-in-function-constructor.html
+/sdcard/android/layout_tests/fast/js/lastModified.html
+/sdcard/android/layout_tests/fast/js/isPrototypeOf.html
+/sdcard/android/layout_tests/fast/js/invalid-syntax-for-function.html
+/sdcard/android/layout_tests/fast/js/integer-extremes.html
+/sdcard/android/layout_tests/fast/js/implicit-global-to-global-reentry.html
+/sdcard/android/layout_tests/fast/js/implicit-call-with-global-reentry.html
+/sdcard/android/layout_tests/fast/js/has-own-property.html
+/sdcard/android/layout_tests/fast/js/gmail-re-re.html
+/sdcard/android/layout_tests/fast/js/global-var-limit.html
+/sdcard/android/layout_tests/fast/js/getter-setter-gc.html
+/sdcard/android/layout_tests/fast/js/function-toString-parentheses.html
+/sdcard/android/layout_tests/fast/js/function-toString-object-literals.html
+/sdcard/android/layout_tests/fast/js/function-redefinition.html
+/sdcard/android/layout_tests/fast/js/function-prototype.html
+/sdcard/android/layout_tests/fast/js/function-names.html
+/sdcard/android/layout_tests/fast/js/function-name.html
+/sdcard/android/layout_tests/fast/js/function-dot-arguments.html
+/sdcard/android/layout_tests/fast/js/function-dot-arguments-and-caller.html
+/sdcard/android/layout_tests/fast/js/function-decompilation-operators.html
+/sdcard/android/layout_tests/fast/js/function-declarations.html
+/sdcard/android/layout_tests/fast/js/function-declarations-in-switch-statement.html
+/sdcard/android/layout_tests/fast/js/function-call-register-allocation.html
+/sdcard/android/layout_tests/fast/js/function-argument-evaluation-before-exception.html
+/sdcard/android/layout_tests/fast/js/function-apply.html
+/sdcard/android/layout_tests/fast/js/for-in-var-scope.html
+/sdcard/android/layout_tests/fast/js/for-in-to-text.html
+/sdcard/android/layout_tests/fast/js/for-in-exeception.html
+/sdcard/android/layout_tests/fast/js/for-in-avoid-duplicates.html
+/sdcard/android/layout_tests/fast/js/finally-codegen-failure.html
+/sdcard/android/layout_tests/fast/js/exec-state-marking.html
+/sdcard/android/layout_tests/fast/js/exception-try-finally-scope-error.html
+/sdcard/android/layout_tests/fast/js/exception-thrown-from-new.html
+/sdcard/android/layout_tests/fast/js/exception-thrown-from-function-with-lazy-activation.html
+/sdcard/android/layout_tests/fast/js/exception-thrown-from-eval-inside-closure.html
+/sdcard/android/layout_tests/fast/js/exception-thrown-from-equal.html
+/sdcard/android/layout_tests/fast/js/exception-linenums.html
+/sdcard/android/layout_tests/fast/js/exception-linenums-in-html-2.html
+/sdcard/android/layout_tests/fast/js/exception-linenums-in-html-1.html
+/sdcard/android/layout_tests/fast/js/exception-expression-offset.html
+/sdcard/android/layout_tests/fast/js/eval-var-decl.html
+/sdcard/android/layout_tests/fast/js/eval-overriding.html
+/sdcard/android/layout_tests/fast/js/eval-keyword-vs-function.html
+/sdcard/android/layout_tests/fast/js/eval-cross-window.html
+/sdcard/android/layout_tests/fast/js/eval-cache-crash.html
+/sdcard/android/layout_tests/fast/js/equality.html
+/sdcard/android/layout_tests/fast/js/encode-URI-test.html
+/sdcard/android/layout_tests/fast/js/duplicate-param-crash.html
+/sdcard/android/layout_tests/fast/js/dot-node-base-exception.html
+/sdcard/android/layout_tests/fast/js/do-while-without-semicolon.html
+/sdcard/android/layout_tests/fast/js/do-while-semicolon.html
+/sdcard/android/layout_tests/fast/js/do-while-expression-value.html
+/sdcard/android/layout_tests/fast/js/direct-entry-to-function-code.html
+/sdcard/android/layout_tests/fast/js/delete-then-put.html
+/sdcard/android/layout_tests/fast/js/delete-syntax.html
+/sdcard/android/layout_tests/fast/js/delete-multiple-global-blocks.html
+/sdcard/android/layout_tests/fast/js/delete-getters-setters.html
+/sdcard/android/layout_tests/fast/js/delete-function-parameter.html
+/sdcard/android/layout_tests/fast/js/deep-recursion-test.html
+/sdcard/android/layout_tests/fast/js/declaration-in-block.html
+/sdcard/android/layout_tests/fast/js/debugger.html
+/sdcard/android/layout_tests/fast/js/date-set-to-nan.html
+/sdcard/android/layout_tests/fast/js/date-proto-generic-invocation.html
+/sdcard/android/layout_tests/fast/js/date-preserve-milliseconds.html
+/sdcard/android/layout_tests/fast/js/date-parse-test.html
+/sdcard/android/layout_tests/fast/js/date-parse-comments-test.html
+/sdcard/android/layout_tests/fast/js/date-negative-setmonth.html
+/sdcard/android/layout_tests/fast/js/date-DST-time-cusps.html
+/sdcard/android/layout_tests/fast/js/date-DST-pre-1970.html
+/sdcard/android/layout_tests/fast/js/date-constructor.html
+/sdcard/android/layout_tests/fast/js/date-big-setmonth.html
+/sdcard/android/layout_tests/fast/js/date-big-setdate.html
+/sdcard/android/layout_tests/fast/js/date-big-constructor.html
+/sdcard/android/layout_tests/fast/js/cyclic-ref-toString.html
+/sdcard/android/layout_tests/fast/js/cyclic-prototypes.html
+/sdcard/android/layout_tests/fast/js/cyclic-proto.html
+/sdcard/android/layout_tests/fast/js/convert-nan-to-bool.html
+/sdcard/android/layout_tests/fast/js/continue-break-multiple-labels.html
+/sdcard/android/layout_tests/fast/js/constructor.html
+/sdcard/android/layout_tests/fast/js/constructor-attributes.html
+/sdcard/android/layout_tests/fast/js/construct-global-object.html
+/sdcard/android/layout_tests/fast/js/constant-folding.html
+/sdcard/android/layout_tests/fast/js/constant-count.html
+/sdcard/android/layout_tests/fast/js/const.html
+/sdcard/android/layout_tests/fast/js/const-without-initializer.html
+/sdcard/android/layout_tests/fast/js/comparefn-sort-stability.html
+/sdcard/android/layout_tests/fast/js/codegen-temporaries.html
+/sdcard/android/layout_tests/fast/js/codegen-temporaries-multiple-global-blocks.html
+/sdcard/android/layout_tests/fast/js/codegen-peephole-locals.html
+/sdcard/android/layout_tests/fast/js/codegen-loops-logical-nodes.html
+/sdcard/android/layout_tests/fast/js/code-serialize-paren.html
+/sdcard/android/layout_tests/fast/js/closure-inside-extra-arg-call.html
+/sdcard/android/layout_tests/fast/js/char-at.html
+/sdcard/android/layout_tests/fast/js/caller-property.html
+/sdcard/android/layout_tests/fast/js/bitwise-and-on-undefined.html
+/sdcard/android/layout_tests/fast/js/avl-crash.html
+/sdcard/android/layout_tests/fast/js/assign.html
+/sdcard/android/layout_tests/fast/js/ascii-regexp-subject.html
+/sdcard/android/layout_tests/fast/js/array-tostring-ignore-separator.html
+/sdcard/android/layout_tests/fast/js/array-tostring-and-join.html
+/sdcard/android/layout_tests/fast/js/array-splice.html
+/sdcard/android/layout_tests/fast/js/array-sort-reentrance.html
+/sdcard/android/layout_tests/fast/js/array-some.html
+/sdcard/android/layout_tests/fast/js/array-reset-large-index.html
+/sdcard/android/layout_tests/fast/js/array-map.html
+/sdcard/android/layout_tests/fast/js/array-lastIndexOf.html
+/sdcard/android/layout_tests/fast/js/array-join-bug-11524.html
+/sdcard/android/layout_tests/fast/js/array-iterate-backwards.html
+/sdcard/android/layout_tests/fast/js/array-indexof.html
+/sdcard/android/layout_tests/fast/js/array-indexing.html
+/sdcard/android/layout_tests/fast/js/array-index-immediate-types.html
+/sdcard/android/layout_tests/fast/js/array-holes.html
+/sdcard/android/layout_tests/fast/js/array-functions-non-arrays.html
+/sdcard/android/layout_tests/fast/js/array-foreach.html
+/sdcard/android/layout_tests/fast/js/array-float-delete.html
+/sdcard/android/layout_tests/fast/js/array-filter.html
+/sdcard/android/layout_tests/fast/js/array-every.html
+/sdcard/android/layout_tests/fast/js/arguments.html
+/sdcard/android/layout_tests/fast/js/arguments-bad-index.html
+/sdcard/android/layout_tests/fast/js/activation-proto.html
+/sdcard/android/layout_tests/fast/js/activation-object-function-lifetime.html
+/sdcard/android/layout_tests/fast/invalid/test-case-tr-th-td-should-not-close-dl-list.html
+/sdcard/android/layout_tests/fast/invalid/nestedh3s-rapidweaver.html
+/sdcard/android/layout_tests/fast/inspector/cssURLQuotes.html
+/sdcard/android/layout_tests/fast/innerHTML/javascript-url.html
+/sdcard/android/layout_tests/fast/innerHTML/innerHTML-custom-tag.html
+/sdcard/android/layout_tests/fast/innerHTML/innerHTML-case.html
+/sdcard/android/layout_tests/fast/innerHTML/additional-inline-style.html
+/sdcard/android/layout_tests/fast/innerHTML/005.html
+/sdcard/android/layout_tests/fast/inline/clean-after-removing-temp-boxes.html
+/sdcard/android/layout_tests/fast/images/text-content-crash.html
+/sdcard/android/layout_tests/fast/images/text-content-crash-2.html
+/sdcard/android/layout_tests/fast/images/load-img-with-empty-src.html
+/sdcard/android/layout_tests/fast/images/border.html
+/sdcard/android/layout_tests/fast/images/animated-background-image-crash.html
+/sdcard/android/layout_tests/fast/html/xhtml-serialize.html
+/sdcard/android/layout_tests/fast/html/script-allowed-types-languages.html
+/sdcard/android/layout_tests/fast/html/empty-fragment-id-goto-top.html
+/sdcard/android/layout_tests/fast/html/body-offset-properties.html
+/sdcard/android/layout_tests/fast/frames/viewsource-plain-text-tags.html
+/sdcard/android/layout_tests/fast/frames/set-unloaded-frame-location.html
+/sdcard/android/layout_tests/fast/frames/repaint-display-none-crash.html
+/sdcard/android/layout_tests/fast/frames/remove-frame-with-scrollbars-crash.html
+/sdcard/android/layout_tests/fast/frames/onload-remove-iframe-crash.html
+/sdcard/android/layout_tests/fast/frames/negative-remaining-length-crash.html
+/sdcard/android/layout_tests/fast/frames/location-put-after-removal.html
+/sdcard/android/layout_tests/fast/frames/location-change.html
+/sdcard/android/layout_tests/fast/frames/iframe-target.html
+/sdcard/android/layout_tests/fast/frames/iframe-set-same-src.html
+/sdcard/android/layout_tests/fast/frames/iframe-set-same-location.html
+/sdcard/android/layout_tests/fast/frames/iframe-set-inner-html.html
+/sdcard/android/layout_tests/fast/frames/iframe-remove-after-id-change.html
+/sdcard/android/layout_tests/fast/frames/iframe-name-and-id.html
+/sdcard/android/layout_tests/fast/frames/iframe-js-url-clientWidth.html
+/sdcard/android/layout_tests/fast/frames/iframe-double-attach.html
+/sdcard/android/layout_tests/fast/frames/iframe-display-none.html
+/sdcard/android/layout_tests/fast/frames/hover-timer-crash.html
+/sdcard/android/layout_tests/fast/frames/frame-set-same-src.html
+/sdcard/android/layout_tests/fast/frames/frame-set-same-location.html
+/sdcard/android/layout_tests/fast/frames/frame-name-reset.html
+/sdcard/android/layout_tests/fast/frames/frame-display-none-focus.html
+/sdcard/android/layout_tests/fast/frames/empty-frame-document.html
+/sdcard/android/layout_tests/fast/frames/cross-site-this.html
+/sdcard/android/layout_tests/fast/frames/crash-removed-iframe.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-009.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-008.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-007.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-006.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-005.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-004.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-003.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-002.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-001.html
+/sdcard/android/layout_tests/fast/forms/willvalidate-000.html
+/sdcard/android/layout_tests/fast/forms/textfield-focus-out.html
+/sdcard/android/layout_tests/fast/forms/textarea-trailing-newline.html
+/sdcard/android/layout_tests/fast/forms/textarea-setvalue-without-renderer.html
+/sdcard/android/layout_tests/fast/forms/textarea-setvalue-submit.html
+/sdcard/android/layout_tests/fast/forms/textarea-scrollbar-height.html
+/sdcard/android/layout_tests/fast/forms/textarea-linewrap-dynamic.html
+/sdcard/android/layout_tests/fast/forms/textarea-hard-linewrap-empty.html
+/sdcard/android/layout_tests/fast/forms/textarea-crlf.html
+/sdcard/android/layout_tests/fast/forms/text-set-value-crash.html
+/sdcard/android/layout_tests/fast/forms/tabs-with-modifiers.html
+/sdcard/android/layout_tests/fast/forms/tab-in-input.html
+/sdcard/android/layout_tests/fast/forms/submit-with-base.html
+/sdcard/android/layout_tests/fast/forms/submit-to-url-fragment.html
+/sdcard/android/layout_tests/fast/forms/submit-nil-value-field-assert.html
+/sdcard/android/layout_tests/fast/forms/slow-click.html
+/sdcard/android/layout_tests/fast/forms/selected-index-assert.html
+/sdcard/android/layout_tests/fast/forms/select-width-font-change.html
+/sdcard/android/layout_tests/fast/forms/select-type-ahead-list-box-no-selection.html
+/sdcard/android/layout_tests/fast/forms/select-set-inner.html
+/sdcard/android/layout_tests/fast/forms/select-reset.html
+/sdcard/android/layout_tests/fast/forms/select-replace-option.html
+/sdcard/android/layout_tests/fast/forms/select-remove-option.html
+/sdcard/android/layout_tests/fast/forms/select-out-of-bounds-index.html
+/sdcard/android/layout_tests/fast/forms/select-namedItem.html
+/sdcard/android/layout_tests/fast/forms/select-list-box-mouse-focus.html
+/sdcard/android/layout_tests/fast/forms/select-index-setter.html
+/sdcard/android/layout_tests/fast/forms/saved-state-adoptNode-crash.html
+/sdcard/android/layout_tests/fast/forms/remove-radio-button-assert.html
+/sdcard/android/layout_tests/fast/forms/range-reset.html
+/sdcard/android/layout_tests/fast/forms/range-default-value.html
+/sdcard/android/layout_tests/fast/forms/radio_checked_name.html
+/sdcard/android/layout_tests/fast/forms/radio-no-theme-padding.html
+/sdcard/android/layout_tests/fast/forms/radio-check-click-and-drag.html
+/sdcard/android/layout_tests/fast/forms/radio-button-no-change-event.html
+/sdcard/android/layout_tests/fast/forms/paste-multiline-text-input.html
+/sdcard/android/layout_tests/fast/forms/paste-into-textarea.html
+/sdcard/android/layout_tests/fast/forms/option-in-optgroup-removal.html
+/sdcard/android/layout_tests/fast/forms/option-constructor-selected.html
+/sdcard/android/layout_tests/fast/forms/option-change-single-selected.html
+/sdcard/android/layout_tests/fast/forms/old-names.html
+/sdcard/android/layout_tests/fast/forms/missing-action.html
+/sdcard/android/layout_tests/fast/forms/menulist-selection-reset.html
+/sdcard/android/layout_tests/fast/forms/menulist-no-renderer-onmousedown.html
+/sdcard/android/layout_tests/fast/forms/listbox-typeahead-empty.html
+/sdcard/android/layout_tests/fast/forms/listbox-scroll-after-options-removed.html
+/sdcard/android/layout_tests/fast/forms/input-zero-height-focus.html
+/sdcard/android/layout_tests/fast/forms/input-type-change-in-onfocus-mouse.html
+/sdcard/android/layout_tests/fast/forms/input-type-change-in-onfocus-keyboard.html
+/sdcard/android/layout_tests/fast/forms/input-setvalue-selection.html
+/sdcard/android/layout_tests/fast/forms/input-selection-hidden.html
+/sdcard/android/layout_tests/fast/forms/input-named-action-overrides-action-attribute.html
+/sdcard/android/layout_tests/fast/forms/input-changing-value.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-maxlength.html
+/sdcard/android/layout_tests/fast/forms/input-appearance-elementFromPoint.html
+/sdcard/android/layout_tests/fast/forms/HTMLOptionElement_selected.html
+/sdcard/android/layout_tests/fast/forms/hidden-input-not-enabled.html
+/sdcard/android/layout_tests/fast/forms/form-post-urlencoded.html
+/sdcard/android/layout_tests/fast/forms/form-get-multipart3.html
+/sdcard/android/layout_tests/fast/forms/form-get-multipart2.html
+/sdcard/android/layout_tests/fast/forms/form-get-multipart.html
+/sdcard/android/layout_tests/fast/forms/form-data-encoding.html
+/sdcard/android/layout_tests/fast/forms/form-data-encoding-normalization-overrun.html
+/sdcard/android/layout_tests/fast/forms/form-data-encoding-2.html
+/sdcard/android/layout_tests/fast/forms/focus-style-pending.html
+/sdcard/android/layout_tests/fast/forms/empty-get.html
+/sdcard/android/layout_tests/fast/forms/element-order.html
+/sdcard/android/layout_tests/fast/forms/element-by-name.html
+/sdcard/android/layout_tests/fast/forms/double-focus.html
+/sdcard/android/layout_tests/fast/forms/domstring-replace-crash.html
+/sdcard/android/layout_tests/fast/forms/document-write.html
+/sdcard/android/layout_tests/fast/forms/display-none-in-onchange-keyboard.html
+/sdcard/android/layout_tests/fast/forms/cursor-position.html
+/sdcard/android/layout_tests/fast/forms/button-in-forms-collection.html
+/sdcard/android/layout_tests/fast/forms/button-click-DOM.html
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-008.html
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-007.html
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-006.html
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-005.html
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-004.html
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-002.html
+/sdcard/android/layout_tests/fast/forms/autofocus-opera-001.html
+/sdcard/android/layout_tests/fast/forms/autofocus-attribute.html
+/sdcard/android/layout_tests/fast/forms/add-remove-form-elements-stress-test.html
+/sdcard/android/layout_tests/fast/forms/activate-and-disabled-elements.html
+/sdcard/android/layout_tests/fast/forms/8250.html
+/sdcard/android/layout_tests/fast/forms/4628409.html
+/sdcard/android/layout_tests/fast/forms/11423.html
+/sdcard/android/layout_tests/fast/flexbox/inline-children-crash.html
+/sdcard/android/layout_tests/fast/events/window-load-capture.html
+/sdcard/android/layout_tests/fast/events/submit-reset-nested-bubble.html
+/sdcard/android/layout_tests/fast/events/stopPropagation-submit.html
+/sdcard/android/layout_tests/fast/events/stopPropagation-checkbox.html
+/sdcard/android/layout_tests/fast/events/space-scroll-event.html
+/sdcard/android/layout_tests/fast/events/simulated-key-state.html
+/sdcard/android/layout_tests/fast/events/shadow-boundary-crossing.html
+/sdcard/android/layout_tests/fast/events/selectstart-during-autoscroll.html
+/sdcard/android/layout_tests/fast/events/resize-subframe.html
+/sdcard/android/layout_tests/fast/events/remove-event-listener.html
+/sdcard/android/layout_tests/fast/events/programmatic-check-no-change-event.html
+/sdcard/android/layout_tests/fast/events/overflow-events.html
+/sdcard/android/layout_tests/fast/events/onunload-body-property.html
+/sdcard/android/layout_tests/fast/events/onsubmit-bubbling.html
+/sdcard/android/layout_tests/fast/events/onload-after-document-close-with-subresource.html
+/sdcard/android/layout_tests/fast/events/onload-after-document-close-no-subresource.html
+/sdcard/android/layout_tests/fast/events/onerror-bubbling.html
+/sdcard/android/layout_tests/fast/events/no-window-load.html
+/sdcard/android/layout_tests/fast/events/no-blur-on-page-leave.html
+/sdcard/android/layout_tests/fast/events/no-blur-on-enter-button.html
+/sdcard/android/layout_tests/fast/events/nested-window-event.html
+/sdcard/android/layout_tests/fast/events/nested-event-remove-node-crash.html
+/sdcard/android/layout_tests/fast/events/mouseup-outside-button.html
+/sdcard/android/layout_tests/fast/events/mousedown_in_scrollbar.html
+/sdcard/android/layout_tests/fast/events/message-port.html
+/sdcard/android/layout_tests/fast/events/message-port-inactive-document.html
+/sdcard/android/layout_tests/fast/events/message-port-deleted-frame.html
+/sdcard/android/layout_tests/fast/events/message-port-deleted-document.html
+/sdcard/android/layout_tests/fast/events/message-port-constructor-for-deleted-document.html
+/sdcard/android/layout_tests/fast/events/message-channel-listener-circular-ownership.html
+/sdcard/android/layout_tests/fast/events/message-channel-gc.html
+/sdcard/android/layout_tests/fast/events/message-channel-gc-3.html
+/sdcard/android/layout_tests/fast/events/message-channel-gc-2.html
+/sdcard/android/layout_tests/fast/events/keypress-removed-node.html
+/sdcard/android/layout_tests/fast/events/keydown-remove-frame.html
+/sdcard/android/layout_tests/fast/events/init-event-null-view.html
+/sdcard/android/layout_tests/fast/events/init-event-after-dispatch.html
+/sdcard/android/layout_tests/fast/events/event-targets.html
+/sdcard/android/layout_tests/fast/events/event-listener-html-non-html-confusion.html
+/sdcard/android/layout_tests/fast/events/event-instanceof.html
+/sdcard/android/layout_tests/fast/events/event-creation.html
+/sdcard/android/layout_tests/fast/events/div-focus.html
+/sdcard/android/layout_tests/fast/events/dispatch-to-handle-event.html
+/sdcard/android/layout_tests/fast/events/delayed-style-mutation-event-crash.html
+/sdcard/android/layout_tests/fast/events/caller-access-from-event-listener.html
+/sdcard/android/layout_tests/fast/events/anchor-empty-focus.html
+/sdcard/android/layout_tests/fast/encoding/hebrew/logical.html
+/sdcard/android/layout_tests/fast/encoding/hebrew/iso-ir-138.html
+/sdcard/android/layout_tests/fast/encoding/hebrew/hebrew.html
+/sdcard/android/layout_tests/fast/encoding/hebrew/csISO88598I.html
+/sdcard/android/layout_tests/fast/encoding/hebrew/8859-8.html
+/sdcard/android/layout_tests/fast/encoding/hebrew/8859-8-i.html
+/sdcard/android/layout_tests/fast/encoding/hebrew/8859-8-e.html
+/sdcard/android/layout_tests/fast/encoding/gbk/x-gbk.html
+/sdcard/android/layout_tests/fast/encoding/gbk/x-euc-cn.html
+/sdcard/android/layout_tests/fast/encoding/gbk/iso-ir-58.html
+/sdcard/android/layout_tests/fast/encoding/gbk/gb_2312-80.html
+/sdcard/android/layout_tests/fast/encoding/gbk/gbk.html
+/sdcard/android/layout_tests/fast/encoding/gbk/gb2312.html
+/sdcard/android/layout_tests/fast/encoding/gbk/EUC-CN.html
+/sdcard/android/layout_tests/fast/encoding/gbk/csgb231280.html
+/sdcard/android/layout_tests/fast/encoding/gbk/csgb2312.html
+/sdcard/android/layout_tests/fast/encoding/gbk/cn-gb.html
+/sdcard/android/layout_tests/fast/encoding/gbk/close-gbk-converter.html
+/sdcard/android/layout_tests/fast/encoding/gbk/chinese.html
+/sdcard/android/layout_tests/fast/encoding/yahoo-mail.html
+/sdcard/android/layout_tests/fast/encoding/xml-charset-utf16.html
+/sdcard/android/layout_tests/fast/encoding/utf-32-little-endian-nobom.xml
+/sdcard/android/layout_tests/fast/encoding/utf-32-little-endian-bom.html
+/sdcard/android/layout_tests/fast/encoding/utf-32-big-endian-nobom.xml
+/sdcard/android/layout_tests/fast/encoding/utf-32-big-endian-bom.html
+/sdcard/android/layout_tests/fast/encoding/tag-in-title.html
+/sdcard/android/layout_tests/fast/encoding/script-in-head.html
+/sdcard/android/layout_tests/fast/encoding/pseudo-xml.html
+/sdcard/android/layout_tests/fast/encoding/pseudo-xml-4.html
+/sdcard/android/layout_tests/fast/encoding/pseudo-xml-3.html
+/sdcard/android/layout_tests/fast/encoding/pseudo-xml-2.html
+/sdcard/android/layout_tests/fast/encoding/pseudo-tags-in-attributes.html
+/sdcard/android/layout_tests/fast/encoding/preload-encoding.html
+/sdcard/android/layout_tests/fast/encoding/noscript-in-head.html
+/sdcard/android/layout_tests/fast/encoding/no-charset-on-dynamic-script-load.html
+/sdcard/android/layout_tests/fast/encoding/namespace-tolerance.html
+/sdcard/android/layout_tests/fast/encoding/mispositioned-meta.html
+/sdcard/android/layout_tests/fast/encoding/misplaced-xml-declaration.html
+/sdcard/android/layout_tests/fast/encoding/meta-charset.html
+/sdcard/android/layout_tests/fast/encoding/latin1-winlatin.html
+/sdcard/android/layout_tests/fast/encoding/high-bit-latin1.html
+/sdcard/android/layout_tests/fast/encoding/hanarei-blog32-fc2-com.html
+/sdcard/android/layout_tests/fast/encoding/floraexpress-ru.html
+/sdcard/android/layout_tests/fast/encoding/decoder-allow-null-chars.html
+/sdcard/android/layout_tests/fast/encoding/css-link-charset.html
+/sdcard/android/layout_tests/fast/encoding/css-charset.html
+/sdcard/android/layout_tests/fast/encoding/css-charset-evil.html
+/sdcard/android/layout_tests/fast/encoding/css-charset-dom.html
+/sdcard/android/layout_tests/fast/encoding/charset-xuser-defined.html
+/sdcard/android/layout_tests/fast/encoding/charset-utf16.html
+/sdcard/android/layout_tests/fast/encoding/charset-unicode.html
+/sdcard/android/layout_tests/fast/encoding/charset-invalid.html
+/sdcard/android/layout_tests/fast/encoding/charset-cp1251.html
+/sdcard/android/layout_tests/fast/encoding/bom-in-content.html
+/sdcard/android/layout_tests/fast/encoding/bom-in-content-utf16.html
+/sdcard/android/layout_tests/fast/encoding/bandai-co-jp-releases.html
+/sdcard/android/layout_tests/fast/encoding/ahram-org-eg.html
+/sdcard/android/layout_tests/fast/dynamic/subtree-common-root.html
+/sdcard/android/layout_tests/fast/dynamic/style-access-late-stylesheet-load.html
+/sdcard/android/layout_tests/fast/dynamic/recursive-layout.html
+/sdcard/android/layout_tests/fast/dynamic/outerHTML-no-element.html
+/sdcard/android/layout_tests/fast/dynamic/insertAdjacentText.html
+/sdcard/android/layout_tests/fast/dynamic/insertAdjacentHTML.html
+/sdcard/android/layout_tests/fast/dynamic/insertAdjacentHTML-allowed-parents.html
+/sdcard/android/layout_tests/fast/dynamic/inline-to-block-crash.html
+/sdcard/android/layout_tests/fast/dynamic/hovered-detach.html
+/sdcard/android/layout_tests/fast/dynamic/float-remove-above-line.html
+/sdcard/android/layout_tests/fast/dynamic/checkbox-selection-crash.html
+/sdcard/android/layout_tests/fast/dynamic/ancestor-to-absolute.html
+/sdcard/android/layout_tests/fast/dynamic/5872671.html
+/sdcard/android/layout_tests/fast/dom/Window/window-special-properties.html
+/sdcard/android/layout_tests/fast/dom/Window/window-resize-and-move-sub-frame.html
+/sdcard/android/layout_tests/fast/dom/Window/window-remove-event-listener.html
+/sdcard/android/layout_tests/fast/dom/Window/window-property-shadowing.html
+/sdcard/android/layout_tests/fast/dom/Window/window-property-shadowing-name.html
+/sdcard/android/layout_tests/fast/dom/Window/window-open-top.html
+/sdcard/android/layout_tests/fast/dom/Window/window-open-self.html
+/sdcard/android/layout_tests/fast/dom/Window/window-open-self-from-other-frame.html
+/sdcard/android/layout_tests/fast/dom/Window/window-open-parent.html
+/sdcard/android/layout_tests/fast/dom/Window/window-open-parent-no-parent.html
+/sdcard/android/layout_tests/fast/dom/Window/window-object-cross-frame-calls.html
+/sdcard/android/layout_tests/fast/dom/Window/window-location-replace-functions.html
+/sdcard/android/layout_tests/fast/dom/Window/window-function-frame-getter-precedence.html
+/sdcard/android/layout_tests/fast/dom/Window/window-custom-prototype-crash.html
+/sdcard/android/layout_tests/fast/dom/Window/window-closed-crash.html
+/sdcard/android/layout_tests/fast/dom/Window/window-appendages-cleared.html
+/sdcard/android/layout_tests/fast/dom/Window/setTimeout-no-arguments.html
+/sdcard/android/layout_tests/fast/dom/Window/global-opener-function.html
+/sdcard/android/layout_tests/fast/dom/Window/getMatchedCSSRules-null-crash.html
+/sdcard/android/layout_tests/fast/dom/Window/element-constructors-on-window.html
+/sdcard/android/layout_tests/fast/dom/Window/closure-access-after-navigation-iframe.html
+/sdcard/android/layout_tests/fast/dom/Window/attr-constructor.html
+/sdcard/android/layout_tests/fast/dom/Window/atob-btoa.html
+/sdcard/android/layout_tests/fast/dom/Window/alert-undefined.html
+/sdcard/android/layout_tests/fast/dom/TreeWalker/TreeWalker-currentNode.html
+/sdcard/android/layout_tests/fast/dom/Text/replaceWholeText.html
+/sdcard/android/layout_tests/fast/dom/StyleSheet/ownerNode-lifetime.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/viewless-document.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/not-supported-namespace-in-selector.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/id-fastpath.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/id-fastpath-strict.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/id-fastpath-almost-strict.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/elementRoot.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/dumpNodeList.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/dumpNodeList-almost-strict.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/detached-element.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/caseTag.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/caseID.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/caseID-strict.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/caseID-almost-strict.html
+/sdcard/android/layout_tests/fast/dom/SelectorAPI/bug-17313.html
+/sdcard/android/layout_tests/fast/dom/Range/range-processing-instructions.html
+/sdcard/android/layout_tests/fast/dom/Range/range-modifycontents.html
+/sdcard/android/layout_tests/fast/dom/Range/range-isPointInRange.html
+/sdcard/android/layout_tests/fast/dom/Range/range-intersectsNode.html
+/sdcard/android/layout_tests/fast/dom/Range/range-insertNode-splittext.html
+/sdcard/android/layout_tests/fast/dom/Range/range-insertNode-separate-endContainer.html
+/sdcard/android/layout_tests/fast/dom/Range/range-exceptions.html
+/sdcard/android/layout_tests/fast/dom/Range/range-comparePoint.html
+/sdcard/android/layout_tests/fast/dom/Range/range-compareNode.html
+/sdcard/android/layout_tests/fast/dom/Range/range-clone-empty.html
+/sdcard/android/layout_tests/fast/dom/Range/mutation.html
+/sdcard/android/layout_tests/fast/dom/Range/compareBoundaryPoints-2.html
+/sdcard/android/layout_tests/fast/dom/Range/compareBoundaryPoints-1.html
+/sdcard/android/layout_tests/fast/dom/Range/acid3-surround-contents.html
+/sdcard/android/layout_tests/fast/dom/Range/13000.html
+/sdcard/android/layout_tests/fast/dom/NodeList/item-by-id-with-no-document.html
+/sdcard/android/layout_tests/fast/dom/NodeList/invalidate-node-lists-when-parsing.html
+/sdcard/android/layout_tests/fast/dom/NodeList/childNodes-reset-cache.html
+/sdcard/android/layout_tests/fast/dom/NodeList/5725058-crash-scenario-3.html
+/sdcard/android/layout_tests/fast/dom/NodeList/5725058-crash-scenario-2.html
+/sdcard/android/layout_tests/fast/dom/NodeList/5725058-crash-scenario-1.html
+/sdcard/android/layout_tests/fast/dom/Node/initial-values.html
+/sdcard/android/layout_tests/fast/dom/Node/DOMNodeRemovedEvent.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableSectionElement/rows.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableRowElement/insertCell.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableRowElement/cells.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/tBodies.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/rows.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/insert-row.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/early-acid3-66-excerpt.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/early-acid3-65-excerpt.html
+/sdcard/android/layout_tests/fast/dom/HTMLTableElement/cellpadding-attribute.html
+/sdcard/android/layout_tests/fast/dom/HTMLSelectElement/options-collection-set-string-length.html
+/sdcard/android/layout_tests/fast/dom/HTMLSelectElement/options-collection-detached.html
+/sdcard/android/layout_tests/fast/dom/HTMLScriptElement/script-set-src.html
+/sdcard/android/layout_tests/fast/dom/HTMLScriptElement/script-reexecution.html
+/sdcard/android/layout_tests/fast/dom/HTMLScriptElement/script-load-events.html
+/sdcard/android/layout_tests/fast/dom/HTMLScriptElement/script-decoding-error-after-setting-src.html
+/sdcard/android/layout_tests/fast/dom/HTMLOptionElement/set-option-index-text.html
+/sdcard/android/layout_tests/fast/dom/HTMLOptionElement/option-text.html
+/sdcard/android/layout_tests/fast/dom/HTMLOptionElement/option-prototype.html
+/sdcard/android/layout_tests/fast/dom/HTMLObjectElement/form/test1.html
+/sdcard/android/layout_tests/fast/dom/HTMLMetaElement/meta-attributes.html
+/sdcard/android/layout_tests/fast/dom/HTMLLabelElement/form/test1.html
+/sdcard/android/layout_tests/fast/dom/HTMLInputElement/size-attribute.html
+/sdcard/android/layout_tests/fast/dom/HTMLInputElement/size-as-number.html
+/sdcard/android/layout_tests/fast/dom/HTMLInputElement/input-text-reset.html
+/sdcard/android/layout_tests/fast/dom/HTMLInputElement/input-hidden-value.html
+/sdcard/android/layout_tests/fast/dom/HTMLInputElement/input-checked-reset.html
+/sdcard/android/layout_tests/fast/dom/HTMLInputElement/checked-pseudo-selector.html
+/sdcard/android/layout_tests/fast/dom/HTMLImageElement/image-without-renderer-width.html
+/sdcard/android/layout_tests/fast/dom/HTMLImageElement/image-src-absolute-url.html
+/sdcard/android/layout_tests/fast/dom/HTMLImageElement/image-natural-width-height.html
+/sdcard/android/layout_tests/fast/dom/HTMLImageElement/image-lowsrc-getset.html
+/sdcard/android/layout_tests/fast/dom/HTMLImageElement/image-longdesc-absolute-url.html
+/sdcard/android/layout_tests/fast/dom/HTMLImageElement/image-loading-gc.html
+/sdcard/android/layout_tests/fast/dom/HTMLImageElement/constructor-mutation-event-dispatch.html
+/sdcard/android/layout_tests/fast/dom/HTMLHtmlElement/set-version.html
+/sdcard/android/layout_tests/fast/dom/HTMLHtmlElement/duplicate-html-element-crash.html
+/sdcard/android/layout_tests/fast/dom/HTMLHeadElement/head-check.html
+/sdcard/android/layout_tests/fast/dom/HTMLFormElement/elements-not-in-document.html
+/sdcard/android/layout_tests/fast/dom/HTMLFontElement/size-attribute.html
+/sdcard/android/layout_tests/fast/dom/HTMLElement/set-inner-outer-optimization.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/writeln-multiple-calls.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/writeln-call.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/write-multiple-calls.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/write-call.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/url-getset.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/title-set.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/title-get.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/object-by-name-unknown-child-element.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/object-by-name-or-id.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/document-special-properties.html
+/sdcard/android/layout_tests/fast/dom/HTMLDocument/document-plugins.html
+/sdcard/android/layout_tests/fast/dom/HTMLDivElement/align/getset.html
+/sdcard/android/layout_tests/fast/dom/HTMLButtonElement/value/getset.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/array/004.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/array/003.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/array/002.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/array/001.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/dumpNodeList.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/015.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/014.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/013.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/012.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/009.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/008.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/007.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/006.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/005.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/004.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/003.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/002.html
+/sdcard/android/layout_tests/fast/dom/getElementsByClassName/001.html
+/sdcard/android/layout_tests/fast/dom/EntityReference/readonly-exceptions.html
+/sdcard/android/layout_tests/fast/dom/Element/setAttribute-with-colon.html
+/sdcard/android/layout_tests/fast/dom/Element/setAttribute-case-insensitivity.html
+/sdcard/android/layout_tests/fast/dom/Element/onclick-case.html
+/sdcard/android/layout_tests/fast/dom/Element/offsetTop-table-cell.html
+/sdcard/android/layout_tests/fast/dom/Element/getAttribute-check-case-sensitivity.html
+/sdcard/android/layout_tests/fast/dom/Element/element-traversal.html
+/sdcard/android/layout_tests/fast/dom/Element/dimension-properties-unrendered.html
+/sdcard/android/layout_tests/fast/dom/Element/contains-method.html
+/sdcard/android/layout_tests/fast/dom/Element/attribute-uppercase.html
+/sdcard/android/layout_tests/fast/dom/Element/attr-param-typechecking.html
+/sdcard/android/layout_tests/fast/dom/DOMImplementation/createDocumentType-err.html
+/sdcard/android/layout_tests/fast/dom/DOMException/RangeException.html
+/sdcard/android/layout_tests/fast/dom/DOMException/prototype-object.html
+/sdcard/android/layout_tests/fast/dom/DOMException/EventException.html
+/sdcard/android/layout_tests/fast/dom/Document/title-property-set-multiple-times.html
+/sdcard/android/layout_tests/fast/dom/Document/title-property-creates-title-element.html
+/sdcard/android/layout_tests/fast/dom/Document/replaceChild-null-oldChild.html
+/sdcard/android/layout_tests/fast/dom/Document/replace-child.html
+/sdcard/android/layout_tests/fast/dom/Document/open-with-pending-load.html
+/sdcard/android/layout_tests/fast/dom/Document/document-reopen.html
+/sdcard/android/layout_tests/fast/dom/Document/document-charset.html
+/sdcard/android/layout_tests/fast/dom/Document/doc-open-while-parsing.html
+/sdcard/android/layout_tests/fast/dom/Document/createElementNS-namespace-err.html
+/sdcard/android/layout_tests/fast/dom/Document/createAttributeNS-namespace-err.html
+/sdcard/android/layout_tests/fast/dom/CSSStyleDeclaration/transition-property-names.html
+/sdcard/android/layout_tests/fast/dom/CSSStyleDeclaration/empty-string-property.html
+/sdcard/android/layout_tests/fast/dom/CSSStyleDeclaration/css-properties-case-sensitive.html
+/sdcard/android/layout_tests/fast/dom/XMLSerializer.html
+/sdcard/android/layout_tests/fast/dom/XMLSerializer-doctype2.html
+/sdcard/android/layout_tests/fast/dom/XMLSerializer-doctype.html
+/sdcard/android/layout_tests/fast/dom/xmlhttprequest-invalid-values.html
+/sdcard/android/layout_tests/fast/dom/xmlhttprequest-html-response-encoding.html
+/sdcard/android/layout_tests/fast/dom/wrapper-identity.html
+/sdcard/android/layout_tests/fast/dom/undetectable-style-filter.html
+/sdcard/android/layout_tests/fast/dom/undetectable-document-all.html
+/sdcard/android/layout_tests/fast/dom/title-text-property.html
+/sdcard/android/layout_tests/fast/dom/title-text-property-2.html
+/sdcard/android/layout_tests/fast/dom/timer-clear-interval-in-handler.html
+/sdcard/android/layout_tests/fast/dom/space-to-text.html
+/sdcard/android/layout_tests/fast/dom/setAttributeNS.html
+/sdcard/android/layout_tests/fast/dom/setAttribute-using-initial-input-value.html
+/sdcard/android/layout_tests/fast/dom/set-inner-text-newlines.html
+/sdcard/android/layout_tests/fast/dom/serialize-cdata.html
+/sdcard/android/layout_tests/fast/dom/select-selectedIndex-multiple.html
+/sdcard/android/layout_tests/fast/dom/select-selectedIndex-bug-12942.html
+/sdcard/android/layout_tests/fast/dom/script-element-without-frame-crash.html
+/sdcard/android/layout_tests/fast/dom/script-element-remove-self.html
+/sdcard/android/layout_tests/fast/dom/script-element-gc.html
+/sdcard/android/layout_tests/fast/dom/script-add.html
+/sdcard/android/layout_tests/fast/dom/resource-locations-in-created-html-document.html
+/sdcard/android/layout_tests/fast/dom/replace-first-child.html
+/sdcard/android/layout_tests/fast/dom/replace-child-siblings.html
+/sdcard/android/layout_tests/fast/dom/remove-style-element.html
+/sdcard/android/layout_tests/fast/dom/remove-named-attribute-crash.html
+/sdcard/android/layout_tests/fast/dom/Range-insertNode-crash.html
+/sdcard/android/layout_tests/fast/dom/prototypes.html
+/sdcard/android/layout_tests/fast/dom/prototype-chain.html
+/sdcard/android/layout_tests/fast/dom/plugin-attributes-enumeration.html
+/sdcard/android/layout_tests/fast/dom/outerText-no-element.html
+/sdcard/android/layout_tests/fast/dom/option-properties.html
+/sdcard/android/layout_tests/fast/dom/objc-big-method-name.html
+/sdcard/android/layout_tests/fast/dom/null-document-xmlhttprequest-open.html
+/sdcard/android/layout_tests/fast/dom/location-assign.html
+/sdcard/android/layout_tests/fast/dom/javascript-backslash.html
+/sdcard/android/layout_tests/fast/dom/innerHTML-nbsp.html
+/sdcard/android/layout_tests/fast/dom/innerHTML-escaping-attribute.html
+/sdcard/android/layout_tests/fast/dom/inner-width-height.html
+/sdcard/android/layout_tests/fast/dom/inner-text-with-no-renderer.html
+/sdcard/android/layout_tests/fast/dom/inner-text-rtl.html
+/sdcard/android/layout_tests/fast/dom/importNode-prefix.html
+/sdcard/android/layout_tests/fast/dom/importNode-null.html
+/sdcard/android/layout_tests/fast/dom/import-document-fragment.html
+/sdcard/android/layout_tests/fast/dom/import-attribute-node.html
+/sdcard/android/layout_tests/fast/dom/implementation-createHTMLDocument.html
+/sdcard/android/layout_tests/fast/dom/ImageDocument-image-deletion.html
+/sdcard/android/layout_tests/fast/dom/image-object.html
+/sdcard/android/layout_tests/fast/dom/iframe-document.html
+/sdcard/android/layout_tests/fast/dom/iframe-contentWindow-crash.html
+/sdcard/android/layout_tests/fast/dom/html-attribute-types.html
+/sdcard/android/layout_tests/fast/dom/getter-on-window-object2.html
+/sdcard/android/layout_tests/fast/dom/getter-on-window-object.html
+/sdcard/android/layout_tests/fast/dom/getelementbyname-invalidation.html
+/sdcard/android/layout_tests/fast/dom/generic-form-element-assert.html
+/sdcard/android/layout_tests/fast/dom/gc-7.html
+/sdcard/android/layout_tests/fast/dom/gc-6.html
+/sdcard/android/layout_tests/fast/dom/gc-5.html
+/sdcard/android/layout_tests/fast/dom/gc-4.html
+/sdcard/android/layout_tests/fast/dom/gc-3.html
+/sdcard/android/layout_tests/fast/dom/gc-2.html
+/sdcard/android/layout_tests/fast/dom/gc-11.html
+/sdcard/android/layout_tests/fast/dom/gc-1.html
+/sdcard/android/layout_tests/fast/dom/frame-contentWindow-crash.html
+/sdcard/android/layout_tests/fast/dom/features.html
+/sdcard/android/layout_tests/fast/dom/exception-no-frame-timeout-crash.html
+/sdcard/android/layout_tests/fast/dom/exception-no-frame-inline-script-crash.html
+/sdcard/android/layout_tests/fast/dom/everything-to-string.html
+/sdcard/android/layout_tests/fast/dom/element-attribute-js-null.html
+/sdcard/android/layout_tests/fast/dom/early-frame-url.html
+/sdcard/android/layout_tests/fast/dom/duplicate-ids.html
+/sdcard/android/layout_tests/fast/dom/duplicate-ids-document-order.html
+/sdcard/android/layout_tests/fast/dom/DOMParser-assign-variable.html
+/sdcard/android/layout_tests/fast/dom/domListEnumeration.html
+/sdcard/android/layout_tests/fast/dom/dom-instanceof.html
+/sdcard/android/layout_tests/fast/dom/documenturi-loses-to-base-tag.html
+/sdcard/android/layout_tests/fast/dom/documenturi-assigned-junk-implies-relative-urls-do-not-resolve.html
+/sdcard/android/layout_tests/fast/dom/documenturi-assigned-junk-implies-baseuri-null.html
+/sdcard/android/layout_tests/fast/dom/documenturi-affects-relative-paths.html
+/sdcard/android/layout_tests/fast/dom/documentElement-null.html
+/sdcard/android/layout_tests/fast/dom/document-scripts.html
+/sdcard/android/layout_tests/fast/dom/document-dir-property.html
+/sdcard/android/layout_tests/fast/dom/document-attribute-js-null.html
+/sdcard/android/layout_tests/fast/dom/document-all-select.html
+/sdcard/android/layout_tests/fast/dom/document-all-input.html
+/sdcard/android/layout_tests/fast/dom/dir-no-body.html
+/sdcard/android/layout_tests/fast/dom/destroy-selected-radio-button-crash.html
+/sdcard/android/layout_tests/fast/dom/defaultView.html
+/sdcard/android/layout_tests/fast/dom/css-shortHands.html
+/sdcard/android/layout_tests/fast/dom/css-set-property-exception.html
+/sdcard/android/layout_tests/fast/dom/css-selectorText.html
+/sdcard/android/layout_tests/fast/dom/css-RGBValue.html
+/sdcard/android/layout_tests/fast/dom/css-mediarule-functions.html
+/sdcard/android/layout_tests/fast/dom/css-element-attribute-js-null.html
+/sdcard/android/layout_tests/fast/dom/css-dom-read.html
+/sdcard/android/layout_tests/fast/dom/css-dom-read-2.html
+/sdcard/android/layout_tests/fast/dom/createElementNS.html
+/sdcard/android/layout_tests/fast/dom/createElement.html
+/sdcard/android/layout_tests/fast/dom/createElement-with-column.xml
+/sdcard/android/layout_tests/fast/dom/createElement-with-column.html
+/sdcard/android/layout_tests/fast/dom/createDocumentType2.html
+/sdcard/android/layout_tests/fast/dom/createDocument.html
+/sdcard/android/layout_tests/fast/dom/createDocument-empty.html
+/sdcard/android/layout_tests/fast/dom/createAttribute-exception.html
+/sdcard/android/layout_tests/fast/dom/constructors-overriding.html
+/sdcard/android/layout_tests/fast/dom/constants.html
+/sdcard/android/layout_tests/fast/dom/computed-style-set-property.html
+/sdcard/android/layout_tests/fast/dom/compatMode-Strict.html
+/sdcard/android/layout_tests/fast/dom/compatMode-Compat.html
+/sdcard/android/layout_tests/fast/dom/compatMode-AlmostStrict.html
+/sdcard/android/layout_tests/fast/dom/comment-dom-node.html
+/sdcard/android/layout_tests/fast/dom/comment-document-fragment.html
+/sdcard/android/layout_tests/fast/dom/collection-null-like-arguments.html
+/sdcard/android/layout_tests/fast/dom/collection-namedItem-via-item.html
+/sdcard/android/layout_tests/fast/dom/clone-node-style.html
+/sdcard/android/layout_tests/fast/dom/clone-node-form-elements.html
+/sdcard/android/layout_tests/fast/dom/clone-node-form-elements-with-attr.html
+/sdcard/android/layout_tests/fast/dom/class-all-whitespace.html
+/sdcard/android/layout_tests/fast/dom/capturing-event-listeners.html
+/sdcard/android/layout_tests/fast/dom/canvasContext2d-element-attribute-js-null.html
+/sdcard/android/layout_tests/fast/dom/background-shorthand-csstext.html
+/sdcard/android/layout_tests/fast/dom/attribute-namespaces-get-set.html
+/sdcard/android/layout_tests/fast/dom/attribute-empty-value-no-children.html
+/sdcard/android/layout_tests/fast/dom/attribute-downcast-right.html
+/sdcard/android/layout_tests/fast/dom/attribute-case-sensitivity.html
+/sdcard/android/layout_tests/fast/dom/array-special-accessors-should-ignore-items.html
+/sdcard/android/layout_tests/fast/dom/anchor-toString.html
+/sdcard/android/layout_tests/fast/dom/anchor-backslash.html
+/sdcard/android/layout_tests/fast/doctypes/html-doctype.html
+/sdcard/android/layout_tests/fast/doctypes/doctype-parsing.html
+/sdcard/android/layout_tests/fast/doctypes/doctype-in-element.html
+/sdcard/android/layout_tests/fast/doctypes/doctype-at-end.html
+/sdcard/android/layout_tests/fast/doctypes/doctype-after-comment.html
+/sdcard/android/layout_tests/fast/doctypes/005-case-preserving.html
+/sdcard/android/layout_tests/fast/css-generated-content/reset-content-to-initial.html
+/sdcard/android/layout_tests/fast/css-generated-content/empty-content-with-float-crash.html
+/sdcard/android/layout_tests/fast/css/variables/invalid-identifier.html
+/sdcard/android/layout_tests/fast/css/counters/counter-number-input.html
+/sdcard/android/layout_tests/fast/css/counters/counter-function-input.html
+/sdcard/android/layout_tests/fast/css/counters/counter-function-input-2.html
+/sdcard/android/layout_tests/fast/css/word-break-user-modify-allowed-values.html
+/sdcard/android/layout_tests/fast/css/transition_shorthand_parsing.html
+/sdcard/android/layout_tests/fast/css/transition-timing-function.html
+/sdcard/android/layout_tests/fast/css/transform-function-lowercase-assert.html
+/sdcard/android/layout_tests/fast/css/stale-style-selector-crash-2.html
+/sdcard/android/layout_tests/fast/css/stale-style-selector-crash-1.html
+/sdcard/android/layout_tests/fast/css/sheet-title.html
+/sdcard/android/layout_tests/fast/css/remove-shorthand.html
+/sdcard/android/layout_tests/fast/css/readonly-pseudoclass-opera-005.html
+/sdcard/android/layout_tests/fast/css/readonly-pseudoclass-opera-004.html
+/sdcard/android/layout_tests/fast/css/readonly-pseudoclass-opera-003.html
+/sdcard/android/layout_tests/fast/css/readonly-pseudoclass-opera-002.html
+/sdcard/android/layout_tests/fast/css/readonly-pseudoclass-opera-001.html
+/sdcard/android/layout_tests/fast/css/pseudostyle-anonymous-text.html
+/sdcard/android/layout_tests/fast/css/parse-timing-function-crash.html
+/sdcard/android/layout_tests/fast/css/padding-no-renderer.html
+/sdcard/android/layout_tests/fast/css/overflow-property.html
+/sdcard/android/layout_tests/fast/css/outline-hidden-illegal-value.html
+/sdcard/android/layout_tests/fast/css/orphaned_units_crash.html
+/sdcard/android/layout_tests/fast/css/nested-rule-parent-sheet.html
+/sdcard/android/layout_tests/fast/css/min-device-aspect-ratio.html
+/sdcard/android/layout_tests/fast/css/media-rule-dyn.html
+/sdcard/android/layout_tests/fast/css/max-height-and-max-width.html
+/sdcard/android/layout_tests/fast/css/max-device-aspect-ratio.html
+/sdcard/android/layout_tests/fast/css/legacy-opacity-styles.html
+/sdcard/android/layout_tests/fast/css/invalid-rule-value.html
+/sdcard/android/layout_tests/fast/css/invalid-cursor-property-crash.html
+/sdcard/android/layout_tests/fast/css/insertRule-media.html
+/sdcard/android/layout_tests/fast/css/insertRule-font-face.html
+/sdcard/android/layout_tests/fast/css/import-style-update.html
+/sdcard/android/layout_tests/fast/css/hexColor-isDigit-assert.html
+/sdcard/android/layout_tests/fast/css/getPropertyValue-clip.html
+/sdcard/android/layout_tests/fast/css/getPropertyValue-border.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-zIndex-auto.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-relayout.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-borderRadius.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-border-spacing.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-border-image.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-border-box.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-background-size.html
+/sdcard/android/layout_tests/fast/css/getComputedStyle-background-position.html
+/sdcard/android/layout_tests/fast/css/font-property-priority.html
+/sdcard/android/layout_tests/fast/css/font-family-initial.html
+/sdcard/android/layout_tests/fast/css/font-face-multiple-families.html
+/sdcard/android/layout_tests/fast/css/font-face-descriptor-multiple-values-parsing.html
+/sdcard/android/layout_tests/fast/css/emptyStyleTag.html
+/sdcard/android/layout_tests/fast/css/empty-script.html
+/sdcard/android/layout_tests/fast/css/display-none-inline-style-change-crash.html
+/sdcard/android/layout_tests/fast/css/device-aspect-ratio.html
+/sdcard/android/layout_tests/fast/css/dashboard-regions-attr-crash.html
+/sdcard/android/layout_tests/fast/css/CSSPrimitiveValue-exceptions.html
+/sdcard/android/layout_tests/fast/css/css-selector-text.html
+/sdcard/android/layout_tests/fast/css/css-properties-case-insensitive.html
+/sdcard/android/layout_tests/fast/css/computed-style-negative-top.html
+/sdcard/android/layout_tests/fast/css/computed-style-display-none.html
+/sdcard/android/layout_tests/fast/css/child-selector-implicit-tbody.html
+/sdcard/android/layout_tests/fast/css/case-transform.html
+/sdcard/android/layout_tests/fast/css/border-image-crash.html
+/sdcard/android/layout_tests/fast/css/background-position-serialize.html
+/sdcard/android/layout_tests/fast/css/background-position-inherit.html
+/sdcard/android/layout_tests/fast/css/background-currentcolor.html
+/sdcard/android/layout_tests/fast/cookies/local-file-can-set-cookies.html
+/sdcard/android/layout_tests/fast/canvas/unclosed-canvas-4.html
+/sdcard/android/layout_tests/fast/canvas/unclosed-canvas-3.html
+/sdcard/android/layout_tests/fast/canvas/unclosed-canvas-2.html
+/sdcard/android/layout_tests/fast/canvas/unclosed-canvas-1.html
+/sdcard/android/layout_tests/fast/canvas/toDataURL-noData.html
+/sdcard/android/layout_tests/fast/canvas/script-inside-canvas-fallback.html
+/sdcard/android/layout_tests/fast/canvas/radialGradient-infinite-values.html
+/sdcard/android/layout_tests/fast/canvas/pointInPath.html
+/sdcard/android/layout_tests/fast/canvas/linearGradient-infinite-values.html
+/sdcard/android/layout_tests/fast/canvas/pattern-with-transform.html
+/sdcard/android/layout_tests/fast/canvas/gradient-with-clip.html
+/sdcard/android/layout_tests/fast/canvas/gradient-addColorStop-with-invalid-color.html
+/sdcard/android/layout_tests/fast/canvas/drawImage-with-negative-source-destination.html
+/sdcard/android/layout_tests/fast/canvas/drawImage-with-invalid-args.html
+/sdcard/android/layout_tests/fast/canvas/create-pattern-does-not-crash.html
+/sdcard/android/layout_tests/fast/canvas/canvas-with-incorrect-args.html
+/sdcard/android/layout_tests/fast/canvas/canvas-putImageData.html
+/sdcard/android/layout_tests/fast/canvas/canvas-pattern-behaviour.html
+/sdcard/android/layout_tests/fast/canvas/canvas-path-with-inf-nan-dimensions.html
+/sdcard/android/layout_tests/fast/canvas/canvas-invalid-strokestyle.html
+/sdcard/android/layout_tests/fast/canvas/canvas-invalid-fillstyle.html
+/sdcard/android/layout_tests/fast/canvas/canvas-ImageData-behaviour.html
+/sdcard/android/layout_tests/fast/canvas/canvas-hides-fallback.html
+/sdcard/android/layout_tests/fast/canvas/arc-crash.html
+/sdcard/android/layout_tests/fast/canvas/access-zero-sized-canvas.html
diff --git a/tests/DumpRenderTree/run_layout_tests.py b/tests/DumpRenderTree/run_layout_tests.py
new file mode 100755
index 0000000..b4eb685
--- /dev/null
+++ b/tests/DumpRenderTree/run_layout_tests.py
@@ -0,0 +1,176 @@
+#!/usr/bin/python
+
+"""Run layout tests using Android emulator and instrumentation.
+
+  First, you need to get an SD card or sdcard image that has layout tests on it.
+  Layout tests are in following directory:
+    /sdcard/android/layout_tests
+  For example, /sdcard/android/layout_tests/fast
+
+  Usage:
+    Run all tests under fast/ directory:
+      run_layout_tests.py, or
+      run_layout_tests.py fast
+
+    Run all tests under a sub directory:
+      run_layout_tests.py fast/dom
+
+    Run a single test:
+      run_layout_tests.py fast/dom/
+
+  After a merge, if there are changes of layout tests in SD card, you need to
+  use --refresh-test-list option *once* to re-generate test list on the card.
+
+  Some other options are:
+    --time-out-ms (default is 8000 millis) for each test
+    --adb-options="-e" passes option string to adb
+    --results-directory=..., (default is ./layout-test-results) directory name under which results are stored.
+"""
+
+import logging
+import optparse
+import os
+import subprocess
+import sys
+import time
+
+def CountLineNumber(filename):
+  """Compute the number of lines in a given file.
+
+  Args:
+    filename: a file name related to the current directory.
+  """
+
+  fp = open(os.path.abspath(filename), "r");
+  lines = 0
+  for line in fp.readlines():
+    lines = lines + 1
+  fp.close()
+  return lines
+
+def main(options, args):
+  """Run the tests. Will call sys.exit when complete.
+  
+  Args:
+    options: a dictionary of command line options
+    args: a list of sub directories or files to test
+  """
+
+  # 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 = 'fast';
+  else:
+    path = ' '.join(args);
+
+  adb_cmd = "adb ";
+  if options.adb_options:
+    adb_cmd += options.adb_options
+
+  # Re-generate the test list if --refresh-test-list is on
+  if options.refresh_test_list:
+    logging.info("Generating test list.");
+    shell_cmd_str = adb_cmd + " shell am instrument -e class com.android.dumprendertree.LayoutTestsAutoTest#generateTestList -e path fast -w com.android.dumprendertree/.LayoutTestsAutoRunner"
+    adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
+
+    if adb_output.find('Process crashed') != -1:
+       logging.info("Aborting because cannot generate test list.\n" + adb_output)
+       sys.exit(1)
+
+
+  logging.info("Starting tests")
+
+  # Count crashed tests.
+  crashed_tests = []
+
+  timeout_ms = '8000'
+  if options.time_out_ms:
+    timeout_ms = options.time_out_ms
+
+  # Run test until it's done
+
+  # Call LayoutTestsAutoTest::startLayoutTests.
+  shell_cmd_str = adb_cmd + " shell am instrument -e class com.android.dumprendertree.LayoutTestsAutoTest#startLayoutTests -e path \"" + path + "\" -e timeout " + timeout_ms + " -w com.android.dumprendertree/.LayoutTestsAutoRunner"
+  adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
+  while adb_output.find('Process crashed') != -1:
+    # Get the running_test.txt
+    logging.error("DumpRenderTree crashed, output:\n" + adb_output)
+
+    shell_cmd_str = adb_cmd + " shell cat /sdcard/running_test.txt"
+    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 layout test runner...");
+    # Call LayoutTestsAutoTest::resumeLayoutTests
+    shell_cmd_str = adb_cmd + " shell am instrument -e class com.android.dumprendertree.LayoutTestsAutoTest#resumeLayoutTests -e path \"" + path + "\" -e timeout " + timeout_ms + " -w com.android.dumprendertree/.LayoutTestsAutoRunner"
+
+    adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
+
+  if adb_output.find('INSTRUMENTATION_FAILED') != -1:
+    logging.error("Error happened : " + adb_output)
+    sys.exit(1)
+
+  logging.info("Done");
+  logging.debug(adb_output);
+
+  # Pull results from /sdcard
+  results_dir = options.results_directory
+  if not os.path.exists(results_dir):
+    os.makedirs(results_dir)
+  if not os.path.isdir(results_dir):
+    logging.error("Cannot create results dir: " + results_dir);
+    sys.exit(1);
+
+  result_files = ["/sdcard/layout_tests_passed.txt",
+                  "/sdcard/layout_tests_failed.txt",
+                  "/sdcard/layout_tests_nontext.txt"]
+  for file in result_files: 
+    shell_cmd_str = adb_cmd + " pull " + file + " " + results_dir
+    adb_output = subprocess.Popen(shell_cmd_str, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
+    logging.debug(adb_output)
+    
+  # Create the crash list.
+  fp = open(results_dir + "/layout_tests_crashed.txt", "w");
+  fp.writelines(crashed_tests)
+  fp.close()
+
+  # Count the number of tests in each category.
+  passed_tests = CountLineNumber(results_dir + "/layout_tests_passed.txt")
+  logging.info(str(passed_tests) + " passed")
+  failed_tests = CountLineNumber(results_dir + "/layout_tests_failed.txt")
+  logging.info(str(failed_tests) + " failed")
+  crashed_tests = CountLineNumber(results_dir + "/layout_tests_crashed.txt")
+  logging.info(str(crashed_tests) + " crashed")
+  nontext_tests = CountLineNumber(results_dir + "/layout_tests_nontext.txt")
+  logging.info(str(nontext_tests) + " no dumpAsText")
+
+  logging.info("Results are stored under: " + results_dir)
+
+
+if '__main__' == __name__:
+  option_parser = optparse.OptionParser()
+  option_parser.add_option("", "--time-out-ms",
+                           default=None,
+                           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("", "--refresh-test-list", action="store_true",
+                           default=False,
+                           help="re-generate test list, it may take some time.")
+  option_parser.add_option("", "--adb-options",
+                           default=None,
+                           help="pass options to adb, such as -d -e, etc");
+  option_parser.add_option("", "--results-directory",
+                           default="layout-test-results",
+                           help="directory name under which results are stored.")
+  options, args = option_parser.parse_args();
+  main(options, args)
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
index 91597d5..9be33db 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FileFilter.java
@@ -24,13 +24,19 @@
 
     public static boolean ignoreTest(String file) {
       // treat files like directories for the time being.
-      int size = ignoreTestList.length;
-      for (int i = 0; i < size; i ++) {
-          if (file.startsWith(ignoreTestList[i])) {
+      for (int i = 0; i < ignoreTestList.length; i ++) {
+          if (file.endsWith(ignoreTestList[i])) {
              Log.e("FileFilter", "File path in IgnoreTest: " + file); 
              return true;
           }
       }
+      for (int i = 0; i < ignoreTestDirs.length; i++) {
+          if (file.endsWith(ignoreTestDirs[i])) {
+              Log.e("FileFilter", "File path in ignore list: " + file);
+              return true;
+          }
+      }
+      
       return false;
     }
  
@@ -64,8 +70,8 @@
         fillIgnoreResultSet();
         fillBugTable();
     }
- 
-    static final String [] ignoreTestList = {
+
+    static final String[] ignoreTestDirs = {
         ".", // ignore hidden directories and files
         "resources", // ignore resource directories
         "AppleScript", // AppleScript not supported
@@ -73,13 +79,16 @@
         "xsl", //xsl requires libxml2 & libxslt, not sup.
         "kde", // don't run kde tests.
         ".svn", // don't run anything under .svn folder
-        "gradients", //known crash
+        "gradients", // known crash
+        "profiler"  // profiler is not supported
+    };
+        
+    static final String [] ignoreTestList = {
         "toString-stack-overflow.html", // Crashes #606688
         "frame-limit.html", // generates too many GREFs
         "css-insert-import-rule.html", // Crashes, #717414
         "input-text-enter.html", // Crashes. #735088
         "text-shadow-extreme-value.html", // Crashes #571671
-        "001.html",
         "reflection-masks.html",
         "frame-creation-removal.html",
         "large-expressions.html",
@@ -203,6 +212,8 @@
         ignoreResultList.add("fast/loader/local-iFrame-source-from-local.html");
         // extra spacing because iFrames rendered next to each other on Apple
         ignoreResultList.add("fast/loader/opaque-base-url.html");
+        // RegExp is too large, causing OOM
+        ignoreResultList.add("fast/js/regexp-charclass-crash.html");
         ignoreResultList.add("fast/text/plain-text-line-breaks.html");
         
         
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
index 8b33d16..d685f5d 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FileList.java
@@ -117,9 +117,14 @@
     {
     	Map map = (Map) l.getItemAtPosition(position);
     	String path = (String)map.get("path");
-    	if (path.length() > 0)
-    	    processFile(path, true);
 
+        if ((new File(path)).isDirectory()) {
+            mPath = path;
+            mFocusFile = null;
+            updateList();
+        } else {
+            processFile(path, false);
+        }
     }
     
     /*
@@ -148,7 +153,7 @@
     
     protected void setupPath() 
     {
-    	mPath = "/sdcard";
+    	mPath = "/sdcard/android/layout_tests";
     	mBaseLength = mPath.length();
     }
     
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java
index 9521f80..c77d98a 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/HTMLHostActivity.java
@@ -16,14 +16,16 @@
 
 package com.android.dumprendertree;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.BufferedOutputStream;
 import java.io.FileInputStream;
+import java.io.FileReader;
 import java.io.IOException;
+import java.util.List;
 import java.util.Vector;
-import java.util.Stack;
 
 import android.app.Activity;
 import android.content.Intent;
@@ -38,14 +40,12 @@
 import android.webkit.WebView;
 import android.widget.LinearLayout;
 import android.os.*;
-import android.test.TestRecorder;
 
-// SQLite3 in android has a bunch of bugs which
-// is causing TestRecorder to not record the results
-// properly. This class is a wrapper around it and records
-// results in a file as well.
-class TestRecorderV2 extends TestRecorder {
-    @Override
+// TestRecorder creates two files, one for passing tests
+// and another for failing tests and writes the paths to
+// layout tests one line at a time. TestRecorder does not
+// have ability to clear the results.
+class TestRecorder {
     public void passed(String layout_file) {
       try {
           mBufferedOutputPassedStream.write(layout_file.getBytes());
@@ -54,72 +54,68 @@
       } catch(Exception e) {
           e.printStackTrace();
       }
-      super.passed(layout_file);
    }
 
-    @Override
     public void failed(String layout_file, String reason) {
       try {
           mBufferedOutputFailedStream.write(layout_file.getBytes());
+          mBufferedOutputFailedStream.write(" : ".getBytes());
+          mBufferedOutputFailedStream.write(reason.getBytes());
           mBufferedOutputFailedStream.write('\n');
           mBufferedOutputFailedStream.flush();
       } catch(Exception e) {
           e.printStackTrace();
       }
-      super.failed(layout_file, reason);
     }
 
-    public TestRecorderV2() {
-      super();
+    public void nontext(String layout_file) {
       try {
-      File resultsPassedFile = new File("/sdcard/layout_test_presults.txt");
-      File resultsFailedFile = new File("/sdcard/layout_test_fresults.txt");
+          mBufferedOutputNontextStream.write(layout_file.getBytes());
+          mBufferedOutputNontextStream.write('\n');
+          mBufferedOutputNontextStream.flush();
+      } catch(Exception e) {
+          e.printStackTrace();
+      }
+    }
+
+    public TestRecorder(boolean resume) {
+      try {
+      File resultsPassedFile = new File("/sdcard/layout_tests_passed.txt");
+      File resultsFailedFile = new File("/sdcard/layout_tests_failed.txt");
+      File resultsNontextFile = new File("/sdcard/layout_tests_nontext.txt");
  
       mBufferedOutputPassedStream =
-          new BufferedOutputStream(new FileOutputStream(resultsPassedFile, true));
+          new BufferedOutputStream(new FileOutputStream(resultsPassedFile, resume));
       mBufferedOutputFailedStream =
-          new BufferedOutputStream(new FileOutputStream(resultsFailedFile, true));
- 
+          new BufferedOutputStream(new FileOutputStream(resultsFailedFile, resume));
+      mBufferedOutputNontextStream =
+          new BufferedOutputStream(new FileOutputStream(resultsNontextFile, resume));
       } catch (Exception e) {
           e.printStackTrace();
       }
     }
-    
-    protected void finalize() throws Throwable {
-        mBufferedOutputPassedStream.flush();
-        mBufferedOutputFailedStream.flush();
-        mBufferedOutputPassedStream.close();
-        mBufferedOutputFailedStream.close();
-    }
 
-    private static BufferedOutputStream mBufferedOutputPassedStream;
-    private static BufferedOutputStream mBufferedOutputFailedStream;
+    public void close() {
+        try {
+            mBufferedOutputPassedStream.close();
+            mBufferedOutputFailedStream.close();
+            mBufferedOutputNontextStream.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    private BufferedOutputStream mBufferedOutputPassedStream;
+    private BufferedOutputStream mBufferedOutputFailedStream;
+    private BufferedOutputStream mBufferedOutputNontextStream;
 }
 
 public class HTMLHostActivity extends Activity 
      implements LayoutTestController {
- 
-    private TestRecorderV2 mResultRecorder = new TestRecorderV2();
-    private HTMLHostCallbackInterface mCallback = null;
-    private CallbackProxy mCallbackProxy;
-
-    public class FileEntry {
-        public FileEntry(String path, int index) {
-            mPath = path; mIndex=index;
-        }
-        String mPath;
-        int mIndex;
-    }
 
     public class AsyncHandler extends Handler {
         @Override
         public void handleMessage(Message msg) {
-            if (msg.what == MSG_DUMP) {
-                this.removeMessages(MSG_TIMEOUT);
-                mTimedOut = false;
-                requestWebKitData();
-                return;
-            } else if (msg.what == MSG_TIMEOUT) {
+            if (msg.what == MSG_TIMEOUT) {
                 mTimedOut = true;
                 requestWebKitData();
                 return;
@@ -127,21 +123,24 @@
                 HTMLHostActivity.this.dump(mTimedOut, (String)msg.obj);
                 return;
             }
-            
+
             super.handleMessage(msg);
         }
-
-        void requestWebKitData() {
-            Message callback = obtainMessage(MSG_WEBKIT_DATA);
-            if (dumpAsText) { 
-                mWebView.documentAsText(callback);
-            } else {
-                mWebView.externalRepresentation(callback);
-            }
-        }
-
     }
 
+    public void requestWebKitData() {
+        Message callback = mHandler.obtainMessage(MSG_WEBKIT_DATA);
+        
+        if (mRequestedWebKitData)
+            throw new AssertionError("Requested webkit data twice: " + mWebView.getUrl());
+        
+        mRequestedWebKitData = true;
+        if (mDumpAsText) { 
+            mWebView.documentAsText(callback);
+        } else {
+            mWebView.externalRepresentation(callback);
+        }
+    }
     // Activity methods
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
@@ -153,8 +152,9 @@
         mWebView = new WebView(this);
         mWebView.getSettings().setJavaScriptEnabled(true);
         mWebView.setWebChromeClient(mChromeClient);
-        eventSender = new WebViewEventSender(mWebView);
-        mCallbackProxy = new CallbackProxy(eventSender, this);
+        mEventSender = new WebViewEventSender(mWebView);
+        mCallbackProxy = new CallbackProxy(mEventSender, this);
+        mFinishedRunning = false;
 
         mWebView.addJavascriptInterface(mCallbackProxy, "layoutTestController");
         mWebView.addJavascriptInterface(mCallbackProxy, "eventSender");
@@ -168,32 +168,99 @@
         super.onRestoreInstanceState(savedInstanceState);
     }
 
+    private void getTestList() {
+        // Read test list.
+        try {
+            BufferedReader inReader = new BufferedReader(new FileReader(LAYOUT_TESTS_LIST_FILE));
+            String line = inReader.readLine();
+            while (line != null) {
+                if (line.startsWith(mTestPathPrefix))
+                    mTestList.add(line);
+                line = inReader.readLine();
+            }
+            inReader.close();
+            Log.v(LOGTAG, "Test list has " + mTestList.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 stoped last time.
+        try {
+            BufferedReader inReader = new BufferedReader(new FileReader(TEST_STATUS_FILE));
+            String line = inReader.readLine();
+            for (int i = 0; i < mTestList.size(); i++) {
+                if (mTestList.elementAt(i).equals(line)) {
+                    mTestList = new Vector<String>(mTestList.subList(i+1, mTestList.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 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);
+        }
+    }
+    
     protected void onResume() {
         super.onResume();
-        if (mProcessStack == null || mProcessStack.isEmpty() ) {
-            mOutstandingLoads = 0;
-            dumpAsText = false;
-            pageComplete = false;
-
-            mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
-
-            mFinishedStack = new Stack();
-
+        if (mTestList == null)
+            mTestList = new Vector<String>();
+        
+        if (mTestList.isEmpty()) {
+            // Read settings
             Intent intent = getIntent();
-            if (intent.getData() != null) {
-                File f = new File(intent.getData().toString());
+            mTestPathPrefix = intent.getStringExtra(TEST_PATH_PREFIX);
+            mSingleTestMode = intent.getBooleanExtra(SINGLE_TEST_MODE, false);
+            boolean resume = intent.getBooleanExtra(RESUME_FROM_CRASH, false);
+            mTimeoutInMillis = intent.getIntExtra(TIMEOUT_IN_MILLIS, 8000);
+            
+            mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
+            
+            if (mTestPathPrefix == null)
+                throw new AssertionError("mTestPathPrefix cannot be null");
+            
+            Log.v(LOGTAG, "Run tests with prefix: " + mTestPathPrefix);
 
-                if (f.isDirectory()) {
-                    mProcessStack = new Vector();
-                    mProcessStack.add(new FileEntry(intent.getData().toString(), 0));
-                    Log.v(LOGTAG, "Initial dir: "+intent.getData().toString());
-                    loadNextPage();
-                } else {
-                    mCurrentFile = intent.getData().toString();
-                    mWebView.loadUrl("file://"+intent.getData().toString());
-                }
-
+            mResultRecorder = new TestRecorder(resume);
+            
+            if (!resume)
+                clearTestStatus();
+            
+            if (!mSingleTestMode) {
+                getTestList();
+                if (resume)
+                    resumeTestList();
+            } else {
+                mTestList.add(mTestPathPrefix);
             }
+            
+            if (!mTestList.isEmpty())
+                runTestAtIndex(0);
             else
                 mWebView.loadUrl("about:");
         }
@@ -206,9 +273,17 @@
 
     protected void onDestroy() {
         super.onDestroy();
+        mResultRecorder.close();
         mWebView.destroy();
         mWebView = null;
     }
+    
+    public void onLowMemory() {
+        super.onLowMemory();
+        // Simulate a crash
+        Log.e(LOGTAG, "Low memory, killing self");
+        System.exit(1);
+    }
 
     public boolean dispatchKeyEvent(KeyEvent event) {
         // Log key strokes as they don't seem to be matched
@@ -216,82 +291,51 @@
         return super.dispatchKeyEvent(event);
     }
 
-    // Functions
-    
-    protected void loadNextPage() {
-        dumpAsText = false;
-        pageComplete = false;
-        dumpTitleChanges = false;
-        eventSender.resetMouse();
-        while (!mProcessStack.isEmpty()) {
-            FileEntry fe = (FileEntry)mProcessStack.remove(0);
-            if (fe.mIndex == 0) {
-                System.out.println();
-                System.out.print(fe.mPath);
-            }
-            Log.v(LOGTAG, "Processing dir: "+fe.mPath+" size: "+mProcessStack.size());
-            File f = new File(fe.mPath);
-            String [] files = f.list();
-            for (int i = fe.mIndex; i < files.length; i++) {
-                if (FileFilter.ignoreTest(files[i])) {
-                    continue;
-                }
-                File c = new File(f.getPath(), files[i]);
-                if (c.isDirectory()) {
-                    Log.v(LOGTAG, "Adding dir: "+fe.mPath+"/"+files[i]);
-                    mProcessStack.add(new FileEntry(fe.mPath+"/"+files[i], 0));
-                } else if (files[i].toLowerCase().endsWith("ml")) {
-                    mProcessStack.add(0, new FileEntry(fe.mPath, i+1));
-                    mCurrentFile = fe.mPath+"/"+files[i];
-                    Log.e(LOGTAG, "Processing: "+mCurrentFile);
-                    mWebView.loadUrl("file://"+mCurrentFile);
+    // Run a test at specified index in the test list.
+    // Stops activity if run out of tests.
+    protected void runTestAtIndex(int testIndex) {
+        mTestIndex = testIndex;
+        
+        resetTestStatus();
 
-                    // Create a timeout timer
-                    Message m = mHandler.obtainMessage(MSG_TIMEOUT);
-                    // Some tests can take up to 5secs to run.
-                    mHandler.sendMessageDelayed(m, 6000); 
-                    return;
-                }
-            }
-            Log.v(LOGTAG, "Finished dir: "+fe.mPath+" size: "+mProcessStack.size()); 
-        }
-        // If we got to here, then we must have finished completely
-        finished();
-    }
-    
-    public void scheduleDump() {
-        // Only schedule if we really are ready
-        if (waitToDump || mOutstandingLoads > 0 || mDumpRequested) {
+        if (testIndex == mTestList.size()) {
+            finished();
             return;
         }
-        mDumpRequested = true;
-        mHandler.obtainMessage(MSG_DUMP).sendToTarget();
+        String s = mTestList.elementAt(testIndex);
+        if (!mSingleTestMode)
+            updateTestStatus(s);
+        
+        Log.v(LOGTAG, "  Running test: "+s);
+        mWebView.loadUrl("file://"+s);
+        
+        if (!mSingleTestMode) {
+            // Create a timeout timer
+            Message m = mHandler.obtainMessage(MSG_TIMEOUT);
+            mHandler.sendMessageDelayed(m, mTimeoutInMillis);
+        }
     }
-    
+
     // Dump the page
     public void dump(boolean timeout, String webkitData) {
-        mDumpRequested = false;
-        System.out.print('.');
-
-        // remove the extension
-        String resultFile = mCurrentFile.substring(0, mCurrentFile.lastIndexOf('.'));
-
-        // store the finished file on the stack so that we can do a diff at the end.
-        mFinishedStack.push(resultFile);
+        String currentTest = mTestList.elementAt(mTestIndex);
+        String resultFile = currentTest.substring(0, currentTest.lastIndexOf('.'));
 
         // dumpAsText version can be directly compared to expected results
-        if (dumpAsText) {
+        if (mDumpAsText) {
             resultFile += "-results.txt";
         } else {
             resultFile += "-android-results.txt";
         }
+
         try {
             FileOutputStream os = new FileOutputStream(resultFile);
             if (timeout) {
-                Log.i("Layout test: Timeout", resultFile);
-                os.write("**Test timeout\n".getBytes());
+                Log.w("Layout test: Timeout", resultFile);
+                os.write(TIMEOUT_STR.getBytes());
+                os.write('\n');
             }
-            if (dumpTitleChanges)
+            if (mDumpTitleChanges)
                 os.write(mTitleChanges.toString().getBytes());
             if (mDialogStrings != null)
                 os.write(mDialogStrings.toString().getBytes());
@@ -305,18 +349,15 @@
             ex.printStackTrace();
         }
 
-        if (mProcessStack != null)
-            loadNextPage();
-        else
-            finished();
+        processResult(timeout, currentTest);
+        runTestAtIndex(mTestIndex + 1);
     }
 
     // Wrap up
     public void failedCase(String file, String reason) {
-        Log.i("Layout test:", file + " failed" + reason);
+        Log.w("Layout test: ", file + " failed " + reason);
         mResultRecorder.failed(file, reason);
- 
-        file = file + ".html";
+
         String bugNumber = FileFilter.isKnownBug(file);
         if (bugNumber != null) {
             System.out.println("FAIL known:"+bugNumber+ " "+file+reason);
@@ -327,13 +368,11 @@
         }
         System.out.println("FAIL: "+file+reason);        
     }
- 
+
     public void passedCase(String file) {
-        // Add the result to the sqlite database
-        Log.i("Layout test:", file + " passed");
+        Log.v("Layout test:", file + " passed");
         mResultRecorder.passed(file);
 
-        file = file + ".html";
         String bugNumber = FileFilter.isKnownBug(file);
         if (bugNumber != null) {
             System.out.println("Bug Fixed: "+bugNumber+ " "+file);
@@ -345,90 +384,105 @@
             return;
         }
     }
+
+    public void nontextCase(String file) {
+        Log.v("Layout test:", file + " nontext");
+        mResultRecorder.nontext(file);
+    }
  
     public void setCallback(HTMLHostCallbackInterface callback) {
         mCallback = callback;
     }
-        
-    public void finished() {
-        int passed = 0;
-        while (!mFinishedStack.empty()) {
-            Log.v(LOGTAG, "Comparing dump and reference");
-            String file = (String)mFinishedStack.pop();
 
-            // Only check results that we can check, ie dumpAsText results
-            String dumpFile = file + "-results.txt";
-            File f = new File(dumpFile);
-            if (f.exists()) {
-                try {
-                    FileInputStream fr = new FileInputStream(file+"-results.txt");
-                    FileInputStream fe = new FileInputStream(file+"-expected.txt");
-                    
-                    mResultRecorder.started(file);
-                    
-                    // If the length is different then they are different
-                    int diff = fe.available() - fr.available();
-                    if (diff > 1 || diff < 0) {
-                        failedCase(file, " different length");
-                        fr.close();
-                        fe.close();
-                        
-                        mResultRecorder.finished(file);                        
-                        continue;
-                    }
-                    byte[] br = new byte[fr.available()];
-                    byte[] be = new byte[fe.available()];
-                    fr.read(br);
-                    fe.read(be);
-                    boolean fail = false;
-                    for (int i = 0; i < br.length; i++) {
-                        if (br[i] != be[i]) {
-                            failedCase(file, "  @offset: "+i);
-                            fail = true;
-                            break;
-                        }
-                    }
-                    if (br.length != be.length && be[be.length-1] == '\n') {
-                        Log.d(LOGTAG, "Extra new line being ignore:" + file);
-                    }
+    public void processResult(boolean timeout, String test_path) {
+        Log.v(LOGTAG, "  Processing result: " + test_path);
+        // remove the extension
+        String short_file = test_path.substring(0, test_path.lastIndexOf('.'));
+        if (timeout) {
+            failedCase(test_path, "TIMEDOUT");
+            return;
+        }
+        // Only check results that we can check, ie dumpAsText results
+        String dumpFile = short_file + "-results.txt";
+        File f = new File(dumpFile);
+        if (f.exists()) {
+            try {
+                FileInputStream fr = new FileInputStream(short_file+"-results.txt");
+                FileInputStream fe = new FileInputStream(short_file+"-expected.txt");
+              
+                // If the length is different then they are different
+                int diff = fe.available() - fr.available();
+                if (diff > 1 || diff < 0) {
+                    failedCase(test_path, " different length");
                     fr.close();
                     fe.close();
-                    if (!fail) {
-                       passed++;
-                       passedCase(file);
-                    }
-                } catch (FileNotFoundException ex) {
-                    // TODO do something here
-                } catch (IOException ex) {
-                    // Failed on available() or read()
+                    return;
                 }
-                mResultRecorder.finished(file);
+                byte[] br = new byte[fr.available()];
+                byte[] be = new byte[fe.available()];
+                fr.read(br);
+                fe.read(be);
+                boolean fail = false;
+                for (int i = 0; i < br.length; i++) {
+                    if (br[i] != be[i]) {
+                        failedCase(test_path, "  @offset: "+i);
+                        fr.close();
+                        fe.close();
+                        return;
+                    }
+                }
+                if (br.length != be.length && be[be.length-1] == '\n') {
+                    Log.d(LOGTAG, "Extra new line being ignore:" + test_path);
+                }
+                fr.close();
+                fe.close();
+                passedCase(test_path);
+            } catch (FileNotFoundException ex) {
+              // TODO do something here
+            } catch (IOException ex) {
+              // Failed on available() or read()
             }
-        }                        
+            
+            return;
+        }
         
-        if (mCallback != null) {        
+        File nontext_result = new File(short_file + "-android-results.txt");
+        if (nontext_result.exists())
+            mResultRecorder.nontext(test_path);
+    }
+    
+    public void finished() {
+        if (mCallback != null) {
             mCallback.waitForFinish();
-        }  
-        
+        }
+
+        mFinishedRunning = true;
         finish();
     }
     
     // LayoutTestController Functions
     public void dumpAsText() {
-        dumpAsText = true;
-        String url = mWebView.getUrl();
-        Log.v(LOGTAG, "dumpAsText called:"+url);
-        if (url.length() > 60)
-            url = url.substring(60);
+        mDumpAsText = true;
+        if (mWebView != null) {
+            String url = mWebView.getUrl();
+            Log.v(LOGTAG, "dumpAsText called: "+url);
+        }
     }
 
     public void waitUntilDone() {
-        waitToDump = true;
+        mWaitUntilDone = true;
+        String url = mWebView.getUrl();
+        Log.v(LOGTAG, "waitUntilDone called: " + url);
     }
     public void notifyDone() {
-        waitToDump = false;
-        mChromeClient.onProgressChanged(mWebView, 100);
+        String url = mWebView.getUrl();
+        Log.v(LOGTAG, "notifyDone called: " + url);
+        if (mWaitUntilDone) {
+            mWaitUntilDone = false;
+            mChromeClient.onProgressChanged(mWebView, 100);
+        }
     }
+    
     public void display() {
         mWebView.invalidate();
     }
@@ -461,18 +515,17 @@
     }
 
     public void dumpTitleChanges() {
-        if (!dumpTitleChanges) {
+        if (!mDumpTitleChanges) {
             mTitleChanges = new StringBuffer();
         }
-        dumpTitleChanges = true;
+        mDumpTitleChanges = true;
     }
 
     public void keepWebHistory() {
-        if (!keepWebHistory) {
+        if (!mKeepWebHistory) {
             mWebHistory = new Vector();
         }
-        keepWebHistory = true;
-
+        mKeepWebHistory = true;
     }
 
     public void queueBackNavigation(int howfar) {
@@ -491,7 +544,7 @@
     }
 
     public void queueReload() {
-        mWebView.reload();      
+        mWebView.reload();
     }
 
     public void queueScript(String scriptToRunInCurrentContext) {
@@ -520,33 +573,36 @@
     }
 
     public void testRepaint() {
-        mWebView.invalidate();     
+        mWebView.invalidate();
     }
 
     // Instrumentation calls this to find
     // if the activity has finished running the layout tests
+    // TODO(fqian): need to sync on mFinisheRunning
     public boolean hasFinishedRunning() {
-        if( mProcessStack == null || mFinishedStack == null)
-            return false;
-
-        if (mProcessStack.isEmpty() && mFinishedStack.empty()) {
-            return true;
-        }
-
-        return false;
+        return mFinishedRunning;
     }
-
+    
     private final WebChromeClient mChromeClient = new WebChromeClient() {
         @Override
         public void onProgressChanged(WebView view, int newProgress) {
             if (newProgress == 100) {
-                pageComplete = true;
-                String url = mWebView.getUrl();
-                if (url != null) {
+                if (!mSingleTestMode && !mTimedOut && !mWaitUntilDone && !mRequestedWebKitData) {
+                    String url = mWebView.getUrl();
                     Log.v(LOGTAG, "Finished: "+ url);
-                    if (url.length() > 60)
-                        url = url.substring(60);
-                    scheduleDump();
+                    mHandler.removeMessages(MSG_TIMEOUT);
+                    requestWebKitData();
+                } else {
+                    String url = mWebView.getUrl();
+                    if (mSingleTestMode) {
+                        Log.v(LOGTAG, "Single test mode: " + url);
+                    } else if (mTimedOut) {
+                        Log.v(LOGTAG, "Timed out before finishing: " + url);
+                    } else if (mWaitUntilDone) {
+                        Log.v(LOGTAG, "Waiting for notifyDone: " + url);
+                    } else if (mRequestedWebKitData) {
+                        Log.v(LOGTAG, "Requested webkit data ready: " + url);
+                    }
                 }
             }
         }
@@ -556,7 +612,7 @@
             if (title.length() > 30)
                 title = "..."+title.substring(title.length()-30);
             setTitle(title);
-            if (dumpTitleChanges) {
+            if (mDumpTitleChanges) {
                 mTitleChanges.append("TITLE CHANGED: ");
                 mTitleChanges.append(title);
                 mTitleChanges.append("\n");
@@ -572,36 +628,90 @@
             mDialogStrings.append("ALERT: ");
             mDialogStrings.append(message);
             mDialogStrings.append('\n');
-            return false;
+            result.confirm();
+            return true;
+        }
+        
+        @Override
+        public boolean onJsConfirm(WebView view, String url, String message,
+                JsResult result) {
+            if (mDialogStrings == null) {
+                mDialogStrings = new StringBuffer();
+            }
+            mDialogStrings.append("CONFIRM: ");
+            mDialogStrings.append(message);
+            mDialogStrings.append('\n');
+            result.confirm();
+            return true;
+        }
+        
+        @Override
+        public boolean onJsPrompt(WebView view, String url, String message,
+                String defaultValue, JsPromptResult result) {
+            if (mDialogStrings == null) {
+                mDialogStrings = new StringBuffer();
+            }
+            mDialogStrings.append("PROMPT: ");
+            mDialogStrings.append(message);
+            mDialogStrings.append(", default text: ");
+            mDialogStrings.append(defaultValue);
+            mDialogStrings.append('\n');
+            result.confirm();
+            return true;
         }
     };
-
+    
+    private void resetTestStatus() {
+        mWaitUntilDone = false;
+        mDumpAsText = false;
+        mTimedOut = false;
+        mDumpTitleChanges = false;
+        mRequestedWebKitData = false;
+        mEventSender.resetMouse();
+    }
+    
+    private TestRecorder mResultRecorder;
+    private HTMLHostCallbackInterface mCallback = null;
+    private CallbackProxy mCallbackProxy;
+    
     private WebView mWebView;
-    private WebViewEventSender eventSender;
-    private Vector mProcessStack;
-    private Stack mFinishedStack;
-    static final String LOGTAG="DumpRenderTree";
-    private String mCurrentFile;
-    private int mOutstandingLoads;
+    private WebViewEventSender mEventSender;
+    
+    private Vector<String> mTestList;
+    private int mTestIndex;
+
+    private int mTimeoutInMillis;
+    private String mTestPathPrefix;
+    private boolean mSingleTestMode;
+    
     private AsyncHandler mHandler;
-    private boolean mDumpRequested;
-
-    private boolean dumpAsText;
-    private boolean waitToDump;
-    private boolean pageComplete;
-
-    private boolean dumpTitleChanges;
-    private StringBuffer mTitleChanges;
-
-    private StringBuffer mDialogStrings;
-
-    private boolean keepWebHistory;
-    private Vector mWebHistory;
+    private boolean mFinishedRunning;
 
     private boolean mTimedOut;
+    private boolean mRequestedWebKitData;
+    private boolean mDumpAsText;
+    private boolean mWaitUntilDone;
+    private boolean mDumpTitleChanges;
+    
+    private StringBuffer mTitleChanges;
+    private StringBuffer mDialogStrings;
 
-    static final int MSG_DUMP = 0;
-    static final int MSG_TIMEOUT = 1;
-    static final int MSG_WEBKIT_DATA = 2;
+    private boolean mKeepWebHistory;
+    private Vector mWebHistory;
 
+    static final String TIMEOUT_STR = "**Test timeout";
+    
+    static final int MSG_TIMEOUT = 0;
+    static final int MSG_WEBKIT_DATA = 1;
+
+    static final String LOGTAG="DumpRenderTree";
+
+    static final String LAYOUT_TESTS_ROOT = "/sdcard/android/layout_tests/";
+    static final String LAYOUT_TESTS_LIST_FILE = "/sdcard/layout_tests_list.txt";
+    static final String TEST_STATUS_FILE = "/sdcard/running_test.txt";
+    
+    static final String RESUME_FROM_CRASH = "ResumeFromCrash";
+    static final String TEST_PATH_PREFIX = "TestPathPrefix";
+    static final String TIMEOUT_IN_MILLIS = "TimeoutInMillis";
+    static final String SINGLE_TEST_MODE = "SingleTestMode";
 }
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java
index e0e535e..1f37405 100755
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoRunner.java
@@ -21,6 +21,9 @@
 
 import android.test.InstrumentationTestRunner;
 import android.test.InstrumentationTestSuite;
+import android.util.Log;
+import android.content.Intent;
+import android.os.Bundle;
 
 
 /**
@@ -44,5 +47,22 @@
     public ClassLoader getLoader() {
         return LayoutTestsAutoRunner.class.getClassLoader();
     }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        String path = (String) icicle.get("path");
+        LayoutTestsAutoTest.setLayoutTestDir(path);
+        String timeout_str = (String) icicle.get("timeout");
+        int timeout = 0;  // default value
+        if (timeout_str != null) {
+            try {
+                timeout = Integer.parseInt(timeout_str);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        LayoutTestsAutoTest.setTimeoutInMillis(timeout);
+    }
 }
 
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
index f46b263..3e65f0358 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LayoutTestsAutoTest.java
@@ -16,142 +16,157 @@
 
 package com.android.dumprendertree;
 
+import android.app.Activity;
 import android.app.Instrumentation;
 import android.app.Instrumentation.ActivityMonitor;
 import android.content.ContentResolver;
 import android.content.ContentValues;
+import android.content.Intent;
+
 import android.util.Log;
 import android.view.KeyEvent;
 
+import android.os.Bundle;
+import android.os.Message;
 import android.test.ActivityInstrumentationTestCase;
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.LargeTest;
 
 import com.android.dumprendertree.HTMLHostActivity;
 
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
 public class LayoutTestsAutoTest extends ActivityInstrumentationTestCase<Menu> {
 
     private final static String LOGTAG = "LayoutTests";
-    private final static String LAYOUT_TESTS_ROOT = "/sdcard/android/layout_tests/";
-
+    private final static int DEFAULT_TIMEOUT_IN_MILLIS = 6000;
+    private static String layoutTestDir = null;
+    private static int mTimeoutInMillis = 0;
+    
     public LayoutTestsAutoTest() {
       super("com.android.dumprendertree", Menu.class);
     }
 
+    // This function writes the result of the layout test to
+    // Am status so that it can be picked up from a script.
+    public void passOrFailCallback(String file, boolean result) {
+      Instrumentation inst = getInstrumentation();
+      Bundle bundle = new Bundle();
+      bundle.putBoolean(file, result);
+      inst.sendStatus(0, bundle);
+    }
+
+    public static void setTimeoutInMillis(int millis) {
+        mTimeoutInMillis = (millis > 0) ? millis : DEFAULT_TIMEOUT_IN_MILLIS;
+    }
+
+    public static void setLayoutTestDir(String name) {
+        if (name == null)
+            throw new AssertionError("Layout test directory cannot be null.");
+      layoutTestDir = HTMLHostActivity.LAYOUT_TESTS_ROOT + name;
+      Log.v("LayoutTestsAutoTest", " Only running the layout tests : " + layoutTestDir);
+    }
+
     // Invokes running of layout tests
     // and waits till it has finished running.
-    public void executeLayoutTests(String folder) {
+    public void executeLayoutTests(boolean resume) {
       Instrumentation inst = getInstrumentation();
-      getActivity().processFile(folder, true);
-
+      
+      {
+          Activity activity = getActivity();
+          Intent intent = new Intent();
+          intent.setClass(activity, HTMLHostActivity.class);
+          intent.putExtra(HTMLHostActivity.RESUME_FROM_CRASH, resume);
+          intent.putExtra(HTMLHostActivity.SINGLE_TEST_MODE, false);
+          intent.putExtra(HTMLHostActivity.TEST_PATH_PREFIX, layoutTestDir);
+          intent.putExtra(HTMLHostActivity.TIMEOUT_IN_MILLIS, mTimeoutInMillis);
+          activity.startActivity(intent);
+      }
+      
       ActivityMonitor htmlHostActivityMonitor =
           inst.addMonitor("com.android.dumprendertree.HTMLHostActivity", null, false);
+
       HTMLHostActivity activity =
-          (HTMLHostActivity) htmlHostActivityMonitor.waitForActivityWithTimeout(6000);
-      
+          (HTMLHostActivity) htmlHostActivityMonitor.waitForActivity();
+
       while (!activity.hasFinishedRunning()) {
           // Poll every 5 seconds to determine if the layout
           // tests have finished running
           try {Thread.sleep(5000); } catch(Exception e){}
       }
-      
+
       // Wait few more seconds so that results are
       // flushed to the /sdcard
       try {Thread.sleep(5000); } catch(Exception e){}
 
-      return ;
+      // Clean up the HTMLHostActivity activity
+      activity.finish();
+    }
+    
+    public void generateTestList() {
+        try {
+            File tests_list = new File(HTMLHostActivity.LAYOUT_TESTS_LIST_FILE);
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
+            findTestsRecursively(bos, layoutTestDir);
+            bos.flush();
+            bos.close();
+       } catch (Exception e) {
+           Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());
+       }
+    }
+
+    private void findTestsRecursively(BufferedOutputStream bos, String dir) throws IOException {
+         Log.v(LOGTAG, "Searching tests under " + dir);
+         
+         File d = new File(dir);
+         if (!d.isDirectory()) {
+             throw new AssertionError("A directory expected, but got " + dir);
+         }
+         
+         String[] files = d.list();
+         for (int i = 0; i < files.length; i++) {
+             String s = dir + "/" + files[i];
+             if (FileFilter.ignoreTest(s)) {
+                 Log.v(LOGTAG, "  Ignoring: " + s);
+                 continue;
+             }
+             if (s.toLowerCase().endsWith(".html") 
+                 || s.toLowerCase().endsWith(".xml")) {
+                 bos.write(s.getBytes());
+                 bos.write('\n');
+                 continue;
+             }
+             
+             File f = new File(s);
+             if (f.isDirectory()) {
+                 findTestsRecursively(bos, s);
+                 continue;
+             }
+             
+             Log.v(LOGTAG, "Skipping " + s);
+        }
     }
     
     // Running all the layout tests at once sometimes
     // causes the dumprendertree to run out of memory.
     // So, additional tests are added to run the tests
     // in chunks.
-    @LargeTest
-    public void testAllLayoutTests() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast");
+    public void startLayoutTests() {
+        try {
+            File tests_list = new File(HTMLHostActivity.LAYOUT_TESTS_LIST_FILE);
+            if (!tests_list.exists())
+              generateTestList();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        
+        executeLayoutTests(false);
     }
 
-    @LargeTest
-    public void testLayoutSubset1() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/backgrounds");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/borders");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/box-shadow");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/box-sizing");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/canvas");   
-    }
-
-    @LargeTest
-    public void testLayoutSubset2() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/clip");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/compact");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/cookies");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/css");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/css-generated-content");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/doctypes");
-    }
-
-    @LargeTest  
-    public void testLayoutSubset3() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/dom");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/dynamic");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/encoding");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/events");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/flexbox");
-    }
-
-    @LargeTest  
-    public void testLayoutSubset4() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/forms");     
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/frames");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/gradients");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/history");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/html");
-    }
-
-    @LargeTest  
-    public void testLayoutSubset5() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/images");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/inline");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/inline-block");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/innerHTML");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/invalid");
-    }
-
-    @LargeTest
-    public void testLayoutSubset6() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/js");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/layers");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/leaks");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/lists");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/loader");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/media");
-    }
-
-    @LargeTest
-    public void testLayoutSubset7() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/multicol");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/overflow");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/parser");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/profiler");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/reflections");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/regex");
-    }
-
-    @LargeTest
-    public void testLayoutSubset8() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/repaint");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/replaced");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/runin");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/selectors");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/table");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/text");
-    }
-
-    @LargeTest
-    public void testLayoutSubset9() {
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/tokenizer");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/transforms");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/xpath");
-      executeLayoutTests(LAYOUT_TESTS_ROOT + "fast/xsl");
+    public void resumeLayoutTests() {
+        executeLayoutTests(true);
     }
 }
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java b/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
index 2def8f3..de0da61 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/Menu.java
@@ -43,9 +43,12 @@
     
     void processFile(String filename, boolean selection)
     {
-        Intent result = new Intent(null, Uri.parse(filename));
+        Intent result = new Intent();
         result.setClass(this, HTMLHostActivity.class);
-        result.putExtra("ReturnWhenFinished", selection);
+        result.putExtra(HTMLHostActivity.RESUME_FROM_CRASH, false);
+        result.putExtra(HTMLHostActivity.SINGLE_TEST_MODE, true);
+        result.putExtra(HTMLHostActivity.TEST_PATH_PREFIX, filename);
+        result.putExtra(HTMLHostActivity.TIMEOUT_IN_MILLIS, 8000);
         startActivity(result);
     }
    
diff --git a/tests/FrameworkTest/AndroidManifest.xml b/tests/FrameworkTest/AndroidManifest.xml
index 8106a50..c0824c0 100644
--- a/tests/FrameworkTest/AndroidManifest.xml
+++ b/tests/FrameworkTest/AndroidManifest.xml
@@ -845,6 +845,13 @@
             </intent-filter>
         </activity>
 
+        <activity android:name=".drawable.MutateDrawable" android:label="MutateDrawable">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".activity.TranslucentFancyActivity" android:label="TranslucentFancyActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
diff --git a/tests/FrameworkTest/src/com/android/frameworktest/drawable/MutateDrawable.java b/tests/FrameworkTest/src/com/android/frameworktest/drawable/MutateDrawable.java
new file mode 100644
index 0000000..2fcaea3
--- /dev/null
+++ b/tests/FrameworkTest/src/com/android/frameworktest/drawable/MutateDrawable.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.frameworktest.drawable;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.LinearLayout;
+import android.widget.Button;
+import com.android.frameworktest.R;
+
+public class MutateDrawable extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        LinearLayout layout = new LinearLayout(this);
+
+        Button ok = new Button(this);
+        ok.setId(R.id.a);
+        ok.setBackgroundDrawable(getResources().getDrawable(
+                R.drawable.sym_now_playing_skip_forward_1));
+
+        Button cancel = new Button(this);
+        cancel.setId(R.id.b);
+        cancel.setBackgroundDrawable(getResources().getDrawable(
+                R.drawable.sym_now_playing_skip_forward_1));
+
+        layout.addView(ok);
+        layout.addView(cancel);
+
+        ok.getBackground().mutate().setAlpha(127);
+
+        setContentView(layout);
+    }
+}
diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/drawable/MutateDrawableTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/drawable/MutateDrawableTest.java
new file mode 100644
index 0000000..53085ca
--- /dev/null
+++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/drawable/MutateDrawableTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.frameworktest.drawable;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.view.View;
+
+public class MutateDrawableTest extends ActivityInstrumentationTestCase2<MutateDrawable> {
+    private View mFirstButton;
+    private View mSecondButton;
+
+    public MutateDrawableTest() {
+        super("com.android.frameworktest", MutateDrawable.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mFirstButton = getActivity().findViewById(com.android.frameworktest.R.id.a);
+        mSecondButton = getActivity().findViewById(com.android.frameworktest.R.id.b);
+    }
+
+    @MediumTest
+    public void testSetUpConditions() throws Exception {
+        assertNotNull(mFirstButton);
+        assertNotNull(mSecondButton);
+        assertNotSame(mFirstButton.getBackground(), mSecondButton.getBackground());
+    }
+
+    @MediumTest
+    public void testDrawableCanMutate() throws Exception {
+        assertNotSame(mFirstButton.getBackground().getConstantState(),
+                mSecondButton.getBackground().getConstantState());
+    }
+}
diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListScrollListenerTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListScrollListenerTest.java
index 485199e..44958d9 100644
--- a/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListScrollListenerTest.java
+++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListScrollListenerTest.java
@@ -24,7 +24,6 @@
 import android.widget.AbsListView;
 import android.widget.ListView;
 
-import com.android.frameworktest.listview.ListScrollListener;
 import android.test.TouchUtils;
 
 public class ListScrollListenerTest extends ActivityInstrumentationTestCase<ListScrollListener> implements
@@ -88,8 +87,6 @@
 
     @LargeTest
     public void testTouchScrolling() {
-        Instrumentation inst = getInstrumentation();
-        
         int firstVisibleItem = mFirstVisibleItem;
         TouchUtils.dragQuarterScreenUp(this);
         TouchUtils.dragQuarterScreenUp(this);
diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListSetSelectionTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListSetSelectionTest.java
index 18b6199..e35d894 100644
--- a/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListSetSelectionTest.java
+++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/listview/ListSetSelectionTest.java
@@ -58,7 +58,7 @@
         }
     }
     
-    /** Confirm that you can unset the selection using the same API */
+    /** Confirm that you cannot unset the selection using the same API */
     @MediumTest
     @UiThreadTest
     public void testClearSelection() {
@@ -68,7 +68,6 @@
 
         // Clear the selection
         mListView.setSelection(ListView.INVALID_POSITION);
-        assertEquals("Set selection", 
-                ListView.INVALID_POSITION, mListView.getSelectedItemPosition());
+        assertEquals("Set selection", 0, mListView.getSelectedItemPosition());
     }
 }
diff --git a/tests/FrameworkTest/tests/src/com/android/frameworktest/widget/ListViewTest.java b/tests/FrameworkTest/tests/src/com/android/frameworktest/widget/ListViewTest.java
index dff1610..ecb7d3a 100644
--- a/tests/FrameworkTest/tests/src/com/android/frameworktest/widget/ListViewTest.java
+++ b/tests/FrameworkTest/tests/src/com/android/frameworktest/widget/ListViewTest.java
@@ -92,7 +92,7 @@
 
         @Override
         public Resources getResources() {
-            return null;
+            return getInstrumentation().getTargetContext().getResources();
         }
 
         @Override
diff --git a/tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java b/tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java
deleted file mode 100644
index 38073fa..0000000
--- a/tests/GadgetHost/src/com/android/gadgethost/GadgetHostActivity.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gadgethost;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.gadget.GadgetHost;
-import android.gadget.GadgetHostView;
-import android.gadget.GadgetInfo;
-import android.gadget.GadgetManager;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.ContextMenu;
-import android.view.View;
-import android.widget.LinearLayout;
-
-public class GadgetHostActivity extends Activity
-{
-    static final String TAG = "GadgetHostActivity";
-
-    static final int DISCOVER_GADGET_REQUEST = 1;
-
-    GadgetManager mGadgetManager;
-    GadgetContainerView mGadgetContainer;
-
-    public GadgetHostActivity() {
-        mGadgetManager = GadgetManager.getInstance(this);
-    }
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        setContentView(R.layout.gadget_host);
-
-        findViewById(R.id.add_gadget).setOnClickListener(mOnClickListener);
-        mGadgetContainer = (GadgetContainerView)findViewById(R.id.gadget_container);
-    }
-
-    View.OnClickListener mOnClickListener = new View.OnClickListener() {
-        public void onClick(View v) {
-            discoverGadget(DISCOVER_GADGET_REQUEST);
-        }
-    };
-
-    void discoverGadget(int requestCode) {
-        Intent intent = new Intent(GadgetManager.GADGET_PICK_ACTION);
-        startActivityForResult(intent, requestCode);
-    }
-
-    void handleGadgetPickResult(int resultCode, Intent data) {
-        if (resultCode == RESULT_OK) {
-            Bundle extras = data.getExtras();
-            int gadgetId = extras.getInt(GadgetManager.EXTRA_GADGET_ID);
-            GadgetInfo gadget = mGadgetManager.getGadgetInfo(gadgetId);
-
-            if (gadget.configure != null) {
-                // configure the gadget if we should
-
-                // TODO: start the activity.  Watch for a cancel result.  If it returns
-                // RESULT_CANCELED, then remove the gadget.
-            } else {
-                // just add it as is
-                addGadgetView(gadgetId, gadget);
-            }
-        }
-    }
-
-    void addGadgetView(int gadgetId, GadgetInfo gadget) {
-        // Inflate the gadget's RemoteViews
-        GadgetHostView view = mHost.createView(this, gadgetId, gadget);
-
-        // Add it to the list
-        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
-                65, // LinearLayout.LayoutParams.WRAP_CONTENT,
-                LinearLayout.LayoutParams.WRAP_CONTENT);
-        mGadgetContainer.addView(view, layoutParams);
-    }
-
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        switch (requestCode) {
-        case DISCOVER_GADGET_REQUEST:
-            handleGadgetPickResult(resultCode, data);
-            break;
-        }
-    }
-
-    protected void onStart() {
-        super.onStart();
-        mHost.startListening();
-    }
-
-    protected void onStop() {
-        super.onStop();
-        mHost.stopListening();
-    }
-
-    class MyGadgetView extends GadgetHostView {
-        MyGadgetView() {
-            super(GadgetHostActivity.this);
-        }
-
-        public void createContextMenu(ContextMenu menu) {
-            menu.add("Delete");
-        }
-    }
-
-    GadgetHost mHost = new GadgetHost(this, 0) {
-        protected GadgetHostView onCreateView(Context context, int gadgetId, GadgetInfo gadget) {
-            return new MyGadgetView();
-        }
-    };
-
-}
-
-
diff --git a/tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java b/tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java
deleted file mode 100644
index a995544..0000000
--- a/tests/GadgetHost/src/com/android/gadgethost/GadgetPickActivity.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gadgethost;
-
-import android.app.ListActivity;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.gadget.GadgetInfo;
-import android.gadget.GadgetManager;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.util.Log;
-
-import java.util.List;
-
-public class GadgetPickActivity extends ListActivity
-{
-    private static final String TAG = "GadgetPickActivity";
-
-    GadgetManager mGadgetManager;
-    List<GadgetInfo> mInstalled;
-    
-    public GadgetPickActivity() {
-        mGadgetManager = GadgetManager.getInstance(this);
-    }
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-
-        Bundle extras = getIntent().getExtras();
-
-        List<GadgetInfo> installed = mGadgetManager.getInstalledProviders();
-        mInstalled = installed;
-        final int N = installed.size();
-        String[] labels = new String[N];
-        for (int i=0; i<N; i++) {
-            labels[i] = installed.get(i).provider.getClassName();
-        }
-
-        setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, labels));
-    }
-
-    @Override
-    public void onListItemClick(ListView l, View v, int position, long id)
-    {
-        int gadgetId = mGadgetManager.allocateGadgetId(getCallingPackage());
-        mGadgetManager.bindGadgetId(gadgetId, mInstalled.get(position).provider);
-
-        Intent result = new Intent();
-        result.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId);
-
-        setResult(RESULT_OK, result);
-        finish();
-    }
-}
-
diff --git a/tests/ImfTest/AndroidManifest.xml b/tests/ImfTest/AndroidManifest.xml
index 85d6b0c..627ee6dc 100755
--- a/tests/ImfTest/AndroidManifest.xml
+++ b/tests/ImfTest/AndroidManifest.xml
@@ -19,6 +19,134 @@
             </intent-filter>
         </activity>
         
+        <activity android:name=".samples.AppAdjustmentBigEditTextNonScrollablePanScan" android:label="Big ET !Scroll Pan/Scan">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".samples.ManyEditTextActivityNoScrollPanScan" android:label="ManyEditTextActivityNoScrollPanScan">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+        
+        <activity android:name=".samples.AppAdjustmentBigEditTextNonScrollableResize" android:label="Big ET !Scroll Resize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+        
+        <activity android:name=".samples.AppAdjustmentBigEditTextScrollablePanScan" android:label="Big ET Scroll Pan/Scan">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+        
+        <activity android:name=".samples.AppAdjustmentBigEditTextScrollableResize" android:label="Big ET Scroll Resize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".samples.AppAdjustmentEditTextDialog" android:label="ET Dialog">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".samples.ManyEditTextActivityScrollPanScan" android:label="ManyEditTextActivityScrollPanScan">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+        
+        <activity android:name=".samples.ManyEditTextActivityScrollResize" android:label="ManyEditTextActivityScrollResize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name=".samples.BottomEditTextActivityPanScan" android:label="BottomEditTextActivityPanScan">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+        
+        <activity android:name=".samples.BottomEditTextActivityResize" android:label="BottomEditTextActivityResize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+        
+        <activity android:name=".samples.OneEditTextActivitySelected" android:label="OneEditTextActivitySelected">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+    
+        <activity android:name=".samples.OneEditTextActivityNotSelected" android:label="OneEditTextActivityNotSelected">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+         
+        <activity android:name=".samples.AutoCompleteTextViewActivityPortrait" android:label="AutoCompleteTextViewActivityPortrait" android:screenOrientation="portrait">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>
+   
+        <activity android:name=".samples.AutoCompleteTextViewActivityLandscape" android:label="AutoCompleteTextViewActivityLandscape" android:screenOrientation="landscape">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>   
+          
+        <activity android:name=".samples.OneEditTextActivityLandscape" android:label="OneEditTextActivityLandscape" android:screenOrientation="landscape">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>  
+        
+        <activity android:name=".samples.DialogActivity" android:label="DialogActivity" android:screenOrientation="portrait">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.IMF_TEST" />
+            </intent-filter>
+        </activity>              
+          
     </application>
     
 </manifest>
diff --git a/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml b/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml
new file mode 100644
index 0000000..e8ffa1c
--- /dev/null
+++ b/tests/ImfTest/res/layout/dialog_edit_text_no_scroll.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+  
+          http://www.apache.org/licenses/LICENSE-2.0
+  
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:padding="20dip"
+    android:orientation="vertical">
+            
+    <View
+    	android:id="@+id/blank"
+    	android:layout_height="0dip"
+    	android:layout_width="fill_parent"
+    	android:layout_weight="1"/>
+    	
+    <EditText
+        android:id="@+id/dialog_edit_text"
+        android:layout_height="wrap_content"
+        android:layout_width="fill_parent"
+        android:scrollHorizontally="true"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+</LinearLayout>
diff --git a/tests/ImfTest/res/layout/full_screen_edit_text.xml b/tests/ImfTest/res/layout/full_screen_edit_text.xml
new file mode 100755
index 0000000..f22aa2f
--- /dev/null
+++ b/tests/ImfTest/res/layout/full_screen_edit_text.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/samples/SampleCode/res/layout/baseline_1.xml
+**
+** Copyright 2009, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<EditText xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/data" 
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:minLines="15"
+    android:gravity="top"/>
+
diff --git a/tests/ImfTest/res/layout/one_edit_text_activity.xml b/tests/ImfTest/res/layout/one_edit_text_activity.xml
new file mode 100755
index 0000000..09925e1
--- /dev/null
+++ b/tests/ImfTest/res/layout/one_edit_text_activity.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* //device/samples/SampleCode/res/layout/baseline_1.xml
+**
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+>
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:orientation="vertical"
+        android:baselineAligned="false">
+
+        <View android:id="@+id/blank"
+            android:layout_height="0dip"
+            android:layout_width="fill_parent"
+            android:layout_weight="1"
+        />
+
+        <EditText android:id="@+id/dialog_edit_text"
+            android:layout_height="wrap_content"
+            android:layout_width="fill_parent"
+            android:scrollHorizontally="true"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+        />
+    </LinearLayout>
+
+    <View
+        android:layout_width="fill_parent"
+        android:layout_height="1dip"
+        android:background="@android:drawable/divider_horizontal_dark"
+    />
+</LinearLayout>
diff --git a/tests/ImfTest/res/values/strings.xml b/tests/ImfTest/res/values/strings.xml
index a56c363..fc87480 100755
--- a/tests/ImfTest/res/values/strings.xml
+++ b/tests/ImfTest/res/values/strings.xml
@@ -35,5 +35,16 @@
     <string name="normal_datetime_edit_text_label">Datetime</string>
     <string name="date_edit_text_label">Date</string>
     <string name="time_edit_text_label">Time</string>
+    <string name="cap_chars_edit_text_label">Cap Chars</string>
+    <string name="cap_words_edit_text_label">Cap Words</string>
+    <string name="multiline_edit_text_label">Multiline</string>
+    <string name="search_edit_text_label">Search (flag)</string>
+    <string name="cap_sentences_edit_text_label">Cap Sentences</string>
+    <string name="auto_complete_edit_text_label">Auto Complete</string>
+    <string name="auto_correct_edit_text_label">Auto Correct</string>
+    <string name="test_dialog">Test Dialog</string>
+    <string name="open_dialog_scrollable">open scrollable dialog</string>
+    <string name="open_dialog_nonscrollable">open nonscrollable dialog</string>
+    
     
 </resources>
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollablePanScan.java
new file mode 100644
index 0000000..15a29c8
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollablePanScan.java
@@ -0,0 +1,35 @@
+package com.android.imftest.samples;
+
+import com.android.imftest.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+
+public class AppAdjustmentBigEditTextNonScrollablePanScan extends Activity {
+    
+    private LinearLayout mLayout;
+    
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        
+        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+        
+        mLayout = new LinearLayout(this);
+        mLayout.setOrientation(LinearLayout.VERTICAL);
+        mLayout.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+        
+        EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mLayout, false);
+        
+        mLayout.addView(editText);
+        
+        setContentView(mLayout);
+    }
+
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollableResize.java
new file mode 100644
index 0000000..0726823
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextNonScrollableResize.java
@@ -0,0 +1,35 @@
+package com.android.imftest.samples;
+
+import com.android.imftest.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+
+public class AppAdjustmentBigEditTextNonScrollableResize extends Activity {
+    
+    private LinearLayout mLayout;
+    
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        
+        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+        
+        mLayout = new LinearLayout(this);
+        mLayout.setOrientation(LinearLayout.VERTICAL);
+        mLayout.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+        
+        EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mLayout, false);
+        
+        mLayout.addView(editText);
+        
+        setContentView(mLayout);
+    }
+
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollablePanScan.java
new file mode 100644
index 0000000..50a980b
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollablePanScan.java
@@ -0,0 +1,44 @@
+package com.android.imftest.samples;
+
+import com.android.imftest.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+
+public class AppAdjustmentBigEditTextScrollablePanScan extends Activity {
+    
+    private ScrollView mScrollView;
+    private LinearLayout mLayout;
+    
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        
+        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+        
+        mScrollView = new ScrollView(this);
+        mScrollView.setFillViewport(true);
+        mScrollView.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+        
+        mLayout = new LinearLayout(this);
+        mLayout.setOrientation(LinearLayout.VERTICAL);
+        mLayout.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+        
+        EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mScrollView, false);
+        
+        mLayout.addView(editText);
+        mScrollView.addView(mLayout);
+        
+        setContentView(mScrollView);
+    }
+
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java
new file mode 100644
index 0000000..a256878
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentBigEditTextScrollableResize.java
@@ -0,0 +1,44 @@
+package com.android.imftest.samples;
+
+import com.android.imftest.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+
+public class AppAdjustmentBigEditTextScrollableResize extends Activity {
+    
+    private ScrollView mScrollView;
+    private LinearLayout mLayout;
+    
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        
+        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+        
+        mScrollView = new ScrollView(this);
+        mScrollView.setFillViewport(true);
+        mScrollView.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+        
+        mLayout = new LinearLayout(this);
+        mLayout.setOrientation(LinearLayout.VERTICAL);
+        mLayout.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+        
+        EditText editText = (EditText) getLayoutInflater().inflate(R.layout.full_screen_edit_text, mScrollView, false);
+        
+        mLayout.addView(editText);
+        mScrollView.addView(mLayout);
+        
+        setContentView(mScrollView);
+    }
+
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java
new file mode 100644
index 0000000..e82f1d5
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/AppAdjustmentEditTextDialog.java
@@ -0,0 +1,96 @@
+package com.android.imftest.samples;
+
+import com.android.imftest.R;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+
+public class AppAdjustmentEditTextDialog extends Activity {
+    
+    private static final int SCROLLABLE_DIALOG_ID = 0;
+    private static final int NONSCROLLABLE_DIALOG_ID = 1;
+    
+    private LinearLayout mLayout;
+    private ScrollView mScrollView;
+    private LayoutInflater mInflater;
+    private Button mButton1;
+    private Button mButton2;
+    
+    
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        
+        mLayout = new LinearLayout(this);
+        mLayout.setOrientation(LinearLayout.VERTICAL);
+        mLayout.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+        
+        mButton1 = new Button(this);
+        mButton1.setText(R.string.open_dialog_scrollable);
+        mButton1.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                showDialog(SCROLLABLE_DIALOG_ID);
+            }
+        });
+        
+        mButton2 = new Button(this);
+        mButton2.setText(R.string.open_dialog_nonscrollable);
+        mButton2.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+                showDialog(NONSCROLLABLE_DIALOG_ID);
+            }
+        });
+        
+        mLayout.addView(mButton1);
+        mLayout.addView(mButton2);
+        
+        setContentView(mLayout);
+    }
+    
+    @Override
+    protected Dialog onCreateDialog(int id) {
+        switch (id) {
+            case SCROLLABLE_DIALOG_ID:
+                return createDialog(true);
+            case NONSCROLLABLE_DIALOG_ID:
+                return createDialog(false);
+        }
+
+        return super.onCreateDialog(id);
+    }
+    
+    protected Dialog createDialog(boolean scrollable) {
+        View layout;
+        EditText editText;
+        
+        if (scrollable) {
+            layout = new ScrollView(AppAdjustmentEditTextDialog.this);
+            ((ScrollView) layout).setMinimumHeight(mLayout.getHeight());
+            
+            ((ScrollView) layout).addView((
+                    LinearLayout) View.inflate(AppAdjustmentEditTextDialog.this, 
+                    R.layout.dialog_edit_text_no_scroll, null));
+        } else {
+            layout = View.inflate(AppAdjustmentEditTextDialog.this, 
+                    R.layout.dialog_edit_text_no_scroll, null);
+        }
+        
+        Dialog d = new Dialog(AppAdjustmentEditTextDialog.this);
+        d.setTitle(getString(R.string.test_dialog));
+        d.setCancelable(true);
+        d.setContentView(layout);
+        return d;
+    }
+
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java
new file mode 100644
index 0000000..9638d34a
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java
@@ -0,0 +1,85 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.app.ActivityManagerNative;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.provider.MediaStore;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.AutoCompleteTextView;
+import android.widget.ArrayAdapter;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+
+import com.android.internal.R;
+
+/*
+ * Activity with AutoCompleteTextView forced to landscape mode
+ */
+public class AutoCompleteTextViewActivityLandscape extends Activity 
+{
+   @Override
+   public void onCreate(Bundle savedInstanceState) 
+   {
+       super.onCreate(savedInstanceState);
+    
+       setContentView(R.layout.auto_complete_list);
+
+       ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
+               android.R.layout.simple_dropdown_item_1line, COUNTRIES);
+       AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
+       textView.setAdapter(adapter);
+   }
+
+   static final String[] COUNTRIES = new String[] {
+   "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
+   "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
+   "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
+   "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
+   "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
+   "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory",
+   "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
+   "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
+   "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
+   "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
+   "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic",
+   "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic",
+   "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
+   "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland",
+   "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia",
+   "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar",
+   "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau",
+   "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary",
+   "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica",
+   "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos",
+   "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
+   "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands",
+   "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova",
+   "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia",
+   "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand",
+   "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas",
+   "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru",
+   "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar",
+   "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena",
+   "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon",
+   "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal",
+   "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands",
+   "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea",
+   "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden",
+   "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas",
+   "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey",
+   "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda",
+   "Ukraine", "United Arab Emirates", "United Kingdom",
+   "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan",
+   "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara",
+   "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"
+   };
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java
new file mode 100644
index 0000000..58651e1
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java
@@ -0,0 +1,79 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.AutoCompleteTextView;
+import android.widget.ArrayAdapter;
+
+import com.android.internal.R;
+
+/*
+ * Activity with AutoCompleteTextView (Candidate bar should not appear)
+ */
+public class AutoCompleteTextViewActivityPortrait extends Activity 
+{
+   @Override
+   public void onCreate(Bundle savedInstanceState) 
+   {
+       super.onCreate(savedInstanceState);
+       
+       setContentView(R.layout.auto_complete_list);
+
+       ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
+               android.R.layout.simple_dropdown_item_1line, COUNTRIES);
+       AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit);
+       textView.setAdapter(adapter);
+   }
+
+   static final String[] COUNTRIES = new String[] {
+   "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
+   "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
+   "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
+   "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
+   "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
+   "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory",
+   "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
+   "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
+   "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
+   "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
+   "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic",
+   "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic",
+   "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
+   "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland",
+   "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia",
+   "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar",
+   "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau",
+   "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary",
+   "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica",
+   "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos",
+   "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
+   "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands",
+   "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova",
+   "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia",
+   "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand",
+   "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas",
+   "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru",
+   "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar",
+   "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena",
+   "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon",
+   "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal",
+   "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands",
+   "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea",
+   "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden",
+   "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas",
+   "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey",
+   "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda",
+   "Ukraine", "United Arab Emirates", "United Kingdom",
+   "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan",
+   "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara",
+   "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"
+   };
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java
new file mode 100644
index 0000000..d74b9dd
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java
@@ -0,0 +1,37 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.widget.EditText;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import com.android.imftest.R;
+
+/*
+ * Activity with EditText at the bottom (Pan&Scan)
+ */
+public class BottomEditTextActivityPanScan extends Activity 
+{
+    private LayoutInflater mInflater;
+    @Override
+    public void onCreate(Bundle savedInstanceState) 
+    {
+        super.onCreate(savedInstanceState);
+        
+        LinearLayout layout = new LinearLayout(this);
+        layout.setOrientation(LinearLayout.VERTICAL);
+        
+        mInflater = getLayoutInflater();
+        
+        View view = mInflater.inflate(R.layout.one_edit_text_activity, layout, false);
+        layout.addView(view);
+       
+        setContentView(layout);
+        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+    }  
+}
\ No newline at end of file
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java
new file mode 100644
index 0000000..82da29a
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java
@@ -0,0 +1,37 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.widget.EditText;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import com.android.imftest.R;
+
+/*
+ * Activity with EditText at the bottom (Resize)
+ */
+public class BottomEditTextActivityResize extends Activity 
+{
+    private LayoutInflater mInflater;
+    @Override
+    public void onCreate(Bundle savedInstanceState) 
+    {
+        super.onCreate(savedInstanceState);
+        
+        LinearLayout layout = new LinearLayout(this);
+        layout.setOrientation(LinearLayout.VERTICAL);
+        
+        mInflater = getLayoutInflater();
+        
+        View view = mInflater.inflate(R.layout.one_edit_text_activity, layout, false);
+        layout.addView(view);
+       
+        setContentView(layout);
+        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+    }  
+}
\ No newline at end of file
diff --git a/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java
new file mode 100644
index 0000000..e49301c
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java
@@ -0,0 +1,102 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.widget.EditText;
+import android.widget.Button;
+import android.view.LayoutInflater;
+import android.app.Dialog;
+
+import com.android.internal.R;
+
+public class DialogActivity extends Activity {
+
+    private static final int DIALOG_WITHOUT_EDITTEXT = 0;
+    private static final int DIALOG_WITH_EDITTEXT = 1;
+
+    private LinearLayout mLayout;
+    private LayoutInflater mInflater;
+    private Button mButton1;
+    private Button mButton2;
+    private EditText mEditText;
+
+
+    @Override
+    protected void onCreate(Bundle icicle) 
+    {
+        super.onCreate(icicle);
+
+        mLayout = new LinearLayout(this);
+        mLayout.setOrientation(LinearLayout.VERTICAL);
+        mLayout.setLayoutParams(new ViewGroup.LayoutParams(
+                ViewGroup.LayoutParams.FILL_PARENT,
+                ViewGroup.LayoutParams.FILL_PARENT));
+
+        mButton1 = new Button(this);
+        mButton1.setText("Dialog WITHOUT EditText");//(R.string.open_dialog_scrollable);
+        mButton1.setOnClickListener(new View.OnClickListener() 
+        {
+            public void onClick(View v) 
+            {
+                showDialog(DIALOG_WITHOUT_EDITTEXT);
+            }
+        });
+
+        mButton2 = new Button(this);
+        mButton2.setText("Dialog WITH EditText");//(R.string.open_dialog_nonscrollable);
+        mButton2.setOnClickListener(new View.OnClickListener() 
+        {
+            public void onClick(View v) 
+            {
+                showDialog(DIALOG_WITH_EDITTEXT);
+            }
+        });
+
+        mEditText = new EditText(this);
+        mLayout.addView(mEditText);
+        mLayout.addView(mButton1);
+        mLayout.addView(mButton2);
+
+        setContentView(mLayout);
+    }
+
+    @Override
+    protected Dialog onCreateDialog(int id) 
+    {
+        switch (id) 
+        {
+            case DIALOG_WITHOUT_EDITTEXT:
+                return createDialog(false);
+            case DIALOG_WITH_EDITTEXT:
+                return createDialog(true);
+        }
+
+        return super.onCreateDialog(id);
+    }
+
+    protected Dialog createDialog(boolean bEditText) 
+    {
+        LinearLayout layout;        
+        layout = new LinearLayout(this);
+        layout.setOrientation(LinearLayout.VERTICAL);
+        
+        if(bEditText)
+        {
+            EditText editText;
+            editText = new EditText(this);
+            layout.addView(editText);
+        }
+        
+        Dialog d = new Dialog(this);
+        d.setTitle("The DIALOG!!!");
+        d.setCancelable(true);
+        d.setContentView(layout);
+        return d;
+    }
+
+ }
diff --git a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityNoScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityNoScrollPanScan.java
new file mode 100644
index 0000000..b596023
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityNoScrollPanScan.java
@@ -0,0 +1,38 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+
+import com.android.internal.R;
+
+public class EditTextActivityNoScrollPanScan extends Activity 
+{
+   @Override
+   public void onCreate(Bundle savedInstanceState) 
+   {
+       super.onCreate(savedInstanceState);
+                
+       LinearLayout layout = new LinearLayout(this);
+       layout.setOrientation(LinearLayout.VERTICAL);
+       
+       String string = new String();
+       for (int i=0; i<9; i++) 
+       {
+           final EditText editText = new EditText(this);
+           editText.setText(string.valueOf(i));
+           layout.addView(editText);
+       }
+       setContentView(layout);
+       this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+    }  
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java
index f7aaa7b..6c71e86 100755
--- a/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/InputTypeActivity.java
@@ -56,43 +56,67 @@
         mParent = mLayout;
         
         /* Normal Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_NORMAL, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL, 
                 R.string.normal_edit_text_label));
         
+        /* Normal Edit Text w/Cap Chars Flag*/
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS, 
+                R.string.cap_chars_edit_text_label));
+        
+        /* Normal Edit Text w/Cap Words Flag*/
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS, 
+                R.string.cap_words_edit_text_label));
+        
+        /* Normal Edit Text w/Cap Multiline Flag */
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE, 
+                R.string.multiline_edit_text_label));
+        
+        /* Normal Edit Text w/Cap Sentences Flag */
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES, 
+                R.string.cap_sentences_edit_text_label));
+        
+        /* Normal Edit Text w/Auto-complete Flag */
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE, 
+                R.string.auto_complete_edit_text_label));
+        
+        /* Normal Edit Text w/Auto-correct Flag */
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT, 
+                R.string.auto_correct_edit_text_label));
+        
+        /* Normal Edit Text w/Search Flag*/
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_NORMAL|EditorInfo.TYPE_TEXT_FLAG_SEARCH, 
+                R.string.search_edit_text_label));
+        
         /* Uri Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_URI, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_URI, 
         		R.string.uri_edit_text_label));
         
         /* Email Address Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS, 
         		R.string.email_address_edit_text_label));
         
         /* Email Subject Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_EMAIL_SUBJECT, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_EMAIL_SUBJECT, 
                 R.string.email_subject_edit_text_label));
         
         /* Email Content Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_EMAIL_CONTENT, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_LONG_MESSAGE, 
                 R.string.email_content_edit_text_label));
         
         /* Person Name Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME, 
                 R.string.person_name_edit_text_label));
         
         /* Postal Address Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_POSTAL_ADDRESS, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_POSTAL_ADDRESS, 
                 R.string.postal_address_edit_text_label));
         
         /* Password Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_PASSWORD, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_PASSWORD, 
                 R.string.password_edit_text_label));
         
-        /* Search String Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_SEARCH_STRING, 
-                R.string.search_string_edit_text_label));
-        
         /* Web Edit Text */
-        mLayout.addView(buildEntryView(EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT, 
+        mLayout.addView(buildEntryView(EditorInfo.TYPE_CLASS_TEXT|EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT, 
                 R.string.web_edit_text_label));
         
         /* Signed Number Edit Text */
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java
new file mode 100644
index 0000000..4cb3af6a
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java
@@ -0,0 +1,41 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+
+import com.android.internal.R;
+
+/*
+ * Full screen of EditTexts (Non-Scrollable, Pan&Scan)
+ */
+public class ManyEditTextActivityNoScrollPanScan extends Activity 
+{
+   @Override
+   public void onCreate(Bundle savedInstanceState) 
+   {
+       super.onCreate(savedInstanceState);
+                
+       LinearLayout layout = new LinearLayout(this);
+       layout.setOrientation(LinearLayout.VERTICAL);
+       
+       String string = new String();
+       for (int i=0; i<9; i++) 
+       {
+           final EditText editText = new EditText(this);
+           editText.setText(string.valueOf(i));
+           layout.addView(editText);
+       }
+       setContentView(layout);
+       this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+    }  
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java
new file mode 100644
index 0000000..bd32828
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java
@@ -0,0 +1,45 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+
+import com.android.internal.R;
+
+/*
+ * Full screen of EditTexts (Scrollable, Pan&Scan)
+ */
+public class ManyEditTextActivityScrollPanScan extends Activity 
+{
+   private ScrollView mScrollView;
+   @Override
+   public void onCreate(Bundle savedInstanceState) 
+   {
+       super.onCreate(savedInstanceState);
+       mScrollView = new ScrollView(this);
+       
+       LinearLayout layout = new LinearLayout(this);
+       layout.setOrientation(LinearLayout.VERTICAL);
+       
+       String string = new String();
+       for (int i=0; i<12; i++) 
+       {
+           final EditText editText = new EditText(this);
+           editText.setText(string.valueOf(i));
+           layout.addView(editText);
+       }
+
+       mScrollView.addView(layout);
+       setContentView(mScrollView);
+       this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+    }  
+}
\ No newline at end of file
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java
new file mode 100644
index 0000000..eaaa98b
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java
@@ -0,0 +1,37 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.widget.EditText;
+import android.widget.ScrollView;
+
+/*
+ * Full screen of EditTexts (Scrollable, Resize)
+ */
+public class ManyEditTextActivityScrollResize extends Activity 
+{
+    private ScrollView mScrollView;
+    @Override
+    public void onCreate(Bundle savedInstanceState) 
+    {
+        super.onCreate(savedInstanceState);
+        mScrollView = new ScrollView(this);
+       
+        LinearLayout layout = new LinearLayout(this);
+        layout.setOrientation(LinearLayout.VERTICAL);
+       
+        String string = new String();
+        for (int i=0; i<12; i++) 
+        {
+            final EditText editText = new EditText(this);
+            editText.setText(string.valueOf(i));
+            layout.addView(editText);
+        }
+
+        mScrollView.addView(layout);
+        setContentView(mScrollView);
+        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+    }  
+}
\ No newline at end of file
diff --git a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java
new file mode 100644
index 0000000..5fef884
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java
@@ -0,0 +1,40 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+
+import com.android.internal.R;
+
+/*
+ * Activity with non-EditText view selected initially
+ */
+public class OneEditTextActivityNotSelected extends Activity 
+{
+   @Override
+   public void onCreate(Bundle savedInstanceState) 
+   {
+       super.onCreate(savedInstanceState);
+                
+       LinearLayout layout = new LinearLayout(this);
+       layout.setOrientation(LinearLayout.VERTICAL);
+       
+       final EditText editText = new EditText(this);
+       final TextView textView = new TextView(this);
+       textView.setText("The focus is here.");
+       layout.addView(editText);
+       layout.addView(textView);
+  
+       setContentView(layout);
+       textView.requestFocus();
+    }  
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java
new file mode 100644
index 0000000..2fd19e8
--- /dev/null
+++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java
@@ -0,0 +1,37 @@
+package com.android.imftest.samples;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.LinearLayout;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+
+import com.android.internal.R;
+
+/*
+ * Activity with EditText selected initially
+ */
+public class OneEditTextActivitySelected extends Activity 
+{
+   @Override
+   public void onCreate(Bundle savedInstanceState) 
+   {
+       super.onCreate(savedInstanceState);
+                
+       LinearLayout layout = new LinearLayout(this);
+       layout.setOrientation(LinearLayout.VERTICAL);
+       
+       final EditText editText = new EditText(this);
+       layout.addView(editText);
+  
+       setContentView(layout);
+       editText.requestFocus();
+    }  
+}
diff --git a/tests/SmokeTest/tests/AndroidManifest.xml b/tests/SmokeTest/tests/AndroidManifest.xml
index 20b33ee..517eb1e 100644
--- a/tests/SmokeTest/tests/AndroidManifest.xml
+++ b/tests/SmokeTest/tests/AndroidManifest.xml
@@ -25,8 +25,6 @@
         <uses-library android:name="android.test.runner" />
     </application>
 
-    <uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />
-
     <!--
     This declares that this app uses the instrumentation test runner targeting
     the package of com.android.smoketest.  To run the tests use the command:
diff --git a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java b/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
index 4994845..0368651 100644
--- a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
+++ b/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
@@ -17,6 +17,7 @@
 package com.android.internal.policy.impl;
 
 import android.content.Context;
+
 import com.android.internal.telephony.SimCard;
 import android.test.AndroidTestCase;
 import android.view.View;
@@ -112,6 +113,11 @@
         }
 
         /** {@inheritDoc} */
+        public boolean needsInput() {
+            return false;
+        }
+        
+        /** {@inheritDoc} */
         public void onPause() {
             mOnPauseCount++;
         }
@@ -149,8 +155,9 @@
 
 
 
-        private TestableLockPatternKeyguardView(Context context, KeyguardUpdateMonitor updateMonitor, LockPatternUtils lockPatternUtils) {
-            super(context, updateMonitor, lockPatternUtils);
+        private TestableLockPatternKeyguardView(Context context, KeyguardUpdateMonitor updateMonitor,
+                LockPatternUtils lockPatternUtils, KeyguardWindowController controller) {
+            super(context, updateMonitor, lockPatternUtils, controller);
         }
 
         @Override
@@ -214,7 +221,11 @@
         mUpdateMonitor = new MockUpdateMonitor(getContext());
         mLockPatternUtils = new MockLockPatternUtils();
 
-        mLPKV = new TestableLockPatternKeyguardView(getContext(), mUpdateMonitor, mLockPatternUtils);
+        mLPKV = new TestableLockPatternKeyguardView(getContext(), mUpdateMonitor,
+                mLockPatternUtils, new KeyguardWindowController() {
+            public void setNeedsInput(boolean needsInput) {
+            }
+        });
         mKeyguardViewCallback = new MockKeyguardCallback();
         mLPKV.setCallback(mKeyguardViewCallback);
     }
diff --git a/tests/GadgetHost/Android.mk b/tests/gadgets/GadgetHostTest/Android.mk
similarity index 82%
copy from tests/GadgetHost/Android.mk
copy to tests/gadgets/GadgetHostTest/Android.mk
index 1d88db8..5e04b81 100644
--- a/tests/GadgetHost/Android.mk
+++ b/tests/gadgets/GadgetHostTest/Android.mk
@@ -5,7 +5,7 @@
 
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
-LOCAL_PACKAGE_NAME := GadgetHost
+LOCAL_PACKAGE_NAME := GadgetHostTest
 LOCAL_CERTIFICATE := platform
 
 include $(BUILD_PACKAGE)
diff --git a/tests/GadgetHost/AndroidManifest.xml b/tests/gadgets/GadgetHostTest/AndroidManifest.xml
similarity index 69%
rename from tests/GadgetHost/AndroidManifest.xml
rename to tests/gadgets/GadgetHostTest/AndroidManifest.xml
index eeb8979..cac2776 100644
--- a/tests/GadgetHost/AndroidManifest.xml
+++ b/tests/gadgets/GadgetHostTest/AndroidManifest.xml
@@ -1,5 +1,5 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.android.gadgethost">
+        package="com.android.tests.gadgethost">
     <uses-permission android:name="android.permission.VIBRATE" />
 
     <application>
@@ -10,13 +10,15 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <activity android:name="GadgetPickActivity">
+        <activity android:name="TestGadgetConfigure" android:label="Configure TestGadgetProvider">
             <intent-filter>
-                <action android:name="android.gadget.action.PICK_GADGET" />
+                <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-        <receiver android:name="TestGadgetProvider">
+        <receiver android:name="TestGadgetProvider" android:label="@string/oh_hai"
+                    android:icon="@drawable/oh_hai_icon">
             <intent-filter>
                 <action android:name="android.gadget.action.GADGET_UPDATE" />
             </intent-filter>
diff --git a/tests/gadgets/GadgetHostTest/res/drawable/oh_hai_icon.png b/tests/gadgets/GadgetHostTest/res/drawable/oh_hai_icon.png
new file mode 100644
index 0000000..30ff267
--- /dev/null
+++ b/tests/gadgets/GadgetHostTest/res/drawable/oh_hai_icon.png
Binary files differ
diff --git a/tests/GadgetHost/res/layout/gadget_host.xml b/tests/gadgets/GadgetHostTest/res/layout/gadget_host.xml
similarity index 93%
rename from tests/GadgetHost/res/layout/gadget_host.xml
rename to tests/gadgets/GadgetHostTest/res/layout/gadget_host.xml
index 824cc44..743f6c6 100644
--- a/tests/GadgetHost/res/layout/gadget_host.xml
+++ b/tests/gadgets/GadgetHostTest/res/layout/gadget_host.xml
@@ -31,10 +31,11 @@
         android:layout_weight="1"
         >
         
-        <com.android.gadgethost.GadgetContainerView
+        <com.android.tests.gadgethost.GadgetContainerView
             android:id="@+id/gadget_container"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:orientation="vertical"
         />
 
     </ScrollView>
diff --git a/tests/GadgetHost/res/layout/test_gadget.xml b/tests/gadgets/GadgetHostTest/res/layout/test_gadget.xml
similarity index 95%
rename from tests/GadgetHost/res/layout/test_gadget.xml
rename to tests/gadgets/GadgetHostTest/res/layout/test_gadget.xml
index 0fb7929..4d483c7 100644
--- a/tests/GadgetHost/res/layout/test_gadget.xml
+++ b/tests/gadgets/GadgetHostTest/res/layout/test_gadget.xml
@@ -15,6 +15,7 @@
 -->
 
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/oh_hai_text"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/oh_hai"
diff --git a/tests/GadgetHost/res/layout/gadget_host.xml b/tests/gadgets/GadgetHostTest/res/layout/test_gadget_configure.xml
similarity index 67%
copy from tests/GadgetHost/res/layout/gadget_host.xml
copy to tests/gadgets/GadgetHostTest/res/layout/test_gadget_configure.xml
index 824cc44..0d9b983 100644
--- a/tests/GadgetHost/res/layout/gadget_host.xml
+++ b/tests/gadgets/GadgetHostTest/res/layout/test_gadget_configure.xml
@@ -15,36 +15,30 @@
 -->
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
     android:layout_width="fill_parent"
-    android:layout_height="fill_parent" >
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    >
 
     <TextView
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:text="@string/gadget_view_title"
-    />
-
-    <ScrollView
+        android:id="@+id/oh_hai_text"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        android:layout_weight="1"
-        >
-        
-        <com.android.gadgethost.GadgetContainerView
-            android:id="@+id/gadget_container"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-        />
+        android:text="@string/oh_hai"
+    />
 
-    </ScrollView>
+    <EditText
+        android:id="@+id/edit_text"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+    />
 
     <Button
-        android:id="@+id/add_gadget"
-        android:text="@string/add_gadget"
-        android:layout_height="wrap_content"
+        android:id="@+id/save_button"
         android:layout_width="wrap_content"
-        />
+        android:layout_height="wrap_content"
+        android:text="@string/save"
+    />
+
 
 </LinearLayout>
-
diff --git a/tests/GadgetHost/res/values/strings.xml b/tests/gadgets/GadgetHostTest/res/values/strings.xml
similarity index 90%
copy from tests/GadgetHost/res/values/strings.xml
copy to tests/gadgets/GadgetHostTest/res/values/strings.xml
index d94cfbd..ad9916a 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/tests/gadgets/GadgetHostTest/res/values/strings.xml
@@ -18,5 +18,7 @@
     <string name="gadget_view_title">Gadget Test</string>
     <string name="add_gadget">Add Gadget</string>
     <string name="oh_hai">Oh hai.</string>
+    <string name="delete_gadget">Delete</string>
+    <string name="save">Save</string>
 </resources>
 
diff --git a/tests/GadgetHost/res/xml/gadget_info.xml b/tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml
similarity index 64%
copy from tests/GadgetHost/res/xml/gadget_info.xml
copy to tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml
index 84d0603..353df30 100644
--- a/tests/GadgetHost/res/xml/gadget_info.xml
+++ b/tests/gadgets/GadgetHostTest/res/xml/gadget_info.xml
@@ -1,7 +1,8 @@
 <gadget-provider xmlns:android="http://schemas.android.com/apk/res/android"
     android:minWidth="40dp"
     android:minHeight="30dp"
-    android:updatePeriodMillis="30000"
+    android:updatePeriodMillis="3000"
     android:initialLayout="@layout/test_gadget"
+    android:configure="com.android.tests.gadgethost.TestGadgetConfigure"
     >
 </gadget-provider>
diff --git a/tests/GadgetHost/src/com/android/gadgethost/GadgetContainerView.java b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetContainerView.java
similarity index 95%
rename from tests/GadgetHost/src/com/android/gadgethost/GadgetContainerView.java
rename to tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetContainerView.java
index 159cbe4..3814836 100644
--- a/tests/GadgetHost/src/com/android/gadgethost/GadgetContainerView.java
+++ b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetContainerView.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.gadgethost;
+package com.android.tests.gadgethost;
 
 import android.content.Context;
 import android.util.AttributeSet;
diff --git a/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java
new file mode 100644
index 0000000..d3dcf41
--- /dev/null
+++ b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/GadgetHostActivity.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tests.gadgethost;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.gadget.GadgetHost;
+import android.gadget.GadgetHostView;
+import android.gadget.GadgetInfo;
+import android.gadget.GadgetManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.ContextMenu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.LinearLayout;
+
+public class GadgetHostActivity extends Activity
+{
+    static final String TAG = "GadgetHostActivity";
+
+    static final int DISCOVER_GADGET_REQUEST = 1;
+    static final int CONFIGURE_GADGET_REQUEST = 2;
+    static final int HOST_ID = 1234;
+
+    static final String PENDING_GADGET_ID = "pending_gadget";
+    
+    GadgetManager mGadgetManager;
+    GadgetContainerView mGadgetContainer;
+
+    public GadgetHostActivity() {
+        mGadgetManager = GadgetManager.getInstance(this);
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        setContentView(R.layout.gadget_host);
+
+        findViewById(R.id.add_gadget).setOnClickListener(mOnClickListener);
+        mGadgetContainer = (GadgetContainerView)findViewById(R.id.gadget_container);
+
+        if (false) {
+            if (false) {
+                mHost.deleteHost();
+            } else {
+                GadgetHost.deleteAllHosts();
+            }
+        }
+    }
+
+    View.OnClickListener mOnClickListener = new View.OnClickListener() {
+        public void onClick(View v) {
+            discoverGadget(DISCOVER_GADGET_REQUEST);
+        }
+    };
+
+    void discoverGadget(int requestCode) {
+        Intent intent = new Intent(GadgetManager.GADGET_PICK_ACTION);
+        intent.putExtra(GadgetManager.EXTRA_HOST_ID, HOST_ID);
+        intent.putExtra(GadgetManager.EXTRA_GADGET_ID, mHost.allocateGadgetId());
+        startActivityForResult(intent, requestCode);
+    }
+
+    void configureGadget(int requestCode, int gadgetId, ComponentName configure) {
+        Intent intent = new Intent(GadgetManager.GADGET_CONFIGURE_ACTION);
+        intent.setComponent(configure);
+        intent.putExtra(GadgetManager.EXTRA_GADGET_ID, gadgetId);
+        SharedPreferences.Editor prefs = getPreferences(0).edit();
+        prefs.putInt(PENDING_GADGET_ID, gadgetId);
+        prefs.commit();
+        startActivityForResult(intent, requestCode);
+    }
+
+    void handleGadgetPickResult(int resultCode, Intent data) {
+        Bundle extras = data.getExtras();
+        int gadgetId = extras.getInt(GadgetManager.EXTRA_GADGET_ID);
+        if (resultCode == RESULT_OK) {
+            GadgetInfo gadget = mGadgetManager.getGadgetInfo(gadgetId);
+
+            if (gadget.configure != null) {
+                // configure the gadget if we should
+                configureGadget(CONFIGURE_GADGET_REQUEST, gadgetId, gadget.configure);
+            } else {
+                // just add it as is
+                addGadgetView(gadgetId, gadget);
+            }
+        } else {
+            mHost.deleteGadgetId(gadgetId);
+        }
+    }
+
+    void handleGadgetConfigureResult(int resultCode, Intent data) {
+        int gadgetId = getPreferences(0).getInt(PENDING_GADGET_ID, -1);
+        Log.d(TAG, "resultCode=" + resultCode + " gadgetId=" + gadgetId);
+        if (gadgetId < 0) {
+            Log.w(TAG, "was no preference for PENDING_GADGET_ID");
+            return;
+        }
+        if (resultCode == RESULT_OK) {
+            GadgetInfo gadget = mGadgetManager.getGadgetInfo(gadgetId);
+            addGadgetView(gadgetId, gadget);
+        } else {
+            mHost.deleteGadgetId(gadgetId);
+        }
+    }
+
+    void addGadgetView(int gadgetId, GadgetInfo gadget) {
+        // Inflate the gadget's RemoteViews
+        GadgetHostView view = mHost.createView(this, gadgetId, gadget);
+
+        // Add it to the list
+        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
+                LinearLayout.LayoutParams.FILL_PARENT,
+                LinearLayout.LayoutParams.WRAP_CONTENT);
+        mGadgetContainer.addView(view, layoutParams);
+
+        registerForContextMenu(view);
+    }
+
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        switch (requestCode) {
+        case DISCOVER_GADGET_REQUEST:
+            handleGadgetPickResult(resultCode, data);
+            break;
+        case CONFIGURE_GADGET_REQUEST:
+            handleGadgetConfigureResult(resultCode, data);
+        }
+    }
+
+    protected void onStart() {
+        super.onStart();
+        mHost.startListening();
+    }
+
+    protected void onStop() {
+        super.onStop();
+        mHost.stopListening();
+    }
+
+    public void onCreateContextMenu(ContextMenu menu, View v,
+            ContextMenu.ContextMenuInfo menuInfo) {
+        menu.add(ContextMenu.NONE, R.string.delete_gadget, ContextMenu.NONE,
+                R.string.delete_gadget);
+    }
+
+    public boolean onContextItemSelected(MenuItem item) {
+        MyGadgetView view = (MyGadgetView)item.getMenuInfo();
+        switch (item.getItemId()) {
+        case R.string.delete_gadget:
+            Log.d(TAG, "delete! " + view.gadgetId);
+            mGadgetContainer.removeView(view);
+            mHost.deleteGadgetId(view.gadgetId);
+            break;
+        }
+
+        return true;
+    }
+
+    class MyGadgetView extends GadgetHostView implements ContextMenu.ContextMenuInfo {
+        int gadgetId;
+
+        MyGadgetView(int gadgetId) {
+            super(GadgetHostActivity.this);
+            this.gadgetId = gadgetId;
+        }
+
+        public ContextMenu.ContextMenuInfo getContextMenuInfo() {
+            return this;
+        }
+    }
+
+    GadgetHost mHost = new GadgetHost(this, HOST_ID) {
+        protected GadgetHostView onCreateView(Context context, int gadgetId, GadgetInfo gadget) {
+            return new MyGadgetView(gadgetId);
+        }
+    };
+
+}
+
+
diff --git a/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetConfigure.java b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetConfigure.java
new file mode 100644
index 0000000..897c13c
--- /dev/null
+++ b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetConfigure.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tests.gadgethost;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.EditText;
+
+public class TestGadgetConfigure extends Activity {
+    static final String TAG = "TestGadgetConfigure";
+
+    public TestGadgetConfigure() {
+        super();
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        setContentView(R.layout.test_gadget_configure);
+
+        findViewById(R.id.save_button).setOnClickListener(mOnClickListener);
+    }
+
+    View.OnClickListener mOnClickListener = new View.OnClickListener() {
+        public void onClick(View v) {
+            String text = ((EditText)findViewById(R.id.edit_text)).getText().toString();
+            Log.d(TAG, "text is '" + text + '\'');
+            SharedPreferences.Editor prefs = getSharedPreferences(TestGadgetProvider.PREFS_NAME, 0)
+                    .edit();
+            prefs.putString(TestGadgetProvider.PREF_PREFIX_KEY, text);
+            prefs.commit();
+            setResult(RESULT_OK);
+            finish();
+        }
+    };
+
+}
+
+
diff --git a/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java
new file mode 100644
index 0000000..7614c9e
--- /dev/null
+++ b/tests/gadgets/GadgetHostTest/src/com/android/tests/gadgethost/TestGadgetProvider.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tests.gadgethost;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.gadget.GadgetManager;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+public class TestGadgetProvider extends BroadcastReceiver {
+    static final String TAG = "TestGadgetProvider";
+
+    static final String PREFS_NAME = "com.android.tests.gadgethost.TestGadgetProvider";
+    static final String PREF_PREFIX_KEY = "prefix";
+
+    public void onReceive(Context context, Intent intent) {
+        String action = intent.getAction();
+        Log.d(TAG, "intent=" + intent);
+
+        if (GadgetManager.GADGET_ENABLED_ACTION.equals(action)) {
+            Log.d(TAG, "ENABLED");
+        }
+        else if (GadgetManager.GADGET_DISABLED_ACTION.equals(action)) {
+            Log.d(TAG, "DISABLED");
+        }
+        else if (GadgetManager.GADGET_UPDATE_ACTION.equals(action)) {
+            Log.d(TAG, "UPDATE");
+            Bundle extras = intent.getExtras();
+            int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS);
+
+            SharedPreferences prefs = context.getSharedPreferences(
+                    TestGadgetProvider.PREFS_NAME, 0);
+            String prefix = prefs.getString(PREF_PREFIX_KEY, "hai");
+
+            GadgetManager gm = GadgetManager.getInstance(context);
+            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_gadget);
+            views.setTextViewText(R.id.oh_hai_text, prefix + ": " + SystemClock.elapsedRealtime());
+            if (false) {
+                gm.updateGadget(gadgetIds, views);
+            } else {
+                gm.updateGadget(new ComponentName("com.android.tests.gadgethost",
+                            "com.android.tests.gadgethost.TestGadgetProvider"), views);
+            }
+        }
+    }
+}
+
diff --git a/tests/GadgetHost/Android.mk b/tests/gadgets/GadgetProviderTest/Android.mk
similarity index 82%
rename from tests/GadgetHost/Android.mk
rename to tests/gadgets/GadgetProviderTest/Android.mk
index 1d88db8..b9bfcdb 100644
--- a/tests/GadgetHost/Android.mk
+++ b/tests/gadgets/GadgetProviderTest/Android.mk
@@ -5,7 +5,7 @@
 
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
-LOCAL_PACKAGE_NAME := GadgetHost
+LOCAL_PACKAGE_NAME := GadgetProvider
 LOCAL_CERTIFICATE := platform
 
 include $(BUILD_PACKAGE)
diff --git a/tests/gadgets/GadgetProviderTest/AndroidManifest.xml b/tests/gadgets/GadgetProviderTest/AndroidManifest.xml
new file mode 100644
index 0000000..47a7a2e
--- /dev/null
+++ b/tests/gadgets/GadgetProviderTest/AndroidManifest.xml
@@ -0,0 +1,13 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+        package="com.android.tests.gadgetprovider">
+    <uses-permission android:name="android.permission.VIBRATE" />
+
+    <application>
+        <receiver android:name="TestGadgetProvider">
+            <intent-filter>
+                <action android:name="android.gadget.action.GADGET_UPDATE" />
+            </intent-filter>
+            <meta-data android:name="android.gadget.provider" android:resource="@xml/gadget_info" />
+        </receiver>
+    </application>
+</manifest>
diff --git a/tests/GadgetHost/res/layout/test_gadget.xml b/tests/gadgets/GadgetProviderTest/res/layout/test_gadget.xml
similarity index 95%
copy from tests/GadgetHost/res/layout/test_gadget.xml
copy to tests/gadgets/GadgetProviderTest/res/layout/test_gadget.xml
index 0fb7929..4d483c7 100644
--- a/tests/GadgetHost/res/layout/test_gadget.xml
+++ b/tests/gadgets/GadgetProviderTest/res/layout/test_gadget.xml
@@ -15,6 +15,7 @@
 -->
 
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/oh_hai_text"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/oh_hai"
diff --git a/tests/GadgetHost/res/values/strings.xml b/tests/gadgets/GadgetProviderTest/res/values/strings.xml
similarity index 94%
rename from tests/GadgetHost/res/values/strings.xml
rename to tests/gadgets/GadgetProviderTest/res/values/strings.xml
index d94cfbd..e07725f 100644
--- a/tests/GadgetHost/res/values/strings.xml
+++ b/tests/gadgets/GadgetProviderTest/res/values/strings.xml
@@ -18,5 +18,6 @@
     <string name="gadget_view_title">Gadget Test</string>
     <string name="add_gadget">Add Gadget</string>
     <string name="oh_hai">Oh hai.</string>
+    <string name="delete_gadget">Delete</string>
 </resources>
 
diff --git a/tests/GadgetHost/res/xml/gadget_info.xml b/tests/gadgets/GadgetProviderTest/res/xml/gadget_info.xml
similarity index 83%
rename from tests/GadgetHost/res/xml/gadget_info.xml
rename to tests/gadgets/GadgetProviderTest/res/xml/gadget_info.xml
index 84d0603..0b8ca2e 100644
--- a/tests/GadgetHost/res/xml/gadget_info.xml
+++ b/tests/gadgets/GadgetProviderTest/res/xml/gadget_info.xml
@@ -1,7 +1,7 @@
 <gadget-provider xmlns:android="http://schemas.android.com/apk/res/android"
     android:minWidth="40dp"
     android:minHeight="30dp"
-    android:updatePeriodMillis="30000"
+    android:updatePeriodMillis="3000"
     android:initialLayout="@layout/test_gadget"
     >
 </gadget-provider>
diff --git a/tests/gadgets/GadgetProviderTest/src/com/android/tests/gadgetprovider/TestGadgetProvider.java b/tests/gadgets/GadgetProviderTest/src/com/android/tests/gadgetprovider/TestGadgetProvider.java
new file mode 100644
index 0000000..8622bc7
--- /dev/null
+++ b/tests/gadgets/GadgetProviderTest/src/com/android/tests/gadgetprovider/TestGadgetProvider.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.tests.gadgetprovider;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.gadget.GadgetManager;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+public class TestGadgetProvider extends BroadcastReceiver {
+
+    static final String TAG = "TestGadgetProvider";
+
+    public void onReceive(Context context, Intent intent) {
+        String action = intent.getAction();
+        Log.d(TAG, "intent=" + intent);
+
+        if (GadgetManager.GADGET_ENABLED_ACTION.equals(action)) {
+            Log.d(TAG, "ENABLED");
+        }
+        else if (GadgetManager.GADGET_DISABLED_ACTION.equals(action)) {
+            Log.d(TAG, "DISABLED");
+        }
+        else if (GadgetManager.GADGET_UPDATE_ACTION.equals(action)) {
+            Log.d(TAG, "UPDATE");
+            Bundle extras = intent.getExtras();
+            int[] gadgetIds = extras.getIntArray(GadgetManager.EXTRA_GADGET_IDS);
+
+            GadgetManager gm = GadgetManager.getInstance(context);
+            RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.test_gadget);
+            views.setTextViewText(R.id.oh_hai_text, "hai: " + SystemClock.elapsedRealtime());
+            if (false) {
+                gm.updateGadget(gadgetIds, views);
+            } else {
+                gm.updateGadget(new ComponentName("com.android.tests.gadgetprovider",
+                            "com.android.tests.gadgetprovider.TestGadgetProvider"), views);
+            }
+        }
+    }
+}
+
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index a516a5a..4c776fb 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -600,10 +600,22 @@
     return true;
 }
 
-static void dump_image(int w, int h, png_bytepp rows, int bpp)
+static void dump_image(int w, int h, png_bytepp rows, int color_type)
 {
     int i, j, rr, gg, bb, aa;
 
+    int bpp;
+    if (color_type == PNG_COLOR_TYPE_PALETTE || color_type == PNG_COLOR_TYPE_GRAY) {
+        bpp = 1;
+    } else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
+        bpp = 2;
+    } else if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
+	    // We use a padding byte even when there is no alpha
+        bpp = 4;
+    } else {
+        printf("Unknown color type %d.\n", color_type);
+    }
+
     for (j = 0; j < h; j++) {
         png_bytep row = rows[j];
         for (i = 0; i < w; i++) {
@@ -640,7 +652,7 @@
 #define MAX(a,b) ((a)>(b)?(a):(b))
 #define ABS(a)   ((a)<0?-(a):(a))
 
-static void analyze_image(image_info &imageInfo, int grayscaleTolerance,
+static void analyze_image(const char *imageName, image_info &imageInfo, int grayscaleTolerance,
                           png_colorp rgbPalette, png_bytep alphaPalette,
                           int *paletteEntries, bool *hasTransparency, int *colorType,
                           png_bytepp outRows)
@@ -662,7 +674,7 @@
     // 3. There are no more than 256 distinct RGBA colors
 
     // NOISY(printf("Initial image data:\n"));
-    // dump_image(w, h, imageInfo.rows, 4);
+    // dump_image(w, h, imageInfo.rows, PNG_COLOR_TYPE_RGB_ALPHA);
 
     for (j = 0; j < h; j++) {
         png_bytep row = imageInfo.rows[j];
@@ -763,7 +775,7 @@
         *colorType = PNG_COLOR_TYPE_PALETTE;
     } else {
         if (maxGrayDeviation <= grayscaleTolerance) {
-            NOISY(printf("Forcing image to gray (max deviation = %d)\n", maxGrayDeviation));
+            printf("%s: forcing image to gray (max deviation = %d)\n", imageName, maxGrayDeviation);
             *colorType = isOpaque ? PNG_COLOR_TYPE_GRAY : PNG_COLOR_TYPE_GRAY_ALPHA;
         } else {
             *colorType = isOpaque ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA;
@@ -845,7 +857,7 @@
     bool hasTransparency;
     int paletteEntries;
 
-    analyze_image(imageInfo, grayscaleTolerance, rgbPalette, alphaPalette,
+    analyze_image(imageName, imageInfo, grayscaleTolerance, rgbPalette, alphaPalette,
                   &paletteEntries, &hasTransparency, &color_type, outRows);
     switch (color_type) {
     case PNG_COLOR_TYPE_PALETTE:
@@ -910,21 +922,8 @@
     }
     png_write_image(write_ptr, rows);
 
-//     int bpp;
-//     if (color_type == PNG_COLOR_TYPE_PALETTE || color_type == PNG_COLOR_TYPE_GRAY) {
-//         bpp = 1;
-//     } else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
-//         bpp = 2;
-//     } else if (color_type == PNG_COLOR_TYPE_RGB) {
-//         bpp = 4;
-//     } else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
-//         bpp = 4;
-//     } else {
-//         printf("Uknknown color type %d, exiting.\n", color_type);
-//         exit(1);
-//     }
 //     NOISY(printf("Final image data:\n"));
-//     dump_image(imageInfo.width, imageInfo.height, rows, bpp);
+//     dump_image(imageInfo.width, imageInfo.height, rows, color_type);
 
     png_write_end(write_ptr, write_info);
 
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index ee0dbad..71b1a3c 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -146,9 +146,11 @@
  */
 int main(int argc, char* const argv[])
 {
+    char *prog = argv[0];
     Bundle bundle;
     bool wantUsage = false;
     int result = 1;    // pessimistically assume an error.
+    int tolerance = 0;
 
     /* default to compression */
     bundle.setCompressionMethod(ZipEntry::kCompressDeflated);
@@ -214,7 +216,9 @@
                     wantUsage = true;
                     goto bail;
                 }
-                bundle.setGrayscaleTolerance(atoi(argv[0]));
+                tolerance = atoi(argv[0]);
+                bundle.setGrayscaleTolerance(tolerance);
+                printf("%s: Images with deviation <= %d will be forced to grayscale.\n", prog, tolerance);
                 break;
             case 'm':
                 bundle.setMakePackageDirs(true);
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index c438366..6f71a1ed 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -644,6 +644,7 @@
     const String16 bool16("bool");
     const String16 integer16("integer");
     const String16 dimen16("dimen");
+    const String16 fraction16("fraction");
     const String16 style16("style");
     const String16 plurals16("plurals");
     const String16 array16("array");
@@ -1022,6 +1023,10 @@
                 curTag = &dimen16;
                 curType = dimen16;
                 curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_DIMENSION;
+            } else if (strcmp16(block.getElementName(&len), fraction16.string()) == 0) {
+                curTag = &fraction16;
+                curType = fraction16;
+                curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_FRACTION;
             } else if (strcmp16(block.getElementName(&len), bag16.string()) == 0) {
                 curTag = &bag16;
                 curIsBag = true;
diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp
index 2ea453c..d476567 100644
--- a/tools/aapt/XMLNode.cpp
+++ b/tools/aapt/XMLNode.cpp
@@ -220,9 +220,9 @@
             spanStack.pop();
 
             if (empty) {
-                fprintf(stderr, "%s:%d: WARNING: empty '%s' span found for at text '%s'\n",
+                fprintf(stderr, "%s:%d: WARNING: empty '%s' span found in text '%s'\n",
                         fileName, inXml->getLineNumber(),
-                        String8(*outString).string(), String8(spanTag).string());
+                        String8(spanTag).string(), String8(*outString).string());
 
             }
         } else if (code == ResXMLTree::START_NAMESPACE) {
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint.java b/tools/layoutlib/bridge/src/android/graphics/Paint.java
index 13cc62d..ade07d6 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint.java
@@ -380,7 +380,6 @@
         int filterNative = 0;
         if (filter != null)
             filterNative = filter.native_instance;
-        native_setColorFilter(mNativePaint, filterNative);
         mColorFilter = filter;
         return filter;
     }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index f5087d9..39200a1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -27,8 +27,8 @@
 import com.android.layoutlib.api.ILayoutResult.ILayoutViewInfo;
 import com.android.layoutlib.bridge.LayoutResult.LayoutViewInfo;
 import com.android.ninepatch.NinePatch;
-import com.android.tools.layoutlib.create.OverrideMethod;
 import com.android.tools.layoutlib.create.MethodAdapter;
+import com.android.tools.layoutlib.create.OverrideMethod;
 
 import android.graphics.Bitmap;
 import android.graphics.Rect;
@@ -307,32 +307,33 @@
                 projectResources.get(BridgeConstants.RES_STYLE),
                 frameworkResources.get(BridgeConstants.RES_STYLE), styleParentMap);
         
-        BridgeContext context = new BridgeContext(projectKey, currentTheme, projectResources,
-                frameworkResources, styleParentMap, customViewLoader, logger);
-        BridgeInflater inflater = new BridgeInflater(context, customViewLoader);
-        context.setBridgeInflater(inflater);
-        
-        IResourceValue windowBackground = null;
-        int screenOffset = 0;
-        if (currentTheme != null) {
-            windowBackground = context.findItemInStyle(currentTheme, "windowBackground");
-            windowBackground = context.resolveResValue(windowBackground);
-
-            screenOffset = getScreenOffset(currentTheme, context);
-        }
-        
-        // we need to make sure the Looper has been initialized for this thread.
-        // this is required for View that creates Handler objects.
-        if (Looper.myLooper() == null) {
-            Looper.prepare();
-        }
-        
-        BridgeXmlBlockParser parser = new BridgeXmlBlockParser(layoutDescription,
-                context, false /* platformResourceFlag */);
-        
-        ViewGroup root = new FrameLayout(context);
-        
+        BridgeContext context = null; 
         try {
+            context = new BridgeContext(projectKey, currentTheme, projectResources,
+                    frameworkResources, styleParentMap, customViewLoader, logger);
+            BridgeInflater inflater = new BridgeInflater(context, customViewLoader);
+            context.setBridgeInflater(inflater);
+            
+            IResourceValue windowBackground = null;
+            int screenOffset = 0;
+            if (currentTheme != null) {
+                windowBackground = context.findItemInStyle(currentTheme, "windowBackground");
+                windowBackground = context.resolveResValue(windowBackground);
+    
+                screenOffset = getScreenOffset(currentTheme, context);
+            }
+            
+            // we need to make sure the Looper has been initialized for this thread.
+            // this is required for View that creates Handler objects.
+            if (Looper.myLooper() == null) {
+                Looper.prepare();
+            }
+            
+            BridgeXmlBlockParser parser = new BridgeXmlBlockParser(layoutDescription,
+                    context, false /* platformResourceFlag */);
+            
+            ViewGroup root = new FrameLayout(context);
+        
             View view = inflater.inflate(parser, root);
             
             // set the AttachInfo on the root view.
@@ -381,6 +382,10 @@
             return new LayoutResult(ILayoutResult.ERROR,
                     t.getClass().getSimpleName() + ": " + t.getMessage());
         } finally {
+            // Make sure to remove static references, otherwise we could not unload the lib
+            BridgeResources.clearSystem();
+            BridgeAssetManager.clearSystem();
+            
             // Remove the global logger
             synchronized (sDefaultLogger) {
                 sLogger = sDefaultLogger;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeAssetManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeAssetManager.java
index 02545af..1fa11af 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeAssetManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeAssetManager.java
@@ -24,9 +24,36 @@
 public class BridgeAssetManager extends AssetManager {
     
     /**
-     * Change the configuation used when retrieving resources.  Not for use by
-     * applications.
-     * {@hide}
+     * This initializes the static field {@link AssetManager#mSystem} which is used
+     * by methods who get a global asset manager using {@link AssetManager#getSystem()}.
+     * <p/>
+     * They will end up using our bridge asset manager.
+     * <p/>
+     * {@link Bridge} calls this method after setting up a new bridge.
+     */
+    /*package*/ static AssetManager initSystem() {
+        if (!(AssetManager.mSystem instanceof BridgeAssetManager)) {
+            // Note that AssetManager() creates a system AssetManager and we override it
+            // with our BridgeAssetManager.
+            AssetManager.mSystem = new BridgeAssetManager();
+            AssetManager.mSystem.makeStringBlocks(false);
+        }
+        return AssetManager.mSystem;
+    }
+    
+    /**
+     * Clears the static {@link AssetManager#mSystem} to make sure we don't leave objects
+     * around that would prevent us from unloading the library.
+     */
+    /*package*/ static void clearSystem() {
+        AssetManager.mSystem = null;
+    }
+    
+    private BridgeAssetManager() {
+    }
+    
+    /**
+     * Change the configuration used when retrieving resources.  Not for use by applications.
      */
     @Override
     public void setConfiguration(int mcc, int mnc, String locale,
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContentResolver.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContentResolver.java
new file mode 100644
index 0000000..727d6f2
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContentResolver.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.layoutlib.bridge;
+
+import android.content.ContentResolver;
+import android.content.ContentServiceNative;
+import android.content.Context;
+import android.content.IContentProvider;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Bundle;
+
+/**
+ * A mock content resolver for the LayoutLib Bridge.
+ * <p/>
+ * It won't serve any actual data but it's good enough for all
+ * the widgets which expect to have a content resolver available via
+ * {@link BridgeContext#getContentResolver()}.
+ */
+public class BridgeContentResolver extends ContentResolver {
+
+    public BridgeContentResolver(Context context) {
+        super(context);
+    }
+
+    @Override
+    public IContentProvider acquireProvider(Context c, String name) {
+        // ignore
+        return null;
+    }
+
+    @Override
+    public boolean releaseProvider(IContentProvider icp) {
+        // ignore
+        return false;
+    }
+    
+    /**
+     * Stub for the layoutlib bridge content resolver.
+     * <p/>
+     * The super implementation accesses the {@link ContentServiceNative#getDefault()}
+     * which returns null and would make the call crash. Instead we do nothing.
+     */
+    @Override
+    public void registerContentObserver(Uri uri, boolean notifyForDescendents,
+            ContentObserver observer) {
+        // pass
+    }
+    
+    /**
+     * Stub for the layoutlib bridge content resolver.
+     * <p/>
+     * The super implementation accesses the {@link ContentServiceNative#getDefault()}
+     * which returns null and would make the call crash. Instead we do nothing.
+     */
+    @Override
+    public void unregisterContentObserver(ContentObserver observer) {
+        // pass
+    }
+    
+    /**
+     * Stub for the layoutlib bridge content resolver.
+     * <p/>
+     * The super implementation accesses the {@link ContentServiceNative#getDefault()}
+     * which returns null and would make the call crash. Instead we do nothing.
+     */
+    @Override
+    public void notifyChange(Uri uri, ContentObserver observer, boolean syncToNetwork) {
+        // pass
+    }
+    
+    /**
+     * Stub for the layoutlib bridge content resolver.
+     * <p/>
+     * The super implementation accesses the {@link ContentServiceNative#getDefault()}
+     * which returns null and would make the call crash. Instead we do nothing.
+     */
+    @Override
+    public void startSync(Uri uri, Bundle extras) {
+        // pass
+    }
+    
+    /**
+     * Stub for the layoutlib bridge content resolver.
+     * <p/>
+     * The super implementation accesses the {@link ContentServiceNative#getDefault()}
+     * which returns null and would make the call crash. Instead we do nothing.
+     */
+    @Override
+    public void cancelSync(Uri uri) {
+        // pass
+    }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
index cb9509b..0df20e4d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeContext.java
@@ -84,6 +84,7 @@
 
     private final IProjectCallback mProjectCallback;
     private final ILayoutLog mLogger;
+    private BridgeContentResolver mContentResolver;
 
     /**
      * @param projectKey
@@ -107,9 +108,11 @@
         DisplayMetrics metrics = new DisplayMetrics();
         metrics.setToDefaults();
         
-        mResources = new BridgeResources(
+
+        AssetManager assetManager = BridgeAssetManager.initSystem();
+        mResources = BridgeResources.initSystem(
                 this,
-                new BridgeAssetManager(),
+                assetManager,
                 metrics,
                 config,
                 customViewLoader);
@@ -168,6 +171,12 @@
         if (LAYOUT_INFLATER_SERVICE.equals(service)) {
             return mInflater;
         }
+        
+        // AutoCompleteTextView and MultiAutoCompleteTextView want a window 
+        // service. We don't have any but it's not worth an exception.
+        if (WINDOW_SERVICE.equals(service)) {
+            return null;
+        }
 
         throw new UnsupportedOperationException("Unsupported Service: " + service);
     }
@@ -899,8 +908,10 @@
 
     @Override
     public ContentResolver getContentResolver() {
-        // TODO Auto-generated method stub
-        return null;
+        if (mContentResolver == null) {
+            mContentResolver = new BridgeContentResolver(this);
+        }
+        return mContentResolver;
     }
 
     @Override
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java
index 6ab6e32..0bcc7fd 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeResources.java
@@ -51,11 +51,46 @@
     private IProjectCallback mProjectCallback;
     private boolean[] mPlatformResourceFlag = new boolean[1];
     
-    public BridgeResources(BridgeContext context, AssetManager assets, DisplayMetrics metrics,
-            Configuration config, IProjectCallback projetCallback) {
+    /**
+     * This initializes the static field {@link Resources#mSystem} which is used
+     * by methods who get global resources using {@link Resources#getSystem()}.
+     * <p/>
+     * They will end up using our bridge resources.
+     * <p/>
+     * {@link Bridge} calls this method after setting up a new bridge.
+     */
+    /*package*/ static Resources initSystem(BridgeContext context, 
+            AssetManager assets,
+            DisplayMetrics metrics,
+            Configuration config,
+            IProjectCallback projectCallback) {
+        if (!(Resources.mSystem instanceof BridgeResources)) {
+            Resources.mSystem = new BridgeResources(context,
+                    assets,
+                    metrics,
+                    config,
+                    projectCallback);
+        }
+        return Resources.mSystem;
+    }
+    
+    /**
+     * Clears the static {@link Resources#mSystem} to make sure we don't leave objects
+     * around that would prevent us from unloading the library.
+     */
+    /*package*/ static void clearSystem() {
+        if (Resources.mSystem instanceof BridgeResources) {
+            ((BridgeResources)(Resources.mSystem)).mContext = null;
+            ((BridgeResources)(Resources.mSystem)).mProjectCallback = null;
+        }
+        Resources.mSystem = null;
+    }
+
+    private BridgeResources(BridgeContext context, AssetManager assets, DisplayMetrics metrics,
+            Configuration config, IProjectCallback projectCallback) {
         super(assets, metrics, config);
         mContext = context;
-        mProjectCallback = projetCallback;
+        mProjectCallback = projectCallback;
     }
     
     public BridgeTypedArray newTypeArray(int numEntries, boolean platformFile) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/MockView.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/MockView.java
index ca3c8b0..1ca3182 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/MockView.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/MockView.java
@@ -24,7 +24,8 @@
 /**
  * Base class for mocked views.
  * 
- * TODO: implement onDraw and draw a rectangle in a random color with the name of the class (or better the id of the view).
+ * TODO: implement onDraw and draw a rectangle in a random color with the name of the class
+ * (or better the id of the view).
  */
 public class MockView extends TextView {
     
diff --git a/tools/preload/Compile.java b/tools/preload/Compile.java
index 8388b12..67258ef 100644
--- a/tools/preload/Compile.java
+++ b/tools/preload/Compile.java
@@ -15,26 +15,22 @@
  */
 
 import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.IOException;
 import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.BufferedOutputStream;
-import java.util.List;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
-import java.lang.reflect.InvocationTargetException;
+import java.util.List;
 
 /**
  * Parses and analyzes a log, pulling our PRELOAD information. If you have
  * an emulator or device running in the background, this class will use it
  * to measure and record the memory usage of each class.
+ * 
+ * TODO: Should analyze lines and select substring dynamically (instead of hardcoded 19)
  */
 public class Compile {
 
-    public static void main(String[] args)
-            throws IOException, NoSuchMethodException, IllegalAccessException,
-            InvocationTargetException {
+    public static void main(String[] args) throws IOException {
         if (args.length != 2) {
             System.err.println("Usage: Compile [log file] [output file]");
             System.exit(0);
@@ -48,10 +44,17 @@
                 new FileInputStream(args[0])));
 
         String line;
+        int lineNumber = 0;
         while ((line = in.readLine()) != null) {
+            lineNumber++;
             if (line.startsWith("I/PRELOAD")) {
-                line = line.substring(19);
-                records.add(new Record(line));
+                try {
+                    String clipped = line.substring(19);
+                    records.add(new Record(clipped, lineNumber));
+                } catch (RuntimeException e) {
+                    throw new RuntimeException(
+                            "Exception while recording line " + lineNumber + ": " + line, e);
+                }
             }
         }
 
diff --git a/tools/preload/LoadedClass.java b/tools/preload/LoadedClass.java
index 6b3d345..5782807 100644
--- a/tools/preload/LoadedClass.java
+++ b/tools/preload/LoadedClass.java
@@ -14,12 +14,11 @@
  * limitations under the License.
  */
 
-import java.util.List;
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Set;
-import java.util.HashSet;
-import java.io.Serializable;
 
 /**
  * A loaded class.
@@ -134,6 +133,7 @@
         return name.compareTo(o.name);
     }
 
+    @Override
     public String toString() {
         return name;
     }
diff --git a/tools/preload/MemoryUsage.java b/tools/preload/MemoryUsage.java
index 89717eb..e5dfb2a 100644
--- a/tools/preload/MemoryUsage.java
+++ b/tools/preload/MemoryUsage.java
@@ -32,6 +32,9 @@
     private static final long serialVersionUID = 0;
 
     static final MemoryUsage NOT_AVAILABLE = new MemoryUsage();
+    
+    static int errorCount = 0;
+    static final int MAXIMUM_ERRORS = 10;        // give up after this many fails
 
     final int nativeSharedPages;
     final int javaSharedPages;
@@ -160,6 +163,13 @@
      * Measures memory usage for the given class.
      */
     static MemoryUsage forClass(String className) {
+        
+        // This is a coarse approximation for determining that no device is connected,
+        // or that the communication protocol has changed, but we'll keep going and stop whining.
+        if (errorCount >= MAXIMUM_ERRORS) {
+            return NOT_AVAILABLE;
+        }
+        
         MeasureWithTimeout measurer = new MeasureWithTimeout(className);
 
         new Thread(measurer).start();
@@ -237,6 +247,7 @@
                 if (line == null || !line.startsWith("DECAFBAD,")) {
                     System.err.println("Got bad response for " + className
                             + ": " + line);
+                    errorCount += 1;
                     return NOT_AVAILABLE;
                 }
 
diff --git a/tools/preload/Operation.java b/tools/preload/Operation.java
index 65c9a03..4f1938e 100644
--- a/tools/preload/Operation.java
+++ b/tools/preload/Operation.java
@@ -115,4 +115,22 @@
         }
         return microsInt;
     }
+    
+    /**
+     * Primarily for debugger support
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(type.toString());
+        sb.append(' ');
+        sb.append(loadedClass.toString());
+        if (subops.size() > 0) {
+            sb.append(" (");
+            sb.append(subops.size());
+            sb.append(" sub ops)");
+        }
+        return sb.toString();
+    }
+
 }
diff --git a/tools/preload/Policy.java b/tools/preload/Policy.java
new file mode 100644
index 0000000..554966b
--- /dev/null
+++ b/tools/preload/Policy.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * This is not instantiated - we just provide data for other classes to use
+ */
+public class Policy {
+    
+    /**
+     * This location (in the build system) of the preloaded-classes file.
+     */
+    private static final String PRELOADED_CLASS_FILE = "frameworks/base/preloaded-classes";
+    
+    /**
+     * The internal process name of the system process.  Note, this also shows up as
+     * "system_process", e.g. in ddms.
+     */
+    private static final String SYSTEM_SERVER_PROCESS_NAME = "system_server";
+
+    /** 
+     * Names of non-application processes - these will not be checked for preloaded classes.
+     * 
+     * TODO: Replace this hardcoded list with a walk up the parent chain looking for zygote.
+     */
+    private static final Set<String> NOT_FROM_ZYGOTE = new HashSet<String>(Arrays.asList(
+            "zygote",
+            "dexopt",
+            "unknown",
+            SYSTEM_SERVER_PROCESS_NAME,
+            "com.android.development",
+            "app_process" // am & other shell commands
+    ));
+
+    /** 
+     * Long running services.  These are restricted in their contribution to the preloader
+     * because their launch time is less critical.
+     */
+    private static final Set<String> SERVICES = new HashSet<String>(Arrays.asList(
+            SYSTEM_SERVER_PROCESS_NAME,
+            "com.android.acore",
+         // Commented out to make sure DefaultTimeZones gets preloaded.
+         // "com.android.phone",
+            "com.google.process.content",
+            "android.process.media"
+    ));
+
+    /**
+     * Classes which we shouldn't load from the Zygote.
+     */
+    private static final Set<String> EXCLUDED_CLASSES = new HashSet<String>(Arrays.asList(
+        // Binders
+        "android.app.AlarmManager",
+        "android.app.SearchManager",
+        "android.os.FileObserver",
+        "com.android.server.PackageManagerService$AppDirObserver",
+
+        // Threads
+        "android.os.AsyncTask",
+        "android.pim.ContactsAsyncHelper",
+        "java.lang.ProcessManager"
+        
+    ));
+
+    /**
+     * No constructor - use static methods only
+     */
+    private Policy() {}
+    
+    /**
+     * Returns the path/file name of the preloaded classes file that will be written 
+     * by WritePreloadedClassFile.
+     */
+    public static String getPreloadedClassFileName() {
+        return PRELOADED_CLASS_FILE;
+    }
+    
+    /**
+     * Reports if a given process name was created from zygote
+     */
+    public static boolean isFromZygote(String processName) {
+        return !NOT_FROM_ZYGOTE.contains(processName);
+    }
+    
+    /**
+     * Reports if the given process name is a "long running" process or service
+     */
+    public static boolean isService(String processName) {
+        return SERVICES.contains(processName);
+    }
+    
+    /**
+     * Reports if the given class should never be preloaded
+     */
+    public static boolean isPreloadableClass(String className) {
+        return !EXCLUDED_CLASSES.contains(className);
+    }
+}
diff --git a/tools/preload/Proc.java b/tools/preload/Proc.java
index 0b27a51..22697f8 100644
--- a/tools/preload/Proc.java
+++ b/tools/preload/Proc.java
@@ -43,49 +43,6 @@
      */
     static final int MAX_TO_PRELOAD = 100;
 
-    /** Name of system server process. */
-    private static final String SYSTEM_SERVER = "system_server";
-
-    /** Names of non-application processes. */
-    private static final Set<String> NOT_FROM_ZYGOTE
-            = new HashSet<String>(Arrays.asList(
-                    "zygote",
-                    "dexopt",
-                    "unknown",
-                    SYSTEM_SERVER,
-                    "com.android.development",
-                    "app_process" // am
-            ));
-
-    /** Long running services. */
-    private static final Set<String> SERVICES
-            = new HashSet<String>(Arrays.asList(
-                    SYSTEM_SERVER,
-                    "com.android.home",
-// Commented out to make sure DefaultTimeZones gets preloaded.
-//                    "com.android.phone",
-                    "com.google.process.content",
-                    "com.android.process.media"
-            ));
-
-    /**
-     * Classes which we shouldn't load from the Zygote.
-     */
-    static final Set<String> EXCLUDED_CLASSES
-            = new HashSet<String>(Arrays.asList(
-        // Binders
-        "android.app.AlarmManager",
-        "android.app.SearchManager",
-        "android.os.FileObserver",
-        "com.android.server.PackageManagerService$AppDirObserver",
-
-        // Threads
-        "java.lang.ProcessManager",
-
-        // This class was deleted.
-        "java.math.Elementary"
-    ));
-
     /** Parent process. */
     final Proc parent;
 
@@ -139,17 +96,12 @@
     }
 
     /**
-     * Is this a long running process?
-     */
-    boolean isService() {
-        return SERVICES.contains(this.name);
-    }
-
-    /**
      * Returns a list of classes which should be preloaded.
+     * 
+     * @param takeAllClasses forces all classes to be taken (irrespective of ranking)
      */
-    List<LoadedClass> highestRankedClasses() {
-        if (NOT_FROM_ZYGOTE.contains(this.name)) {
+    List<LoadedClass> highestRankedClasses(boolean takeAllClasses) {
+        if (!isApplication()) {
             return Collections.emptyList();
         }
 
@@ -162,23 +114,30 @@
         int timeToSave = totalTimeMicros() * percentageToPreload() / 100;
         int timeSaved = 0;
 
-        boolean service = isService();
+        boolean service = Policy.isService(this.name);
 
         List<LoadedClass> highest = new ArrayList<LoadedClass>();
         for (Operation operation : ranked) {
-            if (highest.size() >= MAX_TO_PRELOAD) {
-                System.out.println(name + " got "
-                        + (timeSaved * 100 / timeToSave) + "% through");
-
-                break;
+            
+            // These are actual ranking decisions, which can be overridden
+            if (!takeAllClasses) {
+                if (highest.size() >= MAX_TO_PRELOAD) {
+                    System.out.println(name + " got " 
+                            + (timeSaved * 100 / timeToSave) + "% through");
+                    break;
+                }
+    
+                if (timeSaved >= timeToSave) {
+                    break;
+                }
             }
 
-            if (timeSaved >= timeToSave) {
-                break;
+            // The remaining rules apply even to wired-down processes
+            if (!Policy.isPreloadableClass(operation.loadedClass.name)) {
+                continue;
             }
-
-            if (EXCLUDED_CLASSES.contains(operation.loadedClass.name)
-                    || !operation.loadedClass.systemClass) {
+            
+            if (!operation.loadedClass.systemClass) {
                 continue;
             }
 
@@ -205,9 +164,13 @@
         return totalTime;
     }
 
-    /** Returns true if this process is an app. */
+    /** 
+     * Returns true if this process is an app.
+     *      
+     * TODO: Replace the hardcoded list with a walk up the parent chain looking for zygote.
+     */
     public boolean isApplication() {
-        return !NOT_FROM_ZYGOTE.contains(name);
+        return Policy.isFromZygote(name);
     }
 
     /**
diff --git a/tools/preload/Record.java b/tools/preload/Record.java
index 9ffab46..b2be4d4 100644
--- a/tools/preload/Record.java
+++ b/tools/preload/Record.java
@@ -56,11 +56,14 @@
 
     /** Record time (ns). */
     final long time;
+    
+    /** Source file line# */
+    int sourceLineNumber;
 
     /**
      * Parses a line from the loaded-classes file.
      */
-    Record(String line) {
+    Record(String line, int lineNum) {
         char typeChar = line.charAt(0);
         switch (typeChar) {
             case '>': type = Type.START_LOAD; break;
@@ -70,6 +73,8 @@
             default: throw new AssertionError("Bad line: " + line);
         }
 
+        sourceLineNumber = lineNum;
+        
         line = line.substring(1);
         String[] parts = line.split(":");
 
@@ -77,20 +82,51 @@
         pid = Integer.parseInt(parts[1]);
         tid = Integer.parseInt(parts[2]);
 
-        processName = parts[3].intern();
+        processName = decode(parts[3]).intern();
 
         classLoader = Integer.parseInt(parts[4]);
-        className = vmTypeToLanguage(parts[5]).intern();
+        className = vmTypeToLanguage(decode(parts[5])).intern();
 
         time = Long.parseLong(parts[6]);
     }
+    
+    /**
+     * Decode any escaping that may have been written to the log line.
+     * 
+     * Supports unicode-style escaping:  \\uXXXX = character in hex
+     * 
+     * @param rawField the field as it was written into the log
+     * @result the same field with any escaped characters replaced
+     */
+    String decode(String rawField) {
+        String result = rawField;
+        int offset = result.indexOf("\\u");
+        while (offset >= 0) {
+            String before = result.substring(0, offset);
+            String escaped = result.substring(offset+2, offset+6);
+            String after = result.substring(offset+6);
+            
+            result = String.format("%s%c%s", before, Integer.parseInt(escaped, 16), after);
+
+            // find another but don't recurse  
+            offset = result.indexOf("\\u", offset + 1);          
+        }
+        return result;
+    }
 
     /**
      * Converts a VM-style name to a language-style name.
      */
-    static String vmTypeToLanguage(String typeName) {
+    String vmTypeToLanguage(String typeName) {
+        // if the typename is (null), just return it as-is.  This is probably in dexopt and 
+        // will be discarded anyway.  NOTE: This corresponds to the case in dalvik/vm/oo/Class.c
+        // where dvmLinkClass() returns false and we clean up and exit.
+        if ("(null)".equals(typeName)) {
+            return typeName;
+        }
+        
         if (!typeName.startsWith("L") || !typeName.endsWith(";") ) {
-            throw new AssertionError("Bad name: " + typeName);
+            throw new AssertionError("Bad name: " + typeName + " in line " + sourceLineNumber);
         }
 
         typeName = typeName.substring(1, typeName.length() - 1);
diff --git a/tools/preload/WritePreloadedClassFile.java b/tools/preload/WritePreloadedClassFile.java
index 5596a62..d87b1f0 100644
--- a/tools/preload/WritePreloadedClassFile.java
+++ b/tools/preload/WritePreloadedClassFile.java
@@ -14,54 +14,69 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-import java.io.Writer;
 import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.List;
 
 /**
- * Writes /java/android/preloaded-classes. Also updates LoadedClass.preloaded
+ * Writes /frameworks/base/preloaded-classes. Also updates LoadedClass.preloaded
  * fields and writes over compiled log file.
  */
 public class WritePreloadedClassFile {
 
-    private static final String PRELOADED_CLASS_FILE
-            = "java/android/preloaded-classes";
-
-    public static void main(String[] args)
-            throws IOException, ClassNotFoundException {
-        if (args.length != 1) {
-            System.err.println(
-                    "Usage: WritePreloadedClassFile [compiled log file]");
+    public static void main(String[] args) throws IOException, ClassNotFoundException {
+        
+        // Process command-line arguments first
+        List<String> wiredProcesses = new ArrayList<String>();
+        String inputFileName = null;
+        int argOffset = 0;
+        try {
+            while ("--preload-all-process".equals(args[argOffset])) {
+                argOffset++;
+                wiredProcesses.add(args[argOffset++]);
+            }
+            
+            inputFileName = args[argOffset++];
+        } catch (RuntimeException e) {
+            System.err.println("Usage: WritePreloadedClassFile " +
+                    "[--preload-all-process process-name] " +
+                    "[compiled log file]");
             System.exit(0);
         }
 
-        Root root = Root.fromFile(args[0]);
+        Root root = Root.fromFile(inputFileName);
 
         for (LoadedClass loadedClass : root.loadedClasses.values()) {
             loadedClass.preloaded = false;
         }
 
         Writer out = new BufferedWriter(new OutputStreamWriter(
-                new FileOutputStream(PRELOADED_CLASS_FILE),
+                new FileOutputStream(Policy.getPreloadedClassFileName()),
                 Charset.forName("US-ASCII")));
 
-        out.write("# Classes which are preloaded by " +
-                "com.android.internal.os.ZygoteInit.\n");
-        out.write("# Automatically generated by /tools/preload.\n");
+        out.write("# Classes which are preloaded by com.android.internal.os.ZygoteInit.\n");
+        out.write("# Automatically generated by /frameworks/base/tools/preload.\n");
         out.write("# percent=" + Proc.PERCENTAGE_TO_PRELOAD + ", weight="
                 + ClassRank.SEQUENCE_WEIGHT
                 + ", bucket_size=" + ClassRank.BUCKET_SIZE
                 + "\n");
+        for (String wiredProcess : wiredProcesses) {
+            out.write("# forcing classes loaded by: " + wiredProcess + "\n");
+        }
 
         Set<LoadedClass> highestRanked = new TreeSet<LoadedClass>();
         for (Proc proc : root.processes.values()) {
-            List<LoadedClass> highestForProc = proc.highestRankedClasses();
+            // test to see if this is one of the wired-down ("take all classes") processes
+            boolean isWired = wiredProcesses.contains(proc.name);
+            
+            List<LoadedClass> highestForProc = proc.highestRankedClasses(isWired);
 
             System.out.println(proc.name + ": " + highestForProc.size());
 
@@ -82,6 +97,6 @@
                 + " classes will be preloaded.");
 
         // Update data to reflect LoadedClass.preloaded changes.
-        root.toFile(args[0]);
+        root.toFile(inputFileName);
     }
 }
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index e454cae..f9a0845 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -54,7 +54,7 @@
 
     boolean setWifiEnabled(boolean enable);
 
-    int getWifiState();
+    int getWifiEnabledState();
 
     int getNumAllowedChannels();
 
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index db989d0..483e0fa 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -605,7 +605,7 @@
      */
     public int getWifiState() {
         try {
-            return mService.getWifiState();
+            return mService.getWifiEnabledState();
         } catch (RemoteException e) {
             return WIFI_STATE_UNKNOWN;
         }
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java
index 8c9e5fa..1799560 100644
--- a/wifi/java/android/net/wifi/WifiMonitor.java
+++ b/wifi/java/android/net/wifi/WifiMonitor.java
@@ -150,19 +150,17 @@
 
                 String eventStr = WifiNative.waitForEvent();
 
-                if (Config.LOGD) {
-                    // Skip logging the common but mostly uninteresting scan-results event
-                    if (eventStr.indexOf(scanResultsEvent) == -1) {
-                        Log.v(TAG, "Event [" + eventStr +"]");
-                    }
-                }
                 if (eventStr == null) {
                     continue;
-                } else if (!eventStr.startsWith(eventPrefix)) {
-                    if (eventStr.startsWith(wpaEventPrefix)) {
-                        if (0 < eventStr.indexOf(passwordKeyMayBeIncorrectEvent)) {
-                            handlePasswordKeyMayBeIncorrect();
-                        }
+                }
+
+                // Skip logging the common but mostly uninteresting scan-results event
+                if (Config.LOGD && eventStr.indexOf(scanResultsEvent) == -1) {
+                    Log.v(TAG, "Event [" + eventStr + "]");
+                }
+                if (!eventStr.startsWith(eventPrefix)) {
+                    if (eventStr.startsWith(wpaEventPrefix) && 0 < eventStr.indexOf(passwordKeyMayBeIncorrectEvent)) {
+                        handlePasswordKeyMayBeIncorrect();
                     }
                     continue;
                 }
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 49021cd..2a47a71 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -89,6 +89,19 @@
 
     public native static boolean stopDriverCommand();
 
+    /**
+     * Start filtering out multicast packets, to reduce battery consumption
+     * that would result from processing them, only to discard them.
+     * @return {@code true} if the operation succeeded, {@code false} otherwise
+     */
+    public native static boolean startPacketFiltering();
+
+    /**
+     * Stop filtering out multicast packets.
+     * @return {@code true} if the operation succeeded, {@code false} otherwise
+     */
+    public native static boolean stopPacketFiltering();
+
     public native static boolean setPowerModeCommand(int mode);
 
     public native static boolean setNumAllowedChannelsCommand(int numChannels);
diff --git a/wifi/java/android/net/wifi/WifiStateTracker.java b/wifi/java/android/net/wifi/WifiStateTracker.java
index 9b96da0..0e70f8b 100644
--- a/wifi/java/android/net/wifi/WifiStateTracker.java
+++ b/wifi/java/android/net/wifi/WifiStateTracker.java
@@ -16,6 +16,7 @@
 
 package android.net.wifi;
 
+import android.app.ActivityManagerNative;
 import android.net.NetworkInfo;
 import android.net.NetworkStateTracker;
 import android.net.DhcpInfo;
@@ -159,7 +160,16 @@
     private boolean mHaveIPAddress;
     private boolean mObtainingIPAddress;
     private boolean mTornDownByConnMgr;
+    /**
+     * A DISCONNECT event has been received, but processing it
+     * is being deferred.
+     */
     private boolean mDisconnectPending;
+    /**
+     * An operation has been performed as a result of which we expect the next event
+     * will be a DISCONNECT.
+     */
+    private boolean mDisconnectExpected;
     private DhcpHandler mDhcpTarget;
     private DhcpInfo mDhcpInfo;
     private int mLastSignalLevel = -1;
@@ -379,8 +389,11 @@
      */
     public synchronized boolean isAvailable() {
         /*
-         * TODO: Should we also look at scan results to see whether we're
-         * in range of any access points?
+         * TODO: Need to also look at scan results to see whether we're
+         * in range of any access points. If we have scan results that
+         * are no more than N seconds old, use those, otherwise, initiate
+         * a scan and wait for the results. This only matters if we
+         * allow mobile to be the preferred network.
          */
         SupplicantState suppState = mWifiInfo.getSupplicantState();
         return suppState != SupplicantState.UNINITIALIZED &&
@@ -653,14 +666,25 @@
                     mLastSsid = mWifiInfo.getSSID();
                     configureInterface();
                 }
-                intent = new Intent(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
-                intent.putExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, true);
-                mContext.sendBroadcast(intent);
+                if (ActivityManagerNative.isSystemReady()) {
+                    intent = new Intent(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
+                    intent.putExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, true);
+                    mContext.sendBroadcast(intent);
+                }
                 if (supplState == SupplicantState.COMPLETED && mHaveIPAddress) {
                     setDetailedState(DetailedState.CONNECTED);
                 } else {
                     setDetailedState(WifiInfo.getDetailedStateOf(supplState));
                 }
+                /*
+                 * Filter out multicast packets. This saves battery power, since
+                 * the CPU doesn't have to spend time processing packets that
+                 * are going to end up being thrown away. Obviously, if we
+                 * ever want to support multicast, this will have to change.
+                 */
+                synchronized (this) {
+                    WifiNative.startPacketFiltering();
+                }
                 break;
 
             case EVENT_SUPPLICANT_DISCONNECT:
@@ -689,13 +713,18 @@
                     mDhcpTarget = null;
                 }
                 mContext.removeStickyBroadcast(new Intent(WifiManager.NETWORK_STATE_CHANGED_ACTION));
-                intent = new Intent(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
-                intent.putExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false);
-                mContext.sendBroadcast(intent);
+                if (ActivityManagerNative.isSystemReady()) {
+                    intent = new Intent(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
+                    intent.putExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, false);
+                    mContext.sendBroadcast(intent);
+                }
                 setDetailedState(DetailedState.DISCONNECTED);
                 setSupplicantState(SupplicantState.UNINITIALIZED);
                 mHaveIPAddress = false;
                 mObtainingIPAddress = false;
+                if (died) {
+                    mWM.setWifiEnabled(false);
+                }
                 break;
 
             case EVENT_SUPPLICANT_STATE_CHANGED:
@@ -749,13 +778,12 @@
                     setSupplicantState(newState);
                     if (newState == SupplicantState.DORMANT) {
                         DetailedState newDetailedState;
-                        if (!mIsScanOnly) {
-                            newDetailedState = DetailedState.FAILED;
-                        } else {
+                        if (mIsScanOnly || mRunState == RUN_STATE_STOPPING) {
                             newDetailedState = DetailedState.IDLE;
+                        } else {
+                            newDetailedState = DetailedState.FAILED;
                         }
                         handleDisconnectedState(newDetailedState);
-                        sendNetworkStateChangeBroadcast();
                         if (mRunState == RUN_STATE_RUNNING && !mIsScanOnly) {
                             sendEmptyMessageDelayed(EVENT_DEFERRED_RECONNECT, RECONNECT_DELAY_MSECS);
                         } else if (mRunState == RUN_STATE_STOPPING) {
@@ -768,9 +796,8 @@
                             }
                         }
                     } else if (newState == SupplicantState.DISCONNECTED) {
-                        if (isDriverStopped()) {
+                        if (isDriverStopped() || mDisconnectExpected) {
                             handleDisconnectedState(DetailedState.DISCONNECTED);
-                            sendNetworkStateChangeBroadcast();
                         } else {
                             scheduleDisconnect();
                         }
@@ -788,7 +815,9 @@
                         }
                     }
 
+                    mDisconnectExpected = false;
                     intent = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
+                    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
                     intent.putExtra(WifiManager.EXTRA_NEW_STATE, (Parcelable)newState);
                     if (failedToAuthenticate) {
                         if (LOCAL_LOGD) Log.d(TAG, "Failed to authenticate, disabling network " + networkId);
@@ -872,7 +901,7 @@
                          * The connection is fully configured as far as link-level
                          * connectivity is concerned, but we may still need to obtain
                          * an IP address. But do this only if we are connecting to
-                         * a different access point than we were connected to previously.
+                         * a different network than we were connected to previously.
                          */
                         if (wasDisconnectPending) {
                             DetailedState saveState = getNetworkInfo().getDetailedState();
@@ -890,11 +919,13 @@
                         setDetailedState(DetailedState.OBTAINING_IPADDR);
                     }
                 }
-                sendNetworkStateChangeBroadcast();
+                sendNetworkStateChangeBroadcast(mWifiInfo.getBSSID());
                 break;
 
             case EVENT_SCAN_RESULTS_AVAILABLE:
-                mContext.sendBroadcast(new Intent(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
+                if (ActivityManagerNative.isSystemReady()) {
+                    mContext.sendBroadcast(new Intent(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
+                }
                 sendScanResultsAvailable();
                 /**
                  * On receiving the first scan results after connecting to
@@ -956,7 +987,7 @@
                 mLastSignalLevel = -1; // force update of signal strength
                 if (mNetworkInfo.getDetailedState() != DetailedState.CONNECTED) {
                     setDetailedState(DetailedState.CONNECTED);
-                    sendNetworkStateChangeBroadcast();
+                    sendNetworkStateChangeBroadcast(mWifiInfo.getBSSID());
                 } else {
                     mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED);
                 }
@@ -1083,16 +1114,13 @@
         if (mDisconnectPending) {
             cancelDisconnect();
         }
-        Intent intent = new Intent(WifiManager.NETWORK_STATE_CHANGED_ACTION);
-        intent.putExtra(WifiManager.EXTRA_NETWORK_INFO, mNetworkInfo);
-        if (mLastBssid != null)
-            intent.putExtra(WifiManager.EXTRA_BSSID, mLastBssid);
+        mDisconnectExpected = false;
+        resetInterface();
+        setDetailedState(newState);
+        sendNetworkStateChangeBroadcast(mLastBssid);
         mWifiInfo.setBSSID(null);
         mLastBssid = null;
         mLastSsid = null;
-        resetInterface();
-        mContext.sendStickyBroadcast(intent);
-        setDetailedState(newState);
         mDisconnectPending = false;
     }
 
@@ -1246,16 +1274,19 @@
     }
 
     private void sendRssiChangeBroadcast(final int newRssi) {
-        Intent intent = new Intent(WifiManager.RSSI_CHANGED_ACTION);
-        intent.putExtra(WifiManager.EXTRA_NEW_RSSI, newRssi);
-        mContext.sendBroadcast(intent);
+        if (ActivityManagerNative.isSystemReady()) {
+            Intent intent = new Intent(WifiManager.RSSI_CHANGED_ACTION);
+            intent.putExtra(WifiManager.EXTRA_NEW_RSSI, newRssi);
+            mContext.sendBroadcast(intent);
+        }
     }
 
-    private void sendNetworkStateChangeBroadcast() {
+    private void sendNetworkStateChangeBroadcast(String bssid) {
         Intent intent = new Intent(WifiManager.NETWORK_STATE_CHANGED_ACTION);
+        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
         intent.putExtra(WifiManager.EXTRA_NETWORK_INFO, mNetworkInfo);
-        if (mWifiInfo.getBSSID() != null)
-            intent.putExtra(WifiManager.EXTRA_BSSID, mWifiInfo.getBSSID());
+        if (bssid != null)
+            intent.putExtra(WifiManager.EXTRA_BSSID, bssid);
         mContext.sendStickyBroadcast(intent);
     }
 
@@ -1292,11 +1323,28 @@
     }
 
     public synchronized boolean disconnectAndStop() {
-        // Take down any open network notifications
-        setNotificationVisible(false, 0, false, 0);
+        if (mRunState != RUN_STATE_STOPPING && mRunState != RUN_STATE_STOPPED) {
+            // Take down any open network notifications
+            setNotificationVisible(false, 0, false, 0);
 
-        mRunState = RUN_STATE_STOPPING;
-        return WifiNative.disconnectCommand();
+            mRunState = RUN_STATE_STOPPING;
+            return WifiNative.disconnectCommand();
+        } else {
+            /*
+             * The "driver-stop" wake lock normally is released from the
+             * connectivity manager after the mobile data connection has
+             * been established, or after a timeout period, if that never
+             * happens. Because WifiService.updateWifiState() can get called
+             * multiple times, we can end up acquiring the wake lock and calling
+             * disconnectAndStop() even when a disconnect or stop operation
+             * is already in progress. In that case, we want to ignore the
+             * disconnectAndStop request and release the (ref-counted) wake
+             * lock, so that eventually, when the mobile data connection is
+             * established, the ref count will drop to zero.
+             */
+            releaseWakeLock();
+        }
+        return true;
     }
 
     public synchronized boolean restart() {
@@ -1309,6 +1357,10 @@
         return true;
     }
 
+    public synchronized boolean removeNetwork(int networkId) {
+        return mDisconnectExpected = WifiNative.removeNetworkCommand(networkId);
+    }
+
     public boolean setRadio(boolean turnOn) {
         return mWM.setWifiEnabled(turnOn);
     }
@@ -1468,8 +1520,9 @@
     @Override
     public String toString() {
         StringBuffer sb = new StringBuffer();
+        sb.append("interface ").append(mInterfaceName).
+                append(" runState=").append(mRunState).append(LS);
         sb.append(mWifiInfo).append(LS);
-        sb.append("interface ").append(mInterfaceName).append(LS);
         sb.append(mDhcpInfo).append(LS);
         sb.append("haveIpAddress=").append(mHaveIPAddress).
                 append(", obtainingIpAddress=").append(mObtainingIPAddress).